Ejemplo n.º 1
0
 // Note: this comparator imposes orderings that are inconsistent with equals.
 public int compare(String a, String b) {
   if (base.get(a) >= base.get(b)) {
     return -1;
   } else {
     return 1;
   } // returning 0 would merge keys
 }
 public UpdateOrStatusOptionsDialog(Project project, Map<Configurable, AbstractVcs> confs) {
   super(project);
   setTitle(getRealTitle());
   myProject = project;
   if (confs.size() == 1) {
     myMainPanel = new JPanel(new BorderLayout());
     final Configurable configurable = confs.keySet().iterator().next();
     addComponent(confs.get(configurable), configurable, BorderLayout.CENTER);
     myMainPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
   } else {
     myMainPanel = new JBTabbedPane();
     final ArrayList<AbstractVcs> vcses = new ArrayList<>(confs.values());
     Collections.sort(
         vcses,
         new Comparator<AbstractVcs>() {
           public int compare(final AbstractVcs o1, final AbstractVcs o2) {
             return o1.getDisplayName().compareTo(o2.getDisplayName());
           }
         });
     Map<AbstractVcs, Configurable> vcsToConfigurable = revertMap(confs);
     for (AbstractVcs vcs : vcses) {
       addComponent(vcs, vcsToConfigurable.get(vcs), vcs.getDisplayName());
     }
   }
   init();
 }
Ejemplo n.º 3
0
    @Override
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

      // Get the renderer component from parent class

      JLabel label =
          (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

      // Get icon to use for the list item value
      Character character = (Character) value;
      Config.ConfigEntry ce = config.get(character.getName());
      Icon icon = null;

      if (ce == null) {
        icon = icons.get(NOTOK);
        label.setToolTipText(
            "Double-click to enter configuration information for this character, right-click for more options");
      } else {
        if (ce.isOk()) {
          icon = icons.get(OK);
          ui.exportAllButton.setEnabled(true);
        } else {
          icon = icons.get(NOTOK);
        }
      }
      // Set icon to display for value

      label.setIcon(icon);
      return label;
    }
Ejemplo n.º 4
0
 @Nullable
 public HighlightSeverity getSeverity(@NotNull String name) {
   final HighlightInfoType type = STANDARD_SEVERITIES.get(name);
   if (type != null) return type.getSeverity(null);
   final SeverityBasedTextAttributes attributes = myMap.get(name);
   if (attributes != null) return attributes.getSeverity();
   return null;
 }
 @Override
 public Font getFont(EditorFontType key) {
   if (UISettings.getInstance().PRESENTATION_MODE) {
     final Font font = myFonts.get(key);
     return new Font(
         font.getName(), font.getStyle(), UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE);
   }
   return myFonts.get(key);
 }
 private void reloadSdk(@NotNull Sdk currentSdk) {
   /* PythonSdkUpdater.update invalidates the modificator so we need to create a new
    one for further changes
   */
   if (PythonSdkUpdater.update(currentSdk, myModificators.get(currentSdk), myProject, null)) {
     myModifiedModificators.remove(myModificators.get(currentSdk));
     myModificators.put(currentSdk, currentSdk.getSdkModificator());
   }
 }
 /** highlight a route (maybe to show it's in use...) */
 public void highlightRoute(String src, String dst) {
   Iterator i = rows.iterator();
   while (i.hasNext()) {
     Map temp = (Map) i.next();
     if (temp.get("Address").equals(dst) && temp.get("Pivot").equals(src)) {
       temp.put("Active", Boolean.TRUE);
     }
   }
 }
Ejemplo n.º 8
0
  public void showTask(String sTaskClass) {

    m_appview.waitCursorBegin();

    if (m_appuser.hasPermission(sTaskClass)) {

      JPanelView m_jMyView = (JPanelView) m_aCreatedViews.get(sTaskClass);

      // cierro la antigua
      if (m_jLastView == null || (m_jMyView != m_jLastView && m_jLastView.deactivate())) {

        // Construct the new view
        if (m_jMyView == null) {

          // Is the view prepared
          m_jMyView = m_aPreparedViews.get(sTaskClass);
          if (m_jMyView == null) {
            // The view is not prepared. Try to get as a Bean...
            try {
              m_jMyView = (JPanelView) m_appview.getBean(sTaskClass);
            } catch (BeanFactoryException e) {
              m_jMyView = new JPanelNull(m_appview, e);
            }
          }

          m_jPanelContainer.add(m_jMyView.getComponent(), sTaskClass);
          m_aCreatedViews.put(sTaskClass, m_jMyView);
        }

        // ejecuto la tarea
        try {
          m_jMyView.activate();
        } catch (BasicException e) {
          JMessageDialog.showMessage(
              this,
              new MessageInf(
                  MessageInf.SGN_WARNING, AppLocal.getIntString("message.notactive"), e));
        }

        // se tiene que mostrar el panel
        m_jLastView = m_jMyView;

        showView(sTaskClass);
        // Y ahora que he cerrado la antigua me abro yo
        String sTitle = m_jMyView.getTitle();
        m_jPanelTitle.setVisible(sTitle != null);
        m_jTitle.setText(sTitle);
      }
    } else {
      // No hay permisos para ejecutar la accion...
      JMessageDialog.showMessage(
          this,
          new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.notpermissions")));
    }
    m_appview.waitCursorEnd();
  }
Ejemplo n.º 9
0
  /**
   * Loads the list of enabled and disabled encryption protocols with their priority.
   *
   * @param enabledEncryptionProtocols The list of enabled encryption protocol available for this
   *     account.
   * @param disabledEncryptionProtocols The list of disabled encryption protocol available for this
   *     account.
   */
  private void loadEncryptionProtocols(
      Map<String, Integer> encryptionProtocols, Map<String, Boolean> encryptionProtocolStatus) {
    int nbEncryptionProtocols = ENCRYPTION_PROTOCOLS.length;
    String[] encryptions = new String[nbEncryptionProtocols];
    boolean[] selectedEncryptions = new boolean[nbEncryptionProtocols];

    // Load stored values.
    int prefixeLength = ProtocolProviderFactory.ENCRYPTION_PROTOCOL.length() + 1;
    String encryptionProtocolPropertyName;
    String name;
    int index;
    boolean enabled;
    Iterator<String> encryptionProtocolNames = encryptionProtocols.keySet().iterator();
    while (encryptionProtocolNames.hasNext()) {
      encryptionProtocolPropertyName = encryptionProtocolNames.next();
      index = encryptionProtocols.get(encryptionProtocolPropertyName);
      // If the property is set.
      if (index != -1) {
        name = encryptionProtocolPropertyName.substring(prefixeLength);
        if (isExistingEncryptionProtocol(name)) {
          enabled =
              encryptionProtocolStatus.get(
                  ProtocolProviderFactory.ENCRYPTION_PROTOCOL_STATUS + "." + name);
          encryptions[index] = name;
          selectedEncryptions[index] = enabled;
        }
      }
    }

    // Load default values.
    String encryptionProtocol;
    boolean set;
    int j = 0;
    for (int i = 0; i < ENCRYPTION_PROTOCOLS.length; ++i) {
      encryptionProtocol = ENCRYPTION_PROTOCOLS[i];
      // Specify a default value only if there is no specific value set.
      if (!encryptionProtocols.containsKey(
          ProtocolProviderFactory.ENCRYPTION_PROTOCOL + "." + encryptionProtocol)) {
        set = false;
        // Search for the first empty element.
        while (j < encryptions.length && !set) {
          if (encryptions[j] == null) {
            encryptions[j] = encryptionProtocol;
            // By default only ZRTP is set to true.
            selectedEncryptions[j] = encryptionProtocol.equals("ZRTP");
            set = true;
          }
          ++j;
        }
      }
    }

    this.encryptionConfigurationTableModel.init(encryptions, selectedEncryptions);
  }
Ejemplo n.º 10
0
 @Override
 public GridCellImpl getCellFor(final Content content) {
   // check if the content is already in some cell
   GridCellImpl current = myContent2Cell.get(content);
   if (current != null) return current;
   // view may be shared between several contents with the same ID in different cells
   // (temporary contents like "Dump Stack" or "Console Result")
   View view = getStateFor(content);
   final GridCellImpl cell = myPlaceInGrid2Cell.get(view.getPlaceInGrid());
   assert cell != null : "Unknown place in grid: " + view.getPlaceInGrid().name();
   return cell;
 }
Ejemplo n.º 11
0
 private void run(int thisStep, GeoPoint a, GeoPoint b, GeoPoint c) {
   Acre[] innerAcres;
   switch (thisStep) {
     case 0:
       nextStep = 5;
       for (int i = 1; i < 5; i++) {
         run(i, a, b, c);
       }
       break;
     case 1:
       innerAcres = buildInnerAcres();
       assert sector.getInnerAcres().length == innerAcres.length;
       System.arraycopy(innerAcres, 0, sector.getInnerAcres(), 0, innerAcres.length);
       break;
     case 2:
       neighborsA = getNeighbors(sectorMap.get(a));
       neighborsB = getNeighbors(sectorMap.get(b));
       neighborsC = getNeighbors(sectorMap.get(c));
       break;
     case 3:
       stitchNeighbors(Edge.AB, neighborsA, a, neighborsB, b);
       stitchNeighbors(Edge.BC, neighborsB, b, neighborsC, c);
       stitchNeighbors(Edge.CA, neighborsC, c, neighborsA, a);
       break;
     case 4:
       stitchNeighbors(neighborsA, a);
       stitchNeighbors(neighborsB, b);
       stitchNeighbors(neighborsC, c);
       break;
     case 100:
       addNeighbors(Edge.AB, neighborsA, a, neighborsB, b);
       addNeighbors(Edge.BC, neighborsB, b, neighborsC, c);
       addNeighbors(Edge.CA, neighborsC, c, neighborsA, a);
       break;
     case 200:
       assignVertexIds();
       break;
     case 999:
       neighborsA = null;
       neighborsB = null;
       neighborsC = null;
       break;
     case 1000:
       acreSeamSeqAccessor = null;
       globalPointMap = null;
       pointLocator = null;
       break;
   }
   if (nextStep < 5) {
     workQueue.addWorkUnit(this);
   }
 }
Ejemplo n.º 12
0
  private void configChanged(String activeConfig) {
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    model.addElement("");
    SortedSet<String> alphaConfigs =
        new TreeSet<String>(
            new Comparator<String>() {
              Collator coll = Collator.getInstance();

              public int compare(String s1, String s2) {
                return coll.compare(label(s1), label(s2));
              }

              private String label(String c) {
                Map<String, String> m = configs.get(c);
                String label = m.get("$label"); // NOI18N
                return label != null ? label : c;
              }
            });
    for (Map.Entry<String, Map<String, String>> entry : configs.entrySet()) {
      String config = entry.getKey();
      if (config != null && entry.getValue() != null) {
        alphaConfigs.add(config);
      }
    }
    for (String c : alphaConfigs) {
      model.addElement(c);
    }
    configCombo.setModel(model);
    configCombo.setSelectedItem(activeConfig != null ? activeConfig : "");
    Map<String, String> m = configs.get(activeConfig);
    Map<String, String> def = configs.get(null);
    if (m != null) {
      // BEGIN Deprecated
      if (compProviderDeprecated != null) {
        compProviderDeprecated.configUpdated(m);
      }
      // END Deprecated
      for (J2SECategoryExtensionProvider compProvider : compProviders) {
        compProvider.configUpdated(m);
      }
      for (int i = 0; i < data.length; i++) {
        String v = m.get(keys[i]);
        if (v == null) {
          // display default value
          v = def.get(keys[i]);
        }
        data[i].setText(v);
      }
    } // else ??
    configDel.setEnabled(activeConfig != null);
  }
Ejemplo n.º 13
0
  public boolean match() {
    if (robot.getOthers() > 5 || targetManager.getAliveTargetCount() == 0) {
      return false;
    }
    Map<Target, Double> dists = new HashMap<Target, Double>();
    final java.util.List<Target> aliveTargets = targetManager.getAliveTargets();
    for (Target t : aliveTargets) {
      final Target closest = targetManager.getClosestTergetToT(t);
      if (closest == null) {
        return false;
      }
      dists.put(t, closest.aDistance(t) + 80);
    }

    LXXPoint candidate = dest;
    Target closest = targetManager.getClosestTarget();
    for (int i = 0; i < 20; i++) {
      double angle =
          Utils.angle(closest.getPosition(), robot.getPosition())
              + Math.random() * LXXConstants.RADIANS_20
              - LXXConstants.RADIANS_10;
      double dist = dists.get(closest);

      if (candidate == null) {
        candidate =
            new LXXPoint(closest.getX() + sin(angle) * dist, closest.getY() + cos(angle) * dist);
      }

      for (Target t : aliveTargets) {
        final double d = t.aDistance(candidate);
        if (d < dists.get(t)) {
          candidate = null;
          break;
        }
      }
      if (candidate != null && robot.getBattleField().contains(candidate)) {
        break;
      }

      candidate =
          new LXXPoint(closest.getX() + sin(angle) * dist, closest.getY() + cos(angle) * dist);
    }

    dest = candidate;

    return candidate != null
        && robot.getBattleField().contains(candidate)
        && StaticData.robot.getDestination().aDistance(dest) > 20;
  }
Ejemplo n.º 14
0
  /** Draws the game */
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    final Graphics2D g2 = (Graphics2D) g;

    /** Draw all the non-falling blocks on the board. Non-OUTSIDE blocks have rounded corners. */
    for (int row = 0; row < board.getHeight(); row++) {
      for (int column = 0; column < board.getWidth(); column++) {
        if (board.getSquareType(row, column) != SquareType.OUTSIDE) {
          Shape tetrominoBlock =
              new RoundRectangle2D.Double(
                  column * SQUARE_WIDTH, row * SQUARE_HEIGHT, SQUARE_WIDTH, SQUARE_HEIGHT, 5, 5);
          g2.setColor(SQUARE_COLOR.get(board.getSquareType(row, column)));
          g2.fill(tetrominoBlock);
          g2.draw(tetrominoBlock);
        } else {
          Shape tetrominoBlock =
              new Rectangle2D.Double(
                  column * SQUARE_WIDTH, row * SQUARE_HEIGHT, SQUARE_WIDTH, SQUARE_HEIGHT);
          g2.setColor(SQUARE_COLOR.get(board.getSquareType(row, column)));
          g2.fill(tetrominoBlock);
          g2.draw(tetrominoBlock);
        }
      }
    }

    Poly tempPoly = board.getFalling();
    if (tempPoly != null) {

      for (int row = 0; row < tempPoly.getSize(); row++) {
        for (int column = 0; column < tempPoly.getSize(); column++) {
          if (tempPoly.getSquareType(row, column) != SquareType.EMPTY) {
            Shape tetrominoBlock =
                new RoundRectangle2D.Double(
                    (column + board.getFallingPosX()) * SQUARE_WIDTH,
                    (row + board.getFallingPosY()) * SQUARE_HEIGHT,
                    SQUARE_WIDTH,
                    SQUARE_HEIGHT,
                    5,
                    5);
            g2.setColor(SQUARE_COLOR.get(tempPoly.getSquareType(row, column)));
            g2.fill(tetrominoBlock);
            g2.draw(tetrominoBlock);
          }
        }
      }
    }
  }
  @Override
  public void mouseMoved(MouseEvent e) {
    Component source = e.getComponent();
    Point location = e.getPoint();
    direction = 0;

    if (location.x < dragInsets.left) direction += WEST;

    if (location.x > source.getWidth() - dragInsets.right - 1) direction += EAST;

    if (location.y < dragInsets.top) direction += NORTH;

    if (location.y > source.getHeight() - dragInsets.bottom - 1) direction += SOUTH;

    //  Mouse is no longer over a resizable border

    if (direction == 0) {
      source.setCursor(sourceCursor);
    } else // use the appropriate resizable cursor
    {
      int cursorType = cursors.get(direction);
      Cursor cursor = Cursor.getPredefinedCursor(cursorType);
      source.setCursor(cursor);
    }
  }
  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;
  }
Ejemplo n.º 17
0
  @Override
  public void writeExternal(Element element) throws WriteExternalException {
    List<HighlightSeverity> list = getOrderAsList(getOrderMap());
    for (HighlightSeverity severity : list) {
      Element info = new Element(INFO_TAG);
      String severityName = severity.getName();
      final SeverityBasedTextAttributes infoType = getAttributesBySeverity(severity);
      if (infoType != null) {
        infoType.writeExternal(info);
        final Color color = myRendererColors.get(severityName);
        if (color != null) {
          info.setAttribute(COLOR_ATTRIBUTE, Integer.toString(color.getRGB() & 0xFFFFFF, 16));
        }
        element.addContent(info);
      }
    }

    if (myReadOrder != null && !myReadOrder.isEmpty()) {
      myReadOrder.writeExternal(element);
    } else if (!getDefaultOrder().equals(list)) {
      final JDOMExternalizableStringList ext =
          new JDOMExternalizableStringList(Collections.nCopies(getOrderMap().size(), ""));
      getOrderMap()
          .forEachEntry(
              new TObjectIntProcedure<HighlightSeverity>() {
                @Override
                public boolean execute(HighlightSeverity orderSeverity, int oIdx) {
                  ext.set(oIdx, orderSeverity.getName());
                  return true;
                }
              });
      ext.writeExternal(element);
    }
  }
Ejemplo n.º 18
0
  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));
    }
  }
 @NotNull
 private InspectionTreeNode getToolParentNode(
     @NotNull String groupName, HighlightDisplayLevel errorLevel, boolean groupedBySeverity) {
   if (groupName.isEmpty()) {
     return getRelativeRootNode(groupedBySeverity, errorLevel);
   }
   ConcurrentMap<String, InspectionGroupNode> map = myGroups.get(errorLevel);
   if (map == null) {
     map =
         ConcurrencyUtil.cacheOrGet(
             myGroups, errorLevel, ContainerUtil.<String, InspectionGroupNode>newConcurrentMap());
   }
   InspectionGroupNode group;
   if (groupedBySeverity) {
     group = map.get(groupName);
   } else {
     group = null;
     for (Map<String, InspectionGroupNode> groupMap : myGroups.values()) {
       if ((group = groupMap.get(groupName)) != null) break;
     }
   }
   if (group == null) {
     group = ConcurrencyUtil.cacheOrGet(map, groupName, new InspectionGroupNode(groupName));
     addChildNodeInEDT(getRelativeRootNode(groupedBySeverity, errorLevel), group);
   }
   return group;
 }
 void finish(BddtHistoryItem hi) {
   GraphBlock gb = in_blocks.get(hi.getThread());
   if (gb != null) {
     gb.finish(hi.getTime());
     in_blocks.remove(hi.getThread());
   }
 }
  private Color getThreadBlockColor(BumpThread bt) {
    if (bt == null) return Color.BLACK;

    synchronized (thread_colors) {
      Color c = thread_colors.get(bt);
      if (c == null) {
        double v;
        int ct = thread_colors.size();
        if (ct == 0) v = 0;
        else if (ct == 1) v = 1;
        else {
          v = 0.5;
          int p0 = ct - 1;
          int p1 = 1;
          for (int p = p0; p > 1; p /= 2) {
            v /= 2.0;
            p0 -= p1;
            p1 *= 2;
          }
          if ((p0 & 1) == 0) p0 = 2 * p1 - p0 + 1;
          v = v * p0;
        }
        float h = (float) (v * 0.8);
        float s = 0.7f;
        float b = 1.0f;
        int rgb = Color.HSBtoRGB(h, s, b);
        rgb |= 0xc0000000;
        c = new Color(rgb, true);
        thread_colors.put(bt, c);
      }
      return c;
    }
  }
Ejemplo n.º 22
0
  void install() {
    Vector components = new Vector();
    Vector indicies = new Vector();
    int size = 0;

    JPanel comp = selectComponents.comp;
    Vector ids = selectComponents.filesets;

    for (int i = 0; i < comp.getComponentCount(); i++) {
      if (((JCheckBox) comp.getComponent(i)).getModel().isSelected()) {
        size += installer.getIntegerProperty("comp." + ids.elementAt(i) + ".real-size");
        components.addElement(installer.getProperty("comp." + ids.elementAt(i) + ".fileset"));
        indicies.addElement(new Integer(i));
      }
    }

    String installDir = chooseDirectory.installDir.getText();

    Map osTaskDirs = chooseDirectory.osTaskDirs;
    Iterator keys = osTaskDirs.keySet().iterator();
    while (keys.hasNext()) {
      OperatingSystem.OSTask osTask = (OperatingSystem.OSTask) keys.next();
      String dir = ((JTextField) osTaskDirs.get(osTask)).getText();
      if (dir != null && dir.length() != 0) {
        osTask.setEnabled(true);
        osTask.setDirectory(dir);
      } else osTask.setEnabled(false);
    }

    InstallThread thread =
        new InstallThread(installer, progress, installDir, osTasks, size, components, indicies);
    progress.setThread(thread);
    thread.start();
  }
Ejemplo n.º 23
0
    private Jp2File getOpenJ2pFile(File outputFile) throws IOException {
      Jp2File jp2File = openFiles.get(outputFile);
      if (jp2File == null) {
        jp2File = new Jp2File();
        jp2File.file = outputFile;
        jp2File.stream = new FileImageInputStream(outputFile);
        jp2File.header = jp2File.stream.readLine();
        jp2File.dataPos = jp2File.stream.getStreamPosition();

        final String[] tokens = jp2File.header.split(" ");
        if (tokens.length != 6) {
          throw new IOException("Unexpected tile format");
        }

        // String pg = tokens[0];   // PG
        // String ml = tokens[1];   // ML
        // String plus = tokens[2]; // +
        int jp2Width;
        int jp2Height;
        try {
          // int jp2File.nbits = Integer.parseInt(tokens[3]);
          jp2File.width = Integer.parseInt(tokens[4]);
          jp2File.height = Integer.parseInt(tokens[5]);
        } catch (NumberFormatException e) {
          throw new IOException("Unexpected tile format");
        }

        openFiles.put(outputFile, jp2File);
      }

      return jp2File;
    }
 public void setMetricsResults(MetricDisplaySpecification displaySpecification, MetricsRun run) {
   final MetricCategory[] categories = MetricCategory.values();
   for (final MetricCategory category : categories) {
     final JTable table = tables.get(category);
     final String type = MetricsCategoryNameUtil.getShortNameForCategory(category);
     final MetricTableSpecification tableSpecification =
         displaySpecification.getSpecification(category);
     final MetricsResult results = run.getResultsForCategory(category);
     final MetricTableModel model = new MetricTableModel(results, type, tableSpecification);
     table.setModel(model);
     final Container tab = table.getParent().getParent();
     if (model.getRowCount() == 0) {
       tabbedPane.remove(tab);
       continue;
     }
     final String longName = MetricsCategoryNameUtil.getLongNameForCategory(category);
     tabbedPane.add(tab, longName);
     final MyColumnListener columnListener = new MyColumnListener(tableSpecification, table);
     final TableColumnModel columnModel = table.getColumnModel();
     columnModel.addColumnModelListener(columnListener);
     final int columnCount = columnModel.getColumnCount();
     for (int i = 0; i < columnCount; i++) {
       final TableColumn column = columnModel.getColumn(i);
       column.addPropertyChangeListener(columnListener);
     }
     setRenderers(table, type);
     setColumnWidths(table, tableSpecification);
   }
 }
  public void addSelection(Point p) {
    ExprPoint ep = null;
    int minDist = -1;

    for (ExprPoint ex : points) {
      int sd = ex.screenDist(p);
      if (ep == null || sd < minDist) {
        ep = ex;
        minDist = sd;
      }
    }

    if (ep != null) {
      Set<Point> remove = new HashSet<Point>();
      for (Point rp : selections.keySet()) {
        if (selections.get(rp).equals(ep)) {
          remove.add(rp);
        }
      }

      selections.put(p, ep);

      for (Point rp : remove) {
        selections.remove(rp);
      }
    }
  }
Ejemplo n.º 26
0
  /**
   * Arena consturctor.
   *
   * @param parent The component where the arena will be displayed in.
   */
  public Arena(Component parent) {
    super();
    this.parent = parent;
    this.isVisible = false;
    if (parent == null) {
      this.isVisible = false;
    } else {
      parent.addKeyListener(this);
    }

    FrictionBuffer get = frictionBufferCache.get(this.svgFileName);
    if (get == null) { // if not in cache, create new instance and
      frictionBuffer = new FrictionBuffer(this);
      frictionBufferCache.put(this.svgFileName, frictionBuffer);
      if (DEBUG_FRICTION_CACHE) {
        System.out.println(
            "Cached friction buffer not found, I have created new instance and cached it.");
      }
    } else {
      frictionBuffer = get;
      if (DEBUG_FRICTION_CACHE) {
        System.out.println("Cached friction buffer found.");
      }
    }
  }
Ejemplo n.º 27
0
  /**
   * ** Returns an I18N instance based on the specified package name and Locale ** @param pkgName
   * The resource package name ** @param loc The Locale resource from with the localized text is
   * loaded
   */
  public static I18N getI18N(String pkgName, Locale loc) {
    if (pkgName != null) {
      loc = I18N.getLocale(loc);

      /* get package map for specific Locale */
      Map<String, I18N> packageMap = localeMap.get(loc);
      if (packageMap == null) {
        packageMap = new HashMap<String, I18N>();
        localeMap.put(loc, packageMap);
      }

      /* get I18N instance for package */
      I18N i18n = packageMap.get(pkgName);
      if (i18n == null) {
        i18n = new I18N(pkgName, loc);
        packageMap.put(pkgName, i18n);
      }
      return i18n;

    } else {

      /* no package specified */
      return null;
    }
  }
Ejemplo n.º 28
0
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      // #93658: GTK needs name to render cell renderer "natively"
      setName("ComboBox.listRenderer"); // NOI18N

      String config = (String) value;
      String label;
      if (config == null) {
        // uninitialized?
        label = null;
      } else if (config.length() > 0) {
        Map<String, String> m = configs.get(config);
        label = m != null ? m.get("$label") : /* temporary? */ null; // NOI18N
        if (label == null) {
          label = config;
        }
      } else {
        label =
            NbBundle.getBundle("org.netbeans.modules.java.j2seproject.Bundle")
                .getString("J2SEConfigurationProvider.default.label"); // NOI18N
      }
      setText(label);

      if (isSelected) {
        setBackground(list.getSelectionBackground());
        setForeground(list.getSelectionForeground());
      } else {
        setBackground(list.getBackground());
        setForeground(list.getForeground());
      }

      return this;
    }
Ejemplo n.º 29
0
 /**
  * Tries to calculate given line's indent column assuming that there might be a comment at the
  * given indent offset (see {@link #getCommentPrefix(IElementType)}).
  *
  * @param line target line
  * @param indentOffset start indent offset to use for the given line
  * @param lineEndOffset given line's end offset
  * @param fallbackColumn column to return if it's not possible to apply comment-specific indent
  *     calculation rules
  * @return given line's indent column to use
  */
 private int calcIndent(int line, int indentOffset, int lineEndOffset, int fallbackColumn) {
   final HighlighterIterator it = myEditor.getHighlighter().createIterator(indentOffset);
   IElementType tokenType = it.getTokenType();
   Language language = tokenType.getLanguage();
   TokenSet comments = myComments.get(language);
   if (comments == null) {
     ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
     if (definition != null) {
       comments = definition.getCommentTokens();
     }
     if (comments == null) {
       return fallbackColumn;
     } else {
       myComments.put(language, comments);
     }
   }
   if (comments.contains(tokenType) && indentOffset == it.getStart()) {
     String prefix = COMMENT_PREFIXES.get(tokenType);
     if (prefix == null) {
       prefix = getCommentPrefix(tokenType);
     }
     if (!NO_COMMENT_INFO_MARKER.equals(prefix)) {
       final int indentInsideCommentOffset =
           CharArrayUtil.shiftForward(
               myChars, indentOffset + prefix.length(), lineEndOffset, " \t");
       if (indentInsideCommentOffset < lineEndOffset) {
         int indent = myEditor.calcColumnNumber(indentInsideCommentOffset, line);
         indentAfterUncomment.put(line, indent - prefix.length());
         return indent;
       }
     }
   }
   return fallbackColumn;
 }
Ejemplo n.º 30
0
 /**
  * Saves current fixed times and loads fixed times for the new channel, if the channel changed.
  *
  * @param stream
  */
 private void manageChannelSpecificVars(String stream) {
   if (!stream.equals(currentStream)) {
     hoverEntry = -1;
     fixedStartTimes.put(currentStream, fixedStartTime);
     fixedEndTimes.put(currentStream, fixedEndTime);
     currentStream = stream;
     fixedStartTime = 0;
     fixedEndTime = 0;
     if (fixedStartTimes.containsKey(stream)) {
       fixedStartTime = fixedStartTimes.get(stream);
     }
     if (fixedEndTimes.containsKey(stream)) {
       fixedEndTime = fixedEndTimes.get(stream);
     }
   }
 }