private void adjustDateLineCrossingPoints() {
      ArrayList<LatLon> corners = new ArrayList<LatLon>(Arrays.asList(sw, se, nw, ne));
      if (!LatLon.locationsCrossDateLine(corners)) return;

      double lonSign = 0;
      for (LatLon corner : corners) {
        if (Math.abs(corner.getLongitude().degrees) != 180)
          lonSign = Math.signum(corner.getLongitude().degrees);
      }

      if (lonSign == 0) return;

      if (Math.abs(sw.getLongitude().degrees) == 180
          && Math.signum(sw.getLongitude().degrees) != lonSign)
        sw = new Position(sw.getLatitude(), sw.getLongitude().multiply(-1), sw.getElevation());
      if (Math.abs(se.getLongitude().degrees) == 180
          && Math.signum(se.getLongitude().degrees) != lonSign)
        se = new Position(se.getLatitude(), se.getLongitude().multiply(-1), se.getElevation());
      if (Math.abs(nw.getLongitude().degrees) == 180
          && Math.signum(nw.getLongitude().degrees) != lonSign)
        nw = new Position(nw.getLatitude(), nw.getLongitude().multiply(-1), nw.getElevation());
      if (Math.abs(ne.getLongitude().degrees) == 180
          && Math.signum(ne.getLongitude().degrees) != lonSign)
        ne = new Position(ne.getLatitude(), ne.getLongitude().multiply(-1), ne.getElevation());
    }
 public void setSwingDataCollection(Collection<ICFSecurityISOCountryObj> value) {
   final String S_ProcName = "setSwingDataCollection";
   swingDataCollection = value;
   if (swingDataCollection == null) {
     arrayOfISOCountry = new ICFSecurityISOCountryObj[0];
   } else {
     int len = value.size();
     arrayOfISOCountry = new ICFSecurityISOCountryObj[len];
     Iterator<ICFSecurityISOCountryObj> iter = swingDataCollection.iterator();
     int idx = 0;
     while (iter.hasNext() && (idx < len)) {
       arrayOfISOCountry[idx++] = iter.next();
     }
     if (idx < len) {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Collection iterator did not fully populate the array copy");
     }
     if (iter.hasNext()) {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Collection iterator had left over items when done populating array copy");
     }
     Arrays.sort(arrayOfISOCountry, compareISOCountryByQualName);
   }
   PickerTableModel tblDataModel = getDataModel();
   if (tblDataModel != null) {
     tblDataModel.fireTableDataChanged();
   }
 }
  private static void patchGtkDefaults(UIDefaults defaults) {
    if (!UIUtil.isUnderGTKLookAndFeel()) return;

    Map<String, Icon> map =
        ContainerUtil.newHashMap(
            Arrays.asList(
                "OptionPane.errorIcon",
                "OptionPane.informationIcon",
                "OptionPane.warningIcon",
                "OptionPane.questionIcon"),
            Arrays.asList(
                AllIcons.General.ErrorDialog,
                AllIcons.General.InformationDialog,
                AllIcons.General.WarningDialog,
                AllIcons.General.QuestionDialog));
    // GTK+ L&F keeps icons hidden in style
    SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON);
    for (String key : map.keySet()) {
      if (defaults.get(key) != null) continue;

      Object icon = style == null ? null : style.get(null, key);
      defaults.put(key, icon instanceof Icon ? icon : map.get(key));
    }

    Color fg = defaults.getColor("Label.foreground");
    Color bg = defaults.getColor("Label.background");
    if (fg != null && bg != null) {
      defaults.put("Label.disabledForeground", UIUtil.mix(fg, bg, 0.5));
    }
  }
Example #4
0
  /**
   * Sets the output text.
   *
   * @param t output text
   * @param s text size
   */
  public final void setText(final byte[] t, final int s) {
    // remove invalid characters and compare old with new string
    int ns = 0;
    final int ts = text.size();
    final byte[] tt = text.text();
    boolean eq = true;
    for (int r = 0; r < s; ++r) {
      final byte b = t[r];
      // support characters, highlighting codes, tabs and newlines
      if (b >= ' ' || b <= TokenBuilder.MARK || b == 0x09 || b == 0x0A) {
        t[ns++] = t[r];
      }
      eq &= ns < ts && ns < s && t[ns] == tt[ns];
    }
    eq &= ns == ts;

    // new text is different...
    if (!eq) {
      text = new BaseXTextTokens(Arrays.copyOf(t, ns));
      rend.setText(text);
      scroll.pos(0);
    }
    if (undo != null) undo.store(t.length != ns ? Arrays.copyOf(t, ns) : t, 0);
    SwingUtilities.invokeLater(calc);
  }
Example #5
0
  public MainPanel() {
    super(new BorderLayout());
    JPanel p = new JPanel(new GridLayout(2, 1));
    final JComboBox<String> c0 = makeComboBox(true, false);
    final JComboBox<String> c1 = makeComboBox(false, false);
    final JComboBox<String> c2 = makeComboBox(true, true);
    final JComboBox<String> c3 = makeComboBox(false, true);

    p.add(makeTitlePanel("setEditable(false)", Arrays.asList(c0, c1)));
    p.add(makeTitlePanel("setEditable(true)", Arrays.asList(c2, c3)));
    p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(p, BorderLayout.NORTH);
    add(
        new JButton(
            new AbstractAction("add") {
              @Override
              public void actionPerformed(ActionEvent e) {
                String str = new Date().toString();
                for (JComboBox<String> c : Arrays.asList(c0, c1, c2, c3)) {
                  MutableComboBoxModel<String> m = (MutableComboBoxModel<String>) c.getModel();
                  m.insertElementAt(str, m.getSize());
                }
              }
            }),
        BorderLayout.SOUTH);
    setPreferredSize(new Dimension(320, 240));
  }
  public List<String> find() throws IOException {
    //		Set<String> g1 = new HashSet<String>(Arrays.asList("HRAS", "NRAS", "KRAS"));
    //		Set<String> g2 = new HashSet<String>(Arrays.asList("BRAF"));

    Set<String> g1 = new HashSet<String>(Arrays.asList("HRAS"));
    Set<String> g2 = new HashSet<String>(Arrays.asList("NRAS", "KRAS"));

    Map<String, Double> pvals = calcDifferencePvals(g1, g2);

    System.out.println("pvals.size() = " + pvals.size());

    List<String> list = FDR.select(pvals, null, fdrThr);
    System.out.println("result size = " + list.size());

    Map<String, Boolean> dirs = getChangeDirections(list, g1, g2);

    int up = 0;
    int dw = 0;

    for (String gene : dirs.keySet()) {
      Boolean d = dirs.get(gene);
      if (d) up++;
      else dw++;
    }

    System.out.println("up = " + up);
    System.out.println("dw = " + dw);

    return list;
  }
  /**
   * setupPlayZone.
   *
   * @param p a {@link arcane.ui.PlayArea} object.
   * @param c an array of {@link forge.Card} objects.
   */
  public static void setupPlayZone(PlayArea p, Card c[]) {
    List<Card> tmp, diff;
    tmp = new ArrayList<Card>();
    for (arcane.ui.CardPanel cpa : p.cardPanels) tmp.add(cpa.gameCard);
    diff = new ArrayList<Card>(tmp);
    diff.removeAll(Arrays.asList(c));
    if (diff.size() == p.cardPanels.size()) p.clear();
    else {
      for (Card card : diff) {
        p.removeCardPanel(p.getCardPanel(card.getUniqueNumber()));
      }
    }
    diff = new ArrayList<Card>(Arrays.asList(c));
    diff.removeAll(tmp);

    arcane.ui.CardPanel toPanel = null;
    for (Card card : diff) {
      toPanel = p.addCard(card);
      Animation.moveCard(toPanel);
    }

    for (Card card : c) {
      toPanel = p.getCardPanel(card.getUniqueNumber());
      if (card.isTapped()) {
        toPanel.tapped = true;
        toPanel.tappedAngle = arcane.ui.CardPanel.TAPPED_ANGLE;
      } else {
        toPanel.tapped = false;
        toPanel.tappedAngle = 0;
      }
      toPanel.attachedPanels.clear();
      if (card.isEnchanted()) {
        ArrayList<Card> enchants = card.getEnchantedBy();
        for (Card e : enchants) {
          arcane.ui.CardPanel cardE = p.getCardPanel(e.getUniqueNumber());
          if (cardE != null) toPanel.attachedPanels.add(cardE);
        }
      }

      if (card.isEquipped()) {
        ArrayList<Card> enchants = card.getEquippedBy();
        for (Card e : enchants) {
          arcane.ui.CardPanel cardE = p.getCardPanel(e.getUniqueNumber());
          if (cardE != null) toPanel.attachedPanels.add(cardE);
        }
      }

      if (card.isEnchanting()) {
        toPanel.attachedToPanel = p.getCardPanel(card.getEnchanting().get(0).getUniqueNumber());
      } else if (card.isEquipping()) {
        toPanel.attachedToPanel = p.getCardPanel(card.getEquipping().get(0).getUniqueNumber());
      } else toPanel.attachedToPanel = null;

      toPanel.setCard(toPanel.gameCard);
    }
    p.invalidate();
    p.repaint();
  }
Example #8
0
  private static boolean matchFramework(
      ProjectCategory projectCategory, FrameworkSupportInModuleProvider framework) {

    FrameworkRole[] roles = framework.getRoles();
    if (roles.length == 0) return true;

    List<FrameworkRole> acceptable = Arrays.asList(projectCategory.getAcceptableFrameworkRoles());
    return ContainerUtil.intersects(Arrays.asList(roles), acceptable);
  }
    /**
     * Removes specific rows from the list of reading lists.
     *
     * @param aRows rows to remove.
     */
    public void removeRows(int[] aRows) {
      Arrays.sort(aRows);

      java.util.List<ReadingList> newLists = new ArrayList<ReadingList>(Arrays.asList(lists));
      for (int i = aRows.length - 1; i >= 0; i--) {
        newLists.remove(aRows[i]);
      }

      setLists(newLists.toArray(new ReadingList[newLists.size()]));
    }
 protected void stitchNeighbors(Set<Sector> neighbors, GeoPoint center) {
   assert gatedAssertion(
       neighbors.size() == 6
           || neighbors.size() == 5 && countDistinctGlobalSectors(neighbors) == 5);
   if (!sector.equals(neighbors.iterator().next())) {
     return;
   }
   Map<GeoPoint, GeoPoint> nextPoints = new HashMap<GeoPoint, GeoPoint>();
   Sector second = null;
   for (Sector s : neighbors) {
     char vertex = s.getVertex(center);
     Sector.Triangle cornerTriangle = s.getCornerTriangle(vertex);
     GeoPoint[] geoPoints = cornerTriangle.getPoints(vertex);
     nextPoints.put(geoPoints[1], geoPoints[2]);
     if (second == null && countShared(s.points, sector.points) == 1) {
       second = s;
     }
   }
   assert gatedAssertion(second != null);
   if (second != null) {
     GeoPoint[] acre = new GeoPoint[nextPoints.size()];
     GeoPoint point = nextPoints.values().iterator().next();
     for (int idx = 0; idx < nextPoints.size(); idx++) {
       assert !Arrays.asList(acre).contains(point);
       acre[idx] = point;
       point = nextPoints.get(point);
       assert gatedAssertion(point != null);
       if (point == null) {
         return;
       }
     }
     Sector[] others = new Sector[neighbors.size() - 2];
     int idx = 0;
     for (Sector s : neighbors) {
       if (s != sector && s != second) {
         others[idx++] = s;
       }
     }
     Acre newAcre = new Acre(1, sector, second, Arrays.asList(others), center, acre);
     CartographicElementView cartographicElementView = getFor(subdivisions);
     for (Sector s : neighbors) {
       char vertex = s.getVertex(center);
       assert vertex == 'A' || vertex == 'B' || vertex == 'C';
       Edge e = Edge.values()[vertex - 'A'];
       List<Acre> vertexAcre =
           cartographicElementView.get(
               s.getSharedAcres(), CartographicElementView.Position.Vertex, e, false);
       assert vertexAcre.size() == 1;
       assert vertexAcre.get(0) == null;
       vertexAcre.set(0, newAcre);
     }
     consume(newAcre);
   }
 }
  public final int readCharacter(final char[] allowed) throws IOException {
    // if we restrict to a limited set and the current character
    // is not in the set, then try again.
    char c;

    Arrays.sort(allowed); // always need to sort before binarySearch

    while (Arrays.binarySearch(allowed, c = (char) readVirtualKey()) < 0) ;

    return c;
  }
Example #12
0
 public TDTree(Point[] pts, boolean cd) {
   this();
   // for(Point p : pts)
   // insert(p);
   this.size = pts.length;
   // TreeNode newRoot = buildBalanced(new ArrayList<Point>(Arrays.asList(pts)), true);
   ArrayList<Point> xSorted = new ArrayList<Point>(Arrays.asList(pts));
   ArrayList<Point> ySorted = new ArrayList<Point>(Arrays.asList(pts));
   Collections.sort(xSorted, new PointComparator(true));
   Collections.sort(ySorted, new PointComparator(false));
   TreeNode newRoot = buildBalanced(xSorted, ySorted, cd);
   recalculateData(newRoot);
   root = newRoot;
 }
  private static HighlightVisitor[] filterVisitors(
      HighlightVisitor[] highlightVisitors, final PsiFile file) {
    final List<HighlightVisitor> visitors =
        new ArrayList<HighlightVisitor>(highlightVisitors.length);
    List<HighlightVisitor> list = Arrays.asList(highlightVisitors);
    for (HighlightVisitor visitor :
        DumbService.getInstance(file.getProject()).filterByDumbAwareness(list)) {
      if (visitor.suitableForFile(file)) visitors.add(visitor);
    }
    LOG.assertTrue(!visitors.isEmpty(), list);

    HighlightVisitor[] visitorArray = visitors.toArray(new HighlightVisitor[visitors.size()]);
    Arrays.sort(visitorArray, VISITOR_ORDER_COMPARATOR);
    return visitorArray;
  }
 Entry[] getParents() {
   List<Entry> list = new ArrayList<Entry>();
   getParents(list);
   Entry[] array = list.toArray(new Entry[list.size()]);
   Arrays.sort(array, new StandardUtilities.StringCompare<Entry>(true));
   return array;
 }
 public MyTableModel() {
   Vector<Vector<String>> rowData = new Vector<Vector<String>>();
   for (int i = 0; i < 1; i++) {
     Vector<String> colData = new Vector<String>(Arrays.asList("players.txt"));
     rowData.add(colData);
   }
 }
  /**
   * When the user has to specify file names, he can use wildcards (*, ?). This methods handles the
   * usage of these wildcards.
   *
   * @param path The path were to search
   * @param s Wilcards
   * @param sort Set to true will sort file names
   * @return An array of String which contains all files matching <code>s</code> in current
   *     directory.
   */
  public static String[] getWildCardMatches(String path, String s, boolean sort) {
    if (s == null) return null;

    String files[];
    String filesThatMatch[];
    String args = new String(s.trim());
    ArrayList filesThatMatchVector = new ArrayList();

    if (path == null) path = getUserDirectory();

    files = (new File(path)).list();
    if (files == null) return null;

    for (int i = 0; i < files.length; i++) {
      if (match(args, files[i])) {
        File temp = new File(getUserDirectory(), files[i]);
        filesThatMatchVector.add(new String(temp.getName()));
      }
    }

    Object[] o = filesThatMatchVector.toArray();
    filesThatMatch = new String[o.length];
    for (int i = 0; i < o.length; i++) filesThatMatch[i] = o[i].toString();
    o = null;
    filesThatMatchVector = null;

    if (sort) Arrays.sort(filesThatMatch);

    return filesThatMatch;
  }
Example #17
0
  private void autoscale() {

    int stateHash = FrameManager.getStateHash();

    //  if(lastFrameStateHash == stateHash) return;

    lastStateHash = stateHash;

    final Collection<Track> trackList = IGV.getInstance().getAllTracks();

    Map<String, List<Track>> autoscaleGroups = new HashMap<String, List<Track>>();

    for (Track track : trackList) {

      if (!track.isVisible()) continue;

      String asGroup = track.getAttributeValue(AttributeManager.GROUP_AUTOSCALE);
      if (asGroup != null) {
        if (!autoscaleGroups.containsKey(asGroup)) {
          autoscaleGroups.put(asGroup, new ArrayList<Track>());
        }
        autoscaleGroups.get(asGroup).add(track);
      } else if (track.getAutoScale()) {
        autoscaleGroup(Arrays.asList(track));
      }
    }

    if (autoscaleGroups.size() > 0) {
      for (List<Track> tracks : autoscaleGroups.values()) {
        autoscaleGroup(tracks);
      }
    }
  }
 public static <T> void assertUnorderedCollection(
     Collection<? extends T> collection, Consumer<T>... checkers) {
   Assert.assertNotNull(collection);
   if (collection.size() != checkers.length) {
     Assert.fail(toString(collection));
   }
   Set<Consumer<T>> checkerSet = new HashSet<Consumer<T>>(Arrays.asList(checkers));
   int i = 0;
   Throwable lastError = null;
   for (final T actual : collection) {
     boolean flag = true;
     for (final Consumer<T> condition : checkerSet) {
       Throwable error = accepts(condition, actual);
       if (error == null) {
         checkerSet.remove(condition);
         flag = false;
         break;
       } else {
         lastError = error;
       }
     }
     if (flag) {
       lastError.printStackTrace();
       Assert.fail("Incorrect element(" + i + "): " + actual);
     }
     i++;
   }
 }
  public NaturalBreaksClassifier(QueryResults qr, int numCategories, Color color1, Color color2) {
    double[] list = new double[qr.items.size()];

    Iterator<QueryResults.QueryResultItem> qrIt = qr.items.values().iterator();

    for (int i = 0; i < list.length; i++) {
      list[i] = qrIt.next().value;
    }

    Arrays.sort(list);

    // we can't classify into more bins than we have values
    if (numCategories > list.length) numCategories = list.length;

    double[] breaks = buildJenksBreaks(list, numCategories);

    if (breaks.length == 0) return;

    for (int i = 0; i < numCategories; i++) {
      // numcategories - 1: fencepost problem. The highest value should get color2
      Color c;
      if (numCategories > 1)
        c = interpolateColor(color1, color2, (float) ((float) i / (float) (numCategories - 1)));
      else c = interpolateColor(color1, color2, 0.5f);

      bins.add(new Bin(breaks[i], breaks[i + 1], c));
    }

    addPercentagesToBins(qr.maxPossible);

    bins.get(0).lower -= 0.00000001;
    bins.get(bins.size() - 1).upper += 0.00000001;
  }
    public AppFrame() {
      // Create the rectangular array of numeric values in the range from 0.0 to 1.0, inclusive, and
      // assign the
      // array a geographic sector.
      this.createRectangularArray();

      // Display the rectangular array of numeric values as a surface that maps each numeric value
      // to a hue, and
      // interpolates the colors between array points.
      RenderableLayer arrayLayer = new RenderableLayer();
      arrayLayer.setName("Rectangular Array");
      this.getWwd().getModel().getLayers().add(arrayLayer);
      this.addRectangularArrayShapes(arrayLayer);

      // Create a layer to group the contour line shapes.
      RenderableLayer contourLayer = new RenderableLayer();
      contourLayer.setName("Contour Lines");
      this.getWwd().getModel().getLayers().add(contourLayer);

      // Create a ContourBuilder with the rectangular array of numeric values as a one-dimensional
      // array of
      // floating point numbers. The contour builder assumes that the array is organized in
      // row-major order, with
      // the first value indicating the value at the upper-left corner.
      ContourBuilder cb = new ContourBuilder(this.arrayWidth, this.arrayHeight, this.arrayValues);

      // Build contour lines for a list of pre-determined threshold values. Contour line coordinates
      // are computed
      // by mapping the rectangular array's coordinates to a geographic sector.
      for (double value : Arrays.asList(0.083, 0.250, 0.416, 0.583, 0.75, 0.916)) {
        List<List<Position>> contourList =
            cb.buildContourLines(value, this.arraySector, 0); // altitude 0
        this.addContourShapes(contourList, value, contourLayer);
      }
    }
Example #21
0
  private void sort() {
    final Locale loc = getLocale();
    final Collator collator = Collator.getInstance(loc);
    final Comparator<Locale> comp =
        new Comparator<Locale>() {
          public int compare(Locale a, Locale b) {
            return collator.compare(a.getDisplayName(loc), b.getDisplayName(loc));
          }
        };
    Arrays.sort(locales, comp);
    setModel(
        new ComboBoxModel<Locale>() {
          public Locale getElementAt(int i) {
            return locales[i];
          }

          public int getSize() {
            return locales.length;
          }

          public void addListDataListener(ListDataListener l) {}

          public void removeListDataListener(ListDataListener l) {}

          public Locale getSelectedItem() {
            return selected >= 0 ? locales[selected] : null;
          }

          public void setSelectedItem(Object anItem) {
            if (anItem == null) selected = -1;
            else selected = Arrays.binarySearch(locales, (Locale) anItem, comp);
          }
        });
    setSelectedItem(selected);
  }
Example #22
0
  private void updateDebugPanelState(String result, boolean debug, boolean test) {
    result = result == null ? "nothing" : result;

    List<Component> componentList = Arrays.asList(getComponents());
    if (!componentList.contains(p_debug)) {

      choice = new Label(String.format("Your choice is: %s", result));
      isDebug = new Label(String.format("Debug mode: %b", debug));
      isTest = new Label(String.format("Test mode: %b", test));
      GridBagLayout layout = new GridBagLayout();
      GridBagConstraints constraints = new GridBagConstraints();
      layout.setConstraints(choice, constraints);
      constraints.gridy = 1;
      layout.setConstraints(isDebug, constraints);
      constraints.gridy = 2;
      layout.setConstraints(isTest, constraints);

      p_debug.setLayout(layout);
      p_debug.add(choice);
      p_debug.add(isDebug);
      p_debug.add(isTest);
      add(p_debug, BorderLayout.SOUTH);

    } else {
      choice.setText(String.format("Your choice is: %s", result));
      isDebug.setText(String.format("Debug mode: %b", debug));
      isTest.setText(String.format("Test mode: %b", test));
    }
  }
  @SuppressWarnings("OverlyBroadCatchBlock")
  private void multiCast(@NotNull Method method, Object[] args) {
    try {
      method.invoke(myBus.syncPublisher(AppTopics.FILE_DOCUMENT_SYNC), args);
    } catch (ClassCastException e) {
      LOG.error("Arguments: " + Arrays.toString(args), e);
    } catch (Exception e) {
      LOG.error(e);
    }

    // Allows pre-save document modification
    for (FileDocumentManagerListener listener : getListeners()) {
      try {
        method.invoke(listener, args);
      } catch (Exception e) {
        LOG.error(e);
      }
    }

    // stripping trailing spaces
    try {
      method.invoke(myTrailingSpacesStripper, args);
    } catch (Exception e) {
      LOG.error(e);
    }
  }
  private static void patchHiDPI(UIDefaults defaults) {
    if (!JBUI.isHiDPI()) return;

    List<String> myIntKeys = Arrays.asList("Tree.leftChildIndent", "Tree.rightChildIndent");
    List<String> patched = new ArrayList<String>();
    for (Map.Entry<Object, Object> entry : defaults.entrySet()) {
      Object value = entry.getValue();
      String key = entry.getKey().toString();
      if (value instanceof DimensionUIResource) {
        entry.setValue(JBUI.size((DimensionUIResource) value).asUIResource());
      } else if (value instanceof InsetsUIResource) {
        entry.setValue(JBUI.insets(((InsetsUIResource) value)).asUIResource());
      } else if (value instanceof Integer) {
        if (key.endsWith(".maxGutterIconWidth") || myIntKeys.contains(key)) {
          if (!"true".equals(defaults.get(key + ".hidpi.patched"))) {
            entry.setValue(Integer.valueOf(JBUI.scale((Integer) value)));
            patched.add(key);
          }
        }
      }
    }
    for (String key : patched) {
      defaults.put(key + ".hidpi.patched", "true");
    }
  }
Example #25
0
  /**
   * Paint to an offscreen graphic, e.g. a graphic for an image or svg file.
   *
   * @param g
   * @param rect
   */
  public void paintOffscreen(Graphics2D g, Rectangle rect) {

    // Get the components of the sort by X position.
    Component[] components = getComponents();
    Arrays.sort(
        components,
        new Comparator<Component>() {
          public int compare(Component component, Component component1) {
            return component.getX() - component1.getX();
          }
        });

    for (Component c : this.getComponents()) {

      if (c instanceof DataPanel) {
        Graphics2D g2d = (Graphics2D) g.create();
        Rectangle clipRect = new Rectangle(c.getBounds());
        clipRect.height = rect.height;
        g2d.setClip(clipRect);
        g2d.translate(c.getX(), 0);
        ((DataPanel) c).paintOffscreen(g2d, rect);
      }
    }
    // super.paintBorder(g);
  }
Example #26
0
 // Sorts labels from the mapping.  We may get rid of this later perhaps.
 String[] revisedLabels(HashMap map) {
   // Sort labels
   String[] labels = new String[map.size()];
   labels = (String[]) (map.keySet().toArray(labels));
   Arrays.sort(labels);
   return labels;
 }
 public void loadData(boolean forceReload) {
   ICFFreeSwitchSchemaObj schemaObj = swingSchema.getSchema();
   if ((containingCluster == null) || forceReload) {
     CFSecurityAuthorization auth = schemaObj.getAuthorization();
     long containingClusterId = auth.getSecClusterId();
     containingCluster = schemaObj.getClusterTableObj().readClusterByIdIdx(containingClusterId);
   }
   if ((listOfTenant == null) || forceReload) {
     arrayOfTenant = null;
     listOfTenant =
         schemaObj
             .getTenantTableObj()
             .readTenantByClusterIdx(containingCluster.getRequiredId(), swingIsInitializing);
     if (listOfTenant != null) {
       Object objArray[] = listOfTenant.toArray();
       if (objArray != null) {
         int len = objArray.length;
         arrayOfTenant = new ICFSecurityTenantObj[len];
         for (int i = 0; i < len; i++) {
           arrayOfTenant[i] = (ICFSecurityTenantObj) objArray[i];
         }
         Arrays.sort(arrayOfTenant, compareTenantByQualName);
       }
     }
   }
 }
  /**
   * Calls all public methods declared in the class corresponding to the given object. Does not
   * include methods from superclasses.
   *
   * @param object object to call the public methods on
   * @param comparator method comparator, allows running the methods in a specific order
   * @return list of methods invoked, including the parameters used for calling them
   */
  private static List<MethodInvocation> callPublicMethodsInOrder(
      Object object, Comparator<Method> comparator) {
    try {
      List<MethodInvocation> invocations = new ArrayList<>();
      Method[] methods = object.getClass().getDeclaredMethods();
      if (comparator != null) Arrays.sort(methods, comparator);

      for (Method method : methods) {
        if (Modifier.isStatic(method.getModifiers()) || !Modifier.isPublic(method.getModifiers()))
          continue;

        Object[] params = new Object[method.getParameterTypes().length];
        for (int i = 0; i < method.getParameterTypes().length; i++) {
          params[i] = instantiateType(method.getParameterTypes()[i]);
        }
        method.invoke(object, params);
        invocations.add(new MethodInvocation(method.getName(), params));
      }
      return invocations;
    } catch (Exception ex) {
      ex.printStackTrace();
      assertTrue(
          "Error calling public methods on object "
              + object
              + " ("
              + object.getClass().getSimpleName()
              + ")",
          false);
      return new ArrayList<>();
    }
  }
  /**
   * Move the cursor <i>where</i> characters, withough checking the current buffer.
   *
   * @see #where
   * @param where the number of characters to move to the right or left.
   */
  private final void moveInternal(final int where) throws IOException {
    // debug ("move cursor " + where + " ("
    // + buf.cursor + " => " + (buf.cursor + where) + ")");
    buf.cursor += where;

    char c;

    if (where < 0) {
      int len = 0;
      for (int i = buf.cursor; i < buf.cursor - where; i++) {
        if (buf.getBuffer().charAt(i) == '\t') len += TAB_WIDTH;
        else len++;
      }

      char cbuf[] = new char[len];
      Arrays.fill(cbuf, BACKSPACE);
      out.write(cbuf);

      return;
    } else if (buf.cursor == 0) {
      return;
    } else if (mask != null) {
      c = mask.charValue();
    } else {
      printCharacters(buf.buffer.substring(buf.cursor - where, buf.cursor).toCharArray());
      return;
    }

    // null character mask: don't output anything
    if (NULL_MASK.equals(mask)) {
      return;
    }

    printCharacters(c, Math.abs(where));
  }
 /** {@inheritDoc} */
 public Iterable<AVList> getLinks() {
   if (this.webViewWindowPtr != 0) {
     AVList[] links = WindowsWebViewJNI.getLinks(this.webViewWindowPtr);
     if (links != null) return Arrays.asList(links);
   }
   return Collections.emptyList();
 }