You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/02/04 12:10:07 UTC
[GitHub] [netbeans] pedro-w opened a new pull request #1918: Implement
simplified HeapView widget
pedro-w opened a new pull request #1918: Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918
This fixes the appearance of the HeapView widget on HiDPI displays. The widget is much simplified, consisting only of a background, an area chart showing the last 100 samples, and text showing the current used heap / total. No bitmaps are used so DPI issues should not be present. Tested on Windows 10/JDK 11 with 125% scaling factor.
NB11.2:

This PR:

The colours and presence/absence of text are configurable as before.
See bug NETBEANS-3785
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] pedro-w commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
pedro-w commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r374913322
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -465,526 +225,174 @@ private void updateTextWidth() {
*
* @param e the MouseEvent
*/
- @Override protected void processMouseEvent(MouseEvent e) {
+ @Override
+ protected void processMouseEvent(MouseEvent e) {
super.processMouseEvent(e);
if (!e.isConsumed()) {
if (e.isPopupTrigger()) {
// Show a popup allowing to configure the various options
showPopup(e.getX(), e.getY());
- } else if (e.getID() == MouseEvent.MOUSE_ENTERED) {
- containsMouse = true;
- cachedBorderVaild = false;
- repaint();
- } else if (e.getID() == MouseEvent.MOUSE_EXITED) {
- containsMouse = false;
- cachedBorderVaild = false;
- repaint();
}
+ }
- }
-
- if (e.getID() == MouseEvent.MOUSE_CLICKED &&
- SwingUtilities.isLeftMouseButton(e) &&
- e.getClickCount() == 1) {
+ if (e.getID() == MouseEvent.MOUSE_CLICKED
+ && SwingUtilities.isLeftMouseButton(e)
+ && e.getClickCount() == 1) {
// Trigger a gc
- GarbageCollectAction.get(GarbageCollectAction.class).performAction();;
+ GarbageCollectAction.get(GarbageCollectAction.class).performAction();
}
}
/**
- * Shows a popup at the specified location that allows you to configure
- * the various options.
+ * Shows a popup at the specified location that allows you to configure the
+ * various options.
*/
private void showPopup(int x, int y) {
JPopupMenu popup = new JPopupMenu();
JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_ShowText"));
cbmi.setSelected(getShowText());
cbmi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- setShowText(((JCheckBoxMenuItem)e.getSource()).
+ setShowText(((JCheckBoxMenuItem) e.getSource()).
isSelected());
}
});
popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_DropShadow"));
- cbmi.setSelected(getShowDropShadow());
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setShowDropShadow(((JCheckBoxMenuItem)e.getSource()).
- isSelected());
- }
- });
- popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_OverlayGrid"));
- cbmi.setSelected(getTickStyle() == STYLE_OVERLAY);
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int style = ((JCheckBoxMenuItem)e.getSource()).
- isSelected() ? STYLE_OVERLAY : STYLE_DEFAULT;
- setTickStyle(style);
- }
- });
- popup.add(cbmi);
popup.show(this, x, y);
}
- /**
- * Returns the first index to start rendering from.
- */
- private int getGraphStartIndex() {
- if (graphFilled) {
- return graphIndex;
- } else {
- return 0;
- }
- }
-
/**
* Paints the component.
*/
- @Override protected void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D)g;
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
int width = getWidth();
int height = getHeight();
- if (width - BORDER_W > 0 && height - BORDER_H > 0) {
+
+ if (width > 0 && height > 0) {
startTimerIfNecessary();
- updateCacheIfNecessary(width, height);
- paintCachedBackground(g2, width, height);
- g.translate(1, 2);
- if (containsMouse) {
- g.clipRect(1, 0, width - 4, height - 4);
- }
- else {
- g.clipRect(0, 0, width - 2, height - 4);
- }
- int innerW = width - BORDER_W;
- int innerH = height - BORDER_H;
- if (heapGrowTimer != null) {
- // Render the heap growing animation.
- Composite lastComposite = ((Graphics2D)g).getComposite();
- float percent = 1f - heapGrowTimer.getPercent();
- ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, percent));
- g.drawImage(heapGrowTimer.image, 0, 0, null);
- ((Graphics2D)g).setComposite(lastComposite);
- }
- paintTicks(g2, innerW, innerH);
- if (getTickStyle() == STYLE_OVERLAY) {
- g2.drawImage(getGridOverlayImage(), 0, 0, null);
- }
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ // Fill background
+ g2.setPaint(BACKGROUND_COLOR);
+ g2.fillRect(0, 0, width + 1, height + 1);
+ // Draw samples
+ g2.setPaint(CHART_COLOR);
+ paintSamples(g2, width, height);
+ // Draw text if enabled
if (getShowText()) {
- if (getShowDropShadow()) {
- paintDropShadowText(g, innerW, innerH);
- } else {
- g.setColor(textColor);
- paintText(g, innerW, innerH);
- }
+ paintText(g2, width, height);
}
- g.translate(-1, -2);
} else {
stopTimerIfNecessary();
- // To honor opaque contract, fill in the background
- g.setColor(getBackground());
- g.fillRect(0, 0, width, height);
- }
- }
-
- private void paintTicks(Graphics2D g, int width, int height) {
- if (graphIndex > 0 || graphFilled) {
- int index = getGraphStartIndex();
- int x = 0;
- if (!graphFilled) {
- x = width - graphIndex;
- }
- float[] localGraph = graph;
- if (localGraph == null) {
- return;
- }
- float min = localGraph[index];
- index = (index + 1) % localGraph.length;
- while (index != graphIndex) {
- min = Math.min(min, localGraph[index]);
- index = (index + 1) % localGraph.length;
- }
- int minHeight = (int)(min * (float)height);
- if (minHeight > 0) {
- g.drawImage(tickGradientImage, x, height - minHeight, width, height,
- x, height - minHeight, width, height, null);
- }
- index = getGraphStartIndex();
- do {
- int tickHeight = (int)(localGraph[index] * (float)height);
- if (tickHeight > minHeight) {
- g.drawImage(tickGradientImage, x, height - tickHeight, x + 1, height - minHeight,
- x, height - tickHeight, x + 1, height - minHeight, null);
- }
- index = (index + 1) % localGraph.length;
- x++;
- } while (index != graphIndex);
}
}
/**
- * Renders the text.
+ * Renders the text using an optional drop shadow.
*/
- private void paintText(Graphics g, int w, int h) {
+ private void paintText(Graphics2D g, int w, int h) {
g.setFont(getFont());
String text = getHeapSizeText();
FontMetrics fm = g.getFontMetrics();
int textWidth = fm.stringWidth(text);
- g.drawString(text, (w - maxTextWidth) / 2 + (maxTextWidth - textWidth),
- h / 2 + fm.getAscent() / 2 - 2);
+ int x = (w - maxTextWidth) / 2 + (maxTextWidth - textWidth);
+ int y = h / 2 + fm.getAscent() / 2 - 2;
+ g.setColor(TEXT_COLOR);
+ g.drawString(text, x, y);
Review comment:
It _was_ me.. I had that and took it out because it didn't seem to add much to the clarity in the original scheme. Here it is with/without drop shadow, using your theme colours of 0x2e90e8/0xCEDBE6


I think there is insufficient contrast between white text and the pale blue, even with the drop shadow. May be better to go black text, what do you think?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] jmborer edited a comment on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
jmborer edited a comment on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-587026764
I would add a simple darker border anyway. It would be more consistent with the icons on the toolbar: they all have dark outlines. Besides I would keep the "cheap" shadow as an option (dark outline 1 pixel down): it makes the text more readable on the yellowish part for example. I would definitely get rid off the grid.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] eirikbakke commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r374796118
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -465,526 +225,174 @@ private void updateTextWidth() {
*
* @param e the MouseEvent
*/
- @Override protected void processMouseEvent(MouseEvent e) {
+ @Override
+ protected void processMouseEvent(MouseEvent e) {
super.processMouseEvent(e);
if (!e.isConsumed()) {
if (e.isPopupTrigger()) {
// Show a popup allowing to configure the various options
showPopup(e.getX(), e.getY());
- } else if (e.getID() == MouseEvent.MOUSE_ENTERED) {
- containsMouse = true;
- cachedBorderVaild = false;
- repaint();
- } else if (e.getID() == MouseEvent.MOUSE_EXITED) {
- containsMouse = false;
- cachedBorderVaild = false;
- repaint();
}
+ }
- }
-
- if (e.getID() == MouseEvent.MOUSE_CLICKED &&
- SwingUtilities.isLeftMouseButton(e) &&
- e.getClickCount() == 1) {
+ if (e.getID() == MouseEvent.MOUSE_CLICKED
+ && SwingUtilities.isLeftMouseButton(e)
+ && e.getClickCount() == 1) {
// Trigger a gc
- GarbageCollectAction.get(GarbageCollectAction.class).performAction();;
+ GarbageCollectAction.get(GarbageCollectAction.class).performAction();
}
}
/**
- * Shows a popup at the specified location that allows you to configure
- * the various options.
+ * Shows a popup at the specified location that allows you to configure the
+ * various options.
*/
private void showPopup(int x, int y) {
JPopupMenu popup = new JPopupMenu();
JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_ShowText"));
cbmi.setSelected(getShowText());
cbmi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- setShowText(((JCheckBoxMenuItem)e.getSource()).
+ setShowText(((JCheckBoxMenuItem) e.getSource()).
isSelected());
}
});
popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_DropShadow"));
- cbmi.setSelected(getShowDropShadow());
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setShowDropShadow(((JCheckBoxMenuItem)e.getSource()).
- isSelected());
- }
- });
- popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_OverlayGrid"));
- cbmi.setSelected(getTickStyle() == STYLE_OVERLAY);
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int style = ((JCheckBoxMenuItem)e.getSource()).
- isSelected() ? STYLE_OVERLAY : STYLE_DEFAULT;
- setTickStyle(style);
- }
- });
- popup.add(cbmi);
popup.show(this, x, y);
}
- /**
- * Returns the first index to start rendering from.
- */
- private int getGraphStartIndex() {
- if (graphFilled) {
- return graphIndex;
- } else {
- return 0;
- }
- }
-
/**
* Paints the component.
*/
- @Override protected void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D)g;
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
int width = getWidth();
int height = getHeight();
- if (width - BORDER_W > 0 && height - BORDER_H > 0) {
+
+ if (width > 0 && height > 0) {
startTimerIfNecessary();
- updateCacheIfNecessary(width, height);
- paintCachedBackground(g2, width, height);
- g.translate(1, 2);
- if (containsMouse) {
- g.clipRect(1, 0, width - 4, height - 4);
- }
- else {
- g.clipRect(0, 0, width - 2, height - 4);
- }
- int innerW = width - BORDER_W;
- int innerH = height - BORDER_H;
- if (heapGrowTimer != null) {
- // Render the heap growing animation.
- Composite lastComposite = ((Graphics2D)g).getComposite();
- float percent = 1f - heapGrowTimer.getPercent();
- ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, percent));
- g.drawImage(heapGrowTimer.image, 0, 0, null);
- ((Graphics2D)g).setComposite(lastComposite);
- }
- paintTicks(g2, innerW, innerH);
- if (getTickStyle() == STYLE_OVERLAY) {
- g2.drawImage(getGridOverlayImage(), 0, 0, null);
- }
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ // Fill background
+ g2.setPaint(BACKGROUND_COLOR);
+ g2.fillRect(0, 0, width + 1, height + 1);
+ // Draw samples
+ g2.setPaint(CHART_COLOR);
+ paintSamples(g2, width, height);
+ // Draw text if enabled
if (getShowText()) {
- if (getShowDropShadow()) {
- paintDropShadowText(g, innerW, innerH);
- } else {
- g.setColor(textColor);
- paintText(g, innerW, innerH);
- }
+ paintText(g2, width, height);
}
- g.translate(-1, -2);
} else {
stopTimerIfNecessary();
- // To honor opaque contract, fill in the background
- g.setColor(getBackground());
- g.fillRect(0, 0, width, height);
- }
- }
-
- private void paintTicks(Graphics2D g, int width, int height) {
- if (graphIndex > 0 || graphFilled) {
- int index = getGraphStartIndex();
- int x = 0;
- if (!graphFilled) {
- x = width - graphIndex;
- }
- float[] localGraph = graph;
- if (localGraph == null) {
- return;
- }
- float min = localGraph[index];
- index = (index + 1) % localGraph.length;
- while (index != graphIndex) {
- min = Math.min(min, localGraph[index]);
- index = (index + 1) % localGraph.length;
- }
- int minHeight = (int)(min * (float)height);
- if (minHeight > 0) {
- g.drawImage(tickGradientImage, x, height - minHeight, width, height,
- x, height - minHeight, width, height, null);
- }
- index = getGraphStartIndex();
- do {
- int tickHeight = (int)(localGraph[index] * (float)height);
- if (tickHeight > minHeight) {
- g.drawImage(tickGradientImage, x, height - tickHeight, x + 1, height - minHeight,
- x, height - tickHeight, x + 1, height - minHeight, null);
- }
- index = (index + 1) % localGraph.length;
- x++;
- } while (index != graphIndex);
}
}
/**
- * Renders the text.
+ * Renders the text using an optional drop shadow.
*/
- private void paintText(Graphics g, int w, int h) {
+ private void paintText(Graphics2D g, int w, int h) {
g.setFont(getFont());
String text = getHeapSizeText();
FontMetrics fm = g.getFontMetrics();
int textWidth = fm.stringWidth(text);
- g.drawString(text, (w - maxTextWidth) / 2 + (maxTextWidth - textWidth),
- h / 2 + fm.getAscent() / 2 - 2);
+ int x = (w - maxTextWidth) / 2 + (maxTextWidth - textWidth);
+ int y = h / 2 + fm.getAscent() / 2 - 2;
+ g.setColor(TEXT_COLOR);
+ g.drawString(text, x, y);
Review comment:
You(?) mentioned earlier the idea of "using the cheap & cheerful way of drawing the text twice, the first time displaced and in a darker colour". Perhaps it would be good to include this to create a little contrast between the text and the graph below? E.g.:
```
g.setColor(Color.BLACK);
g.drawString(text, x + 1, y + 1);
g.setColor(TEXT_COLOR);
g.drawString(text, x, y);
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] pedro-w commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
pedro-w commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r375206878
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -465,526 +225,174 @@ private void updateTextWidth() {
*
* @param e the MouseEvent
*/
- @Override protected void processMouseEvent(MouseEvent e) {
+ @Override
+ protected void processMouseEvent(MouseEvent e) {
super.processMouseEvent(e);
if (!e.isConsumed()) {
if (e.isPopupTrigger()) {
// Show a popup allowing to configure the various options
showPopup(e.getX(), e.getY());
- } else if (e.getID() == MouseEvent.MOUSE_ENTERED) {
- containsMouse = true;
- cachedBorderVaild = false;
- repaint();
- } else if (e.getID() == MouseEvent.MOUSE_EXITED) {
- containsMouse = false;
- cachedBorderVaild = false;
- repaint();
}
+ }
- }
-
- if (e.getID() == MouseEvent.MOUSE_CLICKED &&
- SwingUtilities.isLeftMouseButton(e) &&
- e.getClickCount() == 1) {
+ if (e.getID() == MouseEvent.MOUSE_CLICKED
+ && SwingUtilities.isLeftMouseButton(e)
+ && e.getClickCount() == 1) {
// Trigger a gc
- GarbageCollectAction.get(GarbageCollectAction.class).performAction();;
+ GarbageCollectAction.get(GarbageCollectAction.class).performAction();
}
}
/**
- * Shows a popup at the specified location that allows you to configure
- * the various options.
+ * Shows a popup at the specified location that allows you to configure the
+ * various options.
*/
private void showPopup(int x, int y) {
JPopupMenu popup = new JPopupMenu();
JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_ShowText"));
cbmi.setSelected(getShowText());
cbmi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- setShowText(((JCheckBoxMenuItem)e.getSource()).
+ setShowText(((JCheckBoxMenuItem) e.getSource()).
isSelected());
}
});
popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_DropShadow"));
- cbmi.setSelected(getShowDropShadow());
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setShowDropShadow(((JCheckBoxMenuItem)e.getSource()).
- isSelected());
- }
- });
- popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_OverlayGrid"));
- cbmi.setSelected(getTickStyle() == STYLE_OVERLAY);
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int style = ((JCheckBoxMenuItem)e.getSource()).
- isSelected() ? STYLE_OVERLAY : STYLE_DEFAULT;
- setTickStyle(style);
- }
- });
- popup.add(cbmi);
popup.show(this, x, y);
}
- /**
- * Returns the first index to start rendering from.
- */
- private int getGraphStartIndex() {
- if (graphFilled) {
- return graphIndex;
- } else {
- return 0;
- }
- }
-
/**
* Paints the component.
*/
- @Override protected void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D)g;
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
int width = getWidth();
int height = getHeight();
- if (width - BORDER_W > 0 && height - BORDER_H > 0) {
+
+ if (width > 0 && height > 0) {
startTimerIfNecessary();
- updateCacheIfNecessary(width, height);
- paintCachedBackground(g2, width, height);
- g.translate(1, 2);
- if (containsMouse) {
- g.clipRect(1, 0, width - 4, height - 4);
- }
- else {
- g.clipRect(0, 0, width - 2, height - 4);
- }
- int innerW = width - BORDER_W;
- int innerH = height - BORDER_H;
- if (heapGrowTimer != null) {
- // Render the heap growing animation.
- Composite lastComposite = ((Graphics2D)g).getComposite();
- float percent = 1f - heapGrowTimer.getPercent();
- ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, percent));
- g.drawImage(heapGrowTimer.image, 0, 0, null);
- ((Graphics2D)g).setComposite(lastComposite);
- }
- paintTicks(g2, innerW, innerH);
- if (getTickStyle() == STYLE_OVERLAY) {
- g2.drawImage(getGridOverlayImage(), 0, 0, null);
- }
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ // Fill background
+ g2.setPaint(BACKGROUND_COLOR);
+ g2.fillRect(0, 0, width + 1, height + 1);
+ // Draw samples
+ g2.setPaint(CHART_COLOR);
+ paintSamples(g2, width, height);
+ // Draw text if enabled
if (getShowText()) {
- if (getShowDropShadow()) {
- paintDropShadowText(g, innerW, innerH);
- } else {
- g.setColor(textColor);
- paintText(g, innerW, innerH);
- }
+ paintText(g2, width, height);
}
- g.translate(-1, -2);
} else {
stopTimerIfNecessary();
- // To honor opaque contract, fill in the background
- g.setColor(getBackground());
- g.fillRect(0, 0, width, height);
- }
- }
-
- private void paintTicks(Graphics2D g, int width, int height) {
- if (graphIndex > 0 || graphFilled) {
- int index = getGraphStartIndex();
- int x = 0;
- if (!graphFilled) {
- x = width - graphIndex;
- }
- float[] localGraph = graph;
- if (localGraph == null) {
- return;
- }
- float min = localGraph[index];
- index = (index + 1) % localGraph.length;
- while (index != graphIndex) {
- min = Math.min(min, localGraph[index]);
- index = (index + 1) % localGraph.length;
- }
- int minHeight = (int)(min * (float)height);
- if (minHeight > 0) {
- g.drawImage(tickGradientImage, x, height - minHeight, width, height,
- x, height - minHeight, width, height, null);
- }
- index = getGraphStartIndex();
- do {
- int tickHeight = (int)(localGraph[index] * (float)height);
- if (tickHeight > minHeight) {
- g.drawImage(tickGradientImage, x, height - tickHeight, x + 1, height - minHeight,
- x, height - tickHeight, x + 1, height - minHeight, null);
- }
- index = (index + 1) % localGraph.length;
- x++;
- } while (index != graphIndex);
}
}
/**
- * Renders the text.
+ * Renders the text using an optional drop shadow.
*/
- private void paintText(Graphics g, int w, int h) {
+ private void paintText(Graphics2D g, int w, int h) {
g.setFont(getFont());
String text = getHeapSizeText();
FontMetrics fm = g.getFontMetrics();
int textWidth = fm.stringWidth(text);
- g.drawString(text, (w - maxTextWidth) / 2 + (maxTextWidth - textWidth),
- h / 2 + fm.getAscent() / 2 - 2);
+ int x = (w - maxTextWidth) / 2 + (maxTextWidth - textWidth);
+ int y = h / 2 + fm.getAscent() / 2 - 2;
+ g.setColor(TEXT_COLOR);
+ g.drawString(text, x, y);
Review comment:
I did some more experiments and it seemed that the dark gray was legible without being too prominent. Rendering with alpha didn't seem to make it better. Agree on the border looking good but please can we defer this for the next version!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] pedro-w commented on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
pedro-w commented on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-581980278
I guess that the rest of my NB build is not up-to-date; will check and get back to you.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] jmborer commented on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
jmborer commented on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-587026764
I would add a simple darker border anyway. It would be more consistent with the icons on the toolbar: they all have dark outlines.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] eirikbakke commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r374801958
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -47,301 +42,104 @@
import javax.swing.UIManager;
import org.openide.util.NbBundle;
import org.openide.util.NbPreferences;
-import org.openide.util.RequestProcessor;
/**
*
* @author sky, radim
*/
class HeapView extends JComponent {
+
private static final boolean AUTOMATIC_REFRESH = System.getProperty("org.netbeans.log.startup") == null;
- /**
- * Style for overlay on top of grid.
- */
- private static final int STYLE_DEFAULT = 0;
-
- /**
- * Grid overlayed on top of heap. This is the default.
- */
- private static final int STYLE_OVERLAY = 1;
-
/*
* How often the display is updated.
*/
private static final int TICK = 1500;
-
- /**
- * Time (in ms) to animate heap growing.
- */
- private static final int HEAP_GROW_ANIMATE_TIME = 1000;
-
- /**
- * Width of the border.
- */
- private static final int BORDER_W = 2;
-
- /**
- * Height of the border area.
- */
- private static final int BORDER_H = 4;
-
- /**
- * Colors for the grid. This is alternating pairs for a linear gradient.
- */
- private static final Color[] GRID_COLORS = new Color[8];
-
- /**
- * Border color.
- */
- private static Color border1Color;
/**
- * Border color of line below the top.
+ * Foreground color for the chart.
*/
- private static Color border2Color;
+ private static final Color CHART_COLOR;
- private static Color border3Color;
-
/**
- * Start color for the tick gradient.
+ * Color for text.
*/
- private static Color minTickColor;
+ private static final Color TEXT_COLOR;
/**
- * End color for the tick gradient.
+ * Color for the background.
*/
- private static Color maxTickColor;
+ private static final Color BACKGROUND_COLOR;
/**
- * Color for the text before blurred.
+ * Number of samples to retain in history.
*/
- private static Color textBlurColor;
+ private static final int GRAPH_COUNT = 100;
/**
- * Color for text drawn on top of blurred text.
+ * Key for the Show Text preference.
*/
- private static Color textColor;
-
- /**
- * Start color for the background gradient.
- */
- private static Color background1Color;
-
- /**
- * End color for the background gradient.
- */
- private static Color background2Color;
-
- /**
- * Size used for Kernel used to generate drop shadow.
- */
- private static final int KERNEL_SIZE = 3;
-
- /**
- * Factor used for Kernel used to generate drop shadow.
- */
- private static final float BLUR_FACTOR = 0.1f;
-
- /**
- * How far to shift the drop shadow along the horizontal axis.
- */
- private static final int SHIFT_X = 0;
-
- /**
- * How far to shift the drop shadow along the vertical axis.
- */
- private static final int SHIFT_Y = 1;
+ private static final String SHOW_TEXT = "showText";
static {
//init colors
- Color c = UIManager.getColor( "nb.heapview.border1" ); //NOI18N
- if( null == c )
- c = new Color(0xA6A295);
- border1Color = c;
-
- c = UIManager.getColor( "nb.heapview.border2" ); //NOI18N
- if( null == c )
- c = new Color(0xC0BCAD);
- border2Color = c;
-
- c = UIManager.getColor( "nb.heapview.border3" ); //NOI18N
- if( null == c )
- c = Color.WHITE;
- border3Color = c;
-
- c = UIManager.getColor( "nb.heapview.mintick.color" ); //NOI18N
- if( null == c )
- c = new Color(0xC7D6AD);
- minTickColor = c;
-
- c = UIManager.getColor( "nb.heapview.maxtick.color" ); //NOI18N
- if( null == c )
+ Color c = UIManager.getColor("nb.heapview.maxtick.color"); //NOI18N
+ if (null == c) {
c = new Color(0x615d0f);
Review comment:
For this one, trying using 0x2e90e8 instead. That's the lighter blue color from the NetBeans logo cube. (Might also want to grep the codebase for customizations of nb.heapview.maxtick.color, and change it there as well.)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] AlexFalappa commented on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
AlexFalappa commented on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-581925208
@pedro-w thanks for the screenshots with different LAFs, much appreciated.
The Heap View looks certainly better, it is crisper and more readable.
I am not a committer and cannot approve the PR but the changes look good to me.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] pedro-w commented on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
pedro-w commented on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-581956079
@DevCharly I can do that. Will it cause problems if something tries to set those values after they are removed? (e.g. a look and feel, I am not sure how they interact)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] pedro-w commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
pedro-w commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r374923036
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -465,526 +225,174 @@ private void updateTextWidth() {
*
* @param e the MouseEvent
*/
- @Override protected void processMouseEvent(MouseEvent e) {
+ @Override
+ protected void processMouseEvent(MouseEvent e) {
super.processMouseEvent(e);
if (!e.isConsumed()) {
if (e.isPopupTrigger()) {
// Show a popup allowing to configure the various options
showPopup(e.getX(), e.getY());
- } else if (e.getID() == MouseEvent.MOUSE_ENTERED) {
- containsMouse = true;
- cachedBorderVaild = false;
- repaint();
- } else if (e.getID() == MouseEvent.MOUSE_EXITED) {
- containsMouse = false;
- cachedBorderVaild = false;
- repaint();
}
+ }
- }
-
- if (e.getID() == MouseEvent.MOUSE_CLICKED &&
- SwingUtilities.isLeftMouseButton(e) &&
- e.getClickCount() == 1) {
+ if (e.getID() == MouseEvent.MOUSE_CLICKED
+ && SwingUtilities.isLeftMouseButton(e)
+ && e.getClickCount() == 1) {
// Trigger a gc
- GarbageCollectAction.get(GarbageCollectAction.class).performAction();;
+ GarbageCollectAction.get(GarbageCollectAction.class).performAction();
}
}
/**
- * Shows a popup at the specified location that allows you to configure
- * the various options.
+ * Shows a popup at the specified location that allows you to configure the
+ * various options.
*/
private void showPopup(int x, int y) {
JPopupMenu popup = new JPopupMenu();
JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_ShowText"));
cbmi.setSelected(getShowText());
cbmi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- setShowText(((JCheckBoxMenuItem)e.getSource()).
+ setShowText(((JCheckBoxMenuItem) e.getSource()).
isSelected());
}
});
popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_DropShadow"));
- cbmi.setSelected(getShowDropShadow());
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setShowDropShadow(((JCheckBoxMenuItem)e.getSource()).
- isSelected());
- }
- });
- popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_OverlayGrid"));
- cbmi.setSelected(getTickStyle() == STYLE_OVERLAY);
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int style = ((JCheckBoxMenuItem)e.getSource()).
- isSelected() ? STYLE_OVERLAY : STYLE_DEFAULT;
- setTickStyle(style);
- }
- });
- popup.add(cbmi);
popup.show(this, x, y);
}
- /**
- * Returns the first index to start rendering from.
- */
- private int getGraphStartIndex() {
- if (graphFilled) {
- return graphIndex;
- } else {
- return 0;
- }
- }
-
/**
* Paints the component.
*/
- @Override protected void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D)g;
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
int width = getWidth();
int height = getHeight();
- if (width - BORDER_W > 0 && height - BORDER_H > 0) {
+
+ if (width > 0 && height > 0) {
startTimerIfNecessary();
- updateCacheIfNecessary(width, height);
- paintCachedBackground(g2, width, height);
- g.translate(1, 2);
- if (containsMouse) {
- g.clipRect(1, 0, width - 4, height - 4);
- }
- else {
- g.clipRect(0, 0, width - 2, height - 4);
- }
- int innerW = width - BORDER_W;
- int innerH = height - BORDER_H;
- if (heapGrowTimer != null) {
- // Render the heap growing animation.
- Composite lastComposite = ((Graphics2D)g).getComposite();
- float percent = 1f - heapGrowTimer.getPercent();
- ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, percent));
- g.drawImage(heapGrowTimer.image, 0, 0, null);
- ((Graphics2D)g).setComposite(lastComposite);
- }
- paintTicks(g2, innerW, innerH);
- if (getTickStyle() == STYLE_OVERLAY) {
- g2.drawImage(getGridOverlayImage(), 0, 0, null);
- }
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ // Fill background
+ g2.setPaint(BACKGROUND_COLOR);
+ g2.fillRect(0, 0, width + 1, height + 1);
+ // Draw samples
+ g2.setPaint(CHART_COLOR);
+ paintSamples(g2, width, height);
+ // Draw text if enabled
if (getShowText()) {
- if (getShowDropShadow()) {
- paintDropShadowText(g, innerW, innerH);
- } else {
- g.setColor(textColor);
- paintText(g, innerW, innerH);
- }
+ paintText(g2, width, height);
}
- g.translate(-1, -2);
} else {
stopTimerIfNecessary();
- // To honor opaque contract, fill in the background
- g.setColor(getBackground());
- g.fillRect(0, 0, width, height);
- }
- }
-
- private void paintTicks(Graphics2D g, int width, int height) {
- if (graphIndex > 0 || graphFilled) {
- int index = getGraphStartIndex();
- int x = 0;
- if (!graphFilled) {
- x = width - graphIndex;
- }
- float[] localGraph = graph;
- if (localGraph == null) {
- return;
- }
- float min = localGraph[index];
- index = (index + 1) % localGraph.length;
- while (index != graphIndex) {
- min = Math.min(min, localGraph[index]);
- index = (index + 1) % localGraph.length;
- }
- int minHeight = (int)(min * (float)height);
- if (minHeight > 0) {
- g.drawImage(tickGradientImage, x, height - minHeight, width, height,
- x, height - minHeight, width, height, null);
- }
- index = getGraphStartIndex();
- do {
- int tickHeight = (int)(localGraph[index] * (float)height);
- if (tickHeight > minHeight) {
- g.drawImage(tickGradientImage, x, height - tickHeight, x + 1, height - minHeight,
- x, height - tickHeight, x + 1, height - minHeight, null);
- }
- index = (index + 1) % localGraph.length;
- x++;
- } while (index != graphIndex);
}
}
/**
- * Renders the text.
+ * Renders the text using an optional drop shadow.
*/
- private void paintText(Graphics g, int w, int h) {
+ private void paintText(Graphics2D g, int w, int h) {
g.setFont(getFont());
String text = getHeapSizeText();
FontMetrics fm = g.getFontMetrics();
int textWidth = fm.stringWidth(text);
- g.drawString(text, (w - maxTextWidth) / 2 + (maxTextWidth - textWidth),
- h / 2 + fm.getAscent() / 2 - 2);
+ int x = (w - maxTextWidth) / 2 + (maxTextWidth - textWidth);
+ int y = h / 2 + fm.getAscent() / 2 - 2;
+ g.setColor(TEXT_COLOR);
+ g.drawString(text, x, y);
Review comment:
I think black is too much, makes it look more important than all the other buttons on the ribbon.

How about `#404040`?

Or even not bold?

Sorry for bike shedding!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] pedro-w commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
pedro-w commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r374920962
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -350,60 +148,39 @@ public HeapView() {
setToolTipText(NbBundle.getMessage(GarbageCollectAction.class, "CTL_GC"));
updateUI();
}
-
+
/**
- * Overriden to return true, GCComponent paints in its entire bounds in
- * an opaque manner.
+ * Overridden to return true, GCComponent paints in its entire bounds in an
+ * opaque manner.
*/
- @Override public boolean isOpaque() {
+ @Override
+ public boolean isOpaque() {
return true;
}
-
+
/**
* Updates the look and feel for this component.
*/
- @Override public void updateUI() {
- Font f = new JLabel().getFont();
- f = new Font(f.getName(), Font.BOLD, f.getSize());
+ @Override
+ public void updateUI() {
+ Font f = new JLabel().getFont().deriveFont(Font.BOLD);
Review comment:
Makes sense. While we're at it, is this the correct use of the updateUI method? The comments on `JComponent::updateUI` say:
```
* Resets the UI property to a value from the current look and feel.
* <code>JComponent</code> subclasses must override this method
* like this:
* <pre>
* public void updateUI() {
* setUI((SliderUI)UIManager.getUI(this);
* }
* </pre>
```
which I don't really understand.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] lkishalmi commented on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
lkishalmi commented on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-583424401
The last changes are looking sane as well. Are we ready to merge this one?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] eirikbakke commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r374803198
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -47,301 +42,104 @@
import javax.swing.UIManager;
import org.openide.util.NbBundle;
import org.openide.util.NbPreferences;
-import org.openide.util.RequestProcessor;
/**
*
* @author sky, radim
*/
class HeapView extends JComponent {
+
private static final boolean AUTOMATIC_REFRESH = System.getProperty("org.netbeans.log.startup") == null;
- /**
- * Style for overlay on top of grid.
- */
- private static final int STYLE_DEFAULT = 0;
-
- /**
- * Grid overlayed on top of heap. This is the default.
- */
- private static final int STYLE_OVERLAY = 1;
-
/*
* How often the display is updated.
*/
private static final int TICK = 1500;
-
- /**
- * Time (in ms) to animate heap growing.
- */
- private static final int HEAP_GROW_ANIMATE_TIME = 1000;
-
- /**
- * Width of the border.
- */
- private static final int BORDER_W = 2;
-
- /**
- * Height of the border area.
- */
- private static final int BORDER_H = 4;
-
- /**
- * Colors for the grid. This is alternating pairs for a linear gradient.
- */
- private static final Color[] GRID_COLORS = new Color[8];
-
- /**
- * Border color.
- */
- private static Color border1Color;
/**
- * Border color of line below the top.
+ * Foreground color for the chart.
*/
- private static Color border2Color;
+ private static final Color CHART_COLOR;
- private static Color border3Color;
-
/**
- * Start color for the tick gradient.
+ * Color for text.
*/
- private static Color minTickColor;
+ private static final Color TEXT_COLOR;
/**
- * End color for the tick gradient.
+ * Color for the background.
*/
- private static Color maxTickColor;
+ private static final Color BACKGROUND_COLOR;
/**
- * Color for the text before blurred.
+ * Number of samples to retain in history.
*/
- private static Color textBlurColor;
+ private static final int GRAPH_COUNT = 100;
/**
- * Color for text drawn on top of blurred text.
+ * Key for the Show Text preference.
*/
- private static Color textColor;
-
- /**
- * Start color for the background gradient.
- */
- private static Color background1Color;
-
- /**
- * End color for the background gradient.
- */
- private static Color background2Color;
-
- /**
- * Size used for Kernel used to generate drop shadow.
- */
- private static final int KERNEL_SIZE = 3;
-
- /**
- * Factor used for Kernel used to generate drop shadow.
- */
- private static final float BLUR_FACTOR = 0.1f;
-
- /**
- * How far to shift the drop shadow along the horizontal axis.
- */
- private static final int SHIFT_X = 0;
-
- /**
- * How far to shift the drop shadow along the vertical axis.
- */
- private static final int SHIFT_Y = 1;
+ private static final String SHOW_TEXT = "showText";
static {
//init colors
- Color c = UIManager.getColor( "nb.heapview.border1" ); //NOI18N
- if( null == c )
- c = new Color(0xA6A295);
- border1Color = c;
-
- c = UIManager.getColor( "nb.heapview.border2" ); //NOI18N
- if( null == c )
- c = new Color(0xC0BCAD);
- border2Color = c;
-
- c = UIManager.getColor( "nb.heapview.border3" ); //NOI18N
- if( null == c )
- c = Color.WHITE;
- border3Color = c;
-
- c = UIManager.getColor( "nb.heapview.mintick.color" ); //NOI18N
- if( null == c )
- c = new Color(0xC7D6AD);
- minTickColor = c;
-
- c = UIManager.getColor( "nb.heapview.maxtick.color" ); //NOI18N
- if( null == c )
+ Color c = UIManager.getColor("nb.heapview.maxtick.color"); //NOI18N
+ if (null == c) {
c = new Color(0x615d0f);
- maxTickColor = c;
+ }
+ CHART_COLOR = c;
- c = UIManager.getColor( "nb.heapview.textblur" ); //NOI18N
- if( null == c )
+ c = UIManager.getColor("nb.heapview.foreground"); //NOI18N
+ if (null == c) {
c = Color.WHITE;
- textBlurColor = c;
+ }
+ TEXT_COLOR = c;
- c = UIManager.getColor( "nb.heapview.foreground" ); //NOI18N
- if( null == c )
- c = Color.WHITE;
- textColor = c;
-
- c = UIManager.getColor( "nb.heapview.background1" ); //NOI18N
- if( null == c )
- c = new Color(0xD0CCBC);
- background1Color = c;
-
- c = UIManager.getColor( "nb.heapview.background2" ); //NOI18N
- if( null == c )
- c = new Color(0xEAE7D7);
- background2Color = c;
-
- c = UIManager.getColor( "nb.heapview.grid1.start" );
- if( null == c )
- c = new Color(0xE3DFCF);
- GRID_COLORS[0] = c;
-
- c = UIManager.getColor( "nb.heapview.grid1.end" );
- if( null == c )
- c = new Color(0xE7E4D3);
- GRID_COLORS[1] = c;
-
- c = UIManager.getColor( "nb.heapview.grid2.start" );
- if( null == c )
- c = new Color(0xDAD7C6);
- GRID_COLORS[2] = c;
-
- c = UIManager.getColor( "nb.heapview.grid2.end" );
- if( null == c )
- c = new Color(0xDFDCCB);
- GRID_COLORS[3] = c;
-
- c = UIManager.getColor( "nb.heapview.grid3.start" );
- if( null == c )
- c = new Color(0xD3CFBF);
- GRID_COLORS[4] = c;
-
- c = UIManager.getColor( "nb.heapview.grid3.end" );
- if( null == c )
- c = new Color(0xD7D3C3);
- GRID_COLORS[5] = c;
-
- c = UIManager.getColor( "nb.heapview.grid4.start" );
- if( null == c )
- c = new Color(0xCECABA);
- GRID_COLORS[6] = c;
-
- c = UIManager.getColor( "nb.heapview.grid4.end" );
- if( null == c )
- c = new Color(0xD0CCBC);
- GRID_COLORS[7] = c;
+ c = UIManager.getColor("nb.heapview.background1"); //NOI18N
+ if (null == c) {
+ c = new Color(0xC0BCAC);
Review comment:
For this one, use 0xCEDBE6 instead. That will go well with the other suggested color change. (It's the light blueish shadow in the NetBeans logo cube.)
Perhaps also rename this one to nb.heapview.background (without the 1 at the end). This will nullify any LAF customizations from the past, but with the updated branding-consistent colors, that should be fine. New tweaks can be made e.g. for FlatLAF based on the blueish on-brand colors.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] eirikbakke commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r374798212
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -465,526 +225,174 @@ private void updateTextWidth() {
*
* @param e the MouseEvent
*/
- @Override protected void processMouseEvent(MouseEvent e) {
+ @Override
+ protected void processMouseEvent(MouseEvent e) {
super.processMouseEvent(e);
if (!e.isConsumed()) {
if (e.isPopupTrigger()) {
// Show a popup allowing to configure the various options
showPopup(e.getX(), e.getY());
- } else if (e.getID() == MouseEvent.MOUSE_ENTERED) {
- containsMouse = true;
- cachedBorderVaild = false;
- repaint();
- } else if (e.getID() == MouseEvent.MOUSE_EXITED) {
- containsMouse = false;
- cachedBorderVaild = false;
- repaint();
}
+ }
- }
-
- if (e.getID() == MouseEvent.MOUSE_CLICKED &&
- SwingUtilities.isLeftMouseButton(e) &&
- e.getClickCount() == 1) {
+ if (e.getID() == MouseEvent.MOUSE_CLICKED
+ && SwingUtilities.isLeftMouseButton(e)
+ && e.getClickCount() == 1) {
// Trigger a gc
- GarbageCollectAction.get(GarbageCollectAction.class).performAction();;
+ GarbageCollectAction.get(GarbageCollectAction.class).performAction();
}
}
/**
- * Shows a popup at the specified location that allows you to configure
- * the various options.
+ * Shows a popup at the specified location that allows you to configure the
+ * various options.
*/
private void showPopup(int x, int y) {
JPopupMenu popup = new JPopupMenu();
JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_ShowText"));
cbmi.setSelected(getShowText());
cbmi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- setShowText(((JCheckBoxMenuItem)e.getSource()).
+ setShowText(((JCheckBoxMenuItem) e.getSource()).
isSelected());
}
});
popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_DropShadow"));
- cbmi.setSelected(getShowDropShadow());
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setShowDropShadow(((JCheckBoxMenuItem)e.getSource()).
- isSelected());
- }
- });
- popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_OverlayGrid"));
- cbmi.setSelected(getTickStyle() == STYLE_OVERLAY);
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int style = ((JCheckBoxMenuItem)e.getSource()).
- isSelected() ? STYLE_OVERLAY : STYLE_DEFAULT;
- setTickStyle(style);
- }
- });
- popup.add(cbmi);
popup.show(this, x, y);
}
- /**
- * Returns the first index to start rendering from.
- */
- private int getGraphStartIndex() {
- if (graphFilled) {
- return graphIndex;
- } else {
- return 0;
- }
- }
-
/**
* Paints the component.
*/
- @Override protected void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D)g;
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
int width = getWidth();
int height = getHeight();
- if (width - BORDER_W > 0 && height - BORDER_H > 0) {
+
+ if (width > 0 && height > 0) {
startTimerIfNecessary();
- updateCacheIfNecessary(width, height);
- paintCachedBackground(g2, width, height);
- g.translate(1, 2);
- if (containsMouse) {
- g.clipRect(1, 0, width - 4, height - 4);
- }
- else {
- g.clipRect(0, 0, width - 2, height - 4);
- }
- int innerW = width - BORDER_W;
- int innerH = height - BORDER_H;
- if (heapGrowTimer != null) {
- // Render the heap growing animation.
- Composite lastComposite = ((Graphics2D)g).getComposite();
- float percent = 1f - heapGrowTimer.getPercent();
- ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, percent));
- g.drawImage(heapGrowTimer.image, 0, 0, null);
- ((Graphics2D)g).setComposite(lastComposite);
- }
- paintTicks(g2, innerW, innerH);
- if (getTickStyle() == STYLE_OVERLAY) {
- g2.drawImage(getGridOverlayImage(), 0, 0, null);
- }
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ // Fill background
+ g2.setPaint(BACKGROUND_COLOR);
+ g2.fillRect(0, 0, width + 1, height + 1);
+ // Draw samples
+ g2.setPaint(CHART_COLOR);
+ paintSamples(g2, width, height);
+ // Draw text if enabled
if (getShowText()) {
- if (getShowDropShadow()) {
- paintDropShadowText(g, innerW, innerH);
- } else {
- g.setColor(textColor);
- paintText(g, innerW, innerH);
- }
+ paintText(g2, width, height);
}
- g.translate(-1, -2);
} else {
stopTimerIfNecessary();
- // To honor opaque contract, fill in the background
- g.setColor(getBackground());
- g.fillRect(0, 0, width, height);
- }
- }
-
- private void paintTicks(Graphics2D g, int width, int height) {
- if (graphIndex > 0 || graphFilled) {
- int index = getGraphStartIndex();
- int x = 0;
- if (!graphFilled) {
- x = width - graphIndex;
- }
- float[] localGraph = graph;
- if (localGraph == null) {
- return;
- }
- float min = localGraph[index];
- index = (index + 1) % localGraph.length;
- while (index != graphIndex) {
- min = Math.min(min, localGraph[index]);
- index = (index + 1) % localGraph.length;
- }
- int minHeight = (int)(min * (float)height);
- if (minHeight > 0) {
- g.drawImage(tickGradientImage, x, height - minHeight, width, height,
- x, height - minHeight, width, height, null);
- }
- index = getGraphStartIndex();
- do {
- int tickHeight = (int)(localGraph[index] * (float)height);
- if (tickHeight > minHeight) {
- g.drawImage(tickGradientImage, x, height - tickHeight, x + 1, height - minHeight,
- x, height - tickHeight, x + 1, height - minHeight, null);
- }
- index = (index + 1) % localGraph.length;
- x++;
- } while (index != graphIndex);
}
}
/**
- * Renders the text.
+ * Renders the text using an optional drop shadow.
*/
- private void paintText(Graphics g, int w, int h) {
+ private void paintText(Graphics2D g, int w, int h) {
g.setFont(getFont());
String text = getHeapSizeText();
FontMetrics fm = g.getFontMetrics();
int textWidth = fm.stringWidth(text);
- g.drawString(text, (w - maxTextWidth) / 2 + (maxTextWidth - textWidth),
- h / 2 + fm.getAscent() / 2 - 2);
+ int x = (w - maxTextWidth) / 2 + (maxTextWidth - textWidth);
+ int y = h / 2 + fm.getAscent() / 2 - 2;
+ g.setColor(TEXT_COLOR);
+ g.drawString(text, x, y);
}
- /**
- * Renders the text using a drop shadow.
- */
- private void paintDropShadowText(Graphics g, final int w, final int h) {
- BufferedImage dsi = dropShadowImage;
- BufferedImage tsi = textImage;
- if (dsi != null && tsi != null) {
- // And finally copy it.
- Graphics2D blurryImageG = dsi.createGraphics();
- blurryImageG.setComposite(AlphaComposite.Clear);
- blurryImageG.fillRect(0, 0, w, h);
- blurryImageG.setComposite(AlphaComposite.SrcOver);
- blurryImageG.drawImage(tsi, blur, SHIFT_X, SHIFT_Y);
- blurryImageG.setColor(textColor);
- blurryImageG.setFont(getFont());
-
- // Step 3: render the text again on top.
- paintText(blurryImageG, w, h);
- blurryImageG.dispose();
- g.drawImage(dsi, 0, 0, null);
- } else {
- class InitTextAndDropShadow implements Runnable {
- @Override
- public void run() {
- BufferedImage ti = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
- BufferedImage ds = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
- // Step 1: render the text.
- Graphics2D textImageG = ti.createGraphics();
- textImageG.setComposite(AlphaComposite.Clear);
- textImageG.fillRect(0, 0, w, h);
- textImageG.setComposite(AlphaComposite.SrcOver);
- textImageG.setColor(textBlurColor);
- paintText(textImageG, w, h);
- textImageG.dispose();
-
- textImage = ti;
- dropShadowImage = ds;
- repaint();
- }
- }
- RP.post(new InitTextAndDropShadow());
- }
- }
-
private String getHeapSizeText() {
return heapSizeText;
}
-
- /**
- * Paints the grid on top of the ticks.
- */
- private void paintGridOverlay(Graphics2D g, int w, int h) {
- int numCells = GRID_COLORS.length / 2;
- int cellSize = (h - numCells - 1) / numCells;
- int c1 = 0xD0CCBC;
- int c2 = 0xEAE7D7;
- g.setPaint(new GradientPaint(
- 0, 0, new Color((c1 >> 16) & 0xFF, (c1 >> 8) & 0xFF, c1 & 0xFF, 0x30),
- 0, h, new Color((c2 >> 16) & 0xFF, (c2 >> 8) & 0xFF, c2 & 0xFF, 0x40)));
- for (int x = 0; x < w; x += cellSize + 1) {
- g.fillRect(x, 0, 1, h);
- }
- for (int y = h - cellSize - 1; y >= 0; y -= (cellSize + 1)) {
- g.fillRect(0, y, w, 1);
- }
- }
- private void paintCachedBackground(Graphics2D g, int w, int h) {
- if (bgImage != null) {
- g.drawImage(bgImage, 0, 0, null);
- }
- }
-
- private void paintBackgroundTiles(Graphics2D g, int w, int h) {
- g.translate(1, 2);
- w -= BORDER_W;
- h -= BORDER_H;
- int numCells = GRID_COLORS.length / 2;
- int cellSize = (h - numCells - 1) / numCells;
- for (int i = 0; i < numCells; i++) {
- int colorIndex = i;
- int y = h - cellSize * (i + 1) - i;
- int x = 1;
- g.setPaint(new GradientPaint(0, y, GRID_COLORS[colorIndex * 2],
- 0, y + cellSize - 1, GRID_COLORS[colorIndex * 2 + 1]));
- while (x < w) {
- int endX = Math.min(w, x + cellSize);
- g.fillRect(x, y, endX - x, cellSize);
- x = endX + 1;
- }
- y += cellSize + 1;
- }
- g.translate(-1, -2);
- }
-
- private void paintBackground(Graphics2D g, int w, int h) {
- g.setPaint(new GradientPaint(0, 0, background1Color,
- 0, h, background2Color));
- g.fillRect(0, 0, w, h);
- }
-
- private void paintBorder(Graphics g, int w, int h) {
- // Draw the border
- if (containsMouse) {
- g.setColor(border3Color);
- g.drawRect(0, 0, w - 1, h - 1);
- g.drawRect(1, 1, w - 3, h - 3);
- }
- else {
- g.setColor(border1Color);
- g.drawRect(0, 0, w - 1, h - 2);
- g.setColor(border2Color);
- g.fillRect(1, 1, w - 2, 1);
- g.setColor(border3Color);
- g.fillRect(0, h - 1, w, 1);
- }
- }
-
- private void updateCacheIfNecessary(int w, int h) {
- if (cachedWidth != w || cachedHeight != h || !cachedBorderVaild) {
- cachedWidth = w;
- cachedHeight = h;
- cachedBorderVaild = true;
- updateCache(w, h);
- }
- }
-
- private Image getGridOverlayImage() {
- if (gridOverlayImage == null) {
- gridOverlayImage = new BufferedImage(
- getInnerWidth(), getInnerHeight(),
- BufferedImage.TYPE_INT_ARGB);
- Graphics2D g = gridOverlayImage.createGraphics();
- paintGridOverlay(g, getInnerWidth(), getInnerHeight());
- g.dispose();
- }
- return gridOverlayImage;
- }
-
- /**
- * Recreates the various state information needed for rendering.
- */
- private void updateCache(int w, int h) {
- disposeImages();
- textImage = null;
- dropShadowImage = null;
- bgImage = createImage(w, h);
- if (bgImage == null) {
- return;
- }
- Graphics2D imageG = (Graphics2D)bgImage.getGraphics();
- paintBackground(imageG, w, h);
- paintBackgroundTiles(imageG, w, h);
- paintBorder(imageG, w, h);
- imageG.dispose();
- w -= BORDER_W;
- h -= BORDER_H;
- if (graph == null || graph.length != w) {
- graph = new float[w];
- graphFilled = false;
- graphIndex = 0;
- }
- GradientPaint tickGradient = new GradientPaint(0, h, minTickColor,
- w, 0, maxTickColor);
- tickGradientImage = createImage(w, h);
- imageG = (Graphics2D)tickGradientImage.getGraphics();
- imageG.setPaint(tickGradient);
- imageG.fillRect(0, 0, w, h);
- imageG.dispose();
- if (gridOverlayImage != null) {
- gridOverlayImage.flush();
- gridOverlayImage = null;
- }
- }
-
/**
* Invoked when component removed from a heavy weight parent. Stops the
* timer.
*/
- @Override public void removeNotify() {
+ @Override
+ public void removeNotify() {
super.removeNotify();
stopTimerIfNecessary();
}
-
+
/**
* Restarts the timer.
*/
private void startTimerIfNecessary() {
- if (!AUTOMATIC_REFRESH)
+ if (!AUTOMATIC_REFRESH) {
return;
-
+ }
if (updateTimer == null) {
- updateTimer = new Timer(TICK, new ActionHandler());
+ updateTimer = new Timer(TICK, new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ update();
+ }
+ });
updateTimer.setRepeats(true);
updateTimer.start();
}
}
-
+
/**
* Stops the timer.
*/
private void stopTimerIfNecessary() {
if (updateTimer != null) {
- graph = null;
- graphFilled = false;
updateTimer.stop();
updateTimer = null;
lastTotal = 0;
- disposeImages();
- cachedHeight = cachedHeight = -1;
- if (heapGrowTimer != null) {
- heapGrowTimer.stop();
- heapGrowTimer = null;
- }
+ Arrays.fill(graph, 0);
+ heapSizeText = "";
}
}
- private void disposeImages() {
- if (bgImage != null) {
- bgImage.flush();
- bgImage = null;
- }
- if (textImage != null) {
- textImage.flush();
- textImage = null;
- }
- if (dropShadowImage != null) {
- dropShadowImage.flush();
- dropShadowImage = null;
- }
- if (tickGradientImage != null) {
- tickGradientImage.flush();
- tickGradientImage = null;
- }
- if (gridOverlayImage != null) {
- gridOverlayImage.flush();
- gridOverlayImage = null;
- }
- }
-
/**
* Invoked when the update timer fires. Updates the necessary data
* structures and triggers repaints.
*/
private void update() {
- if (!isShowing()) {
+ if (isShowing()) {
+ Runtime r = Runtime.getRuntime();
+ long total = r.totalMemory();
+ long used = total - r.freeMemory();
+ graph[graphIndex] = used;
+ lastTotal = total;
+ ++graphIndex;
+ if (graphIndex >= GRAPH_COUNT) {
+ graphIndex = 0;
+ }
+ heapSizeText = format.format(
+ new Object[]{(double) used / (1024.0 * 1024.0), (double) total / (1024.0 * 1024.0)});
+ repaint();
+ } else {
// Either we've become invisible, or one of our ancestors has.
// Stop the timer and bale. Next paint will trigger timer to
// restart.
stopTimerIfNecessary();
- return;
- }
- Runtime r = Runtime.getRuntime();
- long total = r.totalMemory();
- float[] localGraph = graph;
- if (localGraph == null) {
- return;
- }
- if (total != lastTotal) {
- if (lastTotal != 0) {
- // Total heap size has changed, start an animation.
- startHeapAnimate();
- // Readjust the graph size based on the new max.
- int index = getGraphStartIndex();
- do {
- localGraph[index] = (float)(((double)localGraph[index] *
- (double)lastTotal) / (double)total);
- index = (index + 1) % localGraph.length;
- } while (index != graphIndex);
- }
- lastTotal = total;
- }
- if (heapGrowTimer == null) {
- // Not animating a heap size change, update the graph data and text.
- long used = total - r.freeMemory();
- localGraph[graphIndex] = (float)((double)used / (double)total);
- graphIndex = (graphIndex + 1) % localGraph.length;
- if (graphIndex == 0) {
- graphFilled = true;
- }
- heapSizeText = format.format(
- new Object[] { new Double((double)used / 1024 / 1024),
- new Double((double)total / 1024 / 1024) });
- }
- repaint();
- }
-
- private void startHeapAnimate() {
- if (heapGrowTimer == null) {
- heapGrowTimer = new HeapGrowTimer();
- heapGrowTimer.start();
- }
- }
-
- private void stopHeapAnimate() {
- if (heapGrowTimer != null) {
- heapGrowTimer.stop();
- heapGrowTimer = null;
}
}
- private int getInnerWidth() {
- return getWidth() - BORDER_W;
- }
-
- private int getInnerHeight() {
- return getHeight() - BORDER_H;
- }
-
-
- private final class ActionHandler implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- update();
- }
- }
-
-
- private final class HeapGrowTimer extends Timer {
- private final long startTime;
- private float percent;
- BufferedImage image;
-
- HeapGrowTimer() {
- super(30, null);
- setRepeats(true);
- startTime = System.currentTimeMillis();
- percent = 0f;
- int w = getWidth() - BORDER_W;
- int h = getHeight() - BORDER_H;
- image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g = image.createGraphics();
- paintTicks(g, w, h);
- g.dispose();
- }
-
- public float getPercent() {
- return percent;
- }
-
- @Override protected void fireActionPerformed(ActionEvent e) {
- long time = System.currentTimeMillis();
- long delta = Math.max(0L, time - startTime);
- if (delta > HEAP_GROW_ANIMATE_TIME) {
- stopHeapAnimate();
- } else {
- percent = (float)delta / (float)HEAP_GROW_ANIMATE_TIME;
- repaint();
- }
- }
+ /**
+ * Draw the graph with the heap samples. It is a simple area chart.
+ *
+ * @param g Where to draw
+ * @param width The width of the chart
+ * @param height The height of the chart
+ */
+ private void paintSamples(Graphics2D g, int width, int height) {
+ Path2D path = new Path2D.Double();
+ path.moveTo(0, height);
+ for (int i = 0; i < GRAPH_COUNT; ++i) {
+ int index = (i + graphIndex) % GRAPH_COUNT;
+ double x = (double) i / (double) (GRAPH_COUNT - 1) * (double) width;
+ double y = (double) height * (1.0 - (double) graph[index] / (double) lastTotal);
+ path.lineTo(x, y);
+ }
+ path.lineTo(width, height);
+ path.closePath();
+ g.fill(path);
Review comment:
Perfect--this seems like exactly the right way to draw this, with anti-aliased lines and everything.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] DevCharly commented on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
DevCharly commented on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-581954359
@pedro-w looking at the diff, it seems that lot of UI default values are now obsolete (e.g. `nb.heapview.border1`).
These are defined in at least 3 files:
https://github.com/apache/netbeans/search?q=%22nb.heapview.border1%22&unscoped_q=%22nb.heapview.border1%22
Would be good to remove obsolete values there too.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] pedro-w commented on issue #1918: Implement simplified
HeapView widget
Posted by GitBox <gi...@apache.org>.
pedro-w commented on issue #1918: Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-581879469
Also it looks sharper on my PC than the image above, something to do with scaling a PNG?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] DevCharly commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
DevCharly commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r374945181
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -350,60 +148,39 @@ public HeapView() {
setToolTipText(NbBundle.getMessage(GarbageCollectAction.class, "CTL_GC"));
updateUI();
}
-
+
/**
- * Overriden to return true, GCComponent paints in its entire bounds in
- * an opaque manner.
+ * Overridden to return true, GCComponent paints in its entire bounds in an
+ * opaque manner.
*/
- @Override public boolean isOpaque() {
+ @Override
+ public boolean isOpaque() {
return true;
}
-
+
/**
* Updates the look and feel for this component.
*/
- @Override public void updateUI() {
- Font f = new JLabel().getFont();
- f = new Font(f.getName(), Font.BOLD, f.getSize());
+ @Override
+ public void updateUI() {
+ Font f = new JLabel().getFont().deriveFont(Font.BOLD);
Review comment:
In this custom component it is OK. I think you could remove invocation of `revalidate()` and `repaint()` from `updateUI()`. Does not make any sense IMHO.
`JComponent::updateUI` is usually invoked from two places:
- the component constructor and
- when switching look and feel without restart, which is currently not supported by NB
`setUI()` and `UIManager.getUI()` are used if the component has a UI delegate, which is another class that implements painting, listeners, etc. E.g. UI delegate for `JLabel` is class `javax.swing.plaf.LabelUI`, which is sub-classed by LaFs.
`HeapView` does not have/need a UI delegate. You could even remove `HeapView.updateUI()` and initialize the font in the constructor. But maybe NB supports LaF switching in the future. Then it is good to have it because the label font may be different in various LaFs.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] DevCharly commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
DevCharly commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r374915679
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -350,60 +148,39 @@ public HeapView() {
setToolTipText(NbBundle.getMessage(GarbageCollectAction.class, "CTL_GC"));
updateUI();
}
-
+
/**
- * Overriden to return true, GCComponent paints in its entire bounds in
- * an opaque manner.
+ * Overridden to return true, GCComponent paints in its entire bounds in an
+ * opaque manner.
*/
- @Override public boolean isOpaque() {
+ @Override
+ public boolean isOpaque() {
return true;
}
-
+
/**
* Updates the look and feel for this component.
*/
- @Override public void updateUI() {
- Font f = new JLabel().getFont();
- f = new Font(f.getName(), Font.BOLD, f.getSize());
+ @Override
+ public void updateUI() {
+ Font f = new JLabel().getFont().deriveFont(Font.BOLD);
Review comment:
Probably better use `UIManager.getFont("Label.font")` instead of `new JLabel().getFont()`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] eirikbakke commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r374927609
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -465,526 +225,174 @@ private void updateTextWidth() {
*
* @param e the MouseEvent
*/
- @Override protected void processMouseEvent(MouseEvent e) {
+ @Override
+ protected void processMouseEvent(MouseEvent e) {
super.processMouseEvent(e);
if (!e.isConsumed()) {
if (e.isPopupTrigger()) {
// Show a popup allowing to configure the various options
showPopup(e.getX(), e.getY());
- } else if (e.getID() == MouseEvent.MOUSE_ENTERED) {
- containsMouse = true;
- cachedBorderVaild = false;
- repaint();
- } else if (e.getID() == MouseEvent.MOUSE_EXITED) {
- containsMouse = false;
- cachedBorderVaild = false;
- repaint();
}
+ }
- }
-
- if (e.getID() == MouseEvent.MOUSE_CLICKED &&
- SwingUtilities.isLeftMouseButton(e) &&
- e.getClickCount() == 1) {
+ if (e.getID() == MouseEvent.MOUSE_CLICKED
+ && SwingUtilities.isLeftMouseButton(e)
+ && e.getClickCount() == 1) {
// Trigger a gc
- GarbageCollectAction.get(GarbageCollectAction.class).performAction();;
+ GarbageCollectAction.get(GarbageCollectAction.class).performAction();
}
}
/**
- * Shows a popup at the specified location that allows you to configure
- * the various options.
+ * Shows a popup at the specified location that allows you to configure the
+ * various options.
*/
private void showPopup(int x, int y) {
JPopupMenu popup = new JPopupMenu();
JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_ShowText"));
cbmi.setSelected(getShowText());
cbmi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- setShowText(((JCheckBoxMenuItem)e.getSource()).
+ setShowText(((JCheckBoxMenuItem) e.getSource()).
isSelected());
}
});
popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_DropShadow"));
- cbmi.setSelected(getShowDropShadow());
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setShowDropShadow(((JCheckBoxMenuItem)e.getSource()).
- isSelected());
- }
- });
- popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_OverlayGrid"));
- cbmi.setSelected(getTickStyle() == STYLE_OVERLAY);
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int style = ((JCheckBoxMenuItem)e.getSource()).
- isSelected() ? STYLE_OVERLAY : STYLE_DEFAULT;
- setTickStyle(style);
- }
- });
- popup.add(cbmi);
popup.show(this, x, y);
}
- /**
- * Returns the first index to start rendering from.
- */
- private int getGraphStartIndex() {
- if (graphFilled) {
- return graphIndex;
- } else {
- return 0;
- }
- }
-
/**
* Paints the component.
*/
- @Override protected void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D)g;
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
int width = getWidth();
int height = getHeight();
- if (width - BORDER_W > 0 && height - BORDER_H > 0) {
+
+ if (width > 0 && height > 0) {
startTimerIfNecessary();
- updateCacheIfNecessary(width, height);
- paintCachedBackground(g2, width, height);
- g.translate(1, 2);
- if (containsMouse) {
- g.clipRect(1, 0, width - 4, height - 4);
- }
- else {
- g.clipRect(0, 0, width - 2, height - 4);
- }
- int innerW = width - BORDER_W;
- int innerH = height - BORDER_H;
- if (heapGrowTimer != null) {
- // Render the heap growing animation.
- Composite lastComposite = ((Graphics2D)g).getComposite();
- float percent = 1f - heapGrowTimer.getPercent();
- ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, percent));
- g.drawImage(heapGrowTimer.image, 0, 0, null);
- ((Graphics2D)g).setComposite(lastComposite);
- }
- paintTicks(g2, innerW, innerH);
- if (getTickStyle() == STYLE_OVERLAY) {
- g2.drawImage(getGridOverlayImage(), 0, 0, null);
- }
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ // Fill background
+ g2.setPaint(BACKGROUND_COLOR);
+ g2.fillRect(0, 0, width + 1, height + 1);
+ // Draw samples
+ g2.setPaint(CHART_COLOR);
+ paintSamples(g2, width, height);
+ // Draw text if enabled
if (getShowText()) {
- if (getShowDropShadow()) {
- paintDropShadowText(g, innerW, innerH);
- } else {
- g.setColor(textColor);
- paintText(g, innerW, innerH);
- }
+ paintText(g2, width, height);
}
- g.translate(-1, -2);
} else {
stopTimerIfNecessary();
- // To honor opaque contract, fill in the background
- g.setColor(getBackground());
- g.fillRect(0, 0, width, height);
- }
- }
-
- private void paintTicks(Graphics2D g, int width, int height) {
- if (graphIndex > 0 || graphFilled) {
- int index = getGraphStartIndex();
- int x = 0;
- if (!graphFilled) {
- x = width - graphIndex;
- }
- float[] localGraph = graph;
- if (localGraph == null) {
- return;
- }
- float min = localGraph[index];
- index = (index + 1) % localGraph.length;
- while (index != graphIndex) {
- min = Math.min(min, localGraph[index]);
- index = (index + 1) % localGraph.length;
- }
- int minHeight = (int)(min * (float)height);
- if (minHeight > 0) {
- g.drawImage(tickGradientImage, x, height - minHeight, width, height,
- x, height - minHeight, width, height, null);
- }
- index = getGraphStartIndex();
- do {
- int tickHeight = (int)(localGraph[index] * (float)height);
- if (tickHeight > minHeight) {
- g.drawImage(tickGradientImage, x, height - tickHeight, x + 1, height - minHeight,
- x, height - tickHeight, x + 1, height - minHeight, null);
- }
- index = (index + 1) % localGraph.length;
- x++;
- } while (index != graphIndex);
}
}
/**
- * Renders the text.
+ * Renders the text using an optional drop shadow.
*/
- private void paintText(Graphics g, int w, int h) {
+ private void paintText(Graphics2D g, int w, int h) {
g.setFont(getFont());
String text = getHeapSizeText();
FontMetrics fm = g.getFontMetrics();
int textWidth = fm.stringWidth(text);
- g.drawString(text, (w - maxTextWidth) / 2 + (maxTextWidth - textWidth),
- h / 2 + fm.getAscent() / 2 - 2);
+ int x = (w - maxTextWidth) / 2 + (maxTextWidth - textWidth);
+ int y = h / 2 + fm.getAscent() / 2 - 2;
+ g.setColor(TEXT_COLOR);
+ g.drawString(text, x, y);
Review comment:
Perhaps try black at 85% alpha. Would be good to take out the bold, too, yes.
I also experimented (in Photoshop) with adding a semitransparent dark border (black at 25% alpha) to make the background go better with the surroundings. See screenshot. Though it's a little tricky to paint borders that don't become blurry on fractional HiDPI scalings (o.n.swing.plaf/src/org/netbeans/swing/plaf/windows8/DPIUnscaledBorder.java shows an example), so that can be postponed...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] pedro-w commented on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
pedro-w commented on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-583432022
Unless anyone has any more comments, I think this is ready
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] eirikbakke commented on a change in pull request #1918:
[NETBEANS-3785] Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#discussion_r375392795
##########
File path: platform/openide.actions/src/org/openide/actions/HeapView.java
##########
@@ -465,526 +225,174 @@ private void updateTextWidth() {
*
* @param e the MouseEvent
*/
- @Override protected void processMouseEvent(MouseEvent e) {
+ @Override
+ protected void processMouseEvent(MouseEvent e) {
super.processMouseEvent(e);
if (!e.isConsumed()) {
if (e.isPopupTrigger()) {
// Show a popup allowing to configure the various options
showPopup(e.getX(), e.getY());
- } else if (e.getID() == MouseEvent.MOUSE_ENTERED) {
- containsMouse = true;
- cachedBorderVaild = false;
- repaint();
- } else if (e.getID() == MouseEvent.MOUSE_EXITED) {
- containsMouse = false;
- cachedBorderVaild = false;
- repaint();
}
+ }
- }
-
- if (e.getID() == MouseEvent.MOUSE_CLICKED &&
- SwingUtilities.isLeftMouseButton(e) &&
- e.getClickCount() == 1) {
+ if (e.getID() == MouseEvent.MOUSE_CLICKED
+ && SwingUtilities.isLeftMouseButton(e)
+ && e.getClickCount() == 1) {
// Trigger a gc
- GarbageCollectAction.get(GarbageCollectAction.class).performAction();;
+ GarbageCollectAction.get(GarbageCollectAction.class).performAction();
}
}
/**
- * Shows a popup at the specified location that allows you to configure
- * the various options.
+ * Shows a popup at the specified location that allows you to configure the
+ * various options.
*/
private void showPopup(int x, int y) {
JPopupMenu popup = new JPopupMenu();
JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_ShowText"));
cbmi.setSelected(getShowText());
cbmi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- setShowText(((JCheckBoxMenuItem)e.getSource()).
+ setShowText(((JCheckBoxMenuItem) e.getSource()).
isSelected());
}
});
popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_DropShadow"));
- cbmi.setSelected(getShowDropShadow());
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setShowDropShadow(((JCheckBoxMenuItem)e.getSource()).
- isSelected());
- }
- });
- popup.add(cbmi);
- cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_OverlayGrid"));
- cbmi.setSelected(getTickStyle() == STYLE_OVERLAY);
- cbmi.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int style = ((JCheckBoxMenuItem)e.getSource()).
- isSelected() ? STYLE_OVERLAY : STYLE_DEFAULT;
- setTickStyle(style);
- }
- });
- popup.add(cbmi);
popup.show(this, x, y);
}
- /**
- * Returns the first index to start rendering from.
- */
- private int getGraphStartIndex() {
- if (graphFilled) {
- return graphIndex;
- } else {
- return 0;
- }
- }
-
/**
* Paints the component.
*/
- @Override protected void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D)g;
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
int width = getWidth();
int height = getHeight();
- if (width - BORDER_W > 0 && height - BORDER_H > 0) {
+
+ if (width > 0 && height > 0) {
startTimerIfNecessary();
- updateCacheIfNecessary(width, height);
- paintCachedBackground(g2, width, height);
- g.translate(1, 2);
- if (containsMouse) {
- g.clipRect(1, 0, width - 4, height - 4);
- }
- else {
- g.clipRect(0, 0, width - 2, height - 4);
- }
- int innerW = width - BORDER_W;
- int innerH = height - BORDER_H;
- if (heapGrowTimer != null) {
- // Render the heap growing animation.
- Composite lastComposite = ((Graphics2D)g).getComposite();
- float percent = 1f - heapGrowTimer.getPercent();
- ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, percent));
- g.drawImage(heapGrowTimer.image, 0, 0, null);
- ((Graphics2D)g).setComposite(lastComposite);
- }
- paintTicks(g2, innerW, innerH);
- if (getTickStyle() == STYLE_OVERLAY) {
- g2.drawImage(getGridOverlayImage(), 0, 0, null);
- }
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ // Fill background
+ g2.setPaint(BACKGROUND_COLOR);
+ g2.fillRect(0, 0, width + 1, height + 1);
+ // Draw samples
+ g2.setPaint(CHART_COLOR);
+ paintSamples(g2, width, height);
+ // Draw text if enabled
if (getShowText()) {
- if (getShowDropShadow()) {
- paintDropShadowText(g, innerW, innerH);
- } else {
- g.setColor(textColor);
- paintText(g, innerW, innerH);
- }
+ paintText(g2, width, height);
}
- g.translate(-1, -2);
} else {
stopTimerIfNecessary();
- // To honor opaque contract, fill in the background
- g.setColor(getBackground());
- g.fillRect(0, 0, width, height);
- }
- }
-
- private void paintTicks(Graphics2D g, int width, int height) {
- if (graphIndex > 0 || graphFilled) {
- int index = getGraphStartIndex();
- int x = 0;
- if (!graphFilled) {
- x = width - graphIndex;
- }
- float[] localGraph = graph;
- if (localGraph == null) {
- return;
- }
- float min = localGraph[index];
- index = (index + 1) % localGraph.length;
- while (index != graphIndex) {
- min = Math.min(min, localGraph[index]);
- index = (index + 1) % localGraph.length;
- }
- int minHeight = (int)(min * (float)height);
- if (minHeight > 0) {
- g.drawImage(tickGradientImage, x, height - minHeight, width, height,
- x, height - minHeight, width, height, null);
- }
- index = getGraphStartIndex();
- do {
- int tickHeight = (int)(localGraph[index] * (float)height);
- if (tickHeight > minHeight) {
- g.drawImage(tickGradientImage, x, height - tickHeight, x + 1, height - minHeight,
- x, height - tickHeight, x + 1, height - minHeight, null);
- }
- index = (index + 1) % localGraph.length;
- x++;
- } while (index != graphIndex);
}
}
/**
- * Renders the text.
+ * Renders the text using an optional drop shadow.
*/
- private void paintText(Graphics g, int w, int h) {
+ private void paintText(Graphics2D g, int w, int h) {
g.setFont(getFont());
String text = getHeapSizeText();
FontMetrics fm = g.getFontMetrics();
int textWidth = fm.stringWidth(text);
- g.drawString(text, (w - maxTextWidth) / 2 + (maxTextWidth - textWidth),
- h / 2 + fm.getAscent() / 2 - 2);
+ int x = (w - maxTextWidth) / 2 + (maxTextWidth - textWidth);
+ int y = h / 2 + fm.getAscent() / 2 - 2;
+ g.setColor(TEXT_COLOR);
+ g.drawString(text, x, y);
Review comment:
Yes, happy to defer further improvements! I might look into adding a DPI-safe border myself at some point, after these bigger changes are merged.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] pedro-w commented on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
pedro-w commented on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-581920019
@AlexFalappa done as you suggest.
Nimbus:

Metal:

FlatLAF dark:

DarkMetal:

DarkNimbus:

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] DevCharly commented on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
DevCharly commented on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-581961364
> Will it cause problems if something tries to set those values after they are removed?
No.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] eirikbakke commented on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
eirikbakke commented on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-582021647
> Also it looks sharper on my PC than the image above, something to do with scaling a PNG?
Yes, if you're viewing PNGs in Chrome on, say, 150% HiDPI scaling, you need to have a 67% zoom level to ensure each pixel in the PNG is shown as a device pixel on your monitor. (On MacOS, retina scaling is always 200%, so 50% zoom is what would achieve this, I believe.)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] lkishalmi merged pull request #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
lkishalmi merged pull request #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] DevCharly commented on issue #1918: [NETBEANS-3785]
Implement simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
DevCharly commented on issue #1918: [NETBEANS-3785] Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-581969232
Strange that the background color in the FlatLaf Dark screenshot above is `#C0BCAC` (the default in class `HeapView`) because it is defined as `#4e4e4e` in `FlatDarkLaf.properties`:
https://github.com/apache/netbeans/blob/7aec6ca83c5b71b8ef1d6c9cb8a43e3508a5d1dc/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatDarkLaf.properties#L107
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] AlexFalappa commented on issue #1918: Implement
simplified HeapView widget
Posted by GitBox <gi...@apache.org>.
AlexFalappa commented on issue #1918: Implement simplified HeapView widget
URL: https://github.com/apache/netbeans/pull/1918#issuecomment-581911452
Add prefix [NETBEANS-3785] to the title so that this PR gets linked to the issue on JIRA.
Moreover have you tested it with different LAFs (e.g. with Nimbus, FlatLaf Light and FlatLaf Dark) ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists