下面列出了javafx.scene.paint.Color#web ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static Node createIconContent() {
StackPane sp = new StackPane();
TilePane iconTilePane = new TilePane();
iconTilePane.setAlignment(Pos.CENTER);
Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
rectangle.setStroke(Color.BLACK);
iconTilePane.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
Rectangle[] rec = new Rectangle[9];
for (int i = 0; i < rec.length; i++) {
rec[i] = new Rectangle(14, 14, Color.web("#349b00"));
TilePane.setMargin(rec[i], new Insets(2, 2, 2, 2));
}
iconTilePane.getChildren().addAll(rec);
sp.getChildren().addAll(rectangle, iconTilePane);
return new Group(sp);
}
public static Node createIconContent() {
StackPane sp = new StackPane();
AnchorPane anchorPane = new AnchorPane();
Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
rectangle.setStroke(Color.BLACK);
anchorPane.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
Rectangle r1 = new Rectangle(14, 14, Color.web("#1c89f4"));
Rectangle r2 = new Rectangle(45, 10, Color.web("#349b00"));
Rectangle r3 = new Rectangle(35, 14, Color.web("#349b00"));
anchorPane.getChildren().addAll(r1, r2, r3);
AnchorPane.setTopAnchor(r1, Double.valueOf(1));
AnchorPane.setLeftAnchor(r1, Double.valueOf(1));
AnchorPane.setTopAnchor(r2, Double.valueOf(20));
AnchorPane.setLeftAnchor(r2, Double.valueOf(1));
AnchorPane.setBottomAnchor(r3, Double.valueOf(1));
AnchorPane.setRightAnchor(r3, Double.valueOf(5));
sp.getChildren().addAll(rectangle, anchorPane);
return new Group(sp);
}
public static Node createIconContent() {
StackPane sp = new StackPane();
FlowPane fp = new FlowPane();
fp.setAlignment(Pos.CENTER);
Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
rectangle.setStroke(Color.BLACK);
fp.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
Rectangle[] littleRecs = new Rectangle[4];
Rectangle[] bigRecs = new Rectangle[4];
for (int i = 0; i < 4; i++) {
littleRecs[i] = new Rectangle(14, 14, Color.web("#1c89f4"));
bigRecs[i] = new Rectangle(16, 12, Color.web("#349b00"));
fp.getChildren().addAll(littleRecs[i], bigRecs[i]);
FlowPane.setMargin(littleRecs[i], new Insets(2, 2, 2, 2));
}
sp.getChildren().addAll(rectangle, fp);
return new Group(sp);
}
public HeatControlSkin(HeatControl heatControl) {
super(heatControl);
userAction = false;
newTarget = "";
gradientLookup = new GradientLookup(new Stop(0.10, Color.web("#3221c9")),
new Stop(0.20, Color.web("#216ec9")),
new Stop(0.30, Color.web("#21bac9")),
new Stop(0.40, Color.web("#30cb22")),
new Stop(0.50, Color.web("#2fcb22")),
new Stop(0.60, Color.web("#f1ec28")),
new Stop(0.70, Color.web("#f1c428")),
new Stop(0.80, Color.web("#f19c28")),
new Stop(0.90, Color.web("#f16f28")),
new Stop(1.00, Color.web("#ec272f")));
angleStep = heatControl.getAngleRange() / (heatControl.getMaxValue() - heatControl.getMinValue());
mouseEventHandler = mouseEvent -> handleMouseEvent(mouseEvent);
touchEventHandler = touchEvent -> handleTouchEvent(touchEvent);
init();
initGraphics();
registerListeners();
}
public static Node createIconContent() {
StackPane sp = new StackPane();
VBox vbox = new VBox(3);
vbox.setAlignment(Pos.CENTER);
vbox.setPadding(new Insets(5, 5, 5, 5));
Rectangle rectangle = new Rectangle(32, 62, Color.LIGHTGREY);
rectangle.setStroke(Color.BLACK);
vbox.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
Rectangle r1 = new Rectangle(18, 14, Color.web("#1c89f4"));
Rectangle r2 = new Rectangle(18, 14, Color.web("#349b00"));
Rectangle r3 = new Rectangle(18, 20, Color.web("#349b00"));
vbox.getChildren().addAll(r1, r2, r3);
sp.getChildren().addAll(rectangle, vbox);
return new Group(sp);
}
@Override
public void start(Stage stage) {
// Button btn = new Button("OK");
// Scene scene = new Scene(btn, 200, 250);
// stage.setTitle("OK");
// stage.setScene(scene);
// stage.show();
// create the browser
stage.setTitle("Web Window");
Scene scene = new Scene(new Browser(),750,500, Color.web("#666970"));
stage.setScene(scene);
// scene.getStylesheets().add("webviewsample/BrowserToolbar.css");
stage.show();
instance = this;
}
public static Node createIconContent() {
StackPane sp = new StackPane();
TilePane iconTilePane = new TilePane();
iconTilePane.setAlignment(Pos.CENTER);
Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
rectangle.setStroke(Color.BLACK);
iconTilePane.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
Rectangle[] rec = new Rectangle[9];
for (int i = 0; i < rec.length; i++) {
rec[i] = new Rectangle(14, 14, Color.web("#349b00"));
TilePane.setMargin(rec[i], new Insets(2, 2, 2, 2));
}
iconTilePane.getChildren().addAll(rec);
sp.getChildren().addAll(rectangle, iconTilePane);
return new Group(sp);
}
public TimelineSample() {
super(280,120);
//create a circle
final Circle circle = new Circle(25,25, 20, Color.web("1c89f4"));
circle.setEffect(new Lighting());
//create a timeline for moving the circle
timeline = new Timeline();
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.setAutoReverse(true);
//one can start/pause/stop/play animation by
//timeline.play();
//timeline.pause();
//timeline.stop();
//timeline.playFromStart();
//add the following keyframes to the timeline
timeline.getKeyFrames().addAll
(new KeyFrame(Duration.ZERO,
new KeyValue(circle.translateXProperty(), 0)),
new KeyFrame(new Duration(4000),
new KeyValue(circle.translateXProperty(), 205)));
getChildren().add(createNavigation());
getChildren().add(circle);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Timeline rate", timeline.rateProperty(), -4d, 4d)
//TODO it is possible to do it for integer?
);
// END REMOVE ME
}
public TranslateSample() {
super(230, 220);
//create 2 rectangles with different color
Rectangle rect1 = new Rectangle(90, 90, Color.web("#ed4b00", 0.75));
Rectangle rect2 = new Rectangle(90, 90, Color.web("#ed4b00", 0.5));
//translate second one
rect2.setTranslateX(140);
// rectangle with adjustable translate
Rectangle rect3 = new Rectangle(40, 130, 60, 60);
rect3.setFill(Color.DODGERBLUE);
rect3.setTranslateX(20);
rect3.setTranslateY(10);
//show the rectangles
getChildren().addAll(rect2, rect1, rect3);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Translate X", rect3.translateXProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Translate Y", rect3.translateYProperty(), 0d, 50d)
);
// END REMOVE ME
//create arrow
Polygon polygon = createArrow();
polygon.setLayoutX(110);
polygon.setLayoutY(30);
polygon.setRotate(90);
getChildren().addAll(polygon);
}
/**
* Parse some XML representing this object and return the object it
* represents.
* <p>
* @param node the XML node representing this object.
* @return the object as defined by the XML.
*/
public static Notice parseXML(Node node) {
NodeList list = node.getChildNodes();
String text = "";
int duration = 0;
String colorString = "0xffffffff";
String fontString = "System Regular,50.0";
for (int i = 0; i < list.getLength(); i++) {
switch (list.item(i).getNodeName()) {
case "text":
text = list.item(i).getTextContent();
break;
case "duration":
duration = Integer.parseInt(list.item(i).getTextContent());
if (duration == 0) {
duration = Integer.MAX_VALUE;
}
break;
case "color":
colorString = list.item(i).getTextContent();
break;
case "font":
fontString = list.item(i).getTextContent();
break;
}
}
SerializableColor color = new SerializableColor(Color.web(colorString));
String[] fontTemp = fontString.split(",");
SerializableFont font = new SerializableFont(new Font(fontTemp[0], Double.parseDouble(fontTemp[1])));
return new Notice(text, duration, color, font);
}
public void generate() {
for (int i=0; i<STAR_COUNT; i++) {
int hex = 0;
int randColor = RandomUtil.getRandomInt(31);
if (randColor == 0)
hex = 0xe7420b; // red orange
else if (randColor == 1)
hex = 0xd0d0f9; // light blue
else if (randColor == 2)
hex = 0xf4df0d; // FFFFE0; // yellow
else
hex = 0xffffff; // white
if (hex != 0xffffff) {
int rand = RandomUtil.getRandomInt(127);
hex = hex + rand;
}
String hexString = Integer.toHexString(hex);
Color c = Color.web(hexString, 1.0);
nodes[i] = new Rectangle(1, 1, c);
angles[i] = 2.0 * Math.PI * random.nextDouble();
//start[i] = random.nextInt(2000000000);
start[i] = random.nextInt(2000000000);
}
}
public TimelineSample() {
super(280,120);
//create a circle
final Circle circle = new Circle(25,25, 20, Color.web("1c89f4"));
circle.setEffect(new Lighting());
//create a timeline for moving the circle
timeline = new Timeline();
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.setAutoReverse(true);
//one can start/pause/stop/play animation by
//timeline.play();
//timeline.pause();
//timeline.stop();
//timeline.playFromStart();
//add the following keyframes to the timeline
timeline.getKeyFrames().addAll
(new KeyFrame(Duration.ZERO,
new KeyValue(circle.translateXProperty(), 0)),
new KeyFrame(new Duration(4000),
new KeyValue(circle.translateXProperty(), 205)));
getChildren().add(createNavigation());
getChildren().add(circle);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Timeline rate", timeline.rateProperty(), -4d, 4d)
//TODO it is possible to do it for integer?
);
// END REMOVE ME
}
public Watch() {
startButton = new Button(Color.web("#8cc700"), Color.web("#71a000"));
stopButton = new Button(Color.web("#AA0000"), Color.web("#660000"));
mainDial = new Dial(117, true, 12, 60, Color.RED, true);
minutesDial = new Dial(30, false, 12, 60, "minutes", Color.BLACK, false);
tenthsDial = new Dial(30, false, 12, 60, "10ths", Color.BLACK, false);
configureBackground();
myLayout();
configureListeners();
configureTimeline();
getChildren().addAll(background, minutesDial, tenthsDial, digitalClock, mainDial, startButton, stopButton);
}
public void setVideoMode(VideoMode mode) {
videoMode = mode;
monochomeMode = false;
WHITE = Color.WHITE;
switch (mode) {
case Amber:
monochomeMode = true;
WHITE = Color.web("ff8000");
break;
case Greenscreen:
monochomeMode = true;
WHITE = Color.web("0ccc68");
break;
case Monochrome:
monochomeMode = true;
break;
case Color:
useTextPalette = false;
enableVideo7 = false;
break;
case Mode7:
useTextPalette = false;
enableVideo7 = true;
break;
case Mode7TextFriendly:
useTextPalette = true;
enableVideo7 = true;
break;
case TextFriendly:
useTextPalette = true;
enableVideo7 = false;
break;
}
activePalette = useTextPalette ? TEXT_PALETTE : SOLID_PALETTE;
EmulatorUILogic.notify("Video mode: " + mode.name);
forceRefresh();
}
public static Node createIconContent() {
StackPane sp = new StackPane();
Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
rectangle.setStroke(Color.BLACK);
sp.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
Rectangle biggerRec = new Rectangle(55, 55, Color.web("#1c89f4"));
Rectangle smallerRec = new Rectangle(35, 35, Color.web("#349b00"));
sp.getChildren().addAll(rectangle, biggerRec, smallerRec);
return new Group(sp);
}
@Override public void configurationUpdated(final Configuration configuration) {
if (configuration.isRegisterShortcuts() != this.configuration.isRegisterShortcuts()) {
this.configuration.setRegisterShortcuts(configuration.isRegisterShortcuts());
updateShortcuts();
}
if (configuration.isShowBaseline() != this.configuration.isShowBaseline()) {
this.configuration.setShowBaseline(configuration.isShowBaseline());
updateBaseline();
}
if (configuration.isShowBounds() != this.configuration.isShowBounds()) {
this.configuration.setShowBounds(configuration.isShowBounds());
updateBoundsRects();
}
if (configuration.isShowRuler() != this.configuration.isShowRuler()) {
final Color color = Color.web(configuration.getRulerColor());
showGrid(configuration.isShowRuler(), configuration.getRulerSeparation(), color);
this.configuration.setShowRuler(configuration.isShowRuler());
this.configuration.setRulerSeparation(configuration.getRulerSeparation());
} else if (configuration.getRulerSeparation() != this.configuration.getRulerSeparation() && grid != null) {
grid.updateSeparation(configuration.getRulerSeparation());
this.configuration.setRulerSeparation(configuration.getRulerSeparation());
}
if (configuration.isAutoRefreshStyles() != this.configuration.isAutoRefreshStyles()) {
this.configuration.setAutoRefreshStyles(configuration.isAutoRefreshStyles());
if (this.configuration.isAutoRefreshStyles()) {
startRefresher();
} else {
refresher.finish();
}
}
if (configuration.isComponentSelectOnClick() != this.configuration.isComponentSelectOnClick()) {
this.configuration.setComponentSelectOnClick(configuration.isComponentSelectOnClick());
componentSelectOnClick(configuration.isComponentSelectOnClick());
}
if (!configuration.getRulerColor().equals(this.configuration.getRulerColor())) {
this.configuration.setRulerColor(configuration.getRulerColor());
if (grid != null)
grid.setStroke(Color.web(configuration.getRulerColor()));
}
this.configuration.setAutoRefreshSceneGraph(configuration.isAutoRefreshSceneGraph());
this.configuration.setEventLogEnabled(configuration.isEventLogEnabled());
this.configuration.setIgnoreMouseTransparent(configuration.isIgnoreMouseTransparent());
this.configuration.setCollapseContentControls(configuration.isCollapseContentControls());
this.configuration.setCollapseControls(configuration.isCollapseControls());
this.configuration.setVisibilityFilteringActive(configuration.isVisibilityFilteringActive());
this.configuration.setCSSPropertiesDetail(configuration.isCSSPropertiesDetail());
details.setShowCSSProperties(this.configuration.isCSSPropertiesDetail());
update();
}
protected void makeLocationsColors() {
try {
colorRects.clear();
locationColorsBox.getChildren().clear();
List<GeographyCode> locations = chartController.chartLocations;
if (locations == null || locationColors == null) {
return;
}
Collections.sort(locations, (GeographyCode p1, GeographyCode p2)
-> p1.getFullName().compareTo(p2.getFullName()));
for (int i = 0; i < locations.size(); i++) {
GeographyCode location = locations.get(i);
String name = location.getFullName();
String color = locationColors.get(name);
Label label = new Label(name);
Rectangle rect = new Rectangle();
rect.setWidth(15);
rect.setHeight(15);
Color c = Color.web(color);
rect.setFill(c);
FxmlControl.setTooltip(rect, new Tooltip(FxmlColor.colorNameDisplay(c)));
rect.setUserData(name);
colorRects.add(rect);
Button button = new Button();
ImageView image = new ImageView(ControlStyle.getIcon("iconPalette.png"));
image.setFitWidth(AppVariables.iconSize);
image.setFitHeight(AppVariables.iconSize);
button.setGraphic(image);
button.setOnAction((ActionEvent event) -> {
showPalette(button, message("Settings") + " - " + name);
});
button.setUserData(i);
VBox.setMargin(button, new Insets(0, 0, 0, 15));
FxmlControl.setTooltip(button, message("Palette"));
HBox line = new HBox();
line.setAlignment(Pos.CENTER_LEFT);
line.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
line.setSpacing(5);
VBox.setVgrow(line, Priority.ALWAYS);
HBox.setHgrow(line, Priority.ALWAYS);
line.getChildren().addAll(label, rect, button);
locationColorsBox.getChildren().add(line);
}
} catch (Exception e) {
logger.debug(e.toString());
}
}
@Override public void init() {
// Setup chart items
PlotItem brazil = new PlotItem("Brazil", Colors.LIGHT_BLUE.get());
PlotItem mexico = new PlotItem("Mexico", Colors.ORANGE.get());
PlotItem usa = new PlotItem("USA", Colors.ORANGE.get());
PlotItem canada = new PlotItem("Canada", Colors.LIGHT_RED.get());
PlotItem germany = new PlotItem("Germany", Color.web("#FF48C6"));
PlotItem portugal = new PlotItem("Portugal", Colors.LIGHT_BLUE.get());
PlotItem spain = new PlotItem("Spain", Colors.LIGHT_GREEN.get());
PlotItem england = new PlotItem("England", Colors.LIGHT_RED.get());
PlotItem france = new PlotItem("France", Colors.LIGHT_GREEN.get());
PlotItem southAfrica = new PlotItem("South Africa", Colors.YELLOW.get());
PlotItem angola = new PlotItem("Angola", Colors.PURPLE.get());
PlotItem morocco = new PlotItem("Morocco", Colors.YELLOW.get());
PlotItem senegal = new PlotItem("Senegal", Colors.PURPLE.get());
PlotItem mali = new PlotItem("Mali", Colors.BLUE.get());
PlotItem china = new PlotItem("China", Colors.BLUE.get());
PlotItem japan = new PlotItem("Japan", Colors.GREEN.get());
PlotItem india = new PlotItem("India", Colors.GREEN.get());
// Setup flows
brazil.addToOutgoing(portugal, 5);
brazil.addToOutgoing(france, 1);
brazil.addToOutgoing(spain, 1);
brazil.addToOutgoing(england, 1);
canada.addToOutgoing(portugal, 1);
canada.addToOutgoing(france, 5);
canada.addToOutgoing(england, 1);
mexico.addToOutgoing(portugal, 1);
mexico.addToOutgoing(france, 1);
mexico.addToOutgoing(spain, 5);
mexico.addToOutgoing(england, 1);
usa.addToOutgoing(portugal, 1);
usa.addToOutgoing(france, 1);
usa.addToOutgoing(spain, 1);
usa.addToOutgoing(england, 5);
germany.addToOutgoing(southAfrica, 5);
portugal.addToOutgoing(angola, 2);
portugal.addToOutgoing(senegal, 1);
portugal.addToOutgoing(morocco, 1);
portugal.addToOutgoing(southAfrica, 3);
france.addToOutgoing(angola, 1);
france.addToOutgoing(senegal, 3);
france.addToOutgoing(mali, 3);
france.addToOutgoing(morocco, 3);
france.addToOutgoing(southAfrica, 1);
spain.addToOutgoing(senegal, 1);
spain.addToOutgoing(morocco, 3);
spain.addToOutgoing(southAfrica, 1);
england.addToOutgoing(angola, 1);
england.addToOutgoing(senegal, 1);
england.addToOutgoing(morocco, 2);
england.addToOutgoing(southAfrica, 7);
southAfrica.addToOutgoing(china, 5);
southAfrica.addToOutgoing(india, 1);
southAfrica.addToOutgoing(japan, 3);
angola.addToOutgoing(china, 5);
angola.addToOutgoing(india, 1);
angola.addToOutgoing(japan, 3);
senegal.addToOutgoing(china, 5);
senegal.addToOutgoing(india, 1);
senegal.addToOutgoing(japan, 3);
mali.addToOutgoing(china, 5);
mali.addToOutgoing(india, 1);
mali.addToOutgoing(japan, 3);
morocco.addToOutgoing(china, 5);
morocco.addToOutgoing(india, 1);
morocco.addToOutgoing(japan, 3);
sankeyPlot = SankeyPlotBuilder.create()
.prefSize(600, 400)
.items(brazil, mexico, usa, canada,
germany,
portugal, spain, england, france,
southAfrica, angola, morocco, senegal, mali,
china, japan, india)
//.useItemColor(false)
//.itemColor(Color.RED)
.streamFillMode(StreamFillMode.GRADIENT)
//.streamColor(Color.rgb(200, 0, 0, 0.25))
//.textColor(Color.RED)
//.autoItemWidth(false)
//.itemWidth(5)
//.autoItemGap(false)
//.itemGap(10)
//.showFlowDirection(true)
.build();
}
/**
* Retrieve a Color shared preference.
*
* @param key
* the key of the preference.
*
* @return the corresponding preference value.
*/
public static Color getPreferenceColor(final String key) {
String colorString = mPrefs.get(key, (String) DEFAULT_MAP.get(key));
return Color.web(colorString);
}