类java.awt.Stroke源码实例Demo

下面列出了怎么用java.awt.Stroke的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: coming   文件: Cardumen_00143_s.java
/**
 * Utility method for drawing a line perpendicular to the range axis (used
 * for crosshairs).
 *
 * @param g2  the graphics device.
 * @param dataArea  the area defined by the axes.
 * @param value  the data value.
 * @param stroke  the line stroke (<code>null</code> not permitted).
 * @param paint  the line paint (<code>null</code> not permitted).
 */
protected void drawRangeLine(Graphics2D g2, Rectangle2D dataArea,
        double value, Stroke stroke, Paint paint) {

    double java2D = getRangeAxis().valueToJava2D(value, dataArea, 
            getRangeAxisEdge());
    Line2D line = null;
    if (this.orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(java2D, dataArea.getMinY(), java2D, 
                dataArea.getMaxY());
    }
    else if (this.orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), java2D, 
                dataArea.getMaxX(), java2D);
    }
    g2.setStroke(stroke);
    g2.setPaint(paint);
    g2.draw(line);

}
 
源代码2 项目: wpcleaner   文件: CloseTabComponent.java
@Override
protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  Graphics2D g2 = (Graphics2D) g;
  Stroke stroke = g2.getStroke();
  //shift the image for pressed buttons
  if (!getModel().isPressed()) {
    g2.translate(-1, -1);
  }
  g2.setStroke(new BasicStroke(2));
  g.setColor(Color.BLACK);
  if (getModel().isRollover()) {
    g.setColor(Color.MAGENTA);
  }
  int delta = 6;
  g.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1);
  g.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1);
  //leave the graphics unchanged
  if (!getModel().isPressed()) {
    g.translate(1, 1);
  }
  g2.setStroke(stroke);
}
 
源代码3 项目: ECG-Viewer   文件: Crosshair.java
/**
 * Creates a new crosshair value with the specified value and line style.
 *
 * @param value  the value.
 * @param paint  the line paint (<code>null</code> not permitted).
 * @param stroke  the line stroke (<code>null</code> not permitted).
 */
public Crosshair(double value, Paint paint, Stroke stroke) {
    ParamChecks.nullNotPermitted(paint, "paint");
    ParamChecks.nullNotPermitted(stroke, "stroke");
    this.visible = true;
    this.value = value;
    this.paint = paint;
    this.stroke = stroke;
    this.labelVisible = false;
    this.labelGenerator = new StandardCrosshairLabelGenerator();
    this.labelAnchor = RectangleAnchor.BOTTOM_LEFT;
    this.labelXOffset = 3.0;
    this.labelYOffset = 3.0;
    this.labelFont = new Font("Tahoma", Font.PLAIN, 12);
    this.labelPaint = Color.black;
    this.labelBackgroundPaint = new Color(0, 0, 255, 63);
    this.labelOutlineVisible = true;
    this.labelOutlinePaint = Color.black;
    this.labelOutlineStroke = new BasicStroke(0.5f);
    this.pcs = new PropertyChangeSupport(this);
}
 
源代码4 项目: SIMVA-SoS   文件: FXGraphics2D.java
/**
 * Sets the stroke that will be used to draw shapes.
 * 
 * @param s  the stroke ({@code null} not permitted).
 * 
 * @see #getStroke() 
 */
@Override
public void setStroke(Stroke s) {
    nullNotPermitted(s, "s");
    this.stroke = s;
    if (stroke instanceof BasicStroke) {
        BasicStroke bs = (BasicStroke) s;
        double lineWidth = bs.getLineWidth();
        if (lineWidth == 0.0) {
            lineWidth = this.zeroStrokeWidth;
        }
        this.gc.setLineWidth(lineWidth);
        this.gc.setLineCap(awtToJavaFXLineCap(bs.getEndCap()));
        this.gc.setLineJoin(awtToJavaFXLineJoin(bs.getLineJoin()));
        this.gc.setMiterLimit(bs.getMiterLimit());
    }
}
 
源代码5 项目: openjdk-jdk9   文件: BlockWidget.java
@Override
protected void paintWidget() {
    super.paintWidget();
    Graphics2D g = this.getGraphics();
    Stroke old = g.getStroke();
    g.setColor(Color.BLUE);
    Rectangle r = new Rectangle(this.getPreferredBounds());
    r.width--;
    r.height--;
    if (this.getBounds().width > 0 && this.getBounds().height > 0) {
        g.setStroke(new BasicStroke(2));
        g.drawRect(r.x, r.y, r.width, r.height);
    }

    Color titleColor = Color.BLACK;
    g.setColor(titleColor);
    g.setFont(titleFont);

    String s = "B" + blockNode.getName();
    Rectangle2D r1 = g.getFontMetrics().getStringBounds(s, g);
    g.drawString(s, r.x + 5, r.y + (int) r1.getHeight());
    g.setStroke(old);
}
 
源代码6 项目: buffer_bci   文件: StrokeMap.java
/**
 * Tests this map for equality with an arbitrary object.
 *
 * @param obj  the object (<code>null</code> permitted).
 *
 * @return A boolean.
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof StrokeMap)) {
        return false;
    }
    StrokeMap that = (StrokeMap) obj;
    if (this.store.size() != that.store.size()) {
        return false;
    }
    Set keys = this.store.keySet();
    Iterator iterator = keys.iterator();
    while (iterator.hasNext()) {
        Comparable key = (Comparable) iterator.next();
        Stroke s1 = getStroke(key);
        Stroke s2 = that.getStroke(key);
        if (!ObjectUtilities.equal(s1, s2)) {
            return false;
        }
    }
    return true;
}
 
源代码7 项目: openjdk-8   文件: Underline.java
void drawUnderline(Graphics2D g2d,
                   float thickness,
                   float x1,
                   float x2,
                   float y) {

    Stroke saveStroke = g2d.getStroke();
    g2d.setStroke(stroke);

    Line2D.Float drawLine = new Line2D.Float(x1, y, x2, y);
    g2d.draw(drawLine);

    drawLine.y1 += DEFAULT_THICKNESS;
    drawLine.y2 += DEFAULT_THICKNESS;
    drawLine.x1 += DEFAULT_THICKNESS;

    g2d.draw(drawLine);

    g2d.setStroke(saveStroke);
}
 
源代码8 项目: ramus   文件: DFDSRole.java
@Override
public void paint(Graphics2D g) {

    g.setColor(function.getBackground());
    final Rectangle2D rect = movingArea.getBounds(getBounds());

    RoundRectangle2D.Double rec = new RoundRectangle2D.Double(rect.getX(),
            rect.getY(), rect.getWidth(), rect.getHeight(),
            movingArea.getIDoubleOrdinate(4),
            movingArea.getIDoubleOrdinate(4));

    g.fill(rec);
    g.setFont(function.getFont());
    paintText(g);

    paintBorder(g);

    final Stroke tmp = g.getStroke();
    g.draw(rec);
    g.setStroke(tmp);
    paintTringle(g);

}
 
源代码9 项目: coming   文件: jMutRepair_0020_s.java
/**
 * Draws a grid line against the domain axis.
 * <P>
 * Note that this default implementation assumes that the horizontal axis
 * is the domain axis. If this is not the case, you will need to override
 * this method.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the area for plotting data (not yet adjusted for any
 *                  3D effect).
 * @param value  the Java2D value at which the grid line should be drawn.
 * @param paint  the paint (<code>null</code> not permitted).
 * @param stroke  the stroke (<code>null</code> not permitted).
 *
 * @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis,
 *     Rectangle2D, double)
 *
 * @since 1.2.0
 */
public void drawDomainLine(Graphics2D g2, CategoryPlot plot,
        Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {

    if (paint == null) {
        throw new IllegalArgumentException("Null 'paint' argument.");
    }
    if (stroke == null) {
        throw new IllegalArgumentException("Null 'stroke' argument.");
    }
    Line2D line = null;
    PlotOrientation orientation = plot.getOrientation();

    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(dataArea.getMinX(), value,
                dataArea.getMaxX(), value);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(value, dataArea.getMinY(), value,
                dataArea.getMaxY());
    }

    g2.setPaint(paint);
    g2.setStroke(stroke);
    g2.draw(line);

}
 
源代码10 项目: astor   文件: Marker.java
/**
 * Constructs a new marker.
 *
 * @param paint  the paint (<code>null</code> not permitted).
 * @param stroke  the stroke (<code>null</code> not permitted).
 * @param outlinePaint  the outline paint (<code>null</code> permitted).
 * @param outlineStroke  the outline stroke (<code>null</code> permitted).
 * @param alpha  the alpha transparency (must be in the range 0.0f to 
 *     1.0f).
 *     
 * @throws IllegalArgumentException if <code>paint</code> or 
 *     <code>stroke</code> is <code>null</code>, or <code>alpha</code> is 
 *     not in the specified range.
 */
protected Marker(Paint paint, Stroke stroke, 
                 Paint outlinePaint, Stroke outlineStroke, 
                 float alpha) {

    if (paint == null) {
        throw new IllegalArgumentException("Null 'paint' argument.");
    }
    if (stroke == null) {
        throw new IllegalArgumentException("Null 'stroke' argument.");
    }
    if (alpha < 0.0f || alpha > 1.0f)
        throw new IllegalArgumentException(
                "The 'alpha' value must be in the range 0.0f to 1.0f");
    
    this.paint = paint;
    this.stroke = stroke;
    this.outlinePaint = outlinePaint;
    this.outlineStroke = outlineStroke;
    this.alpha = alpha;
    
    this.labelFont = new Font("SansSerif", Font.PLAIN, 9);
    this.labelPaint = Color.black;
    this.labelAnchor = RectangleAnchor.TOP_LEFT;
    this.labelOffset = new RectangleInsets(3.0, 3.0, 3.0, 3.0);
    this.labelOffsetType = LengthAdjustmentType.CONTRACT;
    this.labelTextAnchor = TextAnchor.CENTER;
    
    this.listenerList = new EventListenerList();
}
 
源代码11 项目: astor   文件: StrokeMap.java
/**
 * Provides serialization support.
 *
 * @param stream  the output stream.
 *
 * @throws IOException  if there is an I/O error.
 */
private void writeObject(ObjectOutputStream stream) throws IOException {
    stream.defaultWriteObject();
    stream.writeInt(this.store.size());
    Set keys = this.store.keySet();
    Iterator iterator = keys.iterator();
    while (iterator.hasNext()) {
        Comparable key = (Comparable) iterator.next();
        stream.writeObject(key);
        Stroke stroke = getStroke(key);
        SerialUtilities.writeStroke(stroke, stream);
    }
}
 
源代码12 项目: astor   文件: PeriodAxisLabelInfo.java
/**
 * Creates a new instance.
 *
 * @param periodClass  the subclass of {@link RegularTimePeriod} to use
 *                     (<code>null</code> not permitted).
 * @param dateFormat  the date format (<code>null</code> not permitted).
 * @param padding  controls the space around the band (<code>null</code>
 *                 not permitted).
 * @param labelFont  the label font (<code>null</code> not permitted).
 * @param labelPaint  the label paint (<code>null</code> not permitted).
 * @param drawDividers  a flag that controls whether dividers are drawn.
 * @param dividerStroke  the stroke used to draw the dividers
 *                       (<code>null</code> not permitted).
 * @param dividerPaint  the paint used to draw the dividers
 *                      (<code>null</code> not permitted).
 */
public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat,
                           RectangleInsets padding,
                           Font labelFont, Paint labelPaint,
                           boolean drawDividers, Stroke dividerStroke,
                           Paint dividerPaint) {
    if (periodClass == null) {
        throw new IllegalArgumentException("Null 'periodClass' argument.");
    }
    if (dateFormat == null) {
        throw new IllegalArgumentException("Null 'dateFormat' argument.");
    }
    if (padding == null) {
        throw new IllegalArgumentException("Null 'padding' argument.");
    }
    if (labelFont == null) {
        throw new IllegalArgumentException("Null 'labelFont' argument.");
    }
    if (labelPaint == null) {
        throw new IllegalArgumentException("Null 'labelPaint' argument.");
    }
    if (dividerStroke == null) {
        throw new IllegalArgumentException(
                "Null 'dividerStroke' argument.");
    }
    if (dividerPaint == null) {
        throw new IllegalArgumentException("Null 'dividerPaint' argument.");
    }
    this.periodClass = periodClass;
    this.dateFormat = dateFormat;
    this.padding = padding;
    this.labelFont = labelFont;
    this.labelPaint = labelPaint;
    this.drawDividers = drawDividers;
    this.dividerStroke = dividerStroke;
    this.dividerPaint = dividerPaint;
}
 
源代码13 项目: opensim-gui   文件: AbstractCategoryItemRenderer.java
/**
 * Draws a grid line against the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 
 *                  3D effect).
 * @param value  the value at which the grid line should be drawn.
 *
 */
public void drawRangeGridline(Graphics2D g2,
                              CategoryPlot plot,
                              ValueAxis axis,
                              Rectangle2D dataArea,
                              double value) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
    Line2D line = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v, 
                dataArea.getMaxY());
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), v, 
                dataArea.getMaxX(), v);
    }

    Paint paint = plot.getRangeGridlinePaint();
    if (paint == null) {
        paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT;
    }
    g2.setPaint(paint);

    Stroke stroke = plot.getRangeGridlineStroke();
    if (stroke == null) {
        stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE;
    }
    g2.setStroke(stroke);

    g2.draw(line);

}
 
源代码14 项目: buffer_bci   文件: DefaultDrawingSupplier.java
/**
 * Creates a new supplier.
 *
 * @param paintSequence  the fill paint sequence.
 * @param outlinePaintSequence  the outline paint sequence.
 * @param strokeSequence  the stroke sequence.
 * @param outlineStrokeSequence  the outline stroke sequence.
 * @param shapeSequence  the shape sequence.
 */
public DefaultDrawingSupplier(Paint[] paintSequence,
                              Paint[] outlinePaintSequence,
                              Stroke[] strokeSequence,
                              Stroke[] outlineStrokeSequence,
                              Shape[] shapeSequence) {

    this.paintSequence = paintSequence;
    this.fillPaintSequence = DEFAULT_FILL_PAINT_SEQUENCE;
    this.outlinePaintSequence = outlinePaintSequence;
    this.strokeSequence = strokeSequence;
    this.outlineStrokeSequence = outlineStrokeSequence;
    this.shapeSequence = shapeSequence;

}
 
源代码15 项目: ECG-Viewer   文件: ContourPlot.java
/**
 * Draws a horizontal line across the chart to represent a 'range marker'.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param rangeAxis  the range axis.
 * @param marker  the marker line.
 * @param dataArea  the axis data area.
 */
public void drawRangeMarker(Graphics2D g2,
                            ContourPlot plot,
                            ValueAxis rangeAxis,
                            Marker marker,
                            Rectangle2D dataArea) {

    if (marker instanceof ValueMarker) {
        ValueMarker vm = (ValueMarker) marker;
        double value = vm.getValue();
        Range range = rangeAxis.getRange();
        if (!range.contains(value)) {
            return;
        }

        double y = rangeAxis.valueToJava2D(value, dataArea,
                RectangleEdge.LEFT);
        Line2D line = new Line2D.Double(dataArea.getMinX(), y,
                dataArea.getMaxX(), y);
        Paint paint = marker.getOutlinePaint();
        Stroke stroke = marker.getOutlineStroke();
        g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
        g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
        g2.draw(line);
    }

}
 
源代码16 项目: netbeans   文件: TabbedPaneWidget.java
public void paint(Graphics2D g2, Rectangle rect) {
    Paint oldPaint = g2.getPaint();
    
    Arc2D arc = new Arc2D.Double(rect.x - radius + 0.5f, rect.y + rect.height - radius *2 +0.5f,
            radius*2, radius*2, -90, 90, Arc2D.OPEN);
    GeneralPath gp = new GeneralPath(arc);
    arc = new Arc2D.Double(rect.x+radius+0.5f, rect.y+0.5f,
            radius*4, radius*4, 180, -90, Arc2D.OPEN);
    gp.append(arc,true);
    arc = new Arc2D.Double(rect.x + rect.width - radius*6 +1f, rect.y+0.5f,
            radius*4, radius*4, 90, -90, Arc2D.OPEN);
    gp.append(arc,true);
    arc = new Arc2D.Double(rect.x + rect.width - radius*2 +1f, rect.y + rect.height - radius*2 +0.5f,
            radius*2, radius*2, 180, 90, Arc2D.OPEN);
    gp.append(arc,true);
    if (tabbedPane.selectedTab==tab) {
        g2.setPaint(SELECTED_TAB_COLOR);
        g2.fill(gp);
    } else {
        g2.setPaint(TAB_COLOR);
        g2.fill(gp);
        gp.closePath();
    }
    g2.setPaint(TAB_BORDER_COLOR);
    if (tab.getState().isFocused()) {
        Stroke s = g2.getStroke ();
        g2.setStroke (new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, BasicStroke.JOIN_MITER, new float[] {2,2}, 0));
        g2.drawRect (rect.x+radius*3, rect.y+radius*2,rect.width-radius*6,rect.height-radius*4);
        g2.setStroke (s);
    }
    g2.draw(gp);
    
    g2.setPaint(oldPaint);
}
 
源代码17 项目: buffer_bci   文件: ContourPlot.java
/**
 * Utility method for drawing a crosshair on the chart (if required).
 *
 * @param g2  The graphics device.
 * @param dataArea  The data area.
 * @param value  The coordinate, where to draw the line.
 * @param stroke  The stroke to use.
 * @param paint  The paint to use.
 */
protected void drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea,
                                  double value, Stroke stroke,
                                  Paint paint) {

    double yy = getRangeAxis().valueToJava2D(value, dataArea,
            RectangleEdge.LEFT);
    Line2D line = new Line2D.Double(dataArea.getMinX(), yy,
            dataArea.getMaxX(), yy);
    g2.setStroke(stroke);
    g2.setPaint(paint);
    g2.draw(line);

}
 
源代码18 项目: ccu-historian   文件: LineBorder.java
/**
 * Creates a new border with the specified color.
 *
 * @param paint  the color ({@code null} not permitted).
 * @param stroke  the border stroke ({@code null} not permitted).
 * @param insets  the insets ({@code null} not permitted).
 */
public LineBorder(Paint paint, Stroke stroke, RectangleInsets insets) {
    ParamChecks.nullNotPermitted(paint, "paint");
    ParamChecks.nullNotPermitted(stroke, "stroke");
    ParamChecks.nullNotPermitted(insets, "insets");
    this.paint = paint;
    this.stroke = stroke;
    this.insets = insets;
}
 
源代码19 项目: ECG-Viewer   文件: DefaultDrawingSupplier.java
/**
 * Creates a new supplier.
 *
 * @param paintSequence  the paint sequence.
 * @param fillPaintSequence  the fill paint sequence.
 * @param outlinePaintSequence  the outline paint sequence.
 * @param strokeSequence  the stroke sequence.
 * @param outlineStrokeSequence  the outline stroke sequence.
 * @param shapeSequence  the shape sequence.
 *
 * @since 1.0.6
 */
public DefaultDrawingSupplier(Paint[] paintSequence,
        Paint[] fillPaintSequence, Paint[] outlinePaintSequence,
        Stroke[] strokeSequence, Stroke[] outlineStrokeSequence,
        Shape[] shapeSequence) {

    this.paintSequence = paintSequence;
    this.fillPaintSequence = fillPaintSequence;
    this.outlinePaintSequence = outlinePaintSequence;
    this.strokeSequence = strokeSequence;
    this.outlineStrokeSequence = outlineStrokeSequence;
    this.shapeSequence = shapeSequence;
}
 
源代码20 项目: Bytecoder   文件: Underline.java
private Stroke getStroke(float thickness) {

            float lineThickness = getLineThickness(thickness);
            BasicStroke stroke = cachedStroke;
            if (stroke == null ||
                    stroke.getLineWidth() != lineThickness) {

                stroke = createStroke(lineThickness);
                cachedStroke = stroke;
            }

            return stroke;
        }
 
源代码21 项目: snap-desktop   文件: DiagramCanvas.java
private void drawValueIndicator(Graphics2D g2d) {
    Diagram.RectTransform transform = diagram.getTransform();
    Point2D a = transform.transformB2A(dragPoint, null);
    double x = a.getX();
    if (x < selectedGraph.getXMin()) {
        x = selectedGraph.getXMin();
    }
    if (x > selectedGraph.getXMax()) {
        x = selectedGraph.getXMax();
    }
    final Stroke oldStroke = g2d.getStroke();
    final Color oldColor = g2d.getColor();

    double y = getY(selectedGraph, x);
    Point2D b = transform.transformA2B(new Point2D.Double(x, y), null);

    g2d.setStroke(new BasicStroke(1.0f));
    g2d.setColor(diagram.getForegroundColor());
    Ellipse2D.Double marker = new Ellipse2D.Double(b.getX() - 4.0, b.getY() - 4.0, 8.0, 8.0);
    g2d.draw(marker);

    g2d.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{6, 6}, 12));
    g2d.setColor(diagram.getForegroundColor());
    final Rectangle graphArea = diagram.getGraphArea();
    g2d.draw(new Line2D.Double(b.getX(), graphArea.y + graphArea.height, b.getX(), b.getY()));
    g2d.draw(new Line2D.Double(graphArea.x, b.getY(), b.getX(), b.getY()));

    DecimalFormat decimalFormat = new DecimalFormat("0.#####E0");
    String text = selectedGraph.getYName() + ": x = " + decimalFormat.format(x) + ", y = " + decimalFormat.format(y);

    g2d.setStroke(oldStroke);
    g2d.setColor(oldColor);

    drawTextBox(g2d, text, graphArea.x + 6, graphArea.y + 6 + 16, new Color(255, 255, 255, 128));
}
 
源代码22 项目: coming   文件: jMutRepair_001_s.java
/**
 * Draws the gridlines for the plot.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area inside the axes.
 * 
 * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List)
 */
protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea) {

    // draw the domain grid lines, if any...
    if (isDomainGridlinesVisible()) {
        CategoryAnchor anchor = getDomainGridlinePosition();
        RectangleEdge domainAxisEdge = getDomainAxisEdge();
        Stroke gridStroke = getDomainGridlineStroke();
        Paint gridPaint = getDomainGridlinePaint();
        if ((gridStroke != null) && (gridPaint != null)) {
            // iterate over the categories
            CategoryDataset data = getDataset();
            if (data != null) {
                CategoryAxis axis = getDomainAxis();
                if (axis != null) {
                    int columnCount = data.getColumnCount();
                    for (int c = 0; c < columnCount; c++) {
                        double xx = axis.getCategoryJava2DCoordinate(
                                anchor, c, columnCount, dataArea, 
                                domainAxisEdge);
                        CategoryItemRenderer renderer1 = getRenderer();
                        if (renderer1 != null) {
                            renderer1.drawDomainGridline(g2, this, 
                                    dataArea, xx);
                        }
                    }
                }
            }
        }
    }
}
 
源代码23 项目: openjdk-jdk8u   文件: Decoration.java
private void drawTextAndEmbellishments(Label label,
                                       Graphics2D g2d,
                                       float x,
                                       float y) {

    label.handleDraw(g2d, x, y);

    if (!strikethrough && stdUnderline == null && imUnderline == null) {
        return;
    }

    float x1 = x;
    float x2 = x1 + (float)label.getLogicalBounds().getWidth();

    CoreMetrics cm = label.getCoreMetrics();
    if (strikethrough) {
        Stroke savedStroke = g2d.getStroke();
        g2d.setStroke(new BasicStroke(cm.strikethroughThickness,
                                      BasicStroke.CAP_BUTT,
                                      BasicStroke.JOIN_MITER));
        float strikeY = y + cm.strikethroughOffset;
        g2d.draw(new Line2D.Float(x1, strikeY, x2, strikeY));
        g2d.setStroke(savedStroke);
    }

    float ulOffset = cm.underlineOffset;
    float ulThickness = cm.underlineThickness;

    if (stdUnderline != null) {
        stdUnderline.drawUnderline(g2d, ulThickness, x1, x2, y + ulOffset);
    }

    if (imUnderline != null) {
        imUnderline.drawUnderline(g2d, ulThickness, x1, x2, y + ulOffset);
    }
}
 
源代码24 项目: opensim-gui   文件: AbstractCategoryItemRenderer.java
/**
 * Draws a grid line against the domain axis.
 * <P>
 * Note that this default implementation assumes that the horizontal axis 
 * is the domain axis. If this is not the case, you will need to override 
 * this method.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the area for plotting data (not yet adjusted for any 
 *                  3D effect).
 * @param value  the Java2D value at which the grid line should be drawn.
 */
public void drawDomainGridline(Graphics2D g2,
                               CategoryPlot plot,
                               Rectangle2D dataArea,
                               double value) {

    Line2D line = null;
    PlotOrientation orientation = plot.getOrientation();

    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(dataArea.getMinX(), value, 
                dataArea.getMaxX(), value);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(value, dataArea.getMinY(), value, 
                dataArea.getMaxY());
    }

    Paint paint = plot.getDomainGridlinePaint();
    if (paint == null) {
        paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT;
    }
    g2.setPaint(paint);

    Stroke stroke = plot.getDomainGridlineStroke();
    if (stroke == null) {
        stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE;
    }
    g2.setStroke(stroke);

    g2.draw(line);

}
 
源代码25 项目: ccu-historian   文件: PeriodAxisLabelInfoTest.java
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class,
            new SimpleDateFormat("d"));
    PeriodAxisLabelInfo info2 = new PeriodAxisLabelInfo(Day.class,
            new SimpleDateFormat("d"));
    assertTrue(info1.equals(info2));
    assertTrue(info2.equals(info1));

    Class c1 = Day.class;
    Class c2 = Month.class;
    DateFormat df1 = new SimpleDateFormat("d");
    DateFormat df2 = new SimpleDateFormat("MMM");
    RectangleInsets sp1 = new RectangleInsets(1, 1, 1, 1);
    RectangleInsets sp2 = new RectangleInsets(2, 2, 2, 2);
    Font lf1 = new Font("SansSerif", Font.PLAIN, 10);
    Font lf2 = new Font("SansSerif", Font.BOLD, 9);
    Paint lp1 = Color.black;
    Paint lp2 = Color.blue;
    boolean b1 = true;
    boolean b2 = false;
    Stroke s1 = new BasicStroke(0.5f);
    Stroke s2 = new BasicStroke(0.25f);
    Paint dp1 = Color.red;
    Paint dp2 = Color.green;

    info1 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1);
    info2 = new PeriodAxisLabelInfo(c1, df1, sp1, lf1, lp1, b1, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2);
    assertTrue(info1.equals(info2));

}
 
源代码26 项目: mzmine3   文件: ChartThemeFactory.java
/**
 * Creates and returns a theme called "Darkness". In this theme, the charts have a black
 * background and white lines and labels
 *
 * @return The "Darkness" theme.
 */
public static EStandardChartTheme createDarknessTheme() {
  EStandardChartTheme theme = new EStandardChartTheme(THEME.DARKNESS, "Darkness");
  // Fonts
  theme.setExtraLargeFont(new Font("Arial", Font.BOLD, 20));
  theme.setLargeFont(new Font("Arial", Font.BOLD, 11));
  theme.setRegularFont(new Font("Arial", Font.PLAIN, 11));
  theme.setSmallFont(new Font("Arial", Font.PLAIN, 11));
  //
  theme.setTitlePaint(Color.white);
  theme.setSubtitlePaint(Color.white);
  theme.setLegendBackgroundPaint(Color.black);
  theme.setLegendItemPaint(Color.white);
  theme.setChartBackgroundPaint(Color.black);
  theme.setPlotBackgroundPaint(Color.black);
  theme.setPlotOutlinePaint(Color.yellow);
  theme.setBaselinePaint(Color.white);
  theme.setCrosshairPaint(Color.red);
  theme.setLabelLinkPaint(Color.lightGray);
  theme.setTickLabelPaint(Color.white);
  theme.setAxisLabelPaint(Color.white);
  theme.setShadowPaint(Color.darkGray);
  theme.setItemLabelPaint(Color.white);
  theme.setDrawingSupplier(new DefaultDrawingSupplier(
      new Paint[] {Color.WHITE, Color.decode("0xFFFF00"), Color.decode("0x0036CC"),
          Color.decode("0xFF0000"), Color.decode("0xFFFF7F"), Color.decode("0x6681CC"),
          Color.decode("0xFF7F7F"), Color.decode("0xFFFFBF"), Color.decode("0x99A6CC"),
          Color.decode("0xFFBFBF"), Color.decode("0xA9A938"), Color.decode("0x2D4587")},
      new Paint[] {Color.decode("0xFFFF00"), Color.decode("0x0036CC")},
      new Stroke[] {new BasicStroke(2.0f)}, new Stroke[] {new BasicStroke(0.5f)},
      DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
  theme.setErrorIndicatorPaint(Color.lightGray);
  theme.setGridBandPaint(new Color(255, 255, 255, 20));
  theme.setGridBandAlternatePaint(new Color(255, 255, 255, 40));

  // axis
  Color transp = new Color(255, 255, 255, 200);
  theme.setRangeGridlinePaint(transp);
  theme.setDomainGridlinePaint(transp);

  theme.setAxisLinePaint(Color.white);

  theme.setMasterFontColor(Color.WHITE);
  // axis offset
  theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
  return theme;
}
 
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label",
            "Key 1", 20.0, Math.PI);
    CategoryPointerAnnotation a2 = new CategoryPointerAnnotation("Label",
            "Key 1", 20.0, Math.PI);
    assertTrue(a1.equals(a2));

    a1 = new CategoryPointerAnnotation("Label2", "Key 1", 20.0, Math.PI);
    assertFalse(a1.equals(a2));
    a2 = new CategoryPointerAnnotation("Label2", "Key 1", 20.0, Math.PI);
    assertTrue(a1.equals(a2));

    a1.setCategory("Key 2");
    assertFalse(a1.equals(a2));
    a2.setCategory("Key 2");
    assertTrue(a1.equals(a2));

    a1.setValue(22.0);
    assertFalse(a1.equals(a2));
    a2.setValue(22.0);
    assertTrue(a1.equals(a2));

    //private double angle;
    a1.setAngle(Math.PI / 4.0);
    assertFalse(a1.equals(a2));
    a2.setAngle(Math.PI / 4.0);
    assertTrue(a1.equals(a2));

    //private double tipRadius;
    a1.setTipRadius(20.0);
    assertFalse(a1.equals(a2));
    a2.setTipRadius(20.0);
    assertTrue(a1.equals(a2));

    //private double baseRadius;
    a1.setBaseRadius(5.0);
    assertFalse(a1.equals(a2));
    a2.setBaseRadius(5.0);
    assertTrue(a1.equals(a2));

    //private double arrowLength;
    a1.setArrowLength(33.0);
    assertFalse(a1.equals(a2));
    a2.setArrowLength(33.0);
    assertTrue(a1.equals(a2));

    //private double arrowWidth;
    a1.setArrowWidth(9.0);
    assertFalse(a1.equals(a2));
    a2.setArrowWidth(9.0);
    assertTrue(a1.equals(a2));

    //private Stroke arrowStroke;
    Stroke stroke = new BasicStroke(1.5f);
    a1.setArrowStroke(stroke);
    assertFalse(a1.equals(a2));
    a2.setArrowStroke(stroke);
    assertTrue(a1.equals(a2));

    //private Paint arrowPaint;
    a1.setArrowPaint(Color.blue);
    assertFalse(a1.equals(a2));
    a2.setArrowPaint(Color.blue);
    assertTrue(a1.equals(a2));

    //private double labelOffset;
    a1.setLabelOffset(10.0);
    assertFalse(a1.equals(a2));
    a2.setLabelOffset(10.0);
    assertTrue(a1.equals(a2));
}
 
源代码28 项目: SIMVA-SoS   文件: PeriodAxisTest.java
/**
 * Confirm that the equals() method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    PeriodAxis a1 = new PeriodAxis("Test");
    PeriodAxis a2 = new PeriodAxis("Test");
    assertTrue(a1.equals(a2));
    assertTrue(a2.equals(a1));

    a1.setFirst(new Year(2000));
    assertFalse(a1.equals(a2));
    a2.setFirst(new Year(2000));
    assertTrue(a1.equals(a2));

    a1.setLast(new Year(2004));
    assertFalse(a1.equals(a2));
    a2.setLast(new Year(2004));
    assertTrue(a1.equals(a2));

    a1.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland"));
    assertFalse(a1.equals(a2));
    a2.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland"));
    assertTrue(a1.equals(a2));

    a1.setAutoRangeTimePeriodClass(Quarter.class);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeTimePeriodClass(Quarter.class);
    assertTrue(a1.equals(a2));

    PeriodAxisLabelInfo info[] = new PeriodAxisLabelInfo[1];
    info[0] = new PeriodAxisLabelInfo(Month.class,
            new SimpleDateFormat("MMM"));

    a1.setLabelInfo(info);
    assertFalse(a1.equals(a2));
    a2.setLabelInfo(info);
    assertTrue(a1.equals(a2));

    a1.setMajorTickTimePeriodClass(Minute.class);
    assertFalse(a1.equals(a2));
    a2.setMajorTickTimePeriodClass(Minute.class);
    assertTrue(a1.equals(a2));

    a1.setMinorTickMarksVisible(!a1.isMinorTickMarksVisible());
    assertFalse(a1.equals(a2));
    a2.setMinorTickMarksVisible(a1.isMinorTickMarksVisible());
    assertTrue(a1.equals(a2));

    a1.setMinorTickTimePeriodClass(Minute.class);
    assertFalse(a1.equals(a2));
    a2.setMinorTickTimePeriodClass(Minute.class);
    assertTrue(a1.equals(a2));

    Stroke s = new BasicStroke(1.23f);
    a1.setMinorTickMarkStroke(s);
    assertFalse(a1.equals(a2));
    a2.setMinorTickMarkStroke(s);
    assertTrue(a1.equals(a2));

    a1.setMinorTickMarkPaint(Color.blue);
    assertFalse(a1.equals(a2));
    a2.setMinorTickMarkPaint(Color.blue);
    assertTrue(a1.equals(a2));
}
 
源代码29 项目: astor   文件: SWTGraphics2D.java
/**
 * Sets the stroke for this graphics context.  For now, this implementation
 * only recognises the {@link BasicStroke} class.
 *
 * @param stroke  the stroke (<code>null</code> not permitted).
 *
 * @see #getStroke()
 */
public void setStroke(Stroke stroke) {
    if (stroke instanceof BasicStroke) {
        BasicStroke bs = (BasicStroke) stroke;
        // linewidth
        this.gc.setLineWidth((int) bs.getLineWidth());

        // line join
        switch (bs.getLineJoin()) {
            case BasicStroke.JOIN_BEVEL :
                this.gc.setLineJoin(SWT.JOIN_BEVEL);
                break;
            case BasicStroke.JOIN_MITER :
                this.gc.setLineJoin(SWT.JOIN_MITER);
                break;
            case BasicStroke.JOIN_ROUND :
                this.gc.setLineJoin(SWT.JOIN_ROUND);
                break;
        }

        // line cap
        switch (bs.getEndCap()) {
            case BasicStroke.CAP_BUTT :
                this.gc.setLineCap(SWT.CAP_FLAT);
                break;
            case BasicStroke.CAP_ROUND :
                this.gc.setLineCap(SWT.CAP_ROUND);
                break;
            case BasicStroke.CAP_SQUARE :
                this.gc.setLineCap(SWT.CAP_SQUARE);
                break;
        }

        // set the line style to solid by default
        this.gc.setLineStyle(SWT.LINE_SOLID);

        // apply dash style if any
        float[] dashes = bs.getDashArray();
        if (dashes != null) {
            int[] swtDashes = new int[dashes.length];
            for (int i = 0; i < swtDashes.length; i++) {
                swtDashes[i] = (int) dashes[i];
            }
            this.gc.setLineDash(swtDashes);
        }
    }
    else {
        throw new RuntimeException(
                "Can only handle 'Basic Stroke' at present.");
    }
}
 
源代码30 项目: bamboobsc   文件: StrategyMapUtils.java
public static byte[] getBackgroundImage(VisionVO vision, int width, int height) throws Exception {
	byte[] data = null;
	List<PerspectiveVO> perspectivesList = perspectiveService.findForListByVisionOid(vision.getOid());
	
	BufferedImage bi = new BufferedImage(getWidth(width), getHeight(height), BufferedImage.TYPE_INT_RGB);
	Graphics2D g2 = bi.createGraphics();	
	Font font = new Font("", Font.BOLD, 16);
	g2.setFont(font);		
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);		
	
	int fontLeft = 3;
	int fontAddY = ONE_HEIGHT; // 150
	int fontNowY = 80;
	int lineAddY = 60;
	
	// 填滿 grid 圖片的底
	BufferedImage bg = ImageIO.read( StrategyMapUtils.class.getClassLoader().getResource(SRC_IMG) );
	for (int y=0; y<height; y+=bg.getHeight()) {
		for (int x=0; x<width; x+=bg.getWidth()) {
			g2.drawImage(bg, x, y, null);
		}
	}
	
	Stroke dashed = new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{9}, 0);
	
	for (int i=0; perspectivesList != null && i < perspectivesList.size(); i++) {
		
		PerspectiveVO perspective = perspectivesList.get(i);
		
		if (fontNowY > bi.getHeight()) {
			logger.warn("Perspective item over heigh, no paint it : " + perspective.getName());
			continue;
		}
		if (fontLeft > bi.getWidth()) {
			logger.warn("Perspective item over width, no paint it : " + perspective.getName());
			continue;				
		}
		
		g2.setPaint( new Color(64, 64, 64) );
		g2.drawString(perspective.getName(), fontLeft, fontNowY);
		
		g2.setStroke(dashed);
		g2.drawLine(0, fontNowY+lineAddY, width, fontNowY+lineAddY);
		
		fontNowY = fontNowY + fontAddY;
	}
	ByteArrayOutputStream baos = null;
	try {
		baos = new ByteArrayOutputStream();
		ImageIO.write(bi, "PNG", baos);
		data = baos.toByteArray();
		baos.flush();
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		baos = null;
	}
	return data;
}
 
 类所在包
 同包方法