List of usage examples for java.awt TexturePaint TexturePaint
public TexturePaint(BufferedImage txtr, Rectangle2D anchor)
From source file:de.tor.tribes.ui.views.DSWorkbenchConquersFrame.java
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("Find")) { BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT); Graphics g = back.getGraphics(); g.setColor(new Color(120, 120, 120, 120)); g.fillRect(0, 0, back.getWidth(), back.getHeight()); g.setColor(new Color(120, 120, 120)); g.drawLine(0, 0, 3, 3);/*from w w w . ja va 2 s. c om*/ g.dispose(); TexturePaint paint = new TexturePaint(back, new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight())); jxFilterPane.setBackgroundPainter(new MattePainter(paint)); DefaultListModel model = new DefaultListModel(); for (int i = 0; i < jConquersTable.getColumnCount(); i++) { TableColumnExt col = jConquersTable.getColumnExt(i); if (col.isVisible() && !col.getTitle().equals("Entfernung") && !col.getTitle().equals("Dorfpunkte")) { model.addElement(col.getTitle()); } } jXColumnList.setModel(model); jXColumnList.setSelectedIndex(0); jxFilterPane.setVisible(true); } }
From source file:TexturedText.java
/** Construct the object */ public TexturedText() { super();/* w ww. j a va2 s. c o m*/ setBackground(Color.white); int width = 8, height = 8; bim = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = bim.createGraphics(); for (int i = 0; i < width; i++) { g2.setPaint(colors[(i / 2) % colors.length]); g2.drawLine(0, i, i, 0); g2.drawLine(width - i, height, width, height - i); } Rectangle r = new Rectangle(0, 0, bim.getWidth(), bim.getHeight()); tp = new TexturePaint(bim, r); }
From source file:de.tor.tribes.ui.views.DSWorkbenchNotepad.java
@Override public void actionPerformed(ActionEvent e) { NoteTableTab activeTab = getActiveTab(); if (e.getActionCommand() != null && activeTab != null) { if (e.getActionCommand().equals("Copy")) { activeTab.transferSelection(NoteTableTab.TRANSFER_TYPE.COPY_TO_INTERNAL_CLIPBOARD); } else if (e.getActionCommand().equals("BBCopy")) { activeTab.transferSelection(NoteTableTab.TRANSFER_TYPE.CLIPBOARD_BB); } else if (e.getActionCommand().equals("BBCopy_Village")) { activeTab.copyVillagesAsBBCodes(); } else if (e.getActionCommand().equals("Cut")) { activeTab.transferSelection(NoteTableTab.TRANSFER_TYPE.CUT_TO_INTERNAL_CLIPBOARD); } else if (e.getActionCommand().equals("Paste")) { activeTab.transferSelection(NoteTableTab.TRANSFER_TYPE.FROM_INTERNAL_CLIPBOARD); } else if (e.getActionCommand().equals("Delete")) { activeTab.deleteSelection(true); } else if (e.getActionCommand().equals("Delete_Village")) { activeTab.deleteVillagesFromNotes(); } else if (e.getActionCommand().equals("Find")) { BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT); Graphics g = back.getGraphics(); g.setColor(new Color(120, 120, 120, 120)); g.fillRect(0, 0, back.getWidth(), back.getHeight()); g.setColor(new Color(120, 120, 120)); g.drawLine(0, 0, 3, 3);// w w w .j ava 2s .c o m g.dispose(); TexturePaint paint = new TexturePaint(back, new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight())); jxSearchPane.setBackgroundPainter(new MattePainter(paint)); jxSearchPane.setVisible(true); } } }
From source file:ImageBorderHack.java
public void fillTexture(Graphics2D g2, Image img, int x, int y, int w, int h) { BufferedImage buff = createBufferedImage(img); Rectangle anchor = new Rectangle(x, y, img.getWidth(null), img.getHeight(null)); TexturePaint paint = new TexturePaint(buff, anchor); g2.setPaint(paint);/*from ww w .java2 s. c om*/ g2.fillRect(x, y, w, h); }
From source file:de.tor.tribes.ui.views.DSWorkbenchTroopsFrame.java
@Override public void actionPerformed(ActionEvent e) { TroopTableTab activeTab = getActiveTab(); if (e.getActionCommand().equals("Delete")) { if (activeTab != null) { activeTab.deleteSelection(); }// w ww .j a v a 2 s. c om } else if (e.getActionCommand().equals("BBCopy")) { if (activeTab != null) { activeTab.transferSelection(TroopTableTab.TRANSFER_TYPE.CLIPBOARD_BB); } } else if (e.getActionCommand().equals("Find")) { BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT); Graphics g = back.getGraphics(); g.setColor(new Color(120, 120, 120, 120)); g.fillRect(0, 0, back.getWidth(), back.getHeight()); g.setColor(new Color(120, 120, 120)); g.drawLine(0, 0, 3, 3); g.dispose(); TexturePaint paint = new TexturePaint(back, new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight())); jxSearchPane.setBackgroundPainter(new MattePainter(paint)); updateTagList(); jxSearchPane.setVisible(true); } else if (e.getActionCommand() != null && activeTab != null) { if (e.getActionCommand().equals("SelectionDone")) { activeTab.updateSelectionInfo(); } } }
From source file:de.tor.tribes.ui.views.DSWorkbenchReportFrame.java
@Override public void actionPerformed(ActionEvent e) { ReportTableTab activeTab = getActiveTab(); if (e.getActionCommand() != null && activeTab != null) { if (e.getActionCommand().equals("Copy")) { activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.COPY_TO_INTERNAL_CLIPBOARD); } else if (e.getActionCommand().equals("BBCopy")) { activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.CLIPBOARD_BB); } else if (e.getActionCommand().equals("Cut")) { activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.CUT_TO_INTERNAL_CLIPBOARD); } else if (e.getActionCommand().equals("Paste")) { activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.FROM_INTERNAL_CLIPBOARD); } else if (e.getActionCommand().equals("Delete")) { activeTab.deleteSelection(true); } else if (e.getActionCommand().equals("Find")) { BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT); Graphics g = back.getGraphics(); g.setColor(new Color(120, 120, 120, 120)); g.fillRect(0, 0, back.getWidth(), back.getHeight()); g.setColor(new Color(120, 120, 120)); g.drawLine(0, 0, 3, 3);//from ww w . jav a2s . c o m g.dispose(); TexturePaint paint = new TexturePaint(back, new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight())); jxSearchPane.setBackgroundPainter(new MattePainter(paint)); DefaultListModel model = new DefaultListModel(); for (int i = 0; i < activeTab.getReportTable().getColumnCount(); i++) { TableColumnExt col = activeTab.getReportTable().getColumnExt(i); if (col.isVisible()) { if (!col.getTitle().equals("Status") && !col.getTitle().equals("Typ") && !col.getTitle().equals("Sonstiges")) { model.addElement(col.getTitle()); } } } jXColumnList.setModel(model); jXColumnList.setSelectedIndex(0); jxSearchPane.setVisible(true); } } }
From source file:br.ufrgs.enq.jcosmo.ui.SigmaProfileAreaPanel.java
public void addProfile(String label, double[] sigma, double[] area, int rgb) { int n = sigma.length; XYSeries comp = new XYSeries(label, false, false); // charges represent the center of the segments comp.add(sigma[0], area[0]);//from w w w. j a va 2s . c om for (int j = 1; j < n; ++j) { double dsigma = (sigma[j] - sigma[j - 1]) / 2; comp.add(sigma[j] - dsigma, area[j]); comp.add(sigma[j] + dsigma + 1e-6, area[j]); } dataset.addSeries(comp); int series = dataset.getSeriesCount() - 1; int patternSize = 6; BufferedImage bi = new BufferedImage(patternSize, patternSize, BufferedImage.TYPE_INT_RGB); Rectangle r = new Rectangle(0, 0, patternSize, patternSize); Graphics2D big = bi.createGraphics(); big.setColor(new Color(rgb, rgb, rgb)); big.fillRect(0, 0, patternSize, patternSize); int pattern = series % 4; if (pattern == 1 || pattern == 3) { big.setColor(Color.WHITE); big.drawLine(0, patternSize / 2, patternSize, patternSize / 2); } if (pattern == 2 || pattern == 3) { big.setColor(Color.WHITE); big.drawLine(patternSize / 2, 0, patternSize / 2, patternSize); } TexturePaint paint = new TexturePaint(bi, r); sigmaProfilePlot.getRenderer().setSeriesPaint(series, paint); // new Color(rgb, rgb, rgb)); }
From source file:de.tor.tribes.ui.views.DSWorkbenchAttackFrame.java
@Override public void actionPerformed(ActionEvent e) { AttackTableTab activeTab = getActiveTab(); int idx = jAttackTabPane.getSelectedIndex(); if (e.getActionCommand() != null && activeTab != null) { if (e.getActionCommand().equals("TimeChange")) { activeTab.fireChangeTimeEvent(); } else if (e.getActionCommand().equals("UnitChange")) { activeTab.fireChangeUnitEvent(); } else if (e.getActionCommand().equals("Recolor")) { activeTab.updateSortHighlighter(); } else if (e.getActionCommand().equals("ExportScript")) { activeTab.fireExportScriptEvent(); } else if (e.getActionCommand().equals("Copy")) { activeTab.transferSelection(AttackTableTab.TRANSFER_TYPE.COPY_TO_INTERNAL_CLIPBOARD); } else if (e.getActionCommand().equals("BBCopy")) { activeTab.transferSelection(AttackTableTab.TRANSFER_TYPE.CLIPBOARD_BB); } else if (e.getActionCommand().equals("Cut")) { activeTab.transferSelection(AttackTableTab.TRANSFER_TYPE.CUT_TO_INTERNAL_CLIPBOARD); jAttackTabPane.setSelectedIndex(idx); } else if (e.getActionCommand().equals("Paste")) { activeTab.transferSelection(AttackTableTab.TRANSFER_TYPE.FROM_INTERNAL_CLIPBOARD); jAttackTabPane.setSelectedIndex(idx); } else if (e.getActionCommand().equals("Delete")) { activeTab.deleteSelection(true); } else if (e.getActionCommand().equals("Find")) { BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT); Graphics g = back.getGraphics(); g.setColor(new Color(120, 120, 120, 120)); g.fillRect(0, 0, back.getWidth(), back.getHeight()); g.setColor(new Color(120, 120, 120)); g.drawLine(0, 0, 3, 3);/* w ww . jav a 2 s . c o m*/ g.dispose(); TexturePaint paint = new TexturePaint(back, new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight())); jxSearchPane.setBackgroundPainter(new MattePainter(paint)); DefaultListModel model = new DefaultListModel(); for (int i = 0; i < activeTab.getAttackTable().getColumnCount(); i++) { TableColumnExt col = activeTab.getAttackTable().getColumnExt(i); if (col.isVisible()) { if (!col.getTitle().equals("Einheit") && !col.getTitle().equals("Typ") && !col.getTitle().equals("Sonstiges") && !col.getTitle().equals("Abschickzeit") && !col.getTitle().equals("Ankunftzeit") && !col.getTitle().equals("Verbleibend")) { model.addElement(col.getTitle()); } } } jXColumnList.setModel(model); jXColumnList.setSelectedIndex(0); jxSearchPane.setVisible(true); } } }
From source file:Paints.java
/** Draw the example */ public void paint(Graphics g1) { Graphics2D g = (Graphics2D) g1; // Paint the entire background using a GradientPaint. // The background color varies diagonally from deep red to pale blue g.setPaint(new GradientPaint(0, 0, new Color(150, 0, 0), WIDTH, HEIGHT, new Color(200, 200, 255))); g.fillRect(0, 0, WIDTH, HEIGHT); // fill the background // Use a different GradientPaint to draw a box. // This one alternates between deep opaque green and transparent green. // Note: the 4th arg to Color() constructor specifies color opacity g.setPaint(new GradientPaint(0, 0, new Color(0, 150, 0), 20, 20, new Color(0, 150, 0, 0), true)); g.setStroke(new BasicStroke(15)); // use wide lines g.drawRect(25, 25, WIDTH - 50, HEIGHT - 50); // draw the box // The glyphs of fonts can be used as Shape objects, which enables // us to use Java2D techniques with letters Just as we would with // any other shape. Here we get some letter shapes to draw. Font font = new Font("Serif", Font.BOLD, 10); // a basic font Font bigfont = // a scaled up version font.deriveFont(AffineTransform.getScaleInstance(30.0, 30.0)); GlyphVector gv = bigfont.createGlyphVector(g.getFontRenderContext(), "JAV"); Shape jshape = gv.getGlyphOutline(0); // Shape of letter J Shape ashape = gv.getGlyphOutline(1); // Shape of letter A Shape vshape = gv.getGlyphOutline(2); // Shape of letter V // We're going to outline the letters with a 5-pixel wide line g.setStroke(new BasicStroke(5.0f)); // We're going to fake shadows for the letters using the // following Paint and AffineTransform objects Paint shadowPaint = new Color(0, 0, 0, 100); // Translucent black AffineTransform shadowTransform = AffineTransform.getShearInstance(-1.0, 0.0); // Shear to the right shadowTransform.scale(1.0, 0.5); // Scale height by 1/2 // Move to the baseline of our first letter g.translate(65, 270);//from ww w . j a v a 2 s . c o m // Draw the shadow of the J shape g.setPaint(shadowPaint); g.translate(15, 20); // Compensate for the descender of the J // transform the J into the shape of its shadow, and fill it g.fill(shadowTransform.createTransformedShape(jshape)); g.translate(-15, -20); // Undo the translation above // Now fill the J shape with a solid (and opaque) color g.setPaint(Color.blue); // Fill with solid, opaque blue g.fill(jshape); // Fill the shape g.setPaint(Color.black); // Switch to solid black g.draw(jshape); // And draw the outline of the J // Now draw the A shadow g.translate(75, 0); // Move to the right g.setPaint(shadowPaint); // Set shadow color g.fill(shadowTransform.createTransformedShape(ashape)); // draw shadow // Draw the A shape using a solid transparent color g.setPaint(new Color(0, 255, 0, 125)); // Transparent green as paint g.fill(ashape); // Fill the shape g.setPaint(Color.black); // Switch to solid back g.draw(ashape); // Draw the outline // Move to the right and draw the shadow of the letter V g.translate(175, 0); g.setPaint(shadowPaint); g.fill(shadowTransform.createTransformedShape(vshape)); // We're going to fill the next letter using a TexturePaint, which // repeatedly tiles an image. The first step is to obtain the image. // We could load it from an image file, but here we create it // ourselves by drawing a into an off-screen image. Note that we use // a GradientPaint to fill the off-screen image, so the fill pattern // combines features of both Paint classes. BufferedImage tile = // Create an image new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB); Graphics2D tg = tile.createGraphics(); // Get its Graphics for drawing tg.setColor(Color.pink); tg.fillRect(0, 0, 50, 50); // Fill tile background with pink tg.setPaint(new GradientPaint(40, 0, Color.green, // diagonal gradient 0, 40, Color.gray)); // green to gray tg.fillOval(5, 5, 40, 40); // Draw a circle with this gradient // Use this new tile to create a TexturePaint and fill the letter V g.setPaint(new TexturePaint(tile, new Rectangle(0, 0, 50, 50))); g.fill(vshape); // Fill letter shape g.setPaint(Color.black); // Switch to solid black g.draw(vshape); // Draw outline of letter // Move to the right and draw the shadow of the final A g.translate(160, 0); g.setPaint(shadowPaint); g.fill(shadowTransform.createTransformedShape(ashape)); g.fill(ashape); // Fill letter A g.setPaint(Color.black); // Revert to solid black g.draw(ashape); // Draw the outline of the A }
From source file:TexturedPanel.java
/** * Creates a new TexturePaint using the provided colors. *///from ww w .jav a 2s. com private void setupDefaultPainter(Color foreground, Color background) { if (foreground == null || background == null) { ourPainter = null; return; } BufferedImage buff = new BufferedImage(6, 6, BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g2 = buff.createGraphics(); g2.setColor(background); g2.fillRect(0, 0, 6, 6); g2.setColor(foreground); g2.drawLine(0, 2, 6, 2); g2.drawLine(0, 5, 6, 5); ourPainter = new TexturePaint(buff, new Rectangle(0, 0, 6, 6)); g2.dispose(); }