patch9
This commit is contained in:
parent
4d6dbd3285
commit
86245d0b46
@ -90,50 +90,52 @@ public class Battery extends Widget {
|
||||
// return getColorBetween(result, result == low ? medium : (result == medium ? high : highest), transition, donePercent);
|
||||
}
|
||||
private static Map<String, Color> colorCache = new HashMap<>();
|
||||
private static Color getColorBetween(Color color1, Color color2, double transition, double progress) {
|
||||
if(color1.equals(color2)) {
|
||||
return color1;
|
||||
}
|
||||
int red1 = color1.getRed();
|
||||
int green1 = color1.getGreen();
|
||||
int blue1 = color1.getBlue();
|
||||
int red2 = color2.getRed();
|
||||
int green2 = color2.getGreen();
|
||||
int blue2 = color2.getBlue();
|
||||
int redDiff = Math.abs(red2-red1);
|
||||
int greenDiff = Math.abs(green2-green1);
|
||||
int blueDiff = Math.abs(blue2-blue1);
|
||||
int red = (int) (Math.min(red1, red2) + ((double)redDiff) * transition);
|
||||
int green = (int) (Math.min(green1, green2) + ((double)greenDiff) * transition);
|
||||
int blue = (int) (Math.min(blue1, blue2) + ((double)blueDiff) * transition);
|
||||
String key = red + COLON + green + COLON + blue;
|
||||
|
||||
// try {new Color(red, green, blue);} catch (Exception e) {
|
||||
// System.out.println(key);
|
||||
// System.out.println("\n\n\nred1=" + red1);
|
||||
// System.out.println("green1=" + green1);
|
||||
// System.out.println("blue1=" + blue1);
|
||||
// System.out.println("red2=" + red2);
|
||||
// System.out.println("green2=" + green2);
|
||||
// System.out.println("blue2=" + blue2);
|
||||
// System.out.println("redDiff=" + redDiff);
|
||||
// System.out.println("greenDiff=" + greenDiff);
|
||||
// System.out.println("blueDiff=" + blueDiff);
|
||||
// System.out.println("red=" + red);
|
||||
// System.out.println("green=" + green);
|
||||
// System.out.println("blue=" + blue);
|
||||
// System.out.println("transition=" + transition);
|
||||
// System.out.println("progress=" + progress);
|
||||
//
|
||||
// return Color.LIGHT_GRAY;
|
||||
// private static Color getColorBetween(Color color1, Color color2, double transition, double progress) {
|
||||
// if(color1.equals(color2)) {
|
||||
// return color1;
|
||||
// }
|
||||
// int red1 = color1.getRed();
|
||||
// int green1 = color1.getGreen();
|
||||
// int blue1 = color1.getBlue();
|
||||
// int red2 = color2.getRed();
|
||||
// int green2 = color2.getGreen();
|
||||
// int blue2 = color2.getBlue();
|
||||
// int redDiff = Math.abs(red2-red1);
|
||||
// int greenDiff = Math.abs(green2-green1);
|
||||
// int blueDiff = Math.abs(blue2-blue1);
|
||||
// int red = (int) (Math.min(red1, red2) + ((double)redDiff) * transition);
|
||||
// int green = (int) (Math.min(green1, green2) + ((double)greenDiff) * transition);
|
||||
// int blue = (int) (Math.min(blue1, blue2) + ((double)blueDiff) * transition);
|
||||
// String key = red + COLON + green + COLON + blue;
|
||||
//
|
||||
//// try {new Color(red, green, blue);} catch (Exception e) {
|
||||
//// System.out.println(key);
|
||||
//// System.out.println("\n\n\nred1=" + red1);
|
||||
//// System.out.println("green1=" + green1);
|
||||
//// System.out.println("blue1=" + blue1);
|
||||
//// System.out.println("red2=" + red2);
|
||||
//// System.out.println("green2=" + green2);
|
||||
//// System.out.println("blue2=" + blue2);
|
||||
//// System.out.println("redDiff=" + redDiff);
|
||||
//// System.out.println("greenDiff=" + greenDiff);
|
||||
//// System.out.println("blueDiff=" + blueDiff);
|
||||
//// System.out.println("red=" + red);
|
||||
//// System.out.println("green=" + green);
|
||||
//// System.out.println("blue=" + blue);
|
||||
//// System.out.println("transition=" + transition);
|
||||
//// System.out.println("progress=" + progress);
|
||||
////
|
||||
//// return Color.LIGHT_GRAY;
|
||||
//// }
|
||||
//
|
||||
// if(!colorCache.containsKey(key)) {
|
||||
// colorCache.put(key, new Color(red, green, blue));
|
||||
// }
|
||||
// return colorCache.get(key);
|
||||
//
|
||||
// }
|
||||
|
||||
if(!colorCache.containsKey(key)) {
|
||||
colorCache.put(key, new Color(red, green, blue));
|
||||
}
|
||||
return colorCache.get(key);
|
||||
|
||||
}
|
||||
public BooleanProperty wavesVisibleProperty
|
||||
= new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
||||
.getKey(), true);
|
||||
|
@ -0,0 +1,33 @@
|
||||
package org.nanoboot.utils.timecalc.swing.progress;
|
||||
|
||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
public class PlaceHolderWidget extends Widget {
|
||||
|
||||
public PlaceHolderWidget() {
|
||||
setPreferredSize(new Dimension(50, 50));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintWidget(Graphics g) {
|
||||
|
||||
Graphics2D brush = (Graphics2D) g;
|
||||
brush.setColor(mouseOver ? Color.LIGHT_GRAY : FOREGROUND_COLOR);
|
||||
|
||||
Visibility visibility = Visibility.ofProperty(visibilityProperty);
|
||||
|
||||
brush.fillRect(1, 1, 48, 48);
|
||||
brush.setColor(Color.LIGHT_GRAY);
|
||||
brush.drawRect(1, 1, 48, 48);
|
||||
|
||||
brush.setColor(FOREGROUND_COLOR);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -30,6 +30,7 @@ import org.nanoboot.utils.timecalc.swing.progress.DayBattery;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.HourBattery;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.MinuteBattery;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.MonthBattery;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.PlaceHolderWidget;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressCircle;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
||||
@ -298,6 +299,11 @@ public class MainWindow extends TWindow {
|
||||
progressCircle.visibleProperty
|
||||
.bindTo(timeCalcConfiguration.circleVisibleProperty);
|
||||
//
|
||||
// PlaceHolderWidget placeHolderWidget = new PlaceHolderWidget();
|
||||
// add(placeHolderWidget);
|
||||
// placeHolderWidget.setBounds(progressSquare.getX() + progressSquare.getWidth() + SwingUtils.MARGIN, SwingUtils.MARGIN, 50, 50);
|
||||
|
||||
|
||||
TLabel arrivalTextFieldLabel = new TLabel("Arrival:", 70);
|
||||
arrivalTextFieldLabel.setBoundsFromTop(clock, 3);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user