コード例 #1
0
ファイル: TableSorter.java プロジェクト: jdepend/cooper
    public void paintIcon(java.awt.Component c, Graphics g, int x, int y) {
      Color color = c == null ? Color.GRAY : c.getBackground();
      // In a compound sort, make each succesive triangle 20%
      // smaller than the previous one.
      int dx = (int) (size / 2 * Math.pow(0.8, priority));
      int dy = descending ? dx : -dx;
      // Align icon (roughly) with font baseline.
      y = y + 5 * size / 6 + (descending ? -dy : 0);
      int shift = descending ? 1 : -1;
      g.translate(x, y);

      // Right diagonal.
      g.setColor(color.darker());
      g.drawLine(dx / 2, dy, 0, 0);
      g.drawLine(dx / 2, dy + shift, 0, shift);

      // Left diagonal.
      g.setColor(color.brighter());
      g.drawLine(dx / 2, dy, dx, 0);
      g.drawLine(dx / 2, dy + shift, dx, shift);

      // Horizontal line.
      if (descending) {
        g.setColor(color.darker().darker());
      } else {
        g.setColor(color.brighter().brighter());
      }
      g.drawLine(dx, 0, 0, 0);

      g.setColor(color);
      g.translate(-x, -y);
    }
コード例 #2
0
  /**
   * Function: getJavaColor Pre: Takes an ANIMAL color string 'c' Post: Returns the java color for
   * this node (Note: returns "white" as a default)
   */
  private Color getJavaColor(String c) {
    if (!isValidNodeColor(c)) return Color.white;

    // Temporary color to use with numbered colors
    Color temp = Color.white;

    if (c.compareTo("black") == 0) return Color.black;
    if (c.compareTo("white") == 0) return Color.white;
    if (c.compareTo("gray") == 0) return Color.gray;
    if (c.compareTo("yellow") == 0) return Color.yellow;
    if (c.startsWith("blue")) temp = Color.blue;
    if (c.startsWith("cyan")) temp = Color.cyan;
    if (c.startsWith("pink")) temp = Color.pink;
    if (c.startsWith("red")) temp = Color.red;
    if (c.startsWith("magenta")) temp = Color.magenta;
    if (c.startsWith("green")) temp = Color.green;

    // Finally, do some final handling for
    temp = temp.darker().darker();
    if (c.endsWith("2")) return temp.brighter();
    if (c.endsWith("3")) return temp.brighter().brighter();
    if (c.endsWith("4")) return temp.brighter().brighter().brighter();

    return temp;
  }
コード例 #3
0
 protected void installDefaults() {
   String string = UIManager.getLookAndFeel().getName();
   Color defaultGridColor = UIManager.getColor("Table.gridColor");
   Color defaultForegroundColor = UIManager.getColor("TableHeader.foreground");
   Color defaultBackgroundColor = UIManager.getColor("TableHeader.background");
   Font defaultGridFont = UIManager.getFont("Table.font");
   Border defaultGridBorder = UIManager.getBorder("TableHeader.border");
   Color defaultSelectionForegroundColor = defaultForegroundColor.brighter();
   Color defaultSelectionBackgroundColor = defaultBackgroundColor;
   Color defaultFocusForegroundColor = defaultForegroundColor.brighter();
   Color defaultFocusBackgroundColor = defaultBackgroundColor.brighter();
   if (!installedHeader) {
     UIManager.getDefaults().put("GridHeader.gridColor", defaultGridColor);
     UIManager.getDefaults().put("GridHeader.foreground", defaultForegroundColor);
     UIManager.getDefaults().put("GridHeader.background", defaultBackgroundColor);
     UIManager.getDefaults()
         .put("GridHeader.selectionForegroundColor", defaultSelectionForegroundColor);
     UIManager.getDefaults()
         .put("GridHeader.selectionBackgroundColor", defaultSelectionBackgroundColor);
     UIManager.getDefaults().put("GridHeader.focusForegroundColor", defaultFocusForegroundColor);
     UIManager.getDefaults().put("GridHeader.focusBackgroundColor", defaultFocusBackgroundColor);
     UIManager.getDefaults().put("GridHeader.border", defaultGridBorder);
     UIManager.getDefaults().put("GridHeader.font", defaultGridFont);
   }
   Color foregroundColor = gridHeader.getForeground();
   Color backgroundColor = gridHeader.getBackground();
   Font gridFont = gridHeader.getFont();
   Border gridBorder = gridHeader.getBorder();
   Color gridColor = gridHeader.getGridColor();
   Color selectionForegroundColor = gridHeader.getSelectionForegroundColor();
   Color selectionBackgroundColor = gridHeader.getSelectionBackgroundColor();
   Color focusForegroundColor = gridHeader.getFocusForegroundColor();
   Color focusBackgroundColor = gridHeader.getFocusBackgroundColor();
   if (foregroundColor == null || foregroundColor instanceof UIResource)
     gridHeader.setForeground(defaultForegroundColor);
   if (backgroundColor == null || backgroundColor instanceof UIResource)
     gridHeader.setBackground(defaultBackgroundColor);
   if (gridColor == null || gridColor instanceof UIResource)
     gridHeader.setGridColor(defaultGridColor);
   if (gridFont == null || gridFont instanceof UIResource) gridHeader.setFont(defaultGridFont);
   if (gridBorder == null || gridBorder instanceof UIResource)
     gridHeader.setBorder(defaultGridBorder);
   if (selectionForegroundColor == null || selectionForegroundColor instanceof UIResource)
     gridHeader.setSelectionForegroundColor(defaultSelectionForegroundColor);
   if (selectionBackgroundColor == null || selectionBackgroundColor instanceof UIResource)
     gridHeader.setSelectionBackgroundColor(defaultSelectionBackgroundColor);
   if (focusForegroundColor == null || focusForegroundColor instanceof UIResource)
     gridHeader.setFocusForegroundColor(defaultFocusForegroundColor);
   if (focusBackgroundColor == null || focusBackgroundColor instanceof UIResource)
     gridHeader.setFocusBackgroundColor(defaultFocusBackgroundColor);
 }
コード例 #4
0
ファイル: CountryButton.java プロジェクト: tbilles/Risk
 public void refresh(GameView view) {
   Color c = view.getCountryColor(country);
   if (c != null) {
     if (view.isCountrySelected(country)) {
       c = c.darker();
       c = c.darker();
       c = c.darker();
     } else if (view.isCountryNeighbourSelected(country)) {
       c = c.brighter();
       c = c.brighter();
       c = c.brighter();
     }
     setBackground(c);
     setText(view.getCountryTroops(country) + "");
   }
 }
コード例 #5
0
  public void update(Graphics g, JComponent c) {
    if (c.isOpaque()) {
      AbstractButton b = (AbstractButton) c;
      if (isToolBarButton(b)) {
        c.setOpaque(false);
      } else if (b.isContentAreaFilled()) {
        g.setColor(c.getBackground());
        g.fillRect(0, 0, c.getWidth(), c.getHeight());

        if (is3D(b)) {
          Color color1 = c.getBackground(); // UIManager.getColor("control");
          Color color2 = color1.brighter();

          int x = 0;
          int y = 0;
          int width = c.getWidth();
          int height = c.getHeight();
          GradientPaint gp = new GradientPaint(x, y, color2, width - 2, height - 2, color1, true);
          Graphics2D g2 = (Graphics2D) g;
          g2.setPaint(gp);
          g2.fillRect(x, y, width, height);
        }
      }
    }
    c.setBorder(defaultBorder);
    paint(g, c);
  }
コード例 #6
0
ファイル: View.java プロジェクト: kaschenko/lab3
    private void drawSquare(Graphics g, int x, int y, Tetrominoes shape) {

      int squareWidth = (int) getSize().getWidth() / model.getWidth();
      int squareHeight = (int) getSize().getHeight() / model.getHeight();

      Color colors[] = {
        new Color(0, 0, 0),
        new Color(204, 102, 102),
        new Color(102, 204, 102),
        new Color(102, 102, 204),
        new Color(204, 204, 102),
        new Color(204, 102, 204),
        new Color(102, 204, 204),
        new Color(218, 170, 0)
      };

      Color color = colors[shape.ordinal()];
      g.setColor(color);
      g.fillRect(x + 1, y + 1, squareWidth - 2, squareHeight - 2);
      g.setColor(color.brighter());
      g.drawLine(x, y + squareHeight - 1, x, y);
      g.drawLine(x, y, x + squareWidth - 1, y);

      g.setColor(color.darker());
      g.drawLine(x + 1, y + squareHeight - 1, x + squareWidth - 1, y + squareHeight - 1);
      g.drawLine(x + squareWidth - 1, y + squareHeight - 1, x + squareWidth - 1, y + 1);
    }
コード例 #7
0
 protected void paintDisabledText(DateComponent dc, Graphics g, String s, int textX, int textY) {
   Color background = dc.getBackground();
   g.setColor(background.brighter());
   SwingUtilities2.drawString(dc, g, s, textX + 1, textY + 1);
   g.setColor(background.darker());
   SwingUtilities2.drawString(dc, g, s, textX, textY);
 }
コード例 #8
0
 private void paintFocusAndRollover(Graphics2D g2, JComponent c, Color color) {
   g2.setPaint(
       new GradientPaint(
           0, 0, color, c.getWidth() - 1, c.getHeight() - 1, color.brighter(), true));
   g2.fill(shape);
   g2.setColor(c.getBackground());
   g2.fill(border);
 }
コード例 #9
0
  /** @return the color */
  public Color getActiveColor() {
    synchronized (blinkingState) {
      if (blinkingState == BlinkingStateEnum.BLINKING_BRILLIANT) {
        return (color == Color.WHITE) ? color.darker() : color.brighter();
      }

      return color;
    }
  }
コード例 #10
0
 @Override
 public void setSurfShapeColor(String id, Color col, double opacity) throws NoSuchShapeException {
   SurfaceShape shape = getSurfShape(id);
   BasicShapeAttributes newAttr = new BasicShapeAttributes(attr);
   newAttr.setOutlineMaterial(new Material(col));
   newAttr.setInteriorMaterial(new Material(col.brighter().brighter()));
   newAttr.setOutlineOpacity(opacity);
   newAttr.setInteriorOpacity(NORM_INSIDE_OPACITY * opacity);
   shape.setAttributes(newAttr);
 }
コード例 #11
0
    public SearchPopup(String initialString) {
      final Color foregroundColor = UIUtil.getToolTipForeground();
      Color color1 = UIUtil.getToolTipBackground();
      mySearchField = new SearchField();
      final JLabel searchLabel =
          new JLabel(" " + UIBundle.message("search.popup.search.for.label") + " ");
      searchLabel.setFont(searchLabel.getFont().deriveFont(Font.BOLD));
      searchLabel.setForeground(foregroundColor);
      mySearchField.setBorder(null);
      mySearchField.setBackground(color1.brighter());
      mySearchField.setForeground(foregroundColor);

      mySearchField.setDocument(
          new PlainDocument() {
            public void insertString(int offs, String str, AttributeSet a)
                throws BadLocationException {
              String oldText;
              try {
                oldText = getText(0, getLength());
              } catch (BadLocationException e1) {
                oldText = "";
              }

              String newText = oldText.substring(0, offs) + str + oldText.substring(offs);
              super.insertString(offs, str, a);
              if (findElement(newText) == null) {
                mySearchField.setForeground(Color.RED);
              } else {
                mySearchField.setForeground(foregroundColor);
              }
            }
          });
      mySearchField.setText(initialString);

      setBorder(BorderFactory.createLineBorder(Color.gray, 1));
      setBackground(color1.brighter());
      setLayout(new BorderLayout());
      add(searchLabel, BorderLayout.WEST);
      add(mySearchField, BorderLayout.EAST);
      Object element = findElement(mySearchField.getText());
      updateSelection(element);
    }
コード例 #12
0
 public void setBaseForeground(Color base) {
   if (base == null) {
     setForeground(SystemColor.controlText);
     hoverForeground = SystemColor.controlText;
     depressedForeground = SystemColor.controlHighlight;
   } else {
     hoverForeground = base.darker();
     depressedForeground = base.brighter();
     setForeground(base);
   }
 }
コード例 #13
0
ファイル: SummaryView.java プロジェクト: delkyd/MCT-Plugins
 @Override
 public void paintIcon(Component c, Graphics g, int x, int y) {
   if (g instanceof Graphics2D) {
     ((Graphics2D) g)
         .setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   }
   g.setColor(tagSet.equals(highlighted) ? color.brighter() : color);
   g.fillRoundRect(x, y, ICON_WIDTH - 1, ICON_HEIGHT - 1, ICON_WIDTH / 2, ICON_WIDTH / 2);
   g.setColor(color.darker());
   g.drawRoundRect(x, y, ICON_WIDTH - 1, ICON_HEIGHT - 1, ICON_WIDTH / 2, ICON_WIDTH / 2);
 }
コード例 #14
0
 public void setBaseBackground(Color base) {
   if (base == null) {
     setBackground(SystemColor.control);
     hoverBackground = SystemColor.controlHighlight;
     depressedBackground = SystemColor.controlShadow;
   } else {
     setBackground(base);
     hoverBackground = base.brighter();
     depressedBackground = base.darker();
   }
 }
コード例 #15
0
ファイル: BlockType.java プロジェクト: HYEMIBYUN/JumpingDead
  private BlockType(Color color, int dimension, int cols, int rows, boolean[][] blocks) {
    this.baseColor = color;
    this.lightColor = color.brighter();
    this.darkColor = color.darker();
    this.dimension = dimension;
    this.blocks = blocks;
    this.cols = cols;
    this.rows = rows;

    this.spawnCol = 5 - (dimension >> 1);
    this.spawnRow = getTopInset(0);
  }
コード例 #16
0
  private void installColors() {
    Color shadow = UIManager.getColor("controlShadow");
    Color highlight = UIManager.getColor("controlLtHighlight");
    if (shadow == null) {
      shadow = Color.GRAY;
    }
    if (highlight == null) {
      highlight = shadow.brighter();
    }

    UIManager.put("VLDocking.shadow", shadow);
    UIManager.put("VLDocking.highlight", highlight);
  }
コード例 #17
0
  private static void drawMenuBezel(
      Graphics g, Color background, int x, int y, int width, int height) {
    // shadowed button region
    g.setColor(background);
    g.fillRect(x, y, width, height);

    g.setColor(background.brighter().brighter());
    g.drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1);
    g.drawLine(x + width - 1, y + height - 2, x + width - 1, y + 1);

    g.setColor(background.darker().darker());
    g.drawLine(x, y, x + width - 2, y);
    g.drawLine(x, y + 1, x, y + height - 2);
  }
コード例 #18
0
ファイル: WebLabelPainter.java プロジェクト: J-Almeida/weblaf
 /**
  * Performs disabled text painting.
  *
  * @param label label to process
  * @param g2d graphics context
  * @param text label text
  * @param textX text X coordinate
  * @param textY text Y coordinate
  */
 protected void paintDisabledText(
     final E label, final Graphics2D g2d, final String text, final int textX, final int textY) {
   if (label.isEnabled() && drawShade) {
     g2d.setColor(label.getBackground().darker());
     paintShadowText(g2d, text, textX, textY);
   } else {
     final int accChar = label.getDisplayedMnemonicIndex();
     final Color background = label.getBackground();
     g2d.setColor(background.brighter());
     SwingUtils.drawStringUnderlineCharAt(g2d, text, accChar, textX + 1, textY + 1);
     g2d.setColor(background.darker());
     SwingUtils.drawStringUnderlineCharAt(g2d, text, accChar, textX, textY);
   }
 }
コード例 #19
0
ファイル: Brighter.java プロジェクト: sushilshah/learnJava
  public static void main(String[] args) {
    Picture pic1 = new Picture(args[0]);
    int width = pic1.width();
    int height = pic1.height();
    pic1.show();

    Picture pic2 = new Picture(width, height);
    for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
        Color c1 = pic1.get(x, y);
        Color c2 = c1.brighter();
        pic2.set(x, y, c2);
      }
    }
    pic2.show();
  }
コード例 #20
0
 /**
  * overridden to draw the component
  *
  * @param g graphics object
  */
 public void paintComponent(java.awt.Graphics g) {
   gp = new GradientPaint(20, 20, c.brighter(), getWidth() / 2, getHeight() / 2, c.darker(), true);
   Graphics2D g2 = (Graphics2D) g;
   if (gp != null) {
     g2.setColor(c);
     g2.setPaint(gp);
     g2.drawRoundRect(0, 0, getWidth() + 1, getHeight() - 2, 8, 8);
     g2.setColor(c.darker());
     g2.drawRoundRect(0, 1, getWidth() + 2, getHeight() - 3, 7, 7);
     g2.setColor(c.darker().darker());
     g2.drawRoundRect(0, 2, getWidth() + 4, getHeight() - 4, 6, 6);
     g2.setPaint(gp);
     g2.fillRoundRect(0, 3, getWidth() + 6, getHeight() - 6, 5, 5);
   }
   paintChildren(g);
 }
コード例 #21
0
  public void axisUpdate() {
    ValueAxis va = getValueAxis();
    if (va.isAutoRange()) {
      if (oldColor == null) oldColor = getBackground();
      setBackground(oldColor.brighter());
    } else if (oldColor != null) {
      setBackground(oldColor);
      oldColor = null;
    }
    if (updating) return;
    updating = true;
    displayMin = 0;
    displayMax = 0;
    viewLength = 0;
    double viewMin = 0;
    double viewMax = 0;
    ratio = 1;
    Range dataRange = getDataRange();
    if (dataRange != null) {
      displayMin = getDisplayMinimum();
      displayMax = getDisplayMaximum();
      viewMin = getViewMinimum();
      viewMax = getViewMaximum();
      // ValueAxis va = getValueAxis();
      if (va instanceof DateAxis) {
        Timeline tl = ((DateAxis) va).getTimeline();
        displayMin = tl.toTimelineValue((long) displayMin);
        displayMax = tl.toTimelineValue((long) displayMax);
        viewMin = tl.toTimelineValue((long) viewMin);
        viewMax = tl.toTimelineValue((long) viewMax);
      }
      viewLength = viewMax - viewMin;
      ratio = STEPS / (displayMax - displayMin);
    }

    int newMin = 0;
    int newMax = STEPS;
    int newExtent = (int) (viewLength * ratio);
    int newValue;
    if (orientation == VERTICAL) newValue = (int) ((displayMax - viewMax) * ratio);
    else newValue = (int) ((viewMin - displayMin) * ratio);
    // System.out.println("ChartScrollBar.axisUpdate(): newValue: " + newValue + " newExtent: " +
    // newExtent + " newMin: " + newMin + " newMax: " + newMax);
    setValues(newValue, newExtent, newMin, newMax);
    updating = false;
  }
コード例 #22
0
  /** Adds more colours to the colour list */
  private void extendColourMap() {
    if (m_plotInstances.attribute(m_cIndex).isNominal()) {
      for (int i = m_colorList.size(); i < m_plotInstances.attribute(m_cIndex).numValues(); i++) {
        Color pc = m_DefaultColors[i % 10];
        int ija = i / 10;
        ija *= 2;
        for (int j = 0; j < ija; j++) {
          pc = pc.brighter();
        }

        if (m_backgroundColor != null) {
          pc = Plot2D.checkAgainstBackground(pc, m_backgroundColor);
        }

        m_colorList.add(pc);
      }
    }
  }
コード例 #23
0
    private void drawSpot(
        Graphics g,
        int width,
        boolean thinErrorStripeMark,
        int yStart,
        int yEnd,
        Color color,
        boolean drawTopDecoration,
        boolean drawBottomDecoration) {
      int x = isMirrored() ? 3 : 5;
      int paintWidth = width;
      if (thinErrorStripeMark) {
        paintWidth /= 2;
        paintWidth += 1;
        x = isMirrored() ? width + 2 : 0;
      }
      if (color == null) return;
      g.setColor(color);
      g.fillRect(x + 1, yStart, paintWidth - 2, yEnd - yStart + 1);

      Color brighter = color.brighter();
      g.setColor(brighter);
      // left decoration
      UIUtil.drawLine(g, x, yStart, x, yEnd /* - 1*/);
      if (drawTopDecoration) {
        // top decoration
        UIUtil.drawLine(g, x + 1, yStart, x + paintWidth - 2, yStart);
      }
      Color darker = ColorUtil.shift(color, 0.75);

      g.setColor(darker);
      if (drawBottomDecoration) {
        // bottom decoration
        UIUtil.drawLine(
            g,
            x + 1,
            yEnd /* - 1*/,
            x + paintWidth - 2,
            yEnd /* - 1*/); // large bottom to let overwrite by hl below
      }
      // right decoration
      UIUtil.drawLine(g, x + paintWidth - 2, yStart, x + paintWidth - 2, yEnd /* - 1*/);
    }
コード例 #24
0
ファイル: Login.java プロジェクト: mhcrnl/test
  private static void configure() {

    // overwrite banner
    Color color = new Color(0, 102, 153);
    UIManager.put("JXLoginPane.bannerDarkBackground", color);
    UIManager.put("JXLoginPane.bannerLightBackground", color.brighter());
    UIManager.put("JXLoginPane.bannerFont", new Font("Arial", Font.ITALIC, 25));
    UIManager.put("JXLoginPane.bannerForeground", Color.WHITE);

    // overwrite login & cancel strings from buttons
    UIManager.put("JXLoginPane.loginString", "Ok");
    UIManager.put("JXLoginPane.cancelString", "Exit");

    // overwrite please wait at login
    UIManager.put("JXLoginPane.pleaseWaitFont", new Font("Arial", Font.ITALIC, 20));
    UIManager.put("JXLoginPane.pleaseWait", "Loging ...");
    UIManager.put("JXLoginPane.cancelLogin", "Cancel");

    // overwrite error icon , message, background & border
    // UIManager.put("JXLoginPane.errorIcon", ImageUtil.getImageIcon("img.png"));
    // UIManager.put("JXLoginPane.errorMessage", "Failed"); // if error message must be inserted see
    // login listener
    //            Color errorColor = new Color(252, 236, 236);
    //            UIManager.put("JXLoginPane.errorBackground", errorColor);
    //            UIManager.put("JXLoginPane.errorBorder", new
    // BorderUIResource(BorderFactory.createCompoundBorder(
    //                    BorderFactory.createEmptyBorder(0, 36, 0, 11),
    //                    BorderFactory.createCompoundBorder(
    //                            BorderFactory.createLineBorder(Color.GRAY.darker()),
    //                            BorderFactory.createMatteBorder(5, 7, 5, 5, errorColor)))));

    // overwrite name , password & server labels
    UIManager.put("JXLoginPane.nameString", "User");
    UIManager.put("JXLoginPane.passwordString", "Credentials");
    UIManager.put("JXLoginPane.serverString", "Server");

    // UIManager.put("JXLoginPane.capsOnWarning", "Caps Lock pressed!");

  }
コード例 #25
0
  public void paintPatch(Graphics g, Patch p, int x, int y, int cellS) {
    Color c = Color.BLACK;
    if (p.color.equals(Color.RED)) {
      c = Color.ORANGE;
    } else if (p.smell("food") > 0) {
      c = new Color((int) (p.smell("food")));
    } else {
      double nestScent = p.smell("nestScent");
      double foodScent = p.smell("foodScent");
      if (nestScent > maxNestScent) maxNestScent = nestScent;
      if (foodScent > maxFoodScent) maxFoodScent = foodScent;
      nestScent /= maxNestScent;
      foodScent /= maxFoodScent;
      c = new Color((int) (nestScent * 255), (int) (foodScent * 255), 0);
    }

    if (p.getTurtles().length > 0) {
      if (c.getRed() < 10 && c.getGreen() < 10) c = Color.GRAY.darker().darker();
      else c = c.brighter().brighter().brighter();
    }
    g.setColor(c);
    g.fillRect(x, y, cellS, cellS);
  }
コード例 #26
0
ファイル: SortArrowIcon.java プロジェクト: tixus/Thngm
  public void paintIcon(Component c, Graphics g, int x, int y) {
    Color bg = c.getBackground();
    Color light = bg.brighter();
    Color shade = bg.darker();

    int w = width;
    int h = height;
    int m = w / 2;
    if (direction == ASCENDING) {
      g.setColor(shade);
      g.drawLine(x, y, x + w, y);
      g.drawLine(x, y, x + m, y + h);
      g.setColor(light);
      g.drawLine(x + w, y, x + m, y + h);
    }
    if (direction == DECENDING) {
      g.setColor(shade);
      g.drawLine(x + m, y, x, y + h);
      g.setColor(light);
      g.drawLine(x, y + h, x + w, y + h);
      g.drawLine(x + m, y, x + w, y + h);
    }
  }
コード例 #27
0
ファイル: SummaryView.java プロジェクト: delkyd/MCT-Plugins
 @Override
 public void paintComponent(Graphics g) {
   if (slices != null && !slices.isEmpty()) {
     Arc2D arc2D = null;
     double start = 0;
     int size = Math.min(getWidth(), getHeight()) - 10;
     int x = getWidth() / 2 - size / 2;
     int y = getHeight() / 2 - size / 2;
     if (g instanceof Graphics2D) {
       arc2D = new Arc2D.Double(Arc2D.PIE);
       arc2D.setFrame(x, y, size, size);
       ((Graphics2D) g)
           .setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     }
     for (PieSlice slice : slices) {
       double arc = (slice.cost / total) * 360.0;
       if (g instanceof Graphics2D) {
         arc2D.setAngleStart(start);
         arc2D.setAngleExtent(arc);
         Color c = ScenarioColorPalette.getColor(slice.toString());
         g.setColor(slice.equals(highlighted) ? c.brighter() : c);
         ((Graphics2D) g).fill(arc2D);
         g.setColor(Color.BLACK);
         ((Graphics2D) g).draw(arc2D);
       } else {
         g.setColor(ScenarioColorPalette.getColor(slice.toString()));
         g.fillArc(x, y, size, size, (int) start, (int) arc);
         g.setColor(Color.BLACK);
         g.drawArc(x, y, size, size, (int) start, (int) arc);
       }
       start += arc;
     }
     g.setColor(ScenarioColorPalette.getColor("Untagged"));
     g.fillArc(x, y, size, size, (int) start, (int) (360.0 - start));
   }
 }
コード例 #28
0
  public void drawObject(Graphics2D g, double zoom_factor, int x_shift_origin, int y_shift_origin) {

    position.x -= 10;
    position.y -= 10;
    x_shift_origin -= 10;
    y_shift_origin -= 10;

    this.zoom_factor = zoom_factor;

    Color ccc = new Color(204, 204, 204, 150);

    g.setColor(ccc);
    Paint paint = g.getPaint();
    g.setPaint(
        new GradientPaint(
            getZoomedDim(position.x) - x_shift_origin,
            getZoomedDim(position.y) - y_shift_origin,
            ccc,
            getZoomedDim(position.x) - x_shift_origin + getZoomedDim(width),
            getZoomedDim(position.x) - x_shift_origin + getZoomedDim(height),
            ccc.brighter()));

    g.fillRect(
        getZoomedDim(position.x) - x_shift_origin,
        getZoomedDim(position.y) - y_shift_origin,
        getZoomedDim(width),
        getZoomedDim(height));
    g.setPaint(paint);

    position.x += 10;
    position.y += 10;
    x_shift_origin += 10;
    y_shift_origin += 10;

    drawGraphicsElement(g, zoom_factor, x_shift_origin, y_shift_origin);
  }
コード例 #29
0
  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    g2.setFont(getFont());
    FontMetrics fm = g2.getFontMetrics();

    Color iconC = getBackground();
    g2.setPaint(iconC);

    boolean filled =
        (model.isRollover() || model.isSelected() || model.isPressed() || isFocusOwner());

    if (filled) {
      Color cb = getBackground().brighter().brighter();
      Color ct = cb.brighter();

      if (model.isPressed() || model.isSelected() || isFocusOwner()) {
        ct = getBackground().brighter().brighter();
        cb = getBackground().brighter();
      }

      g2.setPaint(new GradientPaint(0, 0, ct, 0, getHeight(), cb));

      g2.fill(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), getHeight(), getHeight()));

    } else {
      iconC = getBackground().brighter();
    }

    int iconw = fm.getHeight() * 2;
    int iconh = iconw;

    int mgn = (getHeight() - iconh) / 2;

    if (getIcon() != null) {
      iconw = getIcon().getIconWidth();
      iconh = getIcon().getIconHeight();

      mgn = (getHeight() - iconh) / 2;
      getIcon().paintIcon(this, g2, mgn, mgn);
      g2.setStroke(new BasicStroke(2));
      if (filled) {
        g2.draw(new Ellipse2D.Double(mgn, mgn, iconw, iconh));
      }

    } else {
      g2.setPaint(iconC);
      g2.fill(new Ellipse2D.Double(mgn, mgn, iconw, iconh));
    }

    g2.setPaint(getForeground());
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);

    if (getText() != null && getText().length() > 0) {
      String[] sl = getText().split(System.getProperty("line.separator"));
      int l = iconw + mgn * 2;
      int w = getWidth() - l - mgn;
      int t = getHeight() / 2 - sl.length * fm.getHeight() / 2 + fm.getAscent();
      for (int i = 0; i < sl.length; i++) {
        int sw = 0;
        switch (getHorizontalAlignment()) {
          case JButton.RIGHT:
            sw = w - fm.stringWidth(sl[i]);
            break;
          case JButton.CENTER:
            sw = w / 2 - fm.stringWidth(sl[i]) / 2;
            break;
        }
        BasicGraphicsUtils.drawStringUnderlineCharAt(
            g2, sl[i], getDisplayedMnemonicIndex(), l + sw, t + i * fm.getHeight());
        //        g2.drawString(sl[i], l + sw, t + i * fm.getHeight());
      }
    }
  }
コード例 #30
0
 @Override
 public void setHighlightColor(Color col) {
   attrHigh.setOutlineMaterial(new Material(col));
   attrHigh.setInteriorMaterial(new Material(col.brighter().brighter()));
 }