質問するログイン新規登録

質問編集履歴

1

配列クラスを導入(そして失敗)

2018/08/28 03:10

投稿

kairi.sakusaku
kairi.sakusaku

スコア6

title CHANGED
File without changes
body CHANGED
@@ -5,22 +5,22 @@
5
5
 
6
6
  ### 該当のソースコード
7
7
 
8
- ```JAVAFX
9
8
  package b012.libro;
10
9
 
11
10
  import javafx.application.Application;
12
11
  import javafx.scene.Scene;
13
- import javafx.scene.input.MouseEvent;
12
+ import javafx.scene.input.*;
14
- import javafx.scene.layout.Pane;
13
+ import javafx.scene.layout.*;
14
+ import javafx.scene.shape.*;
15
+ import javafx.scene.control.Label;
15
16
  import javafx.scene.paint.Color;
17
+ import javafx.scene.ImageCursor;
16
- import javafx.scene.shape.*;
18
+ import javafx.scene.image.Image;
17
19
  import javafx.stage.Stage;
18
- import javafx.scene.input.KeyEvent;
19
- import javafx.scene.input.KeyCode;
20
+ import java.io.File;
20
- import javafx.scene.control.Label;
21
- import javafx.scene.layout.BorderPane;
22
21
 
23
22
 
23
+
24
24
  public class App extends Application {
25
25
  Color cc = Color.YELLOW;
26
26
  String Stb="Set Total Bolts:";
@@ -30,6 +30,7 @@
30
30
  int Boltno;
31
31
  int[] Boltx=new int[1000];
32
32
  int[] Bolty=new int[1000];
33
+ Path[] p = new Path[1000];
33
34
 
34
35
  public static void main(String[] args) {
35
36
  launch(args);
@@ -39,11 +40,16 @@
39
40
  public void start(Stage stage) {
40
41
  label = new Label( Stb + Boltno+ " " + Colorname+ "/");
41
42
  BorderPane root = new BorderPane();
43
+ String uri = new File("img/cursor.png").toURI().toString();
44
+ Image img = new Image( uri );
45
+ ImageCursor cursor = new ImageCursor( img , img.getWidth() / 2 , img.getHeight() );
42
46
 
43
47
  root.setTop(label);
44
48
  Scene scene = new Scene(root,300,300);
45
49
  scene.setOnMouseClicked(event -> CreateBolt(root,event));
46
50
  scene.setOnKeyPressed(event -> change(event));
51
+
52
+ scene.setCursor( cursor );
47
53
  stage.setScene(scene);
48
54
  stage.setTitle("B012 TEST Ver0.5");
49
55
  stage.show();
@@ -80,26 +86,27 @@
80
86
  Boltx[Boltno]=x;
81
87
  Bolty[Boltno]=y;
82
88
  Boltno++;
83
-
89
+ int p[B]=Boltno;
90
+
84
91
  //Totalno(x,y);
85
- Path path = new Path();
92
+ p[B] = new p();
86
93
  MoveTo b00 = new MoveTo(x-20,y+0);
87
- path.getElements().add(b00);
94
+ p[B].getElements().add(b00);
88
- LineTo b01 = new LineTo(x-10,y-10);
95
+ p[B]To b01 = new LineTo(x-10,y-10);
89
96
  path.getElements().add(b01);
90
97
  LineTo b02 = new LineTo(x+10,y-10);
91
98
  path.getElements().add(b02);
92
99
  LineTo b03 = new LineTo(x+20,y+0);
93
- path.getElements().add(b03);
100
+ p[B].getElements().add(b03);
94
101
  LineTo b04 = new LineTo(x+10,y+10);
95
- path.getElements().add(b04);
102
+ p[B].getElements().add(b04);
96
103
  LineTo b05 = new LineTo(x-10,y+10);
97
- path.getElements().add(b05);
104
+ p[B].getElements().add(b05);
98
- path.getElements().add(new ClosePath());
105
+ p[B].getElements().add(new ClosePath());
99
- path.setFill(cc);
106
+ p[B].setFill(cc);
100
- path.setStroke(Color.BLACK);
107
+ p[B].setStroke(Color.BLACK);
101
- path.setStrokeWidth(2);
108
+ p[B].setStrokeWidth(2);
102
- root.getChildren().add(path);
109
+ root.getChildren().add(p[B]);
103
110
 
104
111
 
105
112
 
@@ -135,17 +142,15 @@
135
142
  }
136
143
  ```
137
144
 
138
- ### 実現してこと
145
+ ### 実現してこと
139
146
 
140
147
  *クリックすると六角形を表示。各図形の座標は配列で管理。
141
148
  *ファンクションキーのF1-F3で色分け。
142
149
  *配列をForで参照、同じ位置に図形が配置されないようにする。
143
150
  (既に置かれてる場合Already set:図形番号 が表示)
144
151
 
145
- ### わからないながらも推測するのは
152
+ ### わからないこと
146
- transformを使う前提でpathの配列化?
153
+ transformを使う前提でpathの配列化?をしてみたのですが、エラー多発・。
147
- ただその場合に、どう表記するかがよく分かってません。
148
- (文字や数字変数の配列化がやっと出来るレベルの知識なので)
149
154
 
150
155
  ### 補足情報(FW/ツールのバージョンなど)
151
156