Java Code Examples for java.awt.geom.Arc2D#CHORD

The following examples show how to use java.awt.geom.Arc2D#CHORD . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestImageGenerator.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
public TestImageGenerator(double[][] matrix, double[] gain, String[] channelNames, int width, int height) {
    this.matrix = matrix;
    this.gain = gain;
    this.channelNames = channelNames;
    this.rand = new Random();
    this.sizeC = channelNames.length;
    this.width = width;
    this.height = height;
    this.concentrations = new List[sizeC];
    this.signals = new double[sizeC][numCells];


    // generate concentrations
    for (int s=0; s<sizeC; s++) {
         concentrations[s] = new ArrayList<>(numCells);
        for (int i=0; i<numCells; i++) {
            int x = rand.nextInt((int)(width-cellRadius));
            int y = rand.nextInt((int)(height-cellRadius));
            Arc2D p = new Arc2D.Double(Arc2D.CHORD);
            p.setArcByCenter(x, y, cellRadius, 0d, 360d, Arc2D.CHORD);
            concentrations[s].add(p);
            double density = (rand.nextGaussian() * 100d) + 100;
            signals[s][i] = density;
        }
    }
}
 
Example 2
Source File: SpotImagePanel.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
protected SpotPos detectSpot(double x, double y) {
    Arc2D.Double arc;
    x -= iOffsX;
    y -= iOffsY;
    x /= scale;
    y /= scale;
    Point p;

    if (SpotImagePanel.this.spotPosList != null && SpotImagePanel.this.spotPosList.size() > 0) {
        for (SpotPos sp : SpotImagePanel.this.spotPosList) {
            p = sp.getPos();
            arc = new Arc2D.Double(p.x - SpotImagePanel.this.radius, p.y - SpotImagePanel.this.radius, SpotImagePanel.this.radius * 2, SpotImagePanel.this.radius * 2, 0, 360, Arc2D.CHORD);
            if (arc.contains(new Point((int) x, (int) y))) {
                return sp;
            }

        }
    }
    return null;
}
 
Example 3
Source File: MeterPlot.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Fills an arc on the dial between the given values.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param minValue  the minimum data value.
 * @param maxValue  the maximum data value.
 * @param paint  the background paint (<code>null</code> not permitted).
 * @param dial  a flag that indicates whether the arc represents the whole
 *              dial.
 */
protected void fillArc(Graphics2D g2, Rectangle2D area,
        double minValue, double maxValue, Paint paint, boolean dial) {

    ParamChecks.nullNotPermitted(paint, "paint");
    double startAngle = valueToAngle(maxValue);
    double endAngle = valueToAngle(minValue);
    double extent = endAngle - startAngle;

    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    int joinType = Arc2D.OPEN;
    if (this.shape == DialShape.PIE) {
        joinType = Arc2D.PIE;
    }
    else if (this.shape == DialShape.CHORD) {
        if (dial && this.meterAngle > 180) {
            joinType = Arc2D.CHORD;
        }
        else {
            joinType = Arc2D.PIE;
        }
    }
    else if (this.shape == DialShape.CIRCLE) {
        joinType = Arc2D.PIE;
        if (dial) {
            extent = 360;
        }
    }
    else {
        throw new IllegalStateException("DialShape not recognised.");
    }

    g2.setPaint(paint);
    Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent,
            joinType);
    g2.fill(arc);
}
 
Example 4
Source File: MeterPlot.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Fills an arc on the dial between the given values.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param minValue  the minimum data value.
 * @param maxValue  the maximum data value.
 * @param paint  the background paint (<code>null</code> not permitted).
 * @param dial  a flag that indicates whether the arc represents the whole
 *              dial.
 */
protected void fillArc(Graphics2D g2, Rectangle2D area,
        double minValue, double maxValue, Paint paint, boolean dial) {

    ParamChecks.nullNotPermitted(paint, "paint");
    double startAngle = valueToAngle(maxValue);
    double endAngle = valueToAngle(minValue);
    double extent = endAngle - startAngle;

    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    int joinType = Arc2D.OPEN;
    if (this.shape == DialShape.PIE) {
        joinType = Arc2D.PIE;
    }
    else if (this.shape == DialShape.CHORD) {
        if (dial && this.meterAngle > 180) {
            joinType = Arc2D.CHORD;
        }
        else {
            joinType = Arc2D.PIE;
        }
    }
    else if (this.shape == DialShape.CIRCLE) {
        joinType = Arc2D.PIE;
        if (dial) {
            extent = 360;
        }
    }
    else {
        throw new IllegalStateException("DialShape not recognised.");
    }

    g2.setPaint(paint);
    Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent,
            joinType);
    g2.fill(arc);
}
 
Example 5
Source File: FXGraphics2D.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
private ArcType intToArcType(int t) {
    if (t == Arc2D.CHORD) {
        return ArcType.CHORD;
    } else if (t == Arc2D.OPEN) {
        return ArcType.OPEN;
    } else if (t == Arc2D.PIE) {
        return ArcType.ROUND;
    }
    throw new IllegalArgumentException("Unrecognised t: " + t);
}
 
Example 6
Source File: MeterPlot.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Fills an arc on the dial between the given values.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param minValue  the minimum data value.
 * @param maxValue  the maximum data value.
 * @param paint  the background paint (<code>null</code> not permitted).
 * @param dial  a flag that indicates whether the arc represents the whole
 *              dial.
 */
protected void fillArc(Graphics2D g2, Rectangle2D area,
        double minValue, double maxValue, Paint paint, boolean dial) {

    ParamChecks.nullNotPermitted(paint, "paint");
    double startAngle = valueToAngle(maxValue);
    double endAngle = valueToAngle(minValue);
    double extent = endAngle - startAngle;

    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    int joinType = Arc2D.OPEN;
    if (this.shape == DialShape.PIE) {
        joinType = Arc2D.PIE;
    }
    else if (this.shape == DialShape.CHORD) {
        if (dial && this.meterAngle > 180) {
            joinType = Arc2D.CHORD;
        }
        else {
            joinType = Arc2D.PIE;
        }
    }
    else if (this.shape == DialShape.CIRCLE) {
        joinType = Arc2D.PIE;
        if (dial) {
            extent = 360;
        }
    }
    else {
        throw new IllegalStateException("DialShape not recognised.");
    }

    g2.setPaint(paint);
    Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent,
            joinType);
    g2.fill(arc);
}
 
Example 7
Source File: FXGraphics2D.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
private ArcType intToArcType(int t) {
    if (t == Arc2D.CHORD) {
        return ArcType.CHORD;
    } else if (t == Arc2D.OPEN) {
        return ArcType.OPEN;
    } else if (t == Arc2D.PIE) {
        return ArcType.ROUND;
    }
    throw new IllegalArgumentException("Unrecognised t: " + t);
}
 
Example 8
Source File: RegionAction.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private static final int toSwingArcType( int iArcStyle )
{
	switch ( iArcStyle )
	{
		case ArcRenderEvent.OPEN :
			return Arc2D.OPEN;
		case ArcRenderEvent.CLOSED :
			return Arc2D.CHORD;
		case ArcRenderEvent.SECTOR :
			return Arc2D.PIE;
	}
	return -1;
}
 
Example 9
Source File: G2dRendererBase.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 
 * @param iArcStyle
 * @return
 */
protected static final int toG2dArcType( int iArcStyle )
{
	switch ( iArcStyle )
	{
		case ArcRenderEvent.OPEN :
			return Arc2D.OPEN;
		case ArcRenderEvent.CLOSED :
			return Arc2D.CHORD;
		case ArcRenderEvent.SECTOR :
			return Arc2D.PIE;
	}
	return -1;
}
 
Example 10
Source File: FXGraphics2D.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
private ArcType intToArcType(int t) {
    if (t == Arc2D.CHORD) {
        return ArcType.CHORD;
    } else if (t == Arc2D.OPEN) {
        return ArcType.OPEN;
    } else if (t == Arc2D.PIE) {
        return ArcType.ROUND;
    }
    throw new IllegalArgumentException("Unrecognised t: " + t);
}
 
Example 11
Source File: FXGraphics2D.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
private ArcType intToArcType(int t) {
    if (t == Arc2D.CHORD) {
        return ArcType.CHORD;
    } else if (t == Arc2D.OPEN) {
        return ArcType.OPEN;
    } else if (t == Arc2D.PIE) {
        return ArcType.ROUND;
    }
    throw new IllegalArgumentException("Unrecognised t: " + t);
}
 
Example 12
Source File: MeterPlot.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Fills an arc on the dial between the given values.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param minValue  the minimum data value.
 * @param maxValue  the maximum data value.
 * @param paint  the background paint (<code>null</code> not permitted).
 * @param dial  a flag that indicates whether the arc represents the whole
 *              dial.
 */
protected void fillArc(Graphics2D g2, Rectangle2D area,
        double minValue, double maxValue, Paint paint, boolean dial) {

    ParamChecks.nullNotPermitted(paint, "paint");
    double startAngle = valueToAngle(maxValue);
    double endAngle = valueToAngle(minValue);
    double extent = endAngle - startAngle;

    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    int joinType = Arc2D.OPEN;
    if (this.shape == DialShape.PIE) {
        joinType = Arc2D.PIE;
    }
    else if (this.shape == DialShape.CHORD) {
        if (dial && this.meterAngle > 180) {
            joinType = Arc2D.CHORD;
        }
        else {
            joinType = Arc2D.PIE;
        }
    }
    else if (this.shape == DialShape.CIRCLE) {
        joinType = Arc2D.PIE;
        if (dial) {
            extent = 360;
        }
    }
    else {
        throw new IllegalStateException("DialShape not recognised.");
    }

    g2.setPaint(paint);
    Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent,
            joinType);
    g2.fill(arc);
}
 
Example 13
Source File: EditSelectionOperation.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
@Override
    protected void tick(int centreX, int centreY, boolean inverse, boolean first, float dynamicLevel) {
        // Create a geometric shape corresponding to the brush size, shape and
        // rotation
        Shape shape;
        final Brush brush = getBrush();
        final int brushRadius = brush.getRadius();
        switch (brush.getBrushShape()) {
            case BITMAP:
            case SQUARE:
                shape = new Rectangle(centreX - brushRadius, centreY - brushRadius, brushRadius * 2 + 1, brushRadius * 2 + 1);
                if (brush instanceof RotatedBrush) {
                    int rotation = ((RotatedBrush) brush).getDegrees();
                    if (rotation != 0) {
                        shape = new Path2D.Float(shape, AffineTransform.getRotateInstance(rotation / DEGREES_TO_RADIANS, centreX, centreY));
                    }
                }
                break;
            case CIRCLE:
                shape = new Arc2D.Float(centreX - brushRadius, centreY - brushRadius, brushRadius * 2 + 1, brushRadius * 2 + 1, 0.0f, 360.0f, Arc2D.CHORD);
                break;
            default:
                throw new InternalError();
        }

        final Dimension dimension = getDimension();
        dimension.setEventsInhibited(true);
        try {
            SelectionHelper selectionHelper = new SelectionHelper(dimension);
            if (inverse) {
                selectionHelper.removeFromSelection(shape);
            } else {
                selectionHelper.addToSelection(shape);
                // TODO: make this work correctly with undo/redo, and make "inside selection" ineffective when there is no selection, to avoid confusion
//                selectionState.setValue(true);
            }
        } finally {
            dimension.setEventsInhibited(false);
        }
    }
 
Example 14
Source File: TMASpotAnnotation.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a TMASpotAnnotation from a rawAnnotation. Reads color, classNum, x,y,w,h,scale,spotX,spotY from binary object.
 *
 * @param ra
 * @throws IOException
 * @throws ClassNotFoundException
 */
public TMASpotAnnotation(RawAnnotation ra) throws IOException, ClassNotFoundException {
    modifyDate = new Date(System.currentTimeMillis());
    setRawAnnotationType(getRawAnnotationType());
    shape = new ClassShape("annotation", Color.yellow, ClassShape.SHAPETYPE_ARC);
    setDescription(ra.getDescription());
    setRawAnnotationId(ra.getRawAnnotationId());
    setRawDataFileId(ra.getRawDataFileId());
    setRawAnnotationType(getRawAnnotationType());
    setUserId(ra.getUserId());
    ByteArrayInputStream is = new ByteArrayInputStream(ra.getData());
    ObjectInputStream ois = new ObjectInputStream(is);
    setColor(ois.readInt());
    shape.setColor(new Color(color));
    setClassNum(ois.readInt());
    double x = ois.readDouble();
    double y = ois.readDouble();
    double w = ois.readDouble();
    double h = ois.readDouble();
    double scale = ois.readDouble();
    setSpotX(ois.readInt());
    setSpotY(ois.readInt());
    Arc2DExt arc = new Arc2DExt(x, y, w, h, 0, 360, Arc2D.CHORD);
    arc.setScale(scale);
    shape.getShapeList().add(arc);
    ois.close();
    is.close();
}
 
Example 15
Source File: MeterPlot.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Fills an arc on the dial between the given values.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param minValue  the minimum data value.
 * @param maxValue  the maximum data value.
 * @param paint  the background paint (<code>null</code> not permitted).
 * @param dial  a flag that indicates whether the arc represents the whole
 *              dial.
 */
protected void fillArc(Graphics2D g2, Rectangle2D area,
        double minValue, double maxValue, Paint paint, boolean dial) {

    ParamChecks.nullNotPermitted(paint, "paint");
    double startAngle = valueToAngle(maxValue);
    double endAngle = valueToAngle(minValue);
    double extent = endAngle - startAngle;

    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    int joinType = Arc2D.OPEN;
    if (this.shape == DialShape.PIE) {
        joinType = Arc2D.PIE;
    }
    else if (this.shape == DialShape.CHORD) {
        if (dial && this.meterAngle > 180) {
            joinType = Arc2D.CHORD;
        }
        else {
            joinType = Arc2D.PIE;
        }
    }
    else if (this.shape == DialShape.CIRCLE) {
        joinType = Arc2D.PIE;
        if (dial) {
            extent = 360;
        }
    }
    else {
        throw new IllegalStateException("DialShape not recognised.");
    }

    g2.setPaint(paint);
    Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent,
            joinType);
    g2.fill(arc);
}
 
Example 16
Source File: FXGraphics2D.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
private ArcType intToArcType(int t) {
    if (t == Arc2D.CHORD) {
        return ArcType.CHORD;
    } else if (t == Arc2D.OPEN) {
        return ArcType.OPEN;
    } else if (t == Arc2D.PIE) {
        return ArcType.ROUND;
    }
    throw new IllegalArgumentException("Unrecognised t: " + t);
}
 
Example 17
Source File: MeterPlot.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Fills an arc on the dial between the given values.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param minValue  the minimum data value.
 * @param maxValue  the maximum data value.
 * @param paint  the background paint (<code>null</code> not permitted).
 * @param dial  a flag that indicates whether the arc represents the whole
 *              dial.
 */
protected void fillArc(Graphics2D g2, Rectangle2D area,
        double minValue, double maxValue, Paint paint, boolean dial) {

    ParamChecks.nullNotPermitted(paint, "paint");
    double startAngle = valueToAngle(maxValue);
    double endAngle = valueToAngle(minValue);
    double extent = endAngle - startAngle;

    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    int joinType = Arc2D.OPEN;
    if (this.shape == DialShape.PIE) {
        joinType = Arc2D.PIE;
    }
    else if (this.shape == DialShape.CHORD) {
        if (dial && this.meterAngle > 180) {
            joinType = Arc2D.CHORD;
        }
        else {
            joinType = Arc2D.PIE;
        }
    }
    else if (this.shape == DialShape.CIRCLE) {
        joinType = Arc2D.PIE;
        if (dial) {
            extent = 360;
        }
    }
    else {
        throw new IllegalStateException("DialShape not recognised.");
    }

    g2.setPaint(paint);
    Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent,
            joinType);
    g2.fill(arc);
}
 
Example 18
Source File: MeterPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Fills an arc on the dial between the given values.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param minValue  the minimum data value.
 * @param maxValue  the maximum data value.
 * @param paint  the background paint (<code>null</code> not permitted).
 * @param dial  a flag that indicates whether the arc represents the whole
 *              dial.
 */
protected void fillArc(Graphics2D g2, Rectangle2D area,
                       double minValue, double maxValue, Paint paint,
                       boolean dial) {
    if (paint == null) {
        throw new IllegalArgumentException("Null 'paint' argument");
    }
    double startAngle = valueToAngle(maxValue);
    double endAngle = valueToAngle(minValue);
    double extent = endAngle - startAngle;

    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    int joinType = Arc2D.OPEN;
    if (this.shape == DialShape.PIE) {
        joinType = Arc2D.PIE;
    }
    else if (this.shape == DialShape.CHORD) {
        if (dial && this.meterAngle > 180) {
            joinType = Arc2D.CHORD;
        }
        else {
            joinType = Arc2D.PIE;
        }
    }
    else if (this.shape == DialShape.CIRCLE) {
        joinType = Arc2D.PIE;
        if (dial) {
            extent = 360;
        }
    }
    else {
        throw new IllegalStateException("DialShape not recognised.");
    }

    g2.setPaint(paint);
    Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent,
            joinType);
    g2.fill(arc);
}
 
Example 19
Source File: MeterPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Fills an arc on the dial between the given values.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param minValue  the minimum data value.
 * @param maxValue  the maximum data value.
 * @param paint  the background paint (<code>null</code> not permitted).
 * @param dial  a flag that indicates whether the arc represents the whole 
 *              dial.
 */
protected void fillArc(Graphics2D g2, Rectangle2D area, 
                       double minValue, double maxValue, Paint paint,
                       boolean dial) {
    if (paint == null) {
        throw new IllegalArgumentException("Null 'paint' argument");
    }
    double startAngle = valueToAngle(maxValue);
    double endAngle = valueToAngle(minValue);
    double extent = endAngle - startAngle;

    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    int joinType = Arc2D.OPEN;
    if (this.shape == DialShape.PIE) {
        joinType = Arc2D.PIE;
    }
    else if (this.shape == DialShape.CHORD) {
        if (dial && this.meterAngle > 180) {
            joinType = Arc2D.CHORD;
        }
        else {
            joinType = Arc2D.PIE;
        }
    }
    else if (this.shape == DialShape.CIRCLE) {
        joinType = Arc2D.PIE;
        if (dial) {
            extent = 360;
        }
    }
    else {
        throw new IllegalStateException("DialShape not recognised.");
    }

    g2.setPaint(paint);
    Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent, 
            joinType);
    g2.fill(arc);
}
 
Example 20
Source File: MeterPlot.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Fills an arc on the dial between the given values.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param minValue  the minimum data value.
 * @param maxValue  the maximum data value.
 * @param paint  the background paint (<code>null</code> not permitted).
 * @param dial  a flag that indicates whether the arc represents the whole 
 *              dial.
 */
protected void fillArc(Graphics2D g2, Rectangle2D area, 
                       double minValue, double maxValue, Paint paint,
                       boolean dial) {
    if (paint == null) {
        throw new IllegalArgumentException("Null 'paint' argument");
    }
    double startAngle = valueToAngle(maxValue);
    double endAngle = valueToAngle(minValue);
    double extent = endAngle - startAngle;

    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    int joinType = Arc2D.OPEN;
    if (this.shape == DialShape.PIE) {
        joinType = Arc2D.PIE;
    }
    else if (this.shape == DialShape.CHORD) {
        if (dial && this.meterAngle > 180) {
            joinType = Arc2D.CHORD;
        }
        else {
            joinType = Arc2D.PIE;
        }
    }
    else if (this.shape == DialShape.CIRCLE) {
        joinType = Arc2D.PIE;
        if (dial) {
            extent = 360;
        }
    }
    else {
        throw new IllegalStateException("DialShape not recognised.");
    }

    g2.setPaint(paint);
    Arc2D.Double arc = new Arc2D.Double(
        x, y, w, h, startAngle, extent, joinType
    );
    g2.fill(arc);
}