Ejemplo n.º 1
0
  public void draw(Graphics2D graphics, DrawingProperties properties) {
    Color startingcol = graphics.getColor();
    Font startingfont = graphics.getFont();
    graphics.setColor(Constants.COLOR_ERROR);
    graphics.setFont(Constants.FONT_CANVAS_SMALL);

    int w = cmptodraw.getWidth();
    int h = cmptodraw.getHeight();
    if (componentName == null) componentName = cmptodraw.getTypeName().toString();

    // draw a rectangle
    graphics.setColor(Color.WHITE);
    graphics.fillRect(EDGE_OFFSET, EDGE_OFFSET, w - 2 * EDGE_OFFSET, h - 2 * EDGE_OFFSET);
    graphics.setColor(Constants.COLOR_ERROR);
    graphics.drawRect(EDGE_OFFSET, EDGE_OFFSET, w - 2 * EDGE_OFFSET, h - 2 * EDGE_OFFSET);

    // draw invalidated sign
    graphics.drawLine(EDGE_OFFSET, EDGE_OFFSET, w - EDGE_OFFSET, h - EDGE_OFFSET);
    graphics.drawLine(EDGE_OFFSET, h - EDGE_OFFSET, w - EDGE_OFFSET, EDGE_OFFSET);

    // draw border
    int wmeo = w - EDGE_OFFSET;
    int hmeo = h - EDGE_OFFSET;
    for (int j = BORDER_LINES_STEP * 2; j <= hmeo; j += BORDER_LINES_STEP) {
      graphics.drawLine(0, j, EDGE_OFFSET, j - BORDER_LINES_STEP);
      graphics.drawLine(wmeo, j, w, j - BORDER_LINES_STEP);
    }
    for (int i = 0; i <= wmeo; i += BORDER_LINES_STEP) {
      graphics.drawLine(i, EDGE_OFFSET, i + BORDER_LINES_STEP, 0);
      graphics.drawLine(i, h, i + BORDER_LINES_STEP, hmeo);
    }

    // draw component type name and instance name
    if (properties.drawingComponentNames) {
      Font oldf = graphics.getFont();
      Color oldc = graphics.getColor();

      Font f = new Font(Constants.TEXT_FONT_CANVAS, Font.PLAIN, Constants.TEXT_NORMAL_FONT_SIZE);
      graphics.setFont(f);
      graphics.drawString(
          cmptodraw.getName().toString(), 0, -Constants.TEXT_NORMAL_FONT_SIZE * 1.5f);

      f = new Font(Constants.TEXT_FONT_CANVAS, Font.PLAIN, Constants.TEXT_SMALL_FONT_SIZE);
      int r = oldc.getRed() + 140;
      r = (r > 230) ? (230) : (r);
      int g = oldc.getGreen() + 140;
      g = (g > 230) ? (230) : (g);
      int b = oldc.getBlue() + 140;
      b = (b > 230) ? (230) : (b);
      graphics.setColor(new Color(r, g, b));
      graphics.setFont(f);
      graphics.drawString(componentName, 0, -Constants.TEXT_NORMAL_FONT_SIZE * 0.5f);

      graphics.setFont(oldf);
      graphics.setColor(oldc);
    }

    graphics.setColor(startingcol);
    graphics.setFont(startingfont);
  }
Ejemplo n.º 2
0
  /**
   * Describe what the method does
   *
   * @todo-javadoc Write javadocs for method
   * @todo-javadoc Write javadocs for method parameter
   * @param g Describe what the parameter does
   */
  public void paint(Graphics2D g) {
    g.setRenderingHints(_renderHints);
    /*
     *  if( isSelected() ) {
     *  g.setColor( Color.red );
     *  } else {
     *  g.setColor( Color.black );
     *  }
     */
    if (_leftRole.getRelation().isMany2Many()) {
      g.setStroke(_dashedStroke);
    } else {
      g.setStroke(_regularStroke);
    }
    drawLineUnlessItsLengthIsZero(g, _mainLine);

    g.setStroke(_regularStroke);
    for (int i = 0; i < _leftLines.length; i++) {
      drawLineUnlessItsLengthIsZero(g, _leftLines[i]);
    }
    for (int i = 0; i < _rightLines.length; i++) {
      drawLineUnlessItsLengthIsZero(g, _rightLines[i]);
    }
    drawImage(
        g,
        getDisplayImage(_rightRole, g.getColor()),
        _leftCardinalityPoint.x - 8,
        _leftCardinalityPoint.y - 8);
    drawImage(
        g,
        getDisplayImage(_leftRole, g.getColor()),
        _rightCardinalityPoint.x - 8,
        _rightCardinalityPoint.y - 8);

    if (_rightRole.isEnabled()) {
      drawLineUnlessItsLengthIsZero(g, _leftArrowLine1);
      drawLineUnlessItsLengthIsZero(g, _leftArrowLine2);
    }
    if (_leftRole.isEnabled()) {
      drawLineUnlessItsLengthIsZero(g, _rightArrowLine1);
      drawLineUnlessItsLengthIsZero(g, _rightArrowLine2);
    }

    // draw the fk image
    if (!_leftRole.isOriginPrimaryKey()) {
      drawImage(g, _fk, _leftFkPoint.x - 6, _leftFkPoint.y - 6);
    }
    if (!_rightRole.isOriginPrimaryKey()) {
      drawImage(g, _fk, _rightFkPoint.x - 6, _rightFkPoint.y - 6);
    }
  }
Ejemplo n.º 3
0
  public static Shape draw(
      Graphics2D g2, Parameters param, GRenderer gRendreres, Shape shape, Point2D center) {
    shape = transformeShape(param, gRendreres, shape, center);

    Stroke oldStroke = g2.getStroke();
    Color oldColor = g2.getColor();
    /*TODO : Regarder setPaint*/

    Stroke newStroke = (Stroke) param.getObject(Parameters.ParameterType.Stroke);
    if (newStroke != null) {
      g2.setStroke(newStroke);
    }
    Color c = param.getColor(Parameters.ParameterType.BgColor);
    if (c != null) {

      g2.setColor(c);
      g2.fill(shape);
    }
    c = param.getColor(Parameters.ParameterType.FgColor);
    if (c != null) {
      g2.setColor(c);
      g2.draw(shape);
    }

    g2.setColor(oldColor);
    g2.setStroke(oldStroke);
    return shape;
  }
Ejemplo n.º 4
0
 @Override
 public void paint(Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   Stroke initialStroke = g2.getStroke();
   Color initialColor = g2.getColor();
   if (drawConcrete) {
     g2.setColor(Color.LIGHT_GRAY);
     g2.fill(getBounds());
   }
   g2.translate(loc.getX(), loc.getY());
   g2.rotate(rot);
   if (picture != null) {
     g2.drawImage(picture, -picture.getWidth(null) / 2, -picture.getHeight(null) / 2, null);
   }
   g2.setStroke(stroke);
   for (int i = 0; i < complexity; i++) {
     g2.translate(rLoc[i].getX(), rLoc[i].getY());
     g2.rotate(rRot[i]);
     g2.setColor(rCol[i]);
     if (rFill[i]) {
       g2.fill(rShape[i]);
     } else {
       g2.draw(rShape[i]);
     }
     g2.rotate(-rRot[i]);
     g2.translate(-rLoc[i].getX(), -rLoc[i].getY());
   }
   g2.setColor(initialColor);
   g2.setStroke(initialStroke);
   g2.rotate(-rot);
   g2.translate(-loc.getX(), -loc.getY());
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
0
  @Override
  public void drawShape() {
    Graphics2D graphics = (Graphics2D) getGraphics();
    Color oldFg = graphics.getColor();
    Table table = getDbModel();
    if (null != table) {
      Point location = getLocation();
      Dimension size = getSize();
      // draw the border
      graphics.setColor(DbexColorConstants.TABLE_BORDER_COLOR);
      graphics.drawRect(location.x, location.y, size.width, size.height);
      graphics.setColor(DbexColorConstants.COLUMN_NAMES_BG_COLOR);
      graphics.fillRect(location.x + 1, location.y + 1, size.width - 1, size.height - 1);
      // draw the header
      graphics.setColor(DbexColorConstants.TABLE_BORDER_COLOR);
      graphics.drawRect(
          location.x, location.y, size.width, DesignUtil.calculateCellHeight(graphics));
      graphics.setColor(DbexColorConstants.TABLE_HEADER_BG_COLOR);
      graphics.fillRect(
          location.x + 1,
          location.y + 1,
          size.width - 1,
          DesignUtil.calculateCellHeight(graphics) - 1);
      graphics.setColor(DbexColorConstants.TABLE_HEADER_FG_COLOR);
      graphics.drawString(
          table.getModelName(),
          location.x + 2,
          location.y + DesignUtil.calculateCellHeight(graphics) - 4);
      // draw the left margin
      graphics.setColor(DbexColorConstants.TABLE_BORDER_COLOR);
      graphics.drawRect(
          location.x,
          location.y + DesignUtil.calculateCellHeight(graphics),
          DbexDesignConstants.TABLE_LEFT_MARGIN_WIDTH,
          size.height - DesignUtil.calculateCellHeight(graphics));
      graphics.setColor(DbexColorConstants.TABLE_LEFT_MARGIN_BG_COLOR);
      graphics.fillRect(
          location.x + 1,
          location.y + DesignUtil.calculateCellHeight(graphics) + 1,
          DbexDesignConstants.TABLE_LEFT_MARGIN_WIDTH - 1,
          size.height - 1 - DesignUtil.calculateCellHeight(graphics));

      // draw columns
      if (null != columnDbShapes) {
        for (int i = 0; i < columnDbShapes.size(); i++) {
          ColumnDbShape columnDbShape = columnDbShapes.get(i);
          columnDbShape.drawShape();
          if (i < columnDbShapes.size() - 1) {
            graphics.setColor(DbexColorConstants.TABLE_BORDER_COLOR);
            graphics.drawLine(
                columnDbShape.getX() + DbexDesignConstants.TABLE_LEFT_MARGIN_WIDTH + 2,
                columnDbShape.getY() + columnDbShape.getHeight() + 2,
                location.x + size.width,
                columnDbShape.getY() + columnDbShape.getHeight() + 2);
          }
        }
      }
    }
    graphics.setColor(oldFg);
  }
  public void drawEdge(Graphics2D g, VisualEdge edge) {
    VisualNode fromAnc = edge.getFrom().getVisibleAncestor();
    VisualNode toAnc = edge.getTo().getVisibleAncestor();

    if (fromAnc == toAnc) return;

    Vec2 toPos = toAnc.getPos();
    Vec2 fromPos = fromAnc.getPos();

    setWeightAndColor(g, edge);

    this.updateCurve(edge);
    g.draw(curve);

    if (!edge.isSymmetric()) {
      GeneralPath p = this.getVectorShape(edge);
      // g.draw(p);

      if (this.gradientColor) {
        Paint gradient =
            new GradientPaint(
                (float) fromPos.toPoint().getX(),
                (float) fromPos.toPoint().getY(),
                Color.WHITE,
                (float) toPos.toPoint().getX(),
                (float) toPos.toPoint().getY(),
                g.getColor());
        g.setPaint(gradient);
      }

      if (this.strokeLines) g.draw(p);

      g.fill(p);
    }
  }
Ejemplo n.º 8
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);
 }
Ejemplo n.º 9
0
 @Override
 public void paintComponent(Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   Object hint = new Object();
   if (isAntialiased()) {
     hint = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
     g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   }
   translation = getTranslation();
   Color oldColor = g2.getColor();
   g2.setColor(new Color(230, 230, 250));
   g2.fill(translation.createTransformedShape(getShape()));
   g2.setColor(Color.BLACK);
   g2.draw(translation.createTransformedShape(getShape()));
   if (isShowingSensors) {
     for (Iterator<Sensor> sIter = sensors.iterator(); sIter.hasNext(); ) {
       Sensor s = (Sensor) sIter.next();
       s.paintComponent(g2);
     }
   }
   if (isShowingStatusFrame) {
     paintStatusFrame(g2);
   }
   g2.setColor(oldColor);
   if (isAntialiased()) {
     g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, hint);
   }
 }
Ejemplo n.º 10
0
  public void draw(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;

    int hGap = 0;
    int y1 = this.y1;

    if (hPosition) {
      hGap = hGap + grpage.hPosition;
      gapH = hGap;
    }

    y1 = y1 + hGap;

    Color oldC = g2d.getColor();
    Stroke oldStroke = g2d.getStroke();

    g2d.setColor(Color.BLUE);
    Composite compositeOld = g2d.getComposite();

    if (selected) {
      g2d.setStroke(new BasicStroke(2.0f));
    }
    g2d.drawRect(0, y1, width, height);

    g2d.setComposite(composite);
    g2d.setPaint(Color.BLUE);
    g2d.fill(new Rectangle(0, y1, width, height));

    g2d.setComposite(compositeOld);
    g2d.setColor(oldC);
    g2d.setStroke(oldStroke);

    yRelative = y1;
    grpage.hPosition = y1 + height;
  }
Ejemplo n.º 11
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();
 }
Ejemplo n.º 12
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();
 }
Ejemplo n.º 13
0
  // TODO misleading name - is centered around point and scaled font but not scale center point
  // (probably :)
  public void drawAntialiasedTextCenteredNoScale(
      Graphics2D g2,
      String text,
      int fontSize,
      Position pos,
      ImmutablePoint center,
      Color fgColor,
      Color bgColor) {
    Color original = g2.getColor();
    FontRenderContext frc = g2.getFontRenderContext();
    TextLayout tl = new TextLayout(text, getFont(fontSize), frc);
    Rectangle2D bounds = tl.getBounds();

    center = center.translate((int) (bounds.getWidth() / -2), (int) (bounds.getHeight() / -2));

    if (bgColor != null) {
      g2.setColor(bgColor);
      g2.fillRect(
          getOffsetX(pos) + center.getX() - 6,
          getOffsetY(pos) + center.getY() - 5,
          12 + (int) bounds.getWidth(),
          10 + (int) bounds.getHeight());
    }

    g2.setColor(fgColor);
    tl.draw(
        g2,
        getOffsetX(pos) + center.getX(),
        getOffsetY(pos) + center.getY() + (int) bounds.getHeight());
    g2.setColor(original);
  }
Ejemplo n.º 14
0
  public void switchForegroundBackgroundColors() {
    Color fg = gc.getColor();
    Color bg = gc.getBackground();

    gc.setColor(bg);
    gc.setBackground(fg);
  }
Ejemplo n.º 15
0
  /** 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);
    }
  }
Ejemplo n.º 16
0
 private void createButtonRect(Graphics2D g, boolean raised) {
   Color oldColor = g.getColor();
   g.setColor(this.ButtonColor);
   g.fill3DRect(
       (int) super.getX(), (int) super.getY(), this.ButtonWidth, this.ButtonHeight, raised);
   g.setColor(oldColor);
 }
Ejemplo n.º 17
0
  @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);
  }
 /**
  * Draw the decoration. If the curve is null when this is called, then curve will be set to the
  * exhibit displayed in the View, which should be of type PlaneCurveParameteric, if this
  * decoration is being used correctly.
  */
 public void doDraw(Graphics2D g, View view, Transform limits) {
   if (curve == null && view != null) {
     Exhibit c = view.getExhibit();
     if (c instanceof PlaneCurveParametric) // It better be!
     curve = (PlaneCurveParametric) c;
     else return;
   }
   if (Double.isNaN(t)) return;
   double x = curve.xValue(t);
   if (Double.isNaN(x) || Double.isInfinite(x)) return;
   double y = curve.yValue(t);
   if (Double.isNaN(y) || Double.isInfinite(y)) return;
   double dx = curve.xDerivativeValue(t);
   if (Double.isNaN(dx) || Double.isInfinite(dx)) return;
   double dy = curve.yDerivativeValue(t);
   if (Double.isNaN(dy) || Double.isInfinite(dy)) return;
   double length = Math.sqrt(dx * dx + dy * dy);
   if (length == 0) return;
   dx = dx / length * 40 * limits.getPixelWidth();
   dy = dy / length * 40 * limits.getPixelHeight();
   Color saveColor = g.getColor();
   Stroke saveStroke = g.getStroke();
   g.setStroke(new BasicStroke(2 * limits.getDefaultStrokeSize()));
   g.setColor(Color.red);
   g.draw(new Line2D.Double(x, y, x + dx, y + dy));
   g.setColor(Color.blue);
   g.draw(new Line2D.Double(x, y, x - dy, y + dx));
   g.setColor(saveColor);
   g.setStroke(saveStroke);
 }
Ejemplo n.º 19
0
  @Override
  public void Draw(Graphics2D g, double zoomFactor, boolean isDeleted, boolean isSelected) {

    // Save the previous color to restore it later
    Color prev = g.getColor();

    if ((!isSelected) && (!isDeleted)) {
      g.setColor(Color.BLACK);
    }

    if ((isSelected) && (!isDeleted)) {
      g.setColor(Color.GREEN);
    }

    if ((!isSelected) && (isDeleted)) {
      g.setColor(Color.RED);
    }

    if ((isSelected) && (isDeleted)) {
      g.setColor(Color.ORANGE);
    }

    // Draw the polygon representing the element
    g.fill(shape);

    g.setColor(prev);
  }
Ejemplo n.º 20
0
 /**
  * fill - overrides parent method
  *
  * <p>See implementation comments in the AEllipse class.
  */
 public void fill(java.awt.Graphics2D brush2D) {
   Color savedColor = brush2D.getColor();
   brush2D.setColor(_fillColor);
   brush2D.fill(this); // "this" class, ARoundRectangle, is subclass
   // of java.awt.geom.Rectangle2D.Double
   // A Graphics2D object knows how to fill it.
   brush2D.setColor(savedColor);
 }
Ejemplo n.º 21
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);
 }
Ejemplo n.º 22
0
 private void renderEnergyBar(Entity entity, int x, int y) {
   int yPos = y + ((int) entity.boundingRadius() + 10);
   graphics.drawRect(x - 15, yPos, 30, 7);
   Color originalColor = graphics.getColor();
   graphics.setColor(Color.BLUE);
   double energyBarLength = 29.0 * entity.energy();
   graphics.fillRect(x - 14, yPos + 1, (int) energyBarLength, 6);
   graphics.setColor(originalColor);
 }
 private void doPaint(Graphics2D g, Rectangle r) {
   Color old = g.getColor();
   g.setColor(getForeground());
   g.drawLine(r.x, r.y, r.x + r.width, r.y + r.height);
   g.drawLine(r.x + 1, r.y, r.x + r.width + 1, r.y + r.height);
   g.drawLine(r.x + r.width, r.y, r.x, r.y + r.height);
   g.drawLine(r.x + r.width - 1, r.y, r.x - 1, r.y + r.height);
   g.setColor(old);
 }
Ejemplo n.º 24
0
 private void renderHealthBar(Entity entity, int x, int y) {
   int yPos = y - ((int) entity.boundingRadius() + 10);
   graphics.drawRect(x - 15, yPos, 30, 7);
   Color originalColor = graphics.getColor();
   double health = entity.health();
   graphics.setColor(getColorFor(health));
   double healthBarLength = 29.0 * health;
   graphics.fillRect(x - 14, yPos + 1, (int) healthBarLength, 6);
   graphics.setColor(originalColor);
 }
Ejemplo n.º 25
0
 /**
  * @param x
  * @param y
  * @param color
  */
 public void drawDot(double x, double y, Color color) {
   double dotSize = 10;
   Color lastColor = g2d.getColor();
   Ellipse2D.Double circle =
       new Ellipse2D.Double(
           World.kmToPx(x) - dotSize / 2, World.kmToPx(y) - dotSize / 2, dotSize, dotSize);
   g2d.setColor(color);
   g2d.fill(circle);
   g2d.setColor(lastColor);
 }
Ejemplo n.º 26
0
 public void paintIcon(Component c, Graphics g, int x, int y) {
   Rectangle r = new Rectangle(x, y, WIDTH - 1, HEIGHT - 1);
   Graphics2D g2 = (Graphics2D) g;
   Color oldColor = g2.getColor();
   g2.setColor(color);
   g2.fill(r);
   g2.setColor(Color.BLACK);
   g2.draw(r);
   g2.setColor(oldColor);
 }
Ejemplo n.º 27
0
  @Override
  protected void drawStroke(Graphics2D g) {
    Color color = g.getColor();
    Stroke stroke = g.getStroke();

    g.draw(rec);

    g.setStroke(stroke);
    g.setColor(color);
  }
Ejemplo n.º 28
0
  public void plotNode(Graphics2D g2, int loc, Color c) {
    double lat = g.getLatitude(loc);
    double lon = g.getLongitude(loc);
    if (lat < bounds.minLat || lat > bounds.maxLat || lon < bounds.minLon || lon > bounds.maxLon)
      return;

    Color old = g2.getColor();
    g2.setColor(c);
    plot(g2, lat, lon, 4);
    g2.setColor(old);
  }
Ejemplo n.º 29
0
  /**
   * 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);
  }
Ejemplo n.º 30
-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);
   }
 }