From 443c6f7e0cca910187737186c6d3e9a2e6f0053d Mon Sep 17 00:00:00 2001 From: "u6k.yu1" Date: Sat, 30 Oct 2010 21:29:20 +0900 Subject: [PATCH 1/1] =?utf8?q?=E5=88=9D=E6=9C=9F=E3=82=A4=E3=83=B3?= =?utf8?q?=E3=83=9D=E3=83=BC=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- online-stg-env/.checkstyle | 9 + online-stg-env/.classpath | 7 + online-stg-env/.fbprefs | 109 +++++++++ online-stg-env/.project | 29 +++ online-stg-env/LICENSE.txt | 30 +++ online-stg-env/pom.xml | 84 +++++++ .../u6k/online_stg_env/DataCommandDialog.java | 70 ++++++ .../java_conf/u6k/online_stg_env/DrawCanvas.java | 147 ++++++++++++ .../java_conf/u6k/online_stg_env/DrawEditor.java | 55 +++++ .../gr/java_conf/u6k/online_stg_env/HashUtil.java | 126 ++++++++++ .../gr/java_conf/u6k/online_stg_env/HttpUtil.java | 195 ++++++++++++++++ .../u6k/online_stg_env/ImmutableDimension.java | 34 +++ .../u6k/online_stg_env/ImmutablePoint.java | 34 +++ .../u6k/online_stg_env/ImmutableRectangle.java | 81 +++++++ .../java_conf/u6k/online_stg_env/LoginDialog.java | 117 ++++++++++ .../u6k/online_stg_env/OnlineStgEditor.java | 127 ++++++++++ .../u6k/online_stg_env/ShapeChooserDialog.java | 250 ++++++++++++++++++++ .../u6k/online_stg_env/ShapeListDialog.java | 98 ++++++++ .../u6k/online_stg_env/ShapePropertyDialog.java | 259 +++++++++++++++++++++ .../u6k/online_stg_env/SimpleErrorDialog.java | 250 ++++++++++++++++++++ .../online_stg_env/SimpleErrorDialog.properties | 6 + .../data/CurrentShapeChangeEvent.java | 25 ++ .../u6k/online_stg_env/data/DataCommand.java | 14 ++ .../online_stg_env/data/DataCommandAddEvent.java | 16 ++ .../online_stg_env/data/DataCommandContainer.java | 70 ++++++ .../data/DataCommandContainerListener.java | 10 + .../u6k/online_stg_env/data/DataCommandInput.java | 119 ++++++++++ .../u6k/online_stg_env/data/DataCommandOutput.java | 94 ++++++++ .../online_stg_env/data/DataCommandPurgeEvent.java | 18 ++ .../u6k/online_stg_env/data/DataContainer.java | 60 +++++ .../online_stg_env/data/DataContainerListener.java | 8 + .../u6k/online_stg_env/data/ShapeAddCommand.java | 56 +++++ .../u6k/online_stg_env/data/ShapeAddEvent.java | 18 ++ .../u6k/online_stg_env/data/ShapeContainer.java | 113 +++++++++ .../data/ShapeContainerListener.java | 10 + .../u6k/online_stg_env/data/ShapeInput.java | 119 ++++++++++ .../u6k/online_stg_env/data/ShapeOutput.java | 94 ++++++++ .../data/ShapePropertyChangeCommand.java | 54 +++++ .../online_stg_env/data/ShapeRemoveCommand.java | 55 +++++ .../u6k/online_stg_env/data/ShapeRemoveEvent.java | 25 ++ .../u6k/online_stg_env/shape/BackgroundShape.java | 132 +++++++++++ .../u6k/online_stg_env/shape/BaseShape.java | 21 ++ .../online_stg_env/shape/FreehandLineShape.java | 166 +++++++++++++ .../u6k/online_stg_env/shape/LineShape.java | 189 +++++++++++++++ .../u6k/online_stg_env/shape/OvalShape.java | 223 ++++++++++++++++++ .../u6k/online_stg_env/shape/RectangleShape.java | 222 ++++++++++++++++++ .../u6k/online_stg_env/shape/ShapeDescription.java | 19 ++ .../u6k/online_stg_env/shape/ShapeIcon.java | 17 ++ .../u6k/online_stg_env/shape/ShapeName.java | 19 ++ .../u6k/online_stg_env/shape/ShapeProperty.java | 13 ++ .../shape/ShapePropertyChangeEvent.java | 37 +++ .../shape/ShapePropertyChangeListener.java | 8 + .../shape/reflect/ShapeDescriptor.java | 85 +++++++ .../shape/reflect/ShapePropertyDescriptor.java | 114 +++++++++ .../reflect/ShapePropertyDescriptorComparator.java | 12 + online-stg-env/src/main/php/app/.htaccess | 1 + online-stg-env/src/main/php/app/common.inc | 91 ++++++++ online-stg-env/src/main/php/app/core.inc | 54 +++++ online-stg-env/src/main/php/app/get_challenge.inc | 13 ++ online-stg-env/src/main/php/app/login.inc | 56 +++++ online-stg-env/src/main/php/app/open_data_file.inc | 44 ++++ online-stg-env/src/main/php/app/read_data_file.inc | 41 ++++ .../src/main/php/app/write_data_file.inc | 45 ++++ online-stg-env/src/main/php/data/.htaccess | 1 + online-stg-env/src/main/php/foo.html | 3 + online-stg-env/src/main/php/jws/.htaccess | 1 + .../src/main/php/jws/online-stg-env.jnlp | 16 ++ online-stg-env/src/main/php/online-stg-env.php | 3 + .../src/main/resources/online-stg-env.properties | 1 + .../main/resources/resources/FreehandLineShape.gif | Bin 0 -> 925 bytes .../src/main/resources/resources/LineShape.gif | Bin 0 -> 893 bytes .../src/main/resources/resources/OvalShape.gif | Bin 0 -> 918 bytes .../main/resources/resources/RectangleShape.gif | Bin 0 -> 902 bytes online-stg-env/u6k-checkstyle-20080303.xml | 117 ++++++++++ 74 files changed, 4859 insertions(+) create mode 100644 online-stg-env/.checkstyle create mode 100644 online-stg-env/.classpath create mode 100644 online-stg-env/.fbprefs create mode 100644 online-stg-env/.project create mode 100644 online-stg-env/LICENSE.txt create mode 100644 online-stg-env/pom.xml create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DataCommandDialog.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DrawCanvas.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DrawEditor.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/HashUtil.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/HttpUtil.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutableDimension.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutablePoint.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutableRectangle.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/LoginDialog.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/OnlineStgEditor.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapeChooserDialog.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapeListDialog.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapePropertyDialog.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/SimpleErrorDialog.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/SimpleErrorDialog.properties create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/CurrentShapeChangeEvent.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommand.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandAddEvent.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandContainer.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandContainerListener.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandInput.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandOutput.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandPurgeEvent.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataContainer.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataContainerListener.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeAddCommand.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeAddEvent.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeContainer.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeContainerListener.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeInput.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeOutput.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapePropertyChangeCommand.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeRemoveCommand.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeRemoveEvent.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/BackgroundShape.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/BaseShape.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/FreehandLineShape.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/LineShape.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/OvalShape.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/RectangleShape.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeDescription.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeIcon.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeName.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeProperty.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapePropertyChangeEvent.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapePropertyChangeListener.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapeDescriptor.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapePropertyDescriptor.java create mode 100644 online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapePropertyDescriptorComparator.java create mode 100644 online-stg-env/src/main/php/app/.htaccess create mode 100644 online-stg-env/src/main/php/app/common.inc create mode 100644 online-stg-env/src/main/php/app/core.inc create mode 100644 online-stg-env/src/main/php/app/get_challenge.inc create mode 100644 online-stg-env/src/main/php/app/login.inc create mode 100644 online-stg-env/src/main/php/app/open_data_file.inc create mode 100644 online-stg-env/src/main/php/app/read_data_file.inc create mode 100644 online-stg-env/src/main/php/app/write_data_file.inc create mode 100644 online-stg-env/src/main/php/data/.htaccess create mode 100644 online-stg-env/src/main/php/foo.html create mode 100644 online-stg-env/src/main/php/jws/.htaccess create mode 100644 online-stg-env/src/main/php/jws/online-stg-env.jnlp create mode 100644 online-stg-env/src/main/php/online-stg-env.php create mode 100644 online-stg-env/src/main/resources/online-stg-env.properties create mode 100644 online-stg-env/src/main/resources/resources/FreehandLineShape.gif create mode 100644 online-stg-env/src/main/resources/resources/LineShape.gif create mode 100644 online-stg-env/src/main/resources/resources/OvalShape.gif create mode 100644 online-stg-env/src/main/resources/resources/RectangleShape.gif create mode 100644 online-stg-env/u6k-checkstyle-20080303.xml diff --git a/online-stg-env/.checkstyle b/online-stg-env/.checkstyle new file mode 100644 index 0000000..e7bfd11 --- /dev/null +++ b/online-stg-env/.checkstyle @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/online-stg-env/.classpath b/online-stg-env/.classpath new file mode 100644 index 0000000..06355fc --- /dev/null +++ b/online-stg-env/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/online-stg-env/.fbprefs b/online-stg-env/.fbprefs new file mode 100644 index 0000000..cc0769d --- /dev/null +++ b/online-stg-env/.fbprefs @@ -0,0 +1,109 @@ +#FindBugs User Preferences +#Sat Mar 08 04:37:39 JST 2008 +detectorBadAppletConstructor=BadAppletConstructor|false +detectorBadResultSetAccess=BadResultSetAccess|true +detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true +detectorBadUseOfReturnValue=BadUseOfReturnValue|true +detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true +detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true +detectorCloneIdiom=CloneIdiom|true +detectorComparatorIdiom=ComparatorIdiom|true +detectorConfusedInheritance=ConfusedInheritance|true +detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true +detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true +detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true +detectorDontUseEnum=DontUseEnum|true +detectorDroppedException=DroppedException|true +detectorDumbMethodInvocations=DumbMethodInvocations|true +detectorDumbMethods=DumbMethods|true +detectorDuplicateBranches=DuplicateBranches|true +detectorEmptyZipFileEntry=EmptyZipFileEntry|true +detectorFinalizerNullsFields=FinalizerNullsFields|true +detectorFindBadCast2=FindBadCast2|true +detectorFindBadForLoop=FindBadForLoop|true +detectorFindCircularDependencies=FindCircularDependencies|false +detectorFindDeadLocalStores=FindDeadLocalStores|true +detectorFindDoubleCheck=FindDoubleCheck|true +detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true +detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true +detectorFindFinalizeInvocations=FindFinalizeInvocations|true +detectorFindFloatEquality=FindFloatEquality|true +detectorFindHEmismatch=FindHEmismatch|true +detectorFindInconsistentSync2=FindInconsistentSync2|true +detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true +detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true +detectorFindMaskedFields=FindMaskedFields|true +detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true +detectorFindNakedNotify=FindNakedNotify|true +detectorFindNonSerializableStoreIntoSession=FindNonSerializableStoreIntoSession|true +detectorFindNonSerializableValuePassedToWriteObject=FindNonSerializableValuePassedToWriteObject|true +detectorFindNonShortCircuit=FindNonShortCircuit|true +detectorFindNullDeref=FindNullDeref|true +detectorFindOpenStream=FindOpenStream|true +detectorFindPuzzlers=FindPuzzlers|true +detectorFindRefComparison=FindRefComparison|true +detectorFindReturnRef=FindReturnRef|true +detectorFindRunInvocations=FindRunInvocations|true +detectorFindSelfComparison=FindSelfComparison|true +detectorFindSelfComparison2=FindSelfComparison2|true +detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true +detectorFindSpinLoop=FindSpinLoop|true +detectorFindSqlInjection=FindSqlInjection|true +detectorFindTwoLockWait=FindTwoLockWait|true +detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true +detectorFindUnconditionalWait=FindUnconditionalWait|true +detectorFindUninitializedGet=FindUninitializedGet|true +detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true +detectorFindUnreleasedLock=FindUnreleasedLock|true +detectorFindUnsyncGet=FindUnsyncGet|true +detectorFindUselessControlFlow=FindUselessControlFlow|true +detectorHugeSharedStringConstants=HugeSharedStringConstants|true +detectorIDivResultCastToDouble=IDivResultCastToDouble|true +detectorIncompatMask=IncompatMask|true +detectorInefficientMemberAccess=InefficientMemberAccess|false +detectorInefficientToArray=InefficientToArray|true +detectorInfiniteLoop=InfiniteLoop|true +detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true +detectorInfiniteRecursiveLoop2=InfiniteRecursiveLoop2|false +detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true +detectorInitializationChain=InitializationChain|true +detectorInstantiateStaticClass=InstantiateStaticClass|true +detectorInvalidJUnitTest=InvalidJUnitTest|true +detectorIteratorIdioms=IteratorIdioms|true +detectorLazyInit=LazyInit|true +detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true +detectorMethodReturnCheck=MethodReturnCheck|true +detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true +detectorMutableLock=MutableLock|true +detectorMutableStaticFields=MutableStaticFields|true +detectorNaming=Naming|true +detectorNumberConstructor=NumberConstructor|true +detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true +detectorPublicSemaphores=PublicSemaphores|false +detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true +detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true +detectorRedundantInterfaces=RedundantInterfaces|true +detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true +detectorSerializableIdiom=SerializableIdiom|true +detectorStartInConstructor=StartInConstructor|true +detectorStaticCalendarDetector=StaticCalendarDetector|true +detectorStringConcatenation=StringConcatenation|true +detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true +detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true +detectorSwitchFallthrough=SwitchFallthrough|true +detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true +detectorTestASM=TestASM|false +detectorURLProblems=URLProblems|true +detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true +detectorUnnecessaryMath=UnnecessaryMath|true +detectorUnreadFields=UnreadFields|true +detectorUseObjectEquals=UseObjectEquals|false +detectorUselessSubclassMethod=UselessSubclassMethod|false +detectorVarArgsProblems=VarArgsProblems|true +detectorVolatileUsage=VolatileUsage|true +detectorWaitInLoop=WaitInLoop|true +detectorWrongMapIterator=WrongMapIterator|true +detectorXMLFactoryBypass=XMLFactoryBypass|true +detector_threshold=3 +filter_settings=Low|PERFORMANCE,CORRECTNESS,I18N,MT_CORRECTNESS,BAD_PRACTICE,MALICIOUS_CODE,STYLE|false +filter_settings_neg=| diff --git a/online-stg-env/.project b/online-stg-env/.project new file mode 100644 index 0000000..8f3ce32 --- /dev/null +++ b/online-stg-env/.project @@ -0,0 +1,29 @@ + + + online-stg-env + + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder + + + + + edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder + + + + + + org.eclipse.jdt.core.javanature + com.atlassw.tools.eclipse.checkstyle.CheckstyleNature + edu.umd.cs.findbugs.plugin.eclipse.findbugsNature + + diff --git a/online-stg-env/LICENSE.txt b/online-stg-env/LICENSE.txt new file mode 100644 index 0000000..28645fd --- /dev/null +++ b/online-stg-env/LICENSE.txt @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2008 u6k.yu1@gmail.com, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact clarkware@clarkware.com. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ \ No newline at end of file diff --git a/online-stg-env/pom.xml b/online-stg-env/pom.xml new file mode 100644 index 0000000..07f73b8 --- /dev/null +++ b/online-stg-env/pom.xml @@ -0,0 +1,84 @@ + + + 4.0.0 + jp.gr.java_conf.u6k.online_stg_env + online-stg-env + jar + 1.0.0-SNAPSHOT + Online STG Environment + 「Online STG Environment」は、インターネット上でSTGを作成するための開発環境です。開発環境はJava Web Startで動作し、データはWebサーバに保存されます。Webサーバにアクセスできないときは、ローカルで開発し、Webサーバにアクセスできるときに同期することができます。ゲームはJava Web Startで動作しますが、Webサーバに接続しなくてもゲームをプレイできるように、スタンドアロン・アプリケーションとしてパッケージングすることもできます。 + 2008 + + + u6k + u6k + u6k.yu1@gmail.com + http://d.hatena.ne.jp/u6k/ + + + + + The BSD License + http://svn.sourceforge.jp/svnroot/filelock/trunk/filelock/LICENSE.txt + manual + + + + + + maven-compiler-plugin + + UTF-8 + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-antrun-plugin + + + replace-process-resources + process-resources + + run + + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + u6k-checkstyle-20080303.xml + LICENSE.txt + basedir=. + + + + org.apache.maven.plugins + maven-pmd-plugin + + true + UTF-8 + 1.5 + + + + org.codehaus.mojo + findbugs-maven-plugin + + + + diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DataCommandDialog.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DataCommandDialog.java new file mode 100644 index 0000000..827fe96 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DataCommandDialog.java @@ -0,0 +1,70 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.BorderLayout; +import java.awt.Dimension; + +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.WindowConstants; +import javax.swing.table.DefaultTableModel; + +import jp.gr.java_conf.u6k.online_stg_env.data.DataCommand; +import jp.gr.java_conf.u6k.online_stg_env.data.DataCommandAddEvent; +import jp.gr.java_conf.u6k.online_stg_env.data.DataCommandContainerListener; +import jp.gr.java_conf.u6k.online_stg_env.data.DataCommandPurgeEvent; +import jp.gr.java_conf.u6k.online_stg_env.data.DataContainer; + +public class DataCommandDialog extends JDialog { + + private JTable commandTable; + + public DataCommandDialog(JFrame owner, DataContainer dataContainer) { + super(owner, false); + + if (dataContainer == null) { + throw new NullPointerException("dataContainer == null"); + } + + this.commandTable = new JTable(new DefaultTableModel(new Object[] { "ID", "コマンド詳細" }, 0)); + this.commandTable.setDefaultEditor(Object.class, null); + JScrollPane commandTableScroll = new JScrollPane(this.commandTable); + this.getContentPane().add(commandTableScroll, BorderLayout.CENTER); + + this.setTitle("コマンド履歴 - DrawEditor"); + this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + this.setPreferredSize(new Dimension(400, 300)); + this.setLocationRelativeTo(null); + + this.pack(); + + for (DataCommand c : dataContainer.getDataCommandContainer().getCommandList()) { + this.addDataCommand(c); + } + + dataContainer.getDataCommandContainer().addListener(new DataCommandContainerListenerImpl()); + } + + private void addDataCommand(DataCommand c) { + int index = this.commandTable.getRowCount(); + + DefaultTableModel tableModel = (DefaultTableModel) this.commandTable.getModel(); + tableModel.addRow(new Object[] { index, c.getDescription() }); + } + + private class DataCommandContainerListenerImpl implements DataCommandContainerListener { + + public void commandAdd(DataCommandAddEvent event) { + DataCommandDialog.this.addDataCommand(event.getCommand()); + } + + public void commandPurge(DataCommandPurgeEvent event) { + // TODO Auto-generated method stub + + } + + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DrawCanvas.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DrawCanvas.java new file mode 100644 index 0000000..3caa3fa --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DrawCanvas.java @@ -0,0 +1,147 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.image.BufferedImage; + +import javax.swing.JPanel; + +import jp.gr.java_conf.u6k.online_stg_env.data.CurrentShapeChangeEvent; +import jp.gr.java_conf.u6k.online_stg_env.data.DataContainer; +import jp.gr.java_conf.u6k.online_stg_env.data.DataContainerListener; +import jp.gr.java_conf.u6k.online_stg_env.data.ShapeAddEvent; +import jp.gr.java_conf.u6k.online_stg_env.data.ShapeContainerListener; +import jp.gr.java_conf.u6k.online_stg_env.data.ShapeRemoveEvent; +import jp.gr.java_conf.u6k.online_stg_env.shape.BackgroundShape; +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; +import jp.gr.java_conf.u6k.online_stg_env.shape.ShapePropertyChangeEvent; +import jp.gr.java_conf.u6k.online_stg_env.shape.ShapePropertyChangeListener; + +@SuppressWarnings("serial") +public class DrawCanvas extends JPanel { + + private DataContainer dc; + + private BufferedImage buffer; + + public DrawCanvas(int width, int height, DataContainer dc) { + if (dc == null) { + throw new NullPointerException("dc == null"); + } + if (width <= 0) { + throw new IllegalArgumentException("width <= 0"); + } + if (height <= 0) { + throw new IllegalArgumentException("height <= 0"); + } + + this.buffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + + this.setPreferredSize(new Dimension(width, height)); + + this.dc = dc; + this.dc.addListener(new DataContainerListenerImpl()); + this.dc.getShapeContainer().addListener(new ShapeContainerListenerImpl()); + + BackgroundShape bgShape = new BackgroundShape(); + bgShape.setWidth(width); + bgShape.setHeight(height); + this.dc.getShapeContainer().addShape(bgShape); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + + g.drawImage(this.buffer, 0, 0, null); + } + + private class DataContainerListenerImpl implements DataContainerListener { + + private ShapePropertyChangeListener shapePropertyChangeListener = new ShapePropertyChangeListenerImpl(); + + public void currentShapeChange(CurrentShapeChangeEvent event) { + Graphics g = DrawCanvas.this.getGraphics(); + try { + g.drawImage(DrawCanvas.this.buffer, 0, 0, null); + } finally { + g.dispose(); + } + + if (event.getOldShape() != null) { + event.getOldShape().createEnd(DrawCanvas.this); + event.getOldShape().removeShapePropertyChangeListener(this.shapePropertyChangeListener); + } + + if (event.getNewShape() != null) { + event.getNewShape().createStart(DrawCanvas.this); + event.getNewShape().addShapePropertyChangeListener(this.shapePropertyChangeListener); + } + } + + } + + private class ShapeContainerListenerImpl implements ShapeContainerListener { + + public void addShape(ShapeAddEvent event) { + Graphics g = buffer.getGraphics(); + try { + event.getShape().draw(g); + } finally { + g.dispose(); + } + + g = DrawCanvas.this.getGraphics(); + if (g != null) { + try { + g.drawImage(buffer, 0, 0, null); + } finally { + g.dispose(); + } + } + } + + public void removeShape(ShapeRemoveEvent event) { + Graphics g = buffer.getGraphics(); + try { + for (BaseShape shape : dc.getShapeContainer().getShapeList()) { + shape.draw(g); + } + } finally { + g.dispose(); + } + + g = DrawCanvas.this.getGraphics(); + if (g != null) { + try { + g.drawImage(buffer, 0, 0, null); + } finally { + g.dispose(); + } + } + } + + } + + private class ShapePropertyChangeListenerImpl implements ShapePropertyChangeListener { + + public void propertyChange(ShapePropertyChangeEvent event) { + BaseShape shape = event.getSource(); + + if ("completed".equals(event.getPropertyName())) { + dc.getShapeContainer().addShape(shape); + } else { + Graphics g = DrawCanvas.this.getGraphics(); + try { + g.drawImage(DrawCanvas.this.buffer, 0, 0, null); + shape.draw(g); + } finally { + g.dispose(); + } + } + } + + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DrawEditor.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DrawEditor.java new file mode 100644 index 0000000..9c9ac93 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/DrawEditor.java @@ -0,0 +1,55 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.BorderLayout; +import java.awt.Container; + +import javax.swing.JFrame; +import javax.swing.WindowConstants; + +import jp.gr.java_conf.u6k.online_stg_env.data.DataContainer; + +public class DrawEditor extends JFrame { + + private DrawCanvas canvas; + + public DrawEditor(DataContainer dc) { + this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.setResizable(false); + + Container c = this.getContentPane(); + c.setLayout(new BorderLayout()); + + this.canvas = new DrawCanvas(640, 480, dc); + c.add(this.canvas, BorderLayout.CENTER); + + this.pack(); + } + + public static void main(String[] args) throws Exception { + DataContainer dc = new DataContainer(); + + DrawEditor drawEditor = new DrawEditor(dc); + drawEditor.setVisible(true); + + DataCommandDialog dataCommandDialog = new DataCommandDialog(drawEditor, dc); + dataCommandDialog.setVisible(true); + + ShapeChooserDialog shapeChooserDialog = new ShapeChooserDialog(drawEditor, dc); + shapeChooserDialog.setVisible(true); + + ShapePropertyDialog shapePropertyDialog = new ShapePropertyDialog(drawEditor, dc); + shapePropertyDialog.setVisible(true); + + ShapeListDialog shapeListDialog = new ShapeListDialog(drawEditor, dc); + shapeListDialog.setVisible(true); + + // None 8.7M + // BufferedImage image = new BufferedImage(640, 480, BufferedImage.TYPE_INT_RGB); // 10.3M + // BufferedImage image = new BufferedImage(800, 600, BufferedImage.TYPE_INT_RGB); // 12.6M + // BufferedImage image = new BufferedImage(1600, 1200, BufferedImage.TYPE_INT_RGB); // 18.2M + // BufferedImage image = new BufferedImage(10000, 10000, BufferedImage.TYPE_INT_RGB); // 403.9M + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/HashUtil.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/HashUtil.java new file mode 100644 index 0000000..7c563cf --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/HashUtil.java @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2008 u6k.yu1@gmail.com, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact clarkware@clarkware.com. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.io.IOException; +import java.io.InputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + *

+ * ハッシュ値を算出します。 + *

+ * + * @version $Id$ + */ +public final class HashUtil { + + /** + *

+ * バッファの長さ。 + *

+ */ + private static final int BUFFER_LENGTH = 1024; + + /** + *

+ * マスク値。 + *

+ */ + private static final int MASK = 0xff; + + /** + *

+ * ハッシュ値を算出するクラス。 + *

+ */ + private MessageDigest md; + + /** + *

+ * 新しいインスタンスを初期化します。 + *

+ * + * @param algorithm + * ハッシュ値算出アルゴリズム。 + * @throws NoSuchAlgorithmException + * アルゴリズムをサポートしていない場合。 + */ + public HashUtil(String algorithm) throws NoSuchAlgorithmException { + this.md = MessageDigest.getInstance(algorithm); + } + + /** + *

+ * ストリームからデータを取得してハッシュ値を算出します。 + *

+ * + * @param in + * ハッシュ値を算出するデータのストリーム。 + * @return データのハッシュ値。 + * @throws NullPointerException + * in引数がnullの場合。 + * @throws IOException + * データの取得に失敗した場合。 + */ + public String digest(InputStream in) throws IOException { + if (in == null) { + throw new NullPointerException("in == null"); + } + + byte[] buf = new byte[HashUtil.BUFFER_LENGTH]; + int len; + while ((len = in.read(buf)) != -1) { + this.md.update(buf, 0, len); + } + + byte[] hashData = this.md.digest(); + String hash = this.toHexString(hashData); + return hash; + } + + private String toHexString(byte[] data) { + StringBuilder hex = new StringBuilder(); + + for (int i = 0; i < data.length; i++) { + String b = Integer.toHexString(data[i] & HashUtil.MASK); + if (b.length() == 1) { + hex.append("0"); + } + hex.append(b); + } + + return hex.toString(); + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/HttpUtil.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/HttpUtil.java new file mode 100644 index 0000000..cc34313 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/HttpUtil.java @@ -0,0 +1,195 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.xml.sax.SAXException; + +public class HttpUtil { + + private static final String URL; + + private static String cookie; + + static { + ResourceBundle rb = ResourceBundle.getBundle("online-stg-env"); + URL = rb.getString("url"); + } + + public static Object post(Map postData) throws MalformedURLException, IOException, SAXException, ParserConfigurationException { + // 引数を確認します。 + if (postData == null) { + throw new NullPointerException("data == null"); + } + + // POST文字列を構築します。 + StringBuilder postDataString = new StringBuilder(); + for (Map.Entry entry : postData.entrySet()) { + if (postDataString.length() > 0) { + postDataString.append("&"); + } + postDataString.append(URLEncoder.encode(entry.getKey(), "UTF-8")); + postDataString.append("="); + postDataString.append(URLEncoder.encode(entry.getValue().toString(), "UTF-8")); + } + + // URLへ接続します。 + HttpURLConnection conn = (HttpURLConnection) new URL(URL).openConnection(); + try { + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + conn.setDoInput(true); + + // 送信します。 + if (cookie != null) { + conn.setRequestProperty("Cookie", cookie); + } + + OutputStream out = conn.getOutputStream(); + try { + out.write(postDataString.toString().getBytes()); + } finally { + out.close(); + } + + // 受信します。 + if (conn.getHeaderField("Set-Cookie") != null && !"".equals(conn.getHeaderField("Set-Cookie"))) { + cookie = conn.getHeaderField("Set-Cookie"); + } + + String returnString; + InputStream in = conn.getInputStream(); + try { + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + int c; + while ((c = in.read()) != -1) { + bout.write(c); + } + returnString = bout.toString(); + } finally { + in.close(); + } + return buildReturnMap(returnString); + } finally { + conn.disconnect(); + } + } + + public static Object buildReturnMap(String returnString) throws SAXException, IOException, ParserConfigurationException { + int returnPos = returnString.indexOf("= 0 && errorPos == -1) { + String returnXml = returnString.substring(returnPos, returnString.lastIndexOf("") + "".length()); + return buildReturnMap0(returnXml); + } else if (returnPos == -1 && errorPos >= 0) { + String errorXml = returnString.substring(errorPos, returnString.lastIndexOf("") + "".length()); + buildErrorMap0(errorXml); + return null; + } else if (returnPos >= 0 && errorPos >= 0) { + if (returnPos < errorPos) { + String returnXml = returnString.substring(returnPos, returnString.lastIndexOf("") + "".length()); + return buildReturnMap0(returnXml); + } else { + String errorXml = returnString.substring(errorPos, returnString.lastIndexOf("") + "".length()); + buildErrorMap0(errorXml); + return null; + } + } else { + throw new RuntimeException(); + } + } + + private static Object buildReturnMap0(String returnXml) throws SAXException, IOException, ParserConfigurationException { + ByteArrayInputStream bin = new ByteArrayInputStream(returnXml.getBytes()); + try { + Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bin); + return buildMap(doc).get("return"); + } finally { + bin.close(); + } + } + + @SuppressWarnings("unchecked") + private static void buildErrorMap0(String errorXml) throws SAXException, IOException, ParserConfigurationException { + ByteArrayInputStream bin = new ByteArrayInputStream(errorXml.getBytes()); + try { + Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bin); + Map m = (Map) buildMap(doc).get("error"); + throw new HttpException((String) m.get("type"), (String) m.get("message"), m.get("data")); + } finally { + bin.close(); + } + } + + private static Map buildMap(Node node) throws UnsupportedEncodingException, DOMException { + Map m = new HashMap(); + + for (int i = 0; i < node.getChildNodes().getLength(); i++) { + if (node.getChildNodes().item(i).getNodeType() == Node.ELEMENT_NODE) { + Node childElement = node.getChildNodes().item(i); + if ("string".equals(childElement.getAttributes().getNamedItem("type").getNodeValue())) { + m.put(childElement.getNodeName(), URLDecoder.decode(childElement.getTextContent(), "UTF-8")); + } else if ("integer".equals(childElement.getAttributes().getNamedItem("type").getNodeValue())) { + m.put(childElement.getNodeName(), Integer.parseInt(URLDecoder.decode(childElement.getTextContent(), "UTF-8"))); + } else if ("float".equals(childElement.getAttributes().getNamedItem("type").getNodeValue())) { + m.put(childElement.getNodeName(), Double.parseDouble(URLDecoder.decode(childElement.getTextContent(), "UTF-8"))); + } else if ("boolean".equals(childElement.getAttributes().getNamedItem("type").getNodeValue())) { + m.put(childElement.getNodeName(), Boolean.parseBoolean(URLDecoder.decode(childElement.getTextContent(), "UTF-8"))); + } else if ("other".equals(childElement.getAttributes().getNamedItem("type").getNodeValue())) { + m.put(childElement.getNodeName(), URLDecoder.decode(childElement.getTextContent(), "UTF-8")); + } else if ("map".equals(childElement.getAttributes().getNamedItem("type").getNodeValue())) { + m.put(childElement.getNodeName(), buildMap(childElement)); + } else { + throw new RuntimeException(); + } + } + } + + return m; + } + + @SuppressWarnings("serial") + public static final class HttpException extends RuntimeException { + + private String type; + + private Object data; + + public HttpException(String type, String message, Object data) { + super(message); + + this.type = type; + this.data = data; + } + + public String getType() { + return this.type; + } + + public Object getData() { + return this.data; + } + + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutableDimension.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutableDimension.java new file mode 100644 index 0000000..7225b62 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutableDimension.java @@ -0,0 +1,34 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.Dimension; + +public final class ImmutableDimension { + + private int width; + + private int height; + + public ImmutableDimension(int width, int height) { + this.width = width; + this.height = height; + } + + public ImmutableDimension(Dimension dimension) { + if (dimension == null) { + throw new NullPointerException("dimension == null"); + } + + this.width = dimension.width; + this.height = dimension.height; + } + + public int getWidth() { + return this.width; + } + + public int getHeight() { + return this.height; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutablePoint.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutablePoint.java new file mode 100644 index 0000000..02d99ef --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutablePoint.java @@ -0,0 +1,34 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.Point; + +public final class ImmutablePoint { + + private int x; + + private int y; + + public ImmutablePoint(int x, int y) { + this.x = x; + this.y = y; + } + + public ImmutablePoint(Point point) { + if (point == null) { + throw new NullPointerException("point == null"); + } + + this.x = point.x; + this.y = point.y; + } + + public int getX() { + return this.x; + } + + public int getY() { + return this.y; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutableRectangle.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutableRectangle.java new file mode 100644 index 0000000..6ad5c99 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ImmutableRectangle.java @@ -0,0 +1,81 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.Rectangle; + +public final class ImmutableRectangle { + + private int x; + + private int y; + + private int width; + + private int height; + + public ImmutableRectangle(int x, int y, int width, int height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + public ImmutableRectangle(Rectangle rectangle) { + if (rectangle == null) { + throw new NullPointerException("rectangle == null"); + } + + this.x = rectangle.x; + this.y = rectangle.y; + this.width = rectangle.width; + this.height = rectangle.height; + } + + public int getX() { + return this.x; + } + + public int getY() { + return this.y; + } + + public int getWidth() { + return this.width; + } + + public int getHeight() { + return this.height; + } + + public static ImmutableRectangle normalize(ImmutablePoint p1, ImmutablePoint p2) { + if (p1 == null) { + throw new NullPointerException("p1 == null"); + } + if (p2 == null) { + throw new NullPointerException("p2 == null"); + } + + int x; + int y; + int width; + int height; + + if (p1.getX() < p2.getX()) { + x = p1.getX(); + width = p2.getX() - p1.getX(); + } else { + x = p2.getX(); + width = p1.getX() - p2.getX(); + } + if (p1.getY() < p2.getY()) { + y = p1.getY(); + height = p2.getY() - p1.getY(); + } else { + y = p2.getY(); + height = p1.getY() - p2.getY(); + } + + return new ImmutableRectangle(x, y, width, height); + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/LoginDialog.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/LoginDialog.java new file mode 100644 index 0000000..5f961d7 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/LoginDialog.java @@ -0,0 +1,117 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.Container; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.ByteArrayInputStream; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.SpringLayout; +import javax.swing.WindowConstants; + +@SuppressWarnings("serial") +public class LoginDialog extends JDialog { + + private JTextField username; + + private JTextField password; + + private boolean auth; + + public LoginDialog() { + super((Frame) null, true); + + this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + this.setSize(300, 150); + this.setResizable(false); + this.setTitle("Login Dialog"); + this.setLocationRelativeTo(null); + + Container c = this.getContentPane(); + SpringLayout l = new SpringLayout(); + c.setLayout(l); + + JLabel usernameLabel = new JLabel("ユーザ名"); + l.putConstraint(SpringLayout.NORTH, usernameLabel, 10, SpringLayout.NORTH, c); + l.putConstraint(SpringLayout.WEST, usernameLabel, 10, SpringLayout.WEST, c); + c.add(usernameLabel); + + JLabel passwordLabel = new JLabel("パスワード"); + l.putConstraint(SpringLayout.NORTH, passwordLabel, 10, SpringLayout.SOUTH, usernameLabel); + l.putConstraint(SpringLayout.WEST, passwordLabel, 10, SpringLayout.WEST, c); + c.add(passwordLabel); + + this.username = new JTextField(); + l.putConstraint(SpringLayout.NORTH, this.username, 10, SpringLayout.NORTH, c); + l.putConstraint(SpringLayout.EAST, this.username, -10, SpringLayout.EAST, c); + l.putConstraint(SpringLayout.WEST, this.username, 10, SpringLayout.EAST, usernameLabel); + c.add(this.username); + + this.password = new JTextField(); + l.putConstraint(SpringLayout.NORTH, this.password, 10, SpringLayout.SOUTH, this.username); + l.putConstraint(SpringLayout.EAST, this.password, -10, SpringLayout.EAST, c); + l.putConstraint(SpringLayout.WEST, this.password, 10, SpringLayout.EAST, passwordLabel); + c.add(this.password); + + JButton closeButton = new JButton("閉じる"); + closeButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + LoginDialog.this.auth = false; + + LoginDialog.this.dispose(); + } + + }); + l.putConstraint(SpringLayout.SOUTH, closeButton, -10, SpringLayout.SOUTH, c); + l.putConstraint(SpringLayout.EAST, closeButton, -10, SpringLayout.EAST, c); + c.add(closeButton); + + JButton loginButton = new JButton("ログイン"); + loginButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent event) { + try { + Map postData = new HashMap(); + postData.put("method", "get_challenge"); + + Object returnData = HttpUtil.post(postData); + + String challenge = (String) returnData; + + postData.clear(); + postData.put("method", "login"); + postData.put("username", LoginDialog.this.username.getText()); + postData.put("password", new HashUtil("MD5").digest(new ByteArrayInputStream((LoginDialog.this.password.getText() + challenge).getBytes()))); + + returnData = HttpUtil.post(postData); + + LoginDialog.this.auth = true; + + LoginDialog.this.dispose(); + } catch (Throwable e) { + SimpleErrorDialog.showDialog(e); + } + } + + }); + l.putConstraint(SpringLayout.SOUTH, loginButton, -10, SpringLayout.SOUTH, c); + l.putConstraint(SpringLayout.EAST, loginButton, -10, SpringLayout.WEST, closeButton); + c.add(loginButton); + } + + public static boolean showDialog() { + LoginDialog dialog = new LoginDialog(); + dialog.setVisible(true); + + return dialog.auth; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/OnlineStgEditor.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/OnlineStgEditor.java new file mode 100644 index 0000000..c2ed7f9 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/OnlineStgEditor.java @@ -0,0 +1,127 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.Container; +import java.awt.DisplayMode; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.SpringLayout; +import javax.swing.UIManager; +import javax.swing.WindowConstants; +import javax.xml.parsers.ParserConfigurationException; + +import org.xml.sax.SAXException; + +@SuppressWarnings("serial") +public class OnlineStgEditor extends JFrame { + + private JTextArea textArea; + + private DisplayMode currentDisplayMode; + + public OnlineStgEditor() throws MalformedURLException, IOException, SAXException, ParserConfigurationException { + this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + this.setSize(640, 480); + this.setTitle("Online STG Editor"); + this.setLocationRelativeTo(null); + + Container c = this.getContentPane(); + SpringLayout l = new SpringLayout(); + c.setLayout(l); + + JButton sendButton = new JButton("送信"); + sendButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent event) { + try { + String text = OnlineStgEditor.this.textArea.getText(); + + Map postData = new HashMap(); + postData.put("method", "write_data_file"); + postData.put("data", text); + + HttpUtil.post(postData); + + JOptionPane.showMessageDialog(OnlineStgEditor.this, "文章を保存しました。", "保存", JOptionPane.INFORMATION_MESSAGE); + } catch (Throwable e) { + SimpleErrorDialog.showDialog(e); + } + } + + }); + l.putConstraint(SpringLayout.SOUTH, sendButton, -10, SpringLayout.SOUTH, c); + l.putConstraint(SpringLayout.EAST, sendButton, -10, SpringLayout.EAST, c); + c.add(sendButton); + + JButton fullScreenButton = new JButton("フルスクリーン"); + fullScreenButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice gd = ge.getDefaultScreenDevice(); + + if (OnlineStgEditor.this.currentDisplayMode == null) { + gd.setFullScreenWindow(OnlineStgEditor.this); + OnlineStgEditor.this.currentDisplayMode = gd.getDisplayMode(); + gd.setDisplayMode(new DisplayMode(640, 480, 32, 60)); + } else { + gd.setDisplayMode(OnlineStgEditor.this.currentDisplayMode); + gd.setFullScreenWindow(null); + OnlineStgEditor.this.currentDisplayMode = null; + } + } + + }); + l.putConstraint(SpringLayout.SOUTH, fullScreenButton, -10, SpringLayout.SOUTH, c); + l.putConstraint(SpringLayout.EAST, fullScreenButton, -10, SpringLayout.WEST, sendButton); + c.add(fullScreenButton); + + this.textArea = new JTextArea(); + JScrollPane textAreaScroll = new JScrollPane(this.textArea); + l.putConstraint(SpringLayout.SOUTH, textAreaScroll, -10, SpringLayout.NORTH, sendButton); + l.putConstraint(SpringLayout.NORTH, textAreaScroll, 10, SpringLayout.NORTH, c); + l.putConstraint(SpringLayout.EAST, textAreaScroll, -10, SpringLayout.EAST, c); + l.putConstraint(SpringLayout.WEST, textAreaScroll, 10, SpringLayout.WEST, c); + c.add(textAreaScroll); + + Map postData = new HashMap(); + postData.put("method", "read_data_file"); + + Object returnData = HttpUtil.post(postData); + this.textArea.setText((String) returnData); + } + + public static void main(String[] args) throws Exception { + // TODO + // Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + // + // public void uncaughtException(Thread t, Throwable e) { + // JOptionPane.showMessageDialog(null, e.toString(), "Error", JOptionPane.ERROR_MESSAGE); + // System.exit(1); + // } + // + // }); + + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + + if (!LoginDialog.showDialog()) { + System.exit(0); + } + + OnlineStgEditor editor = new OnlineStgEditor(); + editor.setVisible(true); + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapeChooserDialog.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapeChooserDialog.java new file mode 100644 index 0000000..ce57b8e --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapeChooserDialog.java @@ -0,0 +1,250 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.beans.IntrospectionException; +import java.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.Icon; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.WindowConstants; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.TableModelListener; +import javax.swing.table.TableModel; + +import jp.gr.java_conf.u6k.online_stg_env.data.DataContainer; +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; +import jp.gr.java_conf.u6k.online_stg_env.shape.ShapePropertyChangeEvent; +import jp.gr.java_conf.u6k.online_stg_env.shape.ShapePropertyChangeListener; +import jp.gr.java_conf.u6k.online_stg_env.shape.reflect.ShapeDescriptor; + +@SuppressWarnings("serial") +public class ShapeChooserDialog extends JDialog { + + public ShapeChooserDialog(JFrame owner, DataContainer dataContainer) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException, InvocationTargetException, MalformedURLException, IntrospectionException { + super(owner, false); + + if (dataContainer == null) { + throw new NullPointerException("dataContainer == null"); + } + + List> shapeClazzList = new ArrayList>(); + shapeClazzList.add(this.classForName("jp.gr.java_conf.u6k.online_stg_env.shape.FreehandLineShape")); + shapeClazzList.add(this.classForName("jp.gr.java_conf.u6k.online_stg_env.shape.LineShape")); + shapeClazzList.add(this.classForName("jp.gr.java_conf.u6k.online_stg_env.shape.OvalShape")); + shapeClazzList.add(this.classForName("jp.gr.java_conf.u6k.online_stg_env.shape.RectangleShape")); + + JTable shapeTable = new JTable(new TableModelImpl(shapeClazzList)); + shapeTable.getSelectionModel().addListSelectionListener(new ListSelectionListenerImpl(shapeTable, dataContainer)); + shapeTable.setRowHeight(40); + shapeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + JScrollPane shapeTableScroll = new JScrollPane(shapeTable); + this.getContentPane().add(shapeTableScroll, BorderLayout.CENTER); + + this.setTitle("図形の選択 - DrawEditor"); + this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + this.setPreferredSize(new Dimension(400, 300)); + this.setLocationRelativeTo(null); + + this.pack(); + } + + @SuppressWarnings("unchecked") + private Class classForName(String className) throws ClassNotFoundException { + return (Class) Class.forName(className); + } + + private static class ShapePropertyChangeListenerImpl implements ShapePropertyChangeListener { + + private JTable shapeTable; + + private DataContainer dataContainer; + + public ShapePropertyChangeListenerImpl(JTable shapeTable, DataContainer dataContainer) { + if (shapeTable == null) { + throw new NullPointerException("shapeTable == null"); + } + if (dataContainer == null) { + throw new NullPointerException("dataContainer != null"); + } + this.shapeTable = shapeTable; + this.dataContainer = dataContainer; + } + + public void propertyChange(ShapePropertyChangeEvent event) { + if ("completed".equals(event.getPropertyName())) { + TableModelImpl tableModel = (TableModelImpl) this.shapeTable.getModel(); + Class shapeClazz = tableModel.getRowData(this.shapeTable.getSelectedRow()).getShapeClazz(); + try { + BaseShape shape = shapeClazz.newInstance(); + shape.addShapePropertyChangeListener(new ShapePropertyChangeListenerImpl(this.shapeTable, this.dataContainer)); + this.dataContainer.setCurrentShape(shape); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + + } + + private static class TableModelImpl implements TableModel { + + private List listenerList = new ArrayList(); + + private List rowDataList = new ArrayList(); + + public TableModelImpl(List> shapeClazzList) throws MalformedURLException, IntrospectionException { + if (shapeClazzList == null) { + throw new NullPointerException("shapeClazzList == null"); + } + + for (Class shapeClazz : shapeClazzList) { + this.rowDataList.add(new TableRowData(shapeClazz)); + } + } + + public void addTableModelListener(TableModelListener l) { + if (l != null) { + this.listenerList.add(l); + } + } + + public Class getColumnClass(int columnIndex) { + switch (columnIndex) { + case 0: + return Icon.class; + case 1: + return String.class; + default: + throw new IllegalArgumentException("columnIndex != {0, 1}"); + } + } + + public int getColumnCount() { + return 2; + } + + public String getColumnName(int columnIndex) { + switch (columnIndex) { + case 0: + return "アイコン"; + case 1: + return "図形名"; + default: + throw new IllegalArgumentException("columnIndex != {0, 1}"); + } + } + + public int getRowCount() { + return this.rowDataList.size(); + } + + public Object getValueAt(int rowIndex, int columnIndex) { + TableRowData rowData = this.rowDataList.get(rowIndex); + + switch (columnIndex) { + case 0: + return rowData.getShapeDescriptor().getIcon(); + case 1: + return rowData.getShapeDescriptor().getName(); + default: + throw new IllegalArgumentException("columnIndex != {0, 1}"); + } + } + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + + public void removeTableModelListener(TableModelListener l) { + if (l != null) { + this.listenerList.remove(l); + } + } + + public void setValueAt(Object value, int rowIndex, int columnIndex) { + } + + public TableRowData getRowData(int rowIndex) { + return this.rowDataList.get(rowIndex); + } + + } + + private static class TableRowData { + + private Class clazz; + + private ShapeDescriptor desc; + + private Map defaultValueMap = new HashMap(); + + public TableRowData(Class clazz) throws MalformedURLException, IntrospectionException { + if (clazz == null) { + throw new NullPointerException("clazz == null"); + } + + this.clazz = clazz; + this.desc = new ShapeDescriptor(clazz); + } + + public Class getShapeClazz() { + return this.clazz; + } + + public ShapeDescriptor getShapeDescriptor() { + return this.desc; + } + + public Map getDefaultValueMap() { + return this.defaultValueMap; + } + + } + + private static class ListSelectionListenerImpl implements ListSelectionListener { + + private JTable shapeTable; + + private DataContainer dataContainer; + + public ListSelectionListenerImpl(JTable shapeTable, DataContainer dataContainer) { + if (shapeTable == null) { + throw new NullPointerException("shapeTable == null"); + } + if (dataContainer == null) { + throw new NullPointerException("dataContainer == null"); + } + this.shapeTable = shapeTable; + this.dataContainer = dataContainer; + } + + public void valueChanged(ListSelectionEvent event) { + TableModelImpl tableModel = (TableModelImpl) this.shapeTable.getModel(); + Class shapeClazz = tableModel.getRowData(this.shapeTable.getSelectedRow()).getShapeClazz(); + try { + BaseShape shape = shapeClazz.newInstance(); + shape.addShapePropertyChangeListener(new ShapePropertyChangeListenerImpl(this.shapeTable, this.dataContainer)); + this.dataContainer.setCurrentShape(shape); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapeListDialog.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapeListDialog.java new file mode 100644 index 0000000..2dcbb72 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapeListDialog.java @@ -0,0 +1,98 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.beans.IntrospectionException; +import java.net.MalformedURLException; + +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.WindowConstants; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.DefaultTableModel; + +import jp.gr.java_conf.u6k.online_stg_env.data.DataContainer; +import jp.gr.java_conf.u6k.online_stg_env.data.ShapeAddEvent; +import jp.gr.java_conf.u6k.online_stg_env.data.ShapeContainerListener; +import jp.gr.java_conf.u6k.online_stg_env.data.ShapeRemoveEvent; +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; +import jp.gr.java_conf.u6k.online_stg_env.shape.reflect.ShapeDescriptor; + +@SuppressWarnings("serial") +public class ShapeListDialog extends JDialog { + + private JTable shapeTable; + + private DataContainer dc; + + public ShapeListDialog(JFrame owner, DataContainer dataContainer) throws MalformedURLException, IntrospectionException { + super(owner, false); + + if (dataContainer == null) { + throw new NullPointerException("dataContainer == null"); + } + + this.dc = dataContainer; + + this.shapeTable = new JTable(new DefaultTableModel(new Object[] { "ID", "図形名" }, 0)); + this.shapeTable.getSelectionModel().addListSelectionListener(new ListSelectionListenerImpl()); + this.shapeTable.setDefaultEditor(Object.class, null); + JScrollPane shapeTableScroll = new JScrollPane(this.shapeTable); + this.getContentPane().add(shapeTableScroll, BorderLayout.CENTER); + + this.setTitle("図形リスト - DrawEditor"); + this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + this.setPreferredSize(new Dimension(400, 300)); + this.setLocationRelativeTo(null); + + this.pack(); + + for (BaseShape shape : dataContainer.getShapeContainer().getShapeList()) { + this.addShape(shape); + } + + dataContainer.getShapeContainer().addListener(new ShapeContainerListenerImpl()); + } + + private void addShape(BaseShape shape) throws MalformedURLException, IntrospectionException { + int index = this.shapeTable.getRowCount(); + + ShapeDescriptor shapeDesc = new ShapeDescriptor(shape.getClass()); + + DefaultTableModel tableModel = (DefaultTableModel) this.shapeTable.getModel(); + tableModel.addRow(new Object[] { index, shapeDesc.getName() }); + } + + private class ShapeContainerListenerImpl implements ShapeContainerListener { + + public void addShape(ShapeAddEvent event) { + try { + ShapeListDialog.this.addShape(event.getShape()); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } + + public void removeShape(ShapeRemoveEvent event) { + // TODO Auto-generated method stub + } + + } + + private class ListSelectionListenerImpl implements ListSelectionListener { + + public void valueChanged(ListSelectionEvent event) { + int index = event.getFirstIndex(); + BaseShape shape = ShapeListDialog.this.dc.getShapeContainer().getShapeList().get(index); + ShapeListDialog.this.dc.setCurrentShape(shape); + } + + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapePropertyDialog.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapePropertyDialog.java new file mode 100644 index 0000000..e9f605b --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/ShapePropertyDialog.java @@ -0,0 +1,259 @@ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.beans.IntrospectionException; +import java.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; + +import javax.swing.JColorChooser; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.WindowConstants; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableModel; + +import jp.gr.java_conf.u6k.online_stg_env.data.CurrentShapeChangeEvent; +import jp.gr.java_conf.u6k.online_stg_env.data.DataContainer; +import jp.gr.java_conf.u6k.online_stg_env.data.DataContainerListener; +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; +import jp.gr.java_conf.u6k.online_stg_env.shape.reflect.ShapeDescriptor; +import jp.gr.java_conf.u6k.online_stg_env.shape.reflect.ShapePropertyDescriptor; + +@SuppressWarnings("serial") +public class ShapePropertyDialog extends JDialog { + + public ShapePropertyDialog(JFrame owner, DataContainer dataContainer) { + super(owner, false); + + if (dataContainer == null) { + throw new NullPointerException("dataContainer == null"); + } + + JTable propTable = new JTable(new TableModelImpl()); + propTable.getColumnModel().getColumn(1).setCellEditor(new TableCellEditorImpl()); + JScrollPane propTableScroll = new JScrollPane(propTable); + this.getContentPane().add(propTableScroll, BorderLayout.CENTER); + + this.setTitle("図形のプロパティ - DrawEditor"); + this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + this.setPreferredSize(new Dimension(400, 300)); + this.setLocationRelativeTo(null); + + this.pack(); + + dataContainer.addListener(new DataContainerListenerImpl(propTable)); + } + + private static class TableCellEditorImpl implements TableCellEditor { + + private List listenerList = new ArrayList(); + + private Object value; + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + // TODO Auto-generated method stub + System.out.println("* getTableCellEditorComponent: " + value + ", " + row + ", " + column); + this.value = value; + if (value instanceof Color) { + Color oldColor = (Color) value; + Color newColor = JColorChooser.showDialog(null, "色の選択", oldColor); + if (newColor != null) { + table.getModel().setValueAt(newColor, row, column); + } + return null; + } else { + return new JTextField(value.toString()); + } + } + + public void addCellEditorListener(CellEditorListener l) { + System.out.println("* addCellEditorListener"); + if (l != null) { + this.listenerList.add(l); + } + } + + public void cancelCellEditing() { + System.out.println("* cancelCellEditing"); + // TODO Auto-generated method stub + ChangeEvent event = new ChangeEvent(this); + for (CellEditorListener l : this.listenerList.toArray(new CellEditorListener[0])) { + l.editingCanceled(event); + } + } + + public Object getCellEditorValue() { + System.out.println("* getCellEditorValue"); + // TODO Auto-generated method stub + return this.value; + } + + public boolean isCellEditable(EventObject anEvent) { + System.out.println("* isCellEditable"); + // TODO Auto-generated method stub + return true; + } + + public void removeCellEditorListener(CellEditorListener l) { + System.out.println("* removeCellEditor"); + if (l != null) { + this.listenerList.remove(l); + } + } + + public boolean shouldSelectCell(EventObject anEvent) { + System.out.println("* shouldSelectCell"); + // TODO Auto-generated method stub + return true; + } + + public boolean stopCellEditing() { + System.out.println("* stopCellEditing"); + // TODO Auto-generated method stub + ChangeEvent event = new ChangeEvent(this); + for (CellEditorListener l : this.listenerList.toArray(new CellEditorListener[0])) { + l.editingStopped(event); + } + return true; + } + + } + + private static class TableModelImpl implements TableModel { + + private List listenerList = new ArrayList(); + + private BaseShape shape; + + private Object[][] rowData = new Object[0][]; + + public void addTableModelListener(TableModelListener l) { + if (l != null) { + this.listenerList.add(l); + } + } + + public Class getColumnClass(int columnIndex) { + return Object.class; + } + + public int getColumnCount() { + return 2; + } + + public String getColumnName(int columnIndex) { + switch (columnIndex) { + case 0: + return "名称"; + case 1: + return "値"; + default: + throw new IllegalArgumentException("columnIndex != {0, 1}"); + } + } + + public int getRowCount() { + return this.rowData.length; + } + + public Object getValueAt(int rowIndex, int columnIndex) { + return this.rowData[rowIndex][columnIndex]; + } + + public boolean isCellEditable(int rowIndex, int columnIndex) { + // TODO Auto-generated method stub + if (columnIndex == 1) { + return true; + } else { + return false; + } + } + + public void removeTableModelListener(TableModelListener l) { + if (l != null) { + this.listenerList.remove(l); + } + } + + public void setValueAt(Object value, int rowIndex, int columnIndex) { + this.rowData[rowIndex][columnIndex] = value; + + TableModelEvent event = new TableModelEvent(this, rowIndex, columnIndex); + for (TableModelListener l : this.listenerList.toArray(new TableModelListener[0])) { + l.tableChanged(event); + } + } + + public void setShape(BaseShape shape) throws MalformedURLException, IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { + if (shape == null) { + throw new NullPointerException("shape == null"); + } + this.shape = shape; + + ShapeDescriptor shapeDesc = new ShapeDescriptor(shape.getClass()); + List propDescList = ShapePropertyDescriptor.getPropertyDescriptorList(shape.getClass()); + + this.rowData = new Object[3 + propDescList.size()][]; + + this.rowData[0] = new Object[] { "名前", shapeDesc.getName() }; + this.rowData[1] = new Object[] { "詳細", shapeDesc.getDescription() }; + this.rowData[2] = new Object[] { "クラス", shape.getClass().getName() }; + for (int i = 0; i < propDescList.size(); i++) { + ShapePropertyDescriptor propDesc = propDescList.get(i); + Object v = propDesc.getGetterMethod().invoke(shape); + this.rowData[3 + i] = new Object[] { propDesc.getName(), v }; + } + + TableModelEvent event = new TableModelEvent(this); + for (TableModelListener l : this.listenerList) { + l.tableChanged(event); + } + } + + } + + private class DataContainerListenerImpl implements DataContainerListener { + + private JTable propTable; + + public DataContainerListenerImpl(JTable propTable) { + if (propTable == null) { + throw new NullPointerException("propTable == null"); + } + this.propTable = propTable; + } + + public void currentShapeChange(CurrentShapeChangeEvent event) { + try { + TableModelImpl tableModel = (TableModelImpl) this.propTable.getModel(); + tableModel.setShape(event.getNewShape()); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } catch (IllegalArgumentException e) { + throw new RuntimeException(e); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + } + + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/SimpleErrorDialog.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/SimpleErrorDialog.java new file mode 100644 index 0000000..29af87c --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/SimpleErrorDialog.java @@ -0,0 +1,250 @@ +/* + * Copyright (C) 2008 u6k.yu1@gmail.com, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact clarkware@clarkware.com. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package jp.gr.java_conf.u6k.online_stg_env; + +import java.awt.Component; +import java.awt.Container; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.ResourceBundle; + +import javax.swing.AbstractAction; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JEditorPane; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTextPane; +import javax.swing.KeyStroke; +import javax.swing.SpringLayout; +import javax.swing.UIManager; +import javax.swing.WindowConstants; +import javax.swing.border.TitledBorder; + +/** + *

+ * エラーを表示する単純なモーダル・ダイアログです。外観は以下の要素で構成されます。 + *

+ *
    + *
  • ユーザへエラーが発生したことを表すメッセージ。 + *
  • エラーの内容を表示するメッセージ。 + *
  • 閉じるボタン。 + *
+ *

+ * 表示するメッセージ、ダイアログの初期サイズなどは外部プロパティ・ファイルで定義されており、ソースコードの修正無しに変更することが可能です。定義内容はSimpleErrorDialog.propertiesを参照してください。 + *

+ * + * @version $Id$ + */ +@SuppressWarnings("serial") +public final class SimpleErrorDialog extends JDialog { + + // TODO 背景色がおかしくなる。 + // TODO 配置がおかしくなる。 + + /** + *

+ * Swingコンポーネント同士の間隔。 + *

+ */ + private static final int COMPONENT_INTERVAL = 10; + + /** + *

+ * 外部リソース。TODO パッケージが変わると共にここも修正します。 + *

+ */ + private static final ResourceBundle RB = ResourceBundle.getBundle("jp.gr.java_conf.u6k.online_stg_env.SimpleErrorDialog"); + + private SimpleErrorDialog(Frame owner, Throwable exception) { + super(owner, SimpleErrorDialog.RB.getString("dialog.title"), true); + + this.initialize(exception); + } + + private SimpleErrorDialog(Dialog owner, Throwable exception) { + super(owner, SimpleErrorDialog.RB.getString("dialog.title"), true); + + this.initialize(exception); + } + + private void initialize(Throwable exception) { + if (exception == null) { + throw new NullPointerException("exception == null"); + } + + /* + * コンポーネントを設定し、ダイアログを初期化します。 + */ + // コンポーネントを作成します。 + Container c = this.getContentPane(); + + JLabel iconLabel = new JLabel(UIManager.getIcon("OptionPane.errorIcon")); + c.add(iconLabel); + + JEditorPane message1 = new JEditorPane(); + message1.setContentType("text/html"); + message1.setText(SimpleErrorDialog.RB.getString("dialog.message1")); + message1.setEditable(false); + message1.setBackground(this.getBackground()); + c.add(message1); + + String exceptionString; + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + exception.printStackTrace(new PrintStream(bout)); + exceptionString = bout.toString(); + + JEditorPane message2 = new ExceptionEditorPane(); + message2.setText(exceptionString); + message2.setEditable(false); + message2.setBackground(this.getBackground()); + JScrollPane message2Scroll = new JScrollPane(message2); + message2Scroll.setBorder(new TitledBorder(SimpleErrorDialog.RB.getString("dialog.message2"))); + c.add(message2Scroll); + + JButton closeButton = new JButton(SimpleErrorDialog.RB.getString("dialog.closeButton")); + closeButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + SimpleErrorDialog.this.dispose(); + } + + }); + c.add(closeButton); + + // レイアウトの調整を行います。 + SpringLayout l = new SpringLayout(); + c.setLayout(l); + + l.putConstraint(SpringLayout.NORTH, iconLabel, SimpleErrorDialog.COMPONENT_INTERVAL, SpringLayout.NORTH, c); + l.putConstraint(SpringLayout.WEST, iconLabel, SimpleErrorDialog.COMPONENT_INTERVAL, SpringLayout.WEST, c); + + l.putConstraint(SpringLayout.NORTH, message1, SimpleErrorDialog.COMPONENT_INTERVAL, SpringLayout.NORTH, c); + l.putConstraint(SpringLayout.EAST, message1, -SimpleErrorDialog.COMPONENT_INTERVAL, SpringLayout.EAST, c); + l.putConstraint(SpringLayout.WEST, message1, SimpleErrorDialog.COMPONENT_INTERVAL, SpringLayout.EAST, iconLabel); + + l.putConstraint(SpringLayout.SOUTH, closeButton, -SimpleErrorDialog.COMPONENT_INTERVAL, SpringLayout.SOUTH, c); + l.putConstraint(SpringLayout.EAST, closeButton, -SimpleErrorDialog.COMPONENT_INTERVAL, SpringLayout.EAST, c); + + l.putConstraint(SpringLayout.SOUTH, message2Scroll, -SimpleErrorDialog.COMPONENT_INTERVAL, SpringLayout.NORTH, closeButton); + l.putConstraint(SpringLayout.NORTH, message2Scroll, SimpleErrorDialog.COMPONENT_INTERVAL, SpringLayout.SOUTH, message1); + l.putConstraint(SpringLayout.EAST, message2Scroll, -SimpleErrorDialog.COMPONENT_INTERVAL, SpringLayout.EAST, c); + l.putConstraint(SpringLayout.WEST, message2Scroll, SimpleErrorDialog.COMPONENT_INTERVAL, SpringLayout.WEST, c); + + // ダイアログの設定を行います。 + this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + + this.setSize(Integer.parseInt(SimpleErrorDialog.RB.getString("dialog.size.width")), Integer.parseInt(SimpleErrorDialog.RB.getString("dialog.size.height"))); + + this.setLocationRelativeTo(this.getOwner()); + + this.getRootPane().setDefaultButton(closeButton); + + this.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close-it"); + this.getRootPane().getActionMap().put("close-it", new AbstractAction() { + + public void actionPerformed(ActionEvent e) { + SimpleErrorDialog.this.dispose(); + } + + }); + } + + /** + *

+ * エラー・ダイアログを表示します。 + *

+ * + * @param owner + * ダイアログの親コンポーネント。{@link Frame}インスタンスか{@link Dialog}インスタンスを指定してください。それ以外のコンポーネントは無視され、nullを指定した場合と同じ動作になります。 + * @param exception + * 発生したエラー。 + * @throws NullPointerException + * exception引数がnullの場合。 + */ + public static void showDialog(Component owner, Throwable exception) { + SimpleErrorDialog d; + if (owner == null) { + d = new SimpleErrorDialog((Frame) null, exception); + } else if (owner instanceof Frame) { + d = new SimpleErrorDialog((Frame) null, exception); + } else if (owner instanceof Dialog) { + d = new SimpleErrorDialog((Dialog) null, exception); + } else { + d = new SimpleErrorDialog((Frame) null, exception); + } + + d.setVisible(true); + } + + /** + *

+ * エラー・ダイアログを表示します。 + *

+ * + * @param exception + * 発生したエラー。 + * @throws NullPointerException + * exception引数がnullの場合。 + */ + public static void showDialog(Throwable exception) { + SimpleErrorDialog.showDialog(null, exception); + } + + /** + *

+ * 例外を表示する{@link JTextPane}拡張コンポーネントです。 + *

+ */ + private static final class ExceptionEditorPane extends JEditorPane { + + public ExceptionEditorPane() { + super(); + } + + @Override + public boolean getScrollableTracksViewportHeight() { + return false; + } + + @Override + public boolean getScrollableTracksViewportWidth() { + return false; + } + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/SimpleErrorDialog.properties b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/SimpleErrorDialog.properties new file mode 100644 index 0000000..35183d9 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/SimpleErrorDialog.properties @@ -0,0 +1,6 @@ +dialog.title=\u4e88\u671f\u3057\u306a\u3044\u30a8\u30e9\u30fc +dialog.message1=\u4e88\u671f\u3057\u306a\u3044\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002\u30a8\u30e9\u30fc\u306e\u5185\u5bb9\u306f\u4e0b\u306e\u30dc\u30c3\u30af\u30b9\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +dialog.message2=\u30a8\u30e9\u30fc\u306e\u5185\u5bb9 +dialog.closeButton=\u9589\u3058\u308b +dialog.size.width=400 +dialog.size.height=300 diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/CurrentShapeChangeEvent.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/CurrentShapeChangeEvent.java new file mode 100644 index 0000000..2016228 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/CurrentShapeChangeEvent.java @@ -0,0 +1,25 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; + +public class CurrentShapeChangeEvent { + + private BaseShape oldShape; + + private BaseShape newShape; + + public CurrentShapeChangeEvent(BaseShape oldShape, BaseShape newShape) { + this.oldShape = oldShape; + this.newShape = newShape; + } + + public BaseShape getOldShape() { + return this.oldShape; + } + + public BaseShape getNewShape() { + return this.newShape; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommand.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommand.java new file mode 100644 index 0000000..4d604e9 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommand.java @@ -0,0 +1,14 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.io.Externalizable; + +public interface DataCommand extends Externalizable { + + void replay(ShapeContainer shapeContainer); + + void rollback(ShapeContainer shapeContainer); + + String getDescription(); + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandAddEvent.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandAddEvent.java new file mode 100644 index 0000000..9bf7078 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandAddEvent.java @@ -0,0 +1,16 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +public class DataCommandAddEvent { + + private DataCommand command; + + public DataCommandAddEvent(DataCommand command) { + this.command = command; + } + + public DataCommand getCommand() { + return this.command; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandContainer.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandContainer.java new file mode 100644 index 0000000..1adc5cb --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandContainer.java @@ -0,0 +1,70 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.SortedMap; +import java.util.TreeMap; + +public class DataCommandContainer { + + private List listenerList = new ArrayList(); + + private List commandList = new ArrayList(); + + public void addListener(DataCommandContainerListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.add(l); + } + + public void removeListener(DataCommandContainerListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.remove(l); + } + + public void addCommand(DataCommand c) { + if (c == null) { + throw new NullPointerException("c == null"); + } + + this.commandList.add(c); + + DataCommandAddEvent event = new DataCommandAddEvent(c); + for (DataCommandContainerListener l : this.listenerList.toArray(new DataCommandContainerListener[0])) { + l.commandAdd(event); + } + } + + public List getCommandList() { + return Collections.unmodifiableList(this.commandList); + } + + public SortedMap purgeCommand(int index) { + if (index > 0 || this.commandList.size() <= index) { + throw new IndexOutOfBoundsException("index > 0 || this.commandList.size() <= index"); + } + + SortedMap purgedCommandMap = new TreeMap(); + if (this.commandList.size() > 0) { + int removedIndex = index; + while (this.commandList.size() > index) { + purgedCommandMap.put(removedIndex, this.commandList.remove(index)); + removedIndex++; + } + } + purgedCommandMap = Collections.unmodifiableSortedMap(purgedCommandMap); + + DataCommandPurgeEvent event = new DataCommandPurgeEvent(purgedCommandMap); + for (DataCommandContainerListener l : this.listenerList.toArray(new DataCommandContainerListener[0])) { + l.commandPurge(event); + } + + return purgedCommandMap; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandContainerListener.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandContainerListener.java new file mode 100644 index 0000000..f93bae9 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandContainerListener.java @@ -0,0 +1,10 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +public interface DataCommandContainerListener { + + void commandAdd(DataCommandAddEvent event); + + void commandPurge(DataCommandPurgeEvent event); + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandInput.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandInput.java new file mode 100644 index 0000000..f575cf0 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandInput.java @@ -0,0 +1,119 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.io.IOException; +import java.io.ObjectInput; + +public class DataCommandInput implements ObjectInput { + + public int available() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public void close() throws IOException { + // TODO Auto-generated method stub + + } + + public int read() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public int read(byte[] b) throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public int read(byte[] b, int off, int len) throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public Object readObject() throws ClassNotFoundException, IOException { + // TODO Auto-generated method stub + return null; + } + + public long skip(long n) throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public boolean readBoolean() throws IOException { + // TODO Auto-generated method stub + return false; + } + + public byte readByte() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public char readChar() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public double readDouble() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public float readFloat() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public void readFully(byte[] b) throws IOException { + // TODO Auto-generated method stub + + } + + public void readFully(byte[] b, int off, int len) throws IOException { + // TODO Auto-generated method stub + + } + + public int readInt() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public String readLine() throws IOException { + // TODO Auto-generated method stub + return null; + } + + public long readLong() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public short readShort() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public String readUTF() throws IOException { + // TODO Auto-generated method stub + return null; + } + + public int readUnsignedByte() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public int readUnsignedShort() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public int skipBytes(int n) throws IOException { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandOutput.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandOutput.java new file mode 100644 index 0000000..bd4b18a --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandOutput.java @@ -0,0 +1,94 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.io.IOException; +import java.io.ObjectOutput; + +public class DataCommandOutput implements ObjectOutput { + + public void close() throws IOException { + // TODO Auto-generated method stub + + } + + public void flush() throws IOException { + // TODO Auto-generated method stub + + } + + public void write(int b) throws IOException { + // TODO Auto-generated method stub + + } + + public void write(byte[] b) throws IOException { + // TODO Auto-generated method stub + + } + + public void write(byte[] b, int off, int len) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeObject(Object obj) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeBoolean(boolean v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeByte(int v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeBytes(String s) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeChar(int v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeChars(String s) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeDouble(double v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeFloat(float v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeInt(int v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeLong(long v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeShort(int v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeUTF(String str) throws IOException { + // TODO Auto-generated method stub + + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandPurgeEvent.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandPurgeEvent.java new file mode 100644 index 0000000..1471bd2 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataCommandPurgeEvent.java @@ -0,0 +1,18 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.util.SortedMap; + +public class DataCommandPurgeEvent { + + private SortedMap purgedCommandMap; + + public DataCommandPurgeEvent(SortedMap purgedCommandMap) { + this.purgedCommandMap = purgedCommandMap; + } + + public SortedMap getPurgedCommandMap() { + return this.purgedCommandMap; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataContainer.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataContainer.java new file mode 100644 index 0000000..8a39768 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataContainer.java @@ -0,0 +1,60 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.util.ArrayList; +import java.util.List; + +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; + +public class DataContainer { + + private List listenerList = new ArrayList(); + + private ShapeContainer shapeContainer; + + private DataCommandContainer commandContainer; + + private BaseShape currentShape; + + public DataContainer() { + this.commandContainer = new DataCommandContainer(); + this.shapeContainer = new ShapeContainer(this.commandContainer); + } + + public void addListener(DataContainerListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.add(l); + } + + public void removeListener(DataContainerListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.remove(l); + } + + public DataCommandContainer getDataCommandContainer() { + return this.commandContainer; + } + + public ShapeContainer getShapeContainer() { + return this.shapeContainer; + } + + public BaseShape getCurrentShape() { + return this.currentShape; + } + + public void setCurrentShape(BaseShape currentShape) { + BaseShape oldShape = this.currentShape; + this.currentShape = currentShape; + + CurrentShapeChangeEvent event = new CurrentShapeChangeEvent(oldShape, currentShape); + for (DataContainerListener l : this.listenerList.toArray(new DataContainerListener[0])) { + l.currentShapeChange(event); + } + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataContainerListener.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataContainerListener.java new file mode 100644 index 0000000..7093aea --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/DataContainerListener.java @@ -0,0 +1,8 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +public interface DataContainerListener { + + void currentShapeChange(CurrentShapeChangeEvent event); + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeAddCommand.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeAddCommand.java new file mode 100644 index 0000000..6b0fdbb --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeAddCommand.java @@ -0,0 +1,56 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.beans.IntrospectionException; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.net.MalformedURLException; + +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; +import jp.gr.java_conf.u6k.online_stg_env.shape.reflect.ShapeDescriptor; + +public class ShapeAddCommand implements DataCommand { + + private BaseShape shape; + + public ShapeAddCommand(BaseShape shape) { + if (shape == null) { + throw new NullPointerException("shape == null"); + } + + this.shape = shape; + } + + public void replay(ShapeContainer shapeContainer) { + // TODO Auto-generated method stub + + } + + public void rollback(ShapeContainer shapeContainer) { + // TODO Auto-generated method stub + + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + // TODO Auto-generated method stub + + } + + public void writeExternal(ObjectOutput out) throws IOException { + // TODO Auto-generated method stub + + } + + public String getDescription() { + try { + ShapeDescriptor shapeDesc = new ShapeDescriptor(this.shape.getClass()); + return "図形「" + shapeDesc.getName() + "」を追加。"; + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeAddEvent.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeAddEvent.java new file mode 100644 index 0000000..f1709e4 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeAddEvent.java @@ -0,0 +1,18 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; + +public class ShapeAddEvent { + + private BaseShape shape; + + public ShapeAddEvent(BaseShape shape) { + this.shape = shape; + } + + public BaseShape getShape() { + return this.shape; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeContainer.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeContainer.java new file mode 100644 index 0000000..31a0d2b --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeContainer.java @@ -0,0 +1,113 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; +import jp.gr.java_conf.u6k.online_stg_env.shape.ShapePropertyChangeEvent; +import jp.gr.java_conf.u6k.online_stg_env.shape.ShapePropertyChangeListener; + +public class ShapeContainer { + + private List listenerList = new ArrayList(); + + private List shapeList = new ArrayList(); + + private ShapePropertyChangeListener shapePropertyChangeListener = new ShapePropertyChangeListenerImpl(); + + private DataCommandContainer commandContainer; + + public ShapeContainer(DataCommandContainer commandContainer) { + if (commandContainer == null) { + throw new NullPointerException("commandContainer == null"); + } + + this.commandContainer = commandContainer; + } + + public void addListener(ShapeContainerListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.add(l); + } + + public void removeListener(ShapeContainerListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.remove(l); + } + + public void addShape(BaseShape shape) { + if (shape == null) { + throw new NullPointerException("shape == null"); + } + if (this.shapeList.contains(shape)) { + throw new IllegalArgumentException("shape is already added."); + } + + this.shapeList.add(shape); + + shape.addShapePropertyChangeListener(this.shapePropertyChangeListener); + + this.commandContainer.addCommand(new ShapeAddCommand(shape)); + + ShapeAddEvent event = new ShapeAddEvent(shape); + for (ShapeContainerListener l : this.listenerList.toArray(new ShapeContainerListener[0])) { + l.addShape(event); + } + } + + public void removeShape(BaseShape shape) { + if (shape == null) { + throw new NullPointerException("shape == null"); + } + if (!this.shapeList.contains(shape)) { + throw new IllegalArgumentException("shape is not contain."); + } + + int removedIndex = this.getShapeIndex(shape); + + shape.removeShapePropertyChangeListener(this.shapePropertyChangeListener); + + this.shapeList.remove(removedIndex); + + this.commandContainer.addCommand(new ShapeRemoveCommand(removedIndex, shape)); + + ShapeRemoveEvent event = new ShapeRemoveEvent(removedIndex, shape); + for (ShapeContainerListener l : this.listenerList.toArray(new ShapeContainerListener[0])) { + l.removeShape(event); + } + } + + public List getShapeList() { + return Collections.unmodifiableList(this.shapeList); + } + + private int getShapeIndex(BaseShape shape) { + if (shape == null) { + throw new NullPointerException("shape == null"); + } + + for (int i = 0; i < this.shapeList.size(); i++) { + if (this.shapeList.get(i) == shape) { + return i; + } + } + + throw new IllegalArgumentException("shape is not contain."); + } + + private final class ShapePropertyChangeListenerImpl implements ShapePropertyChangeListener { + + public void propertyChange(ShapePropertyChangeEvent event) { + ShapePropertyChangeCommand c = new ShapePropertyChangeCommand(ShapeContainer.this.getShapeIndex(event.getSource()), event.getSource(), event.getPropertyName(), event.getOldValue(), event.getNewValue()); + ShapeContainer.this.commandContainer.addCommand(c); + } + + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeContainerListener.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeContainerListener.java new file mode 100644 index 0000000..89b9a16 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeContainerListener.java @@ -0,0 +1,10 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +public interface ShapeContainerListener { + + void addShape(ShapeAddEvent event); + + void removeShape(ShapeRemoveEvent event); + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeInput.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeInput.java new file mode 100644 index 0000000..b1fee50 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeInput.java @@ -0,0 +1,119 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.io.IOException; +import java.io.ObjectInput; + +public class ShapeInput implements ObjectInput { + + public int available() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public void close() throws IOException { + // TODO Auto-generated method stub + + } + + public int read() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public int read(byte[] b) throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public int read(byte[] b, int off, int len) throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public Object readObject() throws ClassNotFoundException, IOException { + // TODO Auto-generated method stub + return null; + } + + public long skip(long n) throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public boolean readBoolean() throws IOException { + // TODO Auto-generated method stub + return false; + } + + public byte readByte() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public char readChar() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public double readDouble() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public float readFloat() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public void readFully(byte[] b) throws IOException { + // TODO Auto-generated method stub + + } + + public void readFully(byte[] b, int off, int len) throws IOException { + // TODO Auto-generated method stub + + } + + public int readInt() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public String readLine() throws IOException { + // TODO Auto-generated method stub + return null; + } + + public long readLong() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public short readShort() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public String readUTF() throws IOException { + // TODO Auto-generated method stub + return null; + } + + public int readUnsignedByte() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public int readUnsignedShort() throws IOException { + // TODO Auto-generated method stub + return 0; + } + + public int skipBytes(int n) throws IOException { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeOutput.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeOutput.java new file mode 100644 index 0000000..a3abcdf --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeOutput.java @@ -0,0 +1,94 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.io.IOException; +import java.io.ObjectOutput; + +public class ShapeOutput implements ObjectOutput { + + public void close() throws IOException { + // TODO Auto-generated method stub + + } + + public void flush() throws IOException { + // TODO Auto-generated method stub + + } + + public void write(int b) throws IOException { + // TODO Auto-generated method stub + + } + + public void write(byte[] b) throws IOException { + // TODO Auto-generated method stub + + } + + public void write(byte[] b, int off, int len) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeObject(Object obj) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeBoolean(boolean v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeByte(int v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeBytes(String s) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeChar(int v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeChars(String s) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeDouble(double v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeFloat(float v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeInt(int v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeLong(long v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeShort(int v) throws IOException { + // TODO Auto-generated method stub + + } + + public void writeUTF(String str) throws IOException { + // TODO Auto-generated method stub + + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapePropertyChangeCommand.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapePropertyChangeCommand.java new file mode 100644 index 0000000..d1ac388 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapePropertyChangeCommand.java @@ -0,0 +1,54 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; + +public class ShapePropertyChangeCommand implements DataCommand { + + private int shapeListIndex; + + private BaseShape shape; + + private String propertyName; + + private Object oldValue; + + private Object newValue; + + public ShapePropertyChangeCommand(int shapeListIndex, BaseShape shape, String propertyName, Object oldValue, Object newValue) { + this.shapeListIndex = shapeListIndex; + this.shape = shape; + this.propertyName = propertyName; + this.oldValue = oldValue; + this.newValue = newValue; + } + + public void replay(ShapeContainer shapeContainer) { + // TODO Auto-generated method stub + + } + + public void rollback(ShapeContainer shapeContainer) { + // TODO Auto-generated method stub + + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + // TODO Auto-generated method stub + + } + + public void writeExternal(ObjectOutput out) throws IOException { + // TODO Auto-generated method stub + + } + + public String getDescription() { + return "プロパティ「" + this.propertyName + "」を" + this.oldValue + "から" + this.newValue + "に変更。"; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeRemoveCommand.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeRemoveCommand.java new file mode 100644 index 0000000..e6dd68a --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeRemoveCommand.java @@ -0,0 +1,55 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import java.beans.IntrospectionException; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.net.MalformedURLException; + +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; +import jp.gr.java_conf.u6k.online_stg_env.shape.reflect.ShapeDescriptor; + +public class ShapeRemoveCommand implements DataCommand { + + private int removedIndex; + + private BaseShape removedShape; + + public ShapeRemoveCommand(int removedIndex, BaseShape removedShape) { + this.removedIndex = removedIndex; + this.removedShape = removedShape; + } + + public void replay(ShapeContainer shapeContainer) { + // TODO Auto-generated method stub + + } + + public void rollback(ShapeContainer shapeContainer) { + // TODO Auto-generated method stub + + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + // TODO Auto-generated method stub + + } + + public void writeExternal(ObjectOutput out) throws IOException { + // TODO Auto-generated method stub + + } + + public String getDescription() { + try { + ShapeDescriptor shapeDesc = new ShapeDescriptor(this.removedShape.getClass()); + return "図形「" + shapeDesc.getName() + "」を削除。"; + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeRemoveEvent.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeRemoveEvent.java new file mode 100644 index 0000000..bfcfbac --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/data/ShapeRemoveEvent.java @@ -0,0 +1,25 @@ + +package jp.gr.java_conf.u6k.online_stg_env.data; + +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; + +public class ShapeRemoveEvent { + + private int removedIndex; + + private BaseShape shape; + + public ShapeRemoveEvent(int removedIndex, BaseShape shape) { + this.removedIndex = removedIndex; + this.shape = shape; + } + + public int getRemovedIndex() { + return this.removedIndex; + } + + public BaseShape getShape() { + return this.shape; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/BackgroundShape.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/BackgroundShape.java new file mode 100644 index 0000000..492c0df --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/BackgroundShape.java @@ -0,0 +1,132 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.util.ArrayList; +import java.util.List; + +@ShapeName(value = "背景") +@ShapeDescription(value="キャンバスの背景です。この図形はキャンバスの作成時に自動で一度だけ作成されるもので、ユーザが作成することはできません。属性を変更することはできます。") +public class BackgroundShape implements BaseShape { + + private List listenerList = new ArrayList(); + + private boolean completed = false; + + private Color color = Color.WHITE; + + private int width = 0; + + private int height = 0; + + public void addShapePropertyChangeListener(ShapePropertyChangeListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.add(l); + } + + public void createEnd(Component canvas) { + throw new UnsupportedOperationException("BackgroundShape can not create."); + } + + public void createStart(Component canvas) { + throw new UnsupportedOperationException("BackgroundShape can not create."); + } + + public void draw(Graphics g) { + if (this.getWidth() <= 0 || this.getHeight() <= 0) { + throw new IllegalStateException("width <= 0 || height <= 0"); + } + if (this.getColor() == null) { + throw new IllegalStateException("color == null"); + } + + g.setColor(this.color); + g.fillRect(0, 0, this.width, this.height); + } + + public boolean isCompleted() { + return this.completed; + } + + private void setCompleted(boolean completed) { + boolean oldCompleted = this.completed; + this.completed = completed; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "completed", oldCompleted, completed); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + public void removeShapePropertyChangeListener(ShapePropertyChangeListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.remove(l); + } + + @ShapeProperty + public Color getColor() { + return this.color; + } + + @ShapeProperty + public void setColor(Color color) { + if (color == null) { + throw new NullPointerException("color == null"); + } + + Color oldColor = this.color; + this.color = color; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "color", oldColor, color); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + @ShapeProperty + public int getWidth() { + return this.width; + } + + @ShapeProperty + public void setWidth(int width) { + if (width <= 0) { + throw new IllegalArgumentException("width <= 0"); + } + + int oldWidth = this.width; + this.width = width; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "width", oldWidth, width); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + @ShapeProperty + public int getHeight() { + return this.height; + } + + @ShapeProperty + public void setHeight(int height) { + if (height <= 0) { + throw new IllegalArgumentException("height <= 0"); + } + + int oldHeight = this.height; + this.height = height; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "height", oldHeight, height); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/BaseShape.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/BaseShape.java new file mode 100644 index 0000000..e3e4829 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/BaseShape.java @@ -0,0 +1,21 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +import java.awt.Component; +import java.awt.Graphics; + +public interface BaseShape { + + void addShapePropertyChangeListener(ShapePropertyChangeListener l); + + void removeShapePropertyChangeListener(ShapePropertyChangeListener l); + + void draw(Graphics g); + + void createStart(Component canvas); + + void createEnd(Component canvas); + + boolean isCompleted(); + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/FreehandLineShape.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/FreehandLineShape.java new file mode 100644 index 0000000..5228bbb --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/FreehandLineShape.java @@ -0,0 +1,166 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseMotionListener; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import jp.gr.java_conf.u6k.online_stg_env.ImmutablePoint; + +@ShapeName(value = "自由線") +@ShapeIcon(resourceName = "resources/FreehandLineShape.gif") +@ShapeDescription(value = "自由な線です。マウスの軌跡に沿って線を作成できます。") +public class FreehandLineShape implements BaseShape { + + private List listenerList = new ArrayList(); + + private boolean completed; + + private List pointList = new ArrayList(); + + private Color color = Color.BLACK; + + private MouseListener l1; + + private MouseMotionListener l2; + + public void addShapePropertyChangeListener(ShapePropertyChangeListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.add(l); + } + + public void createEnd(Component canvas) { + canvas.removeMouseListener(this.l1); + canvas.removeMouseMotionListener(this.l2); + } + + public void createStart(Component canvas) { + if (this.isCompleted()) { + throw new IllegalStateException("already completed."); + } + + this.l1 = new MouseAdapterImpl(); + this.l2 = new MouseMotionAdapterImpl(); + + canvas.addMouseListener(this.l1); + canvas.addMouseMotionListener(this.l2); + } + + public void draw(Graphics g) { + List pl = this.getPointList(); + if (pl.size() < 2) { + return; + } + if (this.getColor() == null) { + throw new IllegalStateException("color == null"); + } + + g.setColor(this.getColor()); + for (int i = 0; i < (pl.size() - 1); i++) { + ImmutablePoint p1 = pl.get(i); + ImmutablePoint p2 = pl.get(i + 1); + g.drawLine(p1.getX(), p1.getY(), p2.getX(), p2.getY()); + } + } + + public boolean isCompleted() { + return this.completed; + } + + private void setCompleted(boolean completed) { + boolean oldCompleted = this.completed; + this.completed = completed; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "completed", oldCompleted, completed); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + public void removeShapePropertyChangeListener(ShapePropertyChangeListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.remove(l); + } + + @ShapeProperty + public Color getColor() { + return this.color; + } + + @ShapeProperty + public void setColor(Color color) { + if (color == null) { + throw new NullPointerException("color == null"); + } + + Color oldColor = this.color; + this.color = color; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "color", oldColor, color); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + @ShapeProperty + public List getPointList() { + return Collections.unmodifiableList(this.pointList); + } + + public void addPoint(ImmutablePoint point) { + if (point == null) { + throw new NullPointerException("point == null"); + } + + this.pointList.add(point); + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "pointList", null, point); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + private class MouseAdapterImpl extends MouseAdapter { + + @Override + public void mousePressed(MouseEvent e) { + if (!FreehandLineShape.this.isCompleted()) { + FreehandLineShape.this.addPoint(new ImmutablePoint(e.getPoint())); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if (!FreehandLineShape.this.isCompleted()) { + FreehandLineShape.this.addPoint(new ImmutablePoint(e.getPoint())); + + FreehandLineShape.this.setCompleted(true); + } + } + + } + + private class MouseMotionAdapterImpl extends MouseMotionAdapter { + + @Override + public void mouseDragged(MouseEvent e) { + if (!FreehandLineShape.this.isCompleted()) { + FreehandLineShape.this.addPoint(new ImmutablePoint(e.getPoint())); + } + } + + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/LineShape.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/LineShape.java new file mode 100644 index 0000000..b60100a --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/LineShape.java @@ -0,0 +1,189 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseMotionListener; +import java.util.ArrayList; +import java.util.List; + +import jp.gr.java_conf.u6k.online_stg_env.ImmutablePoint; + +@ShapeName(value = "直線") +@ShapeIcon(resourceName = "resources/LineShape.gif") +@ShapeDescription(value = "直線です。") +public class LineShape implements BaseShape { + + private List listenerList = new ArrayList(); + + private boolean completed; + + private ImmutablePoint point1; + + private ImmutablePoint point2; + + private Color color = Color.BLACK; + + private MouseListener l1; + + private MouseMotionListener l2; + + public void addShapePropertyChangeListener(ShapePropertyChangeListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.add(l); + } + + public void createEnd(Component canvas) { + canvas.removeMouseListener(this.l1); + canvas.removeMouseMotionListener(this.l2); + } + + public void createStart(Component canvas) { + if (this.isCompleted()) { + throw new IllegalStateException("already completed."); + } + + this.l1 = new MouseAdapterImpl(); + this.l2 = new MouseMotionAdapterImpl(); + + canvas.addMouseListener(this.l1); + canvas.addMouseMotionListener(this.l2); + } + + public void draw(Graphics g) { + if (this.getPoint1() == null || this.getPoint2() == null) { + return; + } + if (this.getColor() == null) { + throw new IllegalStateException("color == null"); + } + + g.setColor(this.color); + g.drawLine(this.getPoint1().getX(), this.getPoint1().getY(), this.getPoint2().getX(), this.getPoint2().getY()); + } + + public boolean isCompleted() { + return this.completed; + } + + private void setCompleted(boolean completed) { + boolean oldCompleted = this.completed; + this.completed = completed; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "completed", oldCompleted, completed); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + public void removeShapePropertyChangeListener(ShapePropertyChangeListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.remove(l); + } + + @ShapeProperty + public Color getColor() { + return this.color; + } + + @ShapeProperty + public void setColor(Color color) { + if (color == null) { + throw new NullPointerException("color == null"); + } + + Color oldColor = this.color; + this.color = color; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "color", oldColor, color); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + @ShapeProperty + public ImmutablePoint getPoint1() { + return this.point1; + } + + public void setPoint1(ImmutablePoint point1) { + if (point1 == null) { + throw new NullPointerException("point1 == null"); + } + + ImmutablePoint oldPoint1 = this.point1; + this.point1 = point1; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "point1", oldPoint1, point1); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + @ShapeProperty + public ImmutablePoint getPoint2() { + return this.point2; + } + + public void setPoint2(ImmutablePoint point2) { + if (point2 == null) { + throw new NullPointerException("point2 == null"); + } + + ImmutablePoint oldPoint2 = this.point2; + this.point2 = point2; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "point2", oldPoint2, point2); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + private class MouseAdapterImpl extends MouseAdapter { + + @Override + public void mousePressed(MouseEvent e) { + if (!LineShape.this.completed) { + LineShape.this.setPoint1(new ImmutablePoint(e.getPoint())); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if (!LineShape.this.completed) { + if (LineShape.this.getPoint1() == null) { + throw new IllegalStateException("point1 == null"); + } + + LineShape.this.setPoint2(new ImmutablePoint(e.getPoint())); + + LineShape.this.setCompleted(true); + } + } + + } + + private class MouseMotionAdapterImpl extends MouseMotionAdapter { + + @Override + public void mouseDragged(MouseEvent e) { + if (!LineShape.this.completed) { + if (LineShape.this.getPoint1() == null) { + throw new IllegalStateException("point1 == null"); + } + + LineShape.this.setPoint2(new ImmutablePoint(e.getPoint())); + } + } + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/OvalShape.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/OvalShape.java new file mode 100644 index 0000000..a46afc0 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/OvalShape.java @@ -0,0 +1,223 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseMotionListener; +import java.util.ArrayList; +import java.util.List; + +import jp.gr.java_conf.u6k.online_stg_env.ImmutableDimension; +import jp.gr.java_conf.u6k.online_stg_env.ImmutablePoint; +import jp.gr.java_conf.u6k.online_stg_env.ImmutableRectangle; + +@ShapeName(value="円(楕円)") +@ShapeIcon(resourceName="resources/OvalShape.gif") +@ShapeDescription(value="円(楕円)です。") +public class OvalShape implements BaseShape { + + private List listenerList = new ArrayList(); + + private boolean completed; + + private ImmutablePoint location; + + private ImmutableDimension size; + + private Color borderColor = Color.BLACK; + + private Color contentColor; + + private MouseListener l1; + + private MouseMotionListener l2; + + public void addShapePropertyChangeListener(ShapePropertyChangeListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.add(l); + } + + public void createEnd(Component canvas) { + canvas.removeMouseListener(this.l1); + canvas.removeMouseMotionListener(this.l2); + } + + public void createStart(Component canvas) { + if (this.isCompleted()) { + throw new IllegalStateException("already completed."); + } + + this.l1 = new MouseAdapterImpl(); + this.l2 = new MouseMotionAdapterImpl(); + + canvas.addMouseListener(this.l1); + canvas.addMouseMotionListener(this.l2); + } + + public void draw(Graphics g) { + if (this.getLocation() == null || this.getSize() == null) { + return; + } + if (this.getBorderColor() == null) { + throw new IllegalStateException("borderColor == null"); + } + + ImmutablePoint p1 = this.location; + ImmutablePoint p2 = new ImmutablePoint(p1.getX() + this.getSize().getWidth(), p1.getY() + this.getSize().getHeight()); + ImmutableRectangle r = ImmutableRectangle.normalize(p1, p2); + + if (this.getContentColor() != null) { + g.setColor(this.getContentColor()); + g.fillOval(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + } + + g.setColor(this.getBorderColor()); + g.drawOval(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + } + + public boolean isCompleted() { + return this.completed; + } + + private void setCompleted(boolean completed) { + boolean oldCompleted = this.completed; + this.completed = completed; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "completed", oldCompleted, completed); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + public void removeShapePropertyChangeListener(ShapePropertyChangeListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.remove(l); + } + + @ShapeProperty + public ImmutablePoint getLocation() { + return this.location; + } + + public void setLocation(ImmutablePoint location) { + if (location == null) { + throw new NullPointerException("location == null"); + } + + ImmutablePoint oldLocation = this.location; + this.location = location; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "location", oldLocation, location); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + @ShapeProperty + public ImmutableDimension getSize() { + return this.size; + } + + public void setSize(ImmutableDimension size) { + if (size == null) { + throw new NullPointerException("size == null"); + } + + ImmutableDimension oldSize = this.size; + this.size = size; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "size", oldSize, size); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + @ShapeProperty + public Color getBorderColor() { + return this.borderColor; + } + + @ShapeProperty + public void setBorderColor(Color borderColor) { + if (borderColor == null) { + throw new NullPointerException("borderColor == null"); + } + + Color oldBorderColor = this.borderColor; + this.borderColor = borderColor; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "borderColor", oldBorderColor, borderColor); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + @ShapeProperty + public Color getContentColor() { + return this.contentColor; + } + + @ShapeProperty + public void setContentColor(Color contentColor) { + if (contentColor == null) { + throw new NullPointerException("contentColor == null"); + } + + Color oldContentColor = this.contentColor; + this.contentColor = contentColor; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "contentColor", oldContentColor, contentColor); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + private class MouseAdapterImpl extends MouseAdapter { + + @Override + public void mousePressed(MouseEvent e) { + if (!OvalShape.this.isCompleted()) { + OvalShape.this.setLocation(new ImmutablePoint(e.getPoint())); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if (!OvalShape.this.isCompleted()) { + if (OvalShape.this.getLocation() == null) { + throw new IllegalStateException("location == null"); + } + + OvalShape.this.setSize(new ImmutableDimension(e.getX() - OvalShape.this.getLocation().getX(), e.getY() - OvalShape.this.getLocation().getY())); + + OvalShape.this.setCompleted(true); + } + } + + } + + private class MouseMotionAdapterImpl extends MouseMotionAdapter { + + @Override + public void mouseDragged(MouseEvent e) { + if (!OvalShape.this.isCompleted()) { + if (OvalShape.this.getLocation() == null) { + throw new IllegalStateException("location == null"); + } + + OvalShape.this.setSize(new ImmutableDimension(e.getX() - OvalShape.this.getLocation().getX(), e.getY() - OvalShape.this.getLocation().getY())); + } + } + + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/RectangleShape.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/RectangleShape.java new file mode 100644 index 0000000..76b60c0 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/RectangleShape.java @@ -0,0 +1,222 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseMotionListener; +import java.util.ArrayList; +import java.util.List; + +import jp.gr.java_conf.u6k.online_stg_env.ImmutableDimension; +import jp.gr.java_conf.u6k.online_stg_env.ImmutablePoint; +import jp.gr.java_conf.u6k.online_stg_env.ImmutableRectangle; + +@ShapeName(value="四角形(長方形)") +@ShapeIcon(resourceName="resources/RectangleShape.gif") +@ShapeDescription(value="四角形(長方形)です。") +public class RectangleShape implements BaseShape { + + private List listenerList = new ArrayList(); + + private boolean completed; + + private ImmutablePoint location; + + private ImmutableDimension size; + + private Color borderColor = Color.BLACK; + + private Color contentColor = null; + + private MouseListener l1; + + private MouseMotionListener l2; + + public void addShapePropertyChangeListener(ShapePropertyChangeListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.add(l); + } + + public void createEnd(Component canvas) { + canvas.removeMouseListener(this.l1); + canvas.removeMouseMotionListener(this.l2); + } + + public void createStart(Component canvas) { + if (this.isCompleted()) { + throw new IllegalStateException("already completed."); + } + + this.l1 = new MouseAdapterImpl(); + this.l2 = new MouseMotionAdapterImpl(); + + canvas.addMouseListener(this.l1); + canvas.addMouseMotionListener(this.l2); + } + + public void draw(Graphics g) { + if (this.getLocation() == null || this.getSize() == null) { + return; + } + if (this.getBorderColor() == null) { + throw new IllegalStateException("borderColor == null"); + } + + ImmutablePoint p1 = this.location; + ImmutablePoint p2 = new ImmutablePoint(p1.getX() + this.getSize().getWidth(), p1.getY() + this.getSize().getHeight()); + ImmutableRectangle r = ImmutableRectangle.normalize(p1, p2); + + if (this.getContentColor() != null) { + g.setColor(this.getContentColor()); + g.fillRect(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + } + + g.setColor(this.getBorderColor()); + g.drawRect(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + } + + public boolean isCompleted() { + return this.completed; + } + + private void setCompleted(boolean completed) { + boolean oldCompleted = this.completed; + this.completed = completed; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "completed", oldCompleted, completed); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + public void removeShapePropertyChangeListener(ShapePropertyChangeListener l) { + if (l == null) { + throw new NullPointerException("l == null"); + } + this.listenerList.remove(l); + } + + @ShapeProperty + public ImmutablePoint getLocation() { + return this.location; + } + + public void setLocation(ImmutablePoint location) { + if (location == null) { + throw new NullPointerException("location == null"); + } + + ImmutablePoint oldLocation = this.location; + this.location = location; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "location", oldLocation, location); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + @ShapeProperty + public ImmutableDimension getSize() { + return this.size; + } + + public void setSize(ImmutableDimension size) { + if (size == null) { + throw new NullPointerException("size == null"); + } + + ImmutableDimension oldSize = this.size; + this.size = size; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "size", oldSize, size); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + @ShapeProperty + public Color getBorderColor() { + return this.borderColor; + } + + @ShapeProperty + public void setBorderColor(Color borderColor) { + if (borderColor == null) { + throw new NullPointerException("borderColor == null"); + } + + Color oldBorderColor = this.borderColor; + this.borderColor = borderColor; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "borderColor", oldBorderColor, borderColor); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + @ShapeProperty + public Color getContentColor() { + return this.contentColor; + } + + @ShapeProperty + public void setContentColor(Color contentColor) { + if (contentColor == null) { + throw new NullPointerException("contentColor == null"); + } + + Color oldContentColor = this.contentColor; + this.contentColor = contentColor; + + ShapePropertyChangeEvent event = new ShapePropertyChangeEvent(this, "contentColor", oldContentColor, contentColor); + for (ShapePropertyChangeListener l : this.listenerList.toArray(new ShapePropertyChangeListener[0])) { + l.propertyChange(event); + } + } + + private class MouseAdapterImpl extends MouseAdapter { + + @Override + public void mousePressed(MouseEvent e) { + if (!RectangleShape.this.isCompleted()) { + RectangleShape.this.setLocation(new ImmutablePoint(e.getPoint())); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if (!RectangleShape.this.isCompleted()) { + if (RectangleShape.this.getLocation() == null) { + throw new IllegalStateException("location == null"); + } + + RectangleShape.this.setSize(new ImmutableDimension(e.getX() - RectangleShape.this.getLocation().getX(), e.getY() - RectangleShape.this.getLocation().getY())); + + RectangleShape.this.setCompleted(true); + } + } + } + + private class MouseMotionAdapterImpl extends MouseMotionAdapter { + + @Override + public void mouseDragged(MouseEvent e) { + if (!RectangleShape.this.isCompleted()) { + if (RectangleShape.this.getLocation() == null) { + throw new IllegalStateException("location == null"); + } + + RectangleShape.this.setSize(new ImmutableDimension(e.getX() - RectangleShape.this.getLocation().getX(), e.getY() - RectangleShape.this.getLocation().getY())); + } + } + + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeDescription.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeDescription.java new file mode 100644 index 0000000..bc6c0d8 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeDescription.java @@ -0,0 +1,19 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface ShapeDescription { + + String value() default ""; + + String resourceBaseName() default ""; + + String resourceKey() default ""; + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeIcon.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeIcon.java new file mode 100644 index 0000000..09ccb0b --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeIcon.java @@ -0,0 +1,17 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface ShapeIcon { + + String resourceName() default ""; + + String url() default ""; + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeName.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeName.java new file mode 100644 index 0000000..e335b09 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeName.java @@ -0,0 +1,19 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface ShapeName { + + String value() default ""; + + String resourceBaseName() default ""; + + String resourceKey() default ""; + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeProperty.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeProperty.java new file mode 100644 index 0000000..7a8b1f0 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapeProperty.java @@ -0,0 +1,13 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface ShapeProperty { + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapePropertyChangeEvent.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapePropertyChangeEvent.java new file mode 100644 index 0000000..fa1b841 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapePropertyChangeEvent.java @@ -0,0 +1,37 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +public class ShapePropertyChangeEvent { + + private BaseShape source; + + private String propertyName; + + private Object oldValue; + + private Object newValue; + + public ShapePropertyChangeEvent(BaseShape source, String propertyName, Object oldValue, Object newValue) { + this.source = source; + this.propertyName = propertyName; + this.oldValue = oldValue; + this.newValue = newValue; + } + + public BaseShape getSource() { + return this.source; + } + + public String getPropertyName() { + return this.propertyName; + } + + public Object getOldValue() { + return this.oldValue; + } + + public Object getNewValue() { + return this.newValue; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapePropertyChangeListener.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapePropertyChangeListener.java new file mode 100644 index 0000000..58a68d0 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/ShapePropertyChangeListener.java @@ -0,0 +1,8 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape; + +public interface ShapePropertyChangeListener { + + void propertyChange(ShapePropertyChangeEvent event); + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapeDescriptor.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapeDescriptor.java new file mode 100644 index 0000000..09d6ace --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapeDescriptor.java @@ -0,0 +1,85 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape.reflect; + +import java.beans.IntrospectionException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ResourceBundle; + +import javax.swing.Icon; +import javax.swing.ImageIcon; + +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; +import jp.gr.java_conf.u6k.online_stg_env.shape.ShapeDescription; +import jp.gr.java_conf.u6k.online_stg_env.shape.ShapeIcon; +import jp.gr.java_conf.u6k.online_stg_env.shape.ShapeName; + +public class ShapeDescriptor { + + private String name; + + private Icon icon; + + private String description; + + public ShapeDescriptor(Class shapeClazz) throws IntrospectionException, MalformedURLException { + if (shapeClazz == null) { + throw new NullPointerException("shapeClazz == null"); + } + + if (shapeClazz.getAnnotation(ShapeName.class) != null) { + ShapeName nameAnno = shapeClazz.getAnnotation(ShapeName.class); + + if (!"".equals(nameAnno.value())) { + this.name = nameAnno.value(); + } else if (!"".equals(nameAnno.resourceBaseName()) && !"".equals(nameAnno.resourceKey())) { + this.name = ResourceBundle.getBundle(nameAnno.resourceBaseName()).getString(nameAnno.resourceKey()); + } else { + throw new IntrospectionException("「" + shapeClazz.getName() + "」型に対するShapeNameアノテーションの属性の指定が間違えています。"); + } + } else { + this.name = shapeClazz.getSimpleName(); + } + + if (shapeClazz.getAnnotation(ShapeIcon.class) != null) { + ShapeIcon iconAnno = shapeClazz.getAnnotation(ShapeIcon.class); + + if (!"".equals(iconAnno.resourceName())) { + this.icon = new ImageIcon(this.getClass().getClassLoader().getResource(iconAnno.resourceName())); + } else if (!"".equals(iconAnno.url())) { + this.icon = new ImageIcon(new URL(iconAnno.url())); + } else { + throw new IntrospectionException("「" + shapeClazz.getName() + "」型に対するShapeIconアノテーションの属性の指定が間違えています。"); + } + } else { + this.icon = null; + } + + if (shapeClazz.getAnnotation(ShapeDescription.class) != null) { + ShapeDescription descAnno = shapeClazz.getAnnotation(ShapeDescription.class); + + if (!"".equals(descAnno.value())) { + this.description = descAnno.value(); + } else if (!"".equals(descAnno.resourceBaseName()) && !"".equals(descAnno.resourceKey())) { + this.description = ResourceBundle.getBundle(descAnno.resourceBaseName()).getString(descAnno.resourceKey()); + } else { + throw new IntrospectionException("「" + shapeClazz.getName() + "」型に対するShapeDescriptionアノテーションの属性の指定が間違えています。"); + } + } else { + this.description = null; + } + } + + public String getName() { + return this.name; + } + + public Icon getIcon() { + return this.icon; + } + + public String getDescription() { + return this.description; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapePropertyDescriptor.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapePropertyDescriptor.java new file mode 100644 index 0000000..076b0ea --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapePropertyDescriptor.java @@ -0,0 +1,114 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape.reflect; + +import java.beans.IntrospectionException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import jp.gr.java_conf.u6k.online_stg_env.shape.BaseShape; +import jp.gr.java_conf.u6k.online_stg_env.shape.ShapeProperty; + +public class ShapePropertyDescriptor { + + private String name; + + private Class type; + + private Method getterMethod; + + private Method setterMethod; + + public ShapePropertyDescriptor(String name, Class shapeClazz) throws NoSuchMethodException, IntrospectionException { + if (name == null) { + throw new NullPointerException("name == null"); + } + if (shapeClazz == null) { + throw new NullPointerException("shapeClazz == null"); + } + + String propertyBaseName = name.substring(0, 1).toUpperCase(Locale.getDefault()) + name.substring(1); + this.getterMethod = this.getMethod(shapeClazz, "get" + propertyBaseName); + if (this.getterMethod == null) { + this.getterMethod = this.getMethod(shapeClazz, "is" + propertyBaseName); + if (this.getterMethod == null) { + throw new NoSuchMethodException("「get" + propertyBaseName + "」メソッド、及び「is" + propertyBaseName + "」メソッドが見つかりませんでした。"); + } + } + + if (this.getterMethod.getAnnotation(ShapeProperty.class) == null) { + throw new IntrospectionException("「" + this.getterMethod.getName() + "」メソッドはShapePropertyアノテーションを付加されていません。"); + } + + this.name = propertyBaseName.substring(0, 1).toLowerCase(Locale.getDefault()) + propertyBaseName.substring(1); + + this.type = this.getterMethod.getReturnType(); + + this.setterMethod = this.getMethod(shapeClazz, "set" + propertyBaseName, this.type); + if (this.setterMethod != null) { + if (this.setterMethod.getAnnotation(ShapeProperty.class) == null) { + this.setterMethod = null; + } + } + } + + private Method getMethod(Class clazz, String methodName, Class... parameterTypes) { + try { + return clazz.getMethod(methodName, parameterTypes); + } catch (SecurityException e) { + return null; + } catch (NoSuchMethodException e) { + return null; + } + } + + public String getName() { + return this.name; + } + + public Class getType() { + return this.type; + } + + public Method getGetterMethod() { + return this.getterMethod; + } + + public Method getSetterMethod() { + return this.setterMethod; + } + + public static List getPropertyDescriptorList(Class shapeClazz) { + if (shapeClazz == null) { + throw new NullPointerException("shapeClazz == null"); + } + + List l = new ArrayList(); + + for (Method m : shapeClazz.getMethods()) { + String n = null; + if (m.getName().startsWith("get")) { + n = m.getName().substring("get".length()); + n = n.substring(0, 1).toLowerCase(Locale.getDefault()) + n.substring(1); + } else if (m.getName().startsWith("is")) { + n = m.getName().substring("is".length()); + n = n.substring(0, 1).toLowerCase(Locale.getDefault()) + n.substring(1); + } + if (n != null) { + if (m.getAnnotation(ShapeProperty.class) != null) { + try { + l.add(new ShapePropertyDescriptor(n, shapeClazz)); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IntrospectionException e) { + e.printStackTrace(); + } + } + } + } + + return l; + } + +} diff --git a/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapePropertyDescriptorComparator.java b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapePropertyDescriptorComparator.java new file mode 100644 index 0000000..d729e53 --- /dev/null +++ b/online-stg-env/src/main/java/jp/gr/java_conf/u6k/online_stg_env/shape/reflect/ShapePropertyDescriptorComparator.java @@ -0,0 +1,12 @@ + +package jp.gr.java_conf.u6k.online_stg_env.shape.reflect; + +import java.util.Comparator; + +public class ShapePropertyDescriptorComparator implements Comparator { + + public int compare(ShapePropertyDescriptor o1, ShapePropertyDescriptor o2) { + return o1.getName().compareTo(o2.getName()); + } + +} diff --git a/online-stg-env/src/main/php/app/.htaccess b/online-stg-env/src/main/php/app/.htaccess new file mode 100644 index 0000000..e019832 --- /dev/null +++ b/online-stg-env/src/main/php/app/.htaccess @@ -0,0 +1 @@ +deny from all diff --git a/online-stg-env/src/main/php/app/common.inc b/online-stg-env/src/main/php/app/common.inc new file mode 100644 index 0000000..a52fc18 --- /dev/null +++ b/online-stg-env/src/main/php/app/common.inc @@ -0,0 +1,91 @@ +" . $d["data"] . ""; + return $str; +} + +function return_xml0($data) { + $returnData = array(); + if (is_array($data)) { + $returnData["type"] = "map"; + $returnData["data"] = ""; + foreach ($data as $k => $v) { + $d = return_xml0($v); + $returnData["data"] .= "<" . $k . " type=\"" . $d["type"] . "\">" . $d["data"] . ""; + } + } elseif (is_int($data)) { + $returnData["type"] = "integer"; + $returnData["data"] = strval($data); + } elseif (is_float($data)) { + $returnData["type"] = "float"; + $returnData["data"] = strval($data); + } elseif (is_bool($data)) { + $returnData["type"] = "boolean"; + if ($data) { + $returnData["data"] = "true"; + } else { + $returnData["data"] = "false"; + } + } elseif (is_string($data)) { + $returnData["type"] = "string"; + $returnData["data"] = rawurlencode($data); + } else { + $returnData["type"] = "other"; + $returnData["data"] = rawurlencode(strval($data)); + } + return $returnData; +} + +/** + * ƒGƒ‰[‚ª”­¶‚µ‚½‚±‚Æ‚ð•\‚·XMLŒ`Ž®‚Ì•¶Žš—ñ‚ð$g_error_xmlƒOƒ[ƒoƒ‹•Ï”‚ɏo—Í‚µAFALSE‚ð•Ô‚µ‚Ü‚·B + * $g_error_xmlƒOƒ[ƒoƒ‹•Ï”‚ɏo—Í‚³‚ê‚éXML•¶Žš—ñ‚ÍWeb API‚Ì–ß‚è’l‚Æ‚µ‚ÄŽg—p‚³‚ê‚邱‚Æ‚ð‘z’肵‚Ä‚¢‚Ü‚·B + * + * @param string $errorType + * ƒGƒ‰[‚ÌŽí—ށB‹@ŠB“I‚É“Ç‚ÝŽæ‚è‚â‚·‚¢ˆêˆÓ‚ÌŽ¯•Ê•¶Žš—ñ‚ðŽw’肵‚Ä‚­‚¾‚³‚¢B‚ ‚ç‚©‚¶‚ߒ萔‚É‚µ‚Ä‚¨‚­‚Ə®—Ç‚¢‚Å‚·B + * @param string $errorMessage + * ƒGƒ‰[‚ÌÚ×‚Èà–¾B + * @param mixed $data + * ƒGƒ‰[‚Ì‚»‚Ì‘¼‚̏î•ñBreturn_xml()ŠÖ”‚Æ“¯‚¶Œ`Ž®‚ÌXML•¶Žš—ñ‚É•ÏŠ·‚³‚ê‚Ü‚·B + * @return í‚ÉFALSEB + */ +function error_xml($errorType, $errorMessage, $data = null) { + $str = "" . rawurlencode($errorType) . ""; + if (!empty($errorMessage)) { + $str .= "" . rawurlencode($errorMessage) . ""; + } + if (!empty($data)) { + $d = return_xml0($data); + $str .= "" . $d["data"] . ""; + } + $str .= ""; + + global $g_error_xml; + $g_error_xml = $str; + + return FALSE; +} + +/* + * ’萔 + */ +define("ERROR_AUTH_FAIL", "auth fail"); +define("ERROR_NOT_CHALLENGE", "not challenge"); +define("ERROR_IO", "io error"); +define("ERROR_AUTH", "auth fail"); +define("ERROR_EMPTY", "empty"); +define("ERROR_POST_WRONG", "post is wrong"); + +/* + * ƒOƒ[ƒoƒ‹•Ï” + */ +$g_error_xml; +?> diff --git a/online-stg-env/src/main/php/app/core.inc b/online-stg-env/src/main/php/app/core.inc new file mode 100644 index 0000000..9f87903 --- /dev/null +++ b/online-stg-env/src/main/php/app/core.inc @@ -0,0 +1,54 @@ + diff --git a/online-stg-env/src/main/php/app/get_challenge.inc b/online-stg-env/src/main/php/app/get_challenge.inc new file mode 100644 index 0000000..b3ec087 --- /dev/null +++ b/online-stg-env/src/main/php/app/get_challenge.inc @@ -0,0 +1,13 @@ + diff --git a/online-stg-env/src/main/php/app/login.inc b/online-stg-env/src/main/php/app/login.inc new file mode 100644 index 0000000..0c49878 --- /dev/null +++ b/online-stg-env/src/main/php/app/login.inc @@ -0,0 +1,56 @@ + diff --git a/online-stg-env/src/main/php/app/open_data_file.inc b/online-stg-env/src/main/php/app/open_data_file.inc new file mode 100644 index 0000000..9c2bfdf --- /dev/null +++ b/online-stg-env/src/main/php/app/open_data_file.inc @@ -0,0 +1,44 @@ + diff --git a/online-stg-env/src/main/php/app/read_data_file.inc b/online-stg-env/src/main/php/app/read_data_file.inc new file mode 100644 index 0000000..4be1685 --- /dev/null +++ b/online-stg-env/src/main/php/app/read_data_file.inc @@ -0,0 +1,41 @@ + 0) { + if (FALSE == ($content = @fread($fp, $fstat["size"]))) { + @fclose($fp); + return error_xml(ERROR_IO, "data file read fail."); + } + } else { + $content = ""; + } + + @fclose($fp); + + return $content; +} +?> diff --git a/online-stg-env/src/main/php/app/write_data_file.inc b/online-stg-env/src/main/php/app/write_data_file.inc new file mode 100644 index 0000000..101be57 --- /dev/null +++ b/online-stg-env/src/main/php/app/write_data_file.inc @@ -0,0 +1,45 @@ + diff --git a/online-stg-env/src/main/php/data/.htaccess b/online-stg-env/src/main/php/data/.htaccess new file mode 100644 index 0000000..e019832 --- /dev/null +++ b/online-stg-env/src/main/php/data/.htaccess @@ -0,0 +1 @@ +deny from all diff --git a/online-stg-env/src/main/php/foo.html b/online-stg-env/src/main/php/foo.html new file mode 100644 index 0000000..27197d3 --- /dev/null +++ b/online-stg-env/src/main/php/foo.html @@ -0,0 +1,3 @@ + +Test JavaWebStart + \ No newline at end of file diff --git a/online-stg-env/src/main/php/jws/.htaccess b/online-stg-env/src/main/php/jws/.htaccess new file mode 100644 index 0000000..a1e226d --- /dev/null +++ b/online-stg-env/src/main/php/jws/.htaccess @@ -0,0 +1 @@ +AddType application/x-java-jnlp-file jnlp diff --git a/online-stg-env/src/main/php/jws/online-stg-env.jnlp b/online-stg-env/src/main/php/jws/online-stg-env.jnlp new file mode 100644 index 0000000..6137814 --- /dev/null +++ b/online-stg-env/src/main/php/jws/online-stg-env.jnlp @@ -0,0 +1,16 @@ + + + + Online STG Environment + u6k + オンラインでSTGを作成する開発環境です。 + + + + + + + + diff --git a/online-stg-env/src/main/php/online-stg-env.php b/online-stg-env/src/main/php/online-stg-env.php new file mode 100644 index 0000000..4c95620 --- /dev/null +++ b/online-stg-env/src/main/php/online-stg-env.php @@ -0,0 +1,3 @@ + diff --git a/online-stg-env/src/main/resources/online-stg-env.properties b/online-stg-env/src/main/resources/online-stg-env.properties new file mode 100644 index 0000000..4da78bb --- /dev/null +++ b/online-stg-env/src/main/resources/online-stg-env.properties @@ -0,0 +1 @@ +url=http://10.10.12.84/online-stg-env/online-stg-env.php diff --git a/online-stg-env/src/main/resources/resources/FreehandLineShape.gif b/online-stg-env/src/main/resources/resources/FreehandLineShape.gif new file mode 100644 index 0000000000000000000000000000000000000000..51b9b42d146edb2278687256e65b1067b3bd9c0a GIT binary patch literal 925 zcmb`GJ!_S548U9-2aTgEqtkF;j zlW>WUD5jDsX_77(&@SMD28&_3v-VV&s;h=-)><+%HCGF@EEW{q)LlK)vq;e!rr{c) zk#J;G(==T(G}#Jkz#t7vXi;M^*g%8DaF(FT2{#L~EPbpcb2kt3EV;0t7;X_3iF!!U zYw4C@i9Gy(Cezq~en_AY)__48mbAiy#b5&sR+e*BCMUu@%SiOGmMp>}@fEqSpy(N% z_=wXO0594x8nsx7AJAkPJK%(16v7%XNHYm7c(533ptDX?-IU3R&d&$bz zcJC^-6PC^GD%IPJF4voPHQMZ`BQ%AD)JWG&8jk{Q(7X;@3G>jzs@>}wH;4?#fqJX! zKOud0B{%JydiCtxLSJY9rPYB46A$}`PTU{AeeKk}ZQIW;zdbjyxU_5R@0NXoH$E$``y}t5cW%Tmq<+Zcd-#;0g`}TcxX3xaau|tbrcYNMEwRB|q*M&ciZ_Pa4dgtWO jm(I`W7qjyRe@t~oEN(Gm2#GgVse&0;Kjk7wvfXVagw9sUevoO zl({G;e}KP0;WR$;{TocZ{oZ+J=9%Yt=J#G%Upu#YdqE5Ot&ZvVOvhtNHtm?rX2tKN z8V{a)BlzwAg-I@jl)Z_}Oy;tXrL4N>CU<$rQ(oO0rf@|lQc*pcrgUW}Q`t;argBxN z650*i&|oo4clDkQHw&{gt6odyZXV`oUd@7HxJ6i`MKvjU(=Ed?Eeno}TDetNr4?IY z4H%?h2`y?Y1{-Lw7_Ju7IT7yZUagO{WDy?eQ7so16f->2vrrEydcDFcy^x0=&}14r z&<_a|!WuA0!;)5buo!Hh!K!wy%j85xR2zvt){qFMxz!h z@dKJnV+WiNj6zrg25Bat1rHX34RrO1x|=dNQCtio(Z^b{94}e>I_}-Yal*EFT%~)5 z(e3*1u1AL*eT1Q~kp}6$$>7nz1De-?D`6g*She_f=MHI~PWD^f{|U|ARP8x*_5GXe z$8+*JH%hcCTcx^d+4#)0LPe0OT`^XA;eN2izWAKiX7Iq~+_*2o3k8{P{iR?_PU7dAPa%$J2Y?Uag&(eAs$$?8{W={{dY#fVuzx literal 0 HcmV?d00001 diff --git a/online-stg-env/src/main/resources/resources/OvalShape.gif b/online-stg-env/src/main/resources/resources/OvalShape.gif new file mode 100644 index 0000000000000000000000000000000000000000..0ce4e18083e30fd73eeddd809f1cfd92ed17538b GIT binary patch literal 918 zcmb`G&x_7+5XVQ6ha70dg?c>ou+K&gv&H7eMeSOIofccm-8rDE7V!}b`G z4J$^YQSy6Awg*qX5&ZW5LPbo(MWQy5sfwDYi-u@c(NxUDTr9-0dR@g$+{HsYYcy2C zBwQjSim9YZnxsnxvZ+ldwU*3G&DBCJiv>kDbypAdEK>A_X}Csc zBpeylG)>nGO}4@sFi67^TGUt!Hqc-(oF%Ao!p*`gOCM{=+|9#0OD-%ZhFgS1q8?K8 zTDoOeA`d^H$uxGL9}*~pHDHj2C9UvaG1x$ZmE~NO$%$~!G7^2PC5!M#d_^uSD0+q` zKH@Y6z>9W_MlDw22Q-<+4mcqgg|G$;(o8}N9xMhM=&Tb}H)V1nxfn*GkF{jcUb6DF z-MfnIgk^KPO7%9Q%k}16jW#>#2u)!jHPUsH#-o56G_M0!!aOvwYR{kb>qNH7{(7tH zKOvoKlACs&Tz&j@sWUcl>Er5?6N}@$Q#Ws%?`>Y%F_^yo=F0rcy`9@`J?p&c%`W%P zJ^g#=LVtSUz}(8+!Pv^DM;i`)eZO{f-{<>BH~!c%@oVpw2gm1n{mYYswTEY?UR?C; b;~$91@48|jfoOBVyrHJ;177^`|K~IO`(w=glrIX+yl?+be7w|;~4+?_PC7@sn zrH<_&bi6}s1>@xGBI4vOPU$cI&tTwqFPG%W^E`QP<@WOR!NWP3lfP2YwNKX`9a&c~ znM{)3Q?fmH@{QoP{}(D^A}$iOiA+`0L|rsQvx=r-Cgx%xmeuPjZsIN;;#s4i5+>mi zAyG^vRnjC~GN4_+1q~L%bZ70UFjZF#)vUE-W@@e$YFR8Ox~aQ*sArL)H%!AdLL=eG zsHSPUW@xe%)__48me8WcVz7Y*i{UIml@o3jW?A}JOXhAK=2>!KK{4DSEE4sQqSw+b z!xDM;0Zpc{1O1RdA*=y|G%RU_2aCZ58muhms!UFVdzO*tV=Y;PN8&4TVL{O|Jn<2y zF#uk)V>D{95yoF>5BJ_rU-Zsie(+^)>(k5L>hSGwfBW;sx&DpK5BvS2S2Ih`N0*-dn!Z_>*&Yp^ z%zu5hc>i!T`2OhI>ua}u|2bG&zdK&Kc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.11.0