本文整理汇总了Java中java.awt.geom.Arc2D.CHORD属性的典型用法代码示例。如果您正苦于以下问题:Java Arc2D.CHORD属性的具体用法?Java Arc2D.CHORD怎么用?Java Arc2D.CHORD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.geom.Arc2D
的用法示例。
在下文中一共展示了Arc2D.CHORD属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawCurrentPoint
public void drawCurrentPoint() {
if( map==null || point==null || !map.isVisible() ) return;
synchronized (map.getTreeLock() ) {
Graphics2D g = map.getGraphics2D();
float zoom = (float)map.getZoom();
g.setStroke( new BasicStroke( 2f/ zoom ) );
g.setColor(Color.RED);
g.setXORMode( Color.white );
Rectangle2D rect = map.getClipRect2D();
double wrap = map.getWrap();
if( wrap>0. ) while( point.x-wrap > rect.getX() ) point.x-=wrap;
double size = 10./map.getZoom();
Arc2D.Double arc = new Arc2D.Double( 0., point.y-.5*size,
size, size, 0., 360., Arc2D.CHORD);
if( wrap>0. ) {
while( point.x < rect.getX()+rect.getWidth() ) {
arc.x = point.x-.5*size;
g.draw(arc);
point.x += wrap;
}
} else {
arc.x = point.x-.5*size;
g.draw(arc);
}
}
}
示例2: plotXY
public void plotXY( Graphics2D g,
Rectangle2D bounds,
double xScale, double yScale ) {
g.setColor( Color.blue );
float x0 = (float)bounds.getX();
float y0 = (float)bounds.getY();
float sy = (float)yScale;
float sx = (float)xScale;
Arc2D.Float arc = new Arc2D.Float(0f, 0f, 5f, 5f, 0f, 360f,
Arc2D.CHORD);
for(int k=0 ; k<xyd.length ; k++) {
float x = (xyd[k][4]-x0)*sx;
float y = (xyd[k][3]-y0)*sy;
arc.x = x-2.5f;
arc.y = y-2.5f;
g.draw(arc);
}
}
示例3: TestImageGenerator
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;
}
}
}
示例4: detectSpot
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;
}
示例5: intToArcType
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);
}
示例6: fillArc
/**
* 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);
}
示例7: fillArc
/**
* 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} 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) {
Args.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);
}
示例8: TMASpotAnnotation
/**
* 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();
}
示例9: drawArc
/**
* Draws an arc.
*
* @param g2 the graphics device.
* @param area the plot area.
* @param minValue the minimum value.
* @param maxValue the maximum value.
* @param paint the paint.
* @param outlineType the outline type.
*/
protected void drawArc(Graphics2D g2, Rectangle2D area, double minValue, double maxValue,
Paint paint, int outlineType) {
double startAngle = calculateAngle(maxValue);
double endAngle = calculateAngle(minValue);
double extent = endAngle - startAngle;
double x = area.getX();
double y = area.getY();
double w = area.getWidth();
double h = area.getHeight();
g2.setPaint(paint);
if (outlineType > 0) {
g2.setStroke(new BasicStroke(10.0f));
}
else {
g2.setStroke(new BasicStroke(DEFAULT_BORDER_SIZE));
}
int joinType = Arc2D.OPEN;
if (outlineType > 0) {
if (this.shape == DialShape.PIE) {
joinType = Arc2D.PIE;
}
else if (this.shape == DialShape.CHORD) {
if (this.meterAngle > 180) {
joinType = Arc2D.CHORD;
}
else {
joinType = Arc2D.PIE;
}
}
else if (this.shape == DialShape.CIRCLE) {
joinType = Arc2D.PIE;
extent = 360;
}
else {
throw new IllegalStateException(
"MeterPlot.drawArc(...): dialType not recognised."
);
}
}
Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent, joinType);
if (outlineType > 0) {
g2.fill(arc);
}
else {
g2.draw(arc);
}
}
示例10: fillArc
/**
* 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);
}
示例11: drag
void drag( MouseEvent e ) {
drawCircle();
if( ties.size()<2 || currentTie<0 ) {
circle=null;
currentTie = -1;
return;
}
double y = graph.getYAt( e.getPoint() );
double x = graph.getXAt( e.getPoint() );
float[] tie = (float[])ties.get(currentTie);
if( currentTie>0 ) {
tie = (float[])ties.get(currentTie-1);
if( y<tie[0]+.001 ) y = tie[0]+.001;
} else {
tie = (float[])ties.get(currentTie);
y=(float)tie[0];
}
if( currentTie<ties.size()-1 ) {
tie = (float[])ties.get(currentTie+1);
if( y>tie[0]-.001 ) y = tie[0]-.001;
//} else {
// tie = (float[])ties.get(currentTie);
// y=(float)tie[0];
}
if( x<0. )x=0.;
tie = (float[])ties.get(currentTie);
tie[0] = (float)y;
tie[1] = (float)x;
graph.repaint();
prevYPos = -1;
prevXPos = -1;
double[] info = graph.getPlotInfo();
double x0 = info[2];
double y0 = info[3];
double xs = info[0];
double ys = info[1];
y = (-tie[0]-y0)*ys;
x = (tie[1]-x0)*xs;
circle = new Arc2D.Double( x-4., y-4., 8., 8., 0., 360., Arc2D.CHORD);
// circle = new Line2D.Double( 0., y, 1000., y);
drawCircle();
label.setText( currentTie+": "+tie[0]+" m, "+ tie[1] +" mA");
}
示例12: drawCurrentPoint
protected void drawCurrentPoint() {
if( map==null || currentPoint==null || !map.isVisible() ) return;
synchronized (map.getTreeLock() ) {
Graphics2D g = map.getGraphics2D();
Graphics2D g2 = map.getGraphics2D();
float zoom = (float)map.getZoom();
g.setStroke( new BasicStroke( 5f/ zoom ) );
Rectangle2D rect = map.getClipRect2D();
double wrap = map.getWrap();
if( wrap>0. ) while( currentPoint.x-wrap > rect.getX() ) currentPoint.x-=wrap;
double size = 10./map.getZoom();
Arc2D.Double arc = new Arc2D.Double( 0., currentPoint.y,
size/6, size/6, 0., 360., Arc2D.CHORD);
Arc2D.Double arc2 = new Arc2D.Double( 0., currentPoint.y-.5*size,
size, size, 0., 360., Arc2D.CHORD);
if( wrap>0. ) {
while( currentPoint.x < rect.getX()+rect.getWidth() ) {
g.setColor(Color.red);
g.setStroke( new BasicStroke( 5f/ zoom ) );
g.draw(currentSeg);
g.setColor(Color.white);
g.setStroke( new BasicStroke( 2.f/ zoom ) );
arc.x = currentPoint.x;
g.draw(arc);
arc2.x = currentPoint.x-.5*size;
g2.setXORMode( Color.white );
g2.setStroke( new BasicStroke( 4f/ zoom ) );
g2.draw(arc2);
currentPoint.x += wrap;
}
} else {
g.setColor(Color.red);
g.setStroke( new BasicStroke( 5f/ zoom ) );
g.draw(currentSeg);
g.setColor(Color.white);
g.setStroke( new BasicStroke( 2.f/ zoom ) );
arc.x = currentPoint.x;
g.draw(arc);
arc2.x = currentPoint.x-.5*size;
g2.setXORMode( Color.white );
g2.setStroke( new BasicStroke( 4f/ zoom ) );
g2.draw(arc2);
}
}
}
示例13: draw
public void draw(Graphics2D g) {
// if(!display) return;
int yr1 = 1900;
int yr2 = 2005;
try {
long[] interval = timeInterval();
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
if( db.before.isSelected() ) {
cal.setTimeInMillis(interval[0]);
yr1 = cal.get(cal.YEAR);
}
if( db.after.isSelected() ) {
cal.setTimeInMillis(interval[1]);
yr2 = cal.get(cal.YEAR);
}
} catch(Exception e) {
}
// System.out.println( yr1 +"\t"+ yr2);
float size = 2.0f + 6f/(float)map.getZoom();
Arc2D.Float dot = new Arc2D.Float(-size/2f, -size/2f, size, size, 0f, 360f, Arc2D.CHORD);
float size1 = 2.0f + 7f/(float)map.getZoom();
GeneralPath triangle = new GeneralPath();
triangle.moveTo(0f, size1/2f );
triangle.lineTo(size1/2f, -size1/2f );
triangle.lineTo(-size1/2f, -size1/2f );
triangle.closePath();
// Rectangle2D.Float square = new Rectangle2D.Float(-size1/2f, -size1/2f, size1, size1);
AffineTransform at = g.getTransform();
g.setStroke( new BasicStroke( .5f/(float)map.getZoom() ) );
RenderingHints hints = g.getRenderingHints();
g.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g.setRenderingHint( RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
Shape shape = dot;
for(int k=0 ; k<xyd.length ; k++) {
// Shape shape = triangle;
// if( xyd[k][5]<=1991f ) shape = dot;
if( xyd[k][5]>yr2 )continue;
if( xyd[k][5]<yr1 )continue;
g.translate( (double)xyd[k][0], (double)xyd[k][1] );
// g.setColor( Color.black );
// g.draw(shape);
g.setColor( color[k] );
g.fill(shape);
g.setColor( Color.black );
g.draw(shape);
g.setTransform( at );
}
g.setFont( (new Font("Serif", Font.BOLD, 1)).deriveFont( size1*1.5f));
Rectangle2D rect = map.getClipRect2D();
double s = (double) size1;
double x = rect.getX() + s;
double y = rect.getY() + 2.*s;
// g.translate( x, y );
// g.setColor( Color.white );
// g.fill( dot );
// g.setColor( Color.black );
// g.draw( dot );
// g.translate( s, s/2.);
// String year = db.startF.getText();
// String dateString = db.before.isSelected()
// ? "before 1/1/"+year
// : "after 1/1/"+year;
// g.drawString( dateString, 0, 0);
// g.drawString( "before 1/1/1991", 0, 0);
// g.setTransform(at);
// g.translate( x, y+s*2.0 );
// g.setColor( Color.white );
// g.fill( triangle );
// g.setColor( Color.black );
// g.draw( triangle );
// g.translate( s, s/2.);
// g.drawString( "after 1/1/1991", 0, 0);
g.setTransform(at);
g.setRenderingHints( hints);
}