mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GT-2973 - Navigation - review fixes
This commit is contained in:
parent
1d5f9ffd5e
commit
e512cebc91
3 changed files with 37 additions and 70 deletions
|
@ -19,7 +19,6 @@ import java.awt.*;
|
|||
import java.awt.dnd.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -35,6 +34,7 @@ import docking.help.Help;
|
|||
import docking.help.HelpService;
|
||||
import docking.util.AnimationUtils;
|
||||
import generic.util.WindowUtilities;
|
||||
import generic.util.image.ImageUtils;
|
||||
import ghidra.framework.OperatingSystem;
|
||||
import ghidra.framework.Platform;
|
||||
import ghidra.util.HelpLocation;
|
||||
|
@ -494,7 +494,7 @@ public class DockableHeader extends GenericHeader
|
|||
|
||||
EmphasizeDockableComponentPainter(Component component, Set<Component> otherComponents) {
|
||||
this.component = component;
|
||||
this.image = paintImage(component);
|
||||
this.image = ImageUtils.createImage(component);
|
||||
|
||||
for (Component otherComponent : otherComponents) {
|
||||
ComponentPaintInfo info = new ComponentPaintInfo(otherComponent);
|
||||
|
@ -509,7 +509,7 @@ public class DockableHeader extends GenericHeader
|
|||
|
||||
ComponentPaintInfo(Component component) {
|
||||
this.myComponent = component;
|
||||
this.myImage = paintImage(component);
|
||||
this.myImage = ImageUtils.createImage(component);
|
||||
}
|
||||
|
||||
Image getImage() {
|
||||
|
@ -628,16 +628,6 @@ public class DockableHeader extends GenericHeader
|
|||
g2d.drawImage(info.getImage(), offsetX, offsetY, w, h, null);
|
||||
}
|
||||
}
|
||||
|
||||
private Image paintImage(Component c) {
|
||||
Rectangle bounds = c.getBounds();
|
||||
BufferedImage bufferedImage =
|
||||
new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = bufferedImage.getGraphics();
|
||||
c.paint(g);
|
||||
g.dispose();
|
||||
return bufferedImage;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.jdesktop.animation.timing.TimingTargetAdapter;
|
|||
import org.jdesktop.animation.timing.interpolation.PropertySetter;
|
||||
|
||||
import generic.util.WindowUtilities;
|
||||
import generic.util.image.ImageUtils;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.bean.GGlassPane;
|
||||
import ghidra.util.bean.GGlassPanePainter;
|
||||
|
@ -241,12 +242,18 @@ public class AnimationUtils {
|
|||
return driver.animator;
|
||||
}
|
||||
|
||||
public static GGlassPane getGlassPane(Component component) {
|
||||
/**
|
||||
* Returns the {@link GGlassPane} for the given component
|
||||
*
|
||||
* @param c the component
|
||||
* @return the glass pane
|
||||
*/
|
||||
public static GGlassPane getGlassPane(Component c) {
|
||||
|
||||
// TODO: validate component has been realized? ...check for window, but that would
|
||||
// then put the onus on the client
|
||||
|
||||
Window window = WindowUtilities.windowForComponent(component);
|
||||
Window window = WindowUtilities.windowForComponent(c);
|
||||
if (window instanceof JFrame) {
|
||||
JFrame frame = (JFrame) window;
|
||||
Component glass = frame.getGlassPane();
|
||||
|
@ -376,7 +383,7 @@ public class AnimationUtils {
|
|||
FocusPainter(Component component, double max) {
|
||||
this.component = component;
|
||||
this.max = max;
|
||||
image = paintImage();
|
||||
image = ImageUtils.createImage(component);
|
||||
}
|
||||
|
||||
void setPercentComplete(double percent) {
|
||||
|
@ -446,16 +453,6 @@ public class AnimationUtils {
|
|||
|
||||
g.drawImage(image, x, y, width, height, null);
|
||||
}
|
||||
|
||||
private Image paintImage() {
|
||||
Rectangle bounds = component.getBounds();
|
||||
BufferedImage bufferedImage =
|
||||
new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = bufferedImage.getGraphics();
|
||||
component.paint(g);
|
||||
g.dispose();
|
||||
return bufferedImage;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PointToComponentDriver {
|
||||
|
@ -530,7 +527,7 @@ public class AnimationUtils {
|
|||
PointToComponentPainter(Point startPoint, Component component) {
|
||||
this.startPoint = startPoint;
|
||||
this.component = component;
|
||||
image = paintImage();
|
||||
image = ImageUtils.createImage(component);
|
||||
}
|
||||
|
||||
void setPercentComplete(double percent) {
|
||||
|
@ -565,16 +562,6 @@ public class AnimationUtils {
|
|||
//
|
||||
g2d.drawImage(image, (int) currentX, (int) currentY, scaledWidth, scaledHeight, null);
|
||||
}
|
||||
|
||||
private Image paintImage() {
|
||||
Rectangle bounds = component.getBounds();
|
||||
BufferedImage bufferedImage =
|
||||
new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = bufferedImage.getGraphics();
|
||||
component.paint(g);
|
||||
g.dispose();
|
||||
return bufferedImage;
|
||||
}
|
||||
}
|
||||
|
||||
// note: must be public due to reflection used by the timing framework
|
||||
|
@ -806,7 +793,7 @@ public class AnimationUtils {
|
|||
|
||||
RotatePainter(Component component) {
|
||||
this.component = component;
|
||||
image = paintImage();
|
||||
image = ImageUtils.createImage(component);
|
||||
}
|
||||
|
||||
void setPercentComplete(double percent) {
|
||||
|
@ -881,16 +868,6 @@ public class AnimationUtils {
|
|||
g.drawRect(offsetX, offsetY, iw, ih);
|
||||
g.drawImage(image, offsetX, offsetY, iw, ih, null);
|
||||
}
|
||||
|
||||
private Image paintImage() {
|
||||
Rectangle bounds = component.getBounds();
|
||||
BufferedImage bufferedImage =
|
||||
new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = bufferedImage.getGraphics();
|
||||
component.paint(g);
|
||||
g.dispose();
|
||||
return bufferedImage;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShakeDriver {
|
||||
|
@ -1001,7 +978,7 @@ public class AnimationUtils {
|
|||
|
||||
PulsePainter(Component component) {
|
||||
this.component = component;
|
||||
image = paintImage();
|
||||
image = ImageUtils.createImage(component);
|
||||
}
|
||||
|
||||
void setEmphasis(double emphasis) {
|
||||
|
@ -1032,16 +1009,6 @@ public class AnimationUtils {
|
|||
|
||||
g.drawImage(image, offsetX, offsetY, width, height, null);
|
||||
}
|
||||
|
||||
private Image paintImage() {
|
||||
Rectangle bounds = component.getBounds();
|
||||
BufferedImage bufferedImage =
|
||||
new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = bufferedImage.getGraphics();
|
||||
component.paint(g);
|
||||
g.dispose();
|
||||
return bufferedImage;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ShakePainter implements GGlassPanePainter {
|
||||
|
@ -1051,7 +1018,7 @@ public class AnimationUtils {
|
|||
|
||||
ShakePainter(Component component) {
|
||||
this.component = component;
|
||||
image = paintImage();
|
||||
image = ImageUtils.createImage(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1091,16 +1058,6 @@ public class AnimationUtils {
|
|||
g2d.rotate(lastDirection, emphasizedBounds.getCenterX(), emphasizedBounds.getCenterY());
|
||||
g.drawImage(image, offsetX, offsetY, width, height, null);
|
||||
}
|
||||
|
||||
private Image paintImage() {
|
||||
Rectangle bounds = component.getBounds();
|
||||
BufferedImage bufferedImage =
|
||||
new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = bufferedImage.getGraphics();
|
||||
component.paint(g);
|
||||
g.dispose();
|
||||
return bufferedImage;
|
||||
}
|
||||
}
|
||||
|
||||
private static class PulseAndShakePainter extends PulsePainter {
|
||||
|
|
|
@ -41,6 +41,26 @@ public class ImageUtils {
|
|||
// no
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an image of the given component
|
||||
*
|
||||
* @param c the component
|
||||
* @return the image
|
||||
*/
|
||||
public static Image createImage(Component c) {
|
||||
|
||||
// prevent this from being called when the user has made the window too small to work
|
||||
Rectangle bounds = c.getBounds();
|
||||
int w = Math.max(bounds.width, 1);
|
||||
int h = Math.max(bounds.height, 1);
|
||||
|
||||
BufferedImage bufferedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = bufferedImage.getGraphics();
|
||||
c.paint(g);
|
||||
g.dispose();
|
||||
return bufferedImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pads the given image with space in the amount given.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue