From 6097cbc119ae84c4e660c231e8ad75936b827dd2 Mon Sep 17 00:00:00 2001 From: Boris Pigin Date: Mon, 7 Jun 2021 09:46:15 +0200 Subject: [PATCH 1/2] - Gradle update to 7.0 - GoogleJavaFormatter update and source reformatting according to new rules --- build.gradle | 22 +- gradle/wrapper/gradle-wrapper.properties | 2 +- release/applet/DetectJava.java | 27 +- .../java/free/chess/AbstractChessClock.java | 84 +- .../chess/AbstractColoredBoardPainter.java | 36 +- .../chess/AbstractColoredPiecePainter.java | 56 +- .../free/chess/BoardImageBoardPainter.java | 73 +- src/main/java/free/chess/BoardPainter.java | 12 +- src/main/java/free/chess/Chess.java | 32 +- src/main/java/free/chess/ChessMove.java | 64 +- src/main/java/free/chess/ChessPiece.java | 67 +- .../free/chess/ChesslikeGenericVariant.java | 190 ++-- .../java/free/chess/ColoredBoardPainter.java | 24 +- .../java/free/chess/ColoredPiecePainter.java | 40 +- .../java/free/chess/DefaultBoardPainter.java | 20 +- .../java/free/chess/DefaultPiecePainter.java | 20 +- .../free/chess/EboardVectorPiecePainter.java | 36 +- .../java/free/chess/FischerTimeControl.java | 54 +- .../java/free/chess/ImageBoardPainter.java | 41 +- .../java/free/chess/ImagePiecePainter.java | 115 +-- src/main/java/free/chess/JBoard.java | 489 +++-------- src/main/java/free/chess/JChessClock.java | 93 +- .../java/free/chess/LocalizationService.java | 20 +- src/main/java/free/chess/Move.java | 64 +- .../java/free/chess/MoveFormatException.java | 28 +- src/main/java/free/chess/OddsTimeControl.java | 60 +- src/main/java/free/chess/Piece.java | 56 +- src/main/java/free/chess/PieceChooser.java | 52 +- src/main/java/free/chess/PieceIcon.java | 41 +- src/main/java/free/chess/PiecePainter.java | 17 +- .../java/free/chess/PlainBoardPainter.java | 20 +- src/main/java/free/chess/Player.java | 36 +- src/main/java/free/chess/Position.java | 101 +-- .../free/chess/PositionFormatException.java | 28 +- .../java/free/chess/ResourceBoardPainter.java | 12 +- .../java/free/chess/ResourcePiecePainter.java | 12 +- src/main/java/free/chess/Square.java | 44 +- .../free/chess/SquareImagesBoardPainter.java | 88 +- src/main/java/free/chess/TimeControl.java | 12 +- .../java/free/chess/VectorPiecePainter.java | 32 +- src/main/java/free/chess/WildVariant.java | 32 +- src/main/java/free/chess/event/MoveEvent.java | 35 +- .../java/free/chess/event/MoveListener.java | 16 +- .../free/chess/event/MoveProgressEvent.java | 39 +- .../chess/event/MoveProgressListener.java | 20 +- .../variants/BothSidesCastlingVariant.java | 20 +- .../chess/variants/NoCastlingVariant.java | 28 +- .../free/chess/variants/atomic/Atomic.java | 23 +- .../variants/fischerrandom/FischerRandom.java | 24 +- .../chess/variants/giveaway/Giveaway.java | 21 +- .../chess/variants/kriegspiel/Kriegspiel.java | 59 +- .../variants/kriegspiel/KriegspielMove.java | 41 +- .../chess/variants/shatranj/Shatranj.java | 53 +- .../variants/shuffleboth/ShuffleBoth.java | 24 +- .../free/chess/variants/suicide/Suicide.java | 21 +- .../free/chessclub/ChessclubConnection.java | 189 ++-- .../free/chessclub/ChessclubConstants.java | 148 +--- .../java/free/chessclub/level1/Packet.java | 40 +- .../java/free/chessclub/level2/Datagram.java | 78 +- .../free/chessclub/level2/DatagramEvent.java | 38 +- .../chessclub/level2/DatagramListener.java | 16 +- .../java/free/freechess/DeltaBoardStruct.java | 43 +- .../free/freechess/FreechessConnection.java | 303 ++----- .../java/free/freechess/GameInfoStruct.java | 79 +- src/main/java/free/freechess/Ivar.java | 180 +--- .../java/free/freechess/SeekInfoStruct.java | 87 +- .../java/free/freechess/Style12Struct.java | 109 +-- src/main/java/free/jin/AbstractServer.java | 99 +-- .../java/free/jin/BadChangesException.java | 18 +- src/main/java/free/jin/Connection.java | 177 ++-- src/main/java/free/jin/ConnectionDetails.java | 34 +- src/main/java/free/jin/ConnectionManager.java | 147 ++-- src/main/java/free/jin/FriendsConnection.java | 45 +- src/main/java/free/jin/Game.java | 343 +++----- .../java/free/jin/GameListConnection.java | 14 +- src/main/java/free/jin/GameListItem.java | 90 +- src/main/java/free/jin/HistoryListItem.java | 26 +- src/main/java/free/jin/I18n.java | 248 +++--- src/main/java/free/jin/Jin.java | 163 ++-- src/main/java/free/jin/JinApplet.java | 310 ++----- src/main/java/free/jin/JinApplication.java | 227 ++--- src/main/java/free/jin/JinContext.java | 45 +- src/main/java/free/jin/LibListItem.java | 32 +- src/main/java/free/jin/LoginException.java | 22 +- src/main/java/free/jin/MatchOffer.java | 74 +- .../java/free/jin/MatchOfferConnection.java | 37 +- src/main/java/free/jin/PGNConnection.java | 20 +- src/main/java/free/jin/PlainServerUser.java | 38 +- src/main/java/free/jin/Preferences.java | 235 ++--- src/main/java/free/jin/Resource.java | 13 +- src/main/java/free/jin/SearchListItem.java | 28 +- src/main/java/free/jin/Seek.java | 64 +- src/main/java/free/jin/SeekConnection.java | 29 +- src/main/java/free/jin/Server.java | 59 +- src/main/java/free/jin/ServerUser.java | 26 +- src/main/java/free/jin/Session.java | 118 +-- src/main/java/free/jin/SessionEvent.java | 54 +- src/main/java/free/jin/SessionListener.java | 30 +- src/main/java/free/jin/StoredListItem.java | 26 +- .../free/jin/UnsupportedContextException.java | 18 +- src/main/java/free/jin/UpgradeManager.java | 31 +- src/main/java/free/jin/User.java | 73 +- src/main/java/free/jin/UserMatchOffer.java | 36 +- src/main/java/free/jin/UserSeek.java | 44 +- src/main/java/free/jin/UsernamePolicy.java | 18 +- .../java/free/jin/action/ActionContext.java | 42 +- src/main/java/free/jin/action/ActionInfo.java | 30 +- src/main/java/free/jin/action/JinAction.java | 62 +- .../getserverhelp/GetServerHelpAction.java | 25 +- .../java/free/jin/actions/ActionsPlugin.java | 72 +- src/main/java/free/jin/board/Arrow.java | 49 +- .../java/free/jin/board/BoardManager.java | 425 +++------ src/main/java/free/jin/board/BoardPanel.java | 442 +++------- .../java/free/jin/board/BoardPattern.java | 77 +- .../free/jin/board/BoardPreferencesPanel.java | 72 +- src/main/java/free/jin/board/Circle.java | 41 +- .../jin/board/ExaminedGameButtonPanel.java | 92 +- .../java/free/jin/board/JMaterialPanel.java | 1 - src/main/java/free/jin/board/JinBoard.java | 129 +-- src/main/java/free/jin/board/PieceSet.java | 77 +- .../free/jin/board/PlayedGameButtonPanel.java | 214 ++--- .../jin/board/event/ArrowCircleListener.java | 29 +- .../free/jin/board/event/UserMoveEvent.java | 29 +- .../jin/board/event/UserMoveListener.java | 18 +- .../jin/board/fics/FreechessBoardManager.java | 55 +- .../jin/board/fics/FreechessBoardPanel.java | 22 +- .../board/icc/BlitzinVectorPiecePainter.java | 47 +- .../jin/board/icc/ChessclubBoardManager.java | 38 +- .../jin/board/icc/ChessclubBoardPanel.java | 77 +- .../free/jin/board/icc/ChessclubJBoard.java | 49 +- .../free/jin/board/prefs/BoardLooksPanel.java | 106 +-- .../board/prefs/BoardModifyingPrefsPanel.java | 22 +- .../free/jin/board/prefs/MoveInputPanel.java | 166 ++-- .../board/prefs/SquareCoordinatesPanel.java | 63 +- .../java/free/jin/chessclub/ChessEvent.java | 90 +- .../chessclub/ChessclubListenerManager.java | 49 +- .../free/jin/chessclub/ChessclubServer.java | 18 +- .../free/jin/chessclub/ChessclubUser.java | 18 +- .../jin/chessclub/JinChessclubConnection.java | 819 +++++------------- .../jin/chessclub/NoSuchGameException.java | 22 +- .../free/jin/chessclub/event/ArrowEvent.java | 50 +- .../jin/chessclub/event/ChessEventEvent.java | 38 +- .../chessclub/event/ChessEventListener.java | 22 +- .../event/ChessclubGameListener.java | 30 +- .../free/jin/chessclub/event/CircleEvent.java | 42 +- .../jin/chessclub/servers/icc/ICCServer.java | 14 +- .../jin/chessclub/servers/wcl/WCLServer.java | 14 +- .../console/AbstractConsoleDesignation.java | 146 +--- src/main/java/free/jin/console/Channel.java | 26 +- .../jin/console/ChatConsoleDesignation.java | 85 +- src/main/java/free/jin/console/Command.java | 46 +- src/main/java/free/jin/console/Console.java | 201 ++--- .../free/jin/console/ConsoleDesignation.java | 39 +- .../java/free/jin/console/ConsoleManager.java | 290 ++----- .../free/jin/console/ConsoleTextField.java | 115 +-- .../free/jin/console/ConsoleTextPane.java | 156 +--- .../jin/console/CustomConsoleDesignation.java | 21 +- .../jin/console/GameConsoleDesignation.java | 43 +- .../jin/console/HelpConsoleDesignation.java | 40 +- src/main/java/free/jin/console/Link.java | 34 +- .../PersonalChatConsoleDesignation.java | 46 +- .../jin/console/SystemConsoleDesignation.java | 46 +- .../console/TemporaryConsoleDesignation.java | 24 +- .../free/jin/console/fics/FicsChannel.java | 14 +- .../FicsGeneralChatConsoleDesignation.java | 22 +- .../jin/console/fics/FreechessConsole.java | 22 +- .../console/fics/FreechessConsoleManager.java | 63 +- .../fics/FreechessConsolePrefsPanel.java | 22 +- .../fics/FreechessConsoleTextField.java | 18 +- .../fics/FreechessConsoleTextPane.java | 14 +- .../FreechessCustomConsoleDesignation.java | 23 +- .../FreechessCustomConsolesPrefsPanel.java | 10 +- .../fics/FreechessGameConsoleDesignation.java | 22 +- .../fics/FreechessHelpConsoleDesignation.java | 18 +- .../FreechessSystemConsoleDesignation.java | 14 +- .../jin/console/icc/ChessclubChannel.java | 14 +- .../jin/console/icc/ChessclubConsole.java | 21 +- .../console/icc/ChessclubConsoleManager.java | 77 +- .../icc/ChessclubConsolePrefsPanel.java | 22 +- .../icc/ChessclubConsoleTextField.java | 18 +- .../console/icc/ChessclubConsoleTextPane.java | 14 +- .../ChessclubCustomConsoleDesignation.java | 23 +- .../ChessclubCustomConsolesPrefsPanel.java | 10 +- .../icc/ChessclubGameConsoleDesignation.java | 22 +- .../icc/ChessclubHelpConsoleDesignation.java | 18 +- .../ChessclubSystemConsoleDesignation.java | 14 +- .../java/free/jin/console/icc/IccChannel.java | 14 +- .../icc/IccGeneralChatConsoleDesignation.java | 22 +- .../java/free/jin/console/icc/WclChannel.java | 14 +- .../icc/WclGeneralChatConsoleDesignation.java | 26 +- .../java/free/jin/console/ics/IcsChannel.java | 18 +- .../ics/IcsChannelConsoleDesignation.java | 22 +- .../jin/console/ics/IcsConsoleManager.java | 29 +- .../ics/IcsCustomConsoleDesignation.java | 49 +- .../ics/IcsCustomConsolesPrefsPanel.java | 99 +-- .../ics/IcsGameConsoleDesignation.java | 70 +- .../ics/IcsGeneralChatConsoleDesignation.java | 26 +- .../IcsPersonalChatConsoleDesignation.java | 18 +- .../ics/IcsSystemConsoleDesignation.java | 14 +- .../ics/ShoutChatConsoleDesignation.java | 14 +- .../console/prefs/ChannelTextPrefsPanel.java | 49 +- .../jin/console/prefs/ConsolePrefsPanel.java | 22 +- .../prefs/CustomConsolesPrefsPanel.java | 262 ++---- .../jin/console/prefs/EncodingPrefsPanel.java | 76 +- .../jin/console/prefs/TextPrefsPanel.java | 131 +-- .../console/prefs/TextStyleChooserPanel.java | 98 +-- .../free/jin/event/BasicListenerManager.java | 82 +- .../java/free/jin/event/BoardFlipEvent.java | 22 +- src/main/java/free/jin/event/ChatEvent.java | 72 +- .../java/free/jin/event/ChatListener.java | 18 +- .../free/jin/event/ClockAdjustmentEvent.java | 49 +- .../free/jin/event/ConnectionListener.java | 37 +- .../java/free/jin/event/FriendsEvent.java | 64 +- .../java/free/jin/event/FriendsListener.java | 26 +- .../jin/event/FriendsListenerManager.java | 22 +- src/main/java/free/jin/event/GameAdapter.java | 10 +- .../java/free/jin/event/GameEndEvent.java | 14 +- src/main/java/free/jin/event/GameEvent.java | 26 +- .../java/free/jin/event/GameListEvent.java | 58 +- .../java/free/jin/event/GameListListener.java | 18 +- .../jin/event/GameListListenerManager.java | 18 +- .../java/free/jin/event/GameListener.java | 46 +- .../java/free/jin/event/GameStartEvent.java | 18 +- .../java/free/jin/event/IllegalMoveEvent.java | 42 +- src/main/java/free/jin/event/JinEvent.java | 29 +- .../java/free/jin/event/ListenerManager.java | 15 +- .../java/free/jin/event/MatchOfferEvent.java | 42 +- .../free/jin/event/MatchOfferListener.java | 22 +- .../jin/event/MatchOfferListenerManager.java | 14 +- .../java/free/jin/event/MoveMadeEvent.java | 18 +- src/main/java/free/jin/event/OfferEvent.java | 62 +- .../java/free/jin/event/PlainTextEvent.java | 22 +- .../free/jin/event/PlainTextListener.java | 14 +- .../free/jin/event/PositionChangedEvent.java | 18 +- src/main/java/free/jin/event/SeekEvent.java | 46 +- .../java/free/jin/event/SeekListener.java | 18 +- .../free/jin/event/SeekListenerManager.java | 14 +- .../java/free/jin/event/TakebackEvent.java | 22 +- .../freechess/FreechessListenerManager.java | 30 +- .../free/jin/freechess/FreechessUser.java | 18 +- .../jin/freechess/JinFreechessConnection.java | 487 +++-------- .../jin/freechess/NoSuchGameException.java | 22 +- .../freechess/event/IvarStateChangeEvent.java | 34 +- .../event/IvarStateChangeListener.java | 18 +- .../servers/fics/FreechessServer.java | 18 +- .../java/free/jin/gamelogger/GameLogger.java | 214 ++--- .../GameLoggerPreferencesPanel.java | 116 +-- .../java/free/jin/gamelogger/LoggingRule.java | 50 +- src/main/java/free/jin/plugin/Plugin.java | 81 +- .../java/free/jin/plugin/PluginContext.java | 71 +- src/main/java/free/jin/plugin/PluginInfo.java | 26 +- .../free/jin/plugin/PluginStartException.java | 38 +- .../java/free/jin/plugin/PluginUIAdapter.java | 14 +- .../free/jin/plugin/PluginUIContainer.java | 79 +- .../java/free/jin/plugin/PluginUIEvent.java | 66 +- .../free/jin/plugin/PluginUIListener.java | 46 +- .../free/jin/scripter/BeanShellScript.java | 50 +- .../jin/scripter/BeanShellScriptDialog.java | 40 +- .../java/free/jin/scripter/CommandScript.java | 55 +- .../jin/scripter/CommandsScriptDialog.java | 54 +- src/main/java/free/jin/scripter/Script.java | 62 +- .../java/free/jin/scripter/ScriptDialog.java | 64 +- src/main/java/free/jin/scripter/Scripter.java | 140 +-- .../scripter/ScripterPreferencesPanel.java | 82 +- .../scripter/UserInvokedScriptMenuItem.java | 87 +- .../jin/scripter/fics/FreechessScripter.java | 23 +- .../jin/scripter/icc/ChessclubScripter.java | 23 +- .../java/free/jin/seek/IssueMatchPanel.java | 117 +-- .../java/free/jin/seek/IssueSeekPanel.java | 67 +- .../free/jin/seek/ManualAcceptSelection.java | 29 +- .../seek/OpponentRatingRangeSelection.java | 74 +- .../java/free/jin/seek/OpponentSelection.java | 54 +- .../free/jin/seek/PieceColorSelection.java | 35 +- .../free/jin/seek/RatednessSelection.java | 33 +- src/main/java/free/jin/seek/SoughtGraph.java | 204 ++--- .../java/free/jin/seek/SoughtGraphPlugin.java | 149 ++-- .../free/jin/seek/TimeControlsSelection.java | 73 +- .../free/jin/seek/UseFormulaSelection.java | 25 +- .../java/free/jin/seek/VariantSelection.java | 43 +- .../jin/seek/event/SeekSelectionEvent.java | 29 +- .../jin/seek/event/SeekSelectionListener.java | 18 +- .../seek/fics/FreechessSoughtGraphPlugin.java | 14 +- .../seek/icc/ChessclubSoughtGraphPlugin.java | 61 +- .../java/free/jin/sound/SoundManager.java | 157 ++-- .../jin/sound/fics/FreechessSoundManager.java | 14 +- .../jin/sound/icc/ChessclubSoundManager.java | 14 +- src/main/java/free/jin/ui/AboutPanel.java | 41 +- .../jin/ui/AbstractPluginUIContainer.java | 132 +-- .../java/free/jin/ui/AbstractUiProvider.java | 76 +- src/main/java/free/jin/ui/ActionsMenu.java | 39 +- .../jin/ui/CompositePreferencesPanel.java | 49 +- src/main/java/free/jin/ui/DialogPanel.java | 85 +- src/main/java/free/jin/ui/HelpMenu.java | 46 +- src/main/java/free/jin/ui/InfoButton.java | 20 +- src/main/java/free/jin/ui/LicensePanel.java | 74 +- src/main/java/free/jin/ui/LoginPanel.java | 174 ++-- .../free/jin/ui/LookAndFeelPrefPanel.java | 60 +- src/main/java/free/jin/ui/MdiUiProvider.java | 284 ++---- src/main/java/free/jin/ui/OptionPanel.java | 131 +-- .../free/jin/ui/PluginContainersMenu.java | 90 +- .../ui/PluginUIContainerCreationListener.java | 21 +- .../java/free/jin/ui/PreferencesPanel.java | 30 +- src/main/java/free/jin/ui/PrefsMenu.java | 116 +-- src/main/java/free/jin/ui/SdiUiProvider.java | 138 +-- .../java/free/jin/ui/ServerChoicePanel.java | 47 +- .../free/jin/ui/TabbedPreferencesPanel.java | 21 +- src/main/java/free/jin/ui/UIProvider.java | 43 +- src/main/java/free/jin/ui/UiPrefsPanel.java | 28 +- src/main/java/free/jin/ui/UpgradeDialog.java | 39 +- .../free/jin/ui/WindowingModePrefPanel.java | 38 +- src/main/java/free/util/AWTUtilities.java | 33 +- src/main/java/free/util/AbstractNamed.java | 28 +- src/main/java/free/util/ApplyLicense.java | 20 +- src/main/java/free/util/ArrayEnumeration.java | 44 +- src/main/java/free/util/BeanProperties.java | 232 +++-- src/main/java/free/util/BlockingQueue.java | 61 +- src/main/java/free/util/Bounce.java | 20 +- src/main/java/free/util/BrowserControl.java | 46 +- src/main/java/free/util/ChangeSupport.java | 41 +- src/main/java/free/util/ChildClassLoader.java | 40 +- .../java/free/util/ConcreteContainer.java | 12 +- src/main/java/free/util/Connection.java | 118 +-- .../java/free/util/DelegatingClassLoader.java | 48 +- src/main/java/free/util/Encodings.java | 32 +- .../java/free/util/EventListenerList.java | 32 +- .../free/util/ExtensionFilenameFilter.java | 16 +- .../java/free/util/FilteringEnumeration.java | 37 +- src/main/java/free/util/FormatException.java | 32 +- .../java/free/util/GraphicsUtilities.java | 20 +- src/main/java/free/util/IOUtilities.java | 109 +-- src/main/java/free/util/ImageUtilities.java | 54 +- src/main/java/free/util/Localization.java | 46 +- .../java/free/util/LocalizationService.java | 24 +- .../free/util/MapURLStreamHandlerFactory.java | 24 +- .../java/free/util/MappingEnumeration.java | 34 +- src/main/java/free/util/MathUtilities.java | 20 +- src/main/java/free/util/MemoryFile.java | 63 +- .../java/free/util/MultiOutputStream.java | 40 +- src/main/java/free/util/Named.java | 24 +- src/main/java/free/util/NamedWrapper.java | 36 +- src/main/java/free/util/PaintHook.java | 12 +- src/main/java/free/util/Pair.java | 40 +- src/main/java/free/util/PipedInputStream.java | 24 +- .../java/free/util/PipedOutputStream.java | 28 +- src/main/java/free/util/PipedStreams.java | 92 +- src/main/java/free/util/PlatformUtils.java | 49 +- src/main/java/free/util/PumpThread.java | 36 +- src/main/java/free/util/RawTelnet.java | 32 +- src/main/java/free/util/RectDouble.java | 68 +- src/main/java/free/util/SafeRunnable.java | 16 +- .../java/free/util/SingleItemEnumeration.java | 32 +- src/main/java/free/util/SquareLayout.java | 32 +- src/main/java/free/util/StringEncoder.java | 20 +- src/main/java/free/util/StringParser.java | 27 +- src/main/java/free/util/Struct.java | 64 +- src/main/java/free/util/TableLayout.java | 88 +- src/main/java/free/util/TextUtilities.java | 68 +- src/main/java/free/util/URLClassLoader.java | 28 +- .../util/UnsupportedOperationException.java | 24 +- src/main/java/free/util/Utilities.java | 98 +-- .../free/util/WindowDisposingListener.java | 24 +- .../free/util/audio/AppletAudioPlayer.java | 39 +- .../util/audio/AppletContextAudioPlayer.java | 51 +- src/main/java/free/util/audio/AudioClip.java | 39 +- .../java/free/util/audio/AudioPlayer.java | 24 +- .../java/free/util/audio/NullAudioPlayer.java | 20 +- .../free/util/audio/OpenALAudioPlayer.java | 10 +- .../util/imagefilters/ArgbImageFilter.java | 16 +- .../ArgbMultiplyingImageFilter.java | 40 +- .../imagefilters/BrightnessImageFilter.java | 12 +- .../util/imagefilters/IconImageFilters.java | 40 +- .../imagefilters/OpaquenessImageFilter.java | 12 +- .../free/util/models/BooleanListener.java | 20 +- .../java/free/util/models/BooleanModel.java | 68 +- src/main/java/free/util/models/Model.java | 40 +- .../java/free/util/models/ModelUtils.java | 17 +- .../util/models/UnmodifiableBooleanModel.java | 32 +- .../free/util/swing/AddRemoveButtons.java | 68 +- .../free/util/swing/AdvancedJDesktopPane.java | 57 +- src/main/java/free/util/swing/ArrowIcon.java | 12 +- .../free/util/swing/BackgroundChooser.java | 131 ++- src/main/java/free/util/swing/BorderIcon.java | 37 +- .../java/free/util/swing/ColorChooser.java | 85 +- .../java/free/util/swing/ColoredIcon.java | 45 +- .../java/free/util/swing/CompositeIcon.java | 25 +- .../free/util/swing/ExtensionFileFilter.java | 43 +- .../free/util/swing/FontSelectorPanel.java | 180 ++-- .../java/free/util/swing/FullscreenPanel.java | 105 +-- src/main/java/free/util/swing/IconButton.java | 32 +- .../java/free/util/swing/ImageComponent.java | 80 +- .../swing/IntegerStrictPlainDocument.java | 40 +- .../util/swing/InternalFrameSwitcher.java | 41 +- src/main/java/free/util/swing/LinkLabel.java | 41 +- .../util/swing/ListWrapperComboBoxModel.java | 43 +- .../free/util/swing/LocalizationService.java | 24 +- .../java/free/util/swing/Mnemonicable.java | 16 +- .../util/swing/MoreLessOptionsButton.java | 42 +- .../java/free/util/swing/MultiButton.java | 41 +- .../util/swing/NonEditableTableModel.java | 33 +- src/main/java/free/util/swing/OvalIcon.java | 24 +- .../java/free/util/swing/PlainTextDialog.java | 54 +- .../free/util/swing/PreferredSizedPanel.java | 35 +- .../java/free/util/swing/RectangleIcon.java | 24 +- .../free/util/swing/StrictPlainDocument.java | 13 +- src/main/java/free/util/swing/SwingUtils.java | 70 +- .../free/util/swing/UrlDisplayingAction.java | 40 +- src/main/java/free/util/swing/WrapLayout.java | 71 +- .../free/util/swing/WrapperComponent.java | 44 +- .../tabbedpane/AbstractTabbedPaneModel.java | 60 +- .../swing/tabbedpane/DefaultTabHandle.java | 80 +- .../tabbedpane/DefaultTabHandleFactory.java | 24 +- .../tabbedpane/DefaultTabbedPaneModel.java | 48 +- .../java/free/util/swing/tabbedpane/Tab.java | 84 +- .../swing/tabbedpane/TabCloseApprover.java | 20 +- .../free/util/swing/tabbedpane/TabHandle.java | 20 +- .../swing/tabbedpane/TabHandleFactory.java | 16 +- .../util/swing/tabbedpane/TabbedPane.java | 243 ++---- .../swing/tabbedpane/TabbedPaneEvent.java | 57 +- .../swing/tabbedpane/TabbedPaneListener.java | 32 +- .../swing/tabbedpane/TabbedPaneModel.java | 60 +- .../java/free/util/zip/ZipClassLoader.java | 27 +- .../java/free/util/zip/ZipURLConnection.java | 36 +- .../free/util/zip/ZipURLStreamHandler.java | 33 +- src/main/java/free/workarounds/FixUtils.java | 27 +- .../java/free/workarounds/FixedJComboBox.java | 20 +- .../java/free/workarounds/FixedJDialog.java | 25 +- .../java/free/workarounds/FixedJFrame.java | 18 +- .../free/workarounds/FixedJInternalFrame.java | 63 +- .../java/free/workarounds/FixedJPanel.java | 13 +- .../free/workarounds/FixedJPasswordField.java | 16 +- .../java/free/workarounds/FixedJTable.java | 27 +- .../java/free/workarounds/FixedJTextArea.java | 14 +- .../free/workarounds/FixedJTextField.java | 30 +- .../java/free/workarounds/FixedJTextPane.java | 9 +- .../free/workarounds/FixedTableColumn.java | 19 +- src/main/java/free/workarounds/SwingFix.java | 7 +- .../macosx/free/jin/MacOSXSpecific.java | 22 +- 437 files changed, 8455 insertions(+), 17137 deletions(-) diff --git a/build.gradle b/build.gradle index 08bcf6ca..df5355ea 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,13 @@ plugins { + id "java" id "application" id "wrapper" - id 'com.github.sherter.google-java-format' version '0.3.2' + id 'com.github.sherter.google-java-format' version '0.9' } wrapper { - gradleVersion "5.0" + gradleVersion "7.0" } mainClassName = "free.jin.JinApplication" @@ -16,20 +17,19 @@ repositories { } dependencies { - compile "org.jdesktop:appframework:1.0.3" - compile "org.swinglabs:swing-layout:1.0.3" - compile "org.beanshell:bsh:2.0b5" - compile "org.reflections:reflections:0.9.12" - compile "com.google.guava:guava:30.1.1-jre" - compile "org.lwjgl.lwjgl:lwjgl:2.9.3" - compile "org.lwjgl.lwjgl:lwjgl_util:2.9.1" + implementation "org.jdesktop:appframework:1.0.3" + implementation "org.swinglabs:swing-layout:1.0.3" + implementation "org.beanshell:bsh:2.0b5" + implementation "org.reflections:reflections:0.9.12" + implementation "com.google.guava:guava:30.1.1-jre" + implementation "org.lwjgl.lwjgl:lwjgl:2.9.3" + implementation "org.lwjgl.lwjgl:lwjgl_util:2.9.1" } // If Java formatter checks fail, tell the user how to fix them. task printFormatHelperMessage { doLast { - throw new FileNotFoundException('google-java-format is required.\n' + - 'Use ./gradlew googleJavaFormat to reformat the broken files') + throw new FileNotFoundException('google-java-format is required.\nUse ./gradlew googleJavaFormat to reformat the broken files') } } verifyGoogleJavaFormat.finalizedBy printFormatHelperMessage diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 75b8c7c8..f371643e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/release/applet/DetectJava.java b/release/applet/DetectJava.java index 20c44fff..dc9ba1e4 100644 --- a/release/applet/DetectJava.java +++ b/release/applet/DetectJava.java @@ -2,38 +2,37 @@ * Jin - a chess client for internet chess servers. More information is available at * http://www.jinchess.com/. Copyright (C) 2004 Alexander Maryanovsky. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it under the terms of the + *

This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + *

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with this program; if + *

You should have received a copy of the GNU General Public License along with this program; if * not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ import java.applet.Applet; -import java.net.URL; import java.net.MalformedURLException; +import java.net.URL; /** * A small applet which redirects to a different page based on the version of Java in which it is * run. The applet takes 3 parameters: + * *

*/ public class DetectJava extends Applet { - /** - * Invokes getAppletContext().showDocument() on the appropriate URL. - */ + /** Invokes getAppletContext().showDocument() on the appropriate URL. */ public void start() { String minRequiredJavaVersion = getParameter("minRequiredJavaVersion"); String javaVersion = System.getProperty("java.version"); diff --git a/src/main/java/free/chess/AbstractChessClock.java b/src/main/java/free/chess/AbstractChessClock.java index d4a8bd13..28434422 100644 --- a/src/main/java/free/chess/AbstractChessClock.java +++ b/src/main/java/free/chess/AbstractChessClock.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -18,33 +18,22 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; - import javax.swing.JComponent; import javax.swing.Timer; -/** - * The abstract superclass of all components who display a chess clock (one part of it). - */ +/** The abstract superclass of all components who display a chess clock (one part of it). */ public abstract class AbstractChessClock extends JComponent { - /** - * The code for the mode where only hours and minutes are displayed. - */ + /** The code for the mode where only hours and minutes are displayed. */ public static final int HOUR_MINUTE_DISPLAY_MODE = 0; - /** - * The code for the mode where minutes and seconds are displayed. - */ + /** The code for the mode where minutes and seconds are displayed. */ public static final int MINUTE_SECOND_DISPLAY_MODE = 1; - /** - * The code for the mode where minutes, seconds and second tenths are displayed. - */ + /** The code for the mode where minutes, seconds and second tenths are displayed. */ public static final int SECOND_TENTHS_DISPLAY_MODE = 2; - /** - * The code for the mode where the actual display depends on the current time. - */ + /** The code for the mode where the actual display depends on the current time. */ public static final int TIME_DEPENDENT_DISPLAY_MODE = 3; /** @@ -55,20 +44,18 @@ public abstract class AbstractChessClock extends JComponent { private int time; /** - * The threshold of time under which the clock displays second tenths, when in - * TIME_DEPENDENT_DISPLAY_MODE mode. + * The threshold of time under which the clock displays second tenths, when in + * TIME_DEPENDENT_DISPLAY_MODE mode. */ private int secondTenthsThreshold = 10 * 1000; /** - * The threshold of time under which the clock displays minutes and seconds, when in - * TIME_DEPENDENT_DISPLAY_MODE mode. + * The threshold of time under which the clock displays minutes and seconds, when in + * TIME_DEPENDENT_DISPLAY_MODE mode. */ private int minutesSecondsThreshold = 20 * 60 * 1000; - /** - * The repaint timer. - */ + /** The repaint timer. */ private final Timer repaintTimer = new Timer( 100, @@ -91,9 +78,7 @@ public void actionPerformed(ActionEvent evt) { */ private int displayMode = TIME_DEPENDENT_DISPLAY_MODE; - /** - * Is the clock currently active (the current turn belongs to the owner of this clock). - */ + /** Is the clock currently active (the current turn belongs to the owner of this clock). */ private boolean isActive = false; /** @@ -104,33 +89,25 @@ public AbstractChessClock(int time) { this.time = time; } - /** - * Sets the time displayed by this clock, in milliseconds. - */ + /** Sets the time displayed by this clock, in milliseconds. */ public void setTime(int time) { this.time = time; if (isRunning()) runStart = System.currentTimeMillis(); repaint(); } - /** - * Returns the time displayed by this clock, in milliseconds. - */ + /** Returns the time displayed by this clock, in milliseconds. */ public int getTime() { if (isRunning()) return time - (int) (System.currentTimeMillis() - runStart); else return time; } - /** - * Returns whether the clock is running. - */ + /** Returns whether the clock is running. */ public boolean isRunning() { return runStart >= 0; } - /** - * Sets the clock's running status. - */ + /** Sets the clock's running status. */ public void setRunning(boolean isRunning) { if (isRunning == isRunning()) return; @@ -155,16 +132,12 @@ public void setTimeDependentDisplayModeThresholds(int minutesSeconds, int second repaint(); } - /** - * Sets the delay between repaints of the clock when it is running, in milliseconds. - */ + /** Sets the delay between repaints of the clock when it is running, in milliseconds. */ public void setRepaintDelay(int delay) { repaintTimer.setDelay(delay); } - /** - * Returns the delay between repaints of the clock when it is running, in milliseconds. - */ + /** Returns the delay between repaints of the clock when it is running, in milliseconds. */ public int getRepaintDelay() { return repaintTimer.getDelay(); } @@ -190,18 +163,17 @@ public void setDisplayMode(int displayMode) { } /** - * Returns the current display mode of the clock. Possible values are - * {@link #HOUR_MINUTE_DISPLAY_MODE}, {@link #MINUTE_SECOND_DISPLAY_MODE}, - * {@link #SECOND_TENTHS_DISPLAY_MODE} and {@link #TIME_DEPENDENT_DISPLAY_MODE}. + * Returns the current display mode of the clock. Possible values are {@link + * #HOUR_MINUTE_DISPLAY_MODE}, {@link #MINUTE_SECOND_DISPLAY_MODE}, {@link + * #SECOND_TENTHS_DISPLAY_MODE} and {@link #TIME_DEPENDENT_DISPLAY_MODE}. */ public int getDisplayMode() { return displayMode; } /** - * Returns the actual display mode. If the display mode is - * TIME_DEPENDENT_DISPLAY_MODE, returns one of the other display modes based on the - * current time. + * Returns the actual display mode. If the display mode is TIME_DEPENDENT_DISPLAY_MODE + * , returns one of the other display modes based on the current time. */ protected int getActualDisplayMode() { int displayMode = getDisplayMode(); @@ -222,9 +194,7 @@ public void setActive(boolean isActive) { repaint(); } - /** - * Returns whether this clock is active. - */ + /** Returns whether this clock is active. */ public boolean isActive() { return isActive; } diff --git a/src/main/java/free/chess/AbstractColoredBoardPainter.java b/src/main/java/free/chess/AbstractColoredBoardPainter.java index 017f32fe..ac62abc7 100644 --- a/src/main/java/free/chess/AbstractColoredBoardPainter.java +++ b/src/main/java/free/chess/AbstractColoredBoardPainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -18,19 +18,13 @@ import java.awt.Color; -/** - * A skeleton implementation of ColoredBoardPainter. - */ +/** A skeleton implementation of ColoredBoardPainter. */ public abstract class AbstractColoredBoardPainter implements ColoredBoardPainter { - /** - * The color of the light squares. - */ + /** The color of the light squares. */ private Color lightColor; - /** - * The color of the dark squares. - */ + /** The color of the dark squares. */ private Color darkColor; /** @@ -53,17 +47,13 @@ public AbstractColoredBoardPainter() { this(Color.white.darker(), Color.black.brighter()); } - /** - * Returns the color with which light squares are drawn. - */ + /** Returns the color with which light squares are drawn. */ @Override public Color getLightColor() { return lightColor; } - /** - * Sets the color with which light squares are drawn; - */ + /** Sets the color with which light squares are drawn; */ @Override public void setLightColor(Color lightColor) { if (lightColor == null) throw new IllegalArgumentException("Null color"); @@ -71,17 +61,13 @@ public void setLightColor(Color lightColor) { this.lightColor = lightColor; } - /** - * Returns the color with which dark squares are drawn. - */ + /** Returns the color with which dark squares are drawn. */ @Override public Color getDarkColor() { return darkColor; } - /** - * Sets the color with which dark squares are drawn; - */ + /** Sets the color with which dark squares are drawn; */ @Override public void setDarkColor(Color darkColor) { if (darkColor == null) throw new IllegalArgumentException("Null color"); diff --git a/src/main/java/free/chess/AbstractColoredPiecePainter.java b/src/main/java/free/chess/AbstractColoredPiecePainter.java index ae50cb06..0ef062a7 100644 --- a/src/main/java/free/chess/AbstractColoredPiecePainter.java +++ b/src/main/java/free/chess/AbstractColoredPiecePainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -18,29 +18,19 @@ import java.awt.Color; -/** - * A skeleton implementation of ColoredPiecePainter. - */ +/** A skeleton implementation of ColoredPiecePainter. */ public abstract class AbstractColoredPiecePainter implements ColoredPiecePainter { - /** - * The color of the white pieces. - */ + /** The color of the white pieces. */ private Color whiteColor; - /** - * The color of the black pieces. - */ + /** The color of the black pieces. */ private Color blackColor; - /** - * The color of the outline of the white pieces. - */ + /** The color of the outline of the white pieces. */ private Color whiteOutline; - /** - * The color of the outline of the black pieces. - */ + /** The color of the outline of the black pieces. */ private Color blackOutline; /** @@ -106,9 +96,7 @@ public Color getWhiteColor() { return whiteColor; } - /** - * Sets the color with which white pieces are drawn. - */ + /** Sets the color with which white pieces are drawn. */ @Override public void setWhiteColor(Color color) { if (color == null) throw new IllegalArgumentException("Null color"); @@ -126,9 +114,7 @@ public Color getBlackColor() { return blackColor; } - /** - * Sets the color with which black pieces are drawn. - */ + /** Sets the color with which black pieces are drawn. */ @Override public void setBlackColor(Color color) { if (color == null) throw new IllegalArgumentException("Null color"); @@ -146,9 +132,7 @@ public Color getWhiteOutline() { return whiteOutline; } - /** - * Sets the color with which the outline of white pieces is drawn. - */ + /** Sets the color with which the outline of white pieces is drawn. */ @Override public void setWhiteOutline(Color color) { if (color == null) throw new IllegalArgumentException("Null color"); @@ -166,9 +150,7 @@ public Color getBlackOutline() { return blackOutline; } - /** - * Sets the color with which the outline of black pieces is drawn. - */ + /** Sets the color with which the outline of black pieces is drawn. */ @Override public void setBlackOutline(Color color) { if (color == null) throw new IllegalArgumentException("Null color"); @@ -176,9 +158,7 @@ public void setBlackOutline(Color color) { blackOutline = color; } - /** - * Returns with which the specified piece should be drawn. - */ + /** Returns with which the specified piece should be drawn. */ public Color getPieceColor(Piece piece, boolean isShaded) { if (piece == null) return null; @@ -186,9 +166,7 @@ public Color getPieceColor(Piece piece, boolean isShaded) { return isShaded ? getShaded(color) : color; } - /** - * Returns the color with which the outline of the specified piece should be drawn. - */ + /** Returns the color with which the outline of the specified piece should be drawn. */ public Color getOutlineColor(Piece piece, boolean isShaded) { if (piece == null) return null; @@ -196,9 +174,7 @@ public Color getOutlineColor(Piece piece, boolean isShaded) { return isShaded ? getShaded(color) : color; } - /** - * Returns a shaded version of the specified color. - */ + /** Returns a shaded version of the specified color. */ protected Color getShaded(Color color) { int r = (color.getRed() + 128 * 2) / 3; int g = (color.getGreen() + 128 * 2) / 3; diff --git a/src/main/java/free/chess/BoardImageBoardPainter.java b/src/main/java/free/chess/BoardImageBoardPainter.java index 623c9420..f75d0720 100644 --- a/src/main/java/free/chess/BoardImageBoardPainter.java +++ b/src/main/java/free/chess/BoardImageBoardPainter.java @@ -2,20 +2,22 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2006 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; +import free.util.IOUtilities; +import free.util.ImageUtilities; import java.awt.Component; import java.awt.Graphics; import java.awt.Image; @@ -27,17 +29,10 @@ import java.util.Properties; import java.util.Set; -import free.util.IOUtilities; -import free.util.ImageUtilities; - -/** - * A BoardPainter which paints the entire board using a single, scaled image. - */ +/** A BoardPainter which paints the entire board using a single, scaled image. */ public class BoardImageBoardPainter implements ResourceBoardPainter { - /** - * A delegate board painter we use while the board image is being loaded. - */ + /** A delegate board painter we use while the board image is being loaded. */ private static final BoardPainter whileLoadingDelegate = new DefaultBoardPainter(); /** @@ -47,15 +42,13 @@ public class BoardImageBoardPainter implements ResourceBoardPainter { private static volatile boolean asyncImageLoad = false; /** - * The board image. When BoardImageBoardPainter is used as a - * ResourceBoardPainter, this remains null until the image data is fully + * The board image. When BoardImageBoardPainter is used as a + * ResourceBoardPainter, this remains null until the image data is fully * loaded. */ private Image boardImage = null; - /** - * The board image, scaled according to the last request to paint a board. - */ + /** The board image, scaled according to the last request to paint a board. */ private Image scaledBoardImage = null; /** @@ -64,14 +57,12 @@ public class BoardImageBoardPainter implements ResourceBoardPainter { */ private URL boardImageUrl = null; - /** - * The ImageDataReceiver, if any, currently waiting on board image data to load. - */ + /** The ImageDataReceiver, if any, currently waiting on board image data to load. */ private ImageDataReceiver imageDataReceiver = null; /** - * A no-arg constructor so that this BoardImageBoardPainter can be used as a - * ResourceBoardPainter. + * A no-arg constructor so that this BoardImageBoardPainter can be used as a + * ResourceBoardPainter. */ public BoardImageBoardPainter() {} @@ -90,9 +81,7 @@ public static void setAsyncImageLoad(boolean asyncImageLoad) { BoardImageBoardPainter.asyncImageLoad = asyncImageLoad; } - /** - * Since BoardImageBoardPainters are immutable, simply returns this. - */ + /** Since BoardImageBoardPainters are immutable, simply returns this. */ @Override public BoardPainter freshInstance() { return this; @@ -100,13 +89,15 @@ public BoardPainter freshInstance() { /** * Loads the painter from the specified URL. The file structure at the URL is described below. - *

- * A properties file named "definition" must be located at the URL. That file should contain the - * following property: + * + *

A properties file named "definition" must be located at the URL. That file should contain + * the following property: + * *

+ * * An image file named board.ext must be located at the URL, where "ext" is the value * of the ext property. */ @@ -156,9 +147,7 @@ protected synchronized boolean prepareBoardImage(int width, int height, Componen } } - /** - * Scales the board image to the specified size. - */ + /** Scales the board image to the specified size. */ private void scaleBoardImage(int width, int height) { if ((scaledBoardImage != null) && (scaledBoardImage.getWidth(null) == width) @@ -168,23 +157,17 @@ private void scaleBoardImage(int width, int height) { ImageUtilities.preload(scaledBoardImage); } - /** - * Paints the board at the given location on the given Graphics scaled to the given size. - */ + /** Paints the board at the given location on the given Graphics scaled to the given size. */ @Override public void paintBoard(Graphics g, Component component, int x, int y, int width, int height) { if (prepareBoardImage(width, height, component)) g.drawImage(scaledBoardImage, x, y, component); else whileLoadingDelegate.paintBoard(g, component, x, y, width, height); } - /** - * The receiver of board image data. Responsible for creating the board image. - */ + /** The receiver of board image data. Responsible for creating the board image. */ private class ImageDataReceiver implements IOUtilities.DataReceiver { - /** - * The set of components to repaint once the image is loaded. - */ + /** The set of components to repaint once the image is loaded. */ private final Set componentsToRepaint = new HashSet(2); /** @@ -203,9 +186,7 @@ public void addComponentToRepaint(Component component) { componentsToRepaint.add(component); } - /** - * Called when the image data has been loaded. Creates the board image. - */ + /** Called when the image data has been loaded. Creates the board image. */ @Override public void dataRead(URL[] urls, Object id, byte[][] data, IOException[] exceptions) { // If there are any exceptions, we simply quit - this will cause diff --git a/src/main/java/free/chess/BoardPainter.java b/src/main/java/free/chess/BoardPainter.java index 90713712..67f0c101 100644 --- a/src/main/java/free/chess/BoardPainter.java +++ b/src/main/java/free/chess/BoardPainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -19,9 +19,7 @@ import java.awt.Component; import java.awt.Graphics; -/** - * An interface for classes who paint the board "background" on JBoard. - */ +/** An interface for classes who paint the board "background" on JBoard. */ public interface BoardPainter { /** diff --git a/src/main/java/free/chess/Chess.java b/src/main/java/free/chess/Chess.java index 2e16fb90..929c4b31 100644 --- a/src/main/java/free/chess/Chess.java +++ b/src/main/java/free/chess/Chess.java @@ -2,52 +2,40 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; -/** - * An implementation of WildVariant for the game of chess (classic). - */ +/** An implementation of WildVariant for the game of chess (classic). */ public final class Chess extends ChesslikeGenericVariant { - /** - * The lexigraphic representation of the initial position in chess. - */ + /** The lexigraphic representation of the initial position in chess. */ public static final String INITIAL_POSITION_LEXIGRAPHIC = "rnbqkbnrpppppppp--------------------------------PPPPPPPPRNBQKBNR"; - /** - * The FEN representation of the initial position in chess. - */ + /** The FEN representation of the initial position in chess. */ public static final String INITIAL_POSITION_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; - /** - * The sole instance of this class. - */ + /** The sole instance of this class. */ private static Chess instance = new Chess(); - /** - * Returns an instance of Chess. - */ + /** Returns an instance of Chess. */ public static Chess getInstance() { return instance; } - /** - * Creates a new instance of Chess. - */ + /** Creates a new instance of Chess. */ private Chess() { super(INITIAL_POSITION_FEN, "Chess"); } diff --git a/src/main/java/free/chess/ChessMove.java b/src/main/java/free/chess/ChessMove.java index bb7a6ab7..31c153fa 100644 --- a/src/main/java/free/chess/ChessMove.java +++ b/src/main/java/free/chess/ChessMove.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -24,34 +24,22 @@ */ public class ChessMove extends Move { - /** - * True if this move is an en-passant, false otherwise. - */ + /** True if this move is an en-passant, false otherwise. */ private final boolean isEnPassant; - /** - * True if this move is a short castling move, false otherwise. - */ + /** True if this move is a short castling move, false otherwise. */ private final boolean isShortCastling; - /** - * True if this move is a long castling move, false otherwise. - */ + /** True if this move is a long castling move, false otherwise. */ private final boolean isLongCastling; - /** - * The captured piece, null if this move is not a capture. - */ + /** The captured piece, null if this move is not a capture. */ private final ChessPiece capturedPiece; - /** - * The piece to which the moving pawn was promoted. - */ + /** The piece to which the moving pawn was promoted. */ private final ChessPiece promotionTarget; - /** - * The file of the double pawn push, or -1 if the move isn't a double pawn push. - */ + /** The file of the double pawn push, or -1 if the move isn't a double pawn push. */ private final int doublePawnPushFile; /** @@ -169,51 +157,37 @@ public String getSAN() { return getStringRepresentation(); } - /** - * Returns true if this move is a capture. - */ + /** Returns true if this move is a capture. */ public boolean isCapture() { return (capturedPiece != null); } - /** - * Returns the piece captured by this move, or null if this move is not a capture. - */ + /** Returns the piece captured by this move, or null if this move is not a capture. */ public ChessPiece getCapturedPiece() { return capturedPiece; } - /** - * Returns true if this move is a castling move, false otherwise. - */ + /** Returns true if this move is a castling move, false otherwise. */ public boolean isCastling() { return (isShortCastling || isLongCastling); } - /** - * Returns true if this move is short castling move, false otherwise. - */ + /** Returns true if this move is short castling move, false otherwise. */ public boolean isShortCastling() { return isShortCastling; } - /** - * Returns true if this move if a long castling move, false otherwise. - */ + /** Returns true if this move if a long castling move, false otherwise. */ public boolean isLongCastling() { return isLongCastling; } - /** - * Returns true if this move is an en-passant move, false otherwise. - */ + /** Returns true if this move is an en-passant move, false otherwise. */ public boolean isEnPassant() { return isEnPassant; } - /** - * Returns true if this move is a promotion. - */ + /** Returns true if this move is a promotion. */ public boolean isPromotion() { return promotionTarget != null; } @@ -233,9 +207,7 @@ public int getDoublePawnPushFile() { return doublePawnPushFile; } - /** - * Returns a textual representation of this ChessMove based on the move data. - */ + /** Returns a textual representation of this ChessMove based on the move data. */ @Override public String getMoveString() { if (isShortCastling()) return "O-O"; diff --git a/src/main/java/free/chess/ChessPiece.java b/src/main/java/free/chess/ChessPiece.java index a6d0a139..387646c7 100644 --- a/src/main/java/free/chess/ChessPiece.java +++ b/src/main/java/free/chess/ChessPiece.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -24,34 +24,22 @@ */ public class ChessPiece extends Piece { - /** - * A constant representing a pawn. - */ + /** A constant representing a pawn. */ public static final int PAWN = 1; - /** - * A constant representing a knight. - */ + /** A constant representing a knight. */ public static final int KNIGHT = 2; - /** - * A constant representing a bishop. - */ + /** A constant representing a bishop. */ public static final int BISHOP = 3; - /** - * A constant representing a rook. - */ + /** A constant representing a rook. */ public static final int ROOK = 4; - /** - * A constant representing a queen. - */ + /** A constant representing a queen. */ public static final int QUEEN = 5; - /** - * A constant representing a king. - */ + /** A constant representing a king. */ public static final int KING = 6; // Final objects representing each piece. @@ -75,7 +63,7 @@ public class ChessPiece extends Piece { * * @param color The color of the piece - either {@link Piece#WHITE} or {@link Piece#BLACK}. * @param type The type of the piece - one of {@link #PAWN}, {@link #KNIGHT}, {@link #BISHOP}, - * {@link #ROOK}, {@link #QUEEN} or {@link #KING}. + * {@link #ROOK}, {@link #QUEEN} or {@link #KING}. */ public ChessPiece(int color, int type) { super(color, type); @@ -123,9 +111,7 @@ public static ChessPiece fromShortString(String piece) { throw new IllegalArgumentException("Unknown piece: " + piece); } - /** - * Returns true if this chess piece is of the same color as the given piece. - */ + /** Returns true if this chess piece is of the same color as the given piece. */ public final boolean isSameColorAs(ChessPiece otherPiece) { return this.val * otherPiece.val > 0; } @@ -138,44 +124,32 @@ public final boolean isSameTypeAs(ChessPiece otherPiece) { return Math.abs(this.val) == Math.abs(otherPiece.val); } - /** - * Returns true if this Piece is a pawn, returns false otherwise. - */ + /** Returns true if this Piece is a pawn, returns false otherwise. */ public final boolean isPawn() { return (this == WHITE_PAWN) || (this == BLACK_PAWN); } - /** - * Returns true if this Piece is a knight, returns false otherwise. - */ + /** Returns true if this Piece is a knight, returns false otherwise. */ public final boolean isKnight() { return (this == WHITE_KNIGHT) || (this == BLACK_KNIGHT); } - /** - * Returns true if this Piece is a bishop, returns false otherwise. - */ + /** Returns true if this Piece is a bishop, returns false otherwise. */ public final boolean isBishop() { return (this == WHITE_BISHOP) || (this == BLACK_BISHOP); } - /** - * Returns true if this Piece is a rook, returns false otherwise. - */ + /** Returns true if this Piece is a rook, returns false otherwise. */ public final boolean isRook() { return (this == WHITE_ROOK) || (this == BLACK_ROOK); } - /** - * Returns true if this Piece is a queen, returns false otherwise. - */ + /** Returns true if this Piece is a queen, returns false otherwise. */ public final boolean isQueen() { return (this == WHITE_QUEEN) || (this == BLACK_QUEEN); } - /** - * Returns true if this Piece is a king, returns false otherwise. - */ + /** Returns true if this Piece is a king, returns false otherwise. */ public final boolean isKing() { return (this == WHITE_KING) || (this == BLACK_KING); } @@ -185,7 +159,6 @@ public final boolean isKing() { * example, and "P" for a black pawn). * * @return a short string representing this piece. - * * @see #fromShortString(String) */ @Override @@ -200,9 +173,7 @@ public String toShortString() { throw new Error("This may never happen"); } - /** - * Returns a string representing the type of this piece ("Knight" for a knight for example). - */ + /** Returns a string representing the type of this piece ("Knight" for a knight for example). */ @Override public String getTypeName() { if (isPawn()) return "Pawn"; diff --git a/src/main/java/free/chess/ChesslikeGenericVariant.java b/src/main/java/free/chess/ChesslikeGenericVariant.java index c5bbbb5b..534f9516 100644 --- a/src/main/java/free/chess/ChesslikeGenericVariant.java +++ b/src/main/java/free/chess/ChesslikeGenericVariant.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002, 2003 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -22,20 +22,18 @@ import java.util.List; /** - *

* Implements WildVariant for chesslike variants. Subclasses must only define the initial position * and the name of the variant. Although this class is not abstract, directly instantiating it is * discouraged except for cases where the name or the initial position is unknown at compile time. * When the initial position and the name are known at compile time, its best to instantiate a * subclass which defines them. * - *

- * This class also provides some methods for determining the various properties of a move in the + *

This class also provides some methods for determining the various properties of a move in the * game of chess (en-passant, promotion, castling, etc.). Variants that only differ from chess in * their definition of these terms can override these methods and implement them accordingly. Note - * that it is not necessary to override the - * {@link #createMove(Position, Square, Square, Piece, String)} method as it already calls the - * forementioned methods when determining the properties of the created ChessMove. + * that it is not necessary to override the {@link #createMove(Position, Square, Square, Piece, + * String)} method as it already calls the forementioned methods when determining the properties of + * the created ChessMove. */ public class ChesslikeGenericVariant implements WildVariant { @@ -63,9 +61,7 @@ public class ChesslikeGenericVariant implements WildVariant { ChessPiece.BLACK_KNIGHT }; - /** - * A white short castling move. - */ + /** A white short castling move. */ public static final ChessMove WHITE_SHORT_CASTLING = new ChessMove( Square.parseSquare("e1"), @@ -79,9 +75,7 @@ public class ChesslikeGenericVariant implements WildVariant { null, "O-O"); - /** - * A white long castling move. - */ + /** A white long castling move. */ public static final ChessMove WHITE_LONG_CASTLING = new ChessMove( Square.parseSquare("e1"), @@ -95,9 +89,7 @@ public class ChesslikeGenericVariant implements WildVariant { null, "O-O-O"); - /** - * A black short castling move. - */ + /** A black short castling move. */ public static final ChessMove BLACK_SHORT_CASTLING = new ChessMove( Square.parseSquare("e8"), @@ -111,9 +103,7 @@ public class ChesslikeGenericVariant implements WildVariant { null, "O-O"); - /** - * A black long castling move. - */ + /** A black long castling move. */ public static final ChessMove BLACK_LONG_CASTLING = new ChessMove( Square.parseSquare("e8"), @@ -127,14 +117,10 @@ public class ChesslikeGenericVariant implements WildVariant { null, "O-O-O"); - /** - * The initial position of this variant, in FEN format. - */ + /** The initial position of this variant, in FEN format. */ private final String initialPositionFEN; - /** - * The name of this variant. - */ + /** The name of this variant. */ private final String variantName; /** @@ -247,12 +233,11 @@ public boolean isLongCastling( } /** - * Returns the piece captured by the move defined by the given arguments. Returns - * null if none. The result for an illegal move is undefined, but it should throw no + * Returns the piece captured by the move defined by the given arguments. Returns null + * if none. The result for an illegal move is undefined, but it should throw no * exceptions. This is a convenience method which determines whether the move defined by the given - * properties is an en-passant by invoking - * {@link #isEnPassant(Position, Square, Square, ChessPiece)}. Keep in mind that the called method - * may be overriden. + * properties is an en-passant by invoking {@link #isEnPassant(Position, Square, Square, + * ChessPiece)}. Keep in mind that the called method may be overriden. */ public ChessPiece getCapturedPiece( Position pos, Square startingSquare, Square endingSquare, ChessPiece promotionTarget) { @@ -262,8 +247,8 @@ public ChessPiece getCapturedPiece( } /** - * Returns the piece captured by the move defined by the given arguments. Returns - * null if none. The result for an illegal move is undefined, but it should throw no + * Returns the piece captured by the move defined by the given arguments. Returns null + * if none. The result for an illegal move is undefined, but it should throw no * exceptions. */ public ChessPiece getCapturedPiece( @@ -316,7 +301,7 @@ protected void checkPosition(Position pos) { * Sets the initial position of this chess variant on the given Position object. * * @throws IllegalArgumentException If the given Position is incompatible with this WildVariant as - * defined by {@link #checkPosition(Position)} + * defined by {@link #checkPosition(Position)} */ @Override public void init(Position pos) { @@ -329,12 +314,11 @@ public void init(Position pos) { * If the a move created by the given starting square and ending square in the given position is a * promotion, returns an array containing a knight, bishop, rook and queen of the color of the * promoted pawn. Otherwise returns null. If you want to use this method from the implementation - * of some other wild variant, use the static - * {@link #getChessPromotionTargets(Position, Square, Square)} method instead - it doesn't check - * the wild variant of the position. + * of some other wild variant, use the static {@link #getChessPromotionTargets(Position, Square, + * Square)} method instead - it doesn't check the wild variant of the position. * * @throws IllegalArgumentException If the given Position is incompatible with this WildVariant as - * defined by {@link #checkPosition(Position)} + * defined by {@link #checkPosition(Position)} */ @Override public Piece[] getPromotionTargets(Position pos, Square startingSquare, Square endingSquare) { @@ -371,11 +355,9 @@ public static Piece[] getChessPromotionTargets( * mildly different from Chess. * * @throws IllegalArgumentException If the given Position is incompatible with this WildVariant as - * defined by {@link #checkPosition(Position)} - * + * defined by {@link #checkPosition(Position)} * @throws IllegalArgumentException If the promotionTarget is not null and is not an instance of - * ChessPiece. - * + * ChessPiece. * @throws IllegalArgumentException If the there is no piece at the starting square. */ @Override @@ -392,14 +374,14 @@ public Move createMove( } /** - * Creates a ChessMove from the specified parameters as documented in - * {@link #createMove(Position, Square, Square, Piece, String)} This method is here solely for the + * Creates a ChessMove from the specified parameters as documented in {@link + * #createMove(Position, Square, Square, Piece, String)} This method is here solely for the * benefit of WildVariant implementations which need to create normal chess moves but * don't want to reimplement this method. Note that because this method is not static, to actually - * use it, you still need to obtain an instance of Chess via - * Chess.getInstance(). Unlike the - * {@link #createMove(Position, Square, Square, Piece, String)} method, this method does not - * enforce the wild variant of the position by calling {@link #checkPosition(Position)}. + * use it, you still need to obtain an instance of Chess via + * Chess.getInstance(). Unlike the {@link #createMove(Position, Square, Square, Piece, + * String)} method, this method does not enforce the wild variant of the position by calling + * {@link #checkPosition(Position)}. */ public ChessMove createChessMove( Position pos, @@ -464,9 +446,7 @@ public Move createMove(Position pos, Move move) { cmove.getStringRepresentation()); } - /** - * Creates a short castling move for the current player in the specified position. - */ + /** Creates a short castling move for the current player in the specified position. */ @Override public Move createShortCastling(Position pos) { checkPosition(pos); @@ -476,9 +456,7 @@ public Move createShortCastling(Position pos) { else return BLACK_SHORT_CASTLING; } - /** - * Creates a long castling move for the current player in the specified position. - */ + /** Creates a long castling move for the current player in the specified position. */ @Override public Move createLongCastling(Position pos) { checkPosition(pos); @@ -489,20 +467,17 @@ public Move createLongCastling(Position pos) { } /** - *

* Makes the given ChessMove in the given Position. This method shoudln't (and can't) be called * directly - call {@link Position#makeMove(Move)} instead. * - *

- * If you want to use this method from an implementation of some other wild variant, use the + *

If you want to use this method from an implementation of some other wild variant, use the * static {@link #makeChessMove(ChessMove, Position, Position.Modifier)} method instead - it * doesn't check the wild variant of the position. * * @throws IllegalArgumentException If the given Position is incompatible with this WildVariant as - * defined by {@link #checkPosition(Position)} - * + * defined by {@link #checkPosition(Position)} * @throws IllegalArgumentException if the given Move is not an instance of ChessMove - * . + * . */ @Override public void makeMove(Move move, Position pos, Position.Modifier modifier) { @@ -522,10 +497,10 @@ public void makeMove(Move move, Position pos, Position.Modifier modifier) { * Makes the given ChessMove on the given Position using the given position modifier. This method * is here solely for the benefit of WildVariant implementations which sometimes need to make a * regular ChessMove on a position and don't want to reimplement this method. Note that because - * this method is not static, to actually use it, you still need to obtain an instance of - * Chess via Chess.getInstance(). Unlike the - * {@link #makeMove(Move, Position, Position.Modifier)} method, this method does not enforce the - * wild variant of the position by calling {@link #checkPosition(Position)}. + * this method is not static, to actually use it, you still need to obtain an instance of + * Chess via Chess.getInstance(). Unlike the {@link #makeMove(Move, Position, + * Position.Modifier)} method, this method does not enforce the wild variant of the position by + * calling {@link #checkPosition(Position)}. */ public void makeChessMove(ChessMove cmove, Position pos, Position.Modifier modifier) { // This method is not static in solidarity with the createChessMove method @@ -563,12 +538,10 @@ public void makeChessMove(ChessMove cmove, Position pos, Position.Modifier modif /** * Returns what is described by the {@link #parseChessPiece(String)} method. * - *

- * If you want to use this method from an implementation of some other wild variant, use the + *

If you want to use this method from an implementation of some other wild variant, use the * static {@link #parseChessPiece(String)} method instead. * * @param piece The string representing the piece. - * * @throws IllegalArgumentException if the string is not in the correctformat. */ @Override @@ -580,7 +553,6 @@ public Piece parsePiece(String piece) { * Calls ChessPiece.fromShortString(String) to parse the piece. * * @param piece The string representing the piece. - * * @throws IllegalArgumentException if the string is not in the correctformat. */ public static ChessPiece parseChessPiece(String piece) { @@ -590,12 +562,10 @@ public static ChessPiece parseChessPiece(String piece) { /** * Returns what is described by the {@link #chessPieceToString(ChessPiece)} method. * - *

- * If you want to use this method from an implementation of some other wild variant, use the + *

If you want to use this method from an implementation of some other wild variant, use the * static {@link #chessPieceToString(ChessPiece)} method instead. * * @param piece The string representing the piece. - * * @throws IllegalArgumentException if the string is not in the correctformat. */ @Override @@ -613,9 +583,7 @@ public static String chessPieceToString(ChessPiece piece) { return piece.toShortString(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public Collection getTargetSquares(Position pos, Square square) { checkPosition(pos); @@ -627,9 +595,9 @@ public Collection getTargetSquares(Position pos, Square square) { * Same as {@link #getTargetSquares(Position, Square)}, but does not check that the wild variant * of the specified position is this variant. This method is here for the benefit of * WildVariants which don't subclass this class, but have the same target squares as - * normal chess. The method isn't static because it uses instance methods such as - * {@link #isEnPassant(Position, Square, Square, ChessPiece)}, which may be overridden, but it may - * be used via {@link Chess#getInstance()} from a non-subclass variant. + * normal chess. The method isn't static because it uses instance methods such as {@link + * #isEnPassant(Position, Square, Square, ChessPiece)}, which may be overridden, but it may be + * used via {@link Chess#getInstance()} from a non-subclass variant. */ public Collection getChessTargetSquares(Position pos, Square square) { ChessPiece piece = (ChessPiece) pos.getPieceAt(square); @@ -644,9 +612,7 @@ public Collection getChessTargetSquares(Position pos, Square square) { else throw new IllegalStateException("Unknown piece: " + piece); } - /** - * Returns the target squares for a piece which jumps to its destination (king and knight). - */ + /** Returns the target squares for a piece which jumps to its destination (king and knight). */ public static Collection getJumpingTargetSquares(Position pos, Square square, int[][] offsets) { List targetSquares = new LinkedList(); @@ -710,9 +676,7 @@ public static Collection getSlidingTargetSquares( return targetSquares; } - /** - * King move offsets. - */ + /** King move offsets. */ private static final int[][] KING_OFFSETS = new int[][] { new int[] {-1, -1}, @@ -725,9 +689,7 @@ public static Collection getSlidingTargetSquares( new int[] {1, 1} }; - /** - * Returns target squares for a king. - */ + /** Returns target squares for a king. */ protected Collection getKingTargetSquares(Position pos, Square square) { Collection targetSquares = getJumpingTargetSquares(pos, square, KING_OFFSETS); @@ -741,9 +703,7 @@ protected Collection getKingTargetSquares(Position pos, Square square) { return targetSquares; } - /** - * Queen move directions. - */ + /** Queen move directions. */ private static final int[][] QUEEN_DIRECTIONS = new int[][] { new int[] {-1, -1}, @@ -756,42 +716,30 @@ protected Collection getKingTargetSquares(Position pos, Square square) { new int[] {1, 1} }; - /** - * Returns target squares for a queen. - */ + /** Returns target squares for a queen. */ protected Collection getQueenTargetSquares(Position pos, Square square) { return getSlidingTargetSquares(pos, square, QUEEN_DIRECTIONS); } - /** - * Rook move directions. - */ + /** Rook move directions. */ private static final int[][] ROOK_DIRECTIONS = new int[][] {new int[] {0, -1}, new int[] {-1, 0}, new int[] {1, 0}, new int[] {0, 1}}; - /** - * Returns target squares for a rook. - */ + /** Returns target squares for a rook. */ protected Collection getRookTargetSquares(Position pos, Square square) { return getSlidingTargetSquares(pos, square, ROOK_DIRECTIONS); } - /** - * Bishop move directions. - */ + /** Bishop move directions. */ private static final int[][] BISHOP_DIRECTIONS = new int[][] {new int[] {-1, -1}, new int[] {1, -1}, new int[] {-1, 1}, new int[] {1, 1}}; - /** - * Returns target squares for a bishop. - */ + /** Returns target squares for a bishop. */ protected Collection getBishopTargetSquares(Position pos, Square square) { return getSlidingTargetSquares(pos, square, BISHOP_DIRECTIONS); } - /** - * Knight move offsets. - */ + /** Knight move offsets. */ private static final int[][] KNIGHT_OFFSETS = new int[][] { new int[] {-1, -2}, @@ -804,16 +752,12 @@ protected Collection getBishopTargetSquares(Position pos, Square square) { new int[] {1, 2}, }; - /** - * Returns target squares for a knight. - */ + /** Returns target squares for a knight. */ protected Collection getKnightTargetSquares(Position pos, Square square) { return getJumpingTargetSquares(pos, square, KNIGHT_OFFSETS); } - /** - * Returns target squares for a pawn. - */ + /** Returns target squares for a pawn. */ protected Collection getPawnTargetSquares(Position pos, Square square) { List targetSquares = new LinkedList(); @@ -862,33 +806,25 @@ else if (isEnPassantRank && isEnPassant(pos, square, targetSquare, null)) return targetSquares; } - /** - * Returns an instance of DefaultPiecePainter. - */ + /** Returns an instance of DefaultPiecePainter. */ @Override public PiecePainter createDefaultPiecePainter() { return new DefaultPiecePainter(); } - /** - * Returns an instance of DefaultBoardPainter. - */ + /** Returns an instance of DefaultBoardPainter. */ @Override public BoardPainter createDefaultBoardPainter() { return new DefaultBoardPainter(); } - /** - * Returns the name of this wild variant. - */ + /** Returns the name of this wild variant. */ @Override public String getName() { return variantName; } - /** - * Returns a textual representation of this wild variant. - */ + /** Returns a textual representation of this wild variant. */ @Override public String toString() { return getName(); diff --git a/src/main/java/free/chess/ColoredBoardPainter.java b/src/main/java/free/chess/ColoredBoardPainter.java index 1c3e7df0..60798994 100644 --- a/src/main/java/free/chess/ColoredBoardPainter.java +++ b/src/main/java/free/chess/ColoredBoardPainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -24,23 +24,15 @@ */ public interface ColoredBoardPainter extends BoardPainter { - /** - * Returns the color of the light squares. - */ + /** Returns the color of the light squares. */ Color getLightColor(); - /** - * Sets the color of the light squares. - */ + /** Sets the color of the light squares. */ void setLightColor(Color color); - /** - * Returns the color of the dark squares. - */ + /** Returns the color of the dark squares. */ Color getDarkColor(); - /** - * Sets the color of the dark squares. - */ + /** Sets the color of the dark squares. */ void setDarkColor(Color color); } diff --git a/src/main/java/free/chess/ColoredPiecePainter.java b/src/main/java/free/chess/ColoredPiecePainter.java index 10e2ce2b..e1aeb0d8 100644 --- a/src/main/java/free/chess/ColoredPiecePainter.java +++ b/src/main/java/free/chess/ColoredPiecePainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -24,43 +24,27 @@ */ public interface ColoredPiecePainter extends PiecePainter { - /** - * Returns the color of the white pieces. - */ + /** Returns the color of the white pieces. */ Color getWhiteColor(); - /** - * Sets the color of the white pieces. - */ + /** Sets the color of the white pieces. */ void setWhiteColor(Color color); - /** - * Returns the color of the black pieces. - */ + /** Returns the color of the black pieces. */ Color getBlackColor(); - /** - * Sets the color of the black pieces. - */ + /** Sets the color of the black pieces. */ void setBlackColor(Color color); - /** - * Returns the color of the outline for white pieces. - */ + /** Returns the color of the outline for white pieces. */ Color getWhiteOutline(); - /** - * Sets the color of the outline on white pieces. - */ + /** Sets the color of the outline on white pieces. */ void setWhiteOutline(Color color); - /** - * Returns the color of the outline for black pieces. - */ + /** Returns the color of the outline for black pieces. */ Color getBlackOutline(); - /** - * Sets the color of the outline on black pieces. - */ + /** Sets the color of the outline on black pieces. */ void setBlackOutline(Color color); } diff --git a/src/main/java/free/chess/DefaultBoardPainter.java b/src/main/java/free/chess/DefaultBoardPainter.java index fd389a6f..47cfc78b 100644 --- a/src/main/java/free/chess/DefaultBoardPainter.java +++ b/src/main/java/free/chess/DefaultBoardPainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -24,22 +24,16 @@ */ public class DefaultBoardPainter implements BoardPainter { - /** - * The delegate. - */ + /** The delegate. */ private final BoardPainter delegate = new PlainBoardPainter(); - /** - * Since DefaultBoardPainter is immutable, simply returns this. - */ + /** Since DefaultBoardPainter is immutable, simply returns this. */ @Override public BoardPainter freshInstance() { return new DefaultBoardPainter(); } - /** - * Paints the board. - */ + /** Paints the board. */ @Override public void paintBoard(Graphics g, Component component, int x, int y, int width, int height) { delegate.paintBoard(g, component, x, y, width, height); diff --git a/src/main/java/free/chess/DefaultPiecePainter.java b/src/main/java/free/chess/DefaultPiecePainter.java index c5b25dea..da701247 100644 --- a/src/main/java/free/chess/DefaultPiecePainter.java +++ b/src/main/java/free/chess/DefaultPiecePainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -30,22 +30,16 @@ */ public class DefaultPiecePainter implements PiecePainter { - /** - * The delegate. - */ + /** The delegate. */ private PiecePainter delegate = new EboardVectorPiecePainter(); - /** - * Since DefaultPiecePainter is immutable, simply returns this. - */ + /** Since DefaultPiecePainter is immutable, simply returns this. */ @Override public PiecePainter freshInstance() { return this; } - /** - * Paints the piece. - */ + /** Paints the piece. */ @Override public void paintPiece( Piece piece, Graphics g, Component component, Rectangle rect, boolean shaded) { diff --git a/src/main/java/free/chess/EboardVectorPiecePainter.java b/src/main/java/free/chess/EboardVectorPiecePainter.java index 578d49ad..e27ccecd 100644 --- a/src/main/java/free/chess/EboardVectorPiecePainter.java +++ b/src/main/java/free/chess/EboardVectorPiecePainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -63,17 +63,13 @@ public EboardVectorPiecePainter( super(whiteColor, blackColor, whiteOutline, blackOutline); } - /** - * Returns a copy of this EboardVectorPiecePainter. - */ + /** Returns a copy of this EboardVectorPiecePainter. */ @Override public PiecePainter freshInstance() { return new EboardVectorPiecePainter(); } - /** - * Creates and returns a Polygon for drawing a king. - */ + /** Creates and returns a Polygon for drawing a king. */ @Override protected Polygon createKingPolygon(int width, int height) { Polygon kingPolygon = new Polygon(); @@ -166,9 +162,7 @@ protected void drawKingImage( g.drawLine(53 * width / 108, 86 * height / 108, 82 * width / 108, 92 * height / 108); } - /** - * Creates and returns a Polygon for drawing a queen. - */ + /** Creates and returns a Polygon for drawing a queen. */ @Override protected Polygon createQueenPolygon(int width, int height) { Polygon queenPolygon = new Polygon(); @@ -269,9 +263,7 @@ protected void drawQueenImage( g.drawLine(53 * width / 108, 76 * height / 108, 81 * width / 108, 83 * height / 108); } - /** - * Creates and returns a Polygon for drawing a rook. - */ + /** Creates and returns a Polygon for drawing a rook. */ @Override protected Polygon createRookPolygon(int width, int height) { Polygon rookPolygon = new Polygon(); @@ -329,9 +321,7 @@ protected void drawRookImage( g.drawLine(22 * width / 108, 90 * height / 108, 84 * width / 108, 90 * height / 108); } - /** - * Creates and returns a Polygon for drawing a bishop. - */ + /** Creates and returns a Polygon for drawing a bishop. */ @Override protected Polygon createBishopPolygon(int width, int height) { Polygon bishopPolygon = new Polygon(); @@ -449,9 +439,7 @@ protected void drawBishopImage( g.drawLine(53 * width / 108, 72 * height / 108, 73 * width / 108, 74 * height / 108); } - /** - * Creates and returns a Polygon for drawing a knight. - */ + /** Creates and returns a Polygon for drawing a knight. */ @Override protected Polygon createKnightPolygon(int width, int height) { Polygon knightPolygon = new Polygon(); @@ -545,9 +533,7 @@ protected void drawKnightImage( g.drawLine(22 * width / 108, 75 * height / 108, 25 * width / 108, 68 * height / 108); } - /** - * Creates and returns a Polygon for drawing a pawn. - */ + /** Creates and returns a Polygon for drawing a pawn. */ @Override protected Polygon createPawnPolygon(int width, int height) { Polygon pawnPolygon = new Polygon(); diff --git a/src/main/java/free/chess/FischerTimeControl.java b/src/main/java/free/chess/FischerTimeControl.java index 998111bd..de71581c 100644 --- a/src/main/java/free/chess/FischerTimeControl.java +++ b/src/main/java/free/chess/FischerTimeControl.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2007 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -24,14 +24,10 @@ */ public final class FischerTimeControl extends TimeControl { - /** - * The initial time on the clock, in milliseconds. - */ + /** The initial time on the clock, in milliseconds. */ private final int initial; - /** - * The amount of time added to the clock after each move, in milliseconds. - */ + /** The amount of time added to the clock after each move, in milliseconds. */ private final int increment; /** @@ -39,7 +35,7 @@ public final class FischerTimeControl extends TimeControl { * * @param initial The initial amount of time on the player's clock, in milliseconds. * @param increment The amount of time added to the player's clock after each move, in - * milliseconds. + * milliseconds. */ public FischerTimeControl(int initial, int increment) { if (initial < 0) throw new IllegalArgumentException("Initial time may not be negative"); @@ -49,55 +45,41 @@ public FischerTimeControl(int initial, int increment) { this.increment = increment; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public int getInitialTime(Player player) { return getInitial(); } - /** - * Returns the initial amount of time on the player's clock, in milliseconds. - */ + /** Returns the initial amount of time on the player's clock, in milliseconds. */ public int getInitial() { return initial; } - /** - * Returns the amount of time added to the player's clock after each move. - */ + /** Returns the amount of time added to the player's clock after each move. */ public int getIncrement() { return increment; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public String getLocalizedShortDescription() { return getDescription("shortDescription"); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public String getLocalizedMediumDescription() { return getDescription("mediumDescription"); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public String getLocalizedLongDescription() { return getDescription("longDescription"); } - /** - * Returns a description of the time control obtained using the specified localization key. - */ + /** Returns a description of the time control obtained using the specified localization key. */ private String getDescription(String key) { Localization l10n = LocalizationService.getForClass(FischerTimeControl.class); int initialMinutes = getInitial() / (1000 * 60); @@ -107,9 +89,7 @@ private String getDescription(String key) { return l10n.getFormattedString(key, args); } - /** - * Returns whether the specified object equals to this one. - */ + /** Returns whether the specified object equals to this one. */ @Override public boolean equals(Object o) { if (!(o instanceof FischerTimeControl) || (o == null)) return false; @@ -118,9 +98,7 @@ public boolean equals(Object o) { return (tc.initial == initial) && (tc.increment == increment); } - /** - * Returns the hash code for this object. - */ + /** Returns the hash code for this object. */ @Override public int hashCode() { return initial ^ increment; diff --git a/src/main/java/free/chess/ImageBoardPainter.java b/src/main/java/free/chess/ImageBoardPainter.java index 011b56a9..50a75417 100644 --- a/src/main/java/free/chess/ImageBoardPainter.java +++ b/src/main/java/free/chess/ImageBoardPainter.java @@ -2,43 +2,38 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2006 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; +import free.util.IOUtilities; import java.awt.Component; import java.awt.Graphics; import java.io.IOException; import java.net.URL; import java.util.Properties; -import free.util.IOUtilities; - /** - * This class is provided for backwards compatibility with uses as a - * ResourceBoardPainter. The actual drawing is now done by either - * {@link BoardImageBoardPainter} or {@link SquareImagesBoardPainter}. + * This class is provided for backwards compatibility with uses as a ResourceBoardPainter + * . The actual drawing is now done by either {@link BoardImageBoardPainter} or {@link + * SquareImagesBoardPainter}. */ public final class ImageBoardPainter implements ResourceBoardPainter { - /** - * The delegate that does the actual drawing for us. - */ + /** The delegate that does the actual drawing for us. */ private ResourceBoardPainter delegate; - /** - * Since ImageBoardPainters are immutable, simply returns this. - */ + /** Since ImageBoardPainters are immutable, simply returns this. */ @Override public BoardPainter freshInstance() { return this; @@ -48,13 +43,15 @@ public BoardPainter freshInstance() { * Loads the board images from the specified URL. The structure at the specified url is described * below. A properties file named "definition" must be located at the base URL. That file should * contain the two property: + * *

- * Based on the value of this property, the actual drawing is done by either a - * {@link BoardImageBoardPainter} or a {@link SquareImagesBoardPainter}. + * + * Based on the value of this property, the actual drawing is done by either a {@link + * BoardImageBoardPainter} or a {@link SquareImagesBoardPainter}. */ @Override public void load(URL url) throws IOException { @@ -73,9 +70,7 @@ public void load(URL url) throws IOException { delegate.load(url); } - /** - * Merely delegates the drawing to the actual board painter. - */ + /** Merely delegates the drawing to the actual board painter. */ @Override public void paintBoard(Graphics g, Component component, int x, int y, int width, int height) { delegate.paintBoard(g, component, x, y, width, height); diff --git a/src/main/java/free/chess/ImagePiecePainter.java b/src/main/java/free/chess/ImagePiecePainter.java index 1b019886..8c06d02b 100644 --- a/src/main/java/free/chess/ImagePiecePainter.java +++ b/src/main/java/free/chess/ImagePiecePainter.java @@ -2,20 +2,23 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; +import free.util.IOUtilities; +import free.util.ImageUtilities; +import free.util.TextUtilities; import java.awt.Component; import java.awt.Graphics; import java.awt.Image; @@ -33,23 +36,13 @@ import java.util.Properties; import java.util.Set; -import free.util.IOUtilities; -import free.util.ImageUtilities; -import free.util.TextUtilities; - -/** - * An implementation of PiecePainter which paints images. - */ +/** An implementation of PiecePainter which paints images. */ public final class ImagePiecePainter implements ResourcePiecePainter { - /** - * The painter we delegate to while loading images. - */ + /** The painter we delegate to while loading images. */ private static final PiecePainter whileLoadingDelegate = new DefaultPiecePainter(); - /** - * The ImageFilter we use to create shaded images. - */ + /** The ImageFilter we use to create shaded images. */ private static final ImageFilter SHADING_FILTER = new ShadingFilter(); /** @@ -59,33 +52,31 @@ public final class ImagePiecePainter implements ResourcePiecePainter { private static volatile boolean asyncImageLoad = false; /** - * An array whose indices specify the size of the images and whose values are maps mapping - * Pieces to either Images or URLs, if the image isn't - * loaded yet. + * An array whose indices specify the size of the images and whose values are maps mapping + * Pieces to either Images or URLs, if the image isn't loaded + * yet. */ private Map[] pieceImages; - /** - * Same as pieceImages only for shaded images. - */ + /** Same as pieceImages only for shaded images. */ private Map[] shadedPieceImages; /** - * Maps the square sizes for which images are currently being loaded to the - * ImageDataReceivers waiting on the data. + * Maps the square sizes for which images are currently being loaded to the + * ImageDataReceivers waiting on the data. */ private final Map imageDataReceivers = new HashMap(2); /** - * A no-arg constructor, so that this piece painter can be used as a - * ResourcePiecePainter. + * A no-arg constructor, so that this piece painter can be used as a ResourcePiecePainter + * . */ public ImagePiecePainter() {} /** - * Creates a new ImagePiecePainter with the specified piece images. The given - * Map should map Integers specifying the size of the piece images to - * Mapss which in turn map Pieces to piece Images. + * Creates a new ImagePiecePainter with the specified piece images. The given + * Map should map Integers specifying the size of the piece images to + * Mapss which in turn map Pieces to piece Images. */ public ImagePiecePainter(Map pieceImages) { @@ -135,17 +126,13 @@ public static void setAsyncImageLoad(boolean asyncImageLoad) { ImagePiecePainter.asyncImageLoad = asyncImageLoad; } - /** - * Creates a shaded version of the specified image. - */ + /** Creates a shaded version of the specified image. */ private static Image shadeImage(Image image) { return Toolkit.getDefaultToolkit() .createImage(new FilteredImageSource(image.getSource(), SHADING_FILTER)); } - /** - * Since ImagePiecePainters are immutable, simply returns this. - */ + /** Since ImagePiecePainters are immutable, simply returns this. */ @Override public PiecePainter freshInstance() { return this; @@ -155,18 +142,20 @@ public PiecePainter freshInstance() { * Loads the piece images from the specified URL. The structure at the specified url is described * below. A properties file named "definition" must be located at the base URL. That file should * contain the following three properties: + * *

+ * * Directories with names corresponding to the sizes must be present at the base URL and in those - * directories resources named [color char][piece char].[extension] where - * [color char] is either 'w' or 'b' (for black or white), [piece char] - * is one of 'k', 'q', 'r', 'b', 'n' or 'p'. The images for all twelve pieces must be present - * there and they must have the correct size. + * directories resources named [color char][piece char].[extension] where + * [color char] is either 'w' or 'b' (for black or white), [piece char] is one + * of 'k', 'q', 'r', 'b', 'n' or 'p'. The images for all twelve pieces must be present there and + * they must have the correct size. */ @Override public void load(URL baseUrl) throws IOException { @@ -219,9 +208,7 @@ public void load(URL baseUrl) throws IOException { } } - /** - * Returns the size of provided images which is the best fit for the specified square size. - */ + /** Returns the size of provided images which is the best fit for the specified square size. */ protected int bestFitImageSize(int squareSize) { if (squareSize <= 0) throw new IllegalArgumentException("Image size must be positive"); @@ -238,8 +225,8 @@ protected int bestFitImageSize(int squareSize) { /** * If already loaded, returns the piece images at the specified size. Otherwise, starts loading - * them (if async loading is enabled, in a background thread, in the meanwhile, returning - * null), and once done, repaints the specified component. + * them (if async loading is enabled, in a background thread, in the meanwhile, returning + * null), and once done, repaints the specified component. */ protected synchronized Map loadPieces(int squareSize, boolean shaded, Component target) { int imageSize = bestFitImageSize(squareSize); @@ -310,9 +297,7 @@ public void paintPiece( pieceImage, x + (width - pieceWidth) / 2, y + (height - pieceHeight) / 2, component); } - /** - * The ImageFilter we use to create shaded piece images. - */ + /** The ImageFilter we use to create shaded piece images. */ private static class ShadingFilter extends RGBImageFilter { @Override @@ -336,24 +321,16 @@ public int filterRGB(int x, int y, int rgb) { */ private class ImageDataReceiver implements IOUtilities.DataReceiver { - /** - * The map of pieces to normal images. - */ + /** The map of pieces to normal images. */ private final Map normalImages; - /** - * The map of pieces to shaded images. - */ + /** The map of pieces to shaded images. */ private final Map shadedImages; - /** - * The size of the images we're loading. - */ + /** The size of the images we're loading. */ private final int imageSize; - /** - * The components to repaint when the loading is done. - */ + /** The components to repaint when the loading is done. */ private final Set componentsToRepaint = new HashSet(2); /** @@ -368,16 +345,12 @@ public ImageDataReceiver( componentsToRepaint.add(componentToRepaint); } - /** - * Adds a component to the set of components to repaint once all the images are loaded. - */ + /** Adds a component to the set of components to repaint once all the images are loaded. */ public void addComponentToRepaint(Component component) { componentsToRepaint.add(component); } - /** - * Called when the image data has been loaded. Creates and maps the piece images. - */ + /** Called when the image data has been loaded. Creates and maps the piece images. */ @Override public void dataRead(URL[] urls, Object id, byte[][] data, IOException[] exceptions) { // If there are any exceptions, we simply quit - this will cause diff --git a/src/main/java/free/chess/JBoard.java b/src/main/java/free/chess/JBoard.java index 0831440d..59159b98 100644 --- a/src/main/java/free/chess/JBoard.java +++ b/src/main/java/free/chess/JBoard.java @@ -2,20 +2,28 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; +import free.chess.event.MoveEvent; +import free.chess.event.MoveListener; +import free.chess.event.MoveProgressEvent; +import free.chess.event.MoveProgressListener; +import free.util.MathUtilities; +import free.util.PaintHook; +import free.util.PlatformUtils; +import free.util.Utilities; import java.awt.AWTEvent; import java.awt.BasicStroke; import java.awt.Color; @@ -37,7 +45,6 @@ import java.util.Collection; import java.util.Iterator; import java.util.Vector; - import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.SwingUtilities; @@ -45,39 +52,22 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import free.chess.event.MoveEvent; -import free.chess.event.MoveListener; -import free.chess.event.MoveProgressEvent; -import free.chess.event.MoveProgressListener; -import free.util.MathUtilities; -import free.util.PaintHook; -import free.util.PlatformUtils; -import free.util.Utilities; - /** * An implementation of a chess board component. IMPORTANT: This class is not thread safe - * all modifications should be done in the AWT event dispatching thread. */ public class JBoard extends JComponent { - /** - * The default move highlighting color. - */ + /** The default move highlighting color. */ private static final Color DEFAULT_MOVE_HIGHLIGHT_COLOR = Color.cyan.darker(); - /** - * The default coordinate display color. - */ + /** The default coordinate display color. */ private static final Color DEFAULT_COORDS_DISPLAY_COLOR = Color.blue.darker(); - /** - * The default highlighting color for the squares of the move currently being made. - */ + /** The default highlighting color for the squares of the move currently being made. */ private static final Color DEFAULT_MADE_MOVE_SQUARES_HIGHLIGHT_COLOR = Color.blue; - /** - * The default color for highlighting possible target squares. - */ + /** The default color for highlighting possible target squares. */ private static final Color DEFAULT_POSSIBLE_TARGET_SQUARES_HIGHLIGHT_COLOR = new Color(255, 255, 255, 80); @@ -87,34 +77,22 @@ public class JBoard extends JComponent { */ public static final int UNIFIED_MOVE_INPUT_STYLE = 0; - /** - * The constant for drag'n'drop move input style. - */ + /** The constant for drag'n'drop move input style. */ public static final int DRAG_N_DROP_MOVE_INPUT_STYLE = 1; - /** - * The constant for click'n'click move input style. - */ + /** The constant for click'n'click move input style. */ public static final int CLICK_N_CLICK_MOVE_INPUT_STYLE = 2; - /** - * The constant for move input mode which doesn't let the user move any of the pieces. - */ + /** The constant for move input mode which doesn't let the user move any of the pieces. */ public static final int NO_PIECES_MOVE = 0; - /** - * The constant for move input mode which only lets the user move white pieces. - */ + /** The constant for move input mode which only lets the user move white pieces. */ public static final int WHITE_PIECES_MOVE = 1; - /** - * The constant for move input mode which only lets the user move black pieces. - */ + /** The constant for move input mode which only lets the user move black pieces. */ public static final int BLACK_PIECES_MOVE = 2; - /** - * The constant for move input mode which lets the user move both white and black pieces. - */ + /** The constant for move input mode which lets the user move both white and black pieces. */ public static final int ALL_PIECES_MOVE = 3; /** @@ -123,14 +101,10 @@ public class JBoard extends JComponent { */ public static final int CURRENT_PLAYER_MOVES = 4; - /** - * The constant for no move highlighting. - */ + /** The constant for no move highlighting. */ public static final int NO_MOVE_HIGHLIGHTING = 0; - /** - * The constant for move highlighting done by highlighting the target square of the move. - */ + /** The constant for move highlighting done by highlighting the target square of the move. */ public static final int TARGET_SQUARE_MOVE_HIGHLIGHTING = 1; /** @@ -145,9 +119,7 @@ public class JBoard extends JComponent { */ public static final int ARROW_MOVE_HIGHLIGHTING = 3; - /** - * The constant for not displaying coordinates at all. - */ + /** The constant for not displaying coordinates at all. */ public static final int NO_COORDS = 0; /** @@ -156,19 +128,13 @@ public class JBoard extends JComponent { */ public static final int RIM_COORDS = 1; - /** - * The constant for displaying row and column coordinates outside of the actual board. - */ + /** The constant for displaying row and column coordinates outside of the actual board. */ public static final int OUTSIDE_COORDS = 2; - /** - * The constant for displaying square coordinates in each square. - */ + /** The constant for displaying square coordinates in each square. */ public static final int EVERY_SQUARE_COORDS = 3; - /** - * The Position on the board. - */ + /** The Position on the board. */ private Position position; /** @@ -177,9 +143,7 @@ public class JBoard extends JComponent { */ private Position positionCopy; - /** - * A flag we set when we make a move entered by the user, on this board. - */ + /** A flag we set when we make a move entered by the user, on this board. */ private boolean isMakingUserMove = false; /** @@ -188,9 +152,7 @@ public class JBoard extends JComponent { */ private boolean positionChangedByMove = false; - /** - * The ChangeListener to the Position. - */ + /** The ChangeListener to the Position. */ private final ChangeListener positionChangeListener = new ChangeListener() { @Override @@ -259,9 +221,7 @@ private void updateBoard(Position startPosition, Position endPosition) { positionCopy.copyFrom(endPosition); } - /** - * The MoveListener of the position. - */ + /** The MoveListener of the position. */ private final MoveListener positionMoveListener = new MoveListener() { @Override @@ -293,84 +253,52 @@ public void moveMade(MoveEvent evt) { } }; - /** - * The BoardPainter painting the board. - */ + /** The BoardPainter painting the board. */ private BoardPainter boardPainter; - /** - * The PiecePainter painting the pieces. - */ + /** The PiecePainter painting the pieces. */ private PiecePainter piecePainter; - /** - * PaintHooks. - */ + /** PaintHooks. */ private Vector paintHooks = null; - /** - * The current move input style. - */ + /** The current move input style. */ private int moveInputStyle = UNIFIED_MOVE_INPUT_STYLE; - /** - * The current move input mode. - */ + /** The current move input mode. */ private int moveInputMode = ALL_PIECES_MOVE; - /** - * Whether the piece follows the cursor as a move is being made. - */ + /** Whether the piece follows the cursor as a move is being made. */ private boolean isPieceFollowsCursor = true; - /** - * Whether the squares of the made move are highlighted. - */ + /** Whether the squares of the made move are highlighted. */ private boolean isHighlightMadeMoveSquares = false; - /** - * The current move highlighting style. - */ + /** The current move highlighting style. */ private int moveHighlightingStyle = NO_MOVE_HIGHLIGHTING; - /** - * Whether a shadow piece is shown in the target square while making a move. - */ + /** Whether a shadow piece is shown in the target square while making a move. */ private boolean isShowShadowPieceInTargetSquare = false; - /** - * Whether legal target squares are highlighted when making a move. - */ + /** Whether legal target squares are highlighted when making a move. */ private boolean isHighlightLegalTargetSquares = false; - /** - * Whether the target square snaps to the nearest legal square when making a move. - */ + /** Whether the target square snaps to the nearest legal square when making a move. */ private boolean isSnapToLegalSquare = false; - /** - * The current coordinates display style. - */ + /** The current coordinates display style. */ private int coordsDisplayStyle = NO_COORDS; - /** - * Is the board editable? - */ + /** Is the board editable? */ private boolean isEditable = true; - /** - * Is the board flipped? - */ + /** Is the board flipped? */ private boolean isFlipped = false; - /** - * Are we currently manual promotion mode? - */ + /** Are we currently manual promotion mode? */ private boolean isManualPromote = true; - /** - * The color used for move highlighting. - */ + /** The color used for move highlighting. */ private Color moveHighlightingColor = DEFAULT_MOVE_HIGHLIGHT_COLOR; /** @@ -378,34 +306,22 @@ public void moveMade(MoveEvent evt) { */ private Color coordsDisplayColor = DEFAULT_COORDS_DISPLAY_COLOR; - /** - * The color used for highlighting the squares of a move as it's being made. - */ + /** The color used for highlighting the squares of a move as it's being made. */ private Color madeMoveSquaresHighlightColor = DEFAULT_MADE_MOVE_SQUARES_HIGHLIGHT_COLOR; - /** - * The color with which possible target squares are highlighted. - */ + /** The color with which possible target squares are highlighted. */ private Color legalTargetSquaresHighlightColor = DEFAULT_POSSIBLE_TARGET_SQUARES_HIGHLIGHT_COLOR; - /** - * The duration of piece sliding. When negative, no sliding occurs. - */ + /** The duration of piece sliding. When negative, no sliding occurs. */ private int slideDuration = -1; - /** - * The current highlighted move. - */ + /** The current highlighted move. */ private Move highlightedMove = null; - /** - * An array specifying which squares are shaded. - */ + /** An array specifying which squares are shaded. */ private boolean[][] isShaded = new boolean[8][8]; - /** - * The square of the currently moved piece; null when not making a move. - */ + /** The square of the currently moved piece; null when not making a move. */ private Square movedPieceSquare = null; /** @@ -421,58 +337,46 @@ public void moveMade(MoveEvent evt) { private Square targetSquare; /** - * A set of possible target squares during a move; null if none. May be - * null even during a move, if it's not required (neither in snap-to-legal-square, - * nor in highlight-legal-moves mode). + * A set of possible target squares during a move; null if none. May be null + * even during a move, if it's not required (neither in snap-to-legal-square, nor in + * highlight-legal-moves mode). */ private Collection legalTargetSquares = null; /** * Indicates the current move gesture if in UNIFIED_MOVE_INPUT_STYLE. Possible values * are: + * *

+ * * This is not a property, but a helper variable - it just reuses the constants because it makes * sense. */ private int moveGesture = UNIFIED_MOVE_INPUT_STYLE; - /** - * The time when the last drag gesture started, in UNIFIED_MOVE_MODE. - */ + /** The time when the last drag gesture started, in UNIFIED_MOVE_MODE. */ private long dragStartTime; - /** - * The starting square during a piece slide. - */ + /** The starting square during a piece slide. */ private Square slideStartSquare = null; - /** - * The ending square during a piece slide. - */ + /** The ending square during a piece slide. */ private Square slideEndSquare = null; - /** - * The sliding piece during a piece slide. - */ + /** The sliding piece during a piece slide. */ private Piece slidePiece = null; - /** - * The taken piece during a piece slide. - */ + /** The taken piece during a piece slide. */ private Piece slideTakenPiece; - /** - * The end position for a slide animation. - */ + /** The end position for a slide animation. */ private Position slideTargetPosition; - /** - * The time when the sliding started. - */ + /** The time when the sliding started. */ private long slideStartTime; /** @@ -481,9 +385,7 @@ public void moveMade(MoveEvent evt) { */ private long slideTime; - /** - * The time which invoked repaint() periodically to animate sliding. - */ + /** The time which invoked repaint() periodically to animate sliding. */ private final Timer slideTimer = new Timer( 20, @@ -522,9 +424,7 @@ public void actionPerformed(ActionEvent e) { */ private boolean isShowingModalDialog = false; - /** - * Creates a new JBoard with the specified position and BoardPainter and PiecePainter. - */ + /** Creates a new JBoard with the specified position and BoardPainter and PiecePainter. */ public JBoard(Position position, BoardPainter boardPainter, PiecePainter piecePainter) { if (position == null) throw new IllegalArgumentException("The Position may not be null"); if (boardPainter == null) @@ -540,9 +440,7 @@ public JBoard(Position position, BoardPainter boardPainter, PiecePainter piecePa enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK); } - /** - * Creates a new JBoard with the given position set on it. - */ + /** Creates a new JBoard with the given position set on it. */ public JBoard(Position position) { this( position, @@ -550,30 +448,22 @@ public JBoard(Position position) { position.getVariant().createDefaultPiecePainter()); } - /** - * Creates a new JBoard with the initial position set on it. - */ + /** Creates a new JBoard with the initial position set on it. */ public JBoard() { this(new Position()); } - /** - * Adds a MoveProgressListener. - */ + /** Adds a MoveProgressListener. */ public void addMoveProgressListener(MoveProgressListener listener) { listenerList.add(MoveProgressListener.class, listener); } - /** - * Remove a MoveProgressListener. - */ + /** Remove a MoveProgressListener. */ public void removeMoveProgressListener(MoveProgressListener listener) { listenerList.remove(MoveProgressListener.class, listener); } - /** - * Fires the specified MoveProfressEvent to interested listeners. - */ + /** Fires the specified MoveProfressEvent to interested listeners. */ protected void fireMoveProgressEvent(MoveProgressEvent evt) { int id = evt.getId(); Object[] listeners = listenerList.getListenerList(); @@ -612,16 +502,12 @@ public void removePaintHook(PaintHook hook) { if (paintHooks.size() == 0) paintHooks = null; } - /** - * Returns the Position on this JBoard. - */ + /** Returns the Position on this JBoard. */ public Position getPosition() { return position; } - /** - * Sets this JBoard to display the given Position. - */ + /** Sets this JBoard to display the given Position. */ public void setPosition(Position newPosition) { if (newPosition == null) throw new IllegalArgumentException("Null position"); @@ -643,9 +529,9 @@ public void setPosition(Position newPosition) { } /** - * Sets the move input style of this JBoard to the given style. Possible values are - * {@link #UNIFIED_MOVE_INPUT_STYLE}, {@link #DRAG_N_DROP_MOVE_INPUT_STYLE} and - * {@link #CLICK_N_CLICK_MOVE_INPUT_STYLE}. + * Sets the move input style of this JBoard to the given style. Possible values are {@link + * #UNIFIED_MOVE_INPUT_STYLE}, {@link #DRAG_N_DROP_MOVE_INPUT_STYLE} and {@link + * #CLICK_N_CLICK_MOVE_INPUT_STYLE}. */ public void setMoveInputStyle(int newStyle) { switch (newStyle) { @@ -662,17 +548,15 @@ public void setMoveInputStyle(int newStyle) { firePropertyChange("moveInputStyle", oldStyle, newStyle); } - /** - * Returns the current move input style for this JBoard. - */ + /** Returns the current move input style for this JBoard. */ public int getMoveInputStyle() { return moveInputStyle; } /** - * Sets the move input mode of this JBoard to the given mode. Possible values are - * {@link #NO_PIECES_MOVE}, {@link #WHITE_PIECES_MOVE}, {@link #BLACK_PIECES_MOVE}, - * {@link #ALL_PIECES_MOVE} and {@link #CURRENT_PLAYER_MOVES}. + * Sets the move input mode of this JBoard to the given mode. Possible values are {@link + * #NO_PIECES_MOVE}, {@link #WHITE_PIECES_MOVE}, {@link #BLACK_PIECES_MOVE}, {@link + * #ALL_PIECES_MOVE} and {@link #CURRENT_PLAYER_MOVES}. */ public void setMoveInputMode(int newMode) { switch (newMode) { @@ -690,64 +574,48 @@ public void setMoveInputMode(int newMode) { firePropertyChange("moveInputMode", oldMode, newMode); } - /** - * Returns the current move input mode for this JBoard. - */ + /** Returns the current move input mode for this JBoard. */ public int getMoveInputMode() { return moveInputMode; } - /** - * Sets whether pieces can at all be moved. - */ + /** Sets whether pieces can at all be moved. */ public void setEditable(boolean isEditable) { boolean oldEditable = this.isEditable; this.isEditable = isEditable; firePropertyChange("editable", oldEditable, isEditable); } - /** - * Returns true if the board is editable, i.e. the pieces can at all be moved. - */ + /** Returns true if the board is editable, i.e. the pieces can at all be moved. */ public boolean isEditable() { return isEditable; } - /** - * Sets whether the moved piece follows the mouse cursor while a move is being made. - */ + /** Sets whether the moved piece follows the mouse cursor while a move is being made. */ public void setPieceFollowsCursor(boolean isPieceFollowsCursor) { boolean oldVal = this.isPieceFollowsCursor; this.isPieceFollowsCursor = isPieceFollowsCursor; firePropertyChange("pieceFollowsCursor", oldVal, isPieceFollowsCursor); } - /** - * Returns whether the moved piece follows the mouse cursor while a move is being made. - */ + /** Returns whether the moved piece follows the mouse cursor while a move is being made. */ public boolean isPieceFollowsCursor() { return isPieceFollowsCursor; } - /** - * Sets whether the squares of a move being made are highlighted. - */ + /** Sets whether the squares of a move being made are highlighted. */ public void setHighlightMadeMoveSquares(boolean highlight) { boolean oldVal = this.isHighlightMadeMoveSquares; this.isHighlightMadeMoveSquares = highlight; firePropertyChange("highlightMadeMoveSquares", oldVal, highlight); } - /** - * Returns whether the move being made is highlighted. - */ + /** Returns whether the move being made is highlighted. */ public boolean isHighlightMadeMoveSquares() { return isHighlightMadeMoveSquares; } - /** - * Sets the move highlighting style. - */ + /** Sets the move highlighting style. */ public void setMoveHighlightingStyle(int newStyle) { switch (newStyle) { case NO_MOVE_HIGHLIGHTING: @@ -765,16 +633,12 @@ public void setMoveHighlightingStyle(int newStyle) { firePropertyChange("moveHighlightingStyle", oldStyle, newStyle); } - /** - * Returns the move highlighting style. - */ + /** Returns the move highlighting style. */ public int getMoveHighlightingStyle() { return moveHighlightingStyle; } - /** - * Sets the currently highlighted move, or null if no move should be highlighted. - */ + /** Sets the currently highlighted move, or null if no move should be highlighted. */ public void setHighlightedMove(Move move) { repaintHighlighting(); @@ -803,9 +667,7 @@ private void repaintHighlighting() { repaint(squareToRect(from, null).union(squareToRect(to, null))); } - /** - * Sets whether during a move a shadow piece is displayed at the target square. - */ + /** Sets whether during a move a shadow piece is displayed at the target square. */ public void setShowShadowPieceInTargetSquare(boolean newValue) { boolean oldValue = this.isShowShadowPieceInTargetSquare; this.isShowShadowPieceInTargetSquare = newValue; @@ -813,16 +675,12 @@ public void setShowShadowPieceInTargetSquare(boolean newValue) { firePropertyChange("isShowShadowPieceInTargetSquare", oldValue, newValue); } - /** - * Returns whether during a move a shadow piece is displayed at the target square. - */ + /** Returns whether during a move a shadow piece is displayed at the target square. */ public boolean isShowShadowPieceInTargetSquare() { return isShowShadowPieceInTargetSquare; } - /** - * Sets whether during a move the legal target squares are highlighted. - */ + /** Sets whether during a move the legal target squares are highlighted. */ public void setHighlightLegalTargetSquares(boolean newValue) { boolean oldValue = this.isHighlightLegalTargetSquares; this.isHighlightLegalTargetSquares = newValue; @@ -837,17 +695,15 @@ public void setHighlightLegalTargetSquares(boolean newValue) { firePropertyChange("isHighlightLegalTargetSquares", oldValue, newValue); } - /** - * Returns whether during a move the legal target squares are highlighted. - */ + /** Returns whether during a move the legal target squares are highlighted. */ public boolean isHighlightLegalTargetSquares() { return isHighlightLegalTargetSquares; } /** * Sets the color with which legal target squares are highlighted. This should normally be a - * translucent color, so that for captures, the captured piece is visible. Passing - * null causes the color to be reset to the default one. + * translucent color, so that for captures, the captured piece is visible. Passing null + * causes the color to be reset to the default one. */ public void setLegalTargetSquaresHighlightColor(Color color) { if (color == null) color = DEFAULT_POSSIBLE_TARGET_SQUARES_HIGHLIGHT_COLOR; @@ -860,16 +716,12 @@ public void setLegalTargetSquaresHighlightColor(Color color) { firePropertyChange("legalTargetSquaresHighlightColor", oldColor, color); } - /** - * Returns the color with which legal target squares are highlighted. - */ + /** Returns the color with which legal target squares are highlighted. */ public Color getLegalTargetSquaresHighlightColor() { return legalTargetSquaresHighlightColor; } - /** - * Sets whether the target square snaps to the nearest legal square when making a move. - */ + /** Sets whether the target square snaps to the nearest legal square when making a move. */ public void setSnapToLegalSquare(boolean newValue) { boolean oldValue = this.isSnapToLegalSquare; this.isSnapToLegalSquare = newValue; @@ -877,9 +729,7 @@ public void setSnapToLegalSquare(boolean newValue) { firePropertyChange("isSnapToLegalSquare", oldValue, newValue); } - /** - * Returns whether the target square snaps to the nearest legal square when making a move. - */ + /** Returns whether the target square snaps to the nearest legal square when making a move. */ public boolean isSnapToLegalSquare() { return isSnapToLegalSquare; } @@ -905,9 +755,7 @@ public void setCoordsDisplayStyle(int newStyle) { firePropertyChange("coordsDisplayStyle", oldStyle, newStyle); } - /** - * Returns the current coordinates display style. - */ + /** Returns the current coordinates display style. */ public int getCoordsDisplayStyle() { return coordsDisplayStyle; } @@ -923,9 +771,7 @@ public void setFlipped(boolean isFlipped) { firePropertyChange("flipped", oldFlipped, isFlipped); } - /** - * Returns true if the JBoard is flipped, false otherwise. - */ + /** Returns true if the JBoard is flipped, false otherwise. */ public boolean isFlipped() { return isFlipped; } @@ -948,16 +794,12 @@ public boolean isManualPromote() { return isManualPromote; } - /** - * Returns the BoardPainter of this JBoard. - */ + /** Returns the BoardPainter of this JBoard. */ public BoardPainter getBoardPainter() { return boardPainter; } - /** - * Returns the PiecePainter of this JBoard. - */ + /** Returns the PiecePainter of this JBoard. */ public PiecePainter getPiecePainter() { return piecePainter; } @@ -1002,9 +844,7 @@ public void setMoveHighlightingColor(Color moveHighlightingColor) { firePropertyChange("moveHighlightingColor", oldColor, moveHighlightingColor); } - /** - * Returns the color used for move highlighting. - */ + /** Returns the color used for move highlighting. */ public Color getMoveHighlightingColor() { return moveHighlightingColor; } @@ -1022,17 +862,15 @@ public void setCoordsDisplayColor(Color coordsDisplayColor) { firePropertyChange("coordsDisplayColor", oldColor, coordsDisplayColor); } - /** - * Returns the color used for coordinate display. - */ + /** Returns the color used for coordinate display. */ public Color getCoordsDisplayColor() { return coordsDisplayColor; } /** * Sets the color used for highlighting the squares of the move being made. This refers to the - * highlighting specified by the highlightMadeMoveSquares property. Passing - * null is equivalent to setting it to the default color. + * highlighting specified by the highlightMadeMoveSquares property. Passing + * null is equivalent to setting it to the default color. */ public void setMadeMoveSquaresHighlightColor(Color newColor) { if (newColor == null) newColor = DEFAULT_MADE_MOVE_SQUARES_HIGHLIGHT_COLOR; @@ -1043,9 +881,7 @@ public void setMadeMoveSquaresHighlightColor(Color newColor) { firePropertyChange("madeMoveSquaresHighlightColor", oldColor, newColor); } - /** - * Returns the color used for highlighting the squares of the move being made. - */ + /** Returns the color used for highlighting the squares of the move being made. */ public Color getMadeMoveSquaresHighlightColor() { return madeMoveSquaresHighlightColor; } @@ -1070,18 +906,14 @@ public void setSlideDuration(int slideDuration) { firePropertyChange("slideDuration", oldValue, slideDuration); } - /** - * Sets the shaded state of the specified square. - */ + /** Sets the shaded state of the specified square. */ public void setShaded(Square square, boolean isShaded) { boolean oldState = this.isShaded[square.getFile()][square.getRank()]; this.isShaded[square.getFile()][square.getRank()] = isShaded; if (oldState != isShaded) repaint(squareToRect(square, null)); } - /** - * Sets all the squares to the unshaded state. - */ + /** Sets all the squares to the unshaded state. */ public void clearShaded() { Rectangle helpRect = new Rectangle(); for (int file = 0; file < 8; file++) @@ -1092,23 +924,17 @@ public void clearShaded() { } } - /** - * Returns true iff the specified square is shaded. - */ + /** Returns true iff the specified square is shaded. */ public boolean isShaded(Square square) { return isShaded[square.getFile()][square.getRank()]; } - /** - * Returns true iff a piece is currently being moved/dragged. - */ + /** Returns true iff a piece is currently being moved/dragged. */ public boolean isMovingPiece() { return movedPieceSquare != null; } - /** - * Paints this JBoard on the given Graphics object. - */ + /** Paints this JBoard on the given Graphics object. */ @Override public void paintComponent(Graphics graphics) { super.paintComponent(graphics); @@ -1270,9 +1096,7 @@ private Rectangle slideRect(double progress, Rectangle rect) { */ private static final Font COORDS_FONT = new Font("Monospaced", Font.BOLD, 10); - /** - * Draws the coordinates. - */ + /** Draws the coordinates. */ private void drawCoords(Graphics g) { g.setColor(getCoordsDisplayColor()); @@ -1294,9 +1118,7 @@ private void drawCoords(Graphics g) { } } - /** - * Draws the coordinates for RIM_COORDS style. - */ + /** Draws the coordinates for RIM_COORDS style. */ private void drawRimCoords(Graphics g) { Rectangle boardRect = getBoardRect(null); int squareWidth = boardRect.width / 8; @@ -1328,8 +1150,10 @@ private void drawRimCoords(Graphics g) { // Column coordinates if (clipRect.intersects( new Rectangle( - boardRect.x, boardRect.y + boardRect.height - squareHeight / 2, - boardRect.width, squareHeight / 2))) { + boardRect.x, + boardRect.y + boardRect.height - squareHeight / 2, + boardRect.width, + squareHeight / 2))) { char col = isFlipped() ? 'h' : 'a'; for (int i = 0; i < 8; i++) { g.drawString( @@ -1341,9 +1165,7 @@ private void drawRimCoords(Graphics g) { } } - /** - * Draws the coordinates for OUTSIDE_COORDS style. - */ + /** Draws the coordinates for OUTSIDE_COORDS style. */ private void drawOutsideCoords(Graphics g) { Insets insets = getInsets(); Rectangle boardRect = getBoardRect(null); @@ -1394,9 +1216,7 @@ private void drawOutsideCoords(Graphics g) { } } - /** - * Draws the coordinates for EVERY_SQUARE_COORDS style. - */ + /** Draws the coordinates for EVERY_SQUARE_COORDS style. */ private void drawEverySquareCoords(Graphics g) { Rectangle boardRect = getBoardRect(null); int squareWidth = boardRect.width / 8; @@ -1432,8 +1252,8 @@ private void drawEverySquareCoords(Graphics g) { } /** - * Draws an arrow of the given size between the two specified squares on the given - * Graphics object using the specified color. + * Draws an arrow of the given size between the two specified squares on the given Graphics + * object using the specified color. */ protected void drawArrow( Graphics graphics, Square from, Square to, float arrowSize, Color color) { @@ -1487,9 +1307,8 @@ protected void drawArrow( } /** - * Draws an outline of a square of the given size at the specified square on the given - * Graphics object with the specific color. The size specifies the width of the - * outline. + * Draws an outline of a square of the given size at the specified square on the given + * Graphics object with the specific color. The size specifies the width of the outline. */ protected void drawSquare(Graphics graphics, Square circleSquare, int size, Color color) { Graphics2D g = (Graphics2D) graphics; @@ -1524,9 +1343,7 @@ protected void drawSquare(Graphics graphics, Square circleSquare, int size, Colo g.translate(-rect.x, -rect.y); } - /** - * Calls all the registered PaintHooks. - */ + /** Calls all the registered PaintHooks. */ private void callPaintHooks(Graphics g) { int size = paintHooks == null ? 0 : paintHooks.size(); for (int i = 0; i < size; i++) { @@ -1564,16 +1381,12 @@ public Rectangle getBoardRect(Rectangle rect) { return rect; } - /** - * Returns the rectangle (in pixels) of the given square. - */ + /** Returns the rectangle (in pixels) of the given square. */ public Rectangle squareToRect(Square square, Rectangle squareRect) { return squareToRect(square.getFile(), square.getRank(), squareRect); } - /** - * Returns the rectangle (in pixels) of the given square. - */ + /** Returns the rectangle (in pixels) of the given square. */ public Rectangle squareToRect(int file, int rank, Rectangle squareRect) { squareRect = getBoardRect(squareRect); @@ -1593,9 +1406,9 @@ public Rectangle squareToRect(int file, int rank, Rectangle squareRect) { /** * Calculates a rectangle (in pixels) which completely contains the graphic of the piece currently - * being moved, if we are in pieceFollowsCursor mode. Throws an - * IllegalStateException if we are not in in pieceFollowsCursor mode or - * if a piece is not currently being moved. + * being moved, if we are in pieceFollowsCursor mode. Throws an + * IllegalStateException if we are not in in pieceFollowsCursor mode or if a + * piece is not currently being moved. */ private Rectangle getMovedPieceGraphicRect(Rectangle rect) { if (!isPieceFollowsCursor()) throw new IllegalStateException("Not in pieceFollowsCursor mode"); @@ -1613,9 +1426,7 @@ private Rectangle getMovedPieceGraphicRect(Rectangle rect) { return rect; } - /** - * Calculates the target square during a move based on the specified cursor location. - */ + /** Calculates the target square during a move based on the specified cursor location. */ private Square calcTargetSquare(Point cursorLocation) { if (isSnapToLegalSquare && (legalTargetSquares != null)) { // Check the usual case - square under the cursor @@ -1698,24 +1509,18 @@ public Square locationToSquare(int x, int y) { else return Square.getInstance(file, rank); } - /** - * Returns the square corresponding to the given coordinate (in pixels). - */ + /** Returns the square corresponding to the given coordinate (in pixels). */ public Square locationToSquare(Point p) { return locationToSquare(p.x, p.y); } - /** - * Makes sure no events are dispatched to this JBoard while its showing a modal dialog. - */ + /** Makes sure no events are dispatched to this JBoard while its showing a modal dialog. */ @Override protected void processEvent(AWTEvent evt) { if (!isShowingModalDialog) super.processEvent(evt); } - /** - * Returns whether the given piece can be moved, considering the current move mode. - */ + /** Returns whether the given piece can be moved, considering the current move mode. */ private boolean canBeMoved(Piece piece) { switch (getMoveInputMode()) { case NO_PIECES_MOVE: @@ -1744,9 +1549,7 @@ private boolean isGesture(int style) { || (moveInputStyle == style); } - /** - * Causes the possible target squares to be repainted. - */ + /** Causes the possible target squares to be repainted. */ private void repaintLegalTargetSquares(Rectangle helpRect) { for (Iterator i = legalTargetSquares.iterator(); i.hasNext(); ) repaint(helpRect = squareToRect((Square) i.next(), helpRect)); @@ -1774,9 +1577,7 @@ public void cancelMovingPiece() { fireMoveProgressEvent(new MoveProgressEvent(this, MoveProgressEvent.MOVE_MAKING_ENDED)); } - /** - * Processes a mouse event. - */ + /** Processes a mouse event. */ @Override protected void processMouseEvent(MouseEvent evt) { super.processMouseEvent(evt); @@ -1898,9 +1699,7 @@ protected void processMouseEvent(MouseEvent evt) { } } - /** - * Processes a mouse motion event. - */ + /** Processes a mouse motion event. */ @Override protected void processMouseMotionEvent(MouseEvent evt) { super.processMouseMotionEvent(evt); @@ -1937,9 +1736,7 @@ protected void processMouseMotionEvent(MouseEvent evt) { } } - /** - * Displays a simple JFrame with a JBoard. - */ + /** Displays a simple JFrame with a JBoard. */ public static void main(String[] args) { javax.swing.JFrame frame = new javax.swing.JFrame("JBoard Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); diff --git a/src/main/java/free/chess/JChessClock.java b/src/main/java/free/chess/JChessClock.java index 49e92b4a..f889f2ee 100644 --- a/src/main/java/free/chess/JChessClock.java +++ b/src/main/java/free/chess/JChessClock.java @@ -2,20 +2,22 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2007 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; +import free.util.GraphicsUtilities; +import free.util.TextUtilities; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -28,17 +30,10 @@ import java.io.IOException; import java.io.InputStream; -import free.util.GraphicsUtilities; -import free.util.TextUtilities; - -/** - * A Component for displaying a simple, text based chess clock. - */ +/** A Component for displaying a simple, text based chess clock. */ public class JChessClock extends AbstractChessClock { - /** - * The special clock font we use (if it exists). - */ + /** The special clock font we use (if it exists). */ private static final Font CLOCK_FONT; static { @@ -55,29 +50,19 @@ public class JChessClock extends AbstractChessClock { CLOCK_FONT = font; } - /** - * The active background color. - */ + /** The active background color. */ private Color activeBG = new Color(30, 100, 230); - /** - * The active foreground color. - */ + /** The active foreground color. */ private Color activeFG = Color.white; - /** - * The inactive background color. Defaults to the parent's background. - */ + /** The inactive background color. Defaults to the parent's background. */ private Color inactiveBG = null; - /** - * The inactive foreground color. - */ + /** The inactive foreground color. */ private Color inactiveFG = Color.black; - /** - * Creates a new JChessClock with the given initial amount of time (in milliseconds) on it. - */ + /** Creates a new JChessClock with the given initial amount of time (in milliseconds) on it. */ public JChessClock(int time) { super(time); @@ -85,78 +70,58 @@ public JChessClock(int time) { else setFont(CLOCK_FONT.deriveFont(48f)); } - /** - * Sets the background color of this JChessClock when it's active. - */ + /** Sets the background color of this JChessClock when it's active. */ public void setActiveBackground(Color color) { activeBG = color; repaint(); } - /** - * Returns the background color of this JChessClock when it's active. - */ + /** Returns the background color of this JChessClock when it's active. */ public Color getActiveBackground() { return activeBG; } - /** - * Sets the foreground color of this JChessClock when it's active. - */ + /** Sets the foreground color of this JChessClock when it's active. */ public void setActiveForeground(Color color) { activeFG = color; repaint(); } - /** - * Returns the foreground color of this JChessClock when it's active. - */ + /** Returns the foreground color of this JChessClock when it's active. */ public Color getActiveForeground() { return activeFG; } - /** - * Sets the background color of this JChessClock when it's inactive. - */ + /** Sets the background color of this JChessClock when it's inactive. */ public void setInactiveBackground(Color color) { inactiveBG = color; repaint(); } - /** - * Returns the background color of this JChessClock when it's inactive. - */ + /** Returns the background color of this JChessClock when it's inactive. */ public Color getInactiveBackground() { return inactiveBG; } - /** - * Sets the foreground color of this JChessClock when it's inactive. - */ + /** Sets the foreground color of this JChessClock when it's inactive. */ public void setInactiveForeground(Color color) { inactiveFG = color; repaint(); } - /** - * Returns the foreground color of this JChessClock when it's inactive. - */ + /** Returns the foreground color of this JChessClock when it's inactive. */ public Color getInactiveForeground() { return inactiveFG; } - /** - * Sets whether the owner of this JChessClock is also the owner of the current turn. - */ + /** Sets whether the owner of this JChessClock is also the owner of the current turn. */ @Override public void setActive(boolean isActive) { super.setActive(isActive); repaint(); } - /** - * Returns the string that should be drawn for the given time, in milliseconds. - */ + /** Returns the string that should be drawn for the given time, in milliseconds. */ protected String createTimeString(int time) { boolean isNegative = time < 0; @@ -196,9 +161,7 @@ protected String createTimeString(int time) { } } - /** - * Overrides JComponent.paintComponent(Graphics) to paint this JChessClock. - */ + /** Overrides JComponent.paintComponent(Graphics) to paint this JChessClock. */ @Override public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; @@ -242,9 +205,7 @@ public int getPreferredWidth(int height) { return fm.stringWidth(text); } - /** - * Returns the preferred size of this JChessClock. - */ + /** Returns the preferred size of this JChessClock. */ @Override public Dimension getPreferredSize() { String text = createTimeString(getTime()); @@ -256,9 +217,7 @@ public Dimension getPreferredSize() { return new Dimension(fontWidth, fontHeight); } - /** - * Returns the minimum size of this JChessClock. - */ + /** Returns the minimum size of this JChessClock. */ @Override public Dimension getMinimumSize() { String text = createTimeString(getTime()); diff --git a/src/main/java/free/chess/LocalizationService.java b/src/main/java/free/chess/LocalizationService.java index ccad3ba6..0d852f4a 100644 --- a/src/main/java/free/chess/LocalizationService.java +++ b/src/main/java/free/chess/LocalizationService.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2007 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -18,19 +18,13 @@ import free.util.Localization; -/** - * Provides localization services to the free.chess package. - */ +/** Provides localization services to the free.chess package. */ class LocalizationService { - /** - * The template Localization for the entire package. - */ + /** The template Localization for the entire package. */ private static Localization templateLocalization = null; - /** - * Returns the free.util.Localization localization for the specified class. - */ + /** Returns the free.util.Localization localization for the specified class. */ public static synchronized Localization getForClass(Class c) { // Lazily initialize if (templateLocalization == null) diff --git a/src/main/java/free/chess/Move.java b/src/main/java/free/chess/Move.java index 27c24c93..b6053b55 100644 --- a/src/main/java/free/chess/Move.java +++ b/src/main/java/free/chess/Move.java @@ -2,55 +2,45 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; -/** - * This is the superclass of move implementations for various wild chess variants. - */ +/** This is the superclass of move implementations for various wild chess variants. */ public abstract class Move { - /** - * The square on which the moving piece was standing before the move. - */ + /** The square on which the moving piece was standing before the move. */ protected final Square startingSquare; - /** - * The square to which the moving piece moved. - */ + /** The square to which the moving piece moved. */ protected final Square endingSquare; - /** - * The player making the move. - */ + /** The player making the move. */ protected final Player player; - /** - * The string representation of this move. This may be null. - */ + /** The string representation of this move. This may be null. */ private final String stringRepresentation; /** * Creates a new Move from the given starting Square to the given ending Square, with the given * moving Player. - *

- * Both the starting and ending squares may be null, as they sometimes are, for example in + * + *

Both the starting and ending squares may be null, as they sometimes are, for example in * Kriegspiel. - *

- * The given stringRepresentation will be the string returned from the toString() method. It may - * be null, in which case a string constructed from the move data will be returned by - * toString(). + * + *

The given stringRepresentation will be the string returned from the toString() method. It + * may be null, in which case a string constructed from the move data will be + * returned by toString(). */ public Move( Square startingSquare, Square endingSquare, Player player, String stringRepresentation) { @@ -63,37 +53,27 @@ public Move( this.stringRepresentation = stringRepresentation; } - /** - * Returns the initial square of the moving piece or null if unknown. - */ + /** Returns the initial square of the moving piece or null if unknown. */ public Square getStartingSquare() { return startingSquare; } - /** - * Returns the square to which the moving piece moved or null if unknown - */ + /** Returns the square to which the moving piece moved or null if unknown */ public Square getEndingSquare() { return endingSquare; } - /** - * Returns the Player making the move. - */ + /** Returns the Player making the move. */ public Player getPlayer() { return player; } - /** - * Returns the string representation of the move passed in the constructor. This may be null. - */ + /** Returns the string representation of the move passed in the constructor. This may be null. */ public final String getStringRepresentation() { return stringRepresentation; } - /** - * Returns a string representation of the move based on the move data. - */ + /** Returns a string representation of the move based on the move data. */ public String getMoveString() { Square startingSquare = getStartingSquare(); Square endingSquare = getEndingSquare(); @@ -134,8 +114,8 @@ else if (lastChar == 'C') // Long castling } /** - * Returns the string representation of this Move. If the value returned by - * {@link #getStringRepresentation()} is not null, that is returned. Otherwise the value of + * Returns the string representation of this Move. If the value returned by {@link + * #getStringRepresentation()} is not null, that is returned. Otherwise the value of * getMoveString() is returned. */ @Override diff --git a/src/main/java/free/chess/MoveFormatException.java b/src/main/java/free/chess/MoveFormatException.java index 26669340..079801b5 100644 --- a/src/main/java/free/chess/MoveFormatException.java +++ b/src/main/java/free/chess/MoveFormatException.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -18,35 +18,25 @@ import free.util.FormatException; -/** - * Thrown when the format of a chess move is wrong. - */ +/** Thrown when the format of a chess move is wrong. */ public class MoveFormatException extends FormatException { - /** - * Creates a new MoveFormatException for the given real Throwable and the given message. - */ + /** Creates a new MoveFormatException for the given real Throwable and the given message. */ public MoveFormatException(Throwable realException, String message) { super(realException, message); } - /** - * Creates a new MoveFormatException for the given real Throwable. - */ + /** Creates a new MoveFormatException for the given real Throwable. */ public MoveFormatException(Throwable realException) { super(realException); } - /** - * Creates a new MoveFormatException with the given message. - */ + /** Creates a new MoveFormatException with the given message. */ public MoveFormatException(String message) { super(message); } - /** - * Creates a new MoveFormatException. - */ + /** Creates a new MoveFormatException. */ public MoveFormatException() { super(); } diff --git a/src/main/java/free/chess/OddsTimeControl.java b/src/main/java/free/chess/OddsTimeControl.java index 25ed49ad..8a404671 100644 --- a/src/main/java/free/chess/OddsTimeControl.java +++ b/src/main/java/free/chess/OddsTimeControl.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2007 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -18,19 +18,13 @@ import free.util.Localization; -/** - * A TimeControl when the time control for white and black differ. - */ +/** A TimeControl when the time control for white and black differ. */ public class OddsTimeControl extends TimeControl { - /** - * The white's time control. - */ + /** The white's time control. */ private final TimeControl whiteTimeControl; - /** - * The black's time control. - */ + /** The black's time control. */ private final TimeControl blackTimeControl; /** @@ -46,38 +40,28 @@ public OddsTimeControl(TimeControl whiteTimeControl, TimeControl blackTimeContro this.blackTimeControl = blackTimeControl; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public int getInitialTime(Player player) { return (player.isWhite() ? whiteTimeControl : blackTimeControl).getInitialTime(player); } - /** - * Returns white's time control. - */ + /** Returns white's time control. */ public TimeControl getWhiteTimeControl() { return whiteTimeControl; } - /** - * Returns black's time control. - */ + /** Returns black's time control. */ public TimeControl getBlackTimeControl() { return blackTimeControl; } - /** - * Returns whether the two time controls really differ. - */ + /** Returns whether the two time controls really differ. */ public boolean isOdds() { return !whiteTimeControl.equals(blackTimeControl); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public String getLocalizedShortDescription() { return getDescription( @@ -86,9 +70,7 @@ public String getLocalizedShortDescription() { blackTimeControl.getLocalizedShortDescription()); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public String getLocalizedMediumDescription() { return getDescription( @@ -97,9 +79,7 @@ public String getLocalizedMediumDescription() { blackTimeControl.getLocalizedMediumDescription()); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public String getLocalizedLongDescription() { return getDescription( @@ -108,9 +88,7 @@ public String getLocalizedLongDescription() { blackTimeControl.getLocalizedLongDescription()); } - /** - * Returns a description of the time control obtained using the specified localization key. - */ + /** Returns a description of the time control obtained using the specified localization key. */ private String getDescription(String key, String whiteDescription, String blackDescription) { Localization l10n = LocalizationService.getForClass(OddsTimeControl.class); Object[] args = new Object[] {whiteDescription, blackDescription}; @@ -118,9 +96,7 @@ private String getDescription(String key, String whiteDescription, String blackD return l10n.getFormattedString(key, args); } - /** - * Returns whether the specified object equals to this one. - */ + /** Returns whether the specified object equals to this one. */ @Override public boolean equals(Object o) { if (!(o instanceof OddsTimeControl) || (o == null)) return false; @@ -130,9 +106,7 @@ public boolean equals(Object o) { && tc.blackTimeControl.equals(blackTimeControl); } - /** - * Returns the hash code for this object. - */ + /** Returns the hash code for this object. */ @Override public int hashCode() { return whiteTimeControl.hashCode() ^ blackTimeControl.hashCode(); diff --git a/src/main/java/free/chess/Piece.java b/src/main/java/free/chess/Piece.java index ca39153a..0e75e126 100644 --- a/src/main/java/free/chess/Piece.java +++ b/src/main/java/free/chess/Piece.java @@ -2,33 +2,27 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; -/** - * The superclass of all classes representing pieces in wild chess variants. - */ +/** The superclass of all classes representing pieces in wild chess variants. */ public abstract class Piece { - /** - * A constant representing a white piece. - */ + /** A constant representing a white piece. */ public static final int WHITE = 1; - /** - * A constant representing a black piece. - */ + /** A constant representing a black piece. */ public static final int BLACK = -1; /** @@ -57,45 +51,33 @@ protected Piece(int color, int type) { this.val = color * type; } - /** - * Returns true if the given Piece has opposite color from this piece. - */ + /** Returns true if the given Piece has opposite color from this piece. */ public boolean isOppositeColor(Piece piece) { return this.getColor() != piece.getColor(); } - /** - * Returns trie of the given Piece has the same color as this Piece. - */ + /** Returns trie of the given Piece has the same color as this Piece. */ public boolean isSameColor(Piece piece) { return this.getColor() == piece.getColor(); } - /** - * Returns the Player this piece belongs to. - */ + /** Returns the Player this piece belongs to. */ public Player getPlayer() { if (isWhite()) return Player.WHITE_PLAYER; else return Player.BLACK_PLAYER; } - /** - * Returns the color of this Piece, either {@link #BLACK} or {@link #WHITE}. - */ + /** Returns the color of this Piece, either {@link #BLACK} or {@link #WHITE}. */ public int getColor() { return val < 0 ? BLACK : WHITE; } - /** - * Returns true if this Piece is white, returns false otherwise. - */ + /** Returns true if this Piece is white, returns false otherwise. */ public boolean isWhite() { return (val > 0); } - /** - * Returns true if this Piece is black, returns false otherwise. - */ + /** Returns true if this Piece is black, returns false otherwise. */ public boolean isBlack() { return (val < 0); } @@ -129,22 +111,16 @@ public String getColorName() { throw new Error("This may never happen"); } - /** - * Returns a string representing the type of this piece ("Knight" for a knight for example). - */ + /** Returns a string representing the type of this piece ("Knight" for a knight for example). */ public abstract String getTypeName(); - /** - * Returns a string representation of this chess piece. Returns "Empty" for the empty piece. - */ + /** Returns a string representation of this chess piece. Returns "Empty" for the empty piece. */ @Override public String toString() { return getColorName() + ' ' + getTypeName(); } - /** - * Returns the hashcode of this Piece. - */ + /** Returns the hashcode of this Piece. */ @Override public int hashCode() { return val; diff --git a/src/main/java/free/chess/PieceChooser.java b/src/main/java/free/chess/PieceChooser.java index e5219088..25a0badd 100644 --- a/src/main/java/free/chess/PieceChooser.java +++ b/src/main/java/free/chess/PieceChooser.java @@ -2,20 +2,21 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2004 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; +import free.util.AWTUtilities; import java.awt.BorderLayout; import java.awt.Component; import java.awt.GridLayout; @@ -24,7 +25,6 @@ import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.util.Hashtable; - import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JDialog; @@ -33,31 +33,19 @@ import javax.swing.KeyStroke; import javax.swing.SwingConstants; -import free.util.AWTUtilities; - -/** - * A dialog which lets the user choose a Piece from the given set of pieces. - */ +/** A dialog which lets the user choose a Piece from the given set of pieces. */ public class PieceChooser extends JComponent implements ActionListener { - /** - * Maps JButtons to Pieces. - */ + /** Maps JButtons to Pieces. */ private final Hashtable buttonsToPieces = new Hashtable(); - /** - * Maps pieces to buttons. - */ + /** Maps pieces to buttons. */ private final Hashtable piecesToButtons = new Hashtable(); - /** - * The selected piece. - */ + /** The selected piece. */ private Piece chosenPiece = null; - /** - * Creates a new PieceChooser with the given array of Pieces and the given PiecePainter. - */ + /** Creates a new PieceChooser with the given array of Pieces and the given PiecePainter. */ public PieceChooser(Piece[] pieces, PiecePainter piecePainter) { int gridSize = (int) Math.round(Math.ceil(Math.sqrt(pieces.length))); setLayout(new GridLayout(gridSize, gridSize, 10, 10)); @@ -74,16 +62,12 @@ public PieceChooser(Piece[] pieces, PiecePainter piecePainter) { } } - /** - * Returns the selected Piece. - */ + /** Returns the selected Piece. */ public Piece getSelectedPiece() { return chosenPiece; } - /** - * Returns the button corresponding to the specified piece. - */ + /** Returns the button corresponding to the specified piece. */ public JButton buttonForPiece(Piece piece) { return (JButton) piecesToButtons.get(piece); } @@ -150,9 +134,7 @@ public void actionPerformed(ActionEvent evt) { return selectedPiece; } - /** - * Handles ActionEvents from the piece buttons. - */ + /** Handles ActionEvents from the piece buttons. */ @Override public void actionPerformed(ActionEvent evt) { chosenPiece = (Piece) buttonsToPieces.get(evt.getSource()); @@ -166,16 +148,12 @@ public void addActionListener(ActionListener listener) { listenerList.add(ActionListener.class, listener); } - /** - * Removes an ActionListener from this PieceChooser. - */ + /** Removes an ActionListener from this PieceChooser. */ public void removeActionListener(ActionListener listener) { listenerList.remove(ActionListener.class, listener); } - /** - * Fires an ActionEvent. - */ + /** Fires an ActionEvent. */ protected void fireActionPerformed(ActionEvent evt) { Object[] listeners = listenerList.getListenerList(); ActionEvent e = diff --git a/src/main/java/free/chess/PieceIcon.java b/src/main/java/free/chess/PieceIcon.java index 4c08803d..94ef3559 100644 --- a/src/main/java/free/chess/PieceIcon.java +++ b/src/main/java/free/chess/PieceIcon.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -19,34 +19,23 @@ import java.awt.Component; import java.awt.Graphics; import java.awt.Rectangle; - import javax.swing.Icon; public class PieceIcon implements Icon { - /** - * The Piece. - */ + /** The Piece. */ private final Piece piece; - /** - * The PiecePainter. - */ + /** The PiecePainter. */ private final PiecePainter piecePainter; - /** - * The width of the icon. - */ + /** The width of the icon. */ private final int width; - /** - * The height of the icon. - */ + /** The height of the icon. */ private final int height; - /** - * Creates a new PieceIcon with the given Piece, PiecePainter, width and height. - */ + /** Creates a new PieceIcon with the given Piece, PiecePainter, width and height. */ public PieceIcon(Piece piece, PiecePainter piecePainter, int width, int height) { this.piece = piece; this.piecePainter = piecePainter; @@ -54,25 +43,19 @@ public PieceIcon(Piece piece, PiecePainter piecePainter, int width, int height) this.height = height; } - /** - * Returns the width of the icon. - */ + /** Returns the width of the icon. */ @Override public int getIconWidth() { return width; } - /** - * Returns the height of the icon. - */ + /** Returns the height of the icon. */ @Override public int getIconHeight() { return height; } - /** - * Paints the icon on the given Graphics, at the given location. - */ + /** Paints the icon on the given Graphics, at the given location. */ @Override public void paintIcon(Component component, Graphics g, int x, int y) { piecePainter.paintPiece(piece, g, component, new Rectangle(x, y, width, height), false); diff --git a/src/main/java/free/chess/PiecePainter.java b/src/main/java/free/chess/PiecePainter.java index 032a7406..26b67592 100644 --- a/src/main/java/free/chess/PiecePainter.java +++ b/src/main/java/free/chess/PiecePainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -20,16 +20,13 @@ import java.awt.Graphics; import java.awt.Rectangle; -/** - * An interface for classes that paint the pieces (normally on a JBoard). - */ +/** An interface for classes that paint the pieces (normally on a JBoard). */ public interface PiecePainter { /** * Paints the given piece at the given coordinates on the given Graphics object - * scaled to the given size. The component argument may be null. The - * shaded argument specifies whether the piece should be drawn in a special, shaded - * manner. + * scaled to the given size. The component argument may be null. The shaded + * argument specifies whether the piece should be drawn in a special, shaded manner. */ void paintPiece(Piece piece, Graphics g, Component component, Rectangle rect, boolean shaded); diff --git a/src/main/java/free/chess/PlainBoardPainter.java b/src/main/java/free/chess/PlainBoardPainter.java index 42dc06b1..b1eec150 100644 --- a/src/main/java/free/chess/PlainBoardPainter.java +++ b/src/main/java/free/chess/PlainBoardPainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -20,9 +20,7 @@ import java.awt.Component; import java.awt.Graphics; -/** - * An implementation of BoardPainter which fills the squares with a solid color. - */ +/** An implementation of BoardPainter which fills the squares with a solid color. */ public final class PlainBoardPainter extends AbstractColoredBoardPainter { /** @@ -41,17 +39,13 @@ public PlainBoardPainter() { this(new Color(255, 207, 144), new Color(143, 96, 79)); } - /** - * Returns a new PlainBoardPainter. - */ + /** Returns a new PlainBoardPainter. */ @Override public BoardPainter freshInstance() { return new PlainBoardPainter(); } - /** - * Paints the board at the given location on the given Graphics scaled to the given size. - */ + /** Paints the board at the given location on the given Graphics scaled to the given size. */ @Override public void paintBoard(Graphics g, Component component, int x, int y, int width, int height) { int squareWidth = width / 8; diff --git a/src/main/java/free/chess/Player.java b/src/main/java/free/chess/Player.java index f0dd1c85..453f6a31 100644 --- a/src/main/java/free/chess/Player.java +++ b/src/main/java/free/chess/Player.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -22,46 +22,34 @@ */ public class Player { - /** - * A constant for the white player. - */ + /** A constant for the white player. */ public static final Player WHITE_PLAYER = new Player(); - /** - * A constant for the black player. - */ + /** A constant for the black player. */ public static final Player BLACK_PLAYER = new Player(); - /** - * Do not allow others to instantiate this class. - */ + /** Do not allow others to instantiate this class. */ private Player() {} /** - * Returns the color of the pieces this player plays with - either {@link Piece#WHITE} or - * {@link Piece#BLACK}. + * Returns the color of the pieces this player plays with - either {@link Piece#WHITE} or {@link + * Piece#BLACK}. */ public int getPieceColor() { return isWhite() ? Piece.WHITE : Piece.BLACK; } - /** - * Returns whether this player is the player with the white pieces. - */ + /** Returns whether this player is the player with the white pieces. */ public boolean isWhite() { return (this == WHITE_PLAYER); } - /** - * Returns whether this player is the player with the black pieces. - */ + /** Returns whether this player is the player with the black pieces. */ public boolean isBlack() { return (this == BLACK_PLAYER); } - /** - * Returns the opponent of this player. - */ + /** Returns the opponent of this player. */ public Player getOpponent() { if (this.isWhite()) return BLACK_PLAYER; else return WHITE_PLAYER; diff --git a/src/main/java/free/chess/Position.java b/src/main/java/free/chess/Position.java index 6e773c01..6cfe2b9f 100644 --- a/src/main/java/free/chess/Position.java +++ b/src/main/java/free/chess/Position.java @@ -2,31 +2,29 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; +import free.chess.event.MoveEvent; +import free.chess.event.MoveListener; +import free.util.Utilities; import java.util.Collection; import java.util.StringTokenizer; - import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; -import free.chess.event.MoveEvent; -import free.chess.event.MoveListener; -import free.util.Utilities; - /** * Represents a position in one of the chess wild variants. The Position class itself is generally * variant independent, but it does make some assumptions, such as the board being a 8x8 container @@ -35,29 +33,19 @@ */ public final class Position { - /** - * The WildVariant of this Position. - */ + /** The WildVariant of this Position. */ private final WildVariant variant; - /** - * A matrix to keep references to the pieces. - */ + /** A matrix to keep references to the pieces. */ private final Piece[][] pieces = new Piece[8][8]; - /** - * The Modifier of this Position. - */ + /** The Modifier of this Position. */ private final Modifier modifier; - /** - * The Player whose turn it currently is in this Position. - */ + /** The Player whose turn it currently is in this Position. */ private Player currentPlayer; - /** - * A FEN representation of the position. - */ + /** A FEN representation of the position. */ private String positionFEN; /** @@ -66,9 +54,7 @@ public final class Position { */ protected transient ChangeEvent changeEvent = null; - /** - * The listeners waiting for model changes. - */ + /** The listeners waiting for model changes. */ protected EventListenerList listenerList = new EventListenerList(); /** @@ -80,27 +66,21 @@ public Position() { this(Chess.getInstance()); } - /** - * Creates a new Position with the given WildVariant. - */ + /** Creates a new Position with the given WildVariant. */ public Position(WildVariant variant) { this.variant = variant; this.modifier = new Modifier(this); init(); } - /** - * Creates a new Position which is exactly like the given Position. - */ + /** Creates a new Position which is exactly like the given Position. */ public Position(Position source) { this.variant = source.variant; this.modifier = new Modifier(this); copyFrom(source); } - /** - * Returns the WildVariant of this Position. - */ + /** Returns the WildVariant of this Position. */ public WildVariant getVariant() { return variant; } @@ -114,16 +94,14 @@ public Piece getPieceAt(Square square) { return getPieceAt(square.getFile(), square.getRank()); } - /** - * Returns the piece at the square with the given file and rank. - */ + /** Returns the piece at the square with the given file and rank. */ public Piece getPieceAt(int file, int rank) { return pieces[file][rank]; } /** - * Returns the piece at the square specified by the given string, as if by - * {@link Square#parseSquare(String)}. + * Returns the piece at the square specified by the given string, as if by {@link + * Square#parseSquare(String)}. */ public Piece getPieceAt(String square) { return getPieceAt(Square.parseSquare(square)); @@ -150,9 +128,7 @@ public void setPieceAt(Piece piece, String square) { setPieceAt(piece, Square.parseSquare(square)); } - /** - * Returns the player whose turn it is in this position, the "current" player. - */ + /** Returns the player whose turn it is in this position, the "current" player. */ public Player getCurrentPlayer() { return currentPlayer; } @@ -174,7 +150,6 @@ public void setCurrentPlayer(Player player) { * white pieces. * * @param pos The string representing the position. - * * @throws PositionFormatException if the given string is not in the expected format. */ public void setLexigraphic(String pos) throws PositionFormatException { @@ -278,9 +253,7 @@ public String getFEN() { return positionFEN; } - /** - * Sets this Position to the initial position. - */ + /** Sets this Position to the initial position. */ public final void init() { variant.init(this); } @@ -302,9 +275,8 @@ public void clear() { * ChangeEvent. * * @param move The move to make. - * * @throws IllegalArgumentException if the given Move is incompatible with the wild variant of - * this Position. + * this Position. */ public void makeMove(Move move) { variant.makeMove(move, this, modifier); @@ -343,7 +315,6 @@ public void copyFrom(Position position) { * * @param piece The piece to put. * @param square The square where to put the piece. - * * @see #setPieceAt(Piece, Square); */ private void setPieceAtImpl(Piece piece, Square square) { @@ -383,9 +354,7 @@ public void removeChangeListener(ChangeListener l) { listenerList.remove(ChangeListener.class, l); } - /** - * Run each ChangeListeners stateChanged() method. - */ + /** Run each ChangeListeners stateChanged() method. */ protected void fireStateChanged() { Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { @@ -444,18 +413,14 @@ public Collection getTargetSquares(Square square) { return variant.getTargetSquares(this, square); } - /** - * Returns a textual representation of the board. - */ + /** Returns a textual representation of the board. */ @Override public String toString() { if (getCurrentPlayer().isWhite()) return "White to move in " + getLexigraphic(); else return "Black to move in " + getLexigraphic(); } - /** - * Returns true iff the specified Position is the same as this one. - */ + /** Returns true iff the specified Position is the same as this one. */ public boolean equals(Position pos) { if (!variant.equals(pos.variant)) return false; @@ -479,9 +444,7 @@ public boolean equals(Object obj) { return equals((Position) obj); } - /** - * Returns the hashcode of this position. - */ + /** Returns the hashcode of this position. */ @Override public int hashCode() { int result = 17; @@ -512,23 +475,17 @@ public static final class Modifier { */ private final Position position; - /** - * Creates a new PositionModifier with the given Position. - */ + /** Creates a new PositionModifier with the given Position. */ private Modifier(Position position) { this.position = position; } - /** - * Puts the given piece at the given Square. - */ + /** Puts the given piece at the given Square. */ public void setPieceAt(Piece piece, Square square) { position.setPieceAtImpl(piece, square); } - /** - * Sets the current player. - */ + /** Sets the current player. */ public void setCurrentPlayer(Player player) { position.setCurrentPlayerImpl(player); } diff --git a/src/main/java/free/chess/PositionFormatException.java b/src/main/java/free/chess/PositionFormatException.java index c353cc08..157eb4cb 100644 --- a/src/main/java/free/chess/PositionFormatException.java +++ b/src/main/java/free/chess/PositionFormatException.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -18,35 +18,25 @@ import free.util.FormatException; -/** - * Thrown when the format of a chess Position is wrong. - */ +/** Thrown when the format of a chess Position is wrong. */ public class PositionFormatException extends FormatException { - /** - * Creates a new PositionFormatException for the given real Throwable and the given message. - */ + /** Creates a new PositionFormatException for the given real Throwable and the given message. */ public PositionFormatException(Throwable realException, String message) { super(realException, message); } - /** - * Creates a new PositionFormatException for the given real Throwable. - */ + /** Creates a new PositionFormatException for the given real Throwable. */ public PositionFormatException(Throwable realException) { super(realException); } - /** - * Creates a new PositionFormatException with the given message. - */ + /** Creates a new PositionFormatException with the given message. */ public PositionFormatException(String message) { super(message); } - /** - * Creates a new PositionFormatException. - */ + /** Creates a new PositionFormatException. */ public PositionFormatException() { super(); } diff --git a/src/main/java/free/chess/ResourceBoardPainter.java b/src/main/java/free/chess/ResourceBoardPainter.java index 417a7281..c217753d 100644 --- a/src/main/java/free/chess/ResourceBoardPainter.java +++ b/src/main/java/free/chess/ResourceBoardPainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2004 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -22,8 +22,8 @@ /** * An interface for board painter which depend on additional resources and are capable of loading * them from a specified URL. An implementation is also expected to have a no-arg constructor, so - * that it can be created via Class.newInstance and initialized by invoking the - * load method. + * that it can be created via Class.newInstance and initialized by invoking the + * load method. */ public interface ResourceBoardPainter extends BoardPainter { diff --git a/src/main/java/free/chess/ResourcePiecePainter.java b/src/main/java/free/chess/ResourcePiecePainter.java index 4a460229..7dcc2bc1 100644 --- a/src/main/java/free/chess/ResourcePiecePainter.java +++ b/src/main/java/free/chess/ResourcePiecePainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2004 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -22,8 +22,8 @@ /** * An interface for piece painters which depend on additional resources and are capable of loading * them from a specified URL. An implementation is also expected to have a no-arg constructor, so - * that it can be created via Class.newInstance and initialized by invoking the - * load method. + * that it can be created via Class.newInstance and initialized by invoking the + * load method. */ public interface ResourcePiecePainter extends PiecePainter { diff --git a/src/main/java/free/chess/Square.java b/src/main/java/free/chess/Square.java index bf8e1a19..5dba18a3 100644 --- a/src/main/java/free/chess/Square.java +++ b/src/main/java/free/chess/Square.java @@ -2,38 +2,30 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; -/** - * Represents a location on the chess board. - */ +/** Represents a location on the chess board. */ public class Square { - /** - * The pool of unique immutable instances of Square. - */ + /** The pool of unique immutable instances of Square. */ private static final Square[][] POOL = new Square[8][8]; - /** - * The file of the square. - */ + /** The file of the square. */ private final int file; - /** - * The rank of the square. - */ + /** The rank of the square. */ private final int rank; /** @@ -47,9 +39,7 @@ private Square(int file, int rank) { this.rank = rank; } - /** - * Returns whether the specified file and rank constitute a valid square. - */ + /** Returns whether the specified file and rank constitute a valid square. */ public static boolean isValid(int file, int rank) { return (file >= 0) && (file < 8) && (rank >= 0) && (rank < 8); } @@ -60,7 +50,6 @@ public static boolean isValid(int file, int rank) { * * @param file The file index [0-7] * @param rank The rank index [0-7] - * * @throws IllegalArgumentException if the arguments do not constitute a valid square. */ public static Square getInstance(int file, int rank) throws IllegalArgumentException { @@ -89,9 +78,8 @@ public static synchronized Square getInstanceNonStrict(int file, int rank) { * string in the usual chess format that represents a square, for example: "e3". * * @param square The string representing the location. - * * @throws IllegalArgumentException if the given string is not in the expected format or the - * coordinates are out of the valid range. + * coordinates are out of the valid range. */ public static Square parseSquare(String square) { try { @@ -104,16 +92,12 @@ public static Square parseSquare(String square) { } } - /** - * Returns the file of this Square, a value in the range [0-7]. - */ + /** Returns the file of this Square, a value in the range [0-7]. */ public int getFile() { return file; } - /** - * Returns the rank of this Square, a value in the range [0-7]. - */ + /** Returns the rank of this Square, a value in the range [0-7]. */ public int getRank() { return rank; } @@ -146,9 +130,7 @@ public String toString() { return new String(buff); } - /** - * Returns the hashCode of this Square. - */ + /** Returns the hashCode of this Square. */ @Override public int hashCode() { return (rank << 3) | file; diff --git a/src/main/java/free/chess/SquareImagesBoardPainter.java b/src/main/java/free/chess/SquareImagesBoardPainter.java index 07404ecd..7817f750 100644 --- a/src/main/java/free/chess/SquareImagesBoardPainter.java +++ b/src/main/java/free/chess/SquareImagesBoardPainter.java @@ -2,20 +2,22 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2006 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess; +import free.util.IOUtilities; +import free.util.ImageUtilities; import java.awt.Component; import java.awt.Graphics; import java.awt.Image; @@ -28,9 +30,6 @@ import java.util.Properties; import java.util.Set; -import free.util.IOUtilities; -import free.util.ImageUtilities; - /** * A BoardPainter which paints the board with two images - one for light squares an one * for dark squares. @@ -53,9 +52,7 @@ public class SquareImagesBoardPainter implements ResourceBoardPainter { */ public static final int SLICE_MODE = 1; - /** - * A delegate board painter we use while the board image is being loaded. - */ + /** A delegate board painter we use while the board image is being loaded. */ private static final BoardPainter whileLoadingDelegate = new DefaultBoardPainter(); /** @@ -65,32 +62,26 @@ public class SquareImagesBoardPainter implements ResourceBoardPainter { private static volatile boolean asyncImageLoad = false; /** - * The light square image. When SquareImagesBoardPainter is used as a - * ResourceBoardPainter, this remains null until the image data is fully + * The light square image. When SquareImagesBoardPainter is used as a + * ResourceBoardPainter, this remains null until the image data is fully * loaded. */ private Image lightImage = null; /** - * The dark square image. When SquareImagesBoardPainter is used as a - * ResourceBoardPainter, this remains null until the image data is fully + * The dark square image. When SquareImagesBoardPainter is used as a + * ResourceBoardPainter, this remains null until the image data is fully * loaded. */ private Image darkImage = null; - /** - * The mode of image usage, either {@link #SCALE_MODE} or {@link #SLICE_MODE}. - */ + /** The mode of image usage, either {@link #SCALE_MODE} or {@link #SLICE_MODE}. */ private int mode; - /** - * A version of the light square image, scaled according to the last paint request. - */ + /** A version of the light square image, scaled according to the last paint request. */ private Image scaledLightImage = null; - /** - * A version of the dark square image, scaled according to the last paint request. - */ + /** A version of the dark square image, scaled according to the last paint request. */ private Image scaledDarkImage = null; /** @@ -105,22 +96,19 @@ public class SquareImagesBoardPainter implements ResourceBoardPainter { */ private URL darkImageUrl = null; - /** - * The ImageDataReceiver, if any, currently waiting on board image data to load. - */ + /** The ImageDataReceiver, if any, currently waiting on board image data to load. */ private ImageDataReceiver imageDataReceiver = null; /** - * A no-arg constructor so that this SquareImagesBoardPainter can be used as a - * ResourceBoardPainter. + * A no-arg constructor so that this SquareImagesBoardPainter can be used as a + * ResourceBoardPainter. */ public SquareImagesBoardPainter() {} /** - *

- * Creates a new SquareImagesBoardPainter which paints light squares with - * lightImage and dark squares with darkImage. mode is - * either {@link #SCALE_MODE} or {@link #SLICE_MODE}. + * Creates a new SquareImagesBoardPainter which paints light squares with + * lightImage and dark squares with darkImage. mode is either + * {@link #SCALE_MODE} or {@link #SLICE_MODE}. */ public SquareImagesBoardPainter(Image lightImage, Image darkImage, int mode) { switch (mode) { @@ -154,15 +142,17 @@ public BoardPainter freshInstance() { /** * Loads the painter from the specified URL. The file structure at the URL is described below. - *

- * A properties file named "definition" must be located at the URL. That file should contain the - * following properties: + * + *

A properties file named "definition" must be located at the URL. That file should contain + * the following properties: + * *

+ * * Two images named light.[ext] and dark.[ext] must be located at the * URL, where "ext" is the value of the ext property. */ @@ -224,9 +214,7 @@ protected synchronized boolean prepareSquareImages(int width, int height, Compon } } - /** - * Scales the square image to the specified board size. - */ + /** Scales the square image to the specified board size. */ private void scaleSquareImages(int width, int height) { if (mode == SCALE_MODE) { int squareWidth = width / 8; @@ -246,9 +234,7 @@ private void scaleSquareImages(int width, int height) { } } - /** - * Paints the board at the given location on the given Graphics scaled to the given size. - */ + /** Paints the board at the given location on the given Graphics scaled to the given size. */ @Override public void paintBoard(Graphics g, Component component, int x, int y, int width, int height) { if (prepareSquareImages(width, height, component)) { @@ -303,14 +289,10 @@ public void paintBoard(Graphics g, Component component, int x, int y, int width, } else whileLoadingDelegate.paintBoard(g, component, x, y, width, height); } - /** - * The receiver of square image data. Responsible for creating the square images. - */ + /** The receiver of square image data. Responsible for creating the square images. */ private class ImageDataReceiver implements IOUtilities.DataReceiver { - /** - * The set of components to repaint once the images are loaded. - */ + /** The set of components to repaint once the images are loaded. */ private final Set componentsToRepaint = new HashSet(2); /** @@ -329,9 +311,7 @@ public void addComponentToRepaint(Component component) { componentsToRepaint.add(component); } - /** - * Called when the image data has been loaded. Creates the square images. - */ + /** Called when the image data has been loaded. Creates the square images. */ @Override public void dataRead(URL[] urls, Object id, byte[][] data, IOException[] exceptions) { // If there are any exceptions, we simply quit - this will cause diff --git a/src/main/java/free/chess/TimeControl.java b/src/main/java/free/chess/TimeControl.java index 8b9f523b..b0801ae6 100644 --- a/src/main/java/free/chess/TimeControl.java +++ b/src/main/java/free/chess/TimeControl.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2007 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -22,9 +22,7 @@ */ public abstract class TimeControl { - /** - * Returns the initial amount of time on the specified player's clock, in milliseconds. - */ + /** Returns the initial amount of time on the specified player's clock, in milliseconds. */ public abstract int getInitialTime(Player player); /** diff --git a/src/main/java/free/chess/VectorPiecePainter.java b/src/main/java/free/chess/VectorPiecePainter.java index caca0ea6..ee677489 100644 --- a/src/main/java/free/chess/VectorPiecePainter.java +++ b/src/main/java/free/chess/VectorPiecePainter.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -23,24 +23,16 @@ import java.awt.Polygon; import java.awt.Rectangle; -/** - * An abstract class offering a convenient partial implementation for vector based piece sets. - */ +/** An abstract class offering a convenient partial implementation for vector based piece sets. */ public abstract class VectorPiecePainter extends AbstractColoredPiecePainter { - /** - * The size of the cached pieces. - */ + /** The size of the cached pieces. */ private Dimension cachedPieceSize = new Dimension(-1, -1); - /** - * The cached piece polygons. - */ + /** The cached piece polygons. */ private Polygon kingPolygon, queenPolygon, rookPolygon, bishopPolygon, knightPolygon, pawnPolygon; - /** - * Creates a new VectorPiecePainter. - */ + /** Creates a new VectorPiecePainter. */ public VectorPiecePainter() { super(Color.white, Color.black); } @@ -106,9 +98,7 @@ public VectorPiecePainter( */ protected abstract Polygon createPawnPolygon(int width, int height); - /** - * Clears the caching of piece polygons. - */ + /** Clears the caching of piece polygons. */ private void clearPieceCache() { kingPolygon = null; queenPolygon = null; @@ -118,9 +108,7 @@ private void clearPieceCache() { pawnPolygon = null; } - /** - * Draws the given piece at the given coordinates with the given size on the given Graphics. - */ + /** Draws the given piece at the given coordinates with the given size on the given Graphics. */ @Override public final void paintPiece( Piece piece, Graphics g, Component component, Rectangle rect, boolean isShaded) { diff --git a/src/main/java/free/chess/WildVariant.java b/src/main/java/free/chess/WildVariant.java index d2b1cf33..59d1f8bb 100644 --- a/src/main/java/free/chess/WildVariant.java +++ b/src/main/java/free/chess/WildVariant.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -18,14 +18,10 @@ import java.util.Collection; -/** - * An interface classes defining rules for wild chess variants must implement. - */ +/** An interface classes defining rules for wild chess variants must implement. */ public interface WildVariant { - /** - * Sets the initial position for this wild variant on the given Position. - */ + /** Sets the initial position for this wild variant on the given Position. */ void init(Position pos); /** @@ -55,8 +51,8 @@ Move createMove( /** * Creates a Move object representing a move just like the specified one, but made in * the specified position. If the specified information is so bad that it's impossible to - * construct a move from it altogether, the implementation is allowed to throw an - * IllegalArgumentException. + * construct a move from it altogether, the implementation is allowed to throw an + * IllegalArgumentException. */ Move createMove(Position pos, Move move) throws IllegalArgumentException; @@ -77,9 +73,9 @@ Move createMove( * directly - call Position.makeMove(Move) instead. Implementations of this method should only * modify the Position via the modifier to avoid the change listeners of the position from being * notified in the middle of a move procedure where the position isn't "stable". There is no need - * to trigger the listeners to be called after the move procedure is done - - * Position.makeMove(Move) triggers them as needed by itself (and since this method - * can't be called directly, that's the only way to make a move). + * to trigger the listeners to be called after the move procedure is done - + * Position.makeMove(Move) triggers them as needed by itself (and since this method can't + * be called directly, that's the only way to make a move). */ void makeMove(Move move, Position pos, Position.Modifier modifier); @@ -87,7 +83,7 @@ Move createMove( * Returns the piece represented by the given String. * * @throws IllegalArgumentException if the given character does not represent a piece in this - * WildVariant. + * WildVariant. */ Piece parsePiece(String s); @@ -122,9 +118,7 @@ Move createMove( */ Collection getTargetSquares(Position position, Square square); - /** - * Returns the name of this WildVariant. - */ + /** Returns the name of this WildVariant. */ String getName(); /** diff --git a/src/main/java/free/chess/event/MoveEvent.java b/src/main/java/free/chess/event/MoveEvent.java index 75b2c469..4b1a0c80 100644 --- a/src/main/java/free/chess/event/MoveEvent.java +++ b/src/main/java/free/chess/event/MoveEvent.java @@ -2,59 +2,46 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess.event; -import java.util.EventObject; - import free.chess.Move; import free.chess.Position; +import java.util.EventObject; -/** - * The event sent when a move is made in a chess position. - */ +/** The event sent when a move is made in a chess position. */ public class MoveEvent extends EventObject { - /** - * The move that was made. - */ + /** The move that was made. */ private Move move; - /** - * The Position the move was made in. - */ + /** The Position the move was made in. */ private Position pos; - /** - * Creates a new MoveEvent with the given Move and the Position it was made on. - */ + /** Creates a new MoveEvent with the given Move and the Position it was made on. */ public MoveEvent(Position pos, Move move) { super(pos); this.move = move; this.pos = pos; } - /** - * Returns the Move that trigerred this MoveEvent. - */ + /** Returns the Move that trigerred this MoveEvent. */ public Move getMove() { return move; } - /** - * Returns the Position that changed as the result of this MoveEvent. - */ + /** Returns the Position that changed as the result of this MoveEvent. */ public Position getPosition() { return pos; } diff --git a/src/main/java/free/chess/event/MoveListener.java b/src/main/java/free/chess/event/MoveListener.java index b6e4a9d5..03358a64 100644 --- a/src/main/java/free/chess/event/MoveListener.java +++ b/src/main/java/free/chess/event/MoveListener.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -18,13 +18,9 @@ import java.util.EventListener; -/** - * The listener for moves made on a ChessPosition. - */ +/** The listener for moves made on a ChessPosition. */ public interface MoveListener extends EventListener { - /** - * Gets called when a move is made. - */ + /** Gets called when a move is made. */ void moveMade(MoveEvent evt); } diff --git a/src/main/java/free/chess/event/MoveProgressEvent.java b/src/main/java/free/chess/event/MoveProgressEvent.java index 56088f67..03fb67ca 100644 --- a/src/main/java/free/chess/event/MoveProgressEvent.java +++ b/src/main/java/free/chess/event/MoveProgressEvent.java @@ -2,47 +2,36 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2004 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess.event; -import java.util.EventObject; - import free.chess.JBoard; +import java.util.EventObject; -/** - * The event sent when the state of the move making process changes. - */ +/** The event sent when the state of the move making process changes. */ public class MoveProgressEvent extends EventObject { - /** - * The code for a MOVE_MAKING_STARTED event. - */ + /** The code for a MOVE_MAKING_STARTED event. */ public static final int MOVE_MAKING_STARTED = 1; - /** - * The code for a MOVE_MAKING_ENDED event. - */ + /** The code for a MOVE_MAKING_ENDED event. */ public static final int MOVE_MAKING_ENDED = 2; - /** - * The id of this event. - */ + /** The id of this event. */ private final int id; - /** - * Creates a new MoveProgressEvent with the specified source JBoard and event id. - */ + /** Creates a new MoveProgressEvent with the specified source JBoard and event id. */ public MoveProgressEvent(JBoard source, int id) { super(source); @@ -57,16 +46,14 @@ public MoveProgressEvent(JBoard source, int id) { this.id = id; } - /** - * Returns the board on which this event occured. - */ + /** Returns the board on which this event occured. */ public JBoard getJBoard() { return (JBoard) super.getSource(); } /** - * Returns the id of this event. Possible values are MOVE_MAKING_STARTED and - * MOVE_MAKING_ENDED. + * Returns the id of this event. Possible values are MOVE_MAKING_STARTED and + * MOVE_MAKING_ENDED. */ public int getId() { return id; diff --git a/src/main/java/free/chess/event/MoveProgressListener.java b/src/main/java/free/chess/event/MoveProgressListener.java index 07d0811c..687aaa40 100644 --- a/src/main/java/free/chess/event/MoveProgressListener.java +++ b/src/main/java/free/chess/event/MoveProgressListener.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2004 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -18,18 +18,12 @@ import java.util.EventListener; -/** - * The listener for events about the current state of the move-making process. - */ +/** The listener for events about the current state of the move-making process. */ public interface MoveProgressListener extends EventListener { - /** - * Gets called when the user starts making a move. - */ + /** Gets called when the user starts making a move. */ void moveMakingStarted(MoveProgressEvent evt); - /** - * Gets called when the user finishes making a move. - */ + /** Gets called when the user finishes making a move. */ void moveMakingEnded(MoveProgressEvent evt); } diff --git a/src/main/java/free/chess/variants/BothSidesCastlingVariant.java b/src/main/java/free/chess/variants/BothSidesCastlingVariant.java index 1face3a6..84eca174 100644 --- a/src/main/java/free/chess/variants/BothSidesCastlingVariant.java +++ b/src/main/java/free/chess/variants/BothSidesCastlingVariant.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2003 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -130,9 +130,7 @@ public boolean isLongCastling( } else return false; } - /** - * Makes the given ChessMove on the given position. - */ + /** Makes the given ChessMove on the given position. */ @Override public void makeMove(Move move, Position pos, Position.Modifier modifier) { checkPosition(pos); @@ -165,9 +163,7 @@ public void makeMove(Move move, Position pos, Position.Modifier modifier) { } else super.makeMove(move, pos, modifier); } - /** - * Creates a short castling move for the current player in the specified position. - */ + /** Creates a short castling move for the current player in the specified position. */ @Override public Move createShortCastling(Position pos) { checkPosition(pos); @@ -208,9 +204,7 @@ else if (pos.getPieceAt(Square.parseSquare("d8")) == ChessPiece.BLACK_KING) } } - /** - * Creates a long castling move for the current player in the specified position. - */ + /** Creates a long castling move for the current player in the specified position. */ @Override public Move createLongCastling(Position pos) { checkPosition(pos); diff --git a/src/main/java/free/chess/variants/NoCastlingVariant.java b/src/main/java/free/chess/variants/NoCastlingVariant.java index a2c459eb..901658f2 100644 --- a/src/main/java/free/chess/variants/NoCastlingVariant.java +++ b/src/main/java/free/chess/variants/NoCastlingVariant.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -29,16 +29,12 @@ */ public class NoCastlingVariant extends ChesslikeGenericVariant { - /** - * Creates a new instance of NoCastlingVariant with the given initial position and name. - */ + /** Creates a new instance of NoCastlingVariant with the given initial position and name. */ public NoCastlingVariant(String initialPositionFEN, String variantName) { super(initialPositionFEN, variantName); } - /** - * Returns false, as this is a variant which disallows castling. - */ + /** Returns false, as this is a variant which disallows castling. */ @Override public boolean isShortCastling( Position pos, Square startingSquare, Square endingSquare, ChessPiece promotionTarget) { @@ -46,9 +42,7 @@ public boolean isShortCastling( return false; } - /** - * Returns false, as this is a variant which disallows castling. - */ + /** Returns false, as this is a variant which disallows castling. */ @Override public boolean isLongCastling( Position pos, Square startingSquare, Square endingSquare, ChessPiece promotionTarget) { @@ -56,17 +50,13 @@ public boolean isLongCastling( return false; } - /** - * Always throws UnsupportedOperationException. - */ + /** Always throws UnsupportedOperationException. */ @Override public Move createShortCastling(Position pos) { throw new free.util.UnsupportedOperationException("Can't castle"); } - /** - * Always throws UnsupportedOperationException. - */ + /** Always throws UnsupportedOperationException. */ @Override public Move createLongCastling(Position pos) { throw new free.util.UnsupportedOperationException("Can't castle"); diff --git a/src/main/java/free/chess/variants/atomic/Atomic.java b/src/main/java/free/chess/variants/atomic/Atomic.java index dd8c707e..a6a1d288 100644 --- a/src/main/java/free/chess/variants/atomic/Atomic.java +++ b/src/main/java/free/chess/variants/atomic/Atomic.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -45,32 +45,25 @@ */ public class Atomic extends ChesslikeGenericVariant { - /** - * The sole instance of this class. - */ + /** The sole instance of this class. */ private static final Atomic INSTANCE = new Atomic(); - /** - * Returns an instance of this class. - */ + /** Returns an instance of this class. */ public static Atomic getInstance() { return INSTANCE; } - /** - * Creates an instance of Giveaway. - */ + /** Creates an instance of Giveaway. */ private Atomic() { super(Chess.INITIAL_POSITION_FEN, "Atomic"); } /** - *

* Makes the given ChessMove in the given Position. This method shoudln't (and can't) be called * directly - call {@link Position#makeMove(Move)} instead. * * @throws IllegalArgumentException if the given Move is not an instance of ChessMove - * . + * . */ @Override public void makeMove(Move move, Position pos, Position.Modifier modifier) { diff --git a/src/main/java/free/chess/variants/fischerrandom/FischerRandom.java b/src/main/java/free/chess/variants/fischerrandom/FischerRandom.java index 48b81ed2..e670c9df 100644 --- a/src/main/java/free/chess/variants/fischerrandom/FischerRandom.java +++ b/src/main/java/free/chess/variants/fischerrandom/FischerRandom.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -43,21 +43,15 @@ */ public class FischerRandom extends ChesslikeGenericVariant { - /** - * The sole instance of this class. - */ + /** The sole instance of this class. */ private static final FischerRandom INSTANCE = new FischerRandom(); - /** - * Returns an instance of this class. - */ + /** Returns an instance of this class. */ public static FischerRandom getInstance() { return INSTANCE; } - /** - * Creates an instance of FischerRandom. - */ + /** Creates an instance of FischerRandom. */ private FischerRandom() { super(Chess.INITIAL_POSITION_FEN /* Not used anyway */, "Fischer random"); } @@ -400,9 +394,7 @@ private static int randomInt(int max) { return (int) (Math.random() * max); } - /** - * Makes the given ChessMove on the given position. - */ + /** Makes the given ChessMove on the given position. */ @Override public void makeMove(Move move, Position pos, Position.Modifier modifier) { checkPosition(pos); diff --git a/src/main/java/free/chess/variants/giveaway/Giveaway.java b/src/main/java/free/chess/variants/giveaway/Giveaway.java index 63ca7b17..5c89cabc 100644 --- a/src/main/java/free/chess/variants/giveaway/Giveaway.java +++ b/src/main/java/free/chess/variants/giveaway/Giveaway.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -61,27 +61,20 @@ public class Giveaway extends ChesslikeGenericVariant { ChessPiece.BLACK_KING }; - /** - * The sole instance of this class. - */ + /** The sole instance of this class. */ private static final Giveaway INSTANCE = new Giveaway(); - /** - * Returns an instance of this class. - */ + /** Returns an instance of this class. */ public static Giveaway getInstance() { return INSTANCE; } - /** - * Creates an instance of Giveaway. - */ + /** Creates an instance of Giveaway. */ private Giveaway() { super(Chess.INITIAL_POSITION_FEN, "Giveaway"); } /** - *

* If the a move created by the given starting square and ending square in the given position is a * promotion, returns an array containing a knight, bishop, rook and queen of the color of the * promoted pawn. Otherwise returns null. diff --git a/src/main/java/free/chess/variants/kriegspiel/Kriegspiel.java b/src/main/java/free/chess/variants/kriegspiel/Kriegspiel.java index 0a645e65..d3dab376 100644 --- a/src/main/java/free/chess/variants/kriegspiel/Kriegspiel.java +++ b/src/main/java/free/chess/variants/kriegspiel/Kriegspiel.java @@ -2,22 +2,20 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ package free.chess.variants.kriegspiel; -import java.util.Collection; - import free.chess.BoardPainter; import free.chess.Chess; import free.chess.ChessMove; @@ -32,6 +30,7 @@ import free.chess.Position; import free.chess.Square; import free.chess.WildVariant; +import java.util.Collection; /** * Implements the Kriegspiel wild variant. See DefaultPiecePainter. - */ + /** Returns an instance of DefaultPiecePainter. */ @Override public PiecePainter createDefaultPiecePainter() { return new DefaultPiecePainter(); } - /** - * Returns an instance of DefaultBoardPainter. - */ + /** Returns an instance of DefaultBoardPainter. */ @Override public BoardPainter createDefaultBoardPainter() { return new DefaultBoardPainter(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public Collection getTargetSquares(Position pos, Square square) { checkPosition(pos); @@ -247,17 +230,13 @@ public Collection getTargetSquares(Position pos, Square square) { return Chess.getInstance().getTargetSquares(pos, square); } - /** - * Returns the string "Kriegspiel". - */ + /** Returns the string "Kriegspiel". */ @Override public String getName() { return "Kriegspiel"; } - /** - * Returns a textual representation of this WildVariant. - */ + /** Returns a textual representation of this WildVariant. */ @Override public String toString() { return getName(); diff --git a/src/main/java/free/chess/variants/kriegspiel/KriegspielMove.java b/src/main/java/free/chess/variants/kriegspiel/KriegspielMove.java index 5075ee47..1e7fa0bb 100644 --- a/src/main/java/free/chess/variants/kriegspiel/KriegspielMove.java +++ b/src/main/java/free/chess/variants/kriegspiel/KriegspielMove.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2002 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -24,25 +24,24 @@ /** * A move in the Kriegspiel chess variant. A Kriegspiel move can be of one of two types: + * *

*/ public class KriegspielMove extends Move { - /** - * The square where the piece moved in case of a partially hidden move. - */ + /** The square where the piece moved in case of a partially hidden move. */ private final ChessPiece capturedPiece; /** * Creates a new completely hidden Kriegspiel move. No information about the move is available and * all inquiring methods will throw an IllegalStateException (except that we know it's not a - * capture). The {@link #isCompletelyHidden()} method will return true. - * stringRepresentation may be null in which case a string constructed - * from the move data will be returned by toString().. + * capture). The {@link #isCompletelyHidden()} method will return true. + * stringRepresentation may be null in which case a string constructed from + * the move data will be returned by toString().. */ public KriegspielMove(Player player, String stringRepresentation) { super(null, null, player, stringRepresentation); @@ -52,10 +51,10 @@ public KriegspielMove(Player player, String stringRepresentation) { /** * Creates a partially hidden Kriegspiel move. It is known that this move is a capture, the - * captured piece is known and the target (ending) square is known. The - * {@link #isCompletelyHidden()} method will return false. - * stringRepresentation may be null in which case a string constructed - * from the move data will be returned by toString().. + * captured piece is known and the target (ending) square is known. The {@link + * #isCompletelyHidden()} method will return false. stringRepresentation + * may be null in which case a string constructed from the move data will be returned + * by toString().. */ public KriegspielMove(Position pos, Square endingSquare, String stringRepresentation) { super(null, endingSquare, pos.getCurrentPlayer(), stringRepresentation); @@ -74,9 +73,7 @@ public boolean isCompletelyHidden() { return super.getEndingSquare() == null; } - /** - * Always returns null since the starting square is always unknown. - */ + /** Always returns null since the starting square is always unknown. */ @Override public Square getStartingSquare() { return null; @@ -93,9 +90,7 @@ public Square getEndingSquare() { return super.getEndingSquare(); } - /** - * Returns a string representation of the move based on the move data. - */ + /** Returns a string representation of the move based on the move data. */ @Override public String getMoveString() { if (isCompletelyHidden()) return "?"; diff --git a/src/main/java/free/chess/variants/shatranj/Shatranj.java b/src/main/java/free/chess/variants/shatranj/Shatranj.java index d3fd3a85..fdc02ade 100644 --- a/src/main/java/free/chess/variants/shatranj/Shatranj.java +++ b/src/main/java/free/chess/variants/shatranj/Shatranj.java @@ -1,16 +1,15 @@ package free.chess.variants.shatranj; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - import free.chess.Chess; import free.chess.ChessPiece; import free.chess.Piece; import free.chess.Position; import free.chess.Square; import free.chess.variants.NoCastlingVariant; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; /** * Implements the Shatranj wild variant. See The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -36,21 +36,15 @@ */ public class ShuffleBoth extends BothSidesCastlingVariant { - /** - * The sole instance of this class. - */ + /** The sole instance of this class. */ private static final ShuffleBoth INSTANCE = new ShuffleBoth(); - /** - * Returns an instance of this class. - */ + /** Returns an instance of this class. */ public static ShuffleBoth getInstance() { return INSTANCE; } - /** - * Creates an instance of ShuffleBoth. - */ + /** Creates an instance of ShuffleBoth. */ private ShuffleBoth() { super(Chess.INITIAL_POSITION_FEN /* Not used anyway */, "Shuffle both"); } @@ -79,9 +73,7 @@ private static String createRandomInitialFEN() { return blackPieces + "/pppppppp/8/8/8/8/PPPPPPPP/" + whitePieces + " w KQkq - 0 1"; } - /** - * Creates and returns a random row of pieces, subject to the Shuffle Both rules. - */ + /** Creates and returns a random row of pieces, subject to the Shuffle Both rules. */ private static String createRandomPieceRow() { StringBuffer pieces = new StringBuffer("R------R"); diff --git a/src/main/java/free/chess/variants/suicide/Suicide.java b/src/main/java/free/chess/variants/suicide/Suicide.java index 28d828a9..e5e4d87d 100644 --- a/src/main/java/free/chess/variants/suicide/Suicide.java +++ b/src/main/java/free/chess/variants/suicide/Suicide.java @@ -2,15 +2,15 @@ * The chess framework library. More information is available at http://www.jinchess.com/. Copyright * (C) 2003 Alexander Maryanovsky. All rights reserved. * - * The chess framework library is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software Foundation; + *

The chess framework library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - * The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY + *

The chess framework library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the chess + *

You should have received a copy of the GNU Lesser General Public License along with the chess * framework library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ @@ -57,27 +57,20 @@ public class Suicide extends NoCastlingVariant { ChessPiece.BLACK_KING }; - /** - * The sole instance of this class. - */ + /** The sole instance of this class. */ private static final Suicide INSTANCE = new Suicide(); - /** - * Returns an instance of this class. - */ + /** Returns an instance of this class. */ public static Suicide getInstance() { return INSTANCE; } - /** - * Creates an instance of Suicide. - */ + /** Creates an instance of Suicide. */ private Suicide() { super(Chess.INITIAL_POSITION_FEN, "Suicide"); } /** - *

* If the a move created by the given starting square and ending square in the given position is a * promotion, returns an array containing a king, pawn, knight, bishop, rook queen of the color of * the promoted pawn. Otherwise returns null. diff --git a/src/main/java/free/chessclub/ChessclubConnection.java b/src/main/java/free/chessclub/ChessclubConnection.java index 7ba053db..60eb9b64 100644 --- a/src/main/java/free/chessclub/ChessclubConnection.java +++ b/src/main/java/free/chessclub/ChessclubConnection.java @@ -2,20 +2,27 @@ * The chessclub.com connection library. More information is available at http://www.jinchess.com/. * Copyright (C) 2002-2003 Alexander Maryanovsky. All rights reserved. * - * The chessclub.com connection library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free Software + *

The chessclub.com connection library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. * - * The chessclub.com connection library is distributed in the hope that it will be useful, but + *

The chessclub.com connection library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License along with the + *

You should have received a copy of the GNU Lesser General Public License along with the * chessclub.com connection library; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA */ package free.chessclub; +import free.chessclub.level1.Packet; +import free.chessclub.level2.Datagram; +import free.chessclub.level2.DatagramEvent; +import free.chessclub.level2.DatagramListener; +import free.util.Connection; +import free.util.EventListenerList; +import free.util.FormatException; import java.io.BufferedInputStream; import java.io.EOFException; import java.io.IOException; @@ -30,14 +37,6 @@ import java.util.List; import java.util.StringTokenizer; -import free.chessclub.level1.Packet; -import free.chessclub.level2.Datagram; -import free.chessclub.level2.DatagramEvent; -import free.chessclub.level2.DatagramListener; -import free.util.Connection; -import free.util.EventListenerList; -import free.util.FormatException; - /** * This class is responsible for connecting to the chessclub.com server, logging on and further * processing of information as it arrives from the server. Before using this class you should read @@ -48,39 +47,25 @@ */ public class ChessclubConnection extends free.util.Connection { - /** - * The standard delimiter, used to delimit both level1 and level2. - */ + /** The standard delimiter, used to delimit both level1 and level2. */ private static final char STANDARD_DELIMITER = '\u0019'; - /** - * The start-of-level1-packet delimiter. - */ + /** The start-of-level1-packet delimiter. */ private static final char PACKET_START_DELIMITER = '['; - /** - * The end-of-level1-packet delimiter. - */ + /** The end-of-level1-packet delimiter. */ private static final char PACKET_END_DELIMITER = ']'; - /** - * The start-of-level2-datagram delimiter. - */ + /** The start-of-level2-datagram delimiter. */ private static final char DATAGRAM_START_DELIMITER = '('; - /** - * The end-of-datagram delimiter. - */ + /** The end-of-datagram delimiter. */ private static final char DATAGRAM_END_DELIMITER = ')'; - /** - * Maps rating keys to their english names. - */ + /** Maps rating keys to their english names. */ private final Hashtable ratingCategoryNames = new Hashtable(); - /** - * Maps wild variant indices to their english names. - */ + /** Maps wild variant indices to their english names. */ private final Hashtable variantNames = new Hashtable(); /** @@ -93,46 +78,32 @@ public class ChessclubConnection extends free.util.Connection { /** * The level2 settings requested by the client. The bit at each index specifies whether the * Datagram with that index will be turned on. - *

- * Note that these aren't the "real" settings because the settings only take effect once the + * + *

Note that these aren't the "real" settings because the settings only take effect once the * server reads them and responds with a DG_SET2. The "real" level 2 settings are stored in * level2settings. */ private BitSet requestedLevel2Settings = new BitSet(); - /** - * The current board sending "style". - */ + /** The current board sending "style". */ private int style = 1; - /** - * The value we're supposed to assign to the interface variable during login. - */ + /** The value we're supposed to assign to the interface variable during login. */ private String interfaceVar = "Java chessclub.com library (http://www.jinchess.com/)"; - /** - * The current setting of level1. - */ + /** The current setting of level1. */ private int level1State = 0; - /** - * The "real" level 2 settings on which currently the client and the server agree. - */ + /** The "real" level 2 settings on which currently the client and the server agree. */ private BitSet level2Settings = new BitSet(); - /** - * This is set to true when the "level2settings=..." line has been sent. - */ + /** This is set to true when the "level2settings=..." line has been sent. */ private boolean level2SettingsSent = false; - /** - * The queue of commands we are to send on-login. - */ + /** The queue of commands we are to send on-login. */ private LinkedList onLoginCommandQueue = new LinkedList(); - /** - * A list of listeners to our datagram events, lazily instantiated. - */ + /** A list of listeners to our datagram events, lazily instantiated. */ private final EventListenerList[] datagramListeners = new EventListenerList[Datagram.MAX_DG_ID + 1]; @@ -142,12 +113,11 @@ public class ChessclubConnection extends free.util.Connection { * (level2 settings for example) and then call the connectAndLogin method. * * @param requestedUsername The requested username, note that the actual username is unknown until - * after the login. + * after the login. * @param password The password of the account. * @param logStream The PrintStream where this ChessclubConnection will log all information sent - * by the server and commands sent by this ChessclubConnection. Pass - * null if you don't want logging. - * + * by the server and commands sent by this ChessclubConnection. Pass null + * if you don't want logging. * @see #setDGState(int, boolean) */ public ChessclubConnection(String requestedUsername, String password, PrintStream logStream) { @@ -180,8 +150,8 @@ public ChessclubConnection(String requestedUsername, String password, PrintStrea * receive. It may seem a bit silly, but it's cleaner than making setDGState public. * This also means that when processing the fields of a datagram, you should always be prepared to * handle all the optional fields, even if you did not request them (someone else might have - * requested them). You can check which of the optional fields are on via the - * isDGOn(int) method. + * requested them). You can check which of the optional fields are on via the isDGOn(int) + * method. */ public void addDatagramListener(DatagramListener dgListener, int dgId) { if (datagramListeners[dgId] == null) { @@ -198,8 +168,8 @@ public void addDatagramListener(DatagramListener dgListener, int dgId) { * type of datagram will cause that datagram to be turned off with the server. This is true even * for datagrams which are never sent to the client, but instead act as flags for other datagrams * (DG_MOVE_SMITH for example), which means you may have to unregister listeners for datagrams you - * never indend to receive. It may seem a bit silly, but it's cleaner than making - * setDGState public. + * never indend to receive. It may seem a bit silly, but it's cleaner than making setDGState + * public. */ public void removeDatagramListener(DatagramListener dgListener, int dgId) { if (datagramListeners[dgId] == null) return; @@ -242,9 +212,8 @@ public final synchronized void setLevel1(int level1State) { } /** - * Returns the current level1 state. See - * ftp://ftp.chessclub.com/pub/icc/formats/formats.txt for documentation about - * level1. + * Returns the current level1 state. See ftp://ftp.chessclub.com/pub/icc/formats/formats.txt + * for documentation about level1. */ public final synchronized int getLevel1() { return level1State; @@ -257,19 +226,17 @@ public final synchronized int getLevel1() { * level2settings=0011011011... format. Note that some datagrams are necessary for * the correct behaviour of this class, and cannot be turned off (DG_WHO_AM_I and DG_SET2 for * example). This method is no longer the "normal" way of controlling datagrams' state. In fact, - * you should not control the datagrams' state directly at all - instead, register a - * DatagramListener with the id of the datagram you want to receive and it will be - * turned on for you automatically. This is true even for datagrams which are never sent to the - * client, but instead act as flags for other datagrams (DG_MOVE_SMITH for example). It may seem a - * bit silly, but it's cleaner than making this method public. + * you should not control the datagrams' state directly at all - instead, register a + * DatagramListener with the id of the datagram you want to receive and it will be turned + * on for you automatically. This is true even for datagrams which are never sent to the client, + * but instead act as flags for other datagrams (DG_MOVE_SMITH for example). It may seem a bit + * silly, but it's cleaner than making this method public. * * @param dgNumber The number of the datagram. * @param state Whether turn the datagram on or off. - * * @return Whether the state of the datagram was modified successfully. This always returns true - * when setting a datagram on, and only returns false when trying to set an essential datagram - * off. - * + * when setting a datagram on, and only returns false when trying to set an essential datagram + * off. * @see #isEssentialDG(int) * @see #isDGOn(int) */ @@ -308,9 +275,7 @@ protected synchronized void setDGOnAgain(int dgNumber, String tag) { sendCommand("set-2 " + dgNumber + " 1", false, true, tag); } - /** - * Same as setDGOnAgain, but without the tag. - */ + /** Same as setDGOnAgain, but without the tag. */ protected void setDGOnAgain(int dgNumber) { setDGOnAgain(dgNumber, null); } @@ -327,11 +292,11 @@ public final synchronized void setInterface(String interfaceVar) { } /** - * Sets the style. If the ChessclubConnection is already logged in, then a - * "set-quietly style