Skip to content

Commit

Permalink
Fixed issue #146
Browse files Browse the repository at this point in the history
The bar, needle and tooltip should now be at the right position
  • Loading branch information
HanSolo committed Jun 7, 2018
1 parent 7f21691 commit 1d7f07c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main/java/eu/hansolo/medusa/skins/IndicatorSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ private void initGraphics() {
if (gauge.isValueVisible()) {
Bounds bounds = pane.localToScreen(pane.getBoundsInLocal());
double xFactor = value > gauge.getRange() * 0.8 ? 0.0 : 0.25;
double tooltipAngle = value * angleStep;
double sinValue = Math.sin(Math.toRadians(180 + angleRange * 0.5 - tooltipAngle));
double cosValue = Math.cos(Math.toRadians(180 + angleRange * 0.5 - tooltipAngle));
double tooltipAngle = needleRotate.getAngle();
double sinValue = Math.sin(Math.toRadians(90 + angleRange * 0.5 - tooltipAngle));
double cosValue = Math.cos(Math.toRadians(90 + angleRange * 0.5 - tooltipAngle));
double needleTipX = bounds.getMinX() + bounds.getWidth() * 0.5 + bounds.getHeight() * sinValue;
double needleTipY = bounds.getMinY() + bounds.getHeight() * 0.72 + bounds.getHeight() * cosValue;
needleTooltip.show(needle, needleTipX, needleTipY);
Expand Down Expand Up @@ -266,10 +266,9 @@ private double getStartAngle() {

private void rotateNeedle(final double VALUE) {
double needleStartAngle = angleRange * 0.5;
double targetAngle = (VALUE - minValue) * angleStep - needleStartAngle;
targetAngle = Helper.clamp(-needleStartAngle, -needleStartAngle + angleRange, targetAngle);
double targetAngle = Helper.clamp(-needleStartAngle, -needleStartAngle + angleRange, ((gauge.getCurrentValue() - minValue) * angleStep - needleStartAngle));
needleRotate.setAngle(targetAngle);
bar.setLength(-(gauge.getCurrentValue() - minValue) * angleStep);
bar.setLength(-90 - targetAngle);
setBarColor(VALUE);
}

Expand Down Expand Up @@ -347,13 +346,16 @@ private void resizeStaticText() {
drawSections();
}

double needleStartAngle = angleRange * 0.5;
double targetAngle = Helper.clamp(-needleStartAngle, -needleStartAngle + angleRange, ((gauge.getCurrentValue() - minValue) * angleStep - needleStartAngle));

bar.setCenterX(centerX);
bar.setCenterY(centerY);
bar.setRadiusX(barRadius);
bar.setRadiusY(barRadius);
bar.setStrokeWidth(barWidth);
bar.setStartAngle(angleRange * 0.5 + 90);
bar.setLength(-(gauge.getCurrentValue() - minValue) * angleStep);
bar.setLength(-90 - targetAngle);

double needleWidth = height * 0.13157895;
double needleHeight = height * 0.91315789;
Expand Down

0 comments on commit 1d7f07c

Please sign in to comment.