Exemplo n.º 1
0
 /** Erase the whole canvas. (Does not repaint.) */
 private void erase() {
   Color original = graphic.getColor();
   graphic.setColor(backgroundColor);
   Dimension size = canvas.getSize();
   graphic.fill(new Rectangle(0, 0, size.width, size.height));
   graphic.setColor(original);
 }
Exemplo n.º 2
0
 /**
  * Erases a given shape's outline on the screen.
  *
  * @param shape the shape object to be erased
  */
 public void eraseOutline(Shape shape) {
   Color original = graphic.getColor();
   graphic.setColor(backgroundColour);
   graphic.draw(shape); // erase by drawing background colour
   graphic.setColor(original);
   canvas.repaint();
 }
  @Override
  public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    Color old = g2d.getColor();
    // Draw box
    g2d.setColor(
        clicked
            ? this.clickedBackColor
            : (hovering ? this.hoverBackColor : this.unclickedBackColor));
    g2d.fillRect(0, 0, getWidth(), getHeight());
    // Draw label
    g2d.setColor(
        clicked
            ? this.clickedForeColor
            : (hovering ? this.hoverForeColor : this.unclickedForeColor));
    g2d.setFont(getFont());
    int width = g2d.getFontMetrics().stringWidth(getText());
    int textHeight = getFont().getSize();
    int otherTextHeight = getFontMetrics(getFont()).getHeight();

    textHeight = textHeight - (otherTextHeight - textHeight);
    int height = textHeight + (getHeight() - textHeight) / 2;
    g2d.drawString(getText(), (getWidth() - width) / 2, height);

    g2d.setColor(old);
  }
Exemplo n.º 4
0
 /**
  * Erases a String on the Canvas.
  *
  * @param text the String to be displayed
  * @param x x co-ordinate for text placement
  * @param y y co-ordinate for text placement
  */
 public void eraseString(String text, int x, int y) {
   Color original = graphic.getColor();
   graphic.setColor(backgroundColour);
   graphic.drawString(text, x, y);
   graphic.setColor(original);
   canvas.repaint();
 }
  /** Paints selection for the specified <code>component</code>. */
  public static void paintSelectionDecoration(
      @NotNull RadComponent component, Graphics g, boolean focused) {
    if (component.isSelected()) {
      if (focused) {
        g.setColor(PlatformColors.BLUE);
      } else {
        g.setColor(Color.GRAY);
      }
      final Point[] points = getPoints(component.getWidth(), component.getHeight());
      for (final Point point : points) {
        g.fillRect(point.x - R, point.y - R, 2 * R + 1, 2 * R + 1);
      }
    } else if (component.getWidth() < FormEditingUtil.EMPTY_COMPONENT_SIZE
        || component.getHeight() < FormEditingUtil.EMPTY_COMPONENT_SIZE) {
      Graphics2D g2d = (Graphics2D) g;
      Composite oldComposite = g2d.getComposite();
      Stroke oldStroke = g2d.getStroke();
      Color oldColor = g2d.getColor();

      g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.5f));
      g2d.setStroke(new BasicStroke(0.7f));
      g2d.setColor(Color.black);
      g2d.drawRect(
          0,
          0,
          Math.max(component.getWidth(), FormEditingUtil.EMPTY_COMPONENT_SIZE),
          Math.max(component.getHeight(), FormEditingUtil.EMPTY_COMPONENT_SIZE));

      g2d.setComposite(oldComposite);
      g2d.setStroke(oldStroke);
      g2d.setColor(oldColor);
    }
  }
Exemplo n.º 6
0
 /** [Internal] */
 private void paintBackground(Graphics2D g2, Color theBackground) {
   Color color1 = g2.getColor();
   if (theBackground == null) theBackground = Color.white;
   g2.setColor(theBackground);
   g2.fillRect(0, 0, 30000, 30000);
   g2.setColor(color1);
 }
Exemplo n.º 7
0
 @Override
 public void draw(Graphics2D g2) {
   int w = toolInterface.getStrokeWidth() * 4;
   Color c = g2.getColor();
   g2.setColor(Color.GRAY);
   g2.drawRect(mouseX - w / 2, mouseY - w / 2, w, w);
   g2.setColor(c);
 }
  /**
   * Paints the component.
   *
   * @param g the Graphics context to draw on
   */
  protected void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    Insets insets = getRealInsets();
    Color savedColor = g2d.getColor();

    int rectX = insets.left;
    int rectY = insets.top;
    int rectWidth = getWidth() - insets.left - insets.right;
    int rectHeight = getHeight() - insets.top - insets.bottom;

    // Paint the yellow interior
    g2d.setColor(YELLOW_SNOW);
    g2d.fillRoundRect(rectX, rectY, rectWidth, rectHeight, ARC_WIDTH, ARC_HEIGHT);

    // Draw the gray border
    g2d.setColor(BUBBLE_BORDER);
    g2d.drawRoundRect(rectX, rectY, rectWidth, rectHeight, ARC_WIDTH, ARC_HEIGHT);

    g2d.setColor(savedColor);
  }
Exemplo n.º 9
0
 /**
  * Draws this without refreshing steps.
  *
  * @param panel the drawing panel requesting the drawing
  * @param _g the graphics context on which to draw
  */
 public void drawMe(DrawingPanel panel, Graphics _g) {
   // position and show inspector if requested during loading
   if (inspectorX != Integer.MIN_VALUE
       && trackerPanel != null
       && trackerPanel.getTFrame() != null) {
     positionInspector();
     Runnable runner =
         new Runnable() {
           public void run() {
             showInspector = false;
             inspector.setVisible(true);
           }
         };
     if (showInspector) SwingUtilities.invokeLater(runner);
   }
   if (isVisible() && isTraceVisible()) {
     // draw trace only if fixed coords & (non-worldview or no ref frame)
     TrackerPanel tPanel = (TrackerPanel) panel;
     ImageCoordSystem coords = tPanel.getCoords(); // get active coords
     boolean isRefFrame = coords instanceof ReferenceFrame;
     if (isRefFrame) {
       coords = ((ReferenceFrame) coords).getCoords();
     }
     boolean fixed = coords.isFixedAngle() && coords.isFixedOrigin() && coords.isFixedScale();
     if (fixed && (!(tPanel instanceof WorldTView) || !isRefFrame)) {
       trace.reset();
       for (int i = 0; i < traceX.length; i++) {
         if (Double.isNaN(traceX[i])) continue;
         tracePt.setLocation(traceX[i], traceY[i]);
         java.awt.Point p = tracePt.getScreenPosition(tPanel);
         if (trace.getCurrentPoint() == null) trace.moveTo((float) p.getX(), (float) p.getY());
         else trace.lineTo((float) p.getX(), (float) p.getY());
       }
       Graphics2D g2 = (Graphics2D) _g;
       Color color = g2.getColor();
       Stroke stroke = g2.getStroke();
       g2.setColor(getFootprint().getColor());
       g2.setStroke(traceStroke);
       g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
       g2.draw(trace);
       // restore original color and stroke
       g2.setColor(color);
       g2.setStroke(stroke);
     }
   }
   super.draw(panel, _g);
 }
Exemplo n.º 10
0
 private void setFillColor(int symbolType) {
   penColor = gRef.getColor();
   switch (symbolType) {
     case FTAConstants.SYMB_BASIC:
       gRef.setColor(Preferences.basicInitiatingEventColor);
       break;
     case FTAConstants.SYMB_UNDEV:
       gRef.setColor(Preferences.undevelopedEventColor);
       break;
     case FTAConstants.SYMB_EXTERN:
       gRef.setColor(Preferences.externalEventColor);
       break;
     case FTAConstants.SYMB_INTERMEDIATE:
       gRef.setColor(Preferences.intermediateEventColor);
       break;
     case FTAConstants.SYMB_AND:
       gRef.setColor(Preferences.andGateColor);
       break;
     case FTAConstants.SYMB_OR:
       gRef.setColor(Preferences.orGateColor);
       break;
     case FTAConstants.SYMB_PRIORITY_AND:
       gRef.setColor(Preferences.priorityAndGateColor);
       break;
     case FTAConstants.SYMB_EXCL_OR:
       gRef.setColor(Preferences.exclusiveOrGateColor);
       break;
     case FTAConstants.SYMB_INHIBIT:
       gRef.setColor(Preferences.inhibitGateColor);
       break;
     case FTAConstants.SYMB_CONDITION:
       gRef.setColor(Preferences.conditioningEventColor);
       break;
     case FTAConstants.SYMB_TRANS_IN:
       gRef.setColor(Preferences.transferInColor);
       break;
     case FTAConstants.SYMB_TRANS_OUT:
       gRef.setColor(Preferences.transferOutColor);
       break;
     default:
       gRef.setColor(Preferences.backgroundColor);
       break;
   }
 }
Exemplo n.º 11
0
  protected void paintComponent(Graphics graphics) {
    super.paintComponent(graphics);

    Graphics2D g = (Graphics2D) graphics;

    // If we are disabled, we don't draw our arrow, focus, and unstick
    // decorations:
    if (!isEnabled()) {
      return;
    }
    Color oldColor = g.getColor();
    RenderingHints oldHints = g.getRenderingHints();
    g.setColor(Color.black);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    if (isStuck()) {
      paintHorizontalLine(g);
    }
    g.setRenderingHints(oldHints);
    g.setColor(oldColor);

    knobPainter.paint(g);
  }
Exemplo n.º 12
0
 /**
  * Returns the current colour of the foreground.
  *
  * @return the colour of the foreground of the Canvas
  */
 public Color getForegroundColour() {
   return graphic.getColor();
 }
Exemplo n.º 13
0
 private void clearArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
   penColor = gRef.getColor();
   gRef.setColor(Preferences.backgroundColor);
   gRef.fillArc(x, y, width, height, startAngle, arcAngle);
   gRef.setColor(penColor);
 }
Exemplo n.º 14
-2
 private void paintTextEffect(
     Graphics2D g, float xFrom, float xTo, int y, Color effectColor, EffectType effectType) {
   int xStart = (int) xFrom;
   int xEnd = (int) xTo;
   g.setColor(effectColor);
   if (effectType == EffectType.LINE_UNDERSCORE) {
     UIUtil.drawLine(g, xStart, y + 1, xEnd, y + 1);
   } else if (effectType == EffectType.BOLD_LINE_UNDERSCORE) {
     int height = JBUI.scale(Registry.intValue("editor.bold.underline.height", 2));
     g.fillRect(xStart, y, xEnd - xStart, height);
   } else if (effectType == EffectType.STRIKEOUT) {
     int y1 = y - myView.getCharHeight() / 2;
     UIUtil.drawLine(g, xStart, y1, xEnd, y1);
   } else if (effectType == EffectType.WAVE_UNDERSCORE) {
     UIUtil.drawWave(g, new Rectangle(xStart, y + 1, xEnd - xStart, myView.getDescent() - 1));
   } else if (effectType == EffectType.BOLD_DOTTED_LINE) {
     UIUtil.drawBoldDottedLine(
         g,
         xStart,
         xEnd,
         SystemInfo.isMac ? y : y + 1,
         myEditor.getBackgroundColor(),
         g.getColor(),
         false);
   }
 }