• R/O
  • SSH

Commit

Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Commit MetaInfo

Revisiond0dce7de86b04ac1220a610d64c5566b0f4c0c69 (tree)
Zeit2015-07-02 07:22:39
AutorMirrgieRiana
CommiterMirrgieRiana

Log Message

add mirrg.canvas.chrome

Ändern Zusammenfassung

Diff

diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/.classpath
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/.classpath Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,8 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<classpath>
3+ <classpathentry kind="src" path="src"/>
4+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5+ <classpathentry combineaccessrules="false" kind="src" path="/mirrg.applet.bismuth"/>
6+ <classpathentry combineaccessrules="false" kind="src" path="/mirrg.event.bismuth"/>
7+ <classpathentry kind="output" path="bin"/>
8+</classpath>
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/.project
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/.project Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,17 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<projectDescription>
3+ <name>mirrg.canvas.chrome</name>
4+ <comment></comment>
5+ <projects>
6+ </projects>
7+ <buildSpec>
8+ <buildCommand>
9+ <name>org.eclipse.jdt.core.javabuilder</name>
10+ <arguments>
11+ </arguments>
12+ </buildCommand>
13+ </buildSpec>
14+ <natures>
15+ <nature>org.eclipse.jdt.core.javanature</nature>
16+ </natures>
17+</projectDescription>
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/ChromeCanvasStandard.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/ChromeCanvasStandard.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,130 @@
1+package mirrg.cr.canvas;
2+
3+import java.awt.Graphics2D;
4+
5+import mirrg.applet.bismuth.event.BiEvent;
6+import mirrg.applet.bismuth.event.BiEventApplet;
7+import mirrg.applet.bismuth.event.BiEventComponent;
8+import mirrg.applet.bismuth.gamethread.BiEventGameThread;
9+import mirrg.cr.canvas.GadgetCanvasGrid.IFunction;
10+import mirrg.cr.canvas.GadgetCanvasPainter.IColorProvider;
11+import mirrg.cr.canvas.coord.CoordinatesConverterXYZoom;
12+import mirrg.cr.canvas.core.BiEventChromeCanvas;
13+import mirrg.cr.canvas.core.ChromeCanvasBase;
14+import mirrg.event.bismuth.BiHandler;
15+
16+public abstract class ChromeCanvasStandard
17+ extends ChromeCanvasBase<CoordinatesConverterXYZoom, BiEvent>
18+{
19+
20+ protected GadgetCanvasMove gadgetCanvasMove;
21+ protected GadgetCanvasZoom gadgetCanvasZoom;
22+ protected GadgetCanvasPainter gadgetCanvasPainter;
23+ protected GadgetCanvasGrid gadgetCanvasGrid;
24+
25+ //
26+
27+ @Override
28+ public CoordinatesConverterXYZoom getCoordinatesConverter()
29+ {
30+ return cc;
31+ }
32+
33+ //
34+
35+ @BiHandler
36+ public void handle(BiEventApplet.Init event)
37+ {
38+ super.handle(event);
39+
40+ cc = new CoordinatesConverterXYZoom();
41+ cc.width = getWidth();
42+ cc.height = getHeight();
43+
44+ gadgetCanvasMove = new GadgetCanvasMove();
45+ gadgetCanvasMove.init(getEventManager());
46+
47+ gadgetCanvasZoom = new GadgetCanvasZoom();
48+ gadgetCanvasZoom.init(getEventManager());
49+
50+ gadgetCanvasPainter = new GadgetCanvasPainter();
51+ gadgetCanvasPainter.init(getEventManager());
52+ gadgetCanvasPainter.colorProvider = getColorProvider();
53+
54+ gadgetCanvasGrid = new GadgetCanvasGrid();
55+ gadgetCanvasGrid.init(getEventManager());
56+ gadgetCanvasGrid.function = getFunction();
57+
58+ }
59+
60+ @BiHandler
61+ public void handle(BiEventGameThread.DoEvents event)
62+ {
63+
64+ // input & move
65+ {
66+ // reset
67+ // no task
68+
69+ // event post
70+ getEventManager().post(
71+ new BiEventChromeCanvas.DoInput<CoordinatesConverterXYZoom, BiEvent>(
72+ this));
73+
74+ // end
75+ getGadgetInputStatus().doInputEvents();
76+ }
77+
78+ // draw chrome buffer
79+ {
80+ // reset
81+ // no task
82+
83+ // event post
84+ getEventManager().post(
85+ new BiEventChromeCanvas.PaintChrome<CoordinatesConverterXYZoom, BiEvent>(
86+ this));
87+
88+ // end
89+ getGadgetPainter().getChromeDoubleBuffer().copy();
90+ }
91+
92+ // draw back buffer
93+ {
94+ Graphics2D g = getGadgetPainter().getDoubleBuffer().getGraphics();
95+
96+ // reset
97+ g.drawImage(getGadgetPainter().getChromeDoubleBuffer().getBuffer(), 0, 0, this);
98+
99+ // event post
100+ getEventManager().post(
101+ new BiEventChromeCanvas.PaintBack<CoordinatesConverterXYZoom, BiEvent>(
102+ this));
103+
104+ // end
105+ getGadgetPainter().getDoubleBuffer().flip();
106+ }
107+
108+ // paint
109+ {
110+ repaint();
111+ }
112+
113+ }
114+
115+ @BiHandler
116+ public void handle(BiEventComponent.Resized<?> event)
117+ {
118+ dirty = true;
119+
120+ cc.width = getWidth();
121+ cc.height = getHeight();
122+ }
123+
124+ //
125+
126+ protected abstract IFunction getFunction();
127+
128+ protected abstract IColorProvider getColorProvider();
129+
130+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/GadgetCanvasGrid.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/GadgetCanvasGrid.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,224 @@
1+package mirrg.cr.canvas;
2+
3+import java.awt.Color;
4+import java.awt.Font;
5+import java.awt.Graphics2D;
6+import java.awt.event.KeyEvent;
7+
8+import mirrg.applet.bismuth.input.IInputStatus;
9+import mirrg.cr.canvas.common.StaticAwt;
10+import mirrg.cr.canvas.common.StaticMath;
11+import mirrg.cr.canvas.common.StaticString;
12+import mirrg.cr.canvas.coord.CoordinatesConverterXYZoom;
13+import mirrg.cr.canvas.coord.ICoordinatesConverter;
14+import mirrg.cr.canvas.core.BiEventChromeCanvas;
15+import mirrg.event.bismuth.BiHandler;
16+import mirrg.event.bismuth.gadget.BiGadgetBase;
17+
18+public class GadgetCanvasGrid extends BiGadgetBase<GadgetCanvasGrid>
19+{
20+
21+ private static final Font font = new Font("MS Gothic", Font.BOLD, 14);
22+
23+ public boolean enabledGrid = true;
24+ public boolean enabledCursor = true;
25+
26+ public IFunction function;
27+
28+ @BiHandler
29+ public void handle(BiEventChromeCanvas.PaintBack<?, ?> event)
30+ {
31+ if (!(enabledGrid || enabledCursor)) return;
32+
33+ IChromeCanvas<?, ?> canvas = event.getChromeCanvas();
34+ ICoordinatesConverter cc = event.getChromeCanvas().getCoordinatesConverter();
35+ IInputStatus is = event.getChromeCanvas().getInputStatus();
36+
37+ Graphics2D g = event.getChromeCanvas().getBackDoubleBuffer().getGraphics();
38+
39+ // 画面の頂点における数学的座標の取得
40+ double mx1 = cc.getMxFromDx(0);
41+ double my1 = cc.getMyFromDy(0);
42+ double mx2 = cc.getMxFromDx(canvas.getWidth());
43+ double my2 = cc.getMyFromDy(canvas.getHeight());
44+
45+ // 数学的座標の反転のチェック
46+ {
47+ if (mx1 > mx2) {
48+ double tmp = mx1;
49+ mx1 = mx2;
50+ mx2 = tmp;
51+ }
52+
53+ if (my1 > my2) {
54+ double tmp = my1;
55+ my1 = my2;
56+ my2 = tmp;
57+ }
58+ }
59+
60+ // 画面の縦横の数学的大きさ
61+ final double mwidth = mx2 - mx1;
62+ final double mheight = my2 - my1;
63+
64+ // グリッド間隔の数学的距離
65+ final double gridSpaceW = StaticMath.nice(mwidth * 0.3);
66+ final double gridSpaceH = StaticMath.nice(mheight * 0.3);
67+
68+ // 有効小数点以下桁数
69+ final int effectiveDigitW = (int) (-Math.log10(gridSpaceW) + 0.9);
70+ final int effectiveDigitH = (int) (-Math.log10(gridSpaceH) + 0.9);
71+
72+ // グリッドの開始数学的座標
73+ double mgridstartx = Math.ceil(mx1 / gridSpaceW) * gridSpaceW;
74+ double mgridstarty = Math.ceil(my1 / gridSpaceH) * gridSpaceH;
75+
76+ // グリッド間隔の描画距離
77+ final double gridSpaceDispW = cc.getDxFromMx(mx1 + gridSpaceW);
78+ //final double gridSpaceDispH = cc.getDyFromMy(my1 + gridSpaceH);
79+
80+ // グリッドの終了数学的座標
81+ double mgridendx = mx2;
82+ double mgridendy = my2;
83+
84+ // lines
85+ if (enabledGrid) {
86+ g.setColor(Color.black);
87+ for (double mgridx = mgridstartx; mgridx < mgridendx; mgridx += gridSpaceW) {
88+ int dx = (int) cc.getDxFromMx(mgridx);
89+ g.drawLine(dx, 0, dx, canvas.getHeight());
90+ }
91+ for (double mgridy = mgridstarty; mgridy < mgridendy; mgridy += gridSpaceH) {
92+ int dy = (int) cc.getDyFromMy(mgridy);
93+ g.drawLine(0, dy, canvas.getWidth(), dy);
94+ }
95+ }
96+
97+ // lines cursor
98+ if (enabledCursor) {
99+ g.setColor(Color.blue);
100+
101+ {
102+ double mgridx = cc.getMxFromDx(is.getMx());
103+ int dx = (int) cc.getDxFromMx(mgridx);
104+ g.drawLine(dx, 0, dx, canvas.getHeight());
105+ }
106+
107+ {
108+ double mgridy = cc.getMyFromDy(is.getMy());
109+ int dy = (int) cc.getDyFromMy(mgridy);
110+ g.drawLine(0, dy, canvas.getWidth(), dy);
111+ }
112+
113+ }
114+
115+ // labels
116+ if (enabledGrid) {
117+ // X座標ラベルの描画位置カウンタ
118+ int drawY = 0;
119+
120+ for (double mgridx = mgridstartx; mgridx < mgridendx; mgridx += gridSpaceW) {
121+ int dx = (int) cc.getDxFromMx(mgridx);
122+ String str = StaticString.getEffectiveExpression(mgridx, effectiveDigitW);
123+
124+ g.setFont(getFont());
125+ StaticAwt.drawBoldString(g, str, dx, (1 + drawY) * g.getFont().getSize(), Color.white, Color.black);
126+
127+ int textLength = g.getFontMetrics().stringWidth(str);
128+ drawY = (drawY + 1) % (1 + (int) (textLength / gridSpaceDispW));
129+ }
130+
131+ for (double mgridy = mgridstarty; mgridy < mgridendy; mgridy += gridSpaceH) {
132+ int dy = (int) cc.getDyFromMy(mgridy);
133+ String str = StaticString.getEffectiveExpression(mgridy, effectiveDigitH);
134+
135+ g.setFont(getFont());
136+ StaticAwt.drawBoldString(g, str, 0, dy + g.getFont().getSize(), Color.white, Color.black);
137+ }
138+ }
139+
140+ // labels cursor
141+ if (enabledCursor) {
142+
143+ if (function != null) {
144+ double[] value = function.getValue(
145+ cc.getMxFromDx(is.getMx()), cc.getMyFromDy(is.getMy()));
146+
147+ {
148+ String str = "Re: " + value[0];
149+
150+ g.setFont(getFont());
151+ StaticAwt.drawBoldString(g, str,
152+ is.getMx() + 2,
153+ is.getMy() - 2 - g.getFont().getSize() * 3,
154+ Color.white, Color.black);
155+ }
156+ {
157+ String str = "Im: " + value[1];
158+
159+ g.setFont(getFont());
160+ StaticAwt.drawBoldString(g, str,
161+ is.getMx() + 2,
162+ is.getMy() - 2 - g.getFont().getSize() * 2,
163+ Color.white, Color.black);
164+ }
165+ }
166+
167+ {
168+ double mgridx = cc.getMxFromDx(is.getMx());
169+
170+ String str = "X: " + StaticString.getEffectiveExpression(
171+ mgridx, effectiveDigitW + 4);
172+
173+ g.setFont(getFont());
174+ StaticAwt.drawBoldString(g, str,
175+ is.getMx() + 2,
176+ is.getMy() - 2 - g.getFont().getSize(),
177+ Color.white, Color.black);
178+ }
179+
180+ {
181+ double mgridy = cc.getMyFromDy(is.getMy());
182+
183+ String str = "Y: " + StaticString.getEffectiveExpression(
184+ mgridy, effectiveDigitH + 4);
185+
186+ g.setFont(getFont());
187+ StaticAwt.drawBoldString(g, str,
188+ is.getMx() + 2,
189+ is.getMy() - 2,
190+ Color.white, Color.black);
191+ }
192+
193+ }
194+
195+ }
196+
197+ @BiHandler
198+ public void handle(BiEventChromeCanvas.DoInput<CoordinatesConverterXYZoom, ?> event)
199+ {
200+ IInputStatus is = event.getChromeCanvas().getInputStatus();
201+
202+ if (is.getKb(KeyEvent.VK_G) == 1) {
203+ if (is.getKb(KeyEvent.VK_CONTROL) <= 0) {
204+ enabledGrid = !enabledGrid;
205+ }
206+ if (is.getKb(KeyEvent.VK_SHIFT) <= 0) {
207+ enabledCursor = !enabledCursor;
208+ }
209+ }
210+ }
211+
212+ protected Font getFont()
213+ {
214+ return font;
215+ }
216+
217+ public static interface IFunction
218+ {
219+
220+ public double[] getValue(double r, double i);
221+
222+ }
223+
224+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/GadgetCanvasMove.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/GadgetCanvasMove.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,81 @@
1+package mirrg.cr.canvas;
2+
3+import java.awt.event.MouseEvent;
4+
5+import mirrg.applet.bismuth.input.IInputStatus;
6+import mirrg.cr.canvas.coord.CoordinatesConverterXYZoom;
7+import mirrg.cr.canvas.core.BiEventChromeCanvas;
8+import mirrg.event.bismuth.BiHandler;
9+import mirrg.event.bismuth.gadget.BiGadgetBase;
10+
11+/**
12+ * 中央クリック移動
13+ */
14+public class GadgetCanvasMove extends BiGadgetBase<GadgetCanvasMove>
15+{
16+
17+ public int button;
18+
19+ public GadgetCanvasMove()
20+ {
21+ this(MouseEvent.BUTTON2);
22+ }
23+
24+ public GadgetCanvasMove(int button)
25+ {
26+ this.button = button;
27+ }
28+
29+ @BiHandler
30+ public void handle(BiEventChromeCanvas.DoInput<CoordinatesConverterXYZoom, BiEvent> event)
31+ {
32+ IChromeCanvas<CoordinatesConverterXYZoom, BiEvent> canvas = event.getChromeCanvas();
33+ CoordinatesConverterXYZoom cc = event.getChromeCanvas().getCoordinatesConverter();
34+ IInputStatus is = event.getChromeCanvas().getInputStatus();
35+
36+ if (is.getMb(button) >= 2) {
37+ int dmx = is.getMx() - is.getMmx();
38+ int dmy = is.getMy() - is.getMmy();
39+
40+ if (dmx != 0 || dmy != 0) {
41+ cc.cx -= dmx / cc.zoomX;
42+ cc.cy -= dmy / cc.zoomY;
43+
44+ canvas.setDirty(true);
45+
46+ canvas.getChromeDoubleBuffer().rollback(dmx, dmy);
47+
48+ canvas.getEventPoster().post(new BiEvent.Moved(dmx, dmy));
49+ }
50+ }
51+ }
52+
53+ public static class BiEvent extends mirrg.applet.bismuth.event.BiEvent
54+ {
55+
56+ public static class Moved extends BiEvent
57+ {
58+
59+ private int dmx, dmy;
60+
61+ public Moved(int dmx, int dmy)
62+ {
63+ this.dmx = dmx;
64+ this.dmy = dmy;
65+ }
66+
67+ public int getDmx()
68+ {
69+ return dmx;
70+ }
71+
72+ public int getDmy()
73+ {
74+ return dmy;
75+ }
76+
77+ }
78+
79+ }
80+
81+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/GadgetCanvasPainter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/GadgetCanvasPainter.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,98 @@
1+package mirrg.cr.canvas;
2+
3+import java.awt.image.BufferedImage;
4+
5+import mirrg.cr.canvas.coord.ICoordinatesConverter;
6+import mirrg.cr.canvas.core.BiEventChromeCanvas;
7+import mirrg.event.bismuth.BiHandler;
8+import mirrg.event.bismuth.gadget.BiGadgetBase;
9+
10+public class GadgetCanvasPainter extends BiGadgetBase<GadgetCanvasPainter>
11+{
12+
13+ private int y = 0;
14+ private int clearStart = 0;
15+ private boolean dirty = true;
16+ public IColorProvider colorProvider;
17+
18+ @BiHandler
19+ public void handle(BiEventChromeCanvas.PaintChrome<?, BiEvent> event)
20+ {
21+ IChromeCanvas<?, BiEvent> canvas = event.getChromeCanvas();
22+ ICoordinatesConverter cc = event.getChromeCanvas().getCoordinatesConverter();
23+ BufferedImage buffer = event.getChromeCanvas().getChromeDoubleBuffer().getBuffer();
24+
25+ if (canvas.isDirty()) {
26+ canvas.setDirty(false);
27+
28+ if (!dirty) {
29+ dirty = true;
30+ canvas.getEventPoster().post(new BiEvent.Start());
31+ }
32+ clearStart = y;
33+ }
34+
35+ if (dirty) {
36+
37+ long startTime = System.currentTimeMillis();
38+
39+ do {
40+
41+ paintLine(y, cc, buffer);
42+
43+ y++;
44+ if (y >= buffer.getHeight()) {
45+ y = 0;
46+ }
47+
48+ if (clearStart == y) {
49+ dirty = false;
50+ canvas.getEventPoster().post(new BiEvent.Finish());
51+ break;
52+ }
53+
54+ } while (startTime + 15 > System.currentTimeMillis());
55+
56+ }
57+
58+ }
59+
60+ private void paintLine(int y, ICoordinatesConverter cc, BufferedImage buffer)
61+ {
62+ if (colorProvider != null) {
63+ for (int x = 0; x < buffer.getWidth(); x++) {
64+
65+ try {
66+ buffer.setRGB(x, y, colorProvider.getColorFromComplex(
67+ cc.getMxFromDx(x),
68+ cc.getMyFromDy(y)));
69+ } catch (ArrayIndexOutOfBoundsException e) {
70+ }
71+
72+ }
73+ }
74+ }
75+
76+ public static class BiEvent extends mirrg.applet.bismuth.event.BiEvent
77+ {
78+
79+ public static class Start extends BiEvent
80+ {
81+
82+ }
83+
84+ public static class Finish extends BiEvent
85+ {
86+
87+ }
88+
89+ }
90+
91+ public static interface IColorProvider
92+ {
93+
94+ public int getColorFromComplex(double r, double i);
95+
96+ }
97+
98+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/GadgetCanvasZoom.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/GadgetCanvasZoom.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,75 @@
1+package mirrg.cr.canvas;
2+
3+import java.awt.event.KeyEvent;
4+
5+import mirrg.applet.bismuth.input.IInputStatus;
6+import mirrg.cr.canvas.coord.CoordinatesConverterXYZoom;
7+import mirrg.cr.canvas.core.BiEventChromeCanvas;
8+import mirrg.event.bismuth.BiHandler;
9+import mirrg.event.bismuth.gadget.BiGadgetBase;
10+
11+/**
12+ * 拡大縮小
13+ */
14+public class GadgetCanvasZoom extends BiGadgetBase<GadgetCanvasZoom>
15+{
16+
17+ public double wheelRate;
18+
19+ public GadgetCanvasZoom()
20+ {
21+ this(1.1);
22+ }
23+
24+ public GadgetCanvasZoom(double wheelRate)
25+ {
26+ this.wheelRate = wheelRate;
27+ }
28+
29+ @BiHandler
30+ public void handle(BiEventChromeCanvas.DoInput<CoordinatesConverterXYZoom, ?> event)
31+ {
32+ IChromeCanvas<CoordinatesConverterXYZoom, ?> canvas = event.getChromeCanvas();
33+ CoordinatesConverterXYZoom cc = event.getChromeCanvas().getCoordinatesConverter();
34+ IInputStatus is = event.getChromeCanvas().getInputStatus();
35+
36+ int dmw = is.getMw() - is.getMmw();
37+
38+ if (dmw != 0) {
39+ double rate2X = 1;
40+ double rate2Y = 1;
41+
42+ if (is.getKb(KeyEvent.VK_CONTROL) <= 0) {
43+ rate2X = Math.pow(wheelRate, -dmw);
44+ cc.cx += (is.getMx() - cc.width / 2) / cc.zoomX;
45+ cc.zoomX *= rate2X;
46+ cc.cx -= (is.getMx() - cc.width / 2) / cc.zoomX;
47+ }
48+
49+ if (is.getKb(KeyEvent.VK_SHIFT) <= 0) {
50+ rate2Y = Math.pow(wheelRate, -dmw);
51+ cc.cy += (is.getMy() - cc.height / 2) / cc.zoomY;
52+ cc.zoomY *= rate2Y;
53+ cc.cy -= (is.getMy() - cc.height / 2) / cc.zoomY;
54+ }
55+
56+ canvas.setDirty(true);
57+
58+ canvas.getChromeDoubleBuffer().rollback(
59+ (int) (is.getMx() * (1 - rate2X)),
60+ (int) (is.getMy() * (1 - rate2Y)),
61+ (int) (cc.width * rate2X),
62+ (int) (cc.height * rate2Y));
63+ }
64+
65+ if (is.getKb(KeyEvent.VK_Z) == 1) {
66+ cc.zoomX = -cc.zoomX;
67+ canvas.setDirty(true);
68+ }
69+ if (is.getKb(KeyEvent.VK_X) == 1) {
70+ cc.zoomY = -cc.zoomY;
71+ canvas.setDirty(true);
72+ }
73+
74+ }
75+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/IChromeCanvas.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/IChromeCanvas.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,29 @@
1+package mirrg.cr.canvas;
2+
3+import mirrg.applet.bismuth.doublebuffer.IDoubleBuffer;
4+import mirrg.applet.bismuth.input.IInputStatus;
5+import mirrg.cr.canvas.coord.ICoordinatesConverter;
6+import mirrg.event.bismuth.IBiEventPoster;
7+
8+public interface IChromeCanvas<C extends ICoordinatesConverter, E>
9+{
10+
11+ public C getCoordinatesConverter();
12+
13+ public IInputStatus getInputStatus();
14+
15+ public IDoubleBuffer getChromeDoubleBuffer();
16+
17+ public IDoubleBuffer getBackDoubleBuffer();
18+
19+ public IBiEventPoster<? super E> getEventPoster();
20+
21+ public boolean isDirty();
22+
23+ public void setDirty(boolean dirty);
24+
25+ public int getHeight();
26+
27+ public int getWidth();
28+
29+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/bi/BismuthAppletChrome.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/bi/BismuthAppletChrome.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,34 @@
1+package mirrg.cr.canvas.bi;
2+
3+import mirrg.applet.bismuth.GadgetProviderGameThreadFPS;
4+import mirrg.applet.bismuth.GadgetProviderInputStatus;
5+import mirrg.applet.bismuth.core.BismuthApplet;
6+
7+public class BismuthAppletChrome
8+ extends BismuthApplet<GadgetProviderPainterChrome, GadgetProviderGameThreadFPS, GadgetProviderInputStatus>
9+{
10+
11+ protected void initPainter()
12+ {
13+ GadgetProviderPainterChrome painter = new GadgetProviderPainterChrome();
14+ painter.getGadget().init(getEventManager());
15+ painter.init(getWidth(), getHeight());
16+ this.gadgetPainter = painter;
17+ }
18+
19+ protected void initGameThread()
20+ {
21+ GadgetProviderGameThreadFPS gameThread = new GadgetProviderGameThreadFPS();
22+ gameThread.getGadget().init(getEventManager());
23+ gameThread.getEventRegister().register(this);
24+ this.gadgetGameThread = gameThread;
25+ }
26+
27+ protected void initInputStatus()
28+ {
29+ GadgetProviderInputStatus inputStatus = new GadgetProviderInputStatus();
30+ inputStatus.getGadget().init(getEventManager());
31+ this.gadgetInputStatus = inputStatus;
32+ }
33+
34+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/bi/GadgetProviderPainterChrome.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/bi/GadgetProviderPainterChrome.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,32 @@
1+package mirrg.cr.canvas.bi;
2+
3+import java.awt.Graphics2D;
4+import java.awt.image.BufferedImage;
5+import java.awt.image.ImageObserver;
6+
7+import mirrg.applet.bismuth.GadgetProviderPainterTripleBuffered;
8+import mirrg.applet.bismuth.doublebuffer.DoubleBuffer;
9+
10+public class GadgetProviderPainterChrome
11+ extends GadgetProviderPainterTripleBuffered
12+{
13+
14+ protected final DoubleBuffer chromeDoubleBuffer = new DoubleBuffer();
15+
16+ public DoubleBuffer getChromeDoubleBuffer()
17+ {
18+ return chromeDoubleBuffer;
19+ }
20+
21+ protected void rebuffer(int width, int height)
22+ {
23+ chromeDoubleBuffer.rebuffer(width, height, BufferedImage.TYPE_INT_RGB);
24+ super.rebuffer(width, height);
25+ }
26+
27+ public void print(Graphics2D g, ImageObserver imageObserver)
28+ {
29+ super.print(g, imageObserver);
30+ }
31+
32+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/common/StaticAwt.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/common/StaticAwt.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,23 @@
1+package mirrg.cr.canvas.common;
2+
3+import java.awt.Color;
4+import java.awt.Graphics2D;
5+
6+public class StaticAwt
7+{
8+
9+ /**
10+ * 1ピクセルの枠が付いた文字列を色を指定して描画する。
11+ */
12+ public static void drawBoldString(Graphics2D g, String str, int x, int y, Color borderColor, Color fillColor)
13+ {
14+ g.setColor(borderColor);
15+ g.drawString(str, x + 1, y);
16+ g.drawString(str, x - 1, y);
17+ g.drawString(str, x, y + 1);
18+ g.drawString(str, x, y - 1);
19+ g.setColor(fillColor);
20+ g.drawString(str, x, y);
21+ }
22+
23+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/common/StaticMath.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/common/StaticMath.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,42 @@
1+package mirrg.cr.canvas.common;
2+
3+public class StaticMath
4+{
5+
6+ /**
7+ * log e 10
8+ */
9+ public static final double LOG_10 = Math.log(10);
10+
11+ /**
12+ * log 10 2
13+ */
14+ public static final double LOG_10_2 = Math.log(2) / LOG_10;
15+
16+ /**
17+ * log 10 5
18+ */
19+ public static final double LOG_10_5 = Math.log(5) / LOG_10;
20+
21+ /**
22+ * 与えた数をきりのいい数にする。
23+ */
24+ public static double nice(double mspace)
25+ {
26+ double log10 = Math.log10(mspace);
27+
28+ double integerNumber = Math.floor(log10);
29+ double mod = log10 - integerNumber;
30+
31+ if (mod > LOG_10_5) {
32+ mod = LOG_10_5;
33+ } else if (mod > LOG_10_2) {
34+ mod = LOG_10_2;
35+ } else {
36+ mod = 0;
37+ }
38+
39+ return Math.pow(10, integerNumber + mod);
40+ }
41+
42+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/common/StaticString.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/common/StaticString.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,21 @@
1+package mirrg.cr.canvas.common;
2+
3+public class StaticString
4+{
5+
6+ /**
7+ * 小数点以下n桁まで表示する文字列を返す。
8+ *
9+ * @param effectiveDigit
10+ * n
11+ */
12+ public static String getEffectiveExpression(double value, int effectiveDigit)
13+ {
14+ if (effectiveDigit < 0) {
15+ return String.format("%.0f", value);
16+ } else {
17+ return String.format("%." + effectiveDigit + "f", value);
18+ }
19+ }
20+
21+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/coord/CoordinatesConverterXYZoom.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/coord/CoordinatesConverterXYZoom.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,37 @@
1+package mirrg.cr.canvas.coord;
2+
3+public class CoordinatesConverterXYZoom implements ICoordinatesConverter
4+{
5+
6+ public double zoomX = 100;
7+ public double zoomY = 100;
8+ public double cx = 0.0;
9+ public double cy = 0.0;
10+ public double width = 200;
11+ public double height = 200;
12+
13+ @Override
14+ public double getMxFromDx(double dx)
15+ {
16+ return cx + (dx - width / 2) / zoomX;
17+ }
18+
19+ @Override
20+ public double getMyFromDy(double dy)
21+ {
22+ return -(cy + (dy - height / 2) / zoomY);
23+ }
24+
25+ @Override
26+ public double getDxFromMx(double mx)
27+ {
28+ return (mx - cx) * zoomX + width / 2;
29+ }
30+
31+ @Override
32+ public double getDyFromMy(double my)
33+ {
34+ return (-my - cy) * zoomY + height / 2;
35+ }
36+
37+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/coord/ICoordinatesConverter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/coord/ICoordinatesConverter.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,14 @@
1+package mirrg.cr.canvas.coord;
2+
3+public interface ICoordinatesConverter
4+{
5+
6+ public double getMxFromDx(double dx);
7+
8+ public double getMyFromDy(double dy);
9+
10+ public double getDxFromMx(double mx);
11+
12+ public double getDyFromMy(double my);
13+
14+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/core/BiEventChromeCanvas.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/core/BiEventChromeCanvas.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,46 @@
1+package mirrg.cr.canvas.core;
2+
3+import mirrg.applet.bismuth.event.BiEvent;
4+import mirrg.cr.canvas.IChromeCanvas;
5+import mirrg.cr.canvas.coord.ICoordinatesConverter;
6+
7+public class BiEventChromeCanvas<C extends ICoordinatesConverter, E> extends BiEvent
8+{
9+
10+ private final IChromeCanvas<C, E> canvas;
11+
12+ public IChromeCanvas<C, E> getChromeCanvas()
13+ {
14+ return canvas;
15+ }
16+
17+ public BiEventChromeCanvas(IChromeCanvas<C, E> canvas)
18+ {
19+ this.canvas = canvas;
20+ }
21+
22+ public static class DoInput<C extends ICoordinatesConverter, E> extends BiEventChromeCanvas<C, E>
23+ {
24+ public DoInput(IChromeCanvas<C, E> canvas)
25+ {
26+ super(canvas);
27+ }
28+ }
29+
30+ public static class PaintChrome<C extends ICoordinatesConverter, E> extends BiEventChromeCanvas<C, E>
31+ {
32+ public PaintChrome(IChromeCanvas<C, E> canvas)
33+ {
34+ super(canvas);
35+ }
36+ }
37+
38+ public static class PaintBack<C extends ICoordinatesConverter, E> extends BiEventChromeCanvas<C, E>
39+ {
40+ public PaintBack(IChromeCanvas<C, E> canvas)
41+ {
42+ super(canvas);
43+ }
44+ }
45+
46+}
diff -r 12dd4246c6a6 -r d0dce7de86b0 mirrg.canvas.chrome/src/mirrg/cr/canvas/core/ChromeCanvasBase.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mirrg.canvas.chrome/src/mirrg/cr/canvas/core/ChromeCanvasBase.java Thu Jul 02 07:22:39 2015 +0900
@@ -0,0 +1,61 @@
1+package mirrg.cr.canvas.core;
2+
3+import mirrg.applet.bismuth.doublebuffer.IDoubleBuffer;
4+import mirrg.applet.bismuth.event.BiEvent;
5+import mirrg.applet.bismuth.input.IInputStatus;
6+import mirrg.cr.canvas.IChromeCanvas;
7+import mirrg.cr.canvas.bi.BismuthAppletChrome;
8+import mirrg.cr.canvas.coord.ICoordinatesConverter;
9+import mirrg.event.bismuth.IBiEventPoster;
10+
11+public abstract class ChromeCanvasBase<C extends ICoordinatesConverter, E extends BiEvent>
12+ extends BismuthAppletChrome
13+ implements IChromeCanvas<C, E>
14+{
15+
16+ protected C cc;
17+ protected boolean dirty = true;
18+
19+ @Override
20+ public C getCoordinatesConverter()
21+ {
22+ return cc;
23+ }
24+
25+ @Override
26+ public IInputStatus getInputStatus()
27+ {
28+ return gadgetInputStatus.getInputStatus();
29+ }
30+
31+ @Override
32+ public IDoubleBuffer getChromeDoubleBuffer()
33+ {
34+ return gadgetPainter.getChromeDoubleBuffer();
35+ }
36+
37+ @Override
38+ public IDoubleBuffer getBackDoubleBuffer()
39+ {
40+ return gadgetPainter.getDoubleBuffer();
41+ }
42+
43+ @Override
44+ public IBiEventPoster<? super E> getEventPoster()
45+ {
46+ return getEventManager();
47+ }
48+
49+ @Override
50+ public boolean isDirty()
51+ {
52+ return dirty;
53+ }
54+
55+ @Override
56+ public void setDirty(boolean dirty)
57+ {
58+ this.dirty = dirty;
59+ }
60+
61+}