コード例 #1
0
  // public void render(Graphics2D g2){}
  @Override
  public void render(
      final int type, final Graphics2D g2, final float scaling, final boolean isFormGlyph) {

    final AffineTransform restore = g2.getTransform();
    final BasicStroke oldStroke = (BasicStroke) g2.getStroke();

    float strokeWidth = oldStroke.getLineWidth();

    if (strokeWidth < 0) {
      strokeWidth = -strokeWidth;
    }

    if (useHinting) {
      // Scale down glyph
      g2.scale(1 / 100d, 1 / 100d);

      // Widen stroke to compensate for scale
      strokeWidth *= 100;
    }

    g2.setStroke(
        new BasicStroke(
            strokeWidth,
            BasicStroke.CAP_BUTT,
            BasicStroke.JOIN_ROUND,
            oldStroke.getMiterLimit(),
            oldStroke.getDashArray(),
            oldStroke.getDashPhase()));

    /* drawn the paths*/
    for (int jj = 0; jj < paths.size() - 1; jj++) {

      if ((type & GraphicsState.FILL) == GraphicsState.FILL) {
        g2.fill(paths.elementAt(jj));
      } else if ((type & GraphicsState.STROKE) == GraphicsState.STROKE) {

        if (!hasEndCurve
            || !((((BasicStroke) g2.getStroke()).getDashPhase() == 0.0f)
                && ((BasicStroke) g2.getStroke()).getDashArray() != null)) {

          g2.draw(paths.elementAt(jj));
        }
      }
    }

    if (useHinting) {
      // Restore stroke width and scaling
      g2.setStroke(oldStroke);
      g2.setTransform(restore);
    }
  }
コード例 #2
0
  @Override
  public void draw(Graphics2D g) {
    g.setColor(color.getProp());
    if (bSelected) g.setColor(Color.BLACK);

    Vec2 point = null;
    Vec2 point1 = null;
    for (int i = 0; i < getNumPointsWithPort() - 1; i++) {
      point = getPointWithPort(i);
      point1 = getPointWithPort(i + 1);

      Line2D line = new Line2D.Float(point.x, point.y, point1.x, point1.y);
      drawHighlight(g, line);
      if (bSelected) {
        // Color c=g.getColor();
        // drawShade(g, line, Color.ORANGE, 5);
        // g.setColor(c);
        Color c = g.getColor();
        g.setColor(Color.ORANGE);
        Stroke oldStroke = g.getStroke();
        BasicStroke stroke = createStroke(width.getProp() + 3);
        g.setStroke(stroke);
        g.drawLine((int) point.x, (int) point.y, (int) point1.x, (int) point1.y);
        g.setStroke(oldStroke);
        g.setColor(c);
      }
      ;

      Stroke oldStroke = g.getStroke();
      BasicStroke stroke = getLineStroke();
      g.setStroke(stroke);
      g.draw(line);
      g.setStroke(oldStroke);

      g.setColor(Color.BLACK);
      if (i == 0) {
        g.fillOval((int) point.x - 3, (int) point.y - 3, 6, 6);
      }
      if (i == getNumPointsWithPort() - 2) {
        g.fillOval((int) point1.x - 3, (int) point1.y - 3, 6, 6);
      }
      ;
    }
    ;

    super.draw(g);
    return;
  }
コード例 #3
0
ファイル: GObjectShape.java プロジェクト: coast-team/rivage
  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;
  }
コード例 #4
0
ファイル: AbstractPaintable.java プロジェクト: Joishi/OldCode
 @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());
 }
コード例 #5
0
ファイル: Place.java プロジェクト: mouillerart/greyc-iota
  /*
   * Draws this place.
   */
  void paint(Graphics g) {
    super.paint(g); // very important, do not forget

    Graphics2D g2 = (Graphics2D) g;
    int w = this.getSize().width;
    int h = this.getSize().height;
    int x = this.getPosition().x - (w >> 1);
    int y = this.getPosition().y - (h >> 1);

    // draw forground
    if (this.getAction()) g2.setPaint(this.actionColor);
    else if (this.getSelected()) g2.setPaint(this.selectColor);
    else if (this.getEmphasized()) g2.setPaint(emphasize_color);
    // else g2.setPaint(new GradientPaint(x,y,this.foreground_color,x+w,y+h,Color.white));
    else g2.setPaint(Props.PLACE_FILL_COLOR);

    if (isMouseOver()) {
      Color c = (Color) g2.getPaint();
      g2.setPaint(new Color(c.getRed() ^ 0x66, c.getGreen() ^ 0x00, c.getBlue() ^ 0x00));
    }

    g2.fillOval(x, y, w, h);

    // draw background

    g2.setPaint(Props.PLACE_BORDER_COLOR);
    if (this.getJoined()) {
      Stroke oldStroke = g2.getStroke();
      g2.setStroke(new BasicStroke(2.5f));
      g2.drawOval(x, y, w, h);
      g2.setStroke(oldStroke);
    } else g2.drawOval(x, y, w, h);
  }
コード例 #6
0
  @Override
  protected void paint(DecorationLayer layer, Graphics2D g, RadComponent container) {
    if (!layer.showSelection() || container.getClientProperty(SnapPointFeedbackHost.KEY) != null) {
      return;
    }

    Stroke stroke = g.getStroke();
    g.setStroke(SnapPointFeedbackHost.STROKE);
    g.setColor(SnapPointFeedbackHost.COLOR);

    Rectangle bounds = container.getBounds(layer);
    Map<RadComponent, RelativeInfo> relativeInfos = container.getClientProperty(RelativeInfo.KEY);
    List<RadComponent> selection = layer.getArea().getSelection();

    for (RadComponent component : selection) {
      RelativeInfo info = relativeInfos.get(component);
      if (info != null) {
        paintOutRelative(layer, g, component, info);
        paintContainerRelative(g, bounds, info);
      }
    }

    g.setStroke(stroke);
    g.setColor(JBColor.ORANGE);

    for (RadComponent component : selection) {
      RelativeInfo info = relativeInfos.get(component);
      if (info != null) {
        paintContainerMarginRelative(layer, g, bounds, (RadViewComponent) component, info);
      }
    }
  }
コード例 #7
0
    /**
     * Hook for subclassers to paint the background page(s).
     *
     * @param g2 The graphics object to paint the background page(s) on.
     */
    protected void paintBackgroundPages(Graphics2D g2) {
      Point2D p = graph.toScreen(new Point2D.Double(pageFormat.getWidth(), pageFormat.getHeight()));
      Dimension pSize = graph.getPreferredSize();
      int w = (int) (p.getX() * pageScale);
      int h = (int) (p.getY() * pageScale);
      int cols = (int) Math.max(Math.ceil((double) (pSize.width - 5) / (double) w), 1);
      int rows = (int) Math.max(Math.ceil((double) (pSize.height - 5) / (double) h), 1);
      g2.setColor(graph.getHandleColor());

      // Draws the pages.
      Point offset = getViewPosition();
      g2.translate(-offset.x, -offset.y);
      g2.fillRect(0, 0, graph.getWidth(), graph.getHeight());
      g2.setColor(Color.darkGray);
      g2.fillRect(3, 3, cols * w, rows * h);
      g2.setColor(getGraph().getBackground());
      g2.fillRect(1, 1, cols * w - 1, rows * h - 1);

      // Draws the pagebreaks.
      Stroke previousStroke = g2.getStroke();
      g2.setStroke(
          new BasicStroke(
              1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] {1, 2}, 0));
      g2.setColor(Color.darkGray);
      for (int i = 1; i < cols; i++) g2.drawLine(i * w, 1, i * w, rows * h - 1);
      for (int i = 1; i < rows; i++) g2.drawLine(1, i * h, cols * w - 1, i * h);

      // Restores the graphics.
      g2.setStroke(previousStroke);
      g2.translate(offset.x, offset.y);
      g2.clipRect(0, 0, cols * w - 1 - offset.x, rows * h - 1 - offset.y);
    }
コード例 #8
0
ファイル: Dissector.java プロジェクト: WXrock/TrakEM2
  @Override
  public void paint(
      final Graphics2D g,
      final Rectangle srcRect,
      final double magnification,
      final boolean active,
      final int channels,
      final Layer active_layer,
      final List<Layer> layers) {
    AffineTransform gt = null;
    Stroke stroke = null;
    AffineTransform aff = this.at;
    // remove graphics transform
    if (!"true".equals(getProject().getProperty("dissector_zoom"))) {
      gt = g.getTransform();
      g.setTransform(new AffineTransform()); // identity
      stroke = g.getStroke();
      g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
      aff = new AffineTransform(gt);
      aff.concatenate(this.at);
    }

    for (final Item item : al_items) {
      item.paint(g, aff, active_layer);
    }

    // restore
    if (null != gt) g.setTransform(gt);
    if (null != stroke) g.setStroke(stroke);
  }
コード例 #9
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);
    }
  }
コード例 #10
0
  public void drawMultiInstanceMarker(boolean sequential, int x, int y, int width, int height) {
    int rectangleWidth = MARKER_WIDTH;
    int rectangleHeight = MARKER_WIDTH;
    int lineX = x + (width - rectangleWidth) / 2;
    int lineY = y + height - rectangleHeight - 3;

    Stroke orginalStroke = g.getStroke();
    g.setStroke(MULTI_INSTANCE_STROKE);

    if (sequential) {
      g.draw(new Line2D.Double(lineX, lineY, lineX + rectangleWidth, lineY));
      g.draw(
          new Line2D.Double(
              lineX,
              lineY + rectangleHeight / 2,
              lineX + rectangleWidth,
              lineY + rectangleHeight / 2));
      g.draw(
          new Line2D.Double(
              lineX, lineY + rectangleHeight, lineX + rectangleWidth, lineY + rectangleHeight));
    } else {
      g.draw(new Line2D.Double(lineX, lineY, lineX, lineY + rectangleHeight));
      g.draw(
          new Line2D.Double(
              lineX + rectangleWidth / 2,
              lineY,
              lineX + rectangleWidth / 2,
              lineY + rectangleHeight));
      g.draw(
          new Line2D.Double(
              lineX + rectangleWidth, lineY, lineX + rectangleWidth, lineY + rectangleHeight));
    }

    g.setStroke(orginalStroke);
  }
コード例 #11
0
  private void drawShape(Shuttle shuttle) {
    Graphics2D g = shuttle.g;
    Shape oldclip = shuttle.g.getClip();
    g.setClip(shuttle.clip);
    Composite oldcomposite = g.getComposite();
    if (shuttle.opacity != 1f) {
      g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, shuttle.opacity));
    }

    AffineTransform oldtr = g.getTransform();
    g.setTransform(shuttle.transform);

    Stroke oldStroke = g.getStroke();
    Stroke newStroke =
        new BasicStroke(shuttle.strokeWidth, shuttle.linecap.stroke(), shuttle.linejoin.stroke());
    g.setStroke(newStroke);

    if (shuttle.fill != null) {
      g.setPaint(shuttle.fill);
      g.fill(shuttle.shape);
    }
    if (shuttle.stroke != null) {
      g.setPaint(shuttle.stroke);
      g.draw(shuttle.shape);
    }
    g.setClip(oldclip);
    g.setStroke(oldStroke);
    g.setTransform(oldtr);
    g.setComposite(oldcomposite);
  }
コード例 #12
0
 /** 自定义虚线的绘制方法 */
 protected void drawLine(Graphics2D g2d, int x1, int y1, int x2, int y2) {
   Stroke stroke = g2d.getStroke();
   g2d.setStroke(
       new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, dashparams, 0));
   super.drawLine(g2d, x1, y1, x2, y2);
   g2d.setStroke(stroke);
 }
  private void showScale(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setColor(Color.lightGray);
    int y_step = 20;
    float[] dash1 = {2f, 0f, 2f};

    Stroke strk = g2d.getStroke();

    g2d.setStroke(
        new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash1, 2f));
    for (int y = m_y_offset - y_step; y > m_y_offset - (int) (m_height * 0.5); y -= y_step)
      g2d.drawLine(m_x_offset, y, m_width - m_x_offset, y);
    for (int y = m_y_offset + y_step; y < m_y_offset + (int) (m_height * 0.5); y += y_step)
      g2d.drawLine(m_x_offset, y, m_width - m_x_offset, y);

    for (int x = m_x_offset + y_step; x < m_width - m_x_offset; x += y_step)
      g2d.drawLine(x, m_y_offset - (int) (m_height * 0.5), x, m_y_offset + (int) (m_height * 0.5));

    Font cur_Font = new Font("Arial", Font.BOLD, 8);
    g.setFont(cur_Font);

    int i = y_step;
    for (int y = m_y_offset - y_step;
        y > m_y_offset - (int) (m_height * 0.5);
        y -= y_step, i += y_step) g.drawString(i + "", m_width - m_x_offset, y);
    i = -y_step;
    for (int y = m_y_offset + y_step;
        y < m_y_offset + (int) (m_height * 0.5);
        y += y_step, i -= y_step) g.drawString(i + "", m_width - m_x_offset, y);

    g2d.setStroke(strk);
  }
コード例 #14
0
  public void draw(Graphics g) {
    // 19-2-2008 Removed showing the horizontal and vertical segment constraints
    if (true) return;
    if ((m_seg.getM_parentStk().getM_type() == Stroke.TYPE_NORMAL) && (m_seg.isEnabled())) {
      Graphics2D g2d = (Graphics2D) g;
      // set the color of the graphics to the color of the segment
      Color prevColor = g.getColor();
      g2d.setColor(getColor());

      // create a dashed line for radii lines
      BasicStroke prevStroke = (BasicStroke) g2d.getStroke();
      g2d.setColor(GVariables.DRAWING_ASSIST_COLOR);
      g2d.setStroke(
          new BasicStroke(
              prevStroke.getLineWidth(),
              prevStroke.getEndCap(),
              prevStroke.getLineJoin(),
              prevStroke.getMiterLimit(),
              new float[] {4, 4, 8, 4},
              prevStroke.getDashPhase()));
      g2d.draw(marker_line);
      g2d.setStroke(prevStroke);
      g2d.draw(marker_rect);

      // reset the graphics color back
      g2d.setColor(prevColor);
    }
  }
コード例 #15
0
ファイル: GameState.java プロジェクト: mgriley/hive-wars
  private void drawSelectionBox(Graphics2D g2d) {

    // Draw the rectangular selection box
    if (leftMousePressed && !startedInMiniMap && !startedInHiveCreation) {

      Pt topLeft = new Pt();
      topLeft.setX(Math.min(mouseGlobal.x(), startSelect.x()));
      topLeft.setY(Math.min(mouseGlobal.y(), startSelect.y()));

      int width = (int) Math.abs(mouseGlobal.x() - startSelect.x());
      int height = (int) Math.abs(mouseGlobal.y() - startSelect.y());

      g2d.setColor(Color.GREEN);
      Stroke original = g2d.getStroke();
      int dashOneLength = 3;
      int dashInterval = 5;
      int dashTwoLength = dashOneLength * 5;
      g2d.setStroke(
          new BasicStroke(
              1,
              BasicStroke.CAP_BUTT,
              BasicStroke.JOIN_BEVEL,
              0,
              new float[] {dashOneLength, dashInterval, dashTwoLength, dashInterval},
              0));
      g2d.drawRect(topLeft.intX(), topLeft.intY(), width, height);
      g2d.setStroke(original);
    }
  }
コード例 #16
0
  private void plot(Graphics2D g, Material material, Shape shape, boolean subdued) {
    final Stroke savedStroke = g.getStroke();
    g.setStroke(plotStroke);
    double yTensile = Inventory.tensileStrength(material, shape);
    final int iy = yPlotAreaBottom - (int) Math.round((yTensile / yMax) * heightPlotArea);
    g.setColor(subdued ? subduedBlue : Color.BLUE);
    g.drawLine(xPlotAreaLeft, iy, xPlotAreaRight, iy);

    final int nPlotPoints = 32;
    double yCompressive = Inventory.compressiveStrength(material, shape, 0.0);
    int iy0 = yPlotAreaBottom - (int) Math.round((yCompressive / yMax) * heightPlotArea);
    int ix0 = xPlotAreaLeft;
    g.setColor(subdued ? subduedRed : Color.RED);
    for (int i = 1; i <= nPlotPoints; i++) {
      double t = (double) i / nPlotPoints;
      double x = t * xMax;
      int ix1 = xPlotAreaLeft + (int) Math.round(t * widthPlotArea);
      yCompressive = Inventory.compressiveStrength(material, shape, x);
      int iy1 = yPlotAreaBottom - (int) Math.round((yCompressive / yMax) * heightPlotArea);
      g.drawLine(ix0, iy0, ix1, iy1);
      ix0 = ix1;
      iy0 = iy1;
    }
    g.setStroke(savedStroke);
    g.setColor(Color.BLACK);
  }
コード例 #17
0
  public void drawExclusiveGateway(int x, int y, int width, int height) {
    // rhombus
    drawGateway(x, y, width, height);

    int quarterWidth = width / 4;
    int quarterHeight = height / 4;

    // X inside rhombus
    Stroke orginalStroke = g.getStroke();
    g.setStroke(GATEWAY_TYPE_STROKE);
    Line2D.Double line =
        new Line2D.Double(
            x + quarterWidth + 3,
            y + quarterHeight + 3,
            x + 3 * quarterWidth - 3,
            y + 3 * quarterHeight - 3);
    g.draw(line);
    line =
        new Line2D.Double(
            x + quarterWidth + 3,
            y + 3 * quarterHeight - 3,
            x + 3 * quarterWidth - 3,
            y + quarterHeight + 3);
    g.draw(line);

    g.setStroke(orginalStroke);
  }
コード例 #18
0
  protected void drawTask(String name, int x, int y, int width, int height, boolean thickBorder) {
    Paint originalPaint = g.getPaint();

    // Create a new gradient paint for every task box, gradient depends on x and y and is not
    // relative
    g.setPaint(new GradientPaint(x + 50, y, Color.white, x + 50, y + 50, TASK_BOX_COLOR));

    // shape
    RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width, height, 20, 20);
    g.fill(rect);
    g.setPaint(originalPaint);

    if (thickBorder) {
      Stroke originalStroke = g.getStroke();
      g.setStroke(THICK_TASK_BORDER_STROKE);
      g.draw(rect);
      g.setStroke(originalStroke);
    } else {
      g.draw(rect);
    }

    // text
    if (name != null) {
      drawMultilineText(name, x, y, width, height);
    }
  }
コード例 #19
0
 /**
  * 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);
 }
コード例 #20
0
ファイル: Jclec.java プロジェクト: RubelAhmed57/KEEL
  /**
   * Draw method
   *
   * @param g2 Graphics element
   * @param select Selected node
   */
  public void draw(Graphics2D g2, boolean select) {
    Point pinit = new Point(centre.x - 25, centre.y - 25);
    Point pfin = new Point(centre.x + 25, centre.y + 25);
    figure =
        new RoundRectangle2D.Float(
            pinit.x, pinit.y, Math.abs(pfin.x - pinit.x), Math.abs(pfin.y - pinit.y), 20, 20);

    g2.setColor(Color.black);
    if (select) {
      Stroke s = g2.getStroke();
      g2.setStroke(
          new BasicStroke(
              5, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] {1, 1}, 0));
      g2.draw(figure);
      g2.setStroke(s);
    } else {
      g2.draw(figure);
    }
    g2.drawImage(image, centre.x - 25, centre.y - 25, 50, 50, pd);

    g2.setFont(new Font("Courier", Font.BOLD + Font.ITALIC, 12));
    FontMetrics metrics = g2.getFontMetrics();
    int width = metrics.stringWidth(dsc.getName());
    int height = metrics.getHeight();
    g2.drawString(dsc.getName(), centre.x - width / 2, centre.y + 40);
  }
コード例 #21
0
  /* (non-Javadoc)
   * @see maptool.model.drawing.Drawable#draw(java.awt.Graphics2D, maptool.model.drawing.Pen)
   */
  public void draw(Graphics2D g, Pen pen, int translateX, int translateY) {
    if (pen == null) {
      pen = Pen.DEFAULT;
    }

    Stroke oldStroke = g.getStroke();
    g.setStroke(new BasicStroke(pen.getThickness(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    Composite oldComposite = g.getComposite();
    if (pen.isEraser()) {
      g.setComposite(AlphaComposite.Clear);
    }

    if (pen.getBackgroundMode() == Pen.MODE_SOLID) {
      Color bgColor = new Color(pen.getBackgroundColor());
      g.setColor(bgColor);
      drawBackground(g, translateX, translateY);
    }

    if (pen.getForegroundMode() == Pen.MODE_SOLID) {
      Color color = new Color(pen.getColor());
      g.setColor(color);
      draw(g, translateX, translateY);
    }

    g.setComposite(oldComposite);
    g.setStroke(oldStroke);
  }
コード例 #22
0
  @Override
  protected void fillTitleBar(Graphics2D g2) {
    Paint oldPaint = g2.getPaint();
    Stroke oldStroke = g2.getStroke();

    g2.setColor(new Color(241, 241, 241));
    g2.setStroke(new BasicStroke(1));
    g2.drawLine(0, 0, getWidth(), 0);

    LinearGradientPaint p =
        new LinearGradientPaint(
            1f,
            1f,
            1f,
            getHeight() - 1,
            new float[] {0.0f, 0.499f, 0.5f, 1.0f},
            new Color[] {
              new Color(230, 230, 230),
              new Color(202, 202, 202),
              new Color(202, 202, 202),
              new Color(178, 178, 178)
            });
    g2.setPaint(p);
    g2.fillRect(0, 0, getWidth(), this.getHeight() - 1);

    g2.setPaint(oldPaint);
    g2.setColor(new Color(104, 104, 104));
    g2.setStroke(new BasicStroke(1));
    g2.drawLine(getX(), getHeight() - 1, getWidth(), getHeight() - 1);

    g2.setStroke(oldStroke);
  }
コード例 #23
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;
  }
コード例 #24
0
 private void drawReadingValue(Graphics2D g2) {
   Stroke defaultStroke = g2.getStroke();
   g2.setStroke(readingStroke);
   g2.setColor(Color.gray);
   int x = (int) (getValuePct() * getWidth());
   g2.drawLine(x, 0, x, getHeight());
   g2.setStroke(defaultStroke);
 }
コード例 #25
0
ファイル: XpClock.java プロジェクト: xperimental/xpclock
 private void drawRings(Graphics g, double centerX, double centerY) {
   Graphics2D g2 = (Graphics2D) g;
   Stroke stroke = g2.getStroke();
   g2.setStroke(new BasicStroke((float) ringWidth));
   drawRing(g, centerX, centerY, SECOND_RING);
   drawRing(g, centerX, centerY, MINUTE_RING);
   drawRing(g, centerX, centerY, HOUR_RING);
   g2.setStroke(stroke);
 }
コード例 #26
0
ファイル: VProfileJoin.java プロジェクト: akoyro/furman
  @Override
  protected void drawStroke(Graphics2D g) {
    Color color = g.getColor();
    Stroke stroke = g.getStroke();

    g.draw(rec);

    g.setStroke(stroke);
    g.setColor(color);
  }
コード例 #27
0
ファイル: MyGraphs.java プロジェクト: cclairec/viewerIHI_java
  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    float val;
    int i, x[] = new int[17];
    Dimension dim = this.getSize();
    Stroke defaultStroke = g2.getStroke();
    BasicStroke dashed =
        new BasicStroke(
            1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f, new float[] {5.0f}, 0.0f);

    for (i = 0; i <= 16; i++) x[i] = (int) ((dim.width - 1) * i / (double) 16.0);

    // draw brain structure bars, with colours depending on selected-subject values
    g2.setColor(Color.black);
    for (i = 0; i < 16; i++) {
      if (selectedSubjectVolumes[0] != 0) {
        val = (float) ((selectedSubjectVolumes[i] - mean[i]) / (2.0 * std[i]));
        // System.out.println("val= "+val);
        if (val >= 0 && val <= 1) g2.setColor(new Color(val, 1.0f - val, 0.0f));
        else if (val >= -1 && val < 0) g2.setColor(new Color(0.0f, 1.0f + val, -val));
        else g2.setColor(Color.white);
      } else g2.setColor(Color.white);
      g2.fillRect(x[i], 0, x[i + 1], dim.height);
      g2.setColor(Color.black);
      g2.drawRect(x[i], 0, x[i + 1], dim.height);
    }

    // draw dots for selected subject values
    g2.setColor(Color.black);
    if (selectedSubjectVolumes[0] != 0)
      for (i = 0; i < 16; i++) {
        val = (float) (0.5f + (selectedSubjectVolumes[i] - mean[i]) / (2.0 * std[i]) / 2.0);
        if (val < 0) val = 0;
        if (val > 1) val = 1;
        // fillOval(int x, int y, int width, int height) avec la couleur definit par
        // g2.setColor(Color.black)
        g2.fillOval((x[i] + x[i + 1]) / 2 - 5, (int) (dim.height * (1 - val)) - 5, 11, 11);
      }

    // draw mean and +/- 1 std values
    g2.setColor(Color.black);
    g2.drawLine(0, dim.height / 2, dim.width, dim.height / 2);
    g2.setStroke(dashed);
    g2.drawLine(0, dim.height / 4, dim.width, dim.height / 4);
    g2.drawLine(0, dim.height * 3 / 4, dim.width, dim.height * 3 / 4);

    // draw brain structure names
    for (i = 0; i < 16; i++) {
      g2.translate((x[i] + x[i + 1]) / 2, 2);
      g2.rotate(Math.PI / 2.0);
      g2.drawString(regions[i], 0, 0);
      g2.rotate(-Math.PI / 2.0);
      g2.translate(-(x[i] + x[i + 1]) / 2, -2);
    }
  }
コード例 #28
0
ファイル: JMatrixPanel.java プロジェクト: andrewyatz/biojava
  /**
   * draw alternative alignments
   *
   * @param g
   */
  public void drawPairs(Graphics g) {

    if (aligs == null) return;

    int nr = aligs.length;

    Graphics2D g2D = (Graphics2D) g;
    Stroke oldStroke = g2D.getStroke();
    g2D.setStroke(stroke);

    Color color;
    float hue;

    int width = Math.round(scale);
    int w2 = width / 2;

    for (int i = 0; i < aligs.length; i++) {
      AlternativeAlignment a = aligs[i];
      int[] idx1 = a.getIdx1();
      int[] idx2 = a.getIdx2();
      int xold = -1;
      int yold = -1;
      boolean start = true;

      if ((selectedAlignmentPos != -1) && (selectedAlignmentPos == i)) {
        color = Color.white;
      } else {

        hue = i * (1 / (float) nr);
        color = Color.getHSBColor(hue, 1.0f, 1.0f);
      }
      g.setColor(color);

      for (int j = 0; j < idx1.length; j++) {
        int x1 = Math.round(idx1[j] * scale);
        int y1 = Math.round(idx2[j] * scale);
        if (!start) {
          // g.drawLine(xold+1,yold,x1+1,y1);

          g2D.draw(new Line2D.Double(xold, yold, x1, y1));
          g.fillRect(xold, yold, 2, 2);
        } else {
          g.fillRect(x1, y1, w2, w2);
          start = false;
        }
        xold = x1;
        yold = y1;
      }

      if (!start) g.fillRect(xold, yold, w2, w2);
    }

    g2D.setStroke(oldStroke);
  }
コード例 #29
0
 /**
  * draw - overrides parent method
  *
  * <p>See implementation comments in the AEllipse class.
  */
 public void draw(java.awt.Graphics2D brush2D) {
   Color savedColor = brush2D.getColor();
   brush2D.setColor(_borderColor);
   java.awt.Stroke savedStroke = brush2D.getStroke();
   brush2D.setStroke(new java.awt.BasicStroke(_lineWidth));
   brush2D.draw(this); // "this" class, ARoundRectangle, is subclass
   // of java.awt.geom.Rectangle2D.Double
   // A Graphics2D object knows how to draw the
   // the border of this kind of object.
   brush2D.setStroke(savedStroke);
   brush2D.setColor(savedColor);
 }
コード例 #30
0
  /**
   * Draws the edge.
   *
   * @param graphics the graphics context
   */
  public void draw(Graphics2D graphics) {
    updateContactPoints();

    Color oldColor = graphics.getColor();
    Stroke oldStroke = graphics.getStroke();

    graphics.setColor(getBorderColor());
    graphics.setStroke(getLineStyle());
    graphics.draw(getPath());
    graphics.setStroke(oldStroke);
    graphics.setColor(oldColor);
  }