本文整理匯總了Java中java.awt.geom.Ellipse2D類的典型用法代碼示例。如果您正苦於以下問題:Java Ellipse2D類的具體用法?Java Ellipse2D怎麽用?Java Ellipse2D使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Ellipse2D類屬於java.awt.geom包,在下文中一共展示了Ellipse2D類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: CompassPlot
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
/**
* Constructs a new compass plot.
*
* @param dataset the dataset for the plot.
*/
public CompassPlot(ValueDataset dataset) {
super();
if (dataset != null) {
this.datasets[0] = dataset;
dataset.addChangeListener(this);
}
this.circle1 = new Ellipse2D.Double();
this.circle2 = new Ellipse2D.Double();
this.rect1 = new Rectangle2D.Double();
setSeriesNeedle(0);
}
示例2: main
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setPaint(Color.WHITE);
g.fill(new Rectangle(image.getWidth(), image.getHeight()));
g.scale(.9, .9);
g.setPaint(Color.BLACK);
g.setStroke(new BasicStroke(0.5f));
g.draw(new Ellipse2D.Double(25, 25, 150, 150));
// To visually check it
//ImageIO.write(image, "PNG", new File(args[0]));
boolean nonWhitePixelFound = false;
for (int x = 100; x < 200; ++x) {
if (image.getRGB(x, 90) != Color.WHITE.getRGB()) {
nonWhitePixelFound = true;
break;
}
}
if (!nonWhitePixelFound) {
throw new RuntimeException("A circle is rendered like a 'C' shape.");
}
}
示例3: runTest
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
public void runTest(Object ctx, int numReps) {
FillEllipse2Ds.Context cctx = (FillEllipse2Ds.Context) ctx;
int size = cctx.size;
int x = cctx.initX;
int y = cctx.initY;
Ellipse2D ellipse = cctx.ellipse;
Graphics2D g2d = (Graphics2D) cctx.graphics;
g2d.translate(cctx.orgX, cctx.orgY);
Color rCArray[] = cctx.colorlist;
int ci = cctx.colorindex;
do {
if (rCArray != null) {
g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
}
ellipse.setFrame(x, y, size, size);
g2d.fill(ellipse);
if ((x -= 3) < 0) x += cctx.maxX;
if ((y -= 1) < 0) y += cctx.maxY;
} while (--numReps > 0);
cctx.colorindex = ci;
g2d.translate(-cctx.orgX, -cctx.orgY);
}
示例4: setShape
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
/**
* Creates the shape of the vertex given its description in a string
* @param shapeString "square" or "circle"
*/
public void setShape(String shapeString) {
Shape newShape;
if (shapeString.startsWith("square")){
Rectangle2D rectangle = new Rectangle2D.Float();
rectangle.setFrameFromCenter(0,0,size,size);
newShape = rectangle;
}
else
{
Ellipse2D ellipse = new Ellipse2D.Float();
ellipse.setFrameFromCenter(0,0,size,size);
newShape = ellipse;
}
this.shape = newShape;
}
示例5: changeDrawSettings
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
public void changeDrawSettings(DrawConstrains dCst) {
this.dCst = dCst;
resize();
// assigning the constant of panel
f = dCst.getFont();
stroke = dCst.getDrawStroke();
START_GAP = dCst.getStartingGap();
END_GAP = dCst.getStartingGap();
ELEM_HEIGHT = dCst.getElementHeight();
ELEM_WIDTH = dCst.getElementWidth();
ELEMS_GAP = dCst.getElementsGap();
PROC_RAD = dCst.getProcessorRadius();
// initilazing the queue
queue = new Rectangle2D.Double[queueLength()];
processor = new Ellipse2D.Double();
// repaint();
}
示例6: drawStatus
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
public void drawStatus(int status, double probability, Graphics2D g2d, Color sc, Color pc, Color borderC, boolean bold) {
double x = 2.0 * (2.0 * STATUS_RAD + ELEMS_GAP) * status + START_GAP;
double y = panelH / 2.0 - STATUS_RAD;
double pie = probability * 360;
Color ctmp = g2d.getColor();
if (bold) {
g2d.setStroke(strokeB);
}
statusE[status] = new Ellipse2D.Double(x, y, STATUS_RAD * 2.0, STATUS_RAD * 2.0);
statusP[status] = new Arc2D.Double(x, y, STATUS_RAD * 2.0, STATUS_RAD * 2.0, 0.0, pie, Arc2D.PIE);
g2d.setPaint(sc);
g2d.fill(statusE[status]);
g2d.setPaint(pc);
g2d.fill(statusP[status]);
g2d.setPaint(borderC);
g2d.draw(statusE[status]);
drawCenteredText(probabilityToString(probability, 3), Color.BLACK, x + STATUS_RAD, y - STATUS_RAD, g2d, false);
drawCenteredText("" + status, borderC, x + STATUS_RAD, panelH / 2.0, g2d, false);
g2d.setColor(ctmp);
g2d.setStroke(stroke);
}
示例7: draw
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
/**
* Draws the background to the specified graphics device. If the dial
* frame specifies a window, the clipping region will already have been
* set to this window before this method is called.
*
* @param g2 the graphics device (<code>null</code> not permitted).
* @param plot the plot (ignored here).
* @param frame the dial frame (ignored here).
* @param view the view rectangle (<code>null</code> not permitted).
*/
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
Rectangle2D view) {
g2.setPaint(this.fillPaint);
Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius,
this.radius);
Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(),
f.getHeight());
g2.fill(e);
g2.setPaint(this.outlinePaint);
g2.setStroke(this.outlineStroke);
g2.draw(e);
}
示例8: draw
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
/**
* Draws the frame. This method is called by the {@link DialPlot} class,
* you shouldn't need to call it directly.
*
* @param g2 the graphics target (<code>null</code> not permitted).
* @param plot the plot (<code>null</code> not permitted).
* @param frame the frame (<code>null</code> not permitted).
* @param view the view (<code>null</code> not permitted).
*/
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
Rectangle2D view) {
Shape window = getWindow(frame);
Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius + 0.02,
this.radius + 0.02);
Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(),
f.getHeight());
Area area = new Area(e);
Area area2 = new Area(window);
area.subtract(area2);
g2.setPaint(this.backgroundPaint);
g2.fill(area);
g2.setStroke(this.stroke);
g2.setPaint(this.foregroundPaint);
g2.draw(window);
g2.draw(e);
}
示例9: draw
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
@Override
public void draw(Graphics2D graphics) {
float radius = emp.getRadius();
float diameter = radius * 2;
// inner ring
graphics.setColor(outerColor);
graphics.fill(new Ellipse2D.Double(drawLocation.getX() - radius,
drawLocation.getY() - radius, diameter, diameter));
radius = radius - 2;
diameter = radius * 2;
graphics.setColor(EMP_INNER_COLOR);
graphics.fill(new Ellipse2D.Double(drawLocation.getX() - radius,
drawLocation.getY() - radius, diameter, diameter));
}
示例10: GenerateRTMapPNG
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
private void GenerateRTMapPNG(XYSeriesCollection xySeriesCollection, XYSeries series, float R2) throws IOException {
new File(Workfolder + "/RT_Mapping/").mkdir();
String pngfile = Workfolder + "/RT_Mapping/" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName).substring(0, Math.min(120, FilenameUtils.getBaseName(LCMSA.mzXMLFileName).length() - 1)) + "_" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName).substring(0, Math.min(120, FilenameUtils.getBaseName(LCMSB.mzXMLFileName).length() - 1)) + "_RT.png";
XYSeries smoothline = new XYSeries("RT fitting curve");
for (XYZData data : regression.PredictYList) {
smoothline.add(data.getX(), data.getY());
}
xySeriesCollection.addSeries(smoothline);
xySeriesCollection.addSeries(series);
JFreeChart chart = ChartFactory.createScatterPlot("Retention time mapping: R2=" + R2, "RT:" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName), "RT:" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName), xySeriesCollection,
PlotOrientation.VERTICAL, true, true, false);
XYPlot xyPlot = (XYPlot) chart.getPlot();
xyPlot.setDomainCrosshairVisible(true);
xyPlot.setRangeCrosshairVisible(true);
XYItemRenderer renderer = xyPlot.getRenderer();
renderer.setSeriesPaint(1, Color.blue);
renderer.setSeriesPaint(0, Color.BLACK);
renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3));
renderer.setSeriesStroke(1, new BasicStroke(3.0f));
renderer.setSeriesStroke(0, new BasicStroke(3.0f));
xyPlot.setBackgroundPaint(Color.white);
ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
}
示例11: draw
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
public void draw(Graphics2D g) {
float radius = Beacon.BEACON_RADIUS;
float diameter = Beacon.BEACON_RADIUS * 2;
Ellipse2D.Double shape = new Ellipse2D.Double(drawLocation.getX() - radius,
drawLocation.getY() - radius, diameter, diameter);
g.setColor(BEACON_COLOR);
g.fill(shape);
g.setStroke(JSpaceSettlersComponent.THICK_STROKE);
g.setColor(BEACON_LINE_COLOR);
g.draw(shape);
// add an E to make it clear it is an energy beacon
g.setPaint(Color.BLACK);
g.drawString("E", (int) drawLocation.getX()-3, (int) drawLocation.getY() + 4);
}
示例12: paintPlace
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
/**
* Paints the Place
* @param g - graphic object to contain the Place
*/
public void paintPlace(Graphics g){
int diameter = 30;
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.WHITE);
Ellipse2D.Double circle = new Ellipse2D.Double((position.x - (diameter / 2)), (position.y - (diameter / 2)),
diameter, diameter);
g2d.fill(circle);
g2d.setColor(Color.GREEN);
g2d.fill(circle);
if (token){
g2d.setColor(Color.DARK_GRAY);
Ellipse2D.Double t = new Ellipse2D.Double((position.x - (diameter / 4)),
(position.y - (diameter / 4)),
(diameter / 2), (diameter / 2));
g2d.fill(t);
}
}
示例13: addEntity
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
/**
* Adds an entity to the collection.
*
* @param entities the entity collection being populated.
* @param area the entity area (if <code>null</code> a default will be used).
* @param entityX the entity's center x-coordinate in user space.
* @param entityY the entity's center y-coordinate in user space.
* @param dataset the dataset.
* @param series the series.
* @param item the item.
*/
protected void addEntity(EntityCollection entities, Shape area,
XYDataset dataset, int series, int item,
double entityX, double entityY) {
if (area == null) {
area = new Ellipse2D.Double(
entityX - this.defaultEntityRadius, entityY - this.defaultEntityRadius,
this.defaultEntityRadius * 2, this.defaultEntityRadius * 2
);
}
String tip = null;
XYToolTipGenerator generator = getToolTipGenerator(series, item);
if (generator != null) {
tip = generator.generateToolTip(dataset, series, item);
}
String url = null;
if (getURLGenerator() != null) {
url = getURLGenerator().generateURL(dataset, series, item);
}
XYItemEntity entity = new XYItemEntity(area, dataset, series, item, tip, url);
entities.addEntity(entity);
}
示例14: paintPlace
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
public void paintPlace(Graphics g){
int diameter = 30;
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.WHITE);
Ellipse2D.Double circle = new Ellipse2D.Double((position.x - (diameter / 2)), (position.y - (diameter / 2)),
diameter, diameter);
g2d.fill(circle);
g2d.setColor(Color.GREEN);
g2d.fill(circle);
if (token){
g2d.setColor(Color.DARK_GRAY);
Ellipse2D.Double t = new Ellipse2D.Double((position.x - (diameter / 4)),
(position.y - (diameter / 4)),
(diameter / 2), (diameter / 2));
g2d.fill(t);
}
}
示例15: changeDrawSettings
import java.awt.geom.Ellipse2D; //導入依賴的package包/類
public void changeDrawSettings(DrawConstrains dCst) {
this.dCst = dCst;
resize();
// assigning the constant of panel
f = dCst.getFont();
stroke = dCst.getDrawStroke();
START_GAP = dCst.getStartingGap();
END_GAP = dCst.getStartingGap();
ELEM_HEIGHT = dCst.getElementHeight();
ELEM_WIDTH = dCst.getElementWidth();
ELEMS_GAP = dCst.getElementsGap();
PROC_RAD = dCst.getProcessorRadius();
// initilazing the queue
queue = new Rectangle2D.Double[queueLenght()];
processor = new Ellipse2D.Double();
// repaint();
}