/**
* Returns the shape for the window for this dial. Some dial layers will
* request that their drawing be clipped within this window.
*
* @param frame the reference frame ({@code null} not permitted).
*
* @return The shape of the dial's window.
*/
@Override
public Shape getWindow(Rectangle2D frame) {
Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame,
this.innerRadius, this.innerRadius);
Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame,
this.outerRadius, this.outerRadius);
Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle,
this.extent, Arc2D.OPEN);
Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle
+ this.extent, -this.extent, Arc2D.OPEN);
GeneralPath p = new GeneralPath();
Point2D point1 = inner.getStartPoint();
p.moveTo((float) point1.getX(), (float) point1.getY());
p.append(inner, true);
p.append(outer, true);
p.closePath();
return p;
}
java类java.awt.geom.Arc2D的实例源码
ArcDialFrame.java 文件源码
项目:jfreechart
阅读 21
收藏 0
点赞 0
评论 0
PiePlot.java 文件源码
项目:jfreechart
阅读 17
收藏 0
点赞 0
评论 0
/**
* Returns a rectangle that can be used to create a pie section (taking
* into account the amount by which the pie section is 'exploded').
*
* @param unexploded the area inside which the unexploded pie sections are
* drawn.
* @param exploded the area inside which the exploded pie sections are
* drawn.
* @param angle the start angle.
* @param extent the extent of the arc.
* @param explodePercent the amount by which the pie section is exploded.
*
* @return A rectangle that can be used to create a pie section.
*/
protected Rectangle2D getArcBounds(Rectangle2D unexploded,
Rectangle2D exploded,
double angle, double extent,
double explodePercent) {
if (explodePercent == 0.0) {
return unexploded;
}
Arc2D arc1 = new Arc2D.Double(unexploded, angle, extent / 2,
Arc2D.OPEN);
Point2D point1 = arc1.getEndPoint();
Arc2D.Double arc2 = new Arc2D.Double(exploded, angle, extent / 2,
Arc2D.OPEN);
Point2D point2 = arc2.getEndPoint();
double deltaX = (point1.getX() - point2.getX()) * explodePercent;
double deltaY = (point1.getY() - point2.getY()) * explodePercent;
return new Rectangle2D.Double(unexploded.getX() - deltaX,
unexploded.getY() - deltaY, unexploded.getWidth(),
unexploded.getHeight());
}
ShapeUtils.java 文件源码
项目:jfreechart
阅读 23
收藏 0
点赞 0
评论 0
/**
* Compares two arcs and returns {@code true} if they are equal or
* both {@code null}.
*
* @param a1 the first arc ({@code null} permitted).
* @param a2 the second arc ({@code null} permitted).
*
* @return A boolean.
*/
public static boolean equal(Arc2D a1, Arc2D a2) {
if (a1 == null) {
return (a2 == null);
}
if (a2 == null) {
return false;
}
if (!a1.getFrame().equals(a2.getFrame())) {
return false;
}
if (a1.getAngleStart() != a2.getAngleStart()) {
return false;
}
if (a1.getAngleExtent() != a2.getAngleExtent()) {
return false;
}
if (a1.getArcType() != a2.getArcType()) {
return false;
}
return true;
}
TestImageGenerator.java 文件源码
项目:orbit-image-analysis
阅读 15
收藏 0
点赞 0
评论 0
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;
}
}
}
SpotImagePanel.java 文件源码
项目:orbit-image-analysis
阅读 14
收藏 0
点赞 0
评论 0
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;
}
Protractor.java 文件源码
项目:PhET
阅读 16
收藏 0
点赞 0
评论 0
public void update() {
// System.out.println( "leftLeg.getAngle() = " + leftLeg.getAngle() );
// System.out.println( "right.getAngle() = " + rightLeg.getAngle() );
double arcDist = 30;
Arc2D.Double arc = new Arc2D.Double( -arcDist, -arcDist, arcDist * 2, arcDist * 2, toDegrees( 0 ), toDegrees( 0 ), Arc2D.Double.OPEN );
Point2D p1 = Vector2D.createPolar( 20, leftLeg.getAngle() ).getDestination( new Point2D.Double() );
Point2D p2 = Vector2D.createPolar( 20, rightLeg.getAngle() ).getDestination( new Point2D.Double() );
if ( getDegreesSigned() >= 0 ) {
arc.setAngles( p1, p2 );
}
else {
arc.setAngles( p2, p1 );
}
path.setPathTo( arc );
}
CircularGradientPaint.java 文件源码
项目:PhET
阅读 17
收藏 0
点赞 0
评论 0
public static void main( String[] args ) {
new JFrame() {{
setContentPane( new JPanel() {
@Override
protected void paintComponent( Graphics g ) {
super.paintComponent( g );
Graphics2D g2 = (Graphics2D) g;
Arc2D.Double ellipse2 = new Arc2D.Double( 0, 0, 200, 200, 0, 90, Arc2D.PIE );
CircularGradientPaint rgp2 = new CircularGradientPaint( new Point2D.Double( 100, 100 ), Color.red, Color.white );
g2.setPaint( rgp2 );
g2.fill( ellipse2 );
Arc2D.Double ellipse = new Arc2D.Double( 0, 0, 200, 200, 90, 90, Arc2D.PIE );
CircularGradientPaint rgp = new CircularGradientPaint( new Point2D.Double( 100, 100 ), Color.white, Color.blue );
g2.setPaint( rgp );
g2.fill( ellipse );
}
} );
setSize( 800, 700 );
setVisible( true );
setDefaultCloseOperation( EXIT_ON_CLOSE );
}};
}
PlatformNode2.java 文件源码
项目:PhET
阅读 14
收藏 0
点赞 0
评论 0
public void updateAngle() {
final double extent = ( endAngle - startAngle ) * 360 / 2 / Math.PI;
// final double platformAngle = platform.getPosition() * 360 / Math.PI / 2;
final double platformAngle = -platform.getPosition() * 360 / Math.PI / 2;
final double angle1 = startAngle * 360 / 2 / Math.PI + platformAngle;
// System.out.println( "platform.getPosition() = " + platform.getPosition() + ", angle=" + angle1 );
Arc2D.Double outerArc = new Arc2D.Double( -outerRadius, -outerRadius, outerRadius * 2, outerRadius * 2, angle1, extent, Arc2D.Double.OPEN );
Arc2D.Double outerArcRev = new Arc2D.Double( -outerRadius, -outerRadius, outerRadius * 2, outerRadius * 2, angle1 + extent, -extent, Arc2D.Double.OPEN );
Arc2D.Double innerArc = new Arc2D.Double( -innerRadius, -innerRadius, innerRadius * 2, innerRadius * 2, startAngle * 360 / 2 / Math.PI + extent + platformAngle, -extent, Arc2D.Double.OPEN );
Arc2D.Double innerArcRev = new Arc2D.Double( -innerRadius, -innerRadius, innerRadius * 2, innerRadius * 2, angle1, extent, Arc2D.Double.OPEN );
GeneralPath path = toPathSegment( outerArc, innerArc );
body.setPathTo( path );
Arc2D.Double outerArcDepth = new Arc2D.Double( -outerRadius + edgeDX, -outerRadius + edgeDY, outerRadius * 2, outerRadius * 2, angle1, extent, Arc2D.Double.OPEN );
Arc2D.Double innerArcDepth = new Arc2D.Double( -innerRadius + edgeDX, -innerRadius + edgeDY, innerRadius * 2, innerRadius * 2, startAngle * 360 / 2 / Math.PI + extent + platformAngle, -extent, Arc2D.Double.OPEN );
// Shape p2 = path.createTransformedShape( AffineTransform.getTranslateInstance( edgeDX, edgeDY ) );
// bottomPanel.setPathTo( toPathSegment( outerArcDepth, innerArcDepth ) );
northPanel.setPathTo( toPathSegment( outerArcRev, outerArcDepth ) );
southPanel.setPathTo( toPathSegment( innerArcRev, innerArcDepth ) );
}
PSWTPath.java 文件源码
项目:PhET
阅读 22
收藏 0
点赞 0
评论 0
private void drawShape(final SWTGraphics2D g2) {
final double lineWidth = g2.getTransformedLineWidth();
if (shape instanceof Rectangle2D) {
g2.drawRect(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth, shapePts[3]
- lineWidth);
}
else if (shape instanceof Ellipse2D) {
g2.drawOval(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth, shapePts[3]
- lineWidth);
}
else if (shape instanceof Arc2D) {
g2.drawArc(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth, shapePts[3]
- lineWidth, shapePts[4], shapePts[5]);
}
else if (shape instanceof RoundRectangle2D) {
g2.drawRoundRect(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth,
shapePts[3] - lineWidth, shapePts[4], shapePts[5]);
}
else {
g2.draw(shape);
}
}
PSWTPath.java 文件源码
项目:PhET
阅读 19
收藏 0
点赞 0
评论 0
private void fillShape(final SWTGraphics2D g2) {
final double lineWidth = g2.getTransformedLineWidth();
if (shape instanceof Rectangle2D) {
g2.fillRect(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth, shapePts[3]
- lineWidth);
}
else if (shape instanceof Ellipse2D) {
g2.fillOval(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth, shapePts[3]
- lineWidth);
}
else if (shape instanceof Arc2D) {
g2.fillArc(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth, shapePts[3]
- lineWidth, shapePts[4], shapePts[5]);
}
else if (shape instanceof RoundRectangle2D) {
g2.fillRoundRect(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth,
shapePts[3] - lineWidth, shapePts[4], shapePts[5]);
}
else {
g2.fill(shape);
}
}