List of usage examples for java.awt RenderingHints KEY_ANTIALIASING
Key KEY_ANTIALIASING
To view the source code for java.awt RenderingHints KEY_ANTIALIASING.
Click Source Link
From source file:TransformTranslation.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);//from w w w . j av a2s .c om // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. g2.transform(AffineTransform.getTranslateInstance(150, 0)); // Draw the "new" shapes in dashed. Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:TransformersRotation.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);//from w w w . ja va 2 s. c o m // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. g2.transform(AffineTransform.getRotateInstance(-Math.PI / 6)); // Draw the "new" shapes in dashed. Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:org.openimaj.demos.sandbox.flickr.geo.PlotFlickrGeo.java
public static void main(String[] args) throws IOException { final File inputcsv = new File("/Volumes/SSD/training_latlng"); final List<double[]> data = new ArrayList<double[]>(10000000); // read in images final BufferedReader br = new BufferedReader(new FileReader(inputcsv)); String line;//from ww w. j a va2 s . c o m int i = 0; br.readLine(); while ((line = br.readLine()) != null) { final String[] parts = line.split(" "); final double longitude = Double.parseDouble(parts[2]); final double latitude = Double.parseDouble(parts[1]); data.add(new double[] { longitude, latitude }); if (longitude >= -0.1 && longitude < 0 && latitude > 50 && latitude < 54) System.out.println(parts[0] + " " + latitude + " " + longitude); // if (i++ % 10000 == 0) // System.out.println(i); } br.close(); System.out.println("Done reading"); final float[][] dataArr = new float[2][data.size()]; for (i = 0; i < data.size(); i++) { dataArr[0][i] = (float) data.get(i)[0]; dataArr[1][i] = (float) data.get(i)[1]; } final NumberAxis domainAxis = new NumberAxis("X"); domainAxis.setRange(-180, 180); final NumberAxis rangeAxis = new NumberAxis("Y"); rangeAxis.setRange(-90, 90); final FastScatterPlot plot = new FastScatterPlot(dataArr, domainAxis, rangeAxis); final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); final ApplicationFrame frame = new ApplicationFrame("Title"); frame.setContentPane(chartPanel); frame.pack(); frame.setVisible(true); }
From source file:TransformTransRotation.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);/*from www.j a va 2s . c o m*/ // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. AffineTransform rat = new AffineTransform(); rat.setToTranslation(100, 0); rat.rotate(Math.PI / 6); g2.transform(rat); // Draw the "new" shapes in dashed. Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:TransformTranslatedRotation.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);/*from w w w. j a v a2 s . c o m*/ // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. float cm = 72 / 2.54f; g2.transform(AffineTransform.getRotateInstance(-Math.PI / 6, 3 * cm, 2 * cm)); // Draw the "new" shapes in dashed. Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:TransformersRotationTranslation.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);/*from w w w .j ava 2 s. c om*/ // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. AffineTransform rat = new AffineTransform(); rat.setToRotation(Math.PI / 6); rat.translate(100, 100); g2.transform(rat); // Draw the "new" shapes in dashed. Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:no.met.jtimeseries.chart.XYCloudSymbolRenderer.java
/** * Creates a new renderer./*from w w w. jav a 2 s . com*/ * @param numTimeSteps The number of total timesteps in the domain range. Used in the calculation of symbol width * @param numTimeStepsPerCloud The number of timesteps a cloudsymbol covers. Used in calculation of symbol width */ public XYCloudSymbolRenderer(int numTimeSteps) { super(); renderHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); renderHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); this.numTimeSteps = numTimeSteps; }
From source file:LineStyles.java
/** This method draws the example figure */ public void paint(Graphics g1) { Graphics2D g = (Graphics2D) g1; // Use anti-aliasing to avoid "jaggies" in the lines g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Define the shape to draw GeneralPath shape = new GeneralPath(); shape.moveTo(xpoints[0], ypoints[0]); // start at point 0 shape.lineTo(xpoints[1], ypoints[1]); // draw a line to point 1 shape.lineTo(xpoints[2], ypoints[2]); // and then on to point 2 // Move the origin to the right and down, creating a margin g.translate(20, 40);/*from www. jav a2s. c o m*/ // Now loop, drawing our shape with the three different line styles for (int i = 0; i < linestyles.length; i++) { g.setColor(Color.gray); // Draw a gray line g.setStroke(linestyles[i]); // Select the line style to use g.draw(shape); // Draw the shape g.setColor(Color.black); // Now use black g.setStroke(thindashed); // And the thin dashed line g.draw(shape); // And draw the shape again. // Highlight the location of the vertexes of the shape // This accentuates the cap and join styles we're demonstrating for (int j = 0; j < xpoints.length; j++) g.fillRect(xpoints[j] - 2, ypoints[j] - 2, 5, 5); g.drawString(capNames[i], 5, 105); // Label the cap style g.drawString(joinNames[i], 5, 120); // Label the join style g.translate(150, 0); // Move over to the right before looping again } }
From source file:DrawingApplet.java
public void init() { // Find out how big the applet is and create an offscreen image // that size. int w = getWidth(); int h = getHeight(); image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); // Get a graphics context for drawing into the image g = image.createGraphics();/*from w w w . j a va 2 s .c o m*/ // Start with a pure white background g.setPaint(Color.WHITE); g.fillRect(0, 0, w, h); // Turn on antialiasing g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); try { // sleep here to simulate a long init method Thread.sleep(4000); } catch (InterruptedException ie) { ie.printStackTrace(); } }
From source file:Hypnosis.java
public Hypnosis(double x, double y, double r1, double r2, double a1, double a2, float linewidth, int delay, double deltaA, double deltaX, double deltaY) { this.x = x;/*from w ww .j a v a2 s .c o m*/ this.y = y; this.r1 = r1; this.r2 = r2; this.a1 = a1; this.a2 = a2; this.linewidth = linewidth; this.deltaA = deltaA; this.deltaX = deltaX; this.deltaY = deltaY; // Set up a timer to call actionPerformed() every delay milliseconds timer = new Timer(delay, this); // Create a buffer for double-buffering buffer = new BufferedImage((int) (2 * r2 + linewidth), (int) (2 * r2 + linewidth), BufferedImage.TYPE_INT_RGB); // Create a Graphics object for the buffer, and set the linewidth // and request antialiasing when drawing with it osg = buffer.createGraphics(); osg.setStroke(new BasicStroke(linewidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); osg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); }