Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
package interfacedemo;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.geometry.*;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;
public class InterfaceDemo extends Application {
public VBox addDock() {
VBox dock = new VBox();
dock.setPadding(new Insets(0,4,0,4));
dock.setSpacing(4);
dock.setStyle("-fx-background-color: #F5F5F5;");
TitledPane barName = new TitledPane();
barName.setText("ドック");
barName.setCollapsible(false);
barName.setAnimated(false);
TitledPane rayor = new TitledPane();
rayor.setText("レイアー");
rayor.setCollapsible(false);
rayor.setAnimated(false);
TitledPane mente = new TitledPane();
mente.setText("メンテナンス");
mente.setCollapsible(false);
mente.setAnimated(false);
dock.getChildren().addAll(barName,rayor,mente);
return dock;
}
public MenuBar addMenuBar() {
MenuBar menuBar = new MenuBar();
Menu menuFile = new Menu("ファイル");
MenuItem itemCanvas = new MenuItem("新規作成");
MenuItem itemOpen = new MenuItem("開く");
MenuItem itemSave = new MenuItem("保存");
MenuItem itemSaveAsName = new MenuItem("名前をつけて保存");
MenuItem itemPrint = new MenuItem("印刷");
MenuItem itemClose = new MenuItem("閉じる");
menuFile.getItems().addAll(
itemCanvas,itemOpen,new SeparatorMenuItem(),
itemSave,itemSaveAsName,new SeparatorMenuItem(),
itemPrint,new SeparatorMenuItem(),
itemClose);
Menu menuEdit = new Menu("編集");
MenuItem itemUndo = new MenuItem("取り消し");
MenuItem itemCut = new MenuItem("切り取り");
MenuItem itemCopy = new MenuItem("コピー");
MenuItem itemPaste = new MenuItem("貼り付け");
MenuItem itemTrim = new MenuItem("トリミング");
MenuItem itemLeftTurn = new MenuItem("左回転");
MenuItem itemRightTurn = new MenuItem("右回転");
MenuItem itemReverse = new MenuItem("左右反転");
MenuItem itemCanvasSize = new MenuItem("キャンバスサイズの変更");
MenuItem itemGroup = new MenuItem("グループ化");
menuEdit.getItems().addAll(
itemUndo,new SeparatorMenuItem(),
itemCut,itemCopy,itemPaste,itemTrim,new SeparatorMenuItem(),
itemLeftTurn,itemRightTurn,itemReverse,new SeparatorMenuItem(),
itemCanvasSize,itemGroup);
Menu menuLayer = new Menu("レイヤー");
MenuItem itemAdd = new MenuItem("追加");
menuLayer.getItems().add(itemAdd);
Menu menuFilter = new Menu("フィルター");
MenuItem itemGaus = new MenuItem("ガウスぼかし");
MenuItem itemGetLine = new MenuItem("線画抽出");
menuFilter.getItems().addAll(itemGaus,itemGetLine);
Menu menuSelect = new Menu("選択範囲");
MenuItem itemSelectAll = new MenuItem("全て選択");
MenuItem itemSelectClear = new MenuItem("解除");
MenuItem itemSelectReverse = new MenuItem("反転");
MenuItem itemSelectZoom = new MenuItem("拡大");
MenuItem itemSelectZoomOut = new MenuItem("縮小");
menuSelect.getItems().addAll(itemSelectAll,itemSelectClear,itemSelectReverse,
itemSelectZoom,itemSelectZoom,itemSelectZoomOut);
Menu menuRuler = new Menu("定規");
MenuItem itemHeikou = new MenuItem("平行");
MenuItem itemZyuzi = new MenuItem("十字");
MenuItem itemGrid = new MenuItem("グリッド");
menuRuler.getItems().addAll(itemHeikou,itemZyuzi,itemGrid);
Menu menuColor = new Menu("カラー");
MenuItem itemColorCircle = new MenuItem("色相環");
MenuItem itemColorPicker = new MenuItem("カラーピッカー");
menuColor.getItems().addAll(itemColorCircle,itemColorPicker);
Menu menuDisplay = new Menu("表示");
MenuItem DisplayZoom = new MenuItem("拡大表示");
MenuItem DisplayZoomOut = new MenuItem("縮小表示");
menuDisplay.getItems().addAll(DisplayZoom,DisplayZoomOut);
Menu menuTool = new Menu("ツール");
MenuItem itemPencil = new MenuItem("鉛筆");
MenuItem itemEraser = new MenuItem("消しゴム");
MenuItem itemScal = new MenuItem("定規");
MenuItem itemFinger = new MenuItem("");
MenuItem itemNuno = new MenuItem("");
MenuItem itemPastel = new MenuItem("パステル");
MenuItem itemChork = new MenuItem("チョーク");
MenuItem itemPen = new MenuItem("ペン");
MenuItem itemHude = new MenuItem("");
MenuItem itemAir = new MenuItem("エアブラシ");
MenuItem spoit = new MenuItem("スポイト");
menuTool.getItems().addAll(itemPencil,itemEraser,itemScal,
itemFinger,itemNuno,itemPastel,itemChork,itemPen,itemHude,
itemAir,spoit);
Menu menuConfig = new Menu("設定");
Menu menuWindow = new Menu("ウィンドウ");
Menu menuHelp = new Menu("ヘルプ");
menuBar.getMenus().addAll(menuFile, menuEdit, menuLayer, menuFilter,
menuSelect, menuRuler, menuColor, menuDisplay, menuTool,
menuConfig, menuWindow, menuHelp);
return menuBar;
}
public VBox addToolBar() {
VBox toolBar = new VBox();
toolBar.setPadding(new Insets(0,4,0,4));
toolBar.setSpacing(4);
toolBar.setStyle("-fx-background-color: #F5F5F5;");
//バーの表題
TitledPane barName = new TitledPane();
barName.setText("ツールバー");
barName.setCollapsible(false);
barName.setAnimated(false);
//カラー
TitledPane color = new TitledPane();
color.setAlignment(Pos.CENTER_LEFT);
color.setText("カラー");
final ColorPicker colorPicker = new ColorPicker();
colorPicker.setValue(Color.WHITE);
color.setContent(colorPicker);
color.setCollapsible(false);
color.setAnimated(false);
//ブラシ
VBox burash = new VBox();
burash.setSpacing(4);
TitledPane burashControl = new TitledPane();
burashControl.setText("ブラシコントロール");
Slider slider = new Slider();
slider.setMin(0);
slider.setMax(100);
slider.setValue(40);
slider.setShowTickLabels(true);
slider.setShowTickMarks(true);
slider.setBlockIncrement(10);
burashControl.setContent(slider);
burashControl.setCollapsible(false);
burashControl.setAnimated(false);
TitledPane burashChoser = new TitledPane();
burashChoser.setText("ブラシ");
ListView<String> burashList = new ListView<>();
ObservableList<String> items =FXCollections.observableArrayList (
"鉛筆", "消しゴム", "パステル", "","","","パステル","チョーク","ペン","エアブラシ","スポイト");
burashList.setItems(items);
burashList.setPrefHeight(160);
burashChoser.setContent(burashList);
burashChoser.setCollapsible(false);
burashChoser.setAnimated(false);
burash.getChildren().addAll(burashControl,burashChoser);
toolBar.getChildren().addAll(barName,burash,color);
return toolBar;
}
@Override
public void start(Stage stage) {
BorderPane root = new BorderPane();
MenuBar menuBar = addMenuBar();
VBox toolBar = addToolBar();
VBox paret = addDock();
GridPane canvasPane = new GridPane();
canvasPane.setAlignment(Pos.CENTER);
canvasPane.setStyle("-fx-background-color: #C0C0C0;");
Canvas canvas = new Canvas(600,400);
GraphicsContext gc = canvas.getGraphicsContext2D();
gc.setFill(Color.WHITE);
gc.fillRect(0, 0, 600, 400);
canvasPane.getChildren().add(canvas);
root.setTop(menuBar);
root.setLeft(toolBar);
root.setCenter(canvasPane);
root.setRight(paret);
Scene scene = new Scene(root,1200,700,Color.LIGHTGREY);
stage.setTitle("Circe Desktop");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment