diff --git a/app/src/processing/app/contrib/ManagerTabs.java b/app/src/processing/app/contrib/ManagerTabs.java index 571a059c7..5913f93c7 100644 --- a/app/src/processing/app/contrib/ManagerTabs.java +++ b/app/src/processing/app/contrib/ManagerTabs.java @@ -81,10 +81,6 @@ public class ManagerTabs extends Box { Font font; int fontAscent; - Image offscreen; - int sizeW, sizeH; - int imageW, imageH; - Image gradient; JPanel cardPanel; @@ -193,33 +189,10 @@ public class ManagerTabs extends Box { }); } - public void paintComponent(Graphics screen) { - if (screen == null) return; - Dimension size = getSize(); - if ((size.width != sizeW) || (size.height != sizeH)) { - // component has been resized + public void paintComponent(Graphics g) { + if (g == null) return; - if ((size.width > imageW) || (size.height > imageH)) { - // nix the image and recreate, it's too small - offscreen = null; - - } else { - // if the image is larger than necessary, no need to change - sizeW = size.width; - sizeH = size.height; - } - } - - if (offscreen == null) { - sizeW = size.width; - sizeH = size.height; - imageW = sizeW; - imageH = sizeH; - offscreen = Toolkit.offscreenGraphics(this, imageW, imageH); - } - - Graphics g = offscreen.getGraphics(); g.setFont(font); // need to set this each time through if (fontAscent == 0) { fontAscent = (int) Toolkit.getAscent(g); @@ -227,12 +200,12 @@ public class ManagerTabs extends Box { Graphics2D g2 = Toolkit.prepareGraphics(g); - g.drawImage(gradient, 0, 0, imageW, imageH, this); + g.drawImage(gradient, 0, 0, getWidth(), getHeight(), this); g.setColor(tabColor[SELECTED]); // draw the two pixel line that extends left/right below the tabs // can't be done with lines, b/c retina leaves tiny hairlines - g.fillRect(0, TAB_BOTTOM, imageW, Toolkit.zoom(2)); + g.fillRect(0, TAB_BOTTOM, getWidth(), Toolkit.zoom(2)); // reset all tab positions for (Tab tab : tabList) { @@ -243,14 +216,11 @@ public class ManagerTabs extends Box { placeTabs(0); // now actually draw the tabs drawTabs(g2); - - screen.drawImage(offscreen, 0, 0, imageW, imageH, null); } /** * @param left starting position from the left - * @param g graphics context, or null if we're not drawing */ private void placeTabs(int left) { //, Graphics2D g) { int x = left; diff --git a/app/src/processing/app/ui/EditorFooter.java b/app/src/processing/app/ui/EditorFooter.java index 4f125d383..7b858e739 100644 --- a/app/src/processing/app/ui/EditorFooter.java +++ b/app/src/processing/app/ui/EditorFooter.java @@ -79,10 +79,6 @@ public class EditorFooter extends Box { Font font; int fontAscent; - Image offscreen; - int sizeW, sizeH; - int imageW, imageH; - Image gradient; Color bgColor; @@ -216,35 +212,11 @@ public class EditorFooter extends Box { repaint(); } - public void paintComponent(Graphics screen) { - if (screen == null) return; + public void paintComponent(Graphics g) { + if (g == null) return; Sketch sketch = editor.getSketch(); if (sketch == null) return; // possible? - Dimension size = getSize(); - if ((size.width != sizeW) || (size.height != sizeH)) { - // component has been resized - - if ((size.width > imageW) || (size.height > imageH)) { - // nix the image and recreate, it's too small - offscreen = null; - - } else { - // if the image is larger than necessary, no need to change - sizeW = size.width; - sizeH = size.height; - } - } - - if (offscreen == null) { - sizeW = size.width; - sizeH = size.height; - imageW = sizeW; - imageH = sizeH; - offscreen = Toolkit.offscreenGraphics(this, imageW, imageH); - } - - Graphics g = offscreen.getGraphics(); g.setFont(font); // need to set this each time through if (fontAscent == 0) { fontAscent = (int) Toolkit.getAscent(g); @@ -254,9 +226,9 @@ public class EditorFooter extends Box { g.setColor(tabColor[SELECTED]); // can't be done with lines, b/c retina leaves tiny hairlines - g.fillRect(0, 0, imageW, Toolkit.zoom(2)); + g.fillRect(0, 0, getWidth(), Toolkit.zoom(2)); - g.drawImage(gradient, 0, Toolkit.zoom(2), imageW, imageH, this); + g.drawImage(gradient, 0, Toolkit.zoom(2), getWidth(), getHeight(), this); // reset all tab positions for (Tab tab : tabs) { @@ -269,8 +241,6 @@ public class EditorFooter extends Box { // the number of updates available in the Manager drawUpdates(g2); - - screen.drawImage(offscreen, 0, 0, imageW, imageH, null); } diff --git a/app/src/processing/app/ui/EditorStatus.java b/app/src/processing/app/ui/EditorStatus.java index 301daeb6a..49a0cfdc5 100644 --- a/app/src/processing/app/ui/EditorStatus.java +++ b/app/src/processing/app/ui/EditorStatus.java @@ -112,7 +112,7 @@ public class EditorStatus extends BasicSplitPaneDivider { // a font that supports the Unicode glyphs we need Font glyphFont; - Image offscreen; +// Image offscreen; int sizeW, sizeH; // size of the glyph buttons (width and height are identical) int buttonSize; @@ -329,7 +329,9 @@ public class EditorStatus extends BasicSplitPaneDivider { } - //public void paintComponent(Graphics screen) { + //public void paintComponent(Graphics g) { + public void paint(Graphics g) { + /* public void paint(Graphics screen) { Dimension size = getSize(); if ((size.width != sizeW) || (size.height != sizeH)) { @@ -345,7 +347,11 @@ public class EditorStatus extends BasicSplitPaneDivider { } Graphics g = offscreen.getGraphics(); - /*Graphics2D g2 =*/ Toolkit.prepareGraphics(g); + Toolkit.prepareGraphics(g); + */ + sizeW = getWidth(); + sizeH = getHeight(); + buttonSize = sizeH; g.setFont(font); if (metrics == null) { @@ -410,7 +416,7 @@ public class EditorStatus extends BasicSplitPaneDivider { String collapseGlyph = collapsed ? EXPAND_GLYPH : COLLAPSE_GLYPH; drawButton(g, collapseGlyph, 0, rolloverState == ROLLOVER_COLLAPSE); - screen.drawImage(offscreen, 0, 0, sizeW, sizeH, null); + //screen.drawImage(offscreen, 0, 0, sizeW, sizeH, null); } diff --git a/app/src/processing/app/ui/ModeSelector.java b/app/src/processing/app/ui/ModeSelector.java index d108fe2e7..b3f67fd6e 100644 --- a/app/src/processing/app/ui/ModeSelector.java +++ b/app/src/processing/app/ui/ModeSelector.java @@ -23,32 +23,34 @@ package processing.app.ui; -import processing.app.Messages; - -import javax.swing.*; -import java.awt.*; +import java.awt.Font; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import javax.swing.*; + +import processing.app.Messages; public class ModeSelector extends JPanel { // corner radius for the dropdown static final int RADIUS = Toolkit.zoom(3); - Image offscreen; - int width, height; - String title; Font titleFont; Color titleColor; int titleAscent; int titleWidth; - final int MODE_GAP_WIDTH = processing.app.ui.Toolkit.zoom(13); - final int ARROW_GAP_WIDTH = processing.app.ui.Toolkit.zoom(6); - final int ARROW_WIDTH = processing.app.ui.Toolkit.zoom(6); - final int ARROW_TOP = processing.app.ui.Toolkit.zoom(12); - final int ARROW_BOTTOM = processing.app.ui.Toolkit.zoom(18); + final int MODE_GAP_WIDTH = Toolkit.zoom(13); + final int ARROW_GAP_WIDTH = Toolkit.zoom(6); + final int ARROW_WIDTH = Toolkit.zoom(6); + final int ARROW_TOP = Toolkit.zoom(12); + final int ARROW_BOTTOM = Toolkit.zoom(18); int[] triangleX = new int[3]; int[] triangleY = new int[] { ARROW_TOP, ARROW_TOP, ARROW_BOTTOM }; @@ -82,17 +84,8 @@ public class ModeSelector extends JPanel { } @Override - public void paintComponent(Graphics screen) { - Dimension size = getSize(); - width = 0; - if (width != size.width || height != size.height) { - offscreen = processing.app.ui.Toolkit.offscreenGraphics(this, size.width, size.height); - width = size.width; - height = size.height; - } - - Graphics g = offscreen.getGraphics(); - Graphics2D g2 = processing.app.ui.Toolkit.prepareGraphics(g); + public void paintComponent(Graphics g) { + Graphics2D g2 = Toolkit.prepareGraphics(g); g.setFont(titleFont); if (titleAscent == 0) { @@ -101,6 +94,9 @@ public class ModeSelector extends JPanel { FontMetrics metrics = g.getFontMetrics(); titleWidth = metrics.stringWidth(title); + final int width = getWidth(); + final int height = getHeight(); + // clear the background g.setColor(backgroundColor); g.fillRect(0, 0, width, height); @@ -119,8 +115,6 @@ public class ModeSelector extends JPanel { triangleX[1] = x + ARROW_WIDTH; triangleX[2] = x + ARROW_WIDTH/2; g.fillPolygon(triangleX, triangleY, 3); - - screen.drawImage(offscreen, 0, 0, width, height, this); } @Override diff --git a/app/src/processing/app/ui/Toolkit.java b/app/src/processing/app/ui/Toolkit.java index cc577a020..5e21f572d 100644 --- a/app/src/processing/app/ui/Toolkit.java +++ b/app/src/processing/app/ui/Toolkit.java @@ -808,9 +808,8 @@ public class Toolkit { } - // TODO remove this one? static public Graphics2D prepareGraphics(Graphics g) { - return prepareGraphics(g, true); + return prepareGraphics(g, false); }