List of usage examples for java.awt.geom Area Area
public Area()
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(); Area a2 = new Area(e2); a1.add(a2);/*from www . j a va2 s . c om*/ g2.setColor(Color.orange); g2.fill(a1); }
From source file:com.t3.model.LightSource.java
/** * Area for all lights combined//ww w. j a v a 2 s. co m */ public Area getArea(Token token, Zone zone, Direction position) { Area area = new Area(); for (Light light : getLightList()) { area.add(light.getArea(token, zone)); } return getArea(token, zone, position, area); }
From source file:ec.util.chart.swing.Charts.java
@Nonnull public static LegendItemEntity createFakeLegendItemEntity(XYDataset dataset, Comparable<?> seriesKey) { LegendItemEntity result = new LegendItemEntity(new Area()); result.setDataset(dataset);//w ww . ja v a2 s . c om result.setSeriesKey(seriesKey); return result; }
From source file:fr.romainf.QRCode.java
/** * Renders the QRCode data in an SVG document. * * @param matrix BitMatrix BitMatrix of the encoded QRCode * @param pixelColour Color The colour of pixels representing bits * @return SVGGraphics2D//from w ww. j a v a 2 s .co m */ private static SVGGraphics2D renderSVG(BitMatrix matrix, Color pixelColour) { DOMImplementation implementation = SVGDOMImplementation.getDOMImplementation(); String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; Document document = implementation.createDocument(svgNS, "svg", null); SVGGraphics2D svgGenerator = new SVGGraphics2D(document); int width = matrix.getWidth(); int height = matrix.getHeight(); Area area = new Area(); for (int x = 0; x < width; x += 1) { for (int y = 0; y < height; y += 1) { if (matrix.get(x, y)) { area.add(new Area(new Rectangle(x, y, 1, 1))); } } } svgGenerator.setPaint(pixelColour); svgGenerator.fill(area); return svgGenerator; }
From source file:it.unibo.alchemist.model.implementations.linkingrules.ConnectionBeam.java
private void readObject(final ObjectInputStream o) throws ClassNotFoundException, IOException { o.defaultReadObject();//from w w w . j a va 2 s . c o m oenv = null; obstacles = new Area(); }
From source file:VASSAL.build.module.map.MapShader.java
/** * Get/Build the shape of the shade.//w w w . j a v a2 s. co m */ protected Area getShadeShape(Map map) { final Area myShape = type.equals(FG_TYPE) ? new Area() : new Area(getBoardClip()); for (GamePiece p : map.getPieces()) { checkPiece(myShape, p); } return myShape; }
From source file:org.apache.pdfbox.rendering.PageDrawer.java
/** * Begin buffering the text clipping path, if any. *//*w w w . j a v a 2 s .c o m*/ private void beginTextClip() { // buffer the text clip because it represents a single clipping area textClippingArea = new Area(); }
From source file:VASSAL.build.module.map.MapShader.java
/** * Build a clipping region excluding boards that do not needed to be Shaded. *//*from w w w. j ava 2 s . c om*/ protected void buildBoardClip() { if (boardClip == null) { boardClip = new Area(); for (Board b : map.getBoards()) { String boardName = b.getName(); boolean doShade = false; if (boardSelection.equals(ALL_BOARDS)) { doShade = true; } else if (boardSelection.equals(EXC_BOARDS)) { doShade = true; for (int i = 0; i < boardList.length && doShade; i++) { doShade = !boardList[i].equals(boardName); } } else if (boardSelection.equals(INC_BOARDS)) { for (int i = 0; i < boardList.length && !doShade; i++) { doShade = boardList[i].equals(boardName); } } if (doShade) { boardClip.add(new Area(b.bounds())); } } } }
From source file:tilt.image.page.Line.java
/** * Get the overall bounding box of this line based on its shapes * @return a rectangle//from w w w . j a v a 2 s . c om */ public Rectangle getShapesBounds() { Area region = new Area(); for (int i = 0; i < shapes.size(); i++) { Polygon shape = shapes.get(i); region.add(new Area(shape)); } return region.getBounds(); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.PlotInstanceLegendCreator.java
/** * Creates a continuous legend item for one item in dimensionSet, i.e. dimensionSet must be a * set containing exactly one value./*from w ww . j a v a 2 s. c o m*/ * * @param dateFormat * format used to format minValue and maxValue as dates, or null if they should be * displayed numerically instead of as dates * @throws ChartPlottimeException */ private LegendItem createContinuousLegendItem(PlotInstance plotInstance, Set<PlotDimension> dimensionSet, double minValue, double maxValue, DateFormat dateFormat) { PlotConfiguration plotConfiguration = plotInstance.getCurrentPlotConfigurationClone(); PlotDimension dimension = dimensionSet.iterator().next(); DefaultDimensionConfig dimensionConfig = (DefaultDimensionConfig) plotConfiguration .getDimensionConfig(dimension); DimensionConfigData dimensionConfigData = plotInstance.getPlotData() .getDimensionConfigData(dimensionConfig); // String label = dimensionConfig.getLabel(); // if(label == null) { // label = I18N.getGUILabel("plotter.unnamed_value_label"); // } String label = ""; if (dimension == PlotDimension.COLOR) { ColorProvider colorProvider = dimensionConfigData.getColorProvider(); if (!colorProvider.supportsNumericalValues()) { throw new RuntimeException( "Color provider for continuous legend item does not support numerical values."); } // shape dimensions final int width = 50; final int height = 10; // create item paint // first disable logarithmic scale on color provider ( -> linear gradient in legend) // ContinuousColorProvider continuousColorProvider = null; // if (dimensionConfig.isLogarithmic() && colorProvider instanceof // ContinuousColorProvider) { // continuousColorProvider = (ContinuousColorProvider)colorProvider; // continuousColorProvider.setLogarithmic(false); // } // calculate gradient float fractions[] = new float[width]; Color colors[] = new Color[width]; for (int i = 0; i < width; ++i) { float fraction = i / (width - 1.0f); double fractionValue; if (colorProvider instanceof ContinuousColorProvider && ((ContinuousColorProvider) colorProvider).isColorMinMaxValueDifferentFromOriginal( ((ContinuousColorProvider) colorProvider).getMinValue(), ((ContinuousColorProvider) colorProvider).getMaxValue())) { fractionValue = ((ContinuousColorProvider) colorProvider).getMinValue() + fraction * (((ContinuousColorProvider) colorProvider).getMaxValue() - ((ContinuousColorProvider) colorProvider).getMinValue()); } else { fractionValue = minValue + fraction * (maxValue - minValue); } colors[i] = colorProvider.getColorForValue(fractionValue); fractions[i] = fraction; } LinearGradientPaint shapeFillPaint = new LinearGradientPaint(new Point(0, 0), new Point(width, 0), fractions, colors, CycleMethod.REPEAT); // reset color provider to logarithmic if necessary // if (continuousColorProvider != null && dimensionConfig.isLogarithmic()) { // continuousColorProvider.setLogarithmic(true); // } // create item shape Rectangle itemShape = new Rectangle(width, height); if (colorProvider instanceof ContinuousColorProvider) { return createFlankedShapeLegendItem(label, ((ContinuousColorProvider) colorProvider).getMinValue(), ((ContinuousColorProvider) colorProvider).getMaxValue(), itemShape, shapeFillPaint, true, dateFormat); } else { return createFlankedShapeLegendItem(label, minValue, maxValue, itemShape, shapeFillPaint, true, dateFormat); } } else if (dimension == PlotDimension.SHAPE) { // shape provider probably never supports numerical values return null; } else if (dimension == PlotDimension.SIZE) { SizeProvider sizeProvider = dimensionConfigData.getSizeProvider(); if (!sizeProvider.supportsNumericalValues()) { throw new RuntimeException( "Size provider for continuous legend item does not support numerical values."); } double minScalingFactor = sizeProvider.getMinScalingFactor(); double maxScalingFactor = sizeProvider.getMaxScalingFactor(); ContinuousSizeProvider legendSizeProvider = new ContinuousSizeProvider(minScalingFactor, maxScalingFactor, MIN_LEGEND_ITEM_SCALING_FACTOR, MAX_LEGEND_ITEM_SCALING_FACTOR, false); int legendItemCount = 4; Area composedShape = new Area(); Shape originalShape = UNDEFINED_SHAPE; if (dimensionSet.contains(PlotDimension.SIZE) && dimensionSet.size() == 1) { originalShape = UNDEFINED_SHAPE_AND_COLOR; } double maxHeight = originalShape.getBounds().getHeight() * MAX_LEGEND_ITEM_SCALING_FACTOR; for (int i = 0; i < legendItemCount; ++i) { double fraction = minScalingFactor + ((double) i / legendItemCount * (maxScalingFactor - minScalingFactor)); double legendScalingFactor = legendSizeProvider.getScalingFactorForValue(fraction); double composedWidth = composedShape.getBounds().getWidth(); AffineTransform t = new AffineTransform(); t.scale(legendScalingFactor, legendScalingFactor); Shape shape = t.createTransformedShape(originalShape); t = new AffineTransform(); double shapeWidth = shape.getBounds().getWidth(); double shapeHeight = shape.getBounds().getHeight(); t.translate(composedWidth + shapeWidth * .1, (maxHeight - shapeHeight) / 2.0); t.translate(-shape.getBounds().getMinX(), -shape.getBounds().getMinY()); shape = t.createTransformedShape(shape); composedShape.add(new Area(shape)); } return createFlankedShapeLegendItem(label, minValue, maxValue, composedShape, UNDEFINED_COLOR_PAINT, false, dateFormat); } else { throw new RuntimeException("Unsupported dimension. Execution path should never reach this line."); } }