[#2344] Optimize UI color fetching
This commit is contained in:
parent
2ce09e8f90
commit
248ca23a50
@ -1,6 +1,7 @@
|
|||||||
package net.sf.openrocket.gui.scalefigure;
|
package net.sf.openrocket.gui.scalefigure;
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
@ -57,15 +58,30 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
private Rectangle2D.Double[] finPointHandles = null;
|
private Rectangle2D.Double[] finPointHandles = null;
|
||||||
private int selectedIndex = -1;
|
private int selectedIndex = -1;
|
||||||
|
|
||||||
|
private static Color finPointBodyLineColor;
|
||||||
|
private static Color finPointGridMajorLineColor;
|
||||||
|
private static Color finPointGridMinorLineColor;
|
||||||
|
private static Color finPointPointColor;
|
||||||
|
private static Color finPointSelectedPointColor;
|
||||||
|
|
||||||
public FinPointFigure(FreeformFinSet finset) {
|
public FinPointFigure(FreeformFinSet finset) {
|
||||||
this.finset = finset;
|
this.finset = finset;
|
||||||
|
|
||||||
setBackground(GUIUtil.getUITheme().getBackgroundColor());
|
setBackground(GUIUtil.getUITheme().getBackgroundColor());
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
|
|
||||||
|
updateColors();
|
||||||
updateFigure();
|
updateFigure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void updateColors() {
|
||||||
|
finPointBodyLineColor = GUIUtil.getUITheme().getFinPointBodyLineColor();
|
||||||
|
finPointGridMajorLineColor = GUIUtil.getUITheme().getFinPointGridMajorLineColor();
|
||||||
|
finPointGridMinorLineColor = GUIUtil.getUITheme().getFinPointGridMinorLineColor();
|
||||||
|
finPointPointColor = GUIUtil.getUITheme().getFinPointPointColor();
|
||||||
|
finPointSelectedPointColor = GUIUtil.getUITheme().getFinPointSelectedPointColor();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Point getAutoZoomPoint(){
|
public Point getAutoZoomPoint(){
|
||||||
return new Point( Math.max(0, (originLocation_px.x - borderThickness_px.width)), 0);
|
return new Point( Math.max(0, (originLocation_px.x - borderThickness_px.width)), 0);
|
||||||
@ -122,11 +138,11 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
Line2D.Double line = new Line2D.Double();
|
Line2D.Double line = new Line2D.Double();
|
||||||
for (Tick t : verticalTicks) {
|
for (Tick t : verticalTicks) {
|
||||||
if (t.major) {
|
if (t.major) {
|
||||||
g2.setColor(GUIUtil.getUITheme().getFinPointGridMajorLineColor());
|
g2.setColor(finPointGridMajorLineColor);
|
||||||
line.setLine( t.value, y0, t.value, y1);
|
line.setLine( t.value, y0, t.value, y1);
|
||||||
g2.draw(line);
|
g2.draw(line);
|
||||||
}else{
|
}else{
|
||||||
g2.setColor(GUIUtil.getUITheme().getFinPointGridMinorLineColor());
|
g2.setColor(finPointGridMinorLineColor);
|
||||||
line.setLine( t.value, y0, t.value, y1);
|
line.setLine( t.value, y0, t.value, y1);
|
||||||
g2.draw(line);
|
g2.draw(line);
|
||||||
}
|
}
|
||||||
@ -136,11 +152,11 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
Tick[] horizontalTicks = unit.getTicks(y0, y1, MINOR_TICKS / this.scale, MAJOR_TICKS / this.scale);
|
Tick[] horizontalTicks = unit.getTicks(y0, y1, MINOR_TICKS / this.scale, MAJOR_TICKS / this.scale);
|
||||||
for (Tick t : horizontalTicks) {
|
for (Tick t : horizontalTicks) {
|
||||||
if (t.major) {
|
if (t.major) {
|
||||||
g2.setColor(GUIUtil.getUITheme().getFinPointGridMajorLineColor());
|
g2.setColor(finPointGridMajorLineColor);
|
||||||
line.setLine( x0, t.value, x1, t.value);
|
line.setLine( x0, t.value, x1, t.value);
|
||||||
g2.draw(line);
|
g2.draw(line);
|
||||||
}else{
|
}else{
|
||||||
g2.setColor(GUIUtil.getUITheme().getFinPointGridMinorLineColor());
|
g2.setColor(finPointGridMinorLineColor);
|
||||||
line.setLine( x0, t.value, x1, t.value);
|
line.setLine( x0, t.value, x1, t.value);
|
||||||
g2.draw(line);
|
g2.draw(line);
|
||||||
}
|
}
|
||||||
@ -163,7 +179,7 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
// setup lines
|
// setup lines
|
||||||
final float bodyLineWidth = (float) ( LINE_WIDTH_BODY_PIXELS / scale );
|
final float bodyLineWidth = (float) ( LINE_WIDTH_BODY_PIXELS / scale );
|
||||||
g2.setStroke(new BasicStroke( bodyLineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
g2.setStroke(new BasicStroke( bodyLineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||||
g2.setColor(GUIUtil.getUITheme().getFinPointBodyLineColor());
|
g2.setColor(finPointBodyLineColor);
|
||||||
|
|
||||||
Transition body = (Transition) finset.getParent();
|
Transition body = (Transition) finset.getParent();
|
||||||
final float xResolution_m = 0.01f; // distance between draw points, in meters
|
final float xResolution_m = 0.01f; // distance between draw points, in meters
|
||||||
@ -213,7 +229,7 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
final float bodyLineWidth = (float) ( LINE_WIDTH_BODY_PIXELS / scale );
|
final float bodyLineWidth = (float) ( LINE_WIDTH_BODY_PIXELS / scale );
|
||||||
g2.setStroke(new BasicStroke( bodyLineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
g2.setStroke(new BasicStroke( bodyLineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||||
g2.setColor(GUIUtil.getUITheme().getFinPointBodyLineColor());
|
g2.setColor(finPointBodyLineColor);
|
||||||
g2.draw(shape);
|
g2.draw(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,12 +246,12 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
final float finEdgeWidth_m = (float) (LINE_WIDTH_FIN_PIXELS / scale );
|
final float finEdgeWidth_m = (float) (LINE_WIDTH_FIN_PIXELS / scale );
|
||||||
g2.setStroke(new BasicStroke( finEdgeWidth_m, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
g2.setStroke(new BasicStroke( finEdgeWidth_m, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||||
g2.setColor(GUIUtil.getUITheme().getFinPointBodyLineColor());
|
g2.setColor(finPointBodyLineColor);
|
||||||
g2.draw(shape);
|
g2.draw(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void paintFinHandles(final Graphics2D g2) {
|
private void paintFinHandles(final Graphics2D g2) {
|
||||||
// excludes fin tab points
|
// Excludes fin tab points
|
||||||
final Coordinate[] drawPoints = finset.getFinPoints();
|
final Coordinate[] drawPoints = finset.getFinPoints();
|
||||||
|
|
||||||
// Fin point boxes
|
// Fin point boxes
|
||||||
@ -244,7 +260,7 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
final float boxEdgeWidth_m = (float) ( LINE_WIDTH_BOX_PIXELS / scale );
|
final float boxEdgeWidth_m = (float) ( LINE_WIDTH_BOX_PIXELS / scale );
|
||||||
g2.setStroke(new BasicStroke( boxEdgeWidth_m, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
g2.setStroke(new BasicStroke( boxEdgeWidth_m, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||||
g2.setColor(GUIUtil.getUITheme().getFinPointPointColor());
|
g2.setColor(finPointPointColor);
|
||||||
|
|
||||||
finPointHandles = new Rectangle2D.Double[ drawPoints.length];
|
finPointHandles = new Rectangle2D.Double[ drawPoints.length];
|
||||||
for (int currentIndex = 0; currentIndex < drawPoints.length; currentIndex++) {
|
for (int currentIndex = 0; currentIndex < drawPoints.length; currentIndex++) {
|
||||||
@ -256,15 +272,15 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
final Rectangle2D.Double selectedPointHighlight = new Rectangle2D.Double(c.x - selBoxHalfWidth, c.y - selBoxHalfWidth, selBoxWidth, selBoxWidth);
|
final Rectangle2D.Double selectedPointHighlight = new Rectangle2D.Double(c.x - selBoxHalfWidth, c.y - selBoxHalfWidth, selBoxWidth, selBoxWidth);
|
||||||
|
|
||||||
// switch to the highlight color
|
// Switch to the highlight color
|
||||||
g2.setColor(GUIUtil.getUITheme().getFinPointSelectedPointColor());
|
g2.setColor(finPointSelectedPointColor);
|
||||||
g2.draw(selectedPointHighlight);
|
g2.draw(selectedPointHighlight);
|
||||||
|
|
||||||
// reset to the normal color
|
// Reset to the normal color
|
||||||
g2.setColor(GUIUtil.getUITheme().getFinPointPointColor());
|
g2.setColor(finPointPointColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// normal boxes
|
// Normal boxes
|
||||||
finPointHandles[currentIndex] = new Rectangle2D.Double(c.x - boxHalfWidth, c.y - boxHalfWidth, boxWidth, boxWidth);
|
finPointHandles[currentIndex] = new Rectangle2D.Double(c.x - boxHalfWidth, c.y - boxHalfWidth, boxWidth, boxWidth);
|
||||||
|
|
||||||
g2.draw(finPointHandles[currentIndex]);
|
g2.draw(finPointHandles[currentIndex]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user