From 08762fe6bc85aa2333a047c4c9f2adeea68ef84f Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Mon, 29 Dec 2014 10:19:55 +0300 Subject: [PATCH 01/14] moved to net.freerouting package --- .gitignore | 3 + pom.xml | 67 +++++++ .../autoroute}/AutorouteControl.java | 22 +-- .../autoroute}/AutorouteEngine.java | 28 +-- .../autoroute}/BatchAutorouter.java | 30 +-- .../freerouting/autoroute}/BatchFanout.java | 32 ++-- .../freerouting/autoroute}/BatchOptRoute.java | 24 +-- .../autoroute}/CompleteExpansionRoom.java | 6 +- .../CompleteFreeSpaceExpansionRoom.java | 16 +- .../freerouting/autoroute}/Connection.java | 8 +- .../autoroute}/DestinationDistance.java | 8 +- .../net/freerouting/autoroute}/DrillPage.java | 28 +-- .../autoroute}/DrillPageArray.java | 10 +- .../autoroute}/ExpandableObject.java | 4 +- .../freerouting/autoroute}/ExpansionDoor.java | 10 +- .../autoroute}/ExpansionDrill.java | 14 +- .../freerouting/autoroute}/ExpansionRoom.java | 4 +- .../autoroute}/FreeSpaceExpansionRoom.java | 4 +- .../IncompleteFreeSpaceExpansionRoom.java | 4 +- .../autoroute}/InsertFoundConnectionAlgo.java | 38 ++-- .../autoroute}/ItemAutorouteInfo.java | 8 +- .../autoroute}/LocateFoundConnectionAlgo.java | 20 +- .../LocateFoundConnectionAlgo45Degree.java | 22 +-- .../LocateFoundConnectionAlgoAnyAngle.java | 18 +- .../autoroute}/MazeListElement.java | 4 +- .../autoroute}/MazeSearchAlgo.java | 108 +++++------ .../autoroute}/MazeSearchElement.java | 2 +- .../autoroute}/MazeShoveTraceAlgo.java | 42 ++--- .../autoroute}/ObstacleExpansionRoom.java | 14 +- .../Sorted45DegreeRoomNeighbours.java | 20 +- .../SortedOrthogonalRoomNeighbours.java | 16 +- .../autoroute}/SortedRoomNeighbours.java | 34 ++-- .../autoroute}/TargetItemExpansionDoor.java | 10 +- .../net/freerouting/autoroute}/package.html | 0 .../freerouting/board}/AngleRestriction.java | 2 +- .../net/freerouting/board}/BasicBoard.java | 36 ++-- .../board}/BoardObserverAdaptor.java | 2 +- .../freerouting/board}/BoardObservers.java | 4 +- .../net/freerouting/board}/BoardOutline.java | 25 ++- .../net/freerouting/board}/CalcFromSide.java | 16 +- .../board}/CalcShapeAndFromSide.java | 12 +- .../net/freerouting/board}/ChangedArea.java | 10 +- .../board}/ClearanceViolation.java | 6 +- .../net/freerouting/board}/Communication.java | 8 +- .../net/freerouting/board}/Component.java | 20 +- .../board}/ComponentObstacleArea.java | 12 +- .../freerouting/board}/ComponentOutline.java | 22 +-- .../net/freerouting/board}/Components.java | 12 +- .../freerouting/board}/ConductionArea.java | 18 +- .../net/freerouting/board}/Connectable.java | 4 +- .../board}/CoordinateTransform.java | 24 +-- .../net/freerouting/board}/DrillItem.java | 22 +-- .../net/freerouting/board}/FixedState.java | 2 +- .../net/freerouting/board}/ForcedPadAlgo.java | 24 +-- .../net/freerouting/board}/ForcedViaAlgo.java | 28 +-- .../java/net/freerouting/board}/Item.java | 46 ++--- .../freerouting/board}/ItemIdNoGenerator.java | 4 +- .../board}/ItemSearchTreesInfo.java | 6 +- .../board}/ItemSelectionFilter.java | 6 +- .../java/net/freerouting/board}/Layer.java | 2 +- .../freerouting/board}/LayerStructure.java | 2 +- .../net/freerouting/board}/MoveComponent.java | 14 +- .../freerouting/board}/MoveDrillItemAlgo.java | 20 +- .../freerouting/board}/ObjectInfoPanel.java | 8 +- .../net/freerouting/board}/ObstacleArea.java | 26 +-- .../net/freerouting/board}/OptViaAlgo.java | 18 +- .../main/java/net/freerouting/board}/Pin.java | 44 ++--- .../net/freerouting/board}/PolylineTrace.java | 38 ++-- .../freerouting/board}/PrintableShape.java | 10 +- .../net/freerouting/board}/PullTightAlgo.java | 26 +-- .../freerouting/board}/PullTightAlgo45.java | 26 +-- .../freerouting/board}/PullTightAlgo90.java | 14 +- .../board}/PullTightAlgoAnyAngle.java | 24 +-- .../net/freerouting/board}/RoutingBoard.java | 50 ++--- .../freerouting/board}/SearchTreeManager.java | 10 +- .../freerouting/board}/SearchTreeObject.java | 4 +- .../freerouting/board}/ShapeSearchTree.java | 42 ++--- .../board}/ShapeSearchTree45Degree.java | 20 +- .../board}/ShapeSearchTree90Degree.java | 16 +- .../freerouting/board}/ShapeTraceEntries.java | 14 +- .../freerouting/board}/ShoveTraceAlgo.java | 32 ++-- .../net/freerouting/board}/TestLevel.java | 2 +- .../java/net/freerouting/board}/Trace.java | 24 +-- .../java/net/freerouting/board}/Unit.java | 2 +- .../main/java/net/freerouting/board}/Via.java | 28 +-- .../freerouting/board}/ViaObstacleArea.java | 12 +- .../java/net/freerouting/board}/package.html | 0 .../boardgraphics}/ColorIntensityTable.java | 2 +- .../boardgraphics}/ColorTableModel.java | 2 +- .../boardgraphics}/CoordinateTransform.java | 8 +- .../freerouting/boardgraphics}/Drawable.java | 2 +- .../boardgraphics}/GraphicsContext.java | 20 +- .../boardgraphics}/ItemColorTableModel.java | 6 +- .../boardgraphics}/ItemDrawInfo.java | 2 +- .../boardgraphics}/OtherColorTableModel.java | 4 +- .../freerouting/boardgraphics}/package.html | 0 .../datastructures}/ArrayStack.java | 2 +- .../datastructures}/BigIntAux.java | 2 +- .../datastructures}/FileFilter.java | 2 +- .../datastructures}/IdNoGenerator.java | 2 +- .../datastructures}/IdentifierType.java | 2 +- .../datastructures}/IndentFileWriter.java | 2 +- .../datastructures}/MinAreaTree.java | 6 +- .../datastructures}/Observers.java | 2 +- .../PlanarDelaunayTriangulation.java | 12 +- .../datastructures}/ShapeTree.java | 10 +- .../freerouting/datastructures}/Signum.java | 2 +- .../datastructures}/Stoppable.java | 2 +- .../datastructures}/TimeLimit.java | 2 +- .../datastructures}/UndoableObjects.java | 2 +- .../freerouting/datastructures}/package.html | 0 .../specctra/AutorouteSettings.java | 20 +- .../designformats}/specctra/Circle.java | 16 +- .../designformats}/specctra/Circuit.java | 2 +- .../designformats}/specctra/Component.java | 28 +-- .../specctra/ComponentPlacement.java | 2 +- .../specctra/CoordinateTransform.java | 24 +-- .../designformats}/specctra/DsnFile.java | 58 +++--- .../designformats}/specctra/Keyword.java | 6 +- .../designformats}/specctra/Layer.java | 4 +- .../specctra/LayerStructure.java | 6 +- .../designformats}/specctra/Library.java | 74 ++++---- .../designformats}/specctra/Net.java | 20 +- .../designformats}/specctra/NetClass.java | 2 +- .../designformats}/specctra/NetList.java | 2 +- .../designformats}/specctra/Network.java | 176 +++++++++--------- .../designformats}/specctra/Package.java | 28 +-- .../designformats}/specctra/Parser.java | 8 +- .../designformats}/specctra/PartLibrary.java | 12 +- .../designformats}/specctra/Path.java | 6 +- .../designformats}/specctra/PlaceControl.java | 2 +- .../designformats}/specctra/Placement.java | 2 +- .../designformats}/specctra/Plane.java | 18 +- .../designformats}/specctra/Polygon.java | 18 +- .../designformats}/specctra/PolygonPath.java | 20 +- .../designformats}/specctra/PolylinePath.java | 10 +- .../specctra/ReadScopeParameter.java | 24 +-- .../designformats}/specctra/Rectangle.java | 14 +- .../designformats}/specctra/Resolution.java | 6 +- .../designformats}/specctra/Rule.java | 16 +- .../designformats}/specctra/RulesFile.java | 20 +- .../designformats}/specctra/Scanner.java | 2 +- .../designformats}/specctra/ScopeKeyword.java | 2 +- .../designformats}/specctra/SessionFile.java | 84 ++++----- .../specctra/SessionToEagle.java | 36 ++-- .../designformats}/specctra/Shape.java | 36 ++-- .../specctra/SpecctraFileDescription.flex | 0 .../specctra/SpecctraFileScanner.java | 2 +- .../specctra/SpecctraFileScanner.java~ | 0 .../designformats}/specctra/Structure.java | 134 ++++++------- .../designformats}/specctra/Wiring.java | 120 ++++++------ .../specctra/WriteScopeParameter.java | 12 +- .../designformats}/specctra/package.html | 0 .../freerouting/geometry}/planar/Area.java | 2 +- .../geometry}/planar/BigIntDirection.java | 2 +- .../freerouting/geometry}/planar/Circle.java | 2 +- .../geometry}/planar/ConvexShape.java | 2 +- .../geometry}/planar/Direction.java | 4 +- .../freerouting/geometry}/planar/Ellipse.java | 2 +- .../geometry}/planar/FloatLine.java | 2 +- .../geometry}/planar/FloatPoint.java | 2 +- .../FortyfiveDegreeBoundingDirections.java | 2 +- .../planar/FortyfiveDegreeDirection.java | 2 +- .../freerouting/geometry}/planar/IntBox.java | 2 +- .../geometry}/planar/IntDirection.java | 4 +- .../geometry}/planar/IntOctagon.java | 2 +- .../geometry}/planar/IntPoint.java | 2 +- .../geometry}/planar/IntVector.java | 6 +- .../freerouting/geometry}/planar/Limits.java | 2 +- .../freerouting/geometry}/planar/Line.java | 4 +- .../geometry}/planar/LineSegment.java | 4 +- .../planar/OrthogonalBoundingDirections.java | 2 +- .../freerouting/geometry}/planar/Point.java | 2 +- .../freerouting/geometry}/planar/Polygon.java | 2 +- .../geometry}/planar/PolygonShape.java | 2 +- .../geometry}/planar/Polyline.java | 2 +- .../geometry}/planar/PolylineArea.java | 4 +- .../geometry}/planar/PolylineShape.java | 2 +- .../geometry}/planar/RationalPoint.java | 4 +- .../geometry}/planar/RationalVector.java | 6 +- .../geometry}/planar/RegularTileShape.java | 2 +- .../freerouting/geometry}/planar/Shape.java | 2 +- .../planar/ShapeBoundingDirections.java | 2 +- .../freerouting/geometry}/planar/Side.java | 2 +- .../freerouting/geometry}/planar/Simplex.java | 2 +- .../geometry}/planar/TileShape.java | 2 +- .../freerouting/geometry}/planar/Vector.java | 4 +- .../freerouting/geometry}/planar/package.html | 0 .../java/net/freerouting/gui}/BoardFrame.java | 28 +-- .../net/freerouting/gui}/BoardMenuBar.java | 2 +- .../freerouting/gui}/BoardMenuDisplay.java | 4 +- .../net/freerouting/gui}/BoardMenuFile.java | 12 +- .../net/freerouting/gui}/BoardMenuHelp.java | 6 +- .../gui}/BoardMenuHelpReduced.java | 4 +- .../net/freerouting/gui}/BoardMenuInfo.java | 4 +- .../net/freerouting/gui}/BoardMenuOther.java | 4 +- .../freerouting/gui}/BoardMenuParameter.java | 4 +- .../net/freerouting/gui}/BoardMenuRules.java | 4 +- .../java/net/freerouting/gui}/BoardPanel.java | 10 +- .../freerouting/gui}/BoardPanelStatus.java | 4 +- .../gui}/BoardSavableSubWindow.java | 2 +- .../net/freerouting/gui}/BoardSubWindow.java | 2 +- .../gui}/BoardTemporarySubWindow.java | 2 +- .../net/freerouting/gui}/BoardToolbar.java | 16 +- .../gui}/BoardToolbarSelectedItem.java | 6 +- .../net/freerouting/gui}/ColorManager.java | 8 +- .../freerouting/gui}/ComboBoxClearance.java | 4 +- .../net/freerouting/gui}/ComboBoxLayer.java | 8 +- .../java/net/freerouting/gui}/Cursor.java | 2 +- .../java/net/freerouting/gui}/DesignFile.java | 24 +-- .../gui}/GUIDefaultsDescription.flex | 0 .../net/freerouting/gui}/GUIDefaultsFile.java | 26 +-- .../freerouting/gui}/GUIDefaultsScanner.java | 2 +- .../freerouting/gui}/GUIDefaultsScanner.java~ | 0 .../net/freerouting/gui}/MainApplication.java | 10 +- .../gui}/PopupMenuChangeLayer.java | 8 +- .../net/freerouting/gui}/PopupMenuCopy.java | 8 +- .../freerouting/gui}/PopupMenuDisplay.java | 4 +- .../gui}/PopupMenuDynamicRoute.java | 8 +- .../gui}/PopupMenuInsertCancel.java | 4 +- .../net/freerouting/gui}/PopupMenuMain.java | 6 +- .../net/freerouting/gui}/PopupMenuMove.java | 10 +- .../gui}/PopupMenuSelectedItems.java | 6 +- .../gui}/PopupMenuStitchRoute.java | 8 +- .../gui}/PupupMenuCornerItemConstruction.java | 4 +- .../java/net/freerouting/gui}/WebStart.java | 2 +- .../net/freerouting/gui}/WindowAbout.java | 4 +- .../gui}/WindowAssignNetClass.java | 14 +- .../gui}/WindowAutorouteDetailParameter.java | 16 +- .../gui}/WindowAutorouteParameter.java | 20 +- .../gui}/WindowClearanceMatrix.java | 36 ++-- .../gui}/WindowClearanceViolations.java | 38 ++-- .../freerouting/gui}/WindowComponents.java | 18 +- .../freerouting/gui}/WindowDisplayMisc.java | 24 +-- .../net/freerouting/gui}/WindowEditVias.java | 28 +-- .../freerouting/gui}/WindowIncompletes.java | 8 +- .../gui}/WindowLayerVisibility.java | 8 +- .../gui}/WindowLengthViolations.java | 18 +- .../freerouting/gui}/WindowManualRules.java | 12 +- .../net/freerouting/gui}/WindowMessage.java | 2 +- .../freerouting/gui}/WindowMoveParameter.java | 6 +- .../freerouting/gui}/WindowNetClasses.java | 52 +++--- .../gui}/WindowNetDemonstrations.java | 2 +- .../gui}/WindowNetSampleDesigns.java | 2 +- .../freerouting/gui}/WindowNetSamples.java | 6 +- .../java/net/freerouting/gui}/WindowNets.java | 26 +-- .../freerouting/gui}/WindowObjectInfo.java | 34 ++-- .../freerouting/gui}/WindowObjectList.java | 6 +- .../gui}/WindowObjectListWithFilter.java | 4 +- .../gui}/WindowObjectVisibility.java | 8 +- .../net/freerouting/gui}/WindowPackages.java | 18 +- .../net/freerouting/gui}/WindowPadstacks.java | 22 +-- .../freerouting/gui}/WindowRouteDetail.java | 9 +- .../gui}/WindowRouteParameter.java | 46 ++--- .../freerouting/gui}/WindowRouteStubs.java | 30 +-- .../gui}/WindowSelectParameter.java | 16 +- .../net/freerouting/gui}/WindowSnapshot.java | 16 +- .../gui}/WindowSnapshotSettings.java | 8 +- .../gui}/WindowUnconnectedRoute.java | 26 +-- .../java/net/freerouting/gui}/WindowVia.java | 50 ++--- .../net/freerouting/gui}/WindowViaRule.java | 10 +- .../freerouting/gui}/WindowVisibility.java | 6 +- .../java/net/freerouting/gui}/package.html | 0 .../java/net/freerouting/helpset}/de/Help.hs | 0 .../net/freerouting/helpset}/de/HelpIndex.xml | 0 .../net/freerouting/helpset}/de/HelpTOC.xml | 0 .../helpset}/de/JavaHelpSearch/DOCS | Bin .../helpset}/de/JavaHelpSearch/DOCS.TAB | Bin .../helpset}/de/JavaHelpSearch/OFFSETS | 0 .../helpset}/de/JavaHelpSearch/POSITIONS | Bin .../helpset}/de/JavaHelpSearch/SCHEMA | 0 .../helpset}/de/JavaHelpSearch/TMAP | Bin .../java/net/freerouting/helpset}/de/Map.jhm | 0 .../helpset}/de/html_files/FileMenu.html | 0 .../helpset}/de/html_files/MenuState.html | 0 .../helpset}/de/html_files/MoveItemState.html | 0 .../helpset}/de/html_files/RouteState.html | 0 .../de/html_files/SelectedItemState.html | 0 .../WindowAutorouteDetailParameter.html | 0 .../html_files/WindowAutorouteParameter.html | 0 .../de/html_files/WindowClearanceMatrix.html | 0 .../helpset}/de/html_files/WindowDisplay.html | 0 .../de/html_files/WindowManualRules.html | 0 .../de/html_files/WindowMoveParameter.html | 0 .../de/html_files/WindowNetClasses.html | 0 .../de/html_files/WindowObjectList.html | 0 .../de/html_files/WindowRouteParameter.html | 0 .../de/html_files/WindowSelectParameter.html | 0 .../de/html_files/WindowSnapshots.html | 0 .../helpset}/de/html_files/WindowVia.html | 0 .../net/freerouting/helpset}/de/index.html | 0 .../java/net/freerouting/helpset}/en/Help.hs | 0 .../net/freerouting/helpset}/en/HelpIndex.xml | 0 .../net/freerouting/helpset}/en/HelpTOC.xml | 0 .../helpset}/en/JavaHelpSearch/DOCS | Bin .../helpset}/en/JavaHelpSearch/DOCS.TAB | 0 .../helpset}/en/JavaHelpSearch/OFFSETS | 0 .../helpset}/en/JavaHelpSearch/POSITIONS | Bin .../helpset}/en/JavaHelpSearch/SCHEMA | 0 .../helpset}/en/JavaHelpSearch/TMAP | Bin .../java/net/freerouting/helpset}/en/Map.jhm | 0 .../helpset}/en/html_files/FileMenu.html | 0 .../helpset}/en/html_files/MenuState.html | 0 .../helpset}/en/html_files/MoveItemState.html | 0 .../helpset}/en/html_files/RouteState.html | 0 .../en/html_files/SelectedItemState.html | 0 .../WindowAutorouteDetailParameter.html | 0 .../html_files/WindowAutorouteParameter.html | 0 .../en/html_files/WindowClearanceMatrix.html | 0 .../helpset}/en/html_files/WindowDisplay.html | 0 .../en/html_files/WindowManualRules.html | 0 .../en/html_files/WindowMoveParameter.html | 0 .../en/html_files/WindowNetClasses.html | 0 .../en/html_files/WindowObjectList.html | 0 .../en/html_files/WindowRouteParameter.html | 0 .../en/html_files/WindowSelectParameter.html | 0 .../en/html_files/WindowSnapshots.html | 0 .../helpset}/en/html_files/WindowVia.html | 0 .../freerouting/helpset}/en/images/popup.gif | Bin .../net/freerouting/helpset}/en/index.html | 0 .../interactive}/AutorouteSettings.java | 6 +- .../interactive}/BatchAutorouterThread.java | 20 +- .../interactive}/BoardHandling.java | 78 ++++---- .../interactive}/CircleConstructionState.java | 18 +- .../interactive}/ClearanceViolations.java | 8 +- .../interactive}/CopyItemState.java | 30 +-- .../CornerItemConstructionState.java | 8 +- .../interactive}/CutoutRouteState.java | 14 +- .../interactive}/DragItemState.java | 14 +- .../interactive}/DragMenuState.java | 4 +- .../freerouting/interactive}/DragState.java | 10 +- .../interactive}/DynamicRouteState.java | 4 +- .../interactive}/ExpandTestState.java | 28 +-- .../interactive}/HoleConstructionState.java | 28 +-- .../interactive}/InteractiveActionThread.java | 6 +- .../interactive}/InteractiveState.java | 8 +- .../net/freerouting/interactive}/Logfile.java | 4 +- .../interactive}/LogfileDescription.flex | 0 .../interactive}/LogfileScanner.java | 2 +- .../interactive}/LogfileScope.java | 14 +- .../interactive}/MakeSpaceState.java | 16 +- .../freerouting/interactive}/MenuState.java | 18 +- .../interactive}/MoveItemState.java | 40 ++-- .../interactive}/NetIncompletes.java | 23 +-- .../interactive}/PinSwapState.java | 10 +- .../PolygonShapeConstructionState.java | 12 +- .../freerouting/interactive}/RatsNest.java | 34 ++-- .../net/freerouting/interactive}/Route.java | 88 ++++----- .../interactive}/RouteMenuState.java | 4 +- .../freerouting/interactive}/RouteState.java | 45 +++-- .../interactive}/ScreenMessages.java | 6 +- .../SelectItemsInRegionState.java | 10 +- .../interactive}/SelectMenuState.java | 4 +- .../interactive}/SelectRegionState.java | 4 +- .../interactive}/SelectedItemState.java | 50 ++--- .../freerouting/interactive}/Settings.java | 6 +- .../freerouting/interactive}/SnapShot.java | 16 +- .../interactive}/StitchRouteState.java | 8 +- .../interactive}/TileConstructionState.java | 20 +- .../interactive}/ZoomRegionState.java | 6 +- .../net/freerouting/interactive}/package.html | 0 .../freerouting/library}/BoardLibrary.java | 14 +- .../net/freerouting/library}/LogicalPart.java | 8 +- .../freerouting/library}/LogicalParts.java | 2 +- .../net/freerouting/library}/Package.java | 14 +- .../net/freerouting/library}/Packages.java | 4 +- .../net/freerouting/library}/Padstack.java | 16 +- .../net/freerouting/library}/Padstacks.java | 8 +- .../net/freerouting/library}/package.html | 0 .../net/freerouting/rules}/BoardRules.java | 44 ++--- .../freerouting/rules}/ClearanceMatrix.java | 14 +- .../rules}/DefaultItemClearanceClasses.java | 2 +- .../main/java/net/freerouting/rules}/Net.java | 40 ++-- .../java/net/freerouting/rules}/NetClass.java | 12 +- .../net/freerouting/rules}/NetClasses.java | 8 +- .../java/net/freerouting/rules}/Nets.java | 10 +- .../java/net/freerouting/rules}/ViaInfo.java | 10 +- .../java/net/freerouting/rules}/ViaInfos.java | 8 +- .../java/net/freerouting/rules}/ViaRule.java | 10 +- .../java/net/freerouting/rules}/package.html | 0 .../java/net/freerouting/tests}/Validate.java | 28 +-- .../java/net/freerouting/tests}/package.html | 0 .../board}/FixedState_de.properties | 0 .../board}/FixedState_en.properties | 0 .../board}/ObjectInfoPanel_de.properties | 0 .../board}/ObjectInfoPanel_en.properties | 0 .../ColorTableModel_de.properties | 0 .../ColorTableModel_en.properties | 0 .../freerouting/gui}/BoardFrame_de.properties | 0 .../freerouting/gui}/BoardFrame_en.properties | 0 .../gui}/BoardMenuDisplay_de.properties | 0 .../gui}/BoardMenuDisplay_en.properties | 0 .../gui}/BoardMenuFile_de.properties | 0 .../gui}/BoardMenuFile_en.properties | 0 .../gui}/BoardMenuHelp_de.properties | 0 .../gui}/BoardMenuHelp_en.properties | 0 .../gui}/BoardMenuInfo_de.properties | 0 .../gui}/BoardMenuInfo_en.properties | 0 .../gui}/BoardMenuOther_de.properties | 0 .../gui}/BoardMenuOther_en.properties | 0 .../gui}/BoardMenuParameter_de.properties | 0 .../gui}/BoardMenuParameter_en.properties | 0 .../gui}/BoardMenuRules_de.properties | 0 .../gui}/BoardMenuRules_en.properties | 0 .../gui}/BoardPanelStatus_de.properties | 0 .../gui}/BoardPanelStatus_en.properties | 0 .../BoardToolbarSelectedItem_de.properties | 0 .../BoardToolbarSelectedItem_en.properties | 0 .../gui}/BoardToolbar_de.properties | 0 .../gui}/BoardToolbar_en.properties | 0 .../gui}/CleanupWindows_de.properties | 0 .../gui}/CleanupWindows_en.properties | 0 .../freerouting/gui}/Default_de.properties | 0 .../freerouting/gui}/Default_en.properties | 0 .../gui}/DisplayMisc_de.properties | 0 .../gui}/DisplayMisc_en.properties | 0 .../gui}/MainApplication_de.properties | 0 .../gui}/MainApplication_en.properties | 0 .../gui}/PopupMenuMain_de.properties | 0 .../gui}/PopupMenuMain_en.properties | 0 .../gui}/PopupMenuMove_de.properties | 0 .../gui}/PopupMenuMove_en.properties | 0 .../gui}/WindowAbout_de.properties | 0 .../gui}/WindowAbout_en.properties | 0 .../gui}/WindowAssignNetClass_de.properties | 0 .../gui}/WindowAssignNetClass_en.properties | 0 .../WindowAutorouteParameter_de.properties | 0 .../WindowAutorouteParameter_en.properties | 0 .../gui}/WindowClearanceMatrix_de.properties | 0 .../gui}/WindowClearanceMatrix_en.properties | 0 .../WindowClearanceViolations_de.properties | 0 .../WindowClearanceViolations_en.properties | 0 .../gui}/WindowEditVias_de.properties | 0 .../gui}/WindowEditVias_en.properties | 0 .../gui}/WindowLengthViolations_de.properties | 0 .../gui}/WindowLengthViolations_en.properties | 0 .../gui}/WindowManualRule_de.properties | 0 .../gui}/WindowManualRule_en.properties | 0 .../gui}/WindowMoveParameter_de.properties | 0 .../gui}/WindowMoveParameter_en.properties | 0 .../gui}/WindowNetClasses_de.properties | 0 .../gui}/WindowNetClasses_en.properties | 0 .../gui}/WindowNetSamples_de.properties | 0 .../gui}/WindowNetSamples_en.properties | 0 .../freerouting/gui}/WindowNets_de.properties | 0 .../freerouting/gui}/WindowNets_en.properties | 0 .../gui}/WindowObjectInfo_de.properties | 0 .../gui}/WindowObjectInfo_en.properties | 0 .../gui}/WindowObjectList_de.properties | 0 .../gui}/WindowObjectList_en.properties | 0 .../gui}/WindowObjectVisibility_de.properties | 0 .../gui}/WindowObjectVisibility_en.properties | 0 .../gui}/WindowRouteDetail_de.properties | 0 .../gui}/WindowRouteDetail_en.properties | 0 .../gui}/WindowRouteParameter_de.properties | 0 .../gui}/WindowRouteParameter_en.properties | 0 .../gui}/WindowSelectParameter_de.properties | 0 .../gui}/WindowSelectParameter_en.properties | 0 .../gui}/WindowSnapshotSettings_de.properties | 0 .../gui}/WindowSnapshotSettings_en.properties | 0 .../gui}/WindowSnapshot_de.properties | 0 .../gui}/WindowSnapshot_en.properties | 0 .../gui}/WindowViaRule_de.properties | 0 .../gui}/WindowViaRule_en.properties | 0 .../freerouting/gui}/WindowVia_de.properties | 0 .../freerouting/gui}/WindowVia_en.properties | 0 .../interactive}/BoardHandling_de.properties | 0 .../interactive}/BoardHandling_en.properties | 0 .../InteractiveState_de.properties | 0 .../InteractiveState_en.properties | 0 .../interactive}/RatsNest_de.properties | 0 .../interactive}/RatsNest_en.properties | 0 .../interactive}/ScreenMessages_de.properties | 0 .../interactive}/ScreenMessages_en.properties | 0 .../freerouting/rules}/Default_de.properties | 0 .../freerouting/rules}/Default_en.properties | 0 476 files changed, 2397 insertions(+), 2329 deletions(-) create mode 100644 .gitignore create mode 100644 pom.xml rename {autoroute => src/main/java/net/freerouting/autoroute}/AutorouteControl.java (93%) rename {autoroute => src/main/java/net/freerouting/autoroute}/AutorouteEngine.java (97%) rename {autoroute => src/main/java/net/freerouting/autoroute}/BatchAutorouter.java (94%) rename {autoroute => src/main/java/net/freerouting/autoroute}/BatchFanout.java (85%) rename {autoroute => src/main/java/net/freerouting/autoroute}/BatchOptRoute.java (96%) rename {autoroute => src/main/java/net/freerouting/autoroute}/CompleteExpansionRoom.java (83%) rename {autoroute => src/main/java/net/freerouting/autoroute}/CompleteFreeSpaceExpansionRoom.java (94%) rename {autoroute => src/main/java/net/freerouting/autoroute}/Connection.java (98%) rename {autoroute => src/main/java/net/freerouting/autoroute}/DestinationDistance.java (98%) rename {autoroute => src/main/java/net/freerouting/autoroute}/DrillPage.java (90%) rename {autoroute => src/main/java/net/freerouting/autoroute}/DrillPageArray.java (94%) rename {autoroute => src/main/java/net/freerouting/autoroute}/ExpandableObject.java (95%) rename {autoroute => src/main/java/net/freerouting/autoroute}/ExpansionDoor.java (97%) rename {autoroute => src/main/java/net/freerouting/autoroute}/ExpansionDrill.java (91%) rename {autoroute => src/main/java/net/freerouting/autoroute}/ExpansionRoom.java (95%) rename {autoroute => src/main/java/net/freerouting/autoroute}/FreeSpaceExpansionRoom.java (97%) rename {autoroute => src/main/java/net/freerouting/autoroute}/IncompleteFreeSpaceExpansionRoom.java (95%) rename {autoroute => src/main/java/net/freerouting/autoroute}/InsertFoundConnectionAlgo.java (94%) rename {autoroute => src/main/java/net/freerouting/autoroute}/ItemAutorouteInfo.java (94%) rename {autoroute => src/main/java/net/freerouting/autoroute}/LocateFoundConnectionAlgo.java (97%) rename {autoroute => src/main/java/net/freerouting/autoroute}/LocateFoundConnectionAlgo45Degree.java (96%) rename {autoroute => src/main/java/net/freerouting/autoroute}/LocateFoundConnectionAlgoAnyAngle.java (98%) rename {autoroute => src/main/java/net/freerouting/autoroute}/MazeListElement.java (97%) rename {autoroute => src/main/java/net/freerouting/autoroute}/MazeSearchAlgo.java (93%) rename {autoroute => src/main/java/net/freerouting/autoroute}/MazeSearchElement.java (97%) rename {autoroute => src/main/java/net/freerouting/autoroute}/MazeShoveTraceAlgo.java (92%) rename {autoroute => src/main/java/net/freerouting/autoroute}/ObstacleExpansionRoom.java (93%) rename {autoroute => src/main/java/net/freerouting/autoroute}/Sorted45DegreeRoomNeighbours.java (98%) rename {autoroute => src/main/java/net/freerouting/autoroute}/SortedOrthogonalRoomNeighbours.java (98%) rename {autoroute => src/main/java/net/freerouting/autoroute}/SortedRoomNeighbours.java (98%) rename {autoroute => src/main/java/net/freerouting/autoroute}/TargetItemExpansionDoor.java (91%) rename {autoroute => src/main/java/net/freerouting/autoroute}/package.html (100%) rename {board => src/main/java/net/freerouting/board}/AngleRestriction.java (98%) rename {board => src/main/java/net/freerouting/board}/BasicBoard.java (98%) rename {board => src/main/java/net/freerouting/board}/BoardObserverAdaptor.java (98%) rename {board => src/main/java/net/freerouting/board}/BoardObservers.java (92%) rename {board => src/main/java/net/freerouting/board}/BoardOutline.java (93%) rename {board => src/main/java/net/freerouting/board}/CalcFromSide.java (94%) rename {board => src/main/java/net/freerouting/board}/CalcShapeAndFromSide.java (95%) rename {board => src/main/java/net/freerouting/board}/ChangedArea.java (94%) rename {board => src/main/java/net/freerouting/board}/ClearanceViolation.java (92%) rename {board => src/main/java/net/freerouting/board}/Communication.java (94%) rename {board => src/main/java/net/freerouting/board}/Component.java (93%) rename {board => src/main/java/net/freerouting/board}/ComponentObstacleArea.java (88%) rename {board => src/main/java/net/freerouting/board}/ComponentOutline.java (92%) rename {board => src/main/java/net/freerouting/board}/Components.java (96%) rename {board => src/main/java/net/freerouting/board}/ConductionArea.java (91%) rename {board => src/main/java/net/freerouting/board}/Connectable.java (96%) rename {board => src/main/java/net/freerouting/board}/CoordinateTransform.java (77%) rename {board => src/main/java/net/freerouting/board}/DrillItem.java (96%) rename {board => src/main/java/net/freerouting/board}/FixedState.java (96%) rename {board => src/main/java/net/freerouting/board}/ForcedPadAlgo.java (97%) rename {board => src/main/java/net/freerouting/board}/ForcedViaAlgo.java (94%) rename {board => src/main/java/net/freerouting/board}/Item.java (96%) rename {board => src/main/java/net/freerouting/board}/ItemIdNoGenerator.java (91%) rename {board => src/main/java/net/freerouting/board}/ItemSearchTreesInfo.java (96%) rename {board => src/main/java/net/freerouting/board}/ItemSelectionFilter.java (95%) rename {board => src/main/java/net/freerouting/board}/Layer.java (97%) rename {board => src/main/java/net/freerouting/board}/LayerStructure.java (99%) rename {board => src/main/java/net/freerouting/board}/MoveComponent.java (96%) rename {board => src/main/java/net/freerouting/board}/MoveDrillItemAlgo.java (96%) rename {board => src/main/java/net/freerouting/board}/ObjectInfoPanel.java (92%) rename {board => src/main/java/net/freerouting/board}/ObstacleArea.java (93%) rename {board => src/main/java/net/freerouting/board}/OptViaAlgo.java (98%) rename {board => src/main/java/net/freerouting/board}/Pin.java (95%) rename {board => src/main/java/net/freerouting/board}/PolylineTrace.java (98%) rename {board => src/main/java/net/freerouting/board}/PrintableShape.java (90%) rename {board => src/main/java/net/freerouting/board}/PullTightAlgo.java (97%) rename {board => src/main/java/net/freerouting/board}/PullTightAlgo45.java (98%) rename {board => src/main/java/net/freerouting/board}/PullTightAlgo90.java (95%) rename {board => src/main/java/net/freerouting/board}/PullTightAlgoAnyAngle.java (98%) rename {board => src/main/java/net/freerouting/board}/RoutingBoard.java (97%) rename {board => src/main/java/net/freerouting/board}/SearchTreeManager.java (97%) rename {board => src/main/java/net/freerouting/board}/SearchTreeObject.java (91%) rename {board => src/main/java/net/freerouting/board}/ShapeSearchTree.java (97%) rename {board => src/main/java/net/freerouting/board}/ShapeSearchTree45Degree.java (97%) rename {board => src/main/java/net/freerouting/board}/ShapeSearchTree90Degree.java (97%) rename {board => src/main/java/net/freerouting/board}/ShapeTraceEntries.java (99%) rename {board => src/main/java/net/freerouting/board}/ShoveTraceAlgo.java (97%) rename {board => src/main/java/net/freerouting/board}/TestLevel.java (96%) rename {board => src/main/java/net/freerouting/board}/Trace.java (95%) rename {board => src/main/java/net/freerouting/board}/Unit.java (99%) rename {board => src/main/java/net/freerouting/board}/Via.java (88%) rename {board => src/main/java/net/freerouting/board}/ViaObstacleArea.java (88%) rename {board => src/main/java/net/freerouting/board}/package.html (100%) rename {boardgraphics => src/main/java/net/freerouting/boardgraphics}/ColorIntensityTable.java (98%) rename {boardgraphics => src/main/java/net/freerouting/boardgraphics}/ColorTableModel.java (98%) rename {boardgraphics => src/main/java/net/freerouting/boardgraphics}/CoordinateTransform.java (98%) rename {boardgraphics => src/main/java/net/freerouting/boardgraphics}/Drawable.java (98%) rename {boardgraphics => src/main/java/net/freerouting/boardgraphics}/GraphicsContext.java (98%) rename {boardgraphics => src/main/java/net/freerouting/boardgraphics}/ItemColorTableModel.java (97%) rename {boardgraphics => src/main/java/net/freerouting/boardgraphics}/ItemDrawInfo.java (96%) rename {boardgraphics => src/main/java/net/freerouting/boardgraphics}/OtherColorTableModel.java (97%) rename {boardgraphics => src/main/java/net/freerouting/boardgraphics}/package.html (100%) rename {datastructures => src/main/java/net/freerouting/datastructures}/ArrayStack.java (98%) rename {datastructures => src/main/java/net/freerouting/datastructures}/BigIntAux.java (99%) rename {datastructures => src/main/java/net/freerouting/datastructures}/FileFilter.java (98%) rename {datastructures => src/main/java/net/freerouting/datastructures}/IdNoGenerator.java (96%) rename {datastructures => src/main/java/net/freerouting/datastructures}/IdentifierType.java (98%) rename {datastructures => src/main/java/net/freerouting/datastructures}/IndentFileWriter.java (98%) rename {datastructures => src/main/java/net/freerouting/datastructures}/MinAreaTree.java (98%) rename {datastructures => src/main/java/net/freerouting/datastructures}/Observers.java (97%) rename {datastructures => src/main/java/net/freerouting/datastructures}/PlanarDelaunayTriangulation.java (99%) rename {datastructures => src/main/java/net/freerouting/datastructures}/ShapeTree.java (97%) rename {datastructures => src/main/java/net/freerouting/datastructures}/Signum.java (98%) rename {datastructures => src/main/java/net/freerouting/datastructures}/Stoppable.java (96%) rename {datastructures => src/main/java/net/freerouting/datastructures}/TimeLimit.java (97%) rename {datastructures => src/main/java/net/freerouting/datastructures}/UndoableObjects.java (99%) rename {datastructures => src/main/java/net/freerouting/datastructures}/package.html (100%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/AutorouteSettings.java (91%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Circle.java (84%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Circuit.java (99%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Component.java (91%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/ComponentPlacement.java (98%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/CoordinateTransform.java (90%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/DsnFile.java (82%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Keyword.java (97%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Layer.java (95%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/LayerStructure.java (92%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Library.java (79%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Net.java (80%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/NetClass.java (99%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/NetList.java (98%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Network.java (86%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Package.java (94%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Parser.java (96%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/PartLibrary.java (96%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Path.java (89%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/PlaceControl.java (98%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Placement.java (96%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Plane.java (82%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Polygon.java (86%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/PolygonPath.java (87%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/PolylinePath.java (88%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/ReadScopeParameter.java (77%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Rectangle.java (89%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Resolution.java (89%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Rule.java (94%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/RulesFile.java (92%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Scanner.java (95%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/ScopeKeyword.java (98%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/SessionFile.java (84%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/SessionToEagle.java (94%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Shape.java (94%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/SpecctraFileDescription.flex (100%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/SpecctraFileScanner.java (99%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/SpecctraFileScanner.java~ (100%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Structure.java (89%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/Wiring.java (85%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/WriteScopeParameter.java (81%) rename {designformats => src/main/java/net/freerouting/designformats}/specctra/package.html (100%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Area.java (98%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/BigIntDirection.java (98%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Circle.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/ConvexShape.java (97%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Direction.java (98%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Ellipse.java (97%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/FloatLine.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/FloatPoint.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/FortyfiveDegreeBoundingDirections.java (97%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/FortyfiveDegreeDirection.java (97%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/IntBox.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/IntDirection.java (98%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/IntOctagon.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/IntPoint.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/IntVector.java (98%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Limits.java (97%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Line.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/LineSegment.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/OrthogonalBoundingDirections.java (97%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Point.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Polygon.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/PolygonShape.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Polyline.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/PolylineArea.java (98%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/PolylineShape.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/RationalPoint.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/RationalVector.java (98%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/RegularTileShape.java (98%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Shape.java (98%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/ShapeBoundingDirections.java (97%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Side.java (98%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Simplex.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/TileShape.java (99%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/Vector.java (98%) rename {geometry => src/main/java/net/freerouting/geometry}/planar/package.html (100%) rename {gui => src/main/java/net/freerouting/gui}/BoardFrame.java (96%) rename {gui => src/main/java/net/freerouting/gui}/BoardMenuBar.java (98%) rename {gui => src/main/java/net/freerouting/gui}/BoardMenuDisplay.java (96%) rename {gui => src/main/java/net/freerouting/gui}/BoardMenuFile.java (94%) rename {gui => src/main/java/net/freerouting/gui}/BoardMenuHelp.java (95%) rename {gui => src/main/java/net/freerouting/gui}/BoardMenuHelpReduced.java (91%) rename {gui => src/main/java/net/freerouting/gui}/BoardMenuInfo.java (97%) rename {gui => src/main/java/net/freerouting/gui}/BoardMenuOther.java (92%) rename {gui => src/main/java/net/freerouting/gui}/BoardMenuParameter.java (95%) rename {gui => src/main/java/net/freerouting/gui}/BoardMenuRules.java (95%) rename {gui => src/main/java/net/freerouting/gui}/BoardPanel.java (97%) rename {gui => src/main/java/net/freerouting/gui}/BoardPanelStatus.java (96%) rename {gui => src/main/java/net/freerouting/gui}/BoardSavableSubWindow.java (98%) rename {gui => src/main/java/net/freerouting/gui}/BoardSubWindow.java (97%) rename {gui => src/main/java/net/freerouting/gui}/BoardTemporarySubWindow.java (98%) rename {gui => src/main/java/net/freerouting/gui}/BoardToolbar.java (94%) rename {gui => src/main/java/net/freerouting/gui}/BoardToolbarSelectedItem.java (97%) rename {gui => src/main/java/net/freerouting/gui}/ColorManager.java (96%) rename {gui => src/main/java/net/freerouting/gui}/ComboBoxClearance.java (97%) rename {gui => src/main/java/net/freerouting/gui}/ComboBoxLayer.java (91%) rename {gui => src/main/java/net/freerouting/gui}/Cursor.java (99%) rename {gui => src/main/java/net/freerouting/gui}/DesignFile.java (94%) rename {gui => src/main/java/net/freerouting/gui}/GUIDefaultsDescription.flex (100%) rename {gui => src/main/java/net/freerouting/gui}/GUIDefaultsFile.java (98%) rename {gui => src/main/java/net/freerouting/gui}/GUIDefaultsScanner.java (99%) rename {gui => src/main/java/net/freerouting/gui}/GUIDefaultsScanner.java~ (100%) rename {gui => src/main/java/net/freerouting/gui}/MainApplication.java (97%) rename {gui => src/main/java/net/freerouting/gui}/PopupMenuChangeLayer.java (90%) rename {gui => src/main/java/net/freerouting/gui}/PopupMenuCopy.java (87%) rename {gui => src/main/java/net/freerouting/gui}/PopupMenuDisplay.java (95%) rename {gui => src/main/java/net/freerouting/gui}/PopupMenuDynamicRoute.java (88%) rename {gui => src/main/java/net/freerouting/gui}/PopupMenuInsertCancel.java (93%) rename {gui => src/main/java/net/freerouting/gui}/PopupMenuMain.java (96%) rename {gui => src/main/java/net/freerouting/gui}/PopupMenuMove.java (93%) rename {gui => src/main/java/net/freerouting/gui}/PopupMenuSelectedItems.java (91%) rename {gui => src/main/java/net/freerouting/gui}/PopupMenuStitchRoute.java (88%) rename {gui => src/main/java/net/freerouting/gui}/PupupMenuCornerItemConstruction.java (95%) rename {gui => src/main/java/net/freerouting/gui}/WebStart.java (99%) rename {gui => src/main/java/net/freerouting/gui}/WindowAbout.java (95%) rename {gui => src/main/java/net/freerouting/gui}/WindowAssignNetClass.java (91%) rename {gui => src/main/java/net/freerouting/gui}/WindowAutorouteDetailParameter.java (96%) rename {gui => src/main/java/net/freerouting/gui}/WindowAutorouteParameter.java (92%) rename {gui => src/main/java/net/freerouting/gui}/WindowClearanceMatrix.java (91%) rename {gui => src/main/java/net/freerouting/gui}/WindowClearanceViolations.java (76%) rename {gui => src/main/java/net/freerouting/gui}/WindowComponents.java (78%) rename {gui => src/main/java/net/freerouting/gui}/WindowDisplayMisc.java (94%) rename {gui => src/main/java/net/freerouting/gui}/WindowEditVias.java (90%) rename {gui => src/main/java/net/freerouting/gui}/WindowIncompletes.java (88%) rename {gui => src/main/java/net/freerouting/gui}/WindowLayerVisibility.java (88%) rename {gui => src/main/java/net/freerouting/gui}/WindowLengthViolations.java (86%) rename {gui => src/main/java/net/freerouting/gui}/WindowManualRules.java (95%) rename {gui => src/main/java/net/freerouting/gui}/WindowMessage.java (99%) rename {gui => src/main/java/net/freerouting/gui}/WindowMoveParameter.java (97%) rename {gui => src/main/java/net/freerouting/gui}/WindowNetClasses.java (92%) rename {gui => src/main/java/net/freerouting/gui}/WindowNetDemonstrations.java (99%) rename {gui => src/main/java/net/freerouting/gui}/WindowNetSampleDesigns.java (98%) rename {gui => src/main/java/net/freerouting/gui}/WindowNetSamples.java (97%) rename {gui => src/main/java/net/freerouting/gui}/WindowNets.java (82%) rename {gui => src/main/java/net/freerouting/gui}/WindowObjectInfo.java (90%) rename {gui => src/main/java/net/freerouting/gui}/WindowObjectList.java (97%) rename {gui => src/main/java/net/freerouting/gui}/WindowObjectListWithFilter.java (96%) rename {gui => src/main/java/net/freerouting/gui}/WindowObjectVisibility.java (86%) rename {gui => src/main/java/net/freerouting/gui}/WindowPackages.java (79%) rename {gui => src/main/java/net/freerouting/gui}/WindowPadstacks.java (76%) rename {gui => src/main/java/net/freerouting/gui}/WindowRouteDetail.java (96%) rename {gui => src/main/java/net/freerouting/gui}/WindowRouteParameter.java (93%) rename {gui => src/main/java/net/freerouting/gui}/WindowRouteStubs.java (84%) rename {gui => src/main/java/net/freerouting/gui}/WindowSelectParameter.java (93%) rename {gui => src/main/java/net/freerouting/gui}/WindowSnapshot.java (93%) rename {gui => src/main/java/net/freerouting/gui}/WindowSnapshotSettings.java (97%) rename {gui => src/main/java/net/freerouting/gui}/WindowUnconnectedRoute.java (81%) rename {gui => src/main/java/net/freerouting/gui}/WindowVia.java (89%) rename {gui => src/main/java/net/freerouting/gui}/WindowViaRule.java (96%) rename {gui => src/main/java/net/freerouting/gui}/WindowVisibility.java (96%) rename {gui => src/main/java/net/freerouting/gui}/package.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/Help.hs (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/HelpIndex.xml (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/HelpTOC.xml (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/JavaHelpSearch/DOCS (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/JavaHelpSearch/DOCS.TAB (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/JavaHelpSearch/OFFSETS (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/JavaHelpSearch/POSITIONS (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/JavaHelpSearch/SCHEMA (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/JavaHelpSearch/TMAP (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/Map.jhm (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/FileMenu.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/MenuState.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/MoveItemState.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/RouteState.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/SelectedItemState.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowAutorouteDetailParameter.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowAutorouteParameter.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowClearanceMatrix.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowDisplay.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowManualRules.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowMoveParameter.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowNetClasses.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowObjectList.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowRouteParameter.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowSelectParameter.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowSnapshots.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/html_files/WindowVia.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/de/index.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/Help.hs (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/HelpIndex.xml (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/HelpTOC.xml (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/JavaHelpSearch/DOCS (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/JavaHelpSearch/DOCS.TAB (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/JavaHelpSearch/OFFSETS (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/JavaHelpSearch/POSITIONS (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/JavaHelpSearch/SCHEMA (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/JavaHelpSearch/TMAP (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/Map.jhm (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/FileMenu.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/MenuState.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/MoveItemState.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/RouteState.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/SelectedItemState.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowAutorouteDetailParameter.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowAutorouteParameter.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowClearanceMatrix.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowDisplay.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowManualRules.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowMoveParameter.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowNetClasses.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowObjectList.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowRouteParameter.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowSelectParameter.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowSnapshots.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/html_files/WindowVia.html (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/images/popup.gif (100%) rename {helpset => src/main/java/net/freerouting/helpset}/en/index.html (100%) rename {interactive => src/main/java/net/freerouting/interactive}/AutorouteSettings.java (98%) rename {interactive => src/main/java/net/freerouting/interactive}/BatchAutorouterThread.java (89%) rename {interactive => src/main/java/net/freerouting/interactive}/BoardHandling.java (95%) rename {interactive => src/main/java/net/freerouting/interactive}/CircleConstructionState.java (93%) rename {interactive => src/main/java/net/freerouting/interactive}/ClearanceViolations.java (93%) rename {interactive => src/main/java/net/freerouting/interactive}/CopyItemState.java (94%) rename {interactive => src/main/java/net/freerouting/interactive}/CornerItemConstructionState.java (96%) rename {interactive => src/main/java/net/freerouting/interactive}/CutoutRouteState.java (92%) rename {interactive => src/main/java/net/freerouting/interactive}/DragItemState.java (95%) rename {interactive => src/main/java/net/freerouting/interactive}/DragMenuState.java (94%) rename {interactive => src/main/java/net/freerouting/interactive}/DragState.java (96%) rename {interactive => src/main/java/net/freerouting/interactive}/DynamicRouteState.java (96%) rename {interactive => src/main/java/net/freerouting/interactive}/ExpandTestState.java (92%) rename {interactive => src/main/java/net/freerouting/interactive}/HoleConstructionState.java (89%) rename {interactive => src/main/java/net/freerouting/interactive}/InteractiveActionThread.java (97%) rename {interactive => src/main/java/net/freerouting/interactive}/InteractiveState.java (96%) rename {interactive => src/main/java/net/freerouting/interactive}/Logfile.java (98%) rename {interactive => src/main/java/net/freerouting/interactive}/LogfileDescription.flex (100%) rename {interactive => src/main/java/net/freerouting/interactive}/LogfileScanner.java (99%) rename {interactive => src/main/java/net/freerouting/interactive}/LogfileScope.java (98%) rename {interactive => src/main/java/net/freerouting/interactive}/MakeSpaceState.java (89%) rename {interactive => src/main/java/net/freerouting/interactive}/MenuState.java (91%) rename {interactive => src/main/java/net/freerouting/interactive}/MoveItemState.java (94%) rename {interactive => src/main/java/net/freerouting/interactive}/NetIncompletes.java (95%) rename {interactive => src/main/java/net/freerouting/interactive}/PinSwapState.java (96%) rename {interactive => src/main/java/net/freerouting/interactive}/PolygonShapeConstructionState.java (93%) rename {interactive => src/main/java/net/freerouting/interactive}/RatsNest.java (89%) rename {interactive => src/main/java/net/freerouting/interactive}/Route.java (92%) rename {interactive => src/main/java/net/freerouting/interactive}/RouteMenuState.java (95%) rename {interactive => src/main/java/net/freerouting/interactive}/RouteState.java (93%) rename {interactive => src/main/java/net/freerouting/interactive}/ScreenMessages.java (96%) rename {interactive => src/main/java/net/freerouting/interactive}/SelectItemsInRegionState.java (95%) rename {interactive => src/main/java/net/freerouting/interactive}/SelectMenuState.java (95%) rename {interactive => src/main/java/net/freerouting/interactive}/SelectRegionState.java (95%) rename {interactive => src/main/java/net/freerouting/interactive}/SelectedItemState.java (95%) rename {interactive => src/main/java/net/freerouting/interactive}/Settings.java (99%) rename {interactive => src/main/java/net/freerouting/interactive}/SnapShot.java (92%) rename {interactive => src/main/java/net/freerouting/interactive}/StitchRouteState.java (91%) rename {interactive => src/main/java/net/freerouting/interactive}/TileConstructionState.java (95%) rename {interactive => src/main/java/net/freerouting/interactive}/ZoomRegionState.java (93%) rename {interactive => src/main/java/net/freerouting/interactive}/package.html (100%) rename {library => src/main/java/net/freerouting/library}/BoardLibrary.java (90%) rename {library => src/main/java/net/freerouting/library}/LogicalPart.java (92%) rename {library => src/main/java/net/freerouting/library}/LogicalParts.java (98%) rename {library => src/main/java/net/freerouting/library}/Package.java (92%) rename {library => src/main/java/net/freerouting/library}/Packages.java (97%) rename {library => src/main/java/net/freerouting/library}/Padstack.java (90%) rename {library => src/main/java/net/freerouting/library}/Padstacks.java (94%) rename {library => src/main/java/net/freerouting/library}/package.html (100%) rename {rules => src/main/java/net/freerouting/rules}/BoardRules.java (91%) rename {rules => src/main/java/net/freerouting/rules}/ClearanceMatrix.java (95%) rename {rules => src/main/java/net/freerouting/rules}/DefaultItemClearanceClasses.java (98%) rename {rules => src/main/java/net/freerouting/rules}/Net.java (81%) rename {rules => src/main/java/net/freerouting/rules}/NetClass.java (95%) rename {rules => src/main/java/net/freerouting/rules}/NetClasses.java (92%) rename {rules => src/main/java/net/freerouting/rules}/Nets.java (94%) rename {rules => src/main/java/net/freerouting/rules}/ViaInfo.java (89%) rename {rules => src/main/java/net/freerouting/rules}/ViaInfos.java (91%) rename {rules => src/main/java/net/freerouting/rules}/ViaRule.java (91%) rename {rules => src/main/java/net/freerouting/rules}/package.html (100%) rename {tests => src/main/java/net/freerouting/tests}/Validate.java (93%) rename {tests => src/main/java/net/freerouting/tests}/package.html (100%) rename {board/resources => src/main/resources/net/freerouting/board}/FixedState_de.properties (100%) rename {board/resources => src/main/resources/net/freerouting/board}/FixedState_en.properties (100%) rename {board/resources => src/main/resources/net/freerouting/board}/ObjectInfoPanel_de.properties (100%) rename {board/resources => src/main/resources/net/freerouting/board}/ObjectInfoPanel_en.properties (100%) rename {boardgraphics/resources => src/main/resources/net/freerouting/boardgraphics}/ColorTableModel_de.properties (100%) rename {boardgraphics/resources => src/main/resources/net/freerouting/boardgraphics}/ColorTableModel_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardFrame_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardFrame_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuDisplay_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuDisplay_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuFile_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuFile_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuHelp_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuHelp_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuInfo_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuInfo_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuOther_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuOther_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuParameter_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuParameter_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuRules_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardMenuRules_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardPanelStatus_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardPanelStatus_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardToolbarSelectedItem_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardToolbarSelectedItem_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardToolbar_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/BoardToolbar_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/CleanupWindows_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/CleanupWindows_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/Default_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/Default_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/DisplayMisc_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/DisplayMisc_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/MainApplication_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/MainApplication_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/PopupMenuMain_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/PopupMenuMain_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/PopupMenuMove_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/PopupMenuMove_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowAbout_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowAbout_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowAssignNetClass_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowAssignNetClass_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowAutorouteParameter_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowAutorouteParameter_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowClearanceMatrix_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowClearanceMatrix_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowClearanceViolations_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowClearanceViolations_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowEditVias_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowEditVias_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowLengthViolations_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowLengthViolations_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowManualRule_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowManualRule_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowMoveParameter_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowMoveParameter_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowNetClasses_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowNetClasses_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowNetSamples_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowNetSamples_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowNets_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowNets_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowObjectInfo_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowObjectInfo_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowObjectList_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowObjectList_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowObjectVisibility_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowObjectVisibility_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowRouteDetail_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowRouteDetail_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowRouteParameter_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowRouteParameter_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowSelectParameter_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowSelectParameter_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowSnapshotSettings_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowSnapshotSettings_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowSnapshot_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowSnapshot_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowViaRule_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowViaRule_en.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowVia_de.properties (100%) rename {gui/resources => src/main/resources/net/freerouting/gui}/WindowVia_en.properties (100%) rename {interactive/resources => src/main/resources/net/freerouting/interactive}/BoardHandling_de.properties (100%) rename {interactive/resources => src/main/resources/net/freerouting/interactive}/BoardHandling_en.properties (100%) rename {interactive/resources => src/main/resources/net/freerouting/interactive}/InteractiveState_de.properties (100%) rename {interactive/resources => src/main/resources/net/freerouting/interactive}/InteractiveState_en.properties (100%) rename {interactive/resources => src/main/resources/net/freerouting/interactive}/RatsNest_de.properties (100%) rename {interactive/resources => src/main/resources/net/freerouting/interactive}/RatsNest_en.properties (100%) rename {interactive/resources => src/main/resources/net/freerouting/interactive}/ScreenMessages_de.properties (100%) rename {interactive/resources => src/main/resources/net/freerouting/interactive}/ScreenMessages_en.properties (100%) rename {rules/resources => src/main/resources/net/freerouting/rules}/Default_de.properties (100%) rename {rules/resources => src/main/resources/net/freerouting/rules}/Default_en.properties (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..ec105515 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +target/ +.idea/ +*.iml diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..2730d1f5 --- /dev/null +++ b/pom.xml @@ -0,0 +1,67 @@ + + 4.0.0 + + net.freerouting + freerouting + 1.0-SNAPSHOT + jar + + freerouting + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + javax.help + javahelp + 2.0.05 + + + javax.jnlp + jnlp-api + 7.0 + system + /usr/share/icedtea-web/netx.jar + + + + + + maven-assembly-plugin + 2.5.3 + + + jar-with-dependencies + + + + net.freerouting.gui.MainApplication + + + + + + + make-assembly + + package + + + single + + + + + + + diff --git a/autoroute/AutorouteControl.java b/src/main/java/net/freerouting/autoroute/AutorouteControl.java similarity index 93% rename from autoroute/AutorouteControl.java rename to src/main/java/net/freerouting/autoroute/AutorouteControl.java index d9f96111..07cf7e63 100644 --- a/autoroute/AutorouteControl.java +++ b/src/main/java/net/freerouting/autoroute/AutorouteControl.java @@ -17,14 +17,14 @@ * * Created on 25. Januar 2004, 09:38 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.ConvexShape; -import rules.ViaInfo; -import rules.ViaRule; +import net.freerouting.rules.ViaInfo; +import net.freerouting.rules.ViaRule; -import board.RoutingBoard; +import net.freerouting.board.RoutingBoard; /** * Structure for controlling the autoroute algorithm. @@ -35,21 +35,21 @@ public class AutorouteControl { /** Creates a new instance of AutorouteControl for the input net */ - public AutorouteControl(RoutingBoard p_board, int p_net_no, interactive.Settings p_settings) + public AutorouteControl(RoutingBoard p_board, int p_net_no, net.freerouting.interactive.Settings p_settings) { this(p_board, p_settings, p_settings.autoroute_settings.get_trace_cost_arr()); init_net(p_net_no, p_board, p_settings.autoroute_settings.get_via_costs()); } /** Creates a new instance of AutorouteControl for the input net */ - public AutorouteControl(RoutingBoard p_board, int p_net_no, interactive.Settings p_settings, int p_via_costs, ExpansionCostFactor[] p_trace_cost_arr) + public AutorouteControl(RoutingBoard p_board, int p_net_no, net.freerouting.interactive.Settings p_settings, int p_via_costs, ExpansionCostFactor[] p_trace_cost_arr) { this(p_board, p_settings, p_trace_cost_arr); init_net(p_net_no, p_board, p_via_costs); } /** Creates a new instance of AutorouteControl */ - private AutorouteControl(RoutingBoard p_board, interactive.Settings p_settings, + private AutorouteControl(RoutingBoard p_board, net.freerouting.interactive.Settings p_settings, ExpansionCostFactor[] p_trace_costs_arr) { layer_count = p_board.get_layer_count(); @@ -93,8 +93,8 @@ private AutorouteControl(RoutingBoard p_board, interactive.Settings p_settings, private void init_net(int p_net_no, RoutingBoard p_board, int p_via_costs) { net_no = p_net_no; - rules.Net curr_net = p_board.rules.nets.get(p_net_no); - rules.NetClass curr_net_class; + net.freerouting.rules.Net curr_net = p_board.rules.nets.get(p_net_no); + net.freerouting.rules.NetClass curr_net_class; if (curr_net != null) { curr_net_class = curr_net.get_class(); @@ -139,7 +139,7 @@ private void init_net(int p_net_no, RoutingBoard p_board, int p_via_costs) { this.attach_smd_allowed = true; } - library.Padstack curr_via_padstack = curr_via.get_padstack(); + net.freerouting.library.Padstack curr_via_padstack = curr_via.get_padstack(); int from_layer = curr_via_padstack.from_layer(); int to_layer = curr_via_padstack.to_layer(); for (int j = from_layer; j <= to_layer; ++j) diff --git a/autoroute/AutorouteEngine.java b/src/main/java/net/freerouting/autoroute/AutorouteEngine.java similarity index 97% rename from autoroute/AutorouteEngine.java rename to src/main/java/net/freerouting/autoroute/AutorouteEngine.java index 7b305ad3..b7fa2964 100644 --- a/autoroute/AutorouteEngine.java +++ b/src/main/java/net/freerouting/autoroute/AutorouteEngine.java @@ -17,11 +17,11 @@ * * Created on 11. Januar 2004, 11:14 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.Line; -import geometry.planar.Simplex; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Simplex; +import net.freerouting.geometry.planar.TileShape; import java.util.Collection; import java.util.Iterator; @@ -31,16 +31,16 @@ import java.util.Set; import java.util.SortedSet; -import datastructures.Stoppable; -import datastructures.TimeLimit; +import net.freerouting.datastructures.Stoppable; +import net.freerouting.datastructures.TimeLimit; -import board.SearchTreeObject; -import board.Item; -import board.RoutingBoard; -import board.ShapeSearchTree; -import board.ShapeSearchTree90Degree; -import board.ShapeSearchTree45Degree; -import board.TestLevel; +import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.Item; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.ShapeSearchTree90Degree; +import net.freerouting.board.ShapeSearchTree45Degree; +import net.freerouting.board.TestLevel; /** * Temporary autoroute data stored on the RoutingBoard. @@ -261,7 +261,7 @@ public void clear() /** * Draws the shapes of the expansion rooms created so far. */ - public void draw(java.awt.Graphics p_graphics, boardgraphics.GraphicsContext p_graphics_context, double p_intensity) + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { if (complete_expansion_rooms == null) { diff --git a/autoroute/BatchAutorouter.java b/src/main/java/net/freerouting/autoroute/BatchAutorouter.java similarity index 94% rename from autoroute/BatchAutorouter.java rename to src/main/java/net/freerouting/autoroute/BatchAutorouter.java index 5bdd0ca9..48d22db1 100644 --- a/autoroute/BatchAutorouter.java +++ b/src/main/java/net/freerouting/autoroute/BatchAutorouter.java @@ -13,7 +13,7 @@ * GNU General Public License at * for more details. */ -package autoroute; +package net.freerouting.autoroute; import java.util.Iterator; import java.util.Collection; @@ -21,19 +21,19 @@ import java.util.SortedSet; import java.util.TreeSet; -import datastructures.TimeLimit; -import datastructures.UndoableObjects; +import net.freerouting.datastructures.TimeLimit; +import net.freerouting.datastructures.UndoableObjects; -import geometry.planar.FloatPoint; -import geometry.planar.FloatLine; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatLine; -import board.Connectable; -import board.Item; -import board.DrillItem; -import board.RoutingBoard; +import net.freerouting.board.Connectable; +import net.freerouting.board.Item; +import net.freerouting.board.DrillItem; +import net.freerouting.board.RoutingBoard; -import interactive.BoardHandling; -import interactive.InteractiveActionThread; +import net.freerouting.interactive.BoardHandling; +import net.freerouting.interactive.InteractiveActionThread; /** * Handles the sequencing of the batch autoroute passes. @@ -112,7 +112,7 @@ public BatchAutorouter(InteractiveActionThread p_thread, boolean p_remove_unconn public boolean autoroute_passes() { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("interactive.resources.InteractiveState", hdlg.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", hdlg.get_locale()); boolean still_unrouted_items = true; while (still_unrouted_items && !this.is_interrupted) { @@ -228,7 +228,7 @@ private boolean autoroute_pass(int p_pass_no, boolean p_with_screen_message) } } } - if (routing_board.get_test_level() != board.TestLevel.ALL_DEBUGGING_OUTPUT) + if (routing_board.get_test_level() != net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT) { Item.StopConnectionOption stop_connection_option; if (this.remove_unconnected_vias) @@ -263,7 +263,7 @@ private boolean autoroute_item(Item p_item, int p_route_net_no, SortedSet try { boolean contains_plane = false; - rules.Net route_net = routing_board.rules.nets.get(p_route_net_no); + net.freerouting.rules.Net route_net = routing_board.rules.nets.get(p_route_net_no); if (route_net != null) { contains_plane = route_net.contains_plane(); @@ -296,7 +296,7 @@ private boolean autoroute_item(Item p_item, int p_route_net_no, SortedSet { for (Item curr_item : connected_set) { - if (curr_item instanceof board.ConductionArea) + if (curr_item instanceof net.freerouting.board.ConductionArea) { return true; // already connected to plane diff --git a/autoroute/BatchFanout.java b/src/main/java/net/freerouting/autoroute/BatchFanout.java similarity index 85% rename from autoroute/BatchFanout.java rename to src/main/java/net/freerouting/autoroute/BatchFanout.java index f1d968c4..77844995 100644 --- a/autoroute/BatchFanout.java +++ b/src/main/java/net/freerouting/autoroute/BatchFanout.java @@ -13,18 +13,18 @@ * GNU General Public License at * for more details. */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; import java.util.SortedSet; -import datastructures.TimeLimit; +import net.freerouting.datastructures.TimeLimit; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; -import board.RoutingBoard; +import net.freerouting.board.RoutingBoard; -import interactive.InteractiveActionThread; +import net.freerouting.interactive.InteractiveActionThread; /** * Handles the sequencing of the fanout inside the batch autorouter. @@ -52,11 +52,11 @@ private BatchFanout(InteractiveActionThread p_thread) { this.thread = p_thread; this.routing_board = p_thread.hdlg.get_routing_board(); - Collection board_smd_pin_list = routing_board.get_smd_pins(); + Collection board_smd_pin_list = routing_board.get_smd_pins(); this.sorted_components = new java.util.TreeSet(); for (int i = 1; i <= routing_board.components.count(); ++i) { - board.Component curr_board_component = routing_board.components.get(i); + net.freerouting.board.Component curr_board_component = routing_board.components.get(i); Component curr_component = new Component(curr_board_component, board_smd_pin_list); if (curr_component.smd_pin_count > 0) { @@ -109,7 +109,7 @@ else if (curr_result == AutorouteEngine.AutorouteResult.INSERT_ERROR) } --components_to_go; } - if (this.routing_board.get_test_level() != board.TestLevel.RELEASE_VERSION) + if (this.routing_board.get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { System.out.println("fanout pass: " + (p_pass_no + 1) + ", routed: " + routed_count + ", not routed: " + not_routed_count + ", errors: " + insert_error_count); @@ -123,14 +123,14 @@ else if (curr_result == AutorouteEngine.AutorouteResult.INSERT_ERROR) private static class Component implements Comparable { - Component(board.Component p_board_component, Collection p_board_smd_pin_list) + Component(net.freerouting.board.Component p_board_component, Collection p_board_smd_pin_list) { this.board_component = p_board_component; // calcoulate the center of gravity of all SMD pins of this component. - Collection curr_pin_list = new java.util.LinkedList(); + Collection curr_pin_list = new java.util.LinkedList(); int cmp_no = p_board_component.no; - for (board.Pin curr_board_pin : p_board_smd_pin_list) + for (net.freerouting.board.Pin curr_board_pin : p_board_smd_pin_list) { if (curr_board_pin.get_component_no() == cmp_no) { @@ -139,7 +139,7 @@ private static class Component implements Comparable } double x = 0; double y = 0; - for (board.Pin curr_pin : curr_pin_list) + for (net.freerouting.board.Pin curr_pin : curr_pin_list) { FloatPoint curr_point = curr_pin.get_center().to_float(); x += curr_point.x; @@ -153,7 +153,7 @@ private static class Component implements Comparable // calculate the sorted SMD pins of this component this.smd_pins = new java.util.TreeSet(); - for (board.Pin curr_board_pin : curr_pin_list) + for (net.freerouting.board.Pin curr_board_pin : curr_pin_list) { this.smd_pins.add(new Pin(curr_board_pin)); } @@ -181,7 +181,7 @@ else if (compare_value < 0) } return result; } - final board.Component board_component; + final net.freerouting.board.Component board_component; final int smd_pin_count; final SortedSet smd_pins; /** The center of gravity of all SMD pins of this component. */ @@ -190,7 +190,7 @@ else if (compare_value < 0) class Pin implements Comparable { - Pin(board.Pin p_board_pin) + Pin(net.freerouting.board.Pin p_board_pin) { this.board_pin = p_board_pin; FloatPoint pin_location = p_board_pin.get_center().to_float(); @@ -215,7 +215,7 @@ else if (delta_dist < 0) } return result; } - final board.Pin board_pin; + final net.freerouting.board.Pin board_pin; final double distance_to_component_center; } } diff --git a/autoroute/BatchOptRoute.java b/src/main/java/net/freerouting/autoroute/BatchOptRoute.java similarity index 96% rename from autoroute/BatchOptRoute.java rename to src/main/java/net/freerouting/autoroute/BatchOptRoute.java index 18dfa3fb..2b7f101e 100644 --- a/autoroute/BatchOptRoute.java +++ b/src/main/java/net/freerouting/autoroute/BatchOptRoute.java @@ -13,24 +13,24 @@ * GNU General Public License at * for more details. */ -package autoroute; +package net.freerouting.autoroute; import java.util.Iterator; import java.util.Collection; import java.util.Set; -import datastructures.UndoableObjects; +import net.freerouting.datastructures.UndoableObjects; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; -import board.Item; -import board.Via; -import board.Trace; -import board.RoutingBoard; -import board.FixedState; -import board.TestLevel; +import net.freerouting.board.Item; +import net.freerouting.board.Via; +import net.freerouting.board.Trace; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.FixedState; +import net.freerouting.board.TestLevel; -import interactive.InteractiveActionThread; +import net.freerouting.interactive.InteractiveActionThread; /** * To optimize the vias and traces after the batch autorouter has completed the board. @@ -114,7 +114,7 @@ private boolean opt_route_pass(int p_pass_no, boolean p_with_prefered_directions private boolean opt_route_item(Item p_item, int p_pass_no, boolean p_with_prefered_directions) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("interactive.resources.InteractiveState", this.thread.hdlg.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", this.thread.hdlg.get_locale()); String start_message = resources.getString("batch_optimizer") + " " + resources.getString("stop_message") + " " + resources.getString("pass") + " " + (new Integer(p_pass_no)).toString() + ": "; this.thread.hdlg.screen_messages.set_status_message(start_message); this.thread.hdlg.remove_ratsnest(); @@ -219,7 +219,7 @@ static boolean contains_only_unfixed_traces(Collection p_item_list) private static double calc_weighted_trace_length(RoutingBoard p_board) { double result = 0; - int default_clearance_class = rules.BoardRules.default_clearance_class(); + int default_clearance_class = net.freerouting.rules.BoardRules.default_clearance_class(); Iterator it = p_board.item_list.start_read_object(); for (;;) { diff --git a/autoroute/CompleteExpansionRoom.java b/src/main/java/net/freerouting/autoroute/CompleteExpansionRoom.java similarity index 83% rename from autoroute/CompleteExpansionRoom.java rename to src/main/java/net/freerouting/autoroute/CompleteExpansionRoom.java index 75a17671..06ac7b70 100644 --- a/autoroute/CompleteExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/CompleteExpansionRoom.java @@ -19,7 +19,7 @@ * */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; @@ -38,10 +38,10 @@ public interface CompleteExpansionRoom extends ExpansionRoom /** * Returns the object of tthis complete_expansion_rooom. */ - board.SearchTreeObject get_object(); + net.freerouting.board.SearchTreeObject get_object(); /** * Draws the shape of this room for test purposes */ - void draw(java.awt.Graphics p_graphics, boardgraphics.GraphicsContext p_graphics_context, double p_intensity); + void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity); } diff --git a/autoroute/CompleteFreeSpaceExpansionRoom.java b/src/main/java/net/freerouting/autoroute/CompleteFreeSpaceExpansionRoom.java similarity index 94% rename from autoroute/CompleteFreeSpaceExpansionRoom.java rename to src/main/java/net/freerouting/autoroute/CompleteFreeSpaceExpansionRoom.java index ad419139..1ecf115b 100644 --- a/autoroute/CompleteFreeSpaceExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/CompleteFreeSpaceExpansionRoom.java @@ -18,20 +18,20 @@ * Created on 10. Februar 2004, 10:12 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.TileShape; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import datastructures.ShapeTree; +import net.freerouting.datastructures.ShapeTree; -import board.SearchTreeObject; -import board.ShapeSearchTree; -import board.Connectable; -import board.Item; +import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.Connectable; +import net.freerouting.board.Item; /** @@ -186,7 +186,7 @@ public void calculate_target_doors(ShapeTree.TreeEntry p_own_net_object, int p_ /** * Draws the shape of this room. */ - public void draw(java.awt.Graphics p_graphics, boardgraphics.GraphicsContext p_graphics_context, double p_intensity) + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { java.awt.Color draw_color = p_graphics_context.get_trace_colors(false)[this.get_layer()]; double layer_visibility = p_graphics_context.get_layer_visibility(this.get_layer()); diff --git a/autoroute/Connection.java b/src/main/java/net/freerouting/autoroute/Connection.java similarity index 98% rename from autoroute/Connection.java rename to src/main/java/net/freerouting/autoroute/Connection.java index 016c586d..6e5c2fc8 100644 --- a/autoroute/Connection.java +++ b/src/main/java/net/freerouting/autoroute/Connection.java @@ -19,16 +19,16 @@ * */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; import java.util.Set; import java.util.TreeSet; -import geometry.planar.Point; +import net.freerouting.geometry.planar.Point; -import board.Item; -import board.Trace; +import net.freerouting.board.Item; +import net.freerouting.board.Trace; /** * Describes a routing connection ending at the next fork or terminal item. diff --git a/autoroute/DestinationDistance.java b/src/main/java/net/freerouting/autoroute/DestinationDistance.java similarity index 98% rename from autoroute/DestinationDistance.java rename to src/main/java/net/freerouting/autoroute/DestinationDistance.java index 95481387..a12c2b3a 100644 --- a/autoroute/DestinationDistance.java +++ b/src/main/java/net/freerouting/autoroute/DestinationDistance.java @@ -18,11 +18,11 @@ * Created on 26. Januar 2004, 10:08 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.FloatPoint; -import geometry.planar.IntBox; -import autoroute.AutorouteControl.ExpansionCostFactor; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; diff --git a/autoroute/DrillPage.java b/src/main/java/net/freerouting/autoroute/DrillPage.java similarity index 90% rename from autoroute/DrillPage.java rename to src/main/java/net/freerouting/autoroute/DrillPage.java index 481e4507..15c941b9 100644 --- a/autoroute/DrillPage.java +++ b/src/main/java/net/freerouting/autoroute/DrillPage.java @@ -19,22 +19,22 @@ * */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; import java.util.LinkedList; import java.util.Iterator; -import geometry.planar.Point; -import geometry.planar.IntBox; -import geometry.planar.TileShape; -import geometry.planar.PolylineArea; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.PolylineArea; -import datastructures.ShapeTree.TreeEntry; +import net.freerouting.datastructures.ShapeTree.TreeEntry; -import board.RoutingBoard; -import board.ShapeSearchTree; -import board.Item; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.Item; /** * @@ -82,9 +82,9 @@ public Collection get_drills(AutorouteEngine p_autoroute_engine, { continue; } - if (curr_item instanceof board.Pin) + if (curr_item instanceof net.freerouting.board.Pin) { - if (p_attach_smd && ((board.Pin) curr_item).drill_allowed()) + if (p_attach_smd && ((net.freerouting.board.Pin) curr_item).drill_allowed()) { continue; } @@ -193,7 +193,7 @@ public void invalidate() * Test draw of the drills on this page. */ public void draw(java.awt.Graphics p_graphics, - boardgraphics.GraphicsContext p_graphics_context, double p_intensity) + net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { if (true || drills == null) { @@ -220,9 +220,9 @@ private static Point calc_pin_center_in_drill(TileShape p_drill_shape, int p_lay Point result = null; for (Item curr_item : overlapping_items) { - if (curr_item instanceof board.Pin) + if (curr_item instanceof net.freerouting.board.Pin) { - board.Pin curr_pin = (board.Pin) curr_item; + net.freerouting.board.Pin curr_pin = (net.freerouting.board.Pin) curr_item; if (curr_pin.drill_allowed() && p_drill_shape.contains_inside(curr_pin.get_center())) { result = curr_pin.get_center(); diff --git a/autoroute/DrillPageArray.java b/src/main/java/net/freerouting/autoroute/DrillPageArray.java similarity index 94% rename from autoroute/DrillPageArray.java rename to src/main/java/net/freerouting/autoroute/DrillPageArray.java index 5497c239..d10464c3 100644 --- a/autoroute/DrillPageArray.java +++ b/src/main/java/net/freerouting/autoroute/DrillPageArray.java @@ -19,15 +19,15 @@ * */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; import java.util.LinkedList; -import geometry.planar.IntBox; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.TileShape; -import board.RoutingBoard; +import net.freerouting.board.RoutingBoard; /** * Describes the 2 dimensional array of pages of ExpansionDrill`s used in the maze search algorithm. @@ -139,7 +139,7 @@ public void reset() /* * Test draw of the all drills */ - public void draw(java.awt.Graphics p_graphics, boardgraphics.GraphicsContext p_graphics_context, double p_intensity) + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { for (int j = 0; j < page_arr.length; ++j) { diff --git a/autoroute/ExpandableObject.java b/src/main/java/net/freerouting/autoroute/ExpandableObject.java similarity index 95% rename from autoroute/ExpandableObject.java rename to src/main/java/net/freerouting/autoroute/ExpandableObject.java index d798b220..38eebea0 100644 --- a/autoroute/ExpandableObject.java +++ b/src/main/java/net/freerouting/autoroute/ExpandableObject.java @@ -17,9 +17,9 @@ * * Created on 6. April 2004, 07:30 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.TileShape; /** * An object, which can be expanded by the maze expansion algorithm. diff --git a/autoroute/ExpansionDoor.java b/src/main/java/net/freerouting/autoroute/ExpansionDoor.java similarity index 97% rename from autoroute/ExpansionDoor.java rename to src/main/java/net/freerouting/autoroute/ExpansionDoor.java index 47d1b404..c2faea31 100644 --- a/autoroute/ExpansionDoor.java +++ b/src/main/java/net/freerouting/autoroute/ExpansionDoor.java @@ -17,12 +17,12 @@ * * Created on 6. Januar 2004, 07:23 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.TileShape; -import geometry.planar.FloatPoint; -import geometry.planar.FloatLine; -import geometry.planar.Point; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatLine; +import net.freerouting.geometry.planar.Point; /** * An ExpansionDoor is a common edge between two ExpansionRooms diff --git a/autoroute/ExpansionDrill.java b/src/main/java/net/freerouting/autoroute/ExpansionDrill.java similarity index 91% rename from autoroute/ExpansionDrill.java rename to src/main/java/net/freerouting/autoroute/ExpansionDrill.java index 82e60337..006e54b8 100644 --- a/autoroute/ExpansionDrill.java +++ b/src/main/java/net/freerouting/autoroute/ExpansionDrill.java @@ -17,10 +17,10 @@ * * Created on 19. April 2004, 08:00 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.Point; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.TileShape; import java.util.Collection; import java.util.Iterator; @@ -58,15 +58,15 @@ public ExpansionDrill(TileShape p_shape, Point p_location, int p_first_layer, in public boolean calculate_expansion_rooms(AutorouteEngine p_autoroute_engine) { TileShape search_shape = TileShape.get_instance(location); - Collection overlaps = + Collection overlaps = p_autoroute_engine.autoroute_search_tree.overlapping_objects(search_shape, -1); for (int i = this.first_layer; i <= this.last_layer; ++i) { CompleteExpansionRoom found_room = null; - Iterator it = overlaps.iterator(); + Iterator it = overlaps.iterator(); while (it.hasNext()) { - board.SearchTreeObject curr_ob = it.next(); + net.freerouting.board.SearchTreeObject curr_ob = it.next(); if (!(curr_ob instanceof CompleteExpansionRoom)) { it.remove(); @@ -139,7 +139,7 @@ public void reset() * Test draw of the the shape of this drill. */ public void draw(java.awt.Graphics p_graphics, - boardgraphics.GraphicsContext p_graphics_context, double p_intensity) + net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { java.awt.Color draw_color = p_graphics_context.get_hilight_color(); p_graphics_context.fill_area(this.shape, p_graphics, draw_color, p_intensity); diff --git a/autoroute/ExpansionRoom.java b/src/main/java/net/freerouting/autoroute/ExpansionRoom.java similarity index 95% rename from autoroute/ExpansionRoom.java rename to src/main/java/net/freerouting/autoroute/ExpansionRoom.java index 54bd0de9..1df40ffc 100644 --- a/autoroute/ExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/ExpansionRoom.java @@ -19,11 +19,11 @@ * */ -package autoroute; +package net.freerouting.autoroute; import java.util.List; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.TileShape; /** * diff --git a/autoroute/FreeSpaceExpansionRoom.java b/src/main/java/net/freerouting/autoroute/FreeSpaceExpansionRoom.java similarity index 97% rename from autoroute/FreeSpaceExpansionRoom.java rename to src/main/java/net/freerouting/autoroute/FreeSpaceExpansionRoom.java index 48a79412..fdbd070a 100644 --- a/autoroute/FreeSpaceExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/FreeSpaceExpansionRoom.java @@ -18,9 +18,9 @@ * Created on 29. Dezember 2003, 08:37 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.TileShape; import java.util.Iterator; diff --git a/autoroute/IncompleteFreeSpaceExpansionRoom.java b/src/main/java/net/freerouting/autoroute/IncompleteFreeSpaceExpansionRoom.java similarity index 95% rename from autoroute/IncompleteFreeSpaceExpansionRoom.java rename to src/main/java/net/freerouting/autoroute/IncompleteFreeSpaceExpansionRoom.java index bf979318..f2bd9852 100644 --- a/autoroute/IncompleteFreeSpaceExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/IncompleteFreeSpaceExpansionRoom.java @@ -18,11 +18,11 @@ * Created on 10. Februar 2004, 10:13 */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.TileShape; /** diff --git a/autoroute/InsertFoundConnectionAlgo.java b/src/main/java/net/freerouting/autoroute/InsertFoundConnectionAlgo.java similarity index 94% rename from autoroute/InsertFoundConnectionAlgo.java rename to src/main/java/net/freerouting/autoroute/InsertFoundConnectionAlgo.java index e36ca3c5..91c1eff6 100644 --- a/autoroute/InsertFoundConnectionAlgo.java +++ b/src/main/java/net/freerouting/autoroute/InsertFoundConnectionAlgo.java @@ -17,26 +17,26 @@ * * Created on 23. Februar 2004, 08:18 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.IntPoint; -import geometry.planar.Point; -import geometry.planar.FloatPoint; -import geometry.planar.Polyline; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Polyline; import java.util.Iterator; import java.util.Set; -import library.Padstack; -import rules.ViaInfo; +import net.freerouting.library.Padstack; +import net.freerouting.rules.ViaInfo; -import board.ForcedViaAlgo; -import board.PolylineTrace; -import board.Trace; -import board.Item; -import board.RoutingBoard; -import board.ItemSelectionFilter; -import board.TestLevel; +import net.freerouting.board.ForcedViaAlgo; +import net.freerouting.board.PolylineTrace; +import net.freerouting.board.Trace; +import net.freerouting.board.Item; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.ItemSelectionFilter; +import net.freerouting.board.TestLevel; /** * Inserts the traces and vias of the connection found by the autoroute algorithm. @@ -121,8 +121,8 @@ private boolean insert_trace(LocateFoundConnectionAlgoAnyAngle.ResultItem p_trac board.rules.set_pin_edge_to_turn_dist(-1); // Look for pins att the start and the end of p_trace in case that neckdown is necessecary. - board.Pin start_pin = null; - board.Pin end_pin = null; + net.freerouting.board.Pin start_pin = null; + net.freerouting.board.Pin end_pin = null; if (ctrl.with_neckdown) { ItemSelectionFilter item_filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.PINS); @@ -132,7 +132,7 @@ private boolean insert_trace(LocateFoundConnectionAlgoAnyAngle.ResultItem p_trac Set picked_items = this.board.pick_items(curr_end_corner, p_trace.layer, item_filter); for (Item curr_item : picked_items) { - board.Pin curr_pin = (board.Pin) curr_item; + net.freerouting.board.Pin curr_pin = (net.freerouting.board.Pin) curr_item; if (curr_pin.contains_net(ctrl.net_no) && curr_pin.get_center().equals(curr_end_corner)) { if (i == 0) @@ -220,7 +220,7 @@ else if (ok_point == insert_polyline.first_corner() && i != p_trace.corners.leng return result; } - boolean insert_neckdown(Point p_from_corner, Point p_to_corner, int p_layer, board.Pin p_start_pin, board.Pin p_end_pin) + boolean insert_neckdown(Point p_from_corner, Point p_to_corner, int p_layer, net.freerouting.board.Pin p_start_pin, net.freerouting.board.Pin p_end_pin) { if (p_start_pin != null) { @@ -241,7 +241,7 @@ boolean insert_neckdown(Point p_from_corner, Point p_to_corner, int p_layer, boa return false; } - private Point try_neck_down(Point p_from_corner, Point p_to_corner, int p_layer, board.Pin p_pin, boolean p_at_start) + private Point try_neck_down(Point p_from_corner, Point p_to_corner, int p_layer, net.freerouting.board.Pin p_pin, boolean p_at_start) { if (!p_pin.is_on_layer(p_layer)) { diff --git a/autoroute/ItemAutorouteInfo.java b/src/main/java/net/freerouting/autoroute/ItemAutorouteInfo.java similarity index 94% rename from autoroute/ItemAutorouteInfo.java rename to src/main/java/net/freerouting/autoroute/ItemAutorouteInfo.java index 32199443..43d5affa 100644 --- a/autoroute/ItemAutorouteInfo.java +++ b/src/main/java/net/freerouting/autoroute/ItemAutorouteInfo.java @@ -18,11 +18,11 @@ * Created on 22. Februar 2004, 12:09 */ -package autoroute; +package net.freerouting.autoroute; -import board.ShapeSearchTree; +import net.freerouting.board.ShapeSearchTree; -import board.Item; +import net.freerouting.board.Item; /** @@ -114,7 +114,7 @@ public void reset_doors() /** * Draws the shapes of the expansion rooms of this info for testing purposes. */ - public void draw(java.awt.Graphics p_graphics, boardgraphics.GraphicsContext p_graphics_context, double p_intensity) + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { if (expansion_room_arr == null) { diff --git a/autoroute/LocateFoundConnectionAlgo.java b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo.java similarity index 97% rename from autoroute/LocateFoundConnectionAlgo.java rename to src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo.java index 2c797774..3126a341 100644 --- a/autoroute/LocateFoundConnectionAlgo.java +++ b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo.java @@ -18,22 +18,22 @@ * Created on 31. Januar 2006, 08:20 * */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; import java.util.SortedSet; import java.util.LinkedList; import java.util.Iterator; -import geometry.planar.IntPoint; -import geometry.planar.FloatPoint; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.TileShape; -import board.Connectable; -import board.Item; -import board.AngleRestriction; -import board.ShapeSearchTree; -import board.TestLevel; +import net.freerouting.board.Connectable; +import net.freerouting.board.Item; +import net.freerouting.board.AngleRestriction; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.TestLevel; /** * @@ -269,7 +269,7 @@ private ResultItem calculate_next_trace(boolean p_layer_changed, boolean p_at_fa protected abstract Collection calculate_next_trace_corners(); /** Test display of the baktrack rooms. */ - public void draw(java.awt.Graphics p_graphics, boardgraphics.GraphicsContext p_graphics_context) + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { for (int i = 0; i < backtrack_array.length; ++i) { diff --git a/autoroute/LocateFoundConnectionAlgo45Degree.java b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo45Degree.java similarity index 96% rename from autoroute/LocateFoundConnectionAlgo45Degree.java rename to src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo45Degree.java index 051ea30f..51954b57 100644 --- a/autoroute/LocateFoundConnectionAlgo45Degree.java +++ b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo45Degree.java @@ -19,24 +19,24 @@ * */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; import java.util.LinkedList; import java.util.SortedSet; -import datastructures.Signum; +import net.freerouting.datastructures.Signum; -import geometry.planar.FloatPoint; -import geometry.planar.FloatLine; -import geometry.planar.TileShape; -import geometry.planar.IntBox; -import geometry.planar.Simplex; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatLine; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.Simplex; -import board.ShapeSearchTree; -import board.AngleRestriction; -import board.Item; -import board.TestLevel; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.AngleRestriction; +import net.freerouting.board.Item; +import net.freerouting.board.TestLevel; /** * diff --git a/autoroute/LocateFoundConnectionAlgoAnyAngle.java b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgoAnyAngle.java similarity index 98% rename from autoroute/LocateFoundConnectionAlgoAnyAngle.java rename to src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgoAnyAngle.java index e907d2a1..14ed4313 100644 --- a/autoroute/LocateFoundConnectionAlgoAnyAngle.java +++ b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgoAnyAngle.java @@ -18,21 +18,21 @@ * Created on 14. Februar 2004, 07:55 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.FloatLine; -import geometry.planar.FloatPoint; -import geometry.planar.Side; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.FloatLine; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.TileShape; import java.util.Collection; import java.util.SortedSet; import java.util.LinkedList; -import board.ShapeSearchTree; -import board.AngleRestriction; -import board.Item; -import board.TestLevel; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.AngleRestriction; +import net.freerouting.board.Item; +import net.freerouting.board.TestLevel; /** diff --git a/autoroute/MazeListElement.java b/src/main/java/net/freerouting/autoroute/MazeListElement.java similarity index 97% rename from autoroute/MazeListElement.java rename to src/main/java/net/freerouting/autoroute/MazeListElement.java index 46527c66..40014525 100644 --- a/autoroute/MazeListElement.java +++ b/src/main/java/net/freerouting/autoroute/MazeListElement.java @@ -18,9 +18,9 @@ * Created on 25. Januar 2004, 08:21 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.FloatLine; +import net.freerouting.geometry.planar.FloatLine; /** * Information for the maze expand Algorithm contained in expansion doors and drills diff --git a/autoroute/MazeSearchAlgo.java b/src/main/java/net/freerouting/autoroute/MazeSearchAlgo.java similarity index 93% rename from autoroute/MazeSearchAlgo.java rename to src/main/java/net/freerouting/autoroute/MazeSearchAlgo.java index 56c1452a..97705208 100644 --- a/autoroute/MazeSearchAlgo.java +++ b/src/main/java/net/freerouting/autoroute/MazeSearchAlgo.java @@ -17,18 +17,18 @@ * * Created on 25. Januar 2004, 13:24 */ -package autoroute; - -import geometry.planar.ConvexShape; -import geometry.planar.FloatLine; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.Point; -import geometry.planar.Polyline; -import geometry.planar.TileShape; -import geometry.planar.IntBox; -import geometry.planar.IntOctagon; -import geometry.planar.Line; +package net.freerouting.autoroute; + +import net.freerouting.geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.FloatLine; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.Line; import java.util.Collection; import java.util.Iterator; @@ -36,14 +36,14 @@ import java.util.TreeSet; import java.util.Set; -import board.Connectable; -import board.ForcedViaAlgo; -import board.Item; -import board.PolylineTrace; -import board.ShapeSearchTree; -import board.AngleRestriction; -import board.SearchTreeObject; -import board.ItemSelectionFilter; +import net.freerouting.board.Connectable; +import net.freerouting.board.ForcedViaAlgo; +import net.freerouting.board.Item; +import net.freerouting.board.PolylineTrace; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.AngleRestriction; +import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.ItemSelectionFilter; /** * Class for autorouting an incomplete connection via a maze search algorithm. @@ -236,9 +236,9 @@ private boolean expand_to_room_doors(MazeListElement p_list_element) { // try evtl. neckdown at a start pin Item start_item = ((TargetItemExpansionDoor) p_list_element.door).item; - if (start_item instanceof board.Pin) + if (start_item instanceof net.freerouting.board.Pin) { - double neckdown_half_width = ((board.Pin) start_item).get_trace_neckdown_halfwidth(layer_no); + double neckdown_half_width = ((net.freerouting.board.Pin) start_item).get_trace_neckdown_halfwidth(layer_no); if (neckdown_half_width > 0) { half_width = Math.min(half_width, neckdown_half_width); @@ -341,7 +341,7 @@ else if (p_list_element.next_room instanceof ObstacleExpansionRoom) if (ripup_costs != ALREADY_RIPPED_COSTS && next_room_is_thick) { Item obstacle_item = obstacle_room.get_item(); - if (!curr_door_is_small && this.ctrl.max_shove_trace_recursion_depth > 0 && obstacle_item instanceof board.PolylineTrace) + if (!curr_door_is_small && this.ctrl.max_shove_trace_recursion_depth > 0 && obstacle_item instanceof net.freerouting.board.PolylineTrace) { if (!shove_trace_room(p_list_element, obstacle_room)) { @@ -398,9 +398,9 @@ else if (p_list_element.next_room instanceof ObstacleExpansionRoom) else if (p_list_element.next_room instanceof ObstacleExpansionRoom) { Item curr_obstacle_item = ((ObstacleExpansionRoom) p_list_element.next_room).get_item(); - if (curr_obstacle_item instanceof board.Via) + if (curr_obstacle_item instanceof net.freerouting.board.Via) { - board.Via curr_via = (board.Via) curr_obstacle_item; + net.freerouting.board.Via curr_via = (net.freerouting.board.Via) curr_obstacle_item; ExpansionDrill via_drill_info = curr_via.get_autoroute_drill_info(this.autoroute_engine.autoroute_search_tree); expand_to_drill(via_drill_info, p_list_element, ripup_costs); } @@ -545,7 +545,7 @@ private boolean door_is_small(ExpansionDoor p_door, double p_trace_width) TileShape door_shape = p_door.get_shape(); if (door_shape.is_empty()) { - if (this.autoroute_engine.board.get_test_level().ordinal() >= board.TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) + if (this.autoroute_engine.board.get_test_level().ordinal() >= net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("MazeSearchAlgo:check_door_width door_shape is empty"); } @@ -628,9 +628,9 @@ private void expand_to_drill(ExpansionDrill p_drill, MazeListElement p_from_elem // If expansion comes from a pin with trace exit directions the eapansion_value is calculated // from the nearest trace exit point instead from the center olf the pin. Item from_item = ((TargetItemExpansionDoor) p_from_element.backtrack_door).item; - if (from_item instanceof board.Pin) + if (from_item instanceof net.freerouting.board.Pin) { - FloatPoint nearest_exit_corner = ((board.Pin) from_item).nearest_trace_exit_corner(p_drill.location.to_float(), trace_half_width, layer); + FloatPoint nearest_exit_corner = ((net.freerouting.board.Pin) from_item).nearest_trace_exit_corner(p_drill.location.to_float(), trace_half_width, layer); if (nearest_exit_corner != null) { compare_corner = nearest_exit_corner; @@ -729,11 +729,11 @@ private void expand_to_other_layers(MazeListElement p_list_element) } Item curr_obstacle_item = ((ObstacleExpansionRoom) curr_drill.room_arr[p_list_element.section_no_of_door]).get_item(); - if (!(curr_obstacle_item instanceof board.Via)) + if (!(curr_obstacle_item instanceof net.freerouting.board.Via)) { return; } - library.Padstack curr_obstacle_padstack = ((board.Via) curr_obstacle_item).get_padstack(); + net.freerouting.library.Padstack curr_obstacle_padstack = ((net.freerouting.board.Via) curr_obstacle_item).get_padstack(); if (!this.ctrl.via_rule.contains_padstack(curr_obstacle_padstack) || curr_obstacle_item.clearance_class_no() != this.ctrl.via_clearance_class) { return; @@ -755,16 +755,16 @@ private void expand_to_other_layers(MazeListElement p_list_element) for (;;) { TileShape curr_room_shape = curr_drill.room_arr[curr_layer - curr_drill.first_layer].get_shape(); - board.ForcedPadAlgo.CheckDrillResult drill_result = + net.freerouting.board.ForcedPadAlgo.CheckDrillResult drill_result = ForcedViaAlgo.check_layer(ctrl.via_radius_arr[curr_layer], ctrl.via_clearance_class, ctrl.attach_smd_allowed, curr_room_shape, curr_drill.location, curr_layer, net_no_arr, ctrl.max_shove_trace_recursion_depth, 0, autoroute_engine.board); - if (drill_result == board.ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) + if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) { via_lower_bound = curr_layer + 1; break; } - else if (drill_result == board.ForcedPadAlgo.CheckDrillResult.DRILLABLE_WITH_ATTACH_SMD) + else if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.DRILLABLE_WITH_ATTACH_SMD) { if (curr_layer == 0) { @@ -795,16 +795,16 @@ else if (curr_layer == ctrl.layer_count - 1) break; } TileShape curr_room_shape = curr_drill.room_arr[curr_layer - curr_drill.first_layer].get_shape(); - board.ForcedPadAlgo.CheckDrillResult drill_result = + net.freerouting.board.ForcedPadAlgo.CheckDrillResult drill_result = ForcedViaAlgo.check_layer(ctrl.via_radius_arr[curr_layer], ctrl.via_clearance_class, ctrl.attach_smd_allowed, curr_room_shape, curr_drill.location, curr_layer, net_no_arr, ctrl.max_shove_trace_recursion_depth, 0, autoroute_engine.board); - if (drill_result == board.ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) + if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) { via_upper_bound = curr_layer - 1; break; } - else if (drill_result == board.ForcedPadAlgo.CheckDrillResult.DRILLABLE_WITH_ATTACH_SMD) + else if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.DRILLABLE_WITH_ATTACH_SMD) { if (curr_layer == ctrl.layer_count - 1) { @@ -1005,17 +1005,17 @@ private static void reduce_trace_shapes_at_tie_pins(Collection p_item_list { for (Item curr_item : p_item_list) { - if ((curr_item instanceof board.Pin) && curr_item.net_count() > 1) + if ((curr_item instanceof net.freerouting.board.Pin) && curr_item.net_count() > 1) { Collection pin_contacts = curr_item.get_normal_contacts(); - board.Pin curr_tie_pin = (board.Pin) curr_item; + net.freerouting.board.Pin curr_tie_pin = (net.freerouting.board.Pin) curr_item; for (Item curr_contact : pin_contacts) { - if (!(curr_contact instanceof board.PolylineTrace) || curr_contact.contains_net(p_own_net_no)) + if (!(curr_contact instanceof net.freerouting.board.PolylineTrace) || curr_contact.contains_net(p_own_net_no)) { continue; } - p_autoroute_tree.reduce_trace_shape_at_tie_pin(curr_tie_pin, (board.PolylineTrace) curr_contact); + p_autoroute_tree.reduce_trace_shape_at_tie_pin(curr_tie_pin, (net.freerouting.board.PolylineTrace) curr_contact); } } } @@ -1026,15 +1026,15 @@ private boolean room_shape_is_thick(ObstacleExpansionRoom p_obstacle_room) Item obstacle_item = p_obstacle_room.get_item(); int layer = p_obstacle_room.get_layer(); double obstacle_half_width; - if (obstacle_item instanceof board.Trace) + if (obstacle_item instanceof net.freerouting.board.Trace) { - obstacle_half_width = ((board.Trace) obstacle_item).get_half_width() + obstacle_half_width = ((net.freerouting.board.Trace) obstacle_item).get_half_width() + this.search_tree.clearance_compensation_value(obstacle_item.clearance_class_no(), layer); } - else if (obstacle_item instanceof board.Via) + else if (obstacle_item instanceof net.freerouting.board.Via) { - TileShape via_shape = ((board.Via) obstacle_item).get_tree_shape_on_layer(this.search_tree, layer); + TileShape via_shape = ((net.freerouting.board.Via) obstacle_item).get_tree_shape_on_layer(this.search_tree, layer); obstacle_half_width = 0.5 * via_shape.max_width(); } else @@ -1089,9 +1089,9 @@ else if (previous_item == p_obstacle_item) double fanout_via_cost_factor = 1.0; double cost_factor = 1; - if (p_obstacle_item instanceof board.Trace) + if (p_obstacle_item instanceof net.freerouting.board.Trace) { - board.Trace obstacle_trace = (board.Trace) p_obstacle_item; + net.freerouting.board.Trace obstacle_trace = (net.freerouting.board.Trace) p_obstacle_item; cost_factor = obstacle_trace.get_half_width(); if (!this.ctrl.remove_unconnected_vias) { @@ -1099,19 +1099,19 @@ else if (previous_item == p_obstacle_item) fanout_via_cost_factor = calc_fanout_via_ripup_cost_factor(obstacle_trace); } } - else if (p_obstacle_item instanceof board.Via) + else if (p_obstacle_item instanceof net.freerouting.board.Via) { boolean look_if_fanout_via = !this.ctrl.remove_unconnected_vias; Collection contact_list = p_obstacle_item.get_normal_contacts(); int contact_count = 0; for (Item curr_contact : contact_list) { - if (!(curr_contact instanceof board.Trace) || curr_contact.is_user_fixed()) + if (!(curr_contact instanceof net.freerouting.board.Trace) || curr_contact.is_user_fixed()) { return -1; } ++contact_count; - board.Trace obstacle_trace = (board.Trace) curr_contact; + net.freerouting.board.Trace obstacle_trace = (net.freerouting.board.Trace) curr_contact; cost_factor = Math.max(cost_factor, obstacle_trace.get_half_width()); if (look_if_fanout_via) { @@ -1160,7 +1160,7 @@ else if (p_obstacle_item instanceof board.Via) * Return the addditional cost factor for ripping the trace, if it is connected to a fanout via * or 1, if no fanout via was found. */ - private static double calc_fanout_via_ripup_cost_factor(board.Trace p_trace) + private static double calc_fanout_via_ripup_cost_factor(net.freerouting.board.Trace p_trace) { final double FANOUT_COST_CONST = 20000; Collection curr_end_contacts; @@ -1180,11 +1180,11 @@ private static double calc_fanout_via_ripup_cost_factor(board.Trace p_trace) } Item curr_trace_contact = curr_end_contacts.iterator().next(); boolean protect_fanout_via = false; - if (curr_trace_contact instanceof board.Pin && curr_trace_contact.first_layer() == curr_trace_contact.last_layer()) + if (curr_trace_contact instanceof net.freerouting.board.Pin && curr_trace_contact.first_layer() == curr_trace_contact.last_layer()) { protect_fanout_via = true; } - else if (curr_trace_contact instanceof PolylineTrace && curr_trace_contact.get_fixed_state() == board.FixedState.SHOVE_FIXED) + else if (curr_trace_contact instanceof PolylineTrace && curr_trace_contact.get_fixed_state() == net.freerouting.board.FixedState.SHOVE_FIXED) { // look for shove fixed exit traces of SMD-pins PolylineTrace contact_trace = (PolylineTrace) curr_trace_contact; @@ -1288,9 +1288,9 @@ private double check_neck_down_at_dest_pin(CompleteExpansionRoom p_room) Collection target_doors = p_room.get_target_doors(); for (TargetItemExpansionDoor curr_target_door : target_doors) { - if (curr_target_door.item instanceof board.Pin) + if (curr_target_door.item instanceof net.freerouting.board.Pin) { - return ((board.Pin) curr_target_door.item).get_trace_neckdown_halfwidth(p_room.get_layer()); + return ((net.freerouting.board.Pin) curr_target_door.item).get_trace_neckdown_halfwidth(p_room.get_layer()); } } return 0; diff --git a/autoroute/MazeSearchElement.java b/src/main/java/net/freerouting/autoroute/MazeSearchElement.java similarity index 97% rename from autoroute/MazeSearchElement.java rename to src/main/java/net/freerouting/autoroute/MazeSearchElement.java index e7cccf66..08a81c3b 100644 --- a/autoroute/MazeSearchElement.java +++ b/src/main/java/net/freerouting/autoroute/MazeSearchElement.java @@ -18,7 +18,7 @@ * Created on 31. Januar 2004, 07:46 */ -package autoroute; +package net.freerouting.autoroute; /** * Describes the structure of a section of an ExpandebleObject. diff --git a/autoroute/MazeShoveTraceAlgo.java b/src/main/java/net/freerouting/autoroute/MazeShoveTraceAlgo.java similarity index 92% rename from autoroute/MazeShoveTraceAlgo.java rename to src/main/java/net/freerouting/autoroute/MazeShoveTraceAlgo.java index 9d79bcef..75dd8a85 100644 --- a/autoroute/MazeShoveTraceAlgo.java +++ b/src/main/java/net/freerouting/autoroute/MazeShoveTraceAlgo.java @@ -19,23 +19,23 @@ * */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; -import geometry.planar.TileShape; -import geometry.planar.Line; -import geometry.planar.Polyline; -import geometry.planar.Point; -import geometry.planar.FloatPoint; -import geometry.planar.FloatLine; -import geometry.planar.Side; -import geometry.planar.Direction; -import geometry.planar.LineSegment; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatLine; +import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.Direction; +import net.freerouting.geometry.planar.LineSegment; -import board.Item; -import board.RoutingBoard; -import board.ShoveTraceAlgo; +import net.freerouting.board.Item; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.ShoveTraceAlgo; /** * Auxiliary functions used in MazeSearchAlgo. @@ -58,11 +58,11 @@ public static boolean check_shove_trace_line(MazeListElement p_list_element, return true; } ExpansionDoor from_door = (ExpansionDoor) p_list_element.door; - if (!(p_obstacle_room.get_item() instanceof board.PolylineTrace)) + if (!(p_obstacle_room.get_item() instanceof net.freerouting.board.PolylineTrace)) { return true; } - board.PolylineTrace obstacle_trace = (board.PolylineTrace)p_obstacle_room.get_item(); + net.freerouting.board.PolylineTrace obstacle_trace = (net.freerouting.board.PolylineTrace)p_obstacle_room.get_item(); int trace_layer = p_obstacle_room.get_layer(); // only traces with the same halfwidth and the same clearance class can be shoved. if (obstacle_trace.get_half_width() != p_ctrl.trace_half_width[trace_layer] @@ -291,7 +291,7 @@ else if (!segment_ist_point) FloatLine curr_door_segment = curr_door_shape.diagonal_corner_segment(); if (curr_door_segment == null) { - if (p_board.get_test_level() == board.TestLevel.ALL_DEBUGGING_OUTPUT) + if (p_board.get_test_level() == net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT) { System.out.println("MazeShoveTraceAlgo.check_shove_trace_line: door shape is empty"); } @@ -361,7 +361,7 @@ else if (!segment_ist_point) * Check if the endpoints of p_trace and p_from_item are maching, so that the * shove can continue through a link door. */ - private static boolean end_points_matching(board.PolylineTrace p_trace, Item p_from_item) + private static boolean end_points_matching(net.freerouting.board.PolylineTrace p_trace, Item p_from_item) { if (p_from_item == p_trace) { @@ -372,14 +372,14 @@ private static boolean end_points_matching(board.PolylineTrace p_trace, Item p_f return false; } boolean points_matching; - if (p_from_item instanceof board.DrillItem) + if (p_from_item instanceof net.freerouting.board.DrillItem) { - Point from_center = ((board.DrillItem) p_from_item).get_center(); + Point from_center = ((net.freerouting.board.DrillItem) p_from_item).get_center(); points_matching = from_center.equals(p_trace.first_corner()) || from_center.equals(p_trace.last_corner()); } - else if (p_from_item instanceof board.PolylineTrace) + else if (p_from_item instanceof net.freerouting.board.PolylineTrace) { - board.PolylineTrace from_trace = (board.PolylineTrace) p_from_item; + net.freerouting.board.PolylineTrace from_trace = (net.freerouting.board.PolylineTrace) p_from_item; points_matching = p_trace.first_corner().equals(from_trace.first_corner()) || p_trace.first_corner().equals(from_trace.last_corner()) || p_trace.last_corner().equals(from_trace.first_corner()) || diff --git a/autoroute/ObstacleExpansionRoom.java b/src/main/java/net/freerouting/autoroute/ObstacleExpansionRoom.java similarity index 93% rename from autoroute/ObstacleExpansionRoom.java rename to src/main/java/net/freerouting/autoroute/ObstacleExpansionRoom.java index eae913a2..512148a4 100644 --- a/autoroute/ObstacleExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/ObstacleExpansionRoom.java @@ -19,18 +19,18 @@ * */ -package autoroute; +package net.freerouting.autoroute; import java.util.List; import java.util.Collection; -import board.ShapeSearchTree; -import board.SearchTreeObject; -import board.PolylineTrace; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.PolylineTrace; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.TileShape; -import board.Item; +import net.freerouting.board.Item; /** * Expansion Room used for pushing and ripping obstacles in the autoroute algorithm. @@ -188,7 +188,7 @@ void set_doors_calculated(boolean p_value) /** * Draws the shape of this room. */ - public void draw(java.awt.Graphics p_graphics, boardgraphics.GraphicsContext p_graphics_context, double p_intensity) + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { java.awt.Color draw_color = java.awt.Color.WHITE; double layer_visibility = p_graphics_context.get_layer_visibility(this.get_layer()); diff --git a/autoroute/Sorted45DegreeRoomNeighbours.java b/src/main/java/net/freerouting/autoroute/Sorted45DegreeRoomNeighbours.java similarity index 98% rename from autoroute/Sorted45DegreeRoomNeighbours.java rename to src/main/java/net/freerouting/autoroute/Sorted45DegreeRoomNeighbours.java index 170c31da..d697eb6b 100644 --- a/autoroute/Sorted45DegreeRoomNeighbours.java +++ b/src/main/java/net/freerouting/autoroute/Sorted45DegreeRoomNeighbours.java @@ -19,7 +19,7 @@ * */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; import java.util.Iterator; @@ -27,17 +27,17 @@ import java.util.SortedSet; import java.util.TreeSet; -import datastructures.ShapeTree; +import net.freerouting.datastructures.ShapeTree; -import geometry.planar.Limits; -import geometry.planar.IntOctagon; -import geometry.planar.IntPoint; -import geometry.planar.TileShape; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Limits; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.FloatPoint; -import board.ShapeSearchTree; -import board.SearchTreeObject; -import board.Item; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.Item; /** * diff --git a/autoroute/SortedOrthogonalRoomNeighbours.java b/src/main/java/net/freerouting/autoroute/SortedOrthogonalRoomNeighbours.java similarity index 98% rename from autoroute/SortedOrthogonalRoomNeighbours.java rename to src/main/java/net/freerouting/autoroute/SortedOrthogonalRoomNeighbours.java index 2c260341..37fa6878 100644 --- a/autoroute/SortedOrthogonalRoomNeighbours.java +++ b/src/main/java/net/freerouting/autoroute/SortedOrthogonalRoomNeighbours.java @@ -19,7 +19,7 @@ * */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; import java.util.Iterator; @@ -27,15 +27,15 @@ import java.util.SortedSet; import java.util.TreeSet; -import datastructures.ShapeTree; +import net.freerouting.datastructures.ShapeTree; -import geometry.planar.IntBox; -import geometry.planar.TileShape; -import geometry.planar.Limits; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Limits; -import board.SearchTreeObject; -import board.ShapeSearchTree; -import board.Item; +import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.Item; /** * diff --git a/autoroute/SortedRoomNeighbours.java b/src/main/java/net/freerouting/autoroute/SortedRoomNeighbours.java similarity index 98% rename from autoroute/SortedRoomNeighbours.java rename to src/main/java/net/freerouting/autoroute/SortedRoomNeighbours.java index db07c7d0..d11e99d7 100644 --- a/autoroute/SortedRoomNeighbours.java +++ b/src/main/java/net/freerouting/autoroute/SortedRoomNeighbours.java @@ -19,7 +19,7 @@ * */ -package autoroute; +package net.freerouting.autoroute; import java.util.Collection; import java.util.LinkedList; @@ -27,24 +27,24 @@ import java.util.SortedSet; import java.util.Iterator; -import datastructures.Signum; -import datastructures.ShapeTree; +import net.freerouting.datastructures.Signum; +import net.freerouting.datastructures.ShapeTree; -import geometry.planar.Side; -import geometry.planar.Direction; -import geometry.planar.Point; -import geometry.planar.IntPoint; -import geometry.planar.FloatPoint; -import geometry.planar.Line; -import geometry.planar.TileShape; -import geometry.planar.Simplex; +import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.Direction; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Simplex; -import board.ShapeSearchTree; -import board.SearchTreeObject; -import board.Connectable; -import board.Item; -import board.PolylineTrace; -import board.TestLevel; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.Connectable; +import net.freerouting.board.Item; +import net.freerouting.board.PolylineTrace; +import net.freerouting.board.TestLevel; /** * To calculate the neigbour rooms of an expansion room. diff --git a/autoroute/TargetItemExpansionDoor.java b/src/main/java/net/freerouting/autoroute/TargetItemExpansionDoor.java similarity index 91% rename from autoroute/TargetItemExpansionDoor.java rename to src/main/java/net/freerouting/autoroute/TargetItemExpansionDoor.java index 536e833f..6c82c160 100644 --- a/autoroute/TargetItemExpansionDoor.java +++ b/src/main/java/net/freerouting/autoroute/TargetItemExpansionDoor.java @@ -17,12 +17,12 @@ * * Created on 2. Februar 2004, 12:59 */ -package autoroute; +package net.freerouting.autoroute; -import geometry.planar.Simplex; -import geometry.planar.TileShape; -import board.Item; -import board.ShapeSearchTree; +import net.freerouting.geometry.planar.Simplex; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.board.Item; +import net.freerouting.board.ShapeSearchTree; /** * An expansion door leading to a start or destination item of the autoroute algorithm. diff --git a/autoroute/package.html b/src/main/java/net/freerouting/autoroute/package.html similarity index 100% rename from autoroute/package.html rename to src/main/java/net/freerouting/autoroute/package.html diff --git a/board/AngleRestriction.java b/src/main/java/net/freerouting/board/AngleRestriction.java similarity index 98% rename from board/AngleRestriction.java rename to src/main/java/net/freerouting/board/AngleRestriction.java index afd770f3..4e62c16b 100644 --- a/board/AngleRestriction.java +++ b/src/main/java/net/freerouting/board/AngleRestriction.java @@ -18,7 +18,7 @@ * Created on 14. Juli 2003, 07:40 */ -package board; +package net.freerouting.board; /** * Enum for angle restrictions none, fortyfive degree and ninety degree. diff --git a/board/BasicBoard.java b/src/main/java/net/freerouting/board/BasicBoard.java similarity index 98% rename from board/BasicBoard.java rename to src/main/java/net/freerouting/board/BasicBoard.java index b955e4b6..ec967736 100644 --- a/board/BasicBoard.java +++ b/src/main/java/net/freerouting/board/BasicBoard.java @@ -13,17 +13,17 @@ * GNU General Public License at * for more details. */ -package board; - -import geometry.planar.Area; -import geometry.planar.ConvexShape; -import geometry.planar.IntBox; -import geometry.planar.IntOctagon; -import geometry.planar.Point; -import geometry.planar.Vector; -import geometry.planar.Polyline; -import geometry.planar.PolylineShape; -import geometry.planar.TileShape; +package net.freerouting.board; + +import net.freerouting.geometry.planar.Area; +import net.freerouting.geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.PolylineShape; +import net.freerouting.geometry.planar.TileShape; import java.awt.Graphics; @@ -34,14 +34,14 @@ import java.util.SortedSet; import java.util.TreeSet; -import datastructures.ShapeTree.TreeEntry; +import net.freerouting.datastructures.ShapeTree.TreeEntry; -import library.BoardLibrary; -import library.Padstack; -import rules.BoardRules; -import boardgraphics.GraphicsContext; -import boardgraphics.Drawable; -import datastructures.UndoableObjects; +import net.freerouting.library.BoardLibrary; +import net.freerouting.library.Padstack; +import net.freerouting.rules.BoardRules; +import net.freerouting.boardgraphics.GraphicsContext; +import net.freerouting.boardgraphics.Drawable; +import net.freerouting.datastructures.UndoableObjects; /** * diff --git a/board/BoardObserverAdaptor.java b/src/main/java/net/freerouting/board/BoardObserverAdaptor.java similarity index 98% rename from board/BoardObserverAdaptor.java rename to src/main/java/net/freerouting/board/BoardObserverAdaptor.java index 694c2fcb..93a503ce 100644 --- a/board/BoardObserverAdaptor.java +++ b/src/main/java/net/freerouting/board/BoardObserverAdaptor.java @@ -19,7 +19,7 @@ * */ -package board; +package net.freerouting.board; /** * Empty adaptor implementing the BoardObservers interface. diff --git a/board/BoardObservers.java b/src/main/java/net/freerouting/board/BoardObservers.java similarity index 92% rename from board/BoardObservers.java rename to src/main/java/net/freerouting/board/BoardObservers.java index e724b607..2c454da1 100644 --- a/board/BoardObservers.java +++ b/src/main/java/net/freerouting/board/BoardObservers.java @@ -19,9 +19,9 @@ * */ -package board; +package net.freerouting.board; -import datastructures.Observers; +import net.freerouting.datastructures.Observers; /** * diff --git a/board/BoardOutline.java b/src/main/java/net/freerouting/board/BoardOutline.java similarity index 93% rename from board/BoardOutline.java rename to src/main/java/net/freerouting/board/BoardOutline.java index 5b91901e..a81d3703 100644 --- a/board/BoardOutline.java +++ b/src/main/java/net/freerouting/board/BoardOutline.java @@ -17,19 +17,18 @@ * * Created on 18. August 2004, 07:24 */ -package board; +package net.freerouting.board; -import geometry.planar.IntBox; -import geometry.planar.IntPoint; -import geometry.planar.LineSegment; -import geometry.planar.TileShape; -import geometry.planar.PolylineShape; -import geometry.planar.PolylineArea; -import geometry.planar.Area; -import geometry.planar.Vector; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.PolylineShape; +import net.freerouting.geometry.planar.PolylineArea; +import net.freerouting.geometry.planar.Area; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.FloatPoint; -import boardgraphics.GraphicsContext; +import net.freerouting.boardgraphics.GraphicsContext; /** * Class describing a board outline. @@ -179,7 +178,7 @@ public double get_draw_intensity(GraphicsContext p_graphics_context) public int get_draw_priority() { - return boardgraphics.Drawable.MAX_DRAW_PRIORITY; + return net.freerouting.boardgraphics.Drawable.MAX_DRAW_PRIORITY; } public int shape_count() @@ -268,7 +267,7 @@ public Item copy(int p_id_no) public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("board_outline")); print_clearance_info(p_window, p_locale); p_window.newline(); diff --git a/board/CalcFromSide.java b/src/main/java/net/freerouting/board/CalcFromSide.java similarity index 94% rename from board/CalcFromSide.java rename to src/main/java/net/freerouting/board/CalcFromSide.java index 25953ee3..a60f7e78 100644 --- a/board/CalcFromSide.java +++ b/src/main/java/net/freerouting/board/CalcFromSide.java @@ -18,15 +18,15 @@ * Created on 17. August 2003, 07:36 */ -package board; +package net.freerouting.board; -import geometry.planar.FloatPoint; -import geometry.planar.Line; -import geometry.planar.LineSegment; -import geometry.planar.Point; -import geometry.planar.Polyline; -import geometry.planar.TileShape; -import geometry.planar.Side; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.LineSegment; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Side; /** * diff --git a/board/CalcShapeAndFromSide.java b/src/main/java/net/freerouting/board/CalcShapeAndFromSide.java similarity index 95% rename from board/CalcShapeAndFromSide.java rename to src/main/java/net/freerouting/board/CalcShapeAndFromSide.java index 7b2f2710..37a8e92c 100644 --- a/board/CalcShapeAndFromSide.java +++ b/src/main/java/net/freerouting/board/CalcShapeAndFromSide.java @@ -16,13 +16,13 @@ * Created on 1. September 2003, 08:40 */ -package board; +package net.freerouting.board; -import geometry.planar.FloatPoint; -import geometry.planar.Line; -import geometry.planar.Polyline; -import geometry.planar.Side; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.TileShape; /** * Used in the shove algorithm to calculate the fromside for pushing and diff --git a/board/ChangedArea.java b/src/main/java/net/freerouting/board/ChangedArea.java similarity index 94% rename from board/ChangedArea.java rename to src/main/java/net/freerouting/board/ChangedArea.java index 2bed394f..57d7c6b6 100644 --- a/board/ChangedArea.java +++ b/src/main/java/net/freerouting/board/ChangedArea.java @@ -14,10 +14,10 @@ * for more details. */ -package board; -import geometry.planar.FloatPoint; -import geometry.planar.IntBox; -import geometry.planar.IntOctagon; +package net.freerouting.board; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntOctagon; /** * @@ -66,7 +66,7 @@ public void join (FloatPoint p_point, int p_layer) /** * enlarges the octagon on p_layer, so that it contains p_shape */ - public void join (geometry.planar.TileShape p_shape, int p_layer) + public void join (net.freerouting.geometry.planar.TileShape p_shape, int p_layer) { if (p_shape == null) { diff --git a/board/ClearanceViolation.java b/src/main/java/net/freerouting/board/ClearanceViolation.java similarity index 92% rename from board/ClearanceViolation.java rename to src/main/java/net/freerouting/board/ClearanceViolation.java index d463d4f9..5bf92bc3 100644 --- a/board/ClearanceViolation.java +++ b/src/main/java/net/freerouting/board/ClearanceViolation.java @@ -18,9 +18,9 @@ * Created on 4. Oktober 2004, 08:56 */ -package board; +package net.freerouting.board; -import geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.ConvexShape; /** @@ -43,7 +43,7 @@ public ClearanceViolation(Item p_first_item, Item p_second_item, ConvexShape p_s public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("clearance_violation_2")); p_window.append(" " + resources.getString("at") + " "); p_window.append(shape.centre_of_gravity()); diff --git a/board/Communication.java b/src/main/java/net/freerouting/board/Communication.java similarity index 94% rename from board/Communication.java rename to src/main/java/net/freerouting/board/Communication.java index 781e11e5..1263b873 100644 --- a/board/Communication.java +++ b/src/main/java/net/freerouting/board/Communication.java @@ -18,10 +18,10 @@ * Created on 5. Juli 2004, 07:31 */ -package board; +package net.freerouting.board; -import datastructures.IdNoGenerator; -import designformats.specctra.CoordinateTransform; +import net.freerouting.datastructures.IdNoGenerator; +import net.freerouting.designformats.specctra.CoordinateTransform; /** * Communication information to host systems or host design formats. @@ -48,7 +48,7 @@ public Communication(Unit p_unit, int p_resolution, public Communication() { this(Unit.MIL, 1, new SpecctraParserInfo("\"", null, null, null, null, false), - new CoordinateTransform(1, 0, 0), new board.ItemIdNoGenerator(), new BoardObserverAdaptor()); + new CoordinateTransform(1, 0, 0), new net.freerouting.board.ItemIdNoGenerator(), new BoardObserverAdaptor()); } public boolean host_cad_is_eagle() diff --git a/board/Component.java b/src/main/java/net/freerouting/board/Component.java similarity index 93% rename from board/Component.java rename to src/main/java/net/freerouting/board/Component.java index c67ba63c..0fbd2687 100644 --- a/board/Component.java +++ b/src/main/java/net/freerouting/board/Component.java @@ -18,16 +18,16 @@ * Created on 27. Mai 2004, 07:23 */ -package board; +package net.freerouting.board; -import datastructures.UndoableObjects; +import net.freerouting.datastructures.UndoableObjects; -import geometry.planar.Point; -import geometry.planar.IntPoint; -import geometry.planar.Vector; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Vector; -import library.Package; +import net.freerouting.library.Package; /** @@ -199,7 +199,7 @@ public String toString() /** * Returns information for pin swap and gate swap, if != null. */ - public library.LogicalPart get_logical_part() + public net.freerouting.library.LogicalPart get_logical_part() { return this.logical_part; } @@ -207,7 +207,7 @@ public library.LogicalPart get_logical_part() /** * Sets the infomation for pin swap and gate swap. */ - public void set_logical_part(library.LogicalPart p_logical_part) + public void set_logical_part(net.freerouting.library.LogicalPart p_logical_part) { this.logical_part = p_logical_part; } @@ -215,7 +215,7 @@ public void set_logical_part(library.LogicalPart p_logical_part) public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("component") + " "); p_window.append_bold(this.name); if (this.location != null) @@ -277,7 +277,7 @@ public Package get_package() private double rotation_in_degree; /** Contains information for gate swapping and pin swapping, if != null */ - private library.LogicalPart logical_part = null; + private net.freerouting.library.LogicalPart logical_part = null; /** If false, the component will be placed on the back side of the board. */ private boolean on_front; diff --git a/board/ComponentObstacleArea.java b/src/main/java/net/freerouting/board/ComponentObstacleArea.java similarity index 88% rename from board/ComponentObstacleArea.java rename to src/main/java/net/freerouting/board/ComponentObstacleArea.java index 006ad912..56c879b2 100644 --- a/board/ComponentObstacleArea.java +++ b/src/main/java/net/freerouting/board/ComponentObstacleArea.java @@ -18,11 +18,11 @@ * Created on 8. Mai 2005, 07:28 */ -package board; +package net.freerouting.board; -import geometry.planar.Area; -import geometry.planar.Vector; +import net.freerouting.geometry.planar.Area; +import net.freerouting.geometry.planar.Vector; /** * Describes areas of the board, where components arre not allowed. @@ -71,12 +71,12 @@ public boolean is_selected_by_filter(ItemSelectionFilter p_filter) } - public java.awt.Color[] get_draw_colors(boardgraphics.GraphicsContext p_graphics_context) + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_place_obstacle_colors(); } - public double get_draw_intensity(boardgraphics.GraphicsContext p_graphics_context) + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_place_obstacle_color_intensity(); } @@ -93,7 +93,7 @@ public boolean is_selectrd_by_filter(ItemSelectionFilter p_filter) public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("component_keepout")); this.print_shape_info(p_window, p_locale); this.print_clearance_info(p_window, p_locale); diff --git a/board/ComponentOutline.java b/src/main/java/net/freerouting/board/ComponentOutline.java similarity index 92% rename from board/ComponentOutline.java rename to src/main/java/net/freerouting/board/ComponentOutline.java index 66460e75..e113ac13 100644 --- a/board/ComponentOutline.java +++ b/src/main/java/net/freerouting/board/ComponentOutline.java @@ -18,17 +18,17 @@ * Created on 28. November 2005, 06:42 * */ -package board; +package net.freerouting.board; import java.awt.Color; -import geometry.planar.Area; -import geometry.planar.Vector; -import geometry.planar.Point; -import geometry.planar.IntPoint; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Area; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.FloatPoint; -import boardgraphics.GraphicsContext; +import net.freerouting.boardgraphics.GraphicsContext; /** * @@ -103,9 +103,9 @@ public int tile_shape_count() return 0; } - protected geometry.planar.TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) + protected net.freerouting.geometry.planar.TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) { - return new geometry.planar.TileShape[0]; + return new net.freerouting.geometry.planar.TileShape[0]; } public double get_draw_intensity(GraphicsContext p_graphics_context) @@ -130,7 +130,7 @@ public Color[] get_draw_colors(GraphicsContext p_graphics_context) public int get_draw_priority() { - return boardgraphics.Drawable.MIDDLE_DRAW_PRIORITY; + return net.freerouting.boardgraphics.Drawable.MIDDLE_DRAW_PRIORITY; } public void draw(java.awt.Graphics p_g, GraphicsContext p_graphics_context, Color[] p_color_arr, double p_intensity) @@ -146,7 +146,7 @@ public void draw(java.awt.Graphics p_g, GraphicsContext p_graphics_context, Colo p_graphics_context.draw_boundary(this.get_area(), draw_width, color, p_g, intensity); } - public geometry.planar.IntBox bounding_box() + public net.freerouting.geometry.planar.IntBox bounding_box() { return get_area().bounding_box(); } diff --git a/board/Components.java b/src/main/java/net/freerouting/board/Components.java similarity index 96% rename from board/Components.java rename to src/main/java/net/freerouting/board/Components.java index 3859f583..f27d895c 100644 --- a/board/Components.java +++ b/src/main/java/net/freerouting/board/Components.java @@ -19,18 +19,18 @@ * */ -package board; +package net.freerouting.board; import java.util.Iterator; import java.util.Vector; -import datastructures.UndoableObjects; +import net.freerouting.datastructures.UndoableObjects; -import geometry.planar.Point; -import geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; -import library.Package; +import net.freerouting.library.Package; /** * Contains the lists of components on the board. @@ -168,7 +168,7 @@ private void restore_component_arr_from_undo_list(BoardObservers p_observers) * Moves the component with number p_component_no. * Works contrary to Component.translate_by with the undo algorithm of the board. */ - public void move(int p_component_no, geometry.planar.Vector p_vector ) + public void move(int p_component_no, net.freerouting.geometry.planar.Vector p_vector ) { Component curr_component = this.get(p_component_no); this.undo_list.save_for_undo(curr_component); diff --git a/board/ConductionArea.java b/src/main/java/net/freerouting/board/ConductionArea.java similarity index 91% rename from board/ConductionArea.java rename to src/main/java/net/freerouting/board/ConductionArea.java index 6ad8363b..5f726cac 100644 --- a/board/ConductionArea.java +++ b/src/main/java/net/freerouting/board/ConductionArea.java @@ -18,15 +18,15 @@ * Created on 29. Juni 2003, 11:49 */ -package board; +package net.freerouting.board; import java.util.Iterator; -import geometry.planar.Area; -import geometry.planar.Point; -import geometry.planar.Vector; -import geometry.planar.FloatPoint; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.Area; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.TileShape; import java.util.Set; import java.util.TreeSet; @@ -170,12 +170,12 @@ public boolean is_selected_by_filter(ItemSelectionFilter p_filter) return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.CONDUCTION); } - public java.awt.Color[] get_draw_colors(boardgraphics.GraphicsContext p_graphics_context) + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_conduction_colors(); } - public double get_draw_intensity(boardgraphics.GraphicsContext p_graphics_context) + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_conduction_color_intensity(); } @@ -183,7 +183,7 @@ public double get_draw_intensity(boardgraphics.GraphicsContext p_graphics_contex public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("conduction_area")); this.print_shape_info(p_window, p_locale); this.print_connectable_item_info(p_window, p_locale); diff --git a/board/Connectable.java b/src/main/java/net/freerouting/board/Connectable.java similarity index 96% rename from board/Connectable.java rename to src/main/java/net/freerouting/board/Connectable.java index 24dee2b4..95524e9c 100644 --- a/board/Connectable.java +++ b/src/main/java/net/freerouting/board/Connectable.java @@ -14,9 +14,9 @@ * for more details. */ -package board; +package net.freerouting.board; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.TileShape; import java.util.Set; diff --git a/board/CoordinateTransform.java b/src/main/java/net/freerouting/board/CoordinateTransform.java similarity index 77% rename from board/CoordinateTransform.java rename to src/main/java/net/freerouting/board/CoordinateTransform.java index c1c30a5e..39f1590a 100644 --- a/board/CoordinateTransform.java +++ b/src/main/java/net/freerouting/board/CoordinateTransform.java @@ -18,9 +18,9 @@ * Created on 17. Dezember 2004, 07:34 */ -package board; +package net.freerouting.board; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; /** * Class for transforming objects between user coordinate space and board coordinate space. @@ -76,20 +76,20 @@ public FloatPoint user_to_board(FloatPoint p_point) return new FloatPoint(user_to_board(p_point.x), user_to_board(p_point.y)); } - public PrintableShape board_to_user(geometry.planar.Shape p_shape, java.util.Locale p_locale) + public PrintableShape board_to_user(net.freerouting.geometry.planar.Shape p_shape, java.util.Locale p_locale) { PrintableShape result; - if (p_shape instanceof geometry.planar.Circle) + if (p_shape instanceof net.freerouting.geometry.planar.Circle) { - result = board_to_user((geometry.planar.Circle) p_shape, p_locale); + result = board_to_user((net.freerouting.geometry.planar.Circle) p_shape, p_locale); } - else if (p_shape instanceof geometry.planar.IntBox) + else if (p_shape instanceof net.freerouting.geometry.planar.IntBox) { - result = board_to_user((geometry.planar.IntBox) p_shape, p_locale); + result = board_to_user((net.freerouting.geometry.planar.IntBox) p_shape, p_locale); } - else if (p_shape instanceof geometry.planar.PolylineShape) + else if (p_shape instanceof net.freerouting.geometry.planar.PolylineShape) { - result = board_to_user((geometry.planar.PolylineShape) p_shape, p_locale); + result = board_to_user((net.freerouting.geometry.planar.PolylineShape) p_shape, p_locale); } else { @@ -99,19 +99,19 @@ else if (p_shape instanceof geometry.planar.PolylineShape) return result; } - public PrintableShape.Circle board_to_user(geometry.planar.Circle p_circle, java.util.Locale p_locale) + public PrintableShape.Circle board_to_user(net.freerouting.geometry.planar.Circle p_circle, java.util.Locale p_locale) { return new PrintableShape.Circle(board_to_user(p_circle.center.to_float()), board_to_user(p_circle.radius), p_locale); } - public PrintableShape.Rectangle board_to_user(geometry.planar.IntBox p_box, java.util.Locale p_locale) + public PrintableShape.Rectangle board_to_user(net.freerouting.geometry.planar.IntBox p_box, java.util.Locale p_locale) { return new PrintableShape.Rectangle(board_to_user(p_box.ll.to_float()), board_to_user(p_box.ur.to_float()), p_locale); } - public PrintableShape.Polygon board_to_user(geometry.planar.PolylineShape p_shape, java.util.Locale p_locale) + public PrintableShape.Polygon board_to_user(net.freerouting.geometry.planar.PolylineShape p_shape, java.util.Locale p_locale) { FloatPoint[] corners = p_shape.corner_approx_arr(); FloatPoint[] transformed_corners = new FloatPoint[corners.length]; diff --git a/board/DrillItem.java b/src/main/java/net/freerouting/board/DrillItem.java similarity index 96% rename from board/DrillItem.java rename to src/main/java/net/freerouting/board/DrillItem.java index 185a14aa..0e9b809f 100644 --- a/board/DrillItem.java +++ b/src/main/java/net/freerouting/board/DrillItem.java @@ -18,23 +18,23 @@ * Created on 27. Juni 2003, 11:38 */ -package board; +package net.freerouting.board; -import geometry.planar.IntBox; -import geometry.planar.FloatPoint; -import geometry.planar.Point; -import geometry.planar.IntPoint; -import geometry.planar.Shape; -import geometry.planar.TileShape; -import geometry.planar.Vector; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Vector; import java.util.Collection; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; -import library.Padstack; +import net.freerouting.library.Padstack; /** * Common superclass for Pins and Vias @@ -431,10 +431,10 @@ public void clear_derived_data() public int get_draw_priority() { - return boardgraphics.Drawable.MIDDLE_DRAW_PRIORITY; + return net.freerouting.boardgraphics.Drawable.MIDDLE_DRAW_PRIORITY; } - public void draw(java.awt.Graphics p_g, boardgraphics.GraphicsContext p_graphics_context, + public void draw(java.awt.Graphics p_g, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, java.awt.Color[] p_color_arr, double p_intensity) { if (p_graphics_context == null|| p_intensity <= 0) diff --git a/board/FixedState.java b/src/main/java/net/freerouting/board/FixedState.java similarity index 96% rename from board/FixedState.java rename to src/main/java/net/freerouting/board/FixedState.java index 3b4fe0f0..b7d3b8fb 100644 --- a/board/FixedState.java +++ b/src/main/java/net/freerouting/board/FixedState.java @@ -18,7 +18,7 @@ * Created on 15. Maerz 2005, 06:34 */ -package board; +package net.freerouting.board; /** * Sorted fixed states of board items. The strongest fixed states came last. diff --git a/board/ForcedPadAlgo.java b/src/main/java/net/freerouting/board/ForcedPadAlgo.java similarity index 97% rename from board/ForcedPadAlgo.java rename to src/main/java/net/freerouting/board/ForcedPadAlgo.java index fb17151f..a9c9e816 100644 --- a/board/ForcedPadAlgo.java +++ b/src/main/java/net/freerouting/board/ForcedPadAlgo.java @@ -18,20 +18,20 @@ * Created on 1. September 2003, 08:28 */ -package board; +package net.freerouting.board; -import datastructures.TimeLimit; +import net.freerouting.datastructures.TimeLimit; -import geometry.planar.Direction; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.IntBox; -import geometry.planar.IntOctagon; -import geometry.planar.Point; -import geometry.planar.Vector; -import geometry.planar.Line; -import geometry.planar.Polyline; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.Direction; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.TileShape; import java.util.Collection; diff --git a/board/ForcedViaAlgo.java b/src/main/java/net/freerouting/board/ForcedViaAlgo.java similarity index 94% rename from board/ForcedViaAlgo.java rename to src/main/java/net/freerouting/board/ForcedViaAlgo.java index 9ff43adb..e9bbc53a 100644 --- a/board/ForcedViaAlgo.java +++ b/src/main/java/net/freerouting/board/ForcedViaAlgo.java @@ -18,21 +18,21 @@ * Created on 25. April 2004, 09:55 */ -package board; +package net.freerouting.board; -import geometry.planar.ConvexShape; -import geometry.planar.IntPoint; -import geometry.planar.Point; -import geometry.planar.FloatPoint; -import geometry.planar.Shape; -import geometry.planar.TileShape; -import geometry.planar.Simplex; -import geometry.planar.IntBox; -import geometry.planar.Circle; -import geometry.planar.Vector; -import geometry.planar.Limits; -import rules.ViaInfo; -import library.Padstack; +import net.freerouting.geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Simplex; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.Circle; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Limits; +import net.freerouting.rules.ViaInfo; +import net.freerouting.library.Padstack; /** diff --git a/board/Item.java b/src/main/java/net/freerouting/board/Item.java similarity index 96% rename from board/Item.java rename to src/main/java/net/freerouting/board/Item.java index 7e8ae8a1..75ef9604 100644 --- a/board/Item.java +++ b/src/main/java/net/freerouting/board/Item.java @@ -13,17 +13,17 @@ * GNU General Public License at * for more details. */ -package board; +package net.freerouting.board; import java.util.Collection; import java.util.LinkedList; -import geometry.planar.Point; -import geometry.planar.IntPoint; -import geometry.planar.FloatPoint; -import geometry.planar.TileShape; -import geometry.planar.Vector; -import geometry.planar.IntBox; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.IntBox; import java.awt.Color; import java.awt.Graphics; @@ -32,13 +32,13 @@ import java.util.Set; import java.util.TreeSet; -import rules.Nets; -import boardgraphics.Drawable; -import boardgraphics.GraphicsContext; +import net.freerouting.rules.Nets; +import net.freerouting.boardgraphics.Drawable; +import net.freerouting.boardgraphics.GraphicsContext; -import datastructures.UndoableObjects; -import datastructures.ShapeTree; -import datastructures.ShapeTree.TreeEntry; +import net.freerouting.datastructures.UndoableObjects; +import net.freerouting.datastructures.ShapeTree; +import net.freerouting.datastructures.ShapeTree.TreeEntry; /** * Basic class of the items on a board. @@ -1212,11 +1212,11 @@ public void clear_search_tree_entries() * Gets the information for the autoroute algorithm. * Creates it, if it does not yet exist. */ - public autoroute.ItemAutorouteInfo get_autoroute_info() + public net.freerouting.autoroute.ItemAutorouteInfo get_autoroute_info() { if (autoroute_info == null) { - autoroute_info = new autoroute.ItemAutorouteInfo(this); + autoroute_info = new net.freerouting.autoroute.ItemAutorouteInfo(this); } return autoroute_info; } @@ -1224,7 +1224,7 @@ public autoroute.ItemAutorouteInfo get_autoroute_info() /** * Gets the information for the autoroute algorithm. */ - public autoroute.ItemAutorouteInfo get_autoroute_info_pur() + public net.freerouting.autoroute.ItemAutorouteInfo get_autoroute_info_pur() { return autoroute_info; } @@ -1256,11 +1256,11 @@ public void clear_derived_data() protected void print_net_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); for (int i = 0; i < this.net_count(); ++i) { p_window.append(", " + resources.getString("net") + " "); - rules.Net curr_net = board.rules.nets.get(this.get_net_no(i)); + net.freerouting.rules.Net curr_net = board.rules.nets.get(this.get_net_no(i)); p_window.append(curr_net.name, resources.getString("net_info"), curr_net); } } @@ -1273,7 +1273,7 @@ protected void print_clearance_info(ObjectInfoPanel p_window, java.util.Locale p if (this.clearance_class > 0) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append(", " + resources.getString("clearance_class") + " "); String name = board.rules.clearance_matrix.get_name(this.clearance_class); p_window.append(name, resources.getString("clearance_info"), board.rules.clearance_matrix.get_row(this.clearance_class)); @@ -1288,7 +1288,7 @@ protected void print_fixed_info(ObjectInfoPanel p_window, java.util.Locale p_loc if (this.fixed_state != FixedState.UNFIXED) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.FixedState", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.FixedState", p_locale); p_window.append(", "); p_window.append(resources.getString(this.fixed_state.toString())); } @@ -1303,7 +1303,7 @@ protected void print_contact_info(ObjectInfoPanel p_window, java.util.Locale p_l if (!contacts.isEmpty()) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append(", " + resources.getString("contacts") + " "); Integer contact_count = contacts.size(); p_window.append_items(contact_count.toString(), resources.getString("contact_info"), contacts); @@ -1319,7 +1319,7 @@ protected void print_clearance_violation_info(ObjectInfoPanel p_window, java.uti if (!clearance_violations.isEmpty()) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append(", "); Integer violation_count = clearance_violations.size(); Collection violations = new java.util.LinkedList(); @@ -1465,7 +1465,7 @@ boolean is_fanout_via(Set p_ignore_items) */ private boolean on_the_board = false; /** Temporary data used in the autoroute algorithm. */ - transient private autoroute.ItemAutorouteInfo autoroute_info = null; + transient private net.freerouting.autoroute.ItemAutorouteInfo autoroute_info = null; private static double PROTECT_FANOUT_LENGTH = 400; /** diff --git a/board/ItemIdNoGenerator.java b/src/main/java/net/freerouting/board/ItemIdNoGenerator.java similarity index 91% rename from board/ItemIdNoGenerator.java rename to src/main/java/net/freerouting/board/ItemIdNoGenerator.java index 57e41b33..fa72cf69 100644 --- a/board/ItemIdNoGenerator.java +++ b/src/main/java/net/freerouting/board/ItemIdNoGenerator.java @@ -18,14 +18,14 @@ * Created on 2. Juni 2003, 13:43 */ -package board; +package net.freerouting.board; /** * Creates unique Item identication nunbers. * * @author Alfons Wirtz */ -public class ItemIdNoGenerator implements datastructures.IdNoGenerator, java.io.Serializable +public class ItemIdNoGenerator implements net.freerouting.datastructures.IdNoGenerator, java.io.Serializable { /** diff --git a/board/ItemSearchTreesInfo.java b/src/main/java/net/freerouting/board/ItemSearchTreesInfo.java similarity index 96% rename from board/ItemSearchTreesInfo.java rename to src/main/java/net/freerouting/board/ItemSearchTreesInfo.java index 28def974..b8131d44 100644 --- a/board/ItemSearchTreesInfo.java +++ b/src/main/java/net/freerouting/board/ItemSearchTreesInfo.java @@ -19,14 +19,14 @@ * */ -package board; +package net.freerouting.board; import java.util.Collection; import java.util.LinkedList; -import datastructures.ShapeTree; +import net.freerouting.datastructures.ShapeTree; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.TileShape; /** * Stores information about the search trees of the board items, diff --git a/board/ItemSelectionFilter.java b/src/main/java/net/freerouting/board/ItemSelectionFilter.java similarity index 95% rename from board/ItemSelectionFilter.java rename to src/main/java/net/freerouting/board/ItemSelectionFilter.java index e64378ab..51fcb8a1 100644 --- a/board/ItemSelectionFilter.java +++ b/src/main/java/net/freerouting/board/ItemSelectionFilter.java @@ -18,7 +18,7 @@ * Created on 14. Dezember 2004, 10:57 */ -package board; +package net.freerouting.board; import java.util.Set; import java.util.TreeSet; @@ -118,10 +118,10 @@ public void deselect_all() /** * Filters a collection of items with this filter. */ - public Set filter(java.util.Set p_items) + public Set filter(java.util.Set p_items) { Set result = new TreeSet(); - for (board.Item curr_item : p_items) + for (net.freerouting.board.Item curr_item : p_items) { if (curr_item.is_selected_by_filter(this)) { diff --git a/board/Layer.java b/src/main/java/net/freerouting/board/Layer.java similarity index 97% rename from board/Layer.java rename to src/main/java/net/freerouting/board/Layer.java index 22d53a2e..c6ce8763 100644 --- a/board/Layer.java +++ b/src/main/java/net/freerouting/board/Layer.java @@ -18,7 +18,7 @@ * Created on 26. Mai 2004, 06:31 */ -package board; +package net.freerouting.board; /** * Describes the structure of a board layer. diff --git a/board/LayerStructure.java b/src/main/java/net/freerouting/board/LayerStructure.java similarity index 99% rename from board/LayerStructure.java rename to src/main/java/net/freerouting/board/LayerStructure.java index 7fe1f3ea..3dbaa072 100644 --- a/board/LayerStructure.java +++ b/src/main/java/net/freerouting/board/LayerStructure.java @@ -18,7 +18,7 @@ * Created on 26. Mai 2004, 06:37 */ -package board; +package net.freerouting.board; /** * Describes the layer structure of the board. diff --git a/board/MoveComponent.java b/src/main/java/net/freerouting/board/MoveComponent.java similarity index 96% rename from board/MoveComponent.java rename to src/main/java/net/freerouting/board/MoveComponent.java index b8c81977..9939cc01 100644 --- a/board/MoveComponent.java +++ b/src/main/java/net/freerouting/board/MoveComponent.java @@ -17,20 +17,20 @@ * * Created on 25. Oktober 2003, 09:03 */ -package board; +package net.freerouting.board; -import datastructures.TimeLimit; +import net.freerouting.datastructures.TimeLimit; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.Point; -import geometry.planar.Vector; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Vector; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import datastructures.Signum; +import net.freerouting.datastructures.Signum; /** * Class for moving a group of items on the board diff --git a/board/MoveDrillItemAlgo.java b/src/main/java/net/freerouting/board/MoveDrillItemAlgo.java similarity index 96% rename from board/MoveDrillItemAlgo.java rename to src/main/java/net/freerouting/board/MoveDrillItemAlgo.java index 0c683107..5320e9ef 100644 --- a/board/MoveDrillItemAlgo.java +++ b/src/main/java/net/freerouting/board/MoveDrillItemAlgo.java @@ -19,20 +19,20 @@ * */ -package board; +package net.freerouting.board; import java.util.Collection; -import datastructures.TimeLimit; +import net.freerouting.datastructures.TimeLimit; -import geometry.planar.TileShape; -import geometry.planar.ConvexShape; -import geometry.planar.IntOctagon; -import geometry.planar.IntBox; -import geometry.planar.IntPoint; -import geometry.planar.Point; -import geometry.planar.Vector; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.FloatPoint; /** diff --git a/board/ObjectInfoPanel.java b/src/main/java/net/freerouting/board/ObjectInfoPanel.java similarity index 92% rename from board/ObjectInfoPanel.java rename to src/main/java/net/freerouting/board/ObjectInfoPanel.java index 408d9a6a..85f98102 100644 --- a/board/ObjectInfoPanel.java +++ b/src/main/java/net/freerouting/board/ObjectInfoPanel.java @@ -18,7 +18,7 @@ * Created on 6. Januar 2005, 13:15 */ -package board; +package net.freerouting.board; /** * Output window for printing information about board objects. @@ -58,14 +58,14 @@ public interface ObjectInfoPanel * after transforming to the user coordinate sytem. * Returns false, if that was not possible. */ - boolean append(geometry.planar.FloatPoint p_point); + boolean append(net.freerouting.geometry.planar.FloatPoint p_point); /** * Appends p_shape to the window * after transforming to the user coordinate sytem. * Returns false, if that was not possible. */ - boolean append(geometry.planar.Shape p_shape, java.util.Locale p_locale); + boolean append(net.freerouting.geometry.planar.Shape p_shape, java.util.Locale p_locale); /** * Begins a new line in the window. @@ -88,7 +88,7 @@ public interface ObjectInfoPanel * Appends a link for creating a new PrintInfoWindow with the information * of p_items to the window. Returns false, if that was not possible. */ - boolean append_items( String p_link_name, String p_window_title, java.util.Collection p_items); + boolean append_items( String p_link_name, String p_window_title, java.util.Collection p_items); /** * Appends a link for creating a new PrintInfoWindow with the information diff --git a/board/ObstacleArea.java b/src/main/java/net/freerouting/board/ObstacleArea.java similarity index 93% rename from board/ObstacleArea.java rename to src/main/java/net/freerouting/board/ObstacleArea.java index 011334e0..7c3bf73e 100644 --- a/board/ObstacleArea.java +++ b/src/main/java/net/freerouting/board/ObstacleArea.java @@ -14,19 +14,19 @@ * for more details. */ -package board; +package net.freerouting.board; -import geometry.planar.IntBox; -import geometry.planar.IntPoint; -import geometry.planar.Area; -import geometry.planar.TileShape; -import geometry.planar.Vector; -import geometry.planar.Point; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Area; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.FloatPoint; import java.awt.Color; -import boardgraphics.GraphicsContext; +import net.freerouting.boardgraphics.GraphicsContext; /** * @@ -250,7 +250,7 @@ public double get_draw_intensity(GraphicsContext p_graphics_context) public int get_draw_priority() { - return boardgraphics.Drawable.MIN_DRAW_PRIORITY; + return net.freerouting.boardgraphics.Drawable.MIN_DRAW_PRIORITY; } public void draw(java.awt.Graphics p_g, GraphicsContext p_graphics_context, Color[] p_color_arr, double p_intensity) @@ -295,7 +295,7 @@ protected boolean get_side_changed() public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("keepout")); int cmp_no = this.get_component_no(); if (cmp_no > 0) @@ -315,9 +315,9 @@ public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) protected final void print_shape_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append(" " + resources.getString("at") + " "); - geometry.planar.FloatPoint center = this.get_area().get_border().centre_of_gravity(); + net.freerouting.geometry.planar.FloatPoint center = this.get_area().get_border().centre_of_gravity(); p_window.append(center); Integer hole_count = this.relative_area.get_holes().length; if(hole_count > 0) diff --git a/board/OptViaAlgo.java b/src/main/java/net/freerouting/board/OptViaAlgo.java similarity index 98% rename from board/OptViaAlgo.java rename to src/main/java/net/freerouting/board/OptViaAlgo.java index f327964f..216f5119 100644 --- a/board/OptViaAlgo.java +++ b/src/main/java/net/freerouting/board/OptViaAlgo.java @@ -19,20 +19,20 @@ * */ -package board; +package net.freerouting.board; import java.util.Collection; import java.util.Iterator; -import geometry.planar.Point; -import geometry.planar.IntPoint; -import geometry.planar.Vector; -import geometry.planar.Polyline; -import geometry.planar.FloatPoint; -import geometry.planar.FloatLine; -import geometry.planar.Side; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatLine; +import net.freerouting.geometry.planar.Side; -import autoroute.AutorouteControl.ExpansionCostFactor; +import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; /** * Contains functions for optimizing and improving via locations. diff --git a/board/Pin.java b/src/main/java/net/freerouting/board/Pin.java similarity index 95% rename from board/Pin.java rename to src/main/java/net/freerouting/board/Pin.java index 6a7b9394..67faf541 100644 --- a/board/Pin.java +++ b/src/main/java/net/freerouting/board/Pin.java @@ -18,22 +18,22 @@ * Created on 6. Juni 2003, 08:04 */ -package board; +package net.freerouting.board; -import geometry.planar.Point; -import geometry.planar.IntPoint; -import geometry.planar.Shape; -import geometry.planar.ConvexShape; -import geometry.planar.TileShape; -import geometry.planar.Vector; -import geometry.planar.Direction; -import geometry.planar.Line; -import geometry.planar.Polyline; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Direction; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.FloatPoint; -import library.Package; -import library.Padstack; +import net.freerouting.library.Package; +import net.freerouting.library.Padstack; /** * Class describing the functionality of an electrical Item on the board @@ -454,12 +454,12 @@ public java.util.Set get_swappable_pins() { return result; } - library.LogicalPart logical_part = component.get_logical_part(); + net.freerouting.library.LogicalPart logical_part = component.get_logical_part(); if (logical_part == null) { return result; } - library.LogicalPart.PartPin this_part_pin = logical_part.get_pin(this.pin_no); + net.freerouting.library.LogicalPart.PartPin this_part_pin = logical_part.get_pin(this.pin_no); if (this_part_pin == null) { return result; @@ -475,7 +475,7 @@ public java.util.Set get_swappable_pins() { continue; } - library.LogicalPart.PartPin curr_part_pin = logical_part.get_pin(i); + net.freerouting.library.LogicalPart.PartPin curr_part_pin = logical_part.get_pin(i); if (curr_part_pin != null && curr_part_pin.gate_pin_swap_code == this_part_pin.gate_pin_swap_code && curr_part_pin.gate_name.equals(this_part_pin.gate_name)) { @@ -502,7 +502,7 @@ public boolean is_selected_by_filter(ItemSelectionFilter p_filter) return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.PINS); } - public java.awt.Color[] get_draw_colors(boardgraphics.GraphicsContext p_graphics_context) + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { java.awt.Color[] result; if (this.net_count() > 0) @@ -517,7 +517,7 @@ public java.awt.Color[] get_draw_colors(boardgraphics.GraphicsContext p_graphics return result; } - public double get_draw_intensity(boardgraphics.GraphicsContext p_graphics_context) + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_pin_color_intensity(); } @@ -605,7 +605,7 @@ public double get_min_width(int p_layer) System.out.println("Pin.get_min_width: padstack_shape is null"); return 0; } - geometry.planar.IntBox padstack_bounding_box = padstack_shape.bounding_box(); + net.freerouting.geometry.planar.IntBox padstack_bounding_box = padstack_shape.bounding_box(); if (padstack_bounding_box == null) { System.out.println("Pin.get_min_width: padstack_bounding_box is null"); @@ -637,7 +637,7 @@ public double get_max_width(int p_layer) System.out.println("Pin.get_max_width: padstack_shape is null"); return 0; } - geometry.planar.IntBox padstack_bounding_box = padstack_shape.bounding_box(); + net.freerouting.geometry.planar.IntBox padstack_bounding_box = padstack_shape.bounding_box(); if (padstack_bounding_box == null) { System.out.println("Pin.get_max_width: padstack_bounding_box is null"); @@ -649,7 +649,7 @@ public double get_max_width(int p_layer) public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("pin") + ": "); p_window.append(resources.getString("component_2") + " "); Component component = board.components.get(this.get_component_no()); @@ -657,7 +657,7 @@ public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) p_window.append(", " + resources.getString("pin_2") + " "); p_window.append(component.get_package().get_pin(this.pin_no).name); p_window.append(", " + resources.getString("padstack") + " "); - library.Padstack padstack = this.get_padstack(); + net.freerouting.library.Padstack padstack = this.get_padstack(); p_window.append(padstack.name, resources.getString("padstack_info"), padstack); p_window.append(" " + resources.getString("at") + " "); p_window.append(this.get_center().to_float()); diff --git a/board/PolylineTrace.java b/src/main/java/net/freerouting/board/PolylineTrace.java similarity index 98% rename from board/PolylineTrace.java rename to src/main/java/net/freerouting/board/PolylineTrace.java index 797bc828..554aa972 100644 --- a/board/PolylineTrace.java +++ b/src/main/java/net/freerouting/board/PolylineTrace.java @@ -13,23 +13,23 @@ * GNU General Public License at * for more details. */ -package board; - -import datastructures.Signum; -import datastructures.Stoppable; - -import geometry.planar.IntBox; -import geometry.planar.IntOctagon; -import geometry.planar.Line; -import geometry.planar.LineSegment; -import geometry.planar.Point; -import geometry.planar.IntPoint; -import geometry.planar.FloatPoint; -import geometry.planar.Polyline; -import geometry.planar.Shape; -import geometry.planar.TileShape; -import geometry.planar.Direction; -import geometry.planar.Vector; +package net.freerouting.board; + +import net.freerouting.datastructures.Signum; +import net.freerouting.datastructures.Stoppable; + +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.LineSegment; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Direction; +import net.freerouting.geometry.planar.Vector; import java.awt.Color; import java.awt.Graphics; @@ -37,7 +37,7 @@ import java.util.Iterator; import java.util.LinkedList; -import boardgraphics.GraphicsContext; +import net.freerouting.boardgraphics.GraphicsContext; /** * @@ -649,7 +649,7 @@ else if (!this.is_user_fixed() && (found_item instanceof ConductionArea)) boolean ignore_areas = false; if (this.net_no_arr.length > 0) { - rules.Net curr_net = this.board.rules.nets.get(this.net_no_arr[0]); + net.freerouting.rules.Net curr_net = this.board.rules.nets.get(this.net_no_arr[0]); if (curr_net != null && curr_net.get_class() != null) { ignore_areas = curr_net.get_class().get_ignore_cycles_with_areas(); diff --git a/board/PrintableShape.java b/src/main/java/net/freerouting/board/PrintableShape.java similarity index 90% rename from board/PrintableShape.java rename to src/main/java/net/freerouting/board/PrintableShape.java index 6d82bfcd..65acb679 100644 --- a/board/PrintableShape.java +++ b/src/main/java/net/freerouting/board/PrintableShape.java @@ -18,9 +18,9 @@ * Created on 5. Januar 2005, 08:02 */ -package board; +package net.freerouting.board; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; /** * Shape class used for printing a geometry.planar.Shape after transforming it to user coordinates. @@ -56,7 +56,7 @@ public Circle(FloatPoint p_center, double p_radius, java.util.Locale p_locale) public String toString() { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", this.locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", this.locale); String result = resources.getString("circle") + ": "; if (center.x != 0 || center.y != 0) { @@ -89,7 +89,7 @@ public Rectangle(FloatPoint p_lower_left, FloatPoint p_upper_right, java.util.Lo public String toString() { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", this.locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", this.locale); String result = resources.getString("rectangle") + ": " + resources.getString("lower_left") + " = " + lower_left.to_string(this.locale) + ", " + resources.getString("upper_right") + " = " + upper_right.to_string(this.locale) ; @@ -112,7 +112,7 @@ public Polygon(FloatPoint[] p_corners, java.util.Locale p_locale) public String toString() { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", this.locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", this.locale); String result = resources.getString("polygon") + ": "; for (int i = 0; i < corner_arr.length; ++i) { diff --git a/board/PullTightAlgo.java b/src/main/java/net/freerouting/board/PullTightAlgo.java similarity index 97% rename from board/PullTightAlgo.java rename to src/main/java/net/freerouting/board/PullTightAlgo.java index 2f9583f8..8cf20553 100644 --- a/board/PullTightAlgo.java +++ b/src/main/java/net/freerouting/board/PullTightAlgo.java @@ -17,26 +17,26 @@ * * Created on 19. Juli 2003, 12:42 */ -package board; +package net.freerouting.board; -import geometry.planar.FloatPoint; -import geometry.planar.IntOctagon; -import geometry.planar.IntPoint; -import geometry.planar.Line; -import geometry.planar.Point; -import geometry.planar.Polyline; -import geometry.planar.Side; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.TileShape; import java.util.Collection; import java.util.Iterator; import java.util.Set; -import datastructures.Signum; -import datastructures.Stoppable; -import datastructures.TimeLimit; +import net.freerouting.datastructures.Signum; +import net.freerouting.datastructures.Stoppable; +import net.freerouting.datastructures.TimeLimit; -import autoroute.AutorouteControl.ExpansionCostFactor; +import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; /** * Class with functionality for optimising traces and vias. diff --git a/board/PullTightAlgo45.java b/src/main/java/net/freerouting/board/PullTightAlgo45.java similarity index 98% rename from board/PullTightAlgo45.java rename to src/main/java/net/freerouting/board/PullTightAlgo45.java index af7215a2..64eb69b6 100644 --- a/board/PullTightAlgo45.java +++ b/src/main/java/net/freerouting/board/PullTightAlgo45.java @@ -17,21 +17,21 @@ * * Created on 19. Juli 2003, 18:59 */ -package board; +package net.freerouting.board; -import datastructures.Stoppable; +import net.freerouting.datastructures.Stoppable; -import geometry.planar.Direction; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.Limits; -import geometry.planar.Line; -import geometry.planar.Point; -import geometry.planar.Polyline; -import geometry.planar.Side; -import geometry.planar.TileShape; -import geometry.planar.Vector; -import datastructures.Signum; +import net.freerouting.geometry.planar.Direction; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Limits; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.datastructures.Signum; /** * diff --git a/board/PullTightAlgo90.java b/src/main/java/net/freerouting/board/PullTightAlgo90.java similarity index 95% rename from board/PullTightAlgo90.java rename to src/main/java/net/freerouting/board/PullTightAlgo90.java index d54faae9..89dd2afa 100644 --- a/board/PullTightAlgo90.java +++ b/src/main/java/net/freerouting/board/PullTightAlgo90.java @@ -18,15 +18,15 @@ * Created on 19. Juli 2003, 18:54 */ -package board; +package net.freerouting.board; -import datastructures.Stoppable; +import net.freerouting.datastructures.Stoppable; -import geometry.planar.FloatPoint; -import geometry.planar.Point; -import geometry.planar.Line; -import geometry.planar.Polyline; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.TileShape; /** * diff --git a/board/PullTightAlgoAnyAngle.java b/src/main/java/net/freerouting/board/PullTightAlgoAnyAngle.java similarity index 98% rename from board/PullTightAlgoAnyAngle.java rename to src/main/java/net/freerouting/board/PullTightAlgoAnyAngle.java index 25e52f81..7751eb9a 100644 --- a/board/PullTightAlgoAnyAngle.java +++ b/src/main/java/net/freerouting/board/PullTightAlgoAnyAngle.java @@ -14,20 +14,20 @@ * for more details. */ -package board; +package net.freerouting.board; -import datastructures.Stoppable; -import geometry.planar.Limits; -import datastructures.Signum; +import net.freerouting.datastructures.Stoppable; +import net.freerouting.geometry.planar.Limits; +import net.freerouting.datastructures.Signum; -import geometry.planar.Direction; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.Point; -import geometry.planar.Line; -import geometry.planar.Polyline; -import geometry.planar.Side; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.Direction; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.TileShape; /** * diff --git a/board/RoutingBoard.java b/src/main/java/net/freerouting/board/RoutingBoard.java similarity index 97% rename from board/RoutingBoard.java rename to src/main/java/net/freerouting/board/RoutingBoard.java index 16a72b08..e583e487 100644 --- a/board/RoutingBoard.java +++ b/src/main/java/net/freerouting/board/RoutingBoard.java @@ -13,18 +13,18 @@ * GNU General Public License at * for more details. */ -package board; +package net.freerouting.board; -import geometry.planar.FloatPoint; -import geometry.planar.IntBox; -import geometry.planar.IntOctagon; -import geometry.planar.IntPoint; -import geometry.planar.LineSegment; -import geometry.planar.Point; -import geometry.planar.Polyline; -import geometry.planar.PolylineShape; -import geometry.planar.TileShape; -import geometry.planar.Vector; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.LineSegment; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.PolylineShape; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Vector; import java.util.Collection; import java.util.Iterator; @@ -32,18 +32,18 @@ import java.util.SortedSet; import java.util.TreeSet; -import datastructures.UndoableObjects; -import datastructures.Stoppable; -import datastructures.TimeLimit; -import datastructures.ShapeTree.TreeEntry; +import net.freerouting.datastructures.UndoableObjects; +import net.freerouting.datastructures.Stoppable; +import net.freerouting.datastructures.TimeLimit; +import net.freerouting.datastructures.ShapeTree.TreeEntry; -import rules.ViaInfo; -import rules.BoardRules; +import net.freerouting.rules.ViaInfo; +import net.freerouting.rules.BoardRules; -import autoroute.AutorouteControl; -import autoroute.AutorouteEngine; -import autoroute.AutorouteControl.ExpansionCostFactor; -import autoroute.CompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.AutorouteControl; +import net.freerouting.autoroute.AutorouteEngine; +import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; +import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; /** * @@ -934,7 +934,7 @@ public void finish_autoroute() * is not yet electrically connected. * Returns an enum of type AutorouteEngine.AutorouteResult */ - public AutorouteEngine.AutorouteResult autoroute(Item p_item, interactive.Settings p_settings, int p_via_costs, Stoppable p_stoppable_thread, TimeLimit p_time_limit) + public AutorouteEngine.AutorouteResult autoroute(Item p_item, net.freerouting.interactive.Settings p_settings, int p_via_costs, Stoppable p_stoppable_thread, TimeLimit p_time_limit) { if (!(p_item instanceof Connectable) || p_item.net_count() == 0) { @@ -948,12 +948,12 @@ public AutorouteEngine.AutorouteResult autoroute(Item p_item, interactive.Settin AutorouteControl ctrl_settings = new AutorouteControl(this, route_net_no, p_settings, p_via_costs, p_settings.autoroute_settings.get_trace_cost_arr()); ctrl_settings.remove_unconnected_vias = false; Set route_start_set = p_item.get_connected_set(route_net_no); - rules.Net route_net = rules.nets.get(route_net_no); + net.freerouting.rules.Net route_net = rules.nets.get(route_net_no); if (route_net != null && route_net.contains_plane()) { for (Item curr_item : route_start_set) { - if (curr_item instanceof board.ConductionArea) + if (curr_item instanceof net.freerouting.board.ConductionArea) { return AutorouteEngine.AutorouteResult.ALREADY_CONNECTED; // already connected to plane } @@ -982,7 +982,7 @@ public AutorouteEngine.AutorouteResult autoroute(Item p_item, interactive.Settin * has only 1 layer. Ripup is allowed if p_ripup_costs is >= 0. * Returns an enum of type AutorouteEngine.AutorouteResult */ - public AutorouteEngine.AutorouteResult fanout(Pin p_pin, interactive.Settings p_settings, int p_ripup_costs, + public AutorouteEngine.AutorouteResult fanout(Pin p_pin, net.freerouting.interactive.Settings p_settings, int p_ripup_costs, Stoppable p_stoppable_thread, TimeLimit p_time_limit) { if (p_pin.first_layer() != p_pin.last_layer() || p_pin.net_count() != 1) diff --git a/board/SearchTreeManager.java b/src/main/java/net/freerouting/board/SearchTreeManager.java similarity index 97% rename from board/SearchTreeManager.java rename to src/main/java/net/freerouting/board/SearchTreeManager.java index 03e32448..4bdc3b04 100644 --- a/board/SearchTreeManager.java +++ b/src/main/java/net/freerouting/board/SearchTreeManager.java @@ -19,17 +19,17 @@ * */ -package board; +package net.freerouting.board; import java.util.Collection; import java.util.LinkedList; import java.util.Iterator; -import datastructures.UndoableObjects; -import datastructures.ShapeTree; +import net.freerouting.datastructures.UndoableObjects; +import net.freerouting.datastructures.ShapeTree; -import geometry.planar.FortyfiveDegreeBoundingDirections; -import geometry.planar.Polyline; +import net.freerouting.geometry.planar.FortyfiveDegreeBoundingDirections; +import net.freerouting.geometry.planar.Polyline; /** * diff --git a/board/SearchTreeObject.java b/src/main/java/net/freerouting/board/SearchTreeObject.java similarity index 91% rename from board/SearchTreeObject.java rename to src/main/java/net/freerouting/board/SearchTreeObject.java index 3e0d5877..d362d4cd 100644 --- a/board/SearchTreeObject.java +++ b/src/main/java/net/freerouting/board/SearchTreeObject.java @@ -18,14 +18,14 @@ * Created on 10. Januar 2004, 10:08 */ -package board; +package net.freerouting.board; /** * Common ShapeSearchTree functionality for board.Items and autoroute.ExpansionRooms * * @author Alfons Wirtz */ -public interface SearchTreeObject extends datastructures.ShapeTree.Storable +public interface SearchTreeObject extends net.freerouting.datastructures.ShapeTree.Storable { /** * Returns true if this object is an obstacle to objects containing diff --git a/board/ShapeSearchTree.java b/src/main/java/net/freerouting/board/ShapeSearchTree.java similarity index 97% rename from board/ShapeSearchTree.java rename to src/main/java/net/freerouting/board/ShapeSearchTree.java index 6849e13b..8ba5d7d7 100644 --- a/board/ShapeSearchTree.java +++ b/src/main/java/net/freerouting/board/ShapeSearchTree.java @@ -17,22 +17,22 @@ * * Created on 1. September 2004, 10:13 */ -package board; - -import geometry.planar.ConvexShape; -import geometry.planar.ShapeBoundingDirections; -import geometry.planar.IntOctagon; -import geometry.planar.Line; -import geometry.planar.LineSegment; -import geometry.planar.Polyline; -import geometry.planar.PolylineShape; -import geometry.planar.RegularTileShape; -import geometry.planar.Shape; -import geometry.planar.Side; -import geometry.planar.Simplex; -import geometry.planar.TileShape; -import geometry.planar.IntBox; -import geometry.planar.FloatPoint; +package net.freerouting.board; + +import net.freerouting.geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.ShapeBoundingDirections; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.LineSegment; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.PolylineShape; +import net.freerouting.geometry.planar.RegularTileShape; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.Simplex; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.FloatPoint; import java.util.Collection; import java.util.Iterator; @@ -40,12 +40,12 @@ import java.util.Set; import java.util.TreeSet; -import rules.ClearanceMatrix; +import net.freerouting.rules.ClearanceMatrix; -import datastructures.Signum; +import net.freerouting.datastructures.Signum; -import autoroute.IncompleteFreeSpaceExpansionRoom; -import autoroute.CompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.IncompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; /** * @@ -55,7 +55,7 @@ * * @author Alfons Wirtz */ -public class ShapeSearchTree extends datastructures.MinAreaTree +public class ShapeSearchTree extends net.freerouting.datastructures.MinAreaTree { /** diff --git a/board/ShapeSearchTree45Degree.java b/src/main/java/net/freerouting/board/ShapeSearchTree45Degree.java similarity index 97% rename from board/ShapeSearchTree45Degree.java rename to src/main/java/net/freerouting/board/ShapeSearchTree45Degree.java index 0905ac4c..ff82bf96 100644 --- a/board/ShapeSearchTree45Degree.java +++ b/src/main/java/net/freerouting/board/ShapeSearchTree45Degree.java @@ -18,21 +18,21 @@ * Created on 15. Juli 2007, 07:26 * */ -package board; +package net.freerouting.board; import java.util.Collection; import java.util.LinkedList; -import geometry.planar.FortyfiveDegreeBoundingDirections; -import geometry.planar.TileShape; -import geometry.planar.Shape; -import geometry.planar.IntOctagon; -import geometry.planar.IntBox; -import geometry.planar.Side; -import geometry.planar.Line; +import net.freerouting.geometry.planar.FortyfiveDegreeBoundingDirections; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.Line; -import autoroute.IncompleteFreeSpaceExpansionRoom; -import autoroute.CompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.IncompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; /** * A special simple ShapeSearchtree, where the shapes are of class IntOctagon. diff --git a/board/ShapeSearchTree90Degree.java b/src/main/java/net/freerouting/board/ShapeSearchTree90Degree.java similarity index 97% rename from board/ShapeSearchTree90Degree.java rename to src/main/java/net/freerouting/board/ShapeSearchTree90Degree.java index 551a99c2..255c485f 100644 --- a/board/ShapeSearchTree90Degree.java +++ b/src/main/java/net/freerouting/board/ShapeSearchTree90Degree.java @@ -19,19 +19,19 @@ * */ -package board; +package net.freerouting.board; import java.util.Collection; import java.util.LinkedList; -import geometry.planar.OrthogonalBoundingDirections; -import geometry.planar.TileShape; -import geometry.planar.Shape; -import geometry.planar.IntBox; -import geometry.planar.Polyline; +import net.freerouting.geometry.planar.OrthogonalBoundingDirections; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.Polyline; -import autoroute.IncompleteFreeSpaceExpansionRoom; -import autoroute.CompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.IncompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; /** * A special simple ShapeSearchtree, where the shapes are of class IntBox. diff --git a/board/ShapeTraceEntries.java b/src/main/java/net/freerouting/board/ShapeTraceEntries.java similarity index 99% rename from board/ShapeTraceEntries.java rename to src/main/java/net/freerouting/board/ShapeTraceEntries.java index 09d3f60c..35b436ae 100644 --- a/board/ShapeTraceEntries.java +++ b/src/main/java/net/freerouting/board/ShapeTraceEntries.java @@ -14,14 +14,14 @@ * for more details. */ -package board; +package net.freerouting.board; -import geometry.planar.ConvexShape; -import geometry.planar.FloatPoint; -import geometry.planar.Line; -import geometry.planar.Point; -import geometry.planar.Polyline; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.TileShape; import java.util.Collection; import java.util.Iterator; diff --git a/board/ShoveTraceAlgo.java b/src/main/java/net/freerouting/board/ShoveTraceAlgo.java similarity index 97% rename from board/ShoveTraceAlgo.java rename to src/main/java/net/freerouting/board/ShoveTraceAlgo.java index 2607ef3f..6c77cf9e 100644 --- a/board/ShoveTraceAlgo.java +++ b/src/main/java/net/freerouting/board/ShoveTraceAlgo.java @@ -13,21 +13,21 @@ * GNU General Public License at * for more details. */ -package board; - -import datastructures.TimeLimit; - -import geometry.planar.ConvexShape; -import geometry.planar.Direction; -import geometry.planar.FloatPoint; -import geometry.planar.IntBox; -import geometry.planar.Line; -import geometry.planar.Point; -import geometry.planar.IntPoint; -import geometry.planar.Vector; -import geometry.planar.Polyline; -import geometry.planar.TileShape; -import geometry.planar.LineSegment; +package net.freerouting.board; + +import net.freerouting.datastructures.TimeLimit; + +import net.freerouting.geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.Direction; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.LineSegment; import java.util.Collection; import java.util.Iterator; @@ -244,7 +244,7 @@ public static double check(RoutingBoard p_board, LineSegment p_line_segment, boo FloatPoint end_corner_appprox = p_line_segment.end_point_approx(); double segment_length = end_corner_appprox.distance(start_corner_appprox); - rules.ClearanceMatrix cl_matrix = p_board.rules.clearance_matrix; + net.freerouting.rules.ClearanceMatrix cl_matrix = p_board.rules.clearance_matrix; double result = Integer.MAX_VALUE; diff --git a/board/TestLevel.java b/src/main/java/net/freerouting/board/TestLevel.java similarity index 96% rename from board/TestLevel.java rename to src/main/java/net/freerouting/board/TestLevel.java index e72de5ac..5476588e 100644 --- a/board/TestLevel.java +++ b/src/main/java/net/freerouting/board/TestLevel.java @@ -19,7 +19,7 @@ * */ -package board; +package net.freerouting.board; /** * If > RELEASE, some features may be used, which are still in experimental state. diff --git a/board/Trace.java b/src/main/java/net/freerouting/board/Trace.java similarity index 95% rename from board/Trace.java rename to src/main/java/net/freerouting/board/Trace.java index 67bc1ba5..cb893eab 100644 --- a/board/Trace.java +++ b/src/main/java/net/freerouting/board/Trace.java @@ -14,12 +14,12 @@ * for more details. */ -package board; +package net.freerouting.board; -import geometry.planar.FloatPoint; -import geometry.planar.IntOctagon; -import geometry.planar.Point; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.TileShape; import java.util.Collection; import java.util.Iterator; @@ -177,17 +177,17 @@ public boolean is_tail() } - public java.awt.Color[] get_draw_colors(boardgraphics.GraphicsContext p_graphics_context) + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_trace_colors(this.is_user_fixed()); } public int get_draw_priority() { - return boardgraphics.Drawable.MAX_DRAW_PRIORITY; + return net.freerouting.boardgraphics.Drawable.MAX_DRAW_PRIORITY; } - public double get_draw_intensity(boardgraphics.GraphicsContext p_graphics_context) + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_trace_color_intensity(); } @@ -316,10 +316,10 @@ public boolean is_shove_fixed() } // check, if the trace belongs to a net, which is not shovable. - rules.Nets nets = this.board.rules.nets; + net.freerouting.rules.Nets nets = this.board.rules.nets; for (int curr_net_no : this.net_no_arr) { - if (rules.Nets.is_normal_net_no(curr_net_no)) + if (net.freerouting.rules.Nets.is_normal_net_no(curr_net_no)) { if (nets.get(curr_net_no).get_class().is_shove_fixed()) { @@ -376,7 +376,7 @@ public boolean is_cycle() boolean ignore_areas = false; if (this.net_no_arr.length > 0) { - rules.Net curr_net = this.board.rules.nets.get(this.net_no_arr[0]); + net.freerouting.rules.Net curr_net = this.board.rules.nets.get(this.net_no_arr[0]); if (curr_net != null && curr_net.get_class() != null) { ignore_areas = curr_net.get_class().get_ignore_cycles_with_areas(); @@ -486,7 +486,7 @@ Set touching_pins_at_end_corners() public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("trace")); p_window.append(" " + resources.getString("from")); p_window.append(this.first_corner().to_float()); diff --git a/board/Unit.java b/src/main/java/net/freerouting/board/Unit.java similarity index 99% rename from board/Unit.java rename to src/main/java/net/freerouting/board/Unit.java index efc06183..cb30e1c7 100644 --- a/board/Unit.java +++ b/src/main/java/net/freerouting/board/Unit.java @@ -18,7 +18,7 @@ * Created on 13. Dezember 2004, 08:01 */ -package board; +package net.freerouting.board; /** * Enum for the userunits inch, mil or millimeter. diff --git a/board/Via.java b/src/main/java/net/freerouting/board/Via.java similarity index 88% rename from board/Via.java rename to src/main/java/net/freerouting/board/Via.java index e406784e..fd10c9c2 100644 --- a/board/Via.java +++ b/src/main/java/net/freerouting/board/Via.java @@ -17,17 +17,17 @@ * * Created on 5. Juni 2003, 10:36 */ -package board; +package net.freerouting.board; import java.util.Collection; import java.util.Iterator; -import geometry.planar.Point; -import geometry.planar.IntPoint; -import geometry.planar.TileShape; -import geometry.planar.Shape; -import geometry.planar.Vector; -import library.Padstack; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.library.Padstack; /** * Class describing the functionality of an electrical Item on the board, @@ -164,14 +164,14 @@ public void change_placement_side(IntPoint p_pole) clear_derived_data(); } - public autoroute.ExpansionDrill get_autoroute_drill_info(ShapeSearchTree p_autoroute_tree) + public net.freerouting.autoroute.ExpansionDrill get_autoroute_drill_info(ShapeSearchTree p_autoroute_tree) { if (this.autoroute_drill_info == null) { - autoroute.ItemAutorouteInfo via_autoroute_info = this.get_autoroute_info(); + net.freerouting.autoroute.ItemAutorouteInfo via_autoroute_info = this.get_autoroute_info(); TileShape curr_drill_shape = TileShape.get_instance(this.get_center()); this.autoroute_drill_info = - new autoroute.ExpansionDrill(curr_drill_shape, this.get_center(), this.first_layer(), this.last_layer()); + new net.freerouting.autoroute.ExpansionDrill(curr_drill_shape, this.get_center(), this.first_layer(), this.last_layer()); int via_layer_count = this.last_layer() - this.first_layer() + 1; for (int i = 0; i < via_layer_count; ++i) { @@ -203,7 +203,7 @@ public boolean is_selected_by_filter(ItemSelectionFilter p_filter) return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.VIAS); } - public java.awt.Color[] get_draw_colors(boardgraphics.GraphicsContext p_graphics_context) + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { java.awt.Color[] result; if (this.net_count() == 0) @@ -224,7 +224,7 @@ else if (this.first_layer() >= this.last_layer()) return result; } - public double get_draw_intensity(boardgraphics.GraphicsContext p_graphics_context) + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { double result; if (this.net_count() == 0) @@ -248,7 +248,7 @@ else if (this.first_layer() >= this.last_layer()) public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("via")); p_window.append(" " + resources.getString("at")); p_window.append(this.get_center().to_float()); @@ -274,5 +274,5 @@ public boolean write(java.io.ObjectOutputStream p_stream) public final boolean attach_allowed; transient private Shape[] precalculated_shapes = null; /** Temporary data used in the autoroute algorithm. */ - transient private autoroute.ExpansionDrill autoroute_drill_info = null; + transient private net.freerouting.autoroute.ExpansionDrill autoroute_drill_info = null; } diff --git a/board/ViaObstacleArea.java b/src/main/java/net/freerouting/board/ViaObstacleArea.java similarity index 88% rename from board/ViaObstacleArea.java rename to src/main/java/net/freerouting/board/ViaObstacleArea.java index 1298edd4..668a9b88 100644 --- a/board/ViaObstacleArea.java +++ b/src/main/java/net/freerouting/board/ViaObstacleArea.java @@ -18,10 +18,10 @@ * Created on 19. August 2004, 07:34 */ -package board; +package net.freerouting.board; -import geometry.planar.Area; -import geometry.planar.Vector; +import net.freerouting.geometry.planar.Area; +import net.freerouting.geometry.planar.Vector; /** * Describes Areas on the board, where vias are not allowed. @@ -85,7 +85,7 @@ public boolean is_selected_by_filter(ItemSelectionFilter p_filter) public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("via_keepout")); this.print_shape_info(p_window, p_locale); this.print_clearance_info(p_window, p_locale); @@ -93,12 +93,12 @@ public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) p_window.newline(); } - public java.awt.Color[] get_draw_colors(boardgraphics.GraphicsContext p_graphics_context) + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_via_obstacle_colors(); } - public double get_draw_intensity(boardgraphics.GraphicsContext p_graphics_context) + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_via_obstacle_color_intensity(); } diff --git a/board/package.html b/src/main/java/net/freerouting/board/package.html similarity index 100% rename from board/package.html rename to src/main/java/net/freerouting/board/package.html diff --git a/boardgraphics/ColorIntensityTable.java b/src/main/java/net/freerouting/boardgraphics/ColorIntensityTable.java similarity index 98% rename from boardgraphics/ColorIntensityTable.java rename to src/main/java/net/freerouting/boardgraphics/ColorIntensityTable.java index 654d11ab..dedddc2f 100644 --- a/boardgraphics/ColorIntensityTable.java +++ b/src/main/java/net/freerouting/boardgraphics/ColorIntensityTable.java @@ -18,7 +18,7 @@ * Created on 1. August 2004, 07:46 */ -package boardgraphics; +package net.freerouting.boardgraphics; /** * The color intensities for each item type. diff --git a/boardgraphics/ColorTableModel.java b/src/main/java/net/freerouting/boardgraphics/ColorTableModel.java similarity index 98% rename from boardgraphics/ColorTableModel.java rename to src/main/java/net/freerouting/boardgraphics/ColorTableModel.java index 67d1b23b..d940a6c6 100644 --- a/boardgraphics/ColorTableModel.java +++ b/src/main/java/net/freerouting/boardgraphics/ColorTableModel.java @@ -17,7 +17,7 @@ * * Created on 5. August 2003, 10:18 */ -package boardgraphics; +package net.freerouting.boardgraphics; import javax.swing.table.AbstractTableModel; diff --git a/boardgraphics/CoordinateTransform.java b/src/main/java/net/freerouting/boardgraphics/CoordinateTransform.java similarity index 98% rename from boardgraphics/CoordinateTransform.java rename to src/main/java/net/freerouting/boardgraphics/CoordinateTransform.java index 73afc792..749c0245 100644 --- a/boardgraphics/CoordinateTransform.java +++ b/src/main/java/net/freerouting/boardgraphics/CoordinateTransform.java @@ -14,11 +14,11 @@ * for more details. */ -package boardgraphics; +package net.freerouting.boardgraphics; -import geometry.planar.FloatPoint; -import geometry.planar.IntBox; -import geometry.planar.Limits; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.Limits; import java.awt.Dimension; import java.awt.geom.Point2D; diff --git a/boardgraphics/Drawable.java b/src/main/java/net/freerouting/boardgraphics/Drawable.java similarity index 98% rename from boardgraphics/Drawable.java rename to src/main/java/net/freerouting/boardgraphics/Drawable.java index b3547033..f713be2c 100644 --- a/boardgraphics/Drawable.java +++ b/src/main/java/net/freerouting/boardgraphics/Drawable.java @@ -14,7 +14,7 @@ * for more details. */ -package boardgraphics; +package net.freerouting.boardgraphics; import java.awt.Color; import java.awt.Graphics; diff --git a/boardgraphics/GraphicsContext.java b/src/main/java/net/freerouting/boardgraphics/GraphicsContext.java similarity index 98% rename from boardgraphics/GraphicsContext.java rename to src/main/java/net/freerouting/boardgraphics/GraphicsContext.java index 87e844c6..05683957 100644 --- a/boardgraphics/GraphicsContext.java +++ b/src/main/java/net/freerouting/boardgraphics/GraphicsContext.java @@ -14,16 +14,16 @@ * for more details. */ -package boardgraphics; +package net.freerouting.boardgraphics; -import geometry.planar.Area; -import geometry.planar.Circle; -import geometry.planar.Ellipse; -import geometry.planar.FloatPoint; -import geometry.planar.IntBox; -import geometry.planar.PolylineShape; -import geometry.planar.Shape; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.Area; +import net.freerouting.geometry.planar.Circle; +import net.freerouting.geometry.planar.Ellipse; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.PolylineShape; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.TileShape; import java.awt.AlphaComposite; import java.awt.BasicStroke; @@ -52,7 +52,7 @@ public class GraphicsContext implements java.io.Serializable { public GraphicsContext( IntBox p_design_bounds, - Dimension p_panel_bounds, board.LayerStructure p_layer_structure, java.util.Locale p_locale) + Dimension p_panel_bounds, net.freerouting.board.LayerStructure p_layer_structure, java.util.Locale p_locale) { coordinate_transform = new CoordinateTransform(p_design_bounds, p_panel_bounds); item_color_table = new ItemColorTableModel(p_layer_structure, p_locale); diff --git a/boardgraphics/ItemColorTableModel.java b/src/main/java/net/freerouting/boardgraphics/ItemColorTableModel.java similarity index 97% rename from boardgraphics/ItemColorTableModel.java rename to src/main/java/net/freerouting/boardgraphics/ItemColorTableModel.java index 49110a67..5f3255a6 100644 --- a/boardgraphics/ItemColorTableModel.java +++ b/src/main/java/net/freerouting/boardgraphics/ItemColorTableModel.java @@ -18,7 +18,7 @@ * Created on 4. August 2003, 08:26 */ -package boardgraphics; +package net.freerouting.boardgraphics; import java.awt.Color; @@ -30,7 +30,7 @@ public class ItemColorTableModel extends ColorTableModel implements java.io.Serializable { - public ItemColorTableModel(board.LayerStructure p_layer_structure, java.util.Locale p_locale) + public ItemColorTableModel(net.freerouting.board.LayerStructure p_layer_structure, java.util.Locale p_locale) { super(p_layer_structure.arr.length, p_locale); @@ -143,7 +143,7 @@ public int getRowCount() public String getColumnName(int p_col) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("boardgraphics.resources.ColorTableModel", this.locale); + java.util.ResourceBundle.getBundle("net.freerouting.boardgraphics.ColorTableModel", this.locale); return resources.getString(ColumnNames.values()[p_col].toString()); } diff --git a/boardgraphics/ItemDrawInfo.java b/src/main/java/net/freerouting/boardgraphics/ItemDrawInfo.java similarity index 96% rename from boardgraphics/ItemDrawInfo.java rename to src/main/java/net/freerouting/boardgraphics/ItemDrawInfo.java index 364b8ddf..e0ac839b 100644 --- a/boardgraphics/ItemDrawInfo.java +++ b/src/main/java/net/freerouting/boardgraphics/ItemDrawInfo.java @@ -18,7 +18,7 @@ * Created on 14. Juli 2004, 10:26 */ -package boardgraphics; +package net.freerouting.boardgraphics; import java.awt.Color; diff --git a/boardgraphics/OtherColorTableModel.java b/src/main/java/net/freerouting/boardgraphics/OtherColorTableModel.java similarity index 97% rename from boardgraphics/OtherColorTableModel.java rename to src/main/java/net/freerouting/boardgraphics/OtherColorTableModel.java index a6c4f1d9..9125c279 100644 --- a/boardgraphics/OtherColorTableModel.java +++ b/src/main/java/net/freerouting/boardgraphics/OtherColorTableModel.java @@ -18,7 +18,7 @@ * Created on 5. August 2003, 07:39 */ -package boardgraphics; +package net.freerouting.boardgraphics; import java.awt.Color; @@ -73,7 +73,7 @@ public int getColumnCount() public String getColumnName(int p_col) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("boardgraphics.resources.ColorTableModel", this.locale); + java.util.ResourceBundle.getBundle("net.freerouting.boardgraphics.ColorTableModel", this.locale); return resources.getString(ColumnNames.values()[p_col].toString()); } diff --git a/boardgraphics/package.html b/src/main/java/net/freerouting/boardgraphics/package.html similarity index 100% rename from boardgraphics/package.html rename to src/main/java/net/freerouting/boardgraphics/package.html diff --git a/datastructures/ArrayStack.java b/src/main/java/net/freerouting/datastructures/ArrayStack.java similarity index 98% rename from datastructures/ArrayStack.java rename to src/main/java/net/freerouting/datastructures/ArrayStack.java index 5874e961..7d245d0d 100644 --- a/datastructures/ArrayStack.java +++ b/src/main/java/net/freerouting/datastructures/ArrayStack.java @@ -19,7 +19,7 @@ * */ -package datastructures; +package net.freerouting.datastructures; @SuppressWarnings("unchecked") diff --git a/datastructures/BigIntAux.java b/src/main/java/net/freerouting/datastructures/BigIntAux.java similarity index 99% rename from datastructures/BigIntAux.java rename to src/main/java/net/freerouting/datastructures/BigIntAux.java index 6a70450e..2f923f69 100644 --- a/datastructures/BigIntAux.java +++ b/src/main/java/net/freerouting/datastructures/BigIntAux.java @@ -9,7 +9,7 @@ * Created on 5. January 2003, 11:26 */ -package datastructures; +package net.freerouting.datastructures; import java.math.BigInteger; diff --git a/datastructures/FileFilter.java b/src/main/java/net/freerouting/datastructures/FileFilter.java similarity index 98% rename from datastructures/FileFilter.java rename to src/main/java/net/freerouting/datastructures/FileFilter.java index 9c0a70c2..6859d4ce 100644 --- a/datastructures/FileFilter.java +++ b/src/main/java/net/freerouting/datastructures/FileFilter.java @@ -18,7 +18,7 @@ * Created on 31. Mai 2004, 09:23 */ -package datastructures; +package net.freerouting.datastructures; /** * Used in the file chooser to filter all files which do not have an extension from the input array. diff --git a/datastructures/IdNoGenerator.java b/src/main/java/net/freerouting/datastructures/IdNoGenerator.java similarity index 96% rename from datastructures/IdNoGenerator.java rename to src/main/java/net/freerouting/datastructures/IdNoGenerator.java index 677f790a..05077f9f 100644 --- a/datastructures/IdNoGenerator.java +++ b/src/main/java/net/freerouting/datastructures/IdNoGenerator.java @@ -18,7 +18,7 @@ * Created on 13. Februar 2005, 08:21 */ -package datastructures; +package net.freerouting.datastructures; /** * Interface for creatiing unique identification number. diff --git a/datastructures/IdentifierType.java b/src/main/java/net/freerouting/datastructures/IdentifierType.java similarity index 98% rename from datastructures/IdentifierType.java rename to src/main/java/net/freerouting/datastructures/IdentifierType.java index bbb524d5..4c951fb8 100644 --- a/datastructures/IdentifierType.java +++ b/src/main/java/net/freerouting/datastructures/IdentifierType.java @@ -18,7 +18,7 @@ * Created on 25. Januar 2005, 09:50 */ -package datastructures; +package net.freerouting.datastructures; import java.io.OutputStreamWriter; diff --git a/datastructures/IndentFileWriter.java b/src/main/java/net/freerouting/datastructures/IndentFileWriter.java similarity index 98% rename from datastructures/IndentFileWriter.java rename to src/main/java/net/freerouting/datastructures/IndentFileWriter.java index 8f01d430..37fbe90f 100644 --- a/datastructures/IndentFileWriter.java +++ b/src/main/java/net/freerouting/datastructures/IndentFileWriter.java @@ -18,7 +18,7 @@ * Created on 21. Juni 2004, 09:36 */ -package datastructures; +package net.freerouting.datastructures; /** * Handles the indenting of scopes while writing to an output text file. diff --git a/datastructures/MinAreaTree.java b/src/main/java/net/freerouting/datastructures/MinAreaTree.java similarity index 98% rename from datastructures/MinAreaTree.java rename to src/main/java/net/freerouting/datastructures/MinAreaTree.java index 92932a6c..300af685 100644 --- a/datastructures/MinAreaTree.java +++ b/src/main/java/net/freerouting/datastructures/MinAreaTree.java @@ -18,13 +18,13 @@ * Created on 1. September 2004, 08:29 */ -package datastructures; +package net.freerouting.datastructures; import java.util.Set; import java.util.TreeSet; -import geometry.planar.ShapeBoundingDirections; -import geometry.planar.RegularTileShape; +import net.freerouting.geometry.planar.ShapeBoundingDirections; +import net.freerouting.geometry.planar.RegularTileShape; /** * Binary search tree for shapes in the plane. diff --git a/datastructures/Observers.java b/src/main/java/net/freerouting/datastructures/Observers.java similarity index 97% rename from datastructures/Observers.java rename to src/main/java/net/freerouting/datastructures/Observers.java index 5ef1bed4..9102e181 100644 --- a/datastructures/Observers.java +++ b/src/main/java/net/freerouting/datastructures/Observers.java @@ -18,7 +18,7 @@ * Created on 13. Februar 2005, 09:14 */ -package datastructures; +package net.freerouting.datastructures; /** * Interface to observe changes on objects for syncronisatiation purposes. diff --git a/datastructures/PlanarDelaunayTriangulation.java b/src/main/java/net/freerouting/datastructures/PlanarDelaunayTriangulation.java similarity index 99% rename from datastructures/PlanarDelaunayTriangulation.java rename to src/main/java/net/freerouting/datastructures/PlanarDelaunayTriangulation.java index ce76d8c0..8b24d922 100644 --- a/datastructures/PlanarDelaunayTriangulation.java +++ b/src/main/java/net/freerouting/datastructures/PlanarDelaunayTriangulation.java @@ -18,7 +18,7 @@ * Created on 8. Januar 2005, 10:12 */ -package datastructures; +package net.freerouting.datastructures; import java.util.Collection; import java.util.Collections; @@ -27,10 +27,10 @@ import java.util.Set; import java.util.TreeSet; -import geometry.planar.Point; -import geometry.planar.IntPoint; -import geometry.planar.Side; -import geometry.planar.Limits; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.Limits; /** * Creates a Delaunay triangulation in the plane for the input objects. @@ -349,7 +349,7 @@ public interface Storable /** * Returns an array of corners, which can be used in a planar triangulation. */ - geometry.planar.Point[] get_triangulation_corners(); + net.freerouting.geometry.planar.Point[] get_triangulation_corners(); } /** diff --git a/datastructures/ShapeTree.java b/src/main/java/net/freerouting/datastructures/ShapeTree.java similarity index 97% rename from datastructures/ShapeTree.java rename to src/main/java/net/freerouting/datastructures/ShapeTree.java index 07078ec3..1537fa2d 100644 --- a/datastructures/ShapeTree.java +++ b/src/main/java/net/freerouting/datastructures/ShapeTree.java @@ -18,12 +18,12 @@ * Created on 1. September 2004, 10:50 */ -package datastructures; +package net.freerouting.datastructures; -import geometry.planar.ShapeBoundingDirections; -import geometry.planar.RegularTileShape; -import geometry.planar.Shape; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.ShapeBoundingDirections; +import net.freerouting.geometry.planar.RegularTileShape; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.TileShape; /** * Abstract binary search tree for shapes in the plane. diff --git a/datastructures/Signum.java b/src/main/java/net/freerouting/datastructures/Signum.java similarity index 98% rename from datastructures/Signum.java rename to src/main/java/net/freerouting/datastructures/Signum.java index 2eecd991..b3ab7b9b 100644 --- a/datastructures/Signum.java +++ b/src/main/java/net/freerouting/datastructures/Signum.java @@ -14,7 +14,7 @@ * for more details. */ -package datastructures; +package net.freerouting.datastructures; /** * diff --git a/datastructures/Stoppable.java b/src/main/java/net/freerouting/datastructures/Stoppable.java similarity index 96% rename from datastructures/Stoppable.java rename to src/main/java/net/freerouting/datastructures/Stoppable.java index e63a0b82..00b9e2d7 100644 --- a/datastructures/Stoppable.java +++ b/src/main/java/net/freerouting/datastructures/Stoppable.java @@ -19,7 +19,7 @@ * */ -package datastructures; +package net.freerouting.datastructures; /** * Interface for stoppable threads. diff --git a/datastructures/TimeLimit.java b/src/main/java/net/freerouting/datastructures/TimeLimit.java similarity index 97% rename from datastructures/TimeLimit.java rename to src/main/java/net/freerouting/datastructures/TimeLimit.java index a4bdf14b..eecccebb 100644 --- a/datastructures/TimeLimit.java +++ b/src/main/java/net/freerouting/datastructures/TimeLimit.java @@ -19,7 +19,7 @@ * */ -package datastructures; +package net.freerouting.datastructures; /** * Class used to cancel a performance critical algorithm after a time limit is exceeded. diff --git a/datastructures/UndoableObjects.java b/src/main/java/net/freerouting/datastructures/UndoableObjects.java similarity index 99% rename from datastructures/UndoableObjects.java rename to src/main/java/net/freerouting/datastructures/UndoableObjects.java index 23e7f972..f86aab12 100644 --- a/datastructures/UndoableObjects.java +++ b/src/main/java/net/freerouting/datastructures/UndoableObjects.java @@ -17,7 +17,7 @@ * * Created on 24. August 2003, 06:41 */ -package datastructures; +package net.freerouting.datastructures; import java.util.Collection; import java.util.Iterator; diff --git a/datastructures/package.html b/src/main/java/net/freerouting/datastructures/package.html similarity index 100% rename from datastructures/package.html rename to src/main/java/net/freerouting/datastructures/package.html diff --git a/designformats/specctra/AutorouteSettings.java b/src/main/java/net/freerouting/designformats/specctra/AutorouteSettings.java similarity index 91% rename from designformats/specctra/AutorouteSettings.java rename to src/main/java/net/freerouting/designformats/specctra/AutorouteSettings.java index cb79e0b1..56e65162 100644 --- a/designformats/specctra/AutorouteSettings.java +++ b/src/main/java/net/freerouting/designformats/specctra/AutorouteSettings.java @@ -18,10 +18,10 @@ * Created on 1. Maerz 2007, 07:10 * */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** * @@ -30,9 +30,9 @@ public class AutorouteSettings { - static interactive.AutorouteSettings read_scope(Scanner p_scanner, LayerStructure p_layer_structure) + static net.freerouting.interactive.AutorouteSettings read_scope(Scanner p_scanner, LayerStructure p_layer_structure) { - interactive.AutorouteSettings result = new interactive.AutorouteSettings(p_layer_structure.arr.length); + net.freerouting.interactive.AutorouteSettings result = new net.freerouting.interactive.AutorouteSettings(p_layer_structure.arr.length); boolean with_fanout = false; boolean with_autoroute = true; boolean with_postroute = true; @@ -112,8 +112,8 @@ else if (next_token == Keyword.LAYER_RULE) return result; } - static interactive.AutorouteSettings read_layer_rule(Scanner p_scanner, LayerStructure p_layer_structure, - interactive.AutorouteSettings p_settings) + static net.freerouting.interactive.AutorouteSettings read_layer_rule(Scanner p_scanner, LayerStructure p_layer_structure, + net.freerouting.interactive.AutorouteSettings p_settings) { p_scanner.yybegin(SpecctraFileScanner.NAME); Object next_token; @@ -208,8 +208,8 @@ else if (next_token == Keyword.AGAINST_PREFERRED_DIRECTION_TRACE_COSTS) return p_settings; } - static void write_scope(IndentFileWriter p_file, interactive.AutorouteSettings p_settings, - board.LayerStructure p_layer_structure, IdentifierType p_identifier_type) throws java.io.IOException + static void write_scope(IndentFileWriter p_file, net.freerouting.interactive.AutorouteSettings p_settings, + net.freerouting.board.LayerStructure p_layer_structure, IdentifierType p_identifier_type) throws java.io.IOException { p_file.start_scope(); p_file.write("autoroute_settings"); @@ -283,7 +283,7 @@ static void write_scope(IndentFileWriter p_file, interactive.AutorouteSettings p p_file.write(")"); for (int i = 0; i < p_layer_structure.arr.length; ++i) { - board.Layer curr_layer = p_layer_structure.arr[i]; + net.freerouting.board.Layer curr_layer = p_layer_structure.arr[i]; p_file.start_scope(); p_file.write("layer_rule "); p_identifier_type.write(curr_layer.name, p_file); diff --git a/designformats/specctra/Circle.java b/src/main/java/net/freerouting/designformats/specctra/Circle.java similarity index 84% rename from designformats/specctra/Circle.java rename to src/main/java/net/freerouting/designformats/specctra/Circle.java index 81c08e8a..0e79269e 100644 --- a/designformats/specctra/Circle.java +++ b/src/main/java/net/freerouting/designformats/specctra/Circle.java @@ -18,11 +18,11 @@ * Created on 20. Mai 2004, 09:22 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import geometry.planar.IntPoint; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** * Class for reading and writing circle scopes from dsn-files. @@ -53,17 +53,17 @@ public Circle(Layer p_layer, double p_radius, double p_center_x, double p_center coor[2] = p_center_y; } - public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) + public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) { double [] location = new double[2]; location[0] = coor[1]; location[1] = coor[2]; IntPoint center = p_coordinate_transform.dsn_to_board(location).round(); int radius = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[0]) / 2); - return new geometry.planar.Circle(center, radius); + return new net.freerouting.geometry.planar.Circle(center, radius); } - public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) + public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) { int [] new_coor = new int[3]; new_coor[0] = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[0]) / 2); @@ -71,7 +71,7 @@ public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordi { new_coor[i] = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[i])); } - return new geometry.planar.Circle(new IntPoint(new_coor[1], new_coor[2]), new_coor[0]); + return new net.freerouting.geometry.planar.Circle(new IntPoint(new_coor[1], new_coor[2]), new_coor[0]); } public Rectangle bounding_box() diff --git a/designformats/specctra/Circuit.java b/src/main/java/net/freerouting/designformats/specctra/Circuit.java similarity index 99% rename from designformats/specctra/Circuit.java rename to src/main/java/net/freerouting/designformats/specctra/Circuit.java index f2c126bf..87b9fab1 100644 --- a/designformats/specctra/Circuit.java +++ b/src/main/java/net/freerouting/designformats/specctra/Circuit.java @@ -19,7 +19,7 @@ * */ -package designformats.specctra; +package net.freerouting.designformats.specctra; /** * diff --git a/designformats/specctra/Component.java b/src/main/java/net/freerouting/designformats/specctra/Component.java similarity index 91% rename from designformats/specctra/Component.java rename to src/main/java/net/freerouting/designformats/specctra/Component.java index 7e35641b..7eb78b4b 100644 --- a/designformats/specctra/Component.java +++ b/src/main/java/net/freerouting/designformats/specctra/Component.java @@ -18,7 +18,7 @@ * Created on 20. Mai 2004, 07:32 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; /** @@ -88,7 +88,7 @@ public static ComponentPlacement read_scope(Scanner p_scanner) throws java.io.IO return component_placement; } - public static void write_scope(WriteScopeParameter p_par, board.Component p_component) + public static void write_scope(WriteScopeParameter p_par, net.freerouting.board.Component p_component) throws java.io.IOException { p_par.file.start_scope(); @@ -128,20 +128,20 @@ public static void write_scope(WriteScopeParameter p_par, board.Component p_comp p_par.file.end_scope(); } - private static void write_pin_info(WriteScopeParameter p_par, board.Component p_component, int p_pin_no) + private static void write_pin_info(WriteScopeParameter p_par, net.freerouting.board.Component p_component, int p_pin_no) throws java.io.IOException { if (!p_component.is_placed()) { return; } - library.Package.Pin package_pin = p_component.get_package().get_pin(p_pin_no); + net.freerouting.library.Package.Pin package_pin = p_component.get_package().get_pin(p_pin_no); if (package_pin == null) { System.out.println("Component.write_pin_info: package pin not found"); return; } - board.Pin component_pin = p_par.board.get_pin(p_component.no, p_pin_no); + net.freerouting.board.Pin component_pin = p_par.board.get_pin(p_component.no, p_pin_no); if (component_pin == null) { System.out.println("Component.write_pin_info: component pin not found"); @@ -161,14 +161,14 @@ private static void write_pin_info(WriteScopeParameter p_par, board.Component p_ p_par.file.write("))"); } - private static void write_keepout_infos(WriteScopeParameter p_par, board.Component p_component) + private static void write_keepout_infos(WriteScopeParameter p_par, net.freerouting.board.Component p_component) throws java.io.IOException { if (!p_component.is_placed()) { return; } - library.Package.Keepout[] curr_keepout_arr; + net.freerouting.library.Package.Keepout[] curr_keepout_arr; String keepout_type; for (int j = 0; j < 3; ++j) { @@ -189,8 +189,8 @@ else if (j == 1) } for (int i = 0; i < curr_keepout_arr.length; ++i) { - library.Package.Keepout curr_keepout = curr_keepout_arr[i]; - board.ObstacleArea curr_obstacle_area = get_keepout(p_par.board, p_component.no, curr_keepout.name); + net.freerouting.library.Package.Keepout curr_keepout = curr_keepout_arr[i]; + net.freerouting.board.ObstacleArea curr_obstacle_area = get_keepout(p_par.board, p_component.no, curr_keepout.name); if (curr_obstacle_area == null || curr_obstacle_area.clearance_class_no() == 0) { continue; @@ -211,19 +211,19 @@ else if (j == 1) } } - private static board.ObstacleArea get_keepout(board.BasicBoard p_board, int p_component_no, String p_name) + private static net.freerouting.board.ObstacleArea get_keepout(net.freerouting.board.BasicBoard p_board, int p_component_no, String p_name) { - java.util.Iterator it = p_board.item_list.start_read_object(); + java.util.Iterator it = p_board.item_list.start_read_object(); for(;;) { - board.Item curr_item = (board.Item)p_board.item_list.read_object(it); + net.freerouting.board.Item curr_item = (net.freerouting.board.Item)p_board.item_list.read_object(it); if (curr_item == null) { break; } - if (curr_item.get_component_no() == p_component_no && curr_item instanceof board.ObstacleArea) + if (curr_item.get_component_no() == p_component_no && curr_item instanceof net.freerouting.board.ObstacleArea) { - board.ObstacleArea curr_area = (board.ObstacleArea) curr_item; + net.freerouting.board.ObstacleArea curr_area = (net.freerouting.board.ObstacleArea) curr_item; if (curr_area.name != null && curr_area.name.equals(p_name)) { return curr_area; diff --git a/designformats/specctra/ComponentPlacement.java b/src/main/java/net/freerouting/designformats/specctra/ComponentPlacement.java similarity index 98% rename from designformats/specctra/ComponentPlacement.java rename to src/main/java/net/freerouting/designformats/specctra/ComponentPlacement.java index 3633c2e5..025d1af5 100644 --- a/designformats/specctra/ComponentPlacement.java +++ b/src/main/java/net/freerouting/designformats/specctra/ComponentPlacement.java @@ -18,7 +18,7 @@ * Created on 20. Mai 2004, 07:43 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.LinkedList; diff --git a/designformats/specctra/CoordinateTransform.java b/src/main/java/net/freerouting/designformats/specctra/CoordinateTransform.java similarity index 90% rename from designformats/specctra/CoordinateTransform.java rename to src/main/java/net/freerouting/designformats/specctra/CoordinateTransform.java index 1c291e54..26787b5b 100644 --- a/designformats/specctra/CoordinateTransform.java +++ b/src/main/java/net/freerouting/designformats/specctra/CoordinateTransform.java @@ -18,13 +18,13 @@ * Created on 14. Mai 2004, 09:09 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import geometry.planar.FloatPoint; -import geometry.planar.Vector; -import geometry.planar.Line; -import geometry.planar.IntBox; -import geometry.planar.PolylineShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.PolylineShape; /** * Computes transformations between a specctra dsn-file coordinates and board coordinates. @@ -197,7 +197,7 @@ public FloatPoint dsn_to_board_rel(double [] p_tuple) /** * Transforms a board shape to a dsn shape. */ - public Shape board_to_dsn(geometry.planar.Shape p_board_shape, Layer p_layer) + public Shape board_to_dsn(net.freerouting.geometry.planar.Shape p_board_shape, Layer p_layer) { Shape result; if (p_board_shape instanceof IntBox) @@ -210,9 +210,9 @@ else if (p_board_shape instanceof PolylineShape) double [] coors = board_to_dsn(corners); result = new Polygon(p_layer, coors); } - else if (p_board_shape instanceof geometry.planar.Circle) + else if (p_board_shape instanceof net.freerouting.geometry.planar.Circle) { - geometry.planar.Circle board_circle = (geometry.planar.Circle) p_board_shape; + net.freerouting.geometry.planar.Circle board_circle = (net.freerouting.geometry.planar.Circle) p_board_shape; double diameter = 2 * board_to_dsn(board_circle.radius); double [] center_coor = board_to_dsn(board_circle.center.to_float()); result = new Circle(p_layer, diameter, center_coor[0], center_coor[1]); @@ -228,7 +228,7 @@ else if (p_board_shape instanceof geometry.planar.Circle) /** * Transforms the relative (vector) coordinates of a geometry.planar.Shape to a specctra dsn shape. */ - public Shape board_to_dsn_rel(geometry.planar.Shape p_board_shape, Layer p_layer) + public Shape board_to_dsn_rel(net.freerouting.geometry.planar.Shape p_board_shape, Layer p_layer) { Shape result; if (p_board_shape instanceof IntBox) @@ -241,9 +241,9 @@ else if (p_board_shape instanceof PolylineShape) double [] coors = board_to_dsn_rel(corners); result = new Polygon(p_layer, coors); } - else if (p_board_shape instanceof geometry.planar.Circle) + else if (p_board_shape instanceof net.freerouting.geometry.planar.Circle) { - geometry.planar.Circle board_circle = (geometry.planar.Circle) p_board_shape; + net.freerouting.geometry.planar.Circle board_circle = (net.freerouting.geometry.planar.Circle) p_board_shape; double diameter = 2 * board_to_dsn(board_circle.radius); double [] center_coor = board_to_dsn_rel(board_circle.center.to_float()); result = new Circle(p_layer, diameter, center_coor[0], center_coor[1]); diff --git a/designformats/specctra/DsnFile.java b/src/main/java/net/freerouting/designformats/specctra/DsnFile.java similarity index 82% rename from designformats/specctra/DsnFile.java rename to src/main/java/net/freerouting/designformats/specctra/DsnFile.java index 70009fa2..a2798a8d 100644 --- a/designformats/specctra/DsnFile.java +++ b/src/main/java/net/freerouting/designformats/specctra/DsnFile.java @@ -17,12 +17,12 @@ * * Created on 10. Mai 2004, 07:43 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import datastructures.IndentFileWriter; +import net.freerouting.datastructures.IndentFileWriter; -import board.BasicBoard; -import board.TestLevel; +import net.freerouting.board.BasicBoard; +import net.freerouting.board.TestLevel; /** * Class for reading and writing dsn-files. @@ -44,8 +44,8 @@ public enum ReadResult * in case the board is embedded into a host system. * Returns false, if an error occured. */ - public static ReadResult read(java.io.InputStream p_input_stream, interactive.BoardHandling p_board_handling, - board.BoardObservers p_observers, datastructures.IdNoGenerator p_item_id_no_generator, TestLevel p_test_level) + public static ReadResult read(java.io.InputStream p_input_stream, net.freerouting.interactive.BoardHandling p_board_handling, + net.freerouting.board.BoardObservers p_observers, net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, TestLevel p_test_level) { Scanner scanner = new SpecctraFileScanner(p_input_stream); Object curr_token = null; @@ -108,15 +108,15 @@ else if (!read_scope_par.board_outline_ok) * This is useful in case the layer type was not set correctly to plane in the dsn-file. * Returns true, if something was changed. */ - private static boolean adjust_plane_autoroute_settings(interactive.BoardHandling p_board_handling) + private static boolean adjust_plane_autoroute_settings(net.freerouting.interactive.BoardHandling p_board_handling) { BasicBoard routing_board = p_board_handling.get_routing_board(); - board.LayerStructure board_layer_structure = routing_board.layer_structure; + net.freerouting.board.LayerStructure board_layer_structure = routing_board.layer_structure; if (board_layer_structure.arr.length <= 2) { return false; } - for (board.Layer curr_layer : board_layer_structure.arr) + for (net.freerouting.board.Layer curr_layer : board_layer_structure.arr) { if (!curr_layer.is_signal) { @@ -130,50 +130,50 @@ private static boolean adjust_plane_autoroute_settings(interactive.BoardHandling layer_contains_wires_arr[i] = false; changed_layer_arr[i] = false; } - java.util.Collection conduction_area_list = new java.util.LinkedList(); - java.util.Collection item_list = routing_board.get_items(); - for (board.Item curr_item : item_list) + java.util.Collection conduction_area_list = new java.util.LinkedList(); + java.util.Collection item_list = routing_board.get_items(); + for (net.freerouting.board.Item curr_item : item_list) { - if (curr_item instanceof board.Trace) + if (curr_item instanceof net.freerouting.board.Trace) { - int curr_layer = ((board.Trace) curr_item).get_layer(); + int curr_layer = ((net.freerouting.board.Trace) curr_item).get_layer(); layer_contains_wires_arr[curr_layer] = true; } - else if (curr_item instanceof board.ConductionArea) + else if (curr_item instanceof net.freerouting.board.ConductionArea) { - conduction_area_list.add((board.ConductionArea) curr_item); + conduction_area_list.add((net.freerouting.board.ConductionArea) curr_item); } } boolean nothing_changed = true; - board.BoardOutline board_outline = routing_board.get_outline(); + net.freerouting.board.BoardOutline board_outline = routing_board.get_outline(); double board_area = 0; for (int i = 0; i < board_outline.shape_count(); ++i) { - geometry.planar.TileShape[] curr_piece_arr = board_outline.get_shape(i).split_to_convex(); + net.freerouting.geometry.planar.TileShape[] curr_piece_arr = board_outline.get_shape(i).split_to_convex(); if (curr_piece_arr != null) { - for (geometry.planar.TileShape curr_piece : curr_piece_arr) + for (net.freerouting.geometry.planar.TileShape curr_piece : curr_piece_arr) { board_area += curr_piece.area(); } } } - for (board.ConductionArea curr_conduction_area : conduction_area_list) + for (net.freerouting.board.ConductionArea curr_conduction_area : conduction_area_list) { int layer_no = curr_conduction_area.get_layer(); if (layer_contains_wires_arr[layer_no]) { continue; } - board.Layer curr_layer = routing_board.layer_structure.arr[layer_no]; + net.freerouting.board.Layer curr_layer = routing_board.layer_structure.arr[layer_no]; if (!curr_layer.is_signal || layer_no == 0 || layer_no == board_layer_structure.arr.length - 1) { continue; } - geometry.planar.TileShape[] convex_pieces = curr_conduction_area.get_area().split_to_convex(); + net.freerouting.geometry.planar.TileShape[] convex_pieces = curr_conduction_area.get_area().split_to_convex(); double curr_area = 0; - for (geometry.planar.TileShape curr_piece : convex_pieces) + for (net.freerouting.geometry.planar.TileShape curr_piece : convex_pieces) { curr_area += curr_piece.area(); } @@ -185,15 +185,15 @@ else if (curr_item instanceof board.ConductionArea) for (int i = 0; i < curr_conduction_area.net_count(); ++i) { - rules.Net curr_net = routing_board.rules.nets.get(curr_conduction_area.get_net_no(i)); + net.freerouting.rules.Net curr_net = routing_board.rules.nets.get(curr_conduction_area.get_net_no(i)); curr_net.set_contains_plane(true); nothing_changed = false; } changed_layer_arr[layer_no] = true; - if (curr_conduction_area.get_fixed_state().ordinal() < board.FixedState.USER_FIXED.ordinal()) + if (curr_conduction_area.get_fixed_state().ordinal() < net.freerouting.board.FixedState.USER_FIXED.ordinal()) { - curr_conduction_area.set_fixed_state(board.FixedState.USER_FIXED); + curr_conduction_area.set_fixed_state(net.freerouting.board.FixedState.USER_FIXED); } } if (nothing_changed) @@ -202,7 +202,7 @@ else if (curr_item instanceof board.ConductionArea) } // Adjust the layer prefered directions in the autoroute settings. // and deactivate the changed layers. - interactive.AutorouteSettings autoroute_settings = p_board_handling.settings.autoroute_settings; + net.freerouting.interactive.AutorouteSettings autoroute_settings = p_board_handling.settings.autoroute_settings; int layer_count = routing_board.get_layer_count(); boolean curr_preferred_direction_is_horizontal = autoroute_settings.get_preferred_direction_is_horizontal(0); @@ -227,7 +227,7 @@ else if (autoroute_settings.get_layer_active(i)) * If p_compat_mode is true, only standard speecctra dsn scopes are written, so that any * host system with an specctra interface can read them. */ - public static boolean write(interactive.BoardHandling p_board_handling, java.io.OutputStream p_file, String p_design_name, boolean p_compat_mode) + public static boolean write(net.freerouting.interactive.BoardHandling p_board_handling, java.io.OutputStream p_file, String p_design_name, boolean p_compat_mode) { //tests.Validate.check("before writing dsn", p_board); IndentFileWriter output_file = new IndentFileWriter(p_file); @@ -258,7 +258,7 @@ public static boolean write(interactive.BoardHandling p_board_handling, java.io. return true; } - private static void write_pcb_scope(interactive.BoardHandling p_board_handling, IndentFileWriter p_file, String p_design_name, boolean p_compat_mode) + private static void write_pcb_scope(net.freerouting.interactive.BoardHandling p_board_handling, IndentFileWriter p_file, String p_design_name, boolean p_compat_mode) throws java.io.IOException { BasicBoard routing_board = p_board_handling.get_routing_board(); diff --git a/designformats/specctra/Keyword.java b/src/main/java/net/freerouting/designformats/specctra/Keyword.java similarity index 97% rename from designformats/specctra/Keyword.java rename to src/main/java/net/freerouting/designformats/specctra/Keyword.java index 52da2180..c7810289 100644 --- a/designformats/specctra/Keyword.java +++ b/src/main/java/net/freerouting/designformats/specctra/Keyword.java @@ -17,7 +17,7 @@ * * Created on 8. Mai 2004, 10:23 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; /** * Enumeration class for keywords of the specctra dsn file format @@ -36,7 +36,7 @@ public class Keyword public static final Keyword ACTIVE = new Keyword("active"); public static final Keyword AGAINST_PREFERRED_DIRECTION_TRACE_COSTS = new Keyword("against_preferred_direction_trace_costs"); public static final Keyword ATTACH = new Keyword("attach"); - public static final Keyword AUTOROUTE = new Keyword("autoroute"); + public static final Keyword AUTOROUTE = new Keyword("net/freerouting/autoroute"); public static final Keyword AUTOROUTE_SETTINGS = new Keyword("autoroute_settings"); public static final Keyword BACK = new Keyword("back"); public static final Keyword BOUNDARY = new Keyword("boundary"); @@ -109,7 +109,7 @@ public class Keyword public static final Keyword ROTATE_FIRST = new Keyword("rotate_first"); public static final Keyword ROUTES = new Keyword("routes"); public static final Keyword RULE = new Keyword("rule"); - public static final Keyword RULES = new Keyword("rules"); + public static final Keyword RULES = new Keyword("net/freerouting/rules"); public static final Keyword SESSION = new Keyword("session"); public static final Keyword SHAPE = new Keyword("shape"); public static final Keyword SHOVE_FIXED = new Keyword("shove_fixed"); diff --git a/designformats/specctra/Layer.java b/src/main/java/net/freerouting/designformats/specctra/Layer.java similarity index 95% rename from designformats/specctra/Layer.java rename to src/main/java/net/freerouting/designformats/specctra/Layer.java index 45658f2a..558be4e7 100644 --- a/designformats/specctra/Layer.java +++ b/src/main/java/net/freerouting/designformats/specctra/Layer.java @@ -18,7 +18,7 @@ * Created on 15. Mai 2004, 08:29 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.LinkedList; @@ -75,7 +75,7 @@ public static void write_scope(WriteScopeParameter p_par, int p_layer_no, { p_par.file.start_scope(); p_par.file.write("layer "); - board.Layer board_layer = p_par.board.layer_structure.arr[p_layer_no]; + net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[p_layer_no]; p_par.identifier_type.write(board_layer.name, p_par.file); p_par.file.new_line(); p_par.file.write("(type "); diff --git a/designformats/specctra/LayerStructure.java b/src/main/java/net/freerouting/designformats/specctra/LayerStructure.java similarity index 92% rename from designformats/specctra/LayerStructure.java rename to src/main/java/net/freerouting/designformats/specctra/LayerStructure.java index 202bb81f..e0e71e4f 100644 --- a/designformats/specctra/LayerStructure.java +++ b/src/main/java/net/freerouting/designformats/specctra/LayerStructure.java @@ -17,7 +17,7 @@ * * Created on 16. Mai 2004, 08:08 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.Iterator; @@ -44,12 +44,12 @@ public LayerStructure(Collection p_layer_list) /** * Creates a dsn-LayerStructure from a board LayerStructure. */ - public LayerStructure(board.LayerStructure p_board_layer_structure) + public LayerStructure(net.freerouting.board.LayerStructure p_board_layer_structure) { arr = new Layer[p_board_layer_structure.arr.length]; for (int i = 0; i < arr.length; ++i) { - board.Layer board_layer = p_board_layer_structure.arr[i]; + net.freerouting.board.Layer board_layer = p_board_layer_structure.arr[i]; arr[i] = new Layer(board_layer.name, i, board_layer.is_signal); } } diff --git a/designformats/specctra/Library.java b/src/main/java/net/freerouting/designformats/specctra/Library.java similarity index 79% rename from designformats/specctra/Library.java rename to src/main/java/net/freerouting/designformats/specctra/Library.java index 5ad97c5b..f99ba58f 100644 --- a/designformats/specctra/Library.java +++ b/src/main/java/net/freerouting/designformats/specctra/Library.java @@ -18,12 +18,12 @@ * Created on 21. Mai 2004, 08:09 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import geometry.planar.IntVector; -import geometry.planar.Vector; -import geometry.planar.PolygonShape; -import geometry.planar.Simplex; +import net.freerouting.geometry.planar.IntVector; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.PolygonShape; +import net.freerouting.geometry.planar.Simplex; import java.util.Collection; import java.util.Iterator; @@ -41,13 +41,13 @@ public class Library extends ScopeKeyword /** Creates a new instance of Library */ public Library() { - super("library"); + super("net/freerouting/library"); } public boolean read_scope(ReadScopeParameter p_par) { - board.RoutingBoard board = p_par.board_handling.get_routing_board(); - board.library.padstacks = new library.Padstacks(p_par.board_handling.get_routing_board().layer_structure); + net.freerouting.board.RoutingBoard board = p_par.board_handling.get_routing_board(); + board.library.padstacks = new net.freerouting.library.Padstacks(p_par.board_handling.get_routing_board().layer_structure); Collection package_list = new LinkedList(); Object next_token = null; for (;;) @@ -102,13 +102,13 @@ else if (next_token == Keyword.IMAGE) // Set the via padstacks. if (p_par.via_padstack_names != null) { - library.Padstack[] via_padstacks = new library.Padstack[p_par.via_padstack_names.size()]; + net.freerouting.library.Padstack[] via_padstacks = new net.freerouting.library.Padstack[p_par.via_padstack_names.size()]; Iterator it = p_par.via_padstack_names.iterator(); int found_padstack_count = 0; for (int i = 0; i < via_padstacks.length; ++i) { String curr_padstack_name = it.next(); - library.Padstack curr_padstack = board.library.padstacks.get(curr_padstack_name); + net.freerouting.library.Padstack curr_padstack = board.library.padstacks.get(curr_padstack_name); if (curr_padstack != null) { via_padstacks[found_padstack_count] = curr_padstack; @@ -124,7 +124,7 @@ else if (next_token == Keyword.IMAGE) if (found_padstack_count != via_padstacks.length) { // Some via padstacks were not found in the padstacks scope of the dsn-file. - library.Padstack[] corrected_padstacks = new library.Padstack[found_padstack_count]; + net.freerouting.library.Padstack[] corrected_padstacks = new net.freerouting.library.Padstack[found_padstack_count]; System.arraycopy(via_padstacks, 0, corrected_padstacks, 0, found_padstack_count); via_padstacks = corrected_padstacks; } @@ -132,27 +132,27 @@ else if (next_token == Keyword.IMAGE) } // Create the library packages on the board - board.library.packages = new library.Packages(board.library.padstacks); + board.library.packages = new net.freerouting.library.Packages(board.library.padstacks); Iterator it = package_list.iterator(); while (it.hasNext()) { Package curr_package = it.next(); - library.Package.Pin[] pin_arr = new library.Package.Pin[curr_package.pin_info_arr.length]; + net.freerouting.library.Package.Pin[] pin_arr = new net.freerouting.library.Package.Pin[curr_package.pin_info_arr.length]; for (int i = 0; i < pin_arr.length; ++i) { Package.PinInfo pin_info = curr_package.pin_info_arr[i]; int rel_x = (int) Math.round(p_par.coordinate_transform.dsn_to_board(pin_info.rel_coor[0])); int rel_y = (int) Math.round(p_par.coordinate_transform.dsn_to_board(pin_info.rel_coor[1])); Vector rel_coor = new IntVector(rel_x, rel_y); - library.Padstack board_padstack = board.library.padstacks.get(pin_info.padstack_name); + net.freerouting.library.Padstack board_padstack = board.library.padstacks.get(pin_info.padstack_name); if (board_padstack == null) { System.out.println("Library.read_scope: board padstack not found"); return false; } - pin_arr[i] = new library.Package.Pin(pin_info.pin_name, board_padstack.no, rel_coor, pin_info.rotation); + pin_arr[i] = new net.freerouting.library.Package.Pin(pin_info.pin_name, board_padstack.no, rel_coor, pin_info.rotation); } - geometry.planar.Shape[] outline_arr = new geometry.planar.Shape[curr_package.outline.size()]; + net.freerouting.geometry.planar.Shape[] outline_arr = new net.freerouting.geometry.planar.Shape[curr_package.outline.size()]; Iterator it3 = curr_package.outline.iterator(); for (int i = 0; i < outline_arr.length; ++i) @@ -170,32 +170,32 @@ else if (next_token == Keyword.IMAGE) generate_missing_keepout_names("keepout_", curr_package.keepouts); generate_missing_keepout_names("via_keepout_", curr_package.via_keepouts); generate_missing_keepout_names("place_keepout_", curr_package.place_keepouts); - library.Package.Keepout [] keepout_arr = new library.Package.Keepout [curr_package.keepouts.size()]; + net.freerouting.library.Package.Keepout [] keepout_arr = new net.freerouting.library.Package.Keepout [curr_package.keepouts.size()]; Iterator it2 = curr_package.keepouts.iterator(); for (int i = 0; i < keepout_arr.length; ++i) { Shape.ReadAreaScopeResult curr_keepout = it2.next(); Layer curr_layer = curr_keepout.shape_list.iterator().next().layer; - geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); - keepout_arr[i] = new library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); + net.freerouting.geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); + keepout_arr[i] = new net.freerouting.library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); } - library.Package.Keepout [] via_keepout_arr = new library.Package.Keepout [curr_package.via_keepouts.size()]; + net.freerouting.library.Package.Keepout [] via_keepout_arr = new net.freerouting.library.Package.Keepout [curr_package.via_keepouts.size()]; it2 = curr_package.via_keepouts.iterator(); for (int i = 0; i < via_keepout_arr.length; ++i) { Shape.ReadAreaScopeResult curr_keepout = it2.next(); Layer curr_layer = (curr_keepout.shape_list.iterator().next()).layer; - geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); - via_keepout_arr[i] = new library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); + net.freerouting.geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); + via_keepout_arr[i] = new net.freerouting.library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); } - library.Package.Keepout [] place_keepout_arr = new library.Package.Keepout [curr_package.place_keepouts.size()]; + net.freerouting.library.Package.Keepout [] place_keepout_arr = new net.freerouting.library.Package.Keepout [curr_package.place_keepouts.size()]; it2 = curr_package.place_keepouts.iterator(); for (int i = 0; i < place_keepout_arr.length; ++i) { Shape.ReadAreaScopeResult curr_keepout = it2.next(); Layer curr_layer = (curr_keepout.shape_list.iterator().next()).layer; - geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); - place_keepout_arr[i] = new library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); + net.freerouting.geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); + place_keepout_arr[i] = new net.freerouting.library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); } board.library.packages.add(curr_package.name, pin_arr, outline_arr, keepout_arr, via_keepout_arr, place_keepout_arr, curr_package.is_front); @@ -206,7 +206,7 @@ else if (next_token == Keyword.IMAGE) public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException { p_par.file.start_scope(); - p_par.file.write("library"); + p_par.file.write("net/freerouting/library"); for (int i = 1; i <= p_par.board.library.packages.count(); ++i) { Package.write_scope(p_par, p_par.board.library.packages.get(i)); @@ -218,7 +218,7 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep p_par.file.end_scope(); } - public static void write_padstack_scope(WriteScopeParameter p_par, library.Padstack p_padstack) throws java.io.IOException + public static void write_padstack_scope(WriteScopeParameter p_par, net.freerouting.library.Padstack p_padstack) throws java.io.IOException { // search the layer range of the padstack int first_layer_no = 0; @@ -250,12 +250,12 @@ public static void write_padstack_scope(WriteScopeParameter p_par, library.Padst p_par.identifier_type.write(p_padstack.name, p_par.file); for (int i = first_layer_no; i <= last_layer_no; ++i) { - geometry.planar.Shape curr_board_shape = p_padstack.get_shape(i); + net.freerouting.geometry.planar.Shape curr_board_shape = p_padstack.get_shape(i); if (curr_board_shape == null) { continue; } - board.Layer board_layer = p_par.board.layer_structure.arr[i]; + net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[i]; Layer curr_layer = new Layer(board_layer.name, i, board_layer.is_signal); Shape curr_shape = p_par.coordinate_transform.board_to_dsn_rel(curr_board_shape, curr_layer); p_par.file.start_scope(); @@ -277,7 +277,7 @@ public static void write_padstack_scope(WriteScopeParameter p_par, library.Padst } static boolean read_padstack_scope(Scanner p_scanner, LayerStructure p_layer_structure, - CoordinateTransform p_coordinate_transform, library.Padstacks p_board_padstacks) + CoordinateTransform p_coordinate_transform, net.freerouting.library.Padstacks p_board_padstacks) { String padstack_name = null; boolean is_drilllable = true; @@ -355,16 +355,16 @@ else if (next_token == Keyword.ABSOLUTE) System.out.println(padstack_name); return true; } - geometry.planar.ConvexShape[] padstack_shapes = new geometry.planar.ConvexShape[p_layer_structure.arr.length]; + net.freerouting.geometry.planar.ConvexShape[] padstack_shapes = new net.freerouting.geometry.planar.ConvexShape[p_layer_structure.arr.length]; Iterator it = shape_list.iterator(); while (it.hasNext()) { Shape pad_shape = it.next(); - geometry.planar.Shape curr_shape = pad_shape.transform_to_board_rel(p_coordinate_transform); - geometry.planar.ConvexShape convex_shape; - if (curr_shape instanceof geometry.planar.ConvexShape) + net.freerouting.geometry.planar.Shape curr_shape = pad_shape.transform_to_board_rel(p_coordinate_transform); + net.freerouting.geometry.planar.ConvexShape convex_shape; + if (curr_shape instanceof net.freerouting.geometry.planar.ConvexShape) { - convex_shape = (geometry.planar.ConvexShape) curr_shape; + convex_shape = (net.freerouting.geometry.planar.ConvexShape) curr_shape; } else { @@ -372,7 +372,7 @@ else if (next_token == Keyword.ABSOLUTE) { curr_shape = ((PolygonShape)curr_shape).convex_hull(); } - geometry.planar.TileShape[] convex_shapes = curr_shape.split_to_convex(); + net.freerouting.geometry.planar.TileShape[] convex_shapes = curr_shape.split_to_convex(); if (convex_shapes.length != 1) { System.out.println("Library.read_padstack_scope: convex shape expected"); @@ -383,7 +383,7 @@ else if (next_token == Keyword.ABSOLUTE) convex_shape = ((Simplex) convex_shape).simplify(); } } - geometry.planar.ConvexShape padstack_shape = convex_shape; + net.freerouting.geometry.planar.ConvexShape padstack_shape = convex_shape; if (padstack_shape != null) { if (padstack_shape.dimension() < 2) diff --git a/designformats/specctra/Net.java b/src/main/java/net/freerouting/designformats/specctra/Net.java similarity index 80% rename from designformats/specctra/Net.java rename to src/main/java/net/freerouting/designformats/specctra/Net.java index 8ea45afb..9b7fa8ac 100644 --- a/designformats/specctra/Net.java +++ b/src/main/java/net/freerouting/designformats/specctra/Net.java @@ -18,15 +18,15 @@ * Created on 19. Mai 2004, 08:58 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.Set; import java.util.TreeSet; import java.util.Iterator; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** @@ -43,17 +43,17 @@ public Net(Id p_net_id) id = p_net_id; } - public static void write_scope(WriteScopeParameter p_par, rules.Net p_net, Collection p_pin_list) throws java.io.IOException + public static void write_scope(WriteScopeParameter p_par, net.freerouting.rules.Net p_net, Collection p_pin_list) throws java.io.IOException { p_par.file.start_scope(); write_net_id(p_net, p_par.file, p_par.identifier_type); // write the pins scope p_par.file.start_scope(); p_par.file.write("pins"); - Iterator it = p_pin_list.iterator(); + Iterator it = p_pin_list.iterator(); while (it.hasNext()) { - board.Pin curr_pin = it.next(); + net.freerouting.board.Pin curr_pin = it.next(); if (curr_pin.contains_net(p_net.net_number)) { write_pin(p_par, curr_pin); @@ -63,7 +63,7 @@ public static void write_scope(WriteScopeParameter p_par, rules.Net p_net, Colle p_par.file.end_scope(); } - public static void write_net_id( rules.Net p_net, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException + public static void write_net_id( net.freerouting.rules.Net p_net, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.write("net "); p_identifier_type.write(p_net.name, p_file); @@ -72,15 +72,15 @@ public static void write_net_id( rules.Net p_net, IndentFileWriter p_file, Ident p_file.write(subnet_number.toString()); } - public static void write_pin(WriteScopeParameter p_par, board.Pin p_pin) throws java.io.IOException + public static void write_pin(WriteScopeParameter p_par, net.freerouting.board.Pin p_pin) throws java.io.IOException { - board.Component curr_component = p_par.board.components.get(p_pin.get_component_no()); + net.freerouting.board.Component curr_component = p_par.board.components.get(p_pin.get_component_no()); if (curr_component == null) { System.out.println("Net.write_scope: component not found"); return; } - library.Package.Pin lib_pin = curr_component.get_package().get_pin(p_pin.get_index_in_package()); + net.freerouting.library.Package.Pin lib_pin = curr_component.get_package().get_pin(p_pin.get_index_in_package()); if (lib_pin == null) { System.out.println("Net.write_scope: pin number out of range"); diff --git a/designformats/specctra/NetClass.java b/src/main/java/net/freerouting/designformats/specctra/NetClass.java similarity index 99% rename from designformats/specctra/NetClass.java rename to src/main/java/net/freerouting/designformats/specctra/NetClass.java index 2f588198..af7da4bf 100644 --- a/designformats/specctra/NetClass.java +++ b/src/main/java/net/freerouting/designformats/specctra/NetClass.java @@ -18,7 +18,7 @@ * Created on 13. April 2005, 06:55 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.LinkedList; diff --git a/designformats/specctra/NetList.java b/src/main/java/net/freerouting/designformats/specctra/NetList.java similarity index 98% rename from designformats/specctra/NetList.java rename to src/main/java/net/freerouting/designformats/specctra/NetList.java index 7da24712..48a7fcd6 100644 --- a/designformats/specctra/NetList.java +++ b/src/main/java/net/freerouting/designformats/specctra/NetList.java @@ -18,7 +18,7 @@ * Created on 19. Mai 2004, 09:05 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.Iterator; diff --git a/designformats/specctra/Network.java b/src/main/java/net/freerouting/designformats/specctra/Network.java similarity index 86% rename from designformats/specctra/Network.java rename to src/main/java/net/freerouting/designformats/specctra/Network.java index 042c6b1d..87c7758d 100644 --- a/designformats/specctra/Network.java +++ b/src/main/java/net/freerouting/designformats/specctra/Network.java @@ -17,23 +17,23 @@ * * Created on 22. Mai 2004, 07:44 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import geometry.planar.IntPoint; -import geometry.planar.Point; -import geometry.planar.Vector; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Vector; import java.util.Collection; import java.util.LinkedList; import java.util.Set; import java.util.Iterator; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; -import rules.BoardRules; -import rules.DefaultItemClearanceClasses.ItemClass; -import board.RoutingBoard; +import net.freerouting.rules.BoardRules; +import net.freerouting.rules.DefaultItemClearanceClasses.ItemClass; +import net.freerouting.board.RoutingBoard; /** * Class for reading and writing net network from dsn-files. @@ -53,7 +53,7 @@ public boolean read_scope(ReadScopeParameter p_par) { Collection classes = new LinkedList(); Collection class_class_list = new LinkedList(); - Collection via_infos = new LinkedList(); + Collection via_infos = new LinkedList(); Collection> via_rules = new LinkedList>(); Object next_token = null; for (;;) @@ -87,7 +87,7 @@ public boolean read_scope(ReadScopeParameter p_par) } else if (next_token == Keyword.VIA) { - rules.ViaInfo curr_via_info = read_via_info(p_par.scanner, p_par.board_handling.get_routing_board()); + net.freerouting.rules.ViaInfo curr_via_info = read_via_info(p_par.scanner, p_par.board_handling.get_routing_board()); if (curr_via_info == null) { return false; @@ -140,7 +140,7 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep { p_par.file.start_scope(); p_par.file.write("network"); - Collection board_pins = p_par.board.get_pins(); + Collection board_pins = p_par.board.get_pins(); for (int i = 1; i <= p_par.board.rules.nets.max_net_no(); ++i) { Net.write_scope(p_par, p_par.board.rules.nets.get(i), board_pins); @@ -151,12 +151,12 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep p_par.file.end_scope(); } - public static void write_via_infos(rules.BoardRules p_rules, IndentFileWriter p_file, IdentifierType p_identifier_type) + public static void write_via_infos(net.freerouting.rules.BoardRules p_rules, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { for (int i = 0; i < p_rules.via_infos.count(); ++i) { - rules.ViaInfo curr_via = p_rules.via_infos.get(i); + net.freerouting.rules.ViaInfo curr_via = p_rules.via_infos.get(i); p_file.start_scope(); p_file.write("via "); p_file.new_line(); @@ -173,10 +173,10 @@ public static void write_via_infos(rules.BoardRules p_rules, IndentFileWriter p_ } } - public static void write_via_rules(rules.BoardRules p_rules, IndentFileWriter p_file, IdentifierType p_identifier_type) + public static void write_via_rules(net.freerouting.rules.BoardRules p_rules, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { - for (rules.ViaRule curr_rule : p_rules.via_rules) + for (net.freerouting.rules.ViaRule curr_rule : p_rules.via_rules) { p_file.start_scope(); p_file.write("via_rule"); @@ -200,7 +200,7 @@ public static void write_net_classes(WriteScopeParameter p_par) } } - public static void write_net_class(rules.NetClass p_net_class, WriteScopeParameter p_par) + public static void write_net_class(net.freerouting.rules.NetClass p_net_class, WriteScopeParameter p_par) throws java.io.IOException { p_par.file.start_scope(); @@ -255,7 +255,7 @@ public static void write_net_class(rules.NetClass p_net_class, WriteScopeParamet p_par.file.end_scope(); } - private static void write_circuit(rules.NetClass p_net_class, WriteScopeParameter p_par) + private static void write_circuit(net.freerouting.rules.NetClass p_net_class, WriteScopeParameter p_par) throws java.io.IOException { double min_trace_length = p_net_class.get_minimum_trace_length(); @@ -439,7 +439,7 @@ else if (next_token == Keyword.LAYER_RULE) if (!net_rules.isEmpty()) { // Evaluate the net rules. - rules.Net board_net = p_board.rules.nets.get(curr_subnet.id.name, curr_subnet.id.subnet_number); + net.freerouting.rules.Net board_net = p_board.rules.nets.get(curr_subnet.id.name, curr_subnet.id.subnet_number); if (board_net == null) { System.out.println("Network.read_net_scope: board net not found"); @@ -451,10 +451,10 @@ else if (next_token == Keyword.LAYER_RULE) Rule curr_ob = it.next(); if (curr_ob instanceof Rule.WidthRule) { - rules.NetClass default_net_rule = p_board.rules.get_default_net_class(); + net.freerouting.rules.NetClass default_net_rule = p_board.rules.get_default_net_class(); double wire_width = ((Rule.WidthRule) curr_ob).value; int trace_halfwidth = (int) Math.round(p_coordinate_transform.dsn_to_board(wire_width) / 2); - rules.NetClass net_rule = + net.freerouting.rules.NetClass net_rule = p_board.rules.net_classes.find(trace_halfwidth, default_net_rule.get_trace_clearance_class(), default_net_rule.get_via_rule()); if (net_rule == null) @@ -548,7 +548,7 @@ private static boolean read_net_pins(Scanner p_scanner, Collection p_pi return true; } - static rules.ViaInfo read_via_info(Scanner p_scanner, board.BasicBoard p_board) + static net.freerouting.rules.ViaInfo read_via_info(Scanner p_scanner, net.freerouting.board.BasicBoard p_board) { try { @@ -568,7 +568,7 @@ static rules.ViaInfo read_via_info(Scanner p_scanner, board.BasicBoard p_board) return null; } String padstack_name = (String) next_token; - library.Padstack via_padstack = p_board.library.get_via_padstack(padstack_name); + net.freerouting.library.Padstack via_padstack = p_board.library.get_via_padstack(padstack_name); if (via_padstack == null) { // The padstack may not yet be inserted into the list of via padstacks @@ -610,7 +610,7 @@ static rules.ViaInfo read_via_info(Scanner p_scanner, board.BasicBoard p_board) return null; } } - return new rules.ViaInfo(name, via_padstack, clearance_class, attach_allowed, p_board.rules); + return new net.freerouting.rules.ViaInfo(name, via_padstack, clearance_class, attach_allowed, p_board.rules); } catch (java.io.IOException e) { System.out.println("Network.read_via_info: IO error while scanning file"); @@ -618,7 +618,7 @@ static rules.ViaInfo read_via_info(Scanner p_scanner, board.BasicBoard p_board) } } - static Collection read_via_rule(Scanner p_scanner, board.BasicBoard p_board) + static Collection read_via_rule(Scanner p_scanner, net.freerouting.board.BasicBoard p_board) { try { @@ -646,11 +646,11 @@ static Collection read_via_rule(Scanner p_scanner, board.BasicBoard p_bo } } - private static void insert_via_infos(Collection p_via_infos, RoutingBoard p_board, boolean p_attach_allowed) + private static void insert_via_infos(Collection p_via_infos, RoutingBoard p_board, boolean p_attach_allowed) { if (p_via_infos.size() > 0) { - for (rules.ViaInfo curr_info : p_via_infos) + for (net.freerouting.rules.ViaInfo curr_info : p_via_infos) { p_board.rules.via_infos.add(curr_info); } @@ -661,13 +661,13 @@ private static void insert_via_infos(Collection p_via_infos, Rout } } - private static void create_default_via_infos(board.BasicBoard p_board, rules.NetClass p_net_class, boolean p_attach_allowed) + private static void create_default_via_infos(net.freerouting.board.BasicBoard p_board, net.freerouting.rules.NetClass p_net_class, boolean p_attach_allowed) { - int cl_class = p_net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.VIA); + int cl_class = p_net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.VIA); boolean is_default_class = (p_net_class == p_board.rules.get_default_net_class()); for (int i = 0; i < p_board.library.via_padstack_count(); ++i) { - library.Padstack curr_padstack = p_board.library.get_via_padstack(i); + net.freerouting.library.Padstack curr_padstack = p_board.library.get_via_padstack(i); boolean attach_allowed = p_attach_allowed && curr_padstack.attach_allowed; String via_name; if (is_default_class) @@ -678,13 +678,13 @@ private static void create_default_via_infos(board.BasicBoard p_board, rules.Net { via_name = curr_padstack.name + DsnFile.CLASS_CLEARANCE_SEPARATOR + p_net_class.get_name(); } - rules.ViaInfo found_via_info = - new rules.ViaInfo(via_name, curr_padstack, cl_class, attach_allowed, p_board.rules); + net.freerouting.rules.ViaInfo found_via_info = + new net.freerouting.rules.ViaInfo(via_name, curr_padstack, cl_class, attach_allowed, p_board.rules); p_board.rules.via_infos.add(found_via_info); } } - private static void insert_via_rules(Collection> p_via_rules, board.BasicBoard p_board) + private static void insert_via_rules(Collection> p_via_rules, net.freerouting.board.BasicBoard p_board) { boolean rule_found = false; for (Collection curr_list : p_via_rules) @@ -712,16 +712,16 @@ private static void insert_via_rules(Collection> p_via_rules, * Inserts a via rule into the board. * Replaces an already existing via rule with the same */ - static boolean add_via_rule(Collection p_name_list, board.BasicBoard p_board) + static boolean add_via_rule(Collection p_name_list, net.freerouting.board.BasicBoard p_board) { Iterator it = p_name_list.iterator(); String rule_name = it.next(); - rules.ViaRule existing_rule = p_board.rules.get_via_rule(rule_name); - rules.ViaRule curr_rule = new rules.ViaRule(rule_name); + net.freerouting.rules.ViaRule existing_rule = p_board.rules.get_via_rule(rule_name); + net.freerouting.rules.ViaRule curr_rule = new net.freerouting.rules.ViaRule(rule_name); boolean rule_ok = true; while (it.hasNext()) { - rules.ViaInfo curr_via = p_board.rules.via_infos.get(it.next()); + net.freerouting.rules.ViaInfo curr_via = p_board.rules.via_infos.get(it.next()); if (curr_via != null) { curr_rule.append_via(curr_via); @@ -746,17 +746,17 @@ static boolean add_via_rule(Collection p_name_list, board.BasicBoard p_b private static void insert_net_classes(Collection p_net_classes, ReadScopeParameter p_par) { - board.BasicBoard routing_board = p_par.board_handling.get_routing_board(); + net.freerouting.board.BasicBoard routing_board = p_par.board_handling.get_routing_board(); for (NetClass curr_class : p_net_classes) { insert_net_class(curr_class, p_par.layer_structure, routing_board, p_par.coordinate_transform, p_par.via_at_smd_allowed); } } - static void insert_net_class(NetClass p_class, LayerStructure p_layer_structure, board.BasicBoard p_board, CoordinateTransform p_coordinate_transform, + static void insert_net_class(NetClass p_class, LayerStructure p_layer_structure, net.freerouting.board.BasicBoard p_board, CoordinateTransform p_coordinate_transform, boolean p_via_at_smd_allowed) { - rules.NetClass board_net_class = p_board.rules.append_net_class(p_class.name); + net.freerouting.rules.NetClass board_net_class = p_board.rules.append_net_class(p_class.name); if (p_class.trace_clearance_class != null) { int trace_clearance_class = p_board.rules.clearance_matrix.get_no(p_class.trace_clearance_class); @@ -771,7 +771,7 @@ static void insert_net_class(NetClass p_class, LayerStructure p_layer_structure, } if (p_class.via_rule != null) { - rules.ViaRule via_rule = p_board.rules.get_via_rule(p_class.via_rule); + net.freerouting.rules.ViaRule via_rule = p_board.rules.get_via_rule(p_class.via_rule); if (via_rule != null) { board_net_class.set_via_rule(via_rule); @@ -791,8 +791,8 @@ static void insert_net_class(NetClass p_class, LayerStructure p_layer_structure, } for (String curr_net_name : p_class.net_list) { - Collection curr_net_list = p_board.rules.nets.get(curr_net_name); - for (rules.Net curr_net : curr_net_list) + Collection curr_net_list = p_board.rules.nets.get(curr_net_name); + for (net.freerouting.rules.Net curr_net : curr_net_list) { curr_net.set_class(board_net_class); } @@ -883,11 +883,11 @@ static private void insert_class_pairs(Collection p_class_c for (NetClass.ClassClass curr_class_class : p_class_classes) { java.util.Iterator it1 = curr_class_class.class_names.iterator(); - board.BasicBoard routing_board = p_par.board_handling.get_routing_board(); + net.freerouting.board.BasicBoard routing_board = p_par.board_handling.get_routing_board(); while (it1.hasNext()) { String first_name = it1.next(); - rules.NetClass first_class = routing_board.rules.net_classes.get(first_name); + net.freerouting.rules.NetClass first_class = routing_board.rules.net_classes.get(first_name); if (first_class == null) { System.out.println("Network.insert_class_pairs: first class not found"); @@ -898,7 +898,7 @@ static private void insert_class_pairs(Collection p_class_c while (it2.hasNext()) { String second_name = it2.next(); - rules.NetClass second_class = routing_board.rules.net_classes.get(second_name); + net.freerouting.rules.NetClass second_class = routing_board.rules.net_classes.get(second_name); if (second_class == null) { System.out.println("Network.insert_class_pairs: second class not found"); @@ -914,8 +914,8 @@ static private void insert_class_pairs(Collection p_class_c } } - static private void insert_class_pair_info(NetClass.ClassClass p_class_class, rules.NetClass p_first_class, rules.NetClass p_second_class, - board.BasicBoard p_board, CoordinateTransform p_coordinate_transform) + static private void insert_class_pair_info(NetClass.ClassClass p_class_class, net.freerouting.rules.NetClass p_first_class, net.freerouting.rules.NetClass p_second_class, + net.freerouting.board.BasicBoard p_board, CoordinateTransform p_coordinate_transform) { for (Rule curr_rule : p_class_class.rules) { @@ -957,8 +957,8 @@ static private void insert_class_pair_info(NetClass.ClassClass p_class_class, ru } } - static private void add_mixed_clearance_rule(rules.ClearanceMatrix p_clearance_matrix, rules.NetClass p_first_class, - rules.NetClass p_second_class, Rule.ClearanceRule p_clearance_rule, int p_layer_no, + static private void add_mixed_clearance_rule(net.freerouting.rules.ClearanceMatrix p_clearance_matrix, net.freerouting.rules.NetClass p_first_class, + net.freerouting.rules.NetClass p_second_class, Rule.ClearanceRule p_clearance_rule, int p_layer_no, CoordinateTransform p_coordinate_transform) { int curr_clearance = (int) Math.round(p_coordinate_transform.dsn_to_board(p_clearance_rule.value)); @@ -1030,8 +1030,8 @@ static private void add_mixed_clearance_rule(rules.ClearanceMatrix p_clearance_m } } - static private void create_default_clearance_classes(rules.NetClass p_net_class, - rules.ClearanceMatrix p_clearance_matrix) + static private void create_default_clearance_classes(net.freerouting.rules.NetClass p_net_class, + net.freerouting.rules.ClearanceMatrix p_clearance_matrix) { get_clearance_class(p_clearance_matrix, p_net_class, "via"); get_clearance_class(p_clearance_matrix, p_net_class, "smd"); @@ -1039,15 +1039,15 @@ static private void create_default_clearance_classes(rules.NetClass p_net_class, get_clearance_class(p_clearance_matrix, p_net_class, "area"); } - private static void create_via_rule(Collection p_use_via, rules.NetClass p_net_class, board.BasicBoard p_board, boolean p_attach_allowed) + private static void create_via_rule(Collection p_use_via, net.freerouting.rules.NetClass p_net_class, net.freerouting.board.BasicBoard p_board, boolean p_attach_allowed) { - rules.ViaRule new_via_rule = new rules.ViaRule(p_net_class.get_name()); - int default_via_cl_class = p_net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.VIA); + net.freerouting.rules.ViaRule new_via_rule = new net.freerouting.rules.ViaRule(p_net_class.get_name()); + int default_via_cl_class = p_net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.VIA); for (String curr_via_name : p_use_via) { for (int i = 0; i < p_board.rules.via_infos.count(); ++i) { - rules.ViaInfo curr_via_info = p_board.rules.via_infos.get(i); + net.freerouting.rules.ViaInfo curr_via_info = p_board.rules.via_infos.get(i); if (curr_via_info.get_clearance_class() == default_via_cl_class) { if (curr_via_info.get_padstack().name.equals(curr_via_name)) @@ -1061,7 +1061,7 @@ private static void create_via_rule(Collection p_use_via, rules.NetClass p_net_class.set_via_rule(new_via_rule); } - private static void create_active_trace_layers(Collection p_use_layer, LayerStructure p_layer_structure, rules.NetClass p_net_class) + private static void create_active_trace_layers(Collection p_use_layer, LayerStructure p_layer_structure, net.freerouting.rules.NetClass p_net_class) { for (int i = 0; i < p_layer_structure.arr.length; ++i) { @@ -1082,7 +1082,7 @@ private static void create_active_trace_layers(Collection p_use_layer, L } } - private static void add_clearance_rule(rules.ClearanceMatrix p_clearance_matrix, rules.NetClass p_net_class, + private static void add_clearance_rule(net.freerouting.rules.ClearanceMatrix p_clearance_matrix, net.freerouting.rules.NetClass p_net_class, Rule.ClearanceRule p_rule, int p_layer_no, CoordinateTransform p_coordinate_transform) { int curr_clearance = (int) Math.round(p_coordinate_transform.dsn_to_board(p_rule.value)); @@ -1153,8 +1153,8 @@ private static void add_clearance_rule(rules.ClearanceMatrix p_clearance_matrix, * Gets the number of the clearance class with name combined of p_net_class_name and p_item_class_name. * Creates a new class, if that class is not yet existing. */ - static private int get_clearance_class(rules.ClearanceMatrix p_clearance_matrix, - rules.NetClass p_net_class, String p_item_class_name) + static private int get_clearance_class(net.freerouting.rules.ClearanceMatrix p_clearance_matrix, + net.freerouting.rules.NetClass p_net_class, String p_item_class_name) { String net_class_name = p_net_class.get_name(); String new_class_name = net_class_name; @@ -1227,16 +1227,16 @@ private static void insert_compoments(ReadScopeParameter p_par) */ private static boolean insert_logical_parts(ReadScopeParameter p_par) { - board.BasicBoard routing_board = p_par.board_handling.get_routing_board(); + net.freerouting.board.BasicBoard routing_board = p_par.board_handling.get_routing_board(); for (PartLibrary.LogicalPart next_part : p_par.logical_parts) { - library.Package lib_package = search_lib_package(next_part.name, p_par.logical_part_mappings, routing_board); + net.freerouting.library.Package lib_package = search_lib_package(next_part.name, p_par.logical_part_mappings, routing_board); if (lib_package == null) { return false; } - library.LogicalPart.PartPin[] board_part_pins = - new library.LogicalPart.PartPin[next_part.part_pins.size()]; + net.freerouting.library.LogicalPart.PartPin[] board_part_pins = + new net.freerouting.library.LogicalPart.PartPin[next_part.part_pins.size()]; int curr_index = 0; for (PartLibrary.PartPin curr_part_pin : next_part.part_pins) { @@ -1247,7 +1247,7 @@ private static boolean insert_logical_parts(ReadScopeParameter p_par) return false; } board_part_pins[curr_index] = - new library.LogicalPart.PartPin(pin_no, curr_part_pin.pin_name, + new net.freerouting.library.LogicalPart.PartPin(pin_no, curr_part_pin.pin_name, curr_part_pin.gate_name, curr_part_pin.gate_swap_code, curr_part_pin.gate_pin_name, curr_part_pin.gate_pin_swap_code); ++curr_index; @@ -1257,7 +1257,7 @@ private static boolean insert_logical_parts(ReadScopeParameter p_par) for (PartLibrary.LogicalPartMapping next_mapping : p_par.logical_part_mappings) { - library.LogicalPart curr_logical_part = routing_board.library.logical_parts.get(next_mapping.name); + net.freerouting.library.LogicalPart curr_logical_part = routing_board.library.logical_parts.get(next_mapping.name); { if (curr_logical_part == null) { @@ -1266,7 +1266,7 @@ private static boolean insert_logical_parts(ReadScopeParameter p_par) } for (String curr_cmp_name : next_mapping.components) { - board.Component curr_component = routing_board.components.get(curr_cmp_name); + net.freerouting.board.Component curr_component = routing_board.components.get(curr_cmp_name); if (curr_component != null) { curr_component.set_logical_part(curr_logical_part); @@ -1284,8 +1284,8 @@ private static boolean insert_logical_parts(ReadScopeParameter p_par) * Calculates the library package belonging to the logical part with name p_part_name. * Returns null, if the package was not found. */ - private static library.Package search_lib_package(String p_part_name, - java.util.Collection p_logical_part_mappings, board.BasicBoard p_board) + private static net.freerouting.library.Package search_lib_package(String p_part_name, + java.util.Collection p_logical_part_mappings, net.freerouting.board.BasicBoard p_board) { for (PartLibrary.LogicalPartMapping curr_mapping : p_logical_part_mappings) { @@ -1302,7 +1302,7 @@ private static library.Package search_lib_package(String p_part_name, System.out.println("Network.search_lib_package: component list empty"); return null; } - board.Component curr_component = p_board.components.get(component_name); + net.freerouting.board.Component curr_component = p_board.components.get(component_name); if (curr_component == null) { System.out.println("Network.search_lib_package: component not found"); @@ -1323,9 +1323,9 @@ private static library.Package search_lib_package(String p_part_name, private static void insert_component(ComponentPlacement.ComponentLocation p_location, String p_lib_key, ReadScopeParameter p_par) { - board.RoutingBoard routing_board = p_par.board_handling.get_routing_board(); - library.Package curr_front_package = routing_board.library.packages.get(p_lib_key, true); - library.Package curr_back_package = routing_board.library.packages.get(p_lib_key, false); + net.freerouting.board.RoutingBoard routing_board = p_par.board_handling.get_routing_board(); + net.freerouting.library.Package curr_front_package = routing_board.library.packages.get(p_lib_key, true); + net.freerouting.library.Package curr_back_package = routing_board.library.packages.get(p_lib_key, false); if (curr_front_package == null || curr_back_package == null) { System.out.println("Network.insert_component: component package not found"); @@ -1343,7 +1343,7 @@ private static void insert_component(ComponentPlacement.ComponentLocation p_loca } double rotation_in_degree = p_location.rotation; - board.Component new_component = routing_board.components.add(p_location.name, component_location, + net.freerouting.board.Component new_component = routing_board.components.add(p_location.name, component_location, rotation_in_degree, p_location.is_front, curr_front_package, curr_back_package, p_location.position_fixed); if (component_location == null) @@ -1351,20 +1351,20 @@ private static void insert_component(ComponentPlacement.ComponentLocation p_loca return; // component is not yet placed. } Vector component_translation = component_location.difference_by(Point.ZERO); - board.FixedState fixed_state; + net.freerouting.board.FixedState fixed_state; if (p_location.position_fixed) { - fixed_state = board.FixedState.SYSTEM_FIXED; + fixed_state = net.freerouting.board.FixedState.SYSTEM_FIXED; } else { - fixed_state = board.FixedState.UNFIXED; + fixed_state = net.freerouting.board.FixedState.UNFIXED; } - library.Package curr_package = new_component.get_package(); + net.freerouting.library.Package curr_package = new_component.get_package(); for (int i = 0; i < curr_package.pin_count(); ++i) { - library.Package.Pin curr_pin = curr_package.get_pin(i); - library.Padstack curr_padstack = routing_board.library.padstacks.get(curr_pin.padstack_no); + net.freerouting.library.Package.Pin curr_pin = curr_package.get_pin(i); + net.freerouting.library.Padstack curr_padstack = routing_board.library.padstacks.get(curr_pin.padstack_no); if (curr_padstack == null) { System.out.println("Network.insert_component: pin padstack not found"); @@ -1374,7 +1374,7 @@ private static void insert_component(ComponentPlacement.ComponentLocation p_loca Collection net_numbers = new LinkedList(); for (Net curr_pin_net : pin_nets) { - rules.Net curr_board_net = routing_board.rules.nets.get(curr_pin_net.id.name, curr_pin_net.id.subnet_number); + net.freerouting.rules.Net curr_board_net = routing_board.rules.nets.get(curr_pin_net.id.name, curr_pin_net.id.subnet_number); if (curr_board_net == null) { System.out.println("Network.insert_component: board net not found"); @@ -1392,8 +1392,8 @@ private static void insert_component(ComponentPlacement.ComponentLocation p_loca net_no_arr[net_index] = curr_net_no; ++net_index; } - rules.NetClass net_class; - rules.Net board_net; + net.freerouting.rules.NetClass net_class; + net.freerouting.rules.Net board_net; if (net_no_arr.length > 0) { board_net = routing_board.rules.nets.get(net_no_arr[0]); @@ -1420,11 +1420,11 @@ private static void insert_component(ComponentPlacement.ComponentLocation p_loca { if (curr_padstack.from_layer() == curr_padstack.to_layer()) { - clearance_class = net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.SMD); + clearance_class = net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.SMD); } else { - clearance_class = net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.PIN); + clearance_class = net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.PIN); } } routing_board.insert_pin(new_component.no, i, net_no_arr, clearance_class, fixed_state); @@ -1433,7 +1433,7 @@ private static void insert_component(ComponentPlacement.ComponentLocation p_loca // insert the keepouts belonging to the package (k = 1 for via keepouts) for (int k = 0; k <= 2; ++k) { - library.Package.Keepout[] keepout_arr; + net.freerouting.library.Package.Keepout[] keepout_arr; java.util.Map curr_keepout_infos; if (k == 0) { @@ -1452,7 +1452,7 @@ else if (k == 1) } for (int i = 0; i < keepout_arr.length; ++i) { - library.Package.Keepout curr_keepout = keepout_arr[i]; + net.freerouting.library.Package.Keepout curr_keepout = keepout_arr[i]; int layer = curr_keepout.layer; if (layer >= routing_board.get_layer_count()) { @@ -1464,7 +1464,7 @@ else if (k == 1) layer = routing_board.get_layer_count() - curr_keepout.layer - 1; } int clearance_class = - routing_board.rules.get_default_net_class().default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.AREA); + routing_board.rules.get_default_net_class().default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.AREA); ComponentPlacement.ItemClearanceInfo keepout_info = curr_keepout_infos.get(curr_keepout.name); if (keepout_info != null) { diff --git a/designformats/specctra/Package.java b/src/main/java/net/freerouting/designformats/specctra/Package.java similarity index 94% rename from designformats/specctra/Package.java rename to src/main/java/net/freerouting/designformats/specctra/Package.java index 6347cac7..484da097 100644 --- a/designformats/specctra/Package.java +++ b/src/main/java/net/freerouting/designformats/specctra/Package.java @@ -18,13 +18,13 @@ * Created on 21. Mai 2004, 09:31 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import board.Item; +import net.freerouting.board.Item; /** * Class for reading and writing package scopes from dsn-files. @@ -155,7 +155,7 @@ else if (next_token == Keyword.PLACE_KEEPOUT) } } - public static void write_scope(WriteScopeParameter p_par, library.Package p_package) throws java.io.IOException + public static void write_scope(WriteScopeParameter p_par, net.freerouting.library.Package p_package) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("image "); @@ -174,10 +174,10 @@ public static void write_scope(WriteScopeParameter p_par, library.Package p_pack // write the pins of the package for (int i = 0; i < p_package.pin_count(); ++i) { - library.Package.Pin curr_pin = p_package.get_pin(i); + net.freerouting.library.Package.Pin curr_pin = p_package.get_pin(i); p_par.file.new_line(); p_par.file.write("(pin "); - library.Padstack curr_padstack = p_par.board.library.padstacks.get(curr_pin.padstack_no); + net.freerouting.library.Padstack curr_padstack = p_par.board.library.padstacks.get(curr_pin.padstack_no); p_par.identifier_type.write(curr_padstack.name, p_par.file); p_par.file.write(" "); p_par.identifier_type.write(curr_pin.name, p_par.file); @@ -217,25 +217,25 @@ public static void write_scope(WriteScopeParameter p_par, library.Package p_pack p_par.file.end_scope(); } - private static void write_package_keepout(library.Package.Keepout p_keepout, WriteScopeParameter p_par, + private static void write_package_keepout(net.freerouting.library.Package.Keepout p_keepout, WriteScopeParameter p_par, boolean p_is_via_keepout) throws java.io.IOException { Layer keepout_layer; if (p_keepout.layer >= 0) { - board.Layer board_layer = p_par.board.layer_structure.arr[p_keepout.layer]; + net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[p_keepout.layer]; keepout_layer = new Layer(board_layer.name, p_keepout.layer, board_layer.is_signal); } else { keepout_layer = Layer.SIGNAL; } - geometry.planar.Shape boundary_shape; - geometry.planar.Shape [] holes; - if (p_keepout.area instanceof geometry.planar.Shape) + net.freerouting.geometry.planar.Shape boundary_shape; + net.freerouting.geometry.planar.Shape [] holes; + if (p_keepout.area instanceof net.freerouting.geometry.planar.Shape) { - boundary_shape = (geometry.planar.Shape) p_keepout.area ; - holes = new geometry.planar.Shape [0]; + boundary_shape = (net.freerouting.geometry.planar.Shape) p_keepout.area ; + holes = new net.freerouting.geometry.planar.Shape [0]; } else { @@ -411,14 +411,14 @@ else if (next_token instanceof Double) /** * Writes the placements of p_package to a Specctra dsn-file. */ - public static void write_placement_scope(WriteScopeParameter p_par, library.Package p_package) + public static void write_placement_scope(WriteScopeParameter p_par, net.freerouting.library.Package p_package) throws java.io.IOException { Collection board_items = p_par.board.get_items(); boolean component_found = false; for (int i = 1; i <= p_par.board.components.count(); ++i) { - board.Component curr_component = p_par.board.components.get(i); + net.freerouting.board.Component curr_component = p_par.board.components.get(i); if (curr_component.get_package() == p_package) { // check, if not all items of the component are deleted diff --git a/designformats/specctra/Parser.java b/src/main/java/net/freerouting/designformats/specctra/Parser.java similarity index 96% rename from designformats/specctra/Parser.java rename to src/main/java/net/freerouting/designformats/specctra/Parser.java index dffc2dc2..da2da788 100644 --- a/designformats/specctra/Parser.java +++ b/src/main/java/net/freerouting/designformats/specctra/Parser.java @@ -17,9 +17,9 @@ * * Created on 24. Januar 2005, 08:29 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import board.Communication.SpecctraParserInfo; +import net.freerouting.board.Communication.SpecctraParserInfo; /** * Class for reading and writing parser scopes from dsn-files. @@ -183,8 +183,8 @@ private static String[] read_constant(ReadScopeParameter p_par) /** * p_reduced is true if the scope is written to a session file. */ - public static void write_scope(datastructures.IndentFileWriter p_file, SpecctraParserInfo p_parser_info, - datastructures.IdentifierType p_identifier_type, boolean p_reduced) throws java.io.IOException + public static void write_scope(net.freerouting.datastructures.IndentFileWriter p_file, SpecctraParserInfo p_parser_info, + net.freerouting.datastructures.IdentifierType p_identifier_type, boolean p_reduced) throws java.io.IOException { p_file.start_scope(); p_file.write("parser"); diff --git a/designformats/specctra/PartLibrary.java b/src/main/java/net/freerouting/designformats/specctra/PartLibrary.java similarity index 96% rename from designformats/specctra/PartLibrary.java rename to src/main/java/net/freerouting/designformats/specctra/PartLibrary.java index c0ebb4fa..8cf9135d 100644 --- a/designformats/specctra/PartLibrary.java +++ b/src/main/java/net/freerouting/designformats/specctra/PartLibrary.java @@ -18,7 +18,7 @@ * Created on 23. Maerz 2005, 08:36 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; /** * @@ -90,7 +90,7 @@ else if (next_token == Keyword.LOGICAL_PART) public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException { - library.LogicalParts logical_parts = p_par.board.library.logical_parts; + net.freerouting.library.LogicalParts logical_parts = p_par.board.library.logical_parts; if (logical_parts.count() <= 0) { return; @@ -102,7 +102,7 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep for (int i = 1; i <= logical_parts.count(); ++i) { - library.LogicalPart curr_part = logical_parts.get(i); + net.freerouting.library.LogicalPart curr_part = logical_parts.get(i); p_par.file.start_scope(); p_par.file.write("logical_part_mapping "); p_par.identifier_type.write(curr_part.name, p_par.file); @@ -110,7 +110,7 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep p_par.file.write("(comp"); for (int j = 1; j <= p_par.board.components.count(); ++j) { - board.Component curr_compomnent = p_par.board.components.get(j); + net.freerouting.board.Component curr_compomnent = p_par.board.components.get(j); if (curr_compomnent.get_logical_part() == curr_part) { p_par.file.write(" "); @@ -125,7 +125,7 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep for (int i = 1; i <= logical_parts.count(); ++i) { - library.LogicalPart curr_part = logical_parts.get(i); + net.freerouting.library.LogicalPart curr_part = logical_parts.get(i); p_par.file.start_scope(); p_par.file.write("logical_part "); @@ -134,7 +134,7 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep for (int j = 0; j < curr_part.pin_count(); ++j) { p_par.file.new_line(); - library.LogicalPart.PartPin curr_pin = curr_part.get_pin(j); + net.freerouting.library.LogicalPart.PartPin curr_pin = curr_part.get_pin(j); p_par.file.write("(pin "); p_par.identifier_type.write(curr_pin.pin_name, p_par.file); p_par.file.write(" 0 "); diff --git a/designformats/specctra/Path.java b/src/main/java/net/freerouting/designformats/specctra/Path.java similarity index 89% rename from designformats/specctra/Path.java rename to src/main/java/net/freerouting/designformats/specctra/Path.java index 2cad4036..8fa8eec4 100644 --- a/designformats/specctra/Path.java +++ b/src/main/java/net/freerouting/designformats/specctra/Path.java @@ -18,10 +18,10 @@ * Created on 30. Juni 2004, 09:28 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** * Class for writing path scopes from dsn-files. diff --git a/designformats/specctra/PlaceControl.java b/src/main/java/net/freerouting/designformats/specctra/PlaceControl.java similarity index 98% rename from designformats/specctra/PlaceControl.java rename to src/main/java/net/freerouting/designformats/specctra/PlaceControl.java index e71ab919..a3e7885e 100644 --- a/designformats/specctra/PlaceControl.java +++ b/src/main/java/net/freerouting/designformats/specctra/PlaceControl.java @@ -18,7 +18,7 @@ * Created on 25. November 2004, 13:21 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; /** * Class for reading place_control scopes from dsn-files. diff --git a/designformats/specctra/Placement.java b/src/main/java/net/freerouting/designformats/specctra/Placement.java similarity index 96% rename from designformats/specctra/Placement.java rename to src/main/java/net/freerouting/designformats/specctra/Placement.java index d03f9cda..befa1259 100644 --- a/designformats/specctra/Placement.java +++ b/src/main/java/net/freerouting/designformats/specctra/Placement.java @@ -18,7 +18,7 @@ * Created on 5. Juli 2004, 08:53 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; /** * Class for writing placement scopes from dsn-files. diff --git a/designformats/specctra/Plane.java b/src/main/java/net/freerouting/designformats/specctra/Plane.java similarity index 82% rename from designformats/specctra/Plane.java rename to src/main/java/net/freerouting/designformats/specctra/Plane.java index f58fab0b..8e1e48d5 100644 --- a/designformats/specctra/Plane.java +++ b/src/main/java/net/freerouting/designformats/specctra/Plane.java @@ -18,7 +18,7 @@ * Created on 19. Mai 2004, 08:39 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; @@ -66,7 +66,7 @@ public boolean read_scope(ReadScopeParameter p_par) return true; } - public static void write_scope(WriteScopeParameter p_par, board.ConductionArea p_conduction) throws java.io.IOException + public static void write_scope(WriteScopeParameter p_par, net.freerouting.board.ConductionArea p_conduction) throws java.io.IOException { int net_count = p_conduction.net_count(); if (net_count <= 0 || net_count > 1) @@ -75,16 +75,16 @@ public static void write_scope(WriteScopeParameter p_par, board.ConductionArea p return; } String net_name = p_par.board.rules.nets.get(p_conduction.get_net_no(0)).name; - geometry.planar.Area curr_area = p_conduction.get_area(); + net.freerouting.geometry.planar.Area curr_area = p_conduction.get_area(); int layer_no = p_conduction.get_layer(); - board.Layer board_layer = p_par.board.layer_structure.arr[ layer_no]; + net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[ layer_no]; Layer plane_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal); - geometry.planar.Shape boundary_shape; - geometry.planar.Shape [] holes; - if (curr_area instanceof geometry.planar.Shape) + net.freerouting.geometry.planar.Shape boundary_shape; + net.freerouting.geometry.planar.Shape [] holes; + if (curr_area instanceof net.freerouting.geometry.planar.Shape) { - boundary_shape = (geometry.planar.Shape) curr_area; - holes = new geometry.planar.Shape [0]; + boundary_shape = (net.freerouting.geometry.planar.Shape) curr_area; + holes = new net.freerouting.geometry.planar.Shape [0]; } else { diff --git a/designformats/specctra/Polygon.java b/src/main/java/net/freerouting/designformats/specctra/Polygon.java similarity index 86% rename from designformats/specctra/Polygon.java rename to src/main/java/net/freerouting/designformats/specctra/Polygon.java index 3231e547..a10ea6a0 100644 --- a/designformats/specctra/Polygon.java +++ b/src/main/java/net/freerouting/designformats/specctra/Polygon.java @@ -18,10 +18,10 @@ * Created on 15. Mai 2004, 08:39 */ -package designformats.specctra; -import geometry.planar.IntPoint; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +package net.freerouting.designformats.specctra; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** * Describes a polygon in a Specctra dsn file. @@ -41,7 +41,7 @@ public Polygon(Layer p_layer, double[] p_coor) coor = p_coor; } - public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) + public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) { IntPoint [] corner_arr = new IntPoint[coor.length / 2]; double [] curr_point = new double [2]; @@ -51,14 +51,14 @@ public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate curr_point[1] = coor[2 * i + 1]; corner_arr[i] = p_coordinate_transform.dsn_to_board(curr_point).round(); } - return new geometry.planar.PolygonShape(corner_arr); + return new net.freerouting.geometry.planar.PolygonShape(corner_arr); } - public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) + public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) { if (coor.length < 2) { - return geometry.planar.Simplex.EMPTY; + return net.freerouting.geometry.planar.Simplex.EMPTY; } IntPoint [] corner_arr = new IntPoint[coor.length / 2]; for (int i = 0; i < corner_arr.length; ++i) @@ -67,7 +67,7 @@ public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordi int curr_y = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[2 * i + 1])); corner_arr[i] = new IntPoint(curr_x, curr_y); } - return new geometry.planar.PolygonShape(corner_arr); + return new net.freerouting.geometry.planar.PolygonShape(corner_arr); } public Rectangle bounding_box() diff --git a/designformats/specctra/PolygonPath.java b/src/main/java/net/freerouting/designformats/specctra/PolygonPath.java similarity index 87% rename from designformats/specctra/PolygonPath.java rename to src/main/java/net/freerouting/designformats/specctra/PolygonPath.java index 298b0131..884ee4a7 100644 --- a/designformats/specctra/PolygonPath.java +++ b/src/main/java/net/freerouting/designformats/specctra/PolygonPath.java @@ -18,13 +18,13 @@ * Created on 24. Mai 2004, 08:10 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.IntOctagon; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** @@ -83,7 +83,7 @@ public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier p_file.end_scope(); } - public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) + public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) { FloatPoint [] corner_arr = new FloatPoint[this.coordinate_arr.length / 2]; double [] curr_point = new double [2]; @@ -104,7 +104,7 @@ public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate { rounded_corner_arr[i] = corner_arr[i].round(); } - geometry.planar.Shape result = new geometry.planar.PolygonShape(rounded_corner_arr); + net.freerouting.geometry.planar.Shape result = new net.freerouting.geometry.planar.PolygonShape(rounded_corner_arr); if (offset > 0) { result = result.bounding_tile().enlarge(offset); @@ -112,7 +112,7 @@ public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate return result; } - public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) + public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) { FloatPoint [] corner_arr = new FloatPoint[this.coordinate_arr.length / 2]; double [] curr_point = new double [2]; @@ -133,7 +133,7 @@ public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordi { rounded_corner_arr[i] = corner_arr[i].round(); } - geometry.planar.Shape result = new geometry.planar.PolygonShape(rounded_corner_arr); + net.freerouting.geometry.planar.Shape result = new net.freerouting.geometry.planar.PolygonShape(rounded_corner_arr); if (offset > 0) { result = result.bounding_tile().enlarge(offset); diff --git a/designformats/specctra/PolylinePath.java b/src/main/java/net/freerouting/designformats/specctra/PolylinePath.java similarity index 88% rename from designformats/specctra/PolylinePath.java rename to src/main/java/net/freerouting/designformats/specctra/PolylinePath.java index 2add8004..58a2ffb9 100644 --- a/designformats/specctra/PolylinePath.java +++ b/src/main/java/net/freerouting/designformats/specctra/PolylinePath.java @@ -18,10 +18,10 @@ * Created on 30. Juni 2004, 08:24 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** @@ -82,13 +82,13 @@ public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier p_file.end_scope(); } - public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) + public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) { System.out.println("PolylinePath.transform_to_board_rel not implemented"); return null; } - public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) + public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) { System.out.println("PolylinePath.transform_to_board_rel not implemented"); return null; diff --git a/designformats/specctra/ReadScopeParameter.java b/src/main/java/net/freerouting/designformats/specctra/ReadScopeParameter.java similarity index 77% rename from designformats/specctra/ReadScopeParameter.java rename to src/main/java/net/freerouting/designformats/specctra/ReadScopeParameter.java index 02f4a681..5ffad240 100644 --- a/designformats/specctra/ReadScopeParameter.java +++ b/src/main/java/net/freerouting/designformats/specctra/ReadScopeParameter.java @@ -18,7 +18,7 @@ * Created on 21. Juni 2004, 08:28 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.LinkedList; @@ -32,9 +32,9 @@ public class ReadScopeParameter { /** Creates a new instance of ReadScopeParameter */ - ReadScopeParameter(Scanner p_scanner, interactive.BoardHandling p_board_handling, - board.BoardObservers p_observers, - datastructures.IdNoGenerator p_item_id_no_generator,board.TestLevel p_test_level) + ReadScopeParameter(Scanner p_scanner, net.freerouting.interactive.BoardHandling p_board_handling, + net.freerouting.board.BoardObservers p_observers, + net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, net.freerouting.board.TestLevel p_test_level) { scanner = p_scanner; board_handling = p_board_handling; @@ -44,12 +44,12 @@ public class ReadScopeParameter } final Scanner scanner; - final interactive.BoardHandling board_handling; + final net.freerouting.interactive.BoardHandling board_handling; final NetList netlist = new NetList(); - final board.BoardObservers observers; - final datastructures.IdNoGenerator item_id_no_generator; - final board.TestLevel test_level; + final net.freerouting.board.BoardObservers observers; + final net.freerouting.datastructures.IdNoGenerator item_id_no_generator; + final net.freerouting.board.TestLevel test_level; /** Collection of elements of class PlaneInfo. * The plane cannot be inserted directly into the boards, because the layers may not be read completely. @@ -71,7 +71,7 @@ public class ReadScopeParameter Collection via_padstack_names = null; boolean via_at_smd_allowed = false; - board.AngleRestriction snap_angle = board.AngleRestriction.FORTYFIVE_DEGREE; + net.freerouting.board.AngleRestriction snap_angle = net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE; /** The logical parts are used for pin and gate swaw */ java.util.Collection logical_part_mappings @@ -88,15 +88,15 @@ public class ReadScopeParameter boolean board_outline_ok = true; final Collection constants = new LinkedList(); - board.Communication.SpecctraParserInfo.WriteResolution write_resolution = null; + net.freerouting.board.Communication.SpecctraParserInfo.WriteResolution write_resolution = null; /** The following objects will be initialised when the structure scope is read. */ CoordinateTransform coordinate_transform = null; LayerStructure layer_structure = null; - interactive.AutorouteSettings autoroute_settings = null; + net.freerouting.interactive.AutorouteSettings autoroute_settings = null; - board.Unit unit = board.Unit.MIL; + net.freerouting.board.Unit unit = net.freerouting.board.Unit.MIL; int resolution = 100; // default resulution /** Information for inserting a plane */ diff --git a/designformats/specctra/Rectangle.java b/src/main/java/net/freerouting/designformats/specctra/Rectangle.java similarity index 89% rename from designformats/specctra/Rectangle.java rename to src/main/java/net/freerouting/designformats/specctra/Rectangle.java index 474d4c58..e65133e3 100644 --- a/designformats/specctra/Rectangle.java +++ b/src/main/java/net/freerouting/designformats/specctra/Rectangle.java @@ -18,12 +18,12 @@ * Created on 15. Mai 2004, 08:39 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import geometry.planar.FloatPoint; -import geometry.planar.IntBox; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** * Describes a rectangle in a Specctra dsn file. @@ -61,7 +61,7 @@ public Rectangle union (Rectangle p_other) return new Rectangle(this.layer, result_coor); } - public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) + public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) { int box_coor[] = new int[4]; for (int i = 0; i < 4; ++i) @@ -83,7 +83,7 @@ public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordi return result; } - public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) + public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) { double [] curr_point = new double [2]; curr_point[0] = Math.min(coor[0], coor[2]); diff --git a/designformats/specctra/Resolution.java b/src/main/java/net/freerouting/designformats/specctra/Resolution.java similarity index 89% rename from designformats/specctra/Resolution.java rename to src/main/java/net/freerouting/designformats/specctra/Resolution.java index 833c84a1..6b8c7596 100644 --- a/designformats/specctra/Resolution.java +++ b/src/main/java/net/freerouting/designformats/specctra/Resolution.java @@ -18,7 +18,7 @@ * Created on 30. Oktober 2004, 08:00 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; /** * Class for reading resolution scopes from dsn-files. @@ -45,7 +45,7 @@ public boolean read_scope(ReadScopeParameter p_par) System.out.println("Resolution.read_scope: string expected"); return false; } - p_par.unit = board.Unit.from_string((String) next_token); + p_par.unit = net.freerouting.board.Unit.from_string((String) next_token); if (p_par.unit == null) { System.out.println("Resolution.read_scope: unit mil, inch or mm expected"); @@ -75,7 +75,7 @@ public boolean read_scope(ReadScopeParameter p_par) } } - public static void write_scope(datastructures.IndentFileWriter p_file, board.Communication p_board_communication) throws java.io.IOException + public static void write_scope(net.freerouting.datastructures.IndentFileWriter p_file, net.freerouting.board.Communication p_board_communication) throws java.io.IOException { p_file.new_line(); p_file.write("(resolution "); diff --git a/designformats/specctra/Rule.java b/src/main/java/net/freerouting/designformats/specctra/Rule.java similarity index 94% rename from designformats/specctra/Rule.java rename to src/main/java/net/freerouting/designformats/specctra/Rule.java index 0b90f3f6..415e8edc 100644 --- a/designformats/specctra/Rule.java +++ b/src/main/java/net/freerouting/designformats/specctra/Rule.java @@ -18,7 +18,7 @@ * Created on 1. Juni 2004, 09:27 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.LinkedList; @@ -169,7 +169,7 @@ else if (next_token instanceof Integer) } } - public static void write_scope(rules.NetClass p_net_class, WriteScopeParameter p_par) throws java.io.IOException + public static void write_scope(net.freerouting.rules.NetClass p_net_class, WriteScopeParameter p_par) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("rule"); @@ -191,12 +191,12 @@ public static void write_scope(rules.NetClass p_net_class, WriteScopeParameter p } } - private static void write_layer_rule(rules.NetClass p_net_class, int p_layer_no, WriteScopeParameter p_par) throws java.io.IOException + private static void write_layer_rule(net.freerouting.rules.NetClass p_net_class, int p_layer_no, WriteScopeParameter p_par) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("layer_rule "); - board.Layer curr_board_layer = p_par.board.layer_structure.arr[p_layer_no]; + net.freerouting.board.Layer curr_board_layer = p_par.board.layer_structure.arr[p_layer_no]; p_par.file.write(curr_board_layer.name); p_par.file.start_scope(); @@ -228,7 +228,7 @@ public static void write_default_rule(WriteScopeParameter p_par, int p_layer) th p_par.file.write((new Double(trace_width)).toString()); p_par.file.write(")"); // write the default clearance rule - int default_cl_no = rules.BoardRules.default_clearance_class(); + int default_cl_no = net.freerouting.rules.BoardRules.default_clearance_class(); int default_board_clearance = p_par.board.rules.clearance_matrix.value(default_cl_no, default_cl_no, p_layer); double default_clearance = p_par.coordinate_transform.board_to_dsn(default_board_clearance); p_par.file.new_line(); @@ -255,7 +255,7 @@ public static void write_default_rule(WriteScopeParameter p_par, int p_layer) th private static void write_clearance_rules(WriteScopeParameter p_par, int p_layer, int p_cl_class, int p_max_cl_class, int p_default_clearance) throws java.io.IOException { - rules.ClearanceMatrix cl_matrix = p_par.board.rules.clearance_matrix; + net.freerouting.rules.ClearanceMatrix cl_matrix = p_par.board.rules.clearance_matrix; for (int i = p_cl_class; i < p_max_cl_class; ++i) { int curr_board_clearance = cl_matrix.value(p_cl_class, i, p_layer); @@ -341,8 +341,8 @@ else if (next_token instanceof Integer) } - static public void write_item_clearance_class( String p_name, datastructures.IndentFileWriter p_file, - datastructures.IdentifierType p_identifier_type) throws java.io.IOException + static public void write_item_clearance_class( String p_name, net.freerouting.datastructures.IndentFileWriter p_file, + net.freerouting.datastructures.IdentifierType p_identifier_type) throws java.io.IOException { p_file.new_line(); p_file.write("(clearance_class "); diff --git a/designformats/specctra/RulesFile.java b/src/main/java/net/freerouting/designformats/specctra/RulesFile.java similarity index 92% rename from designformats/specctra/RulesFile.java rename to src/main/java/net/freerouting/designformats/specctra/RulesFile.java index 23dc7d6f..98425864 100644 --- a/designformats/specctra/RulesFile.java +++ b/src/main/java/net/freerouting/designformats/specctra/RulesFile.java @@ -19,11 +19,11 @@ * */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import datastructures.IndentFileWriter; +import net.freerouting.datastructures.IndentFileWriter; -import board.BasicBoard; +import net.freerouting.board.BasicBoard; /** * File for saving the board rules, so that they can be restored after the Board @@ -34,7 +34,7 @@ public class RulesFile { - public static void write(interactive.BoardHandling p_board_handling, java.io.OutputStream p_output_stream, String p_design_name) + public static void write(net.freerouting.interactive.BoardHandling p_board_handling, java.io.OutputStream p_output_stream, String p_design_name) { IndentFileWriter output_file = new IndentFileWriter(p_output_stream); BasicBoard routing_board = p_board_handling.get_routing_board(); @@ -61,7 +61,7 @@ public static void write(interactive.BoardHandling p_board_handling, java.io.Out } public static boolean read(java.io.InputStream p_input_stream, String p_design_name, - interactive.BoardHandling p_board_handling) + net.freerouting.interactive.BoardHandling p_board_handling) { BasicBoard routing_board = p_board_handling.get_routing_board(); Scanner scanner = new SpecctraFileScanner(p_input_stream); @@ -153,7 +153,7 @@ else if (next_token == Keyword.CLASS) else if (next_token == Keyword.SNAP_ANGLE) { - board.AngleRestriction snap_angle = Structure.read_snap_angle(scanner); + net.freerouting.board.AngleRestriction snap_angle = Structure.read_snap_angle(scanner); if (snap_angle != null) { routing_board.rules.set_trace_angle_restriction(snap_angle); @@ -161,7 +161,7 @@ else if (next_token == Keyword.SNAP_ANGLE) } else if (next_token == Keyword.AUTOROUTE_SETTINGS) { - interactive.AutorouteSettings autoroute_settings + net.freerouting.interactive.AutorouteSettings autoroute_settings = AutorouteSettings.read_scope(scanner, layer_structure); if (autoroute_settings != null) { @@ -194,7 +194,7 @@ private static void write_rules( WriteScopeParameter p_par, String p_design_name // write the via padstacks for (int i = 1; i <= p_par.board.library.padstacks.count(); ++i) { - library.Padstack curr_padstack = p_par.board.library.padstacks.get(i); + net.freerouting.library.Padstack curr_padstack = p_par.board.library.padstacks.get(i); if (p_par.board.library.get_via_padstack(curr_padstack.name )!= null) { Library.write_padstack_scope(p_par, curr_padstack); @@ -282,12 +282,12 @@ private static boolean add_layer_rules(Scanner p_scanner, BasicBoard p_board) } private static boolean read_via_info(Scanner p_scanner, BasicBoard p_board) { - rules.ViaInfo curr_via_info = Network.read_via_info(p_scanner, p_board); + net.freerouting.rules.ViaInfo curr_via_info = Network.read_via_info(p_scanner, p_board); if (curr_via_info == null) { return false; } - rules.ViaInfo existing_via = p_board.rules.via_infos.get(curr_via_info.get_name()); + net.freerouting.rules.ViaInfo existing_via = p_board.rules.via_infos.get(curr_via_info.get_name()); if (existing_via != null) { // replace existing via info diff --git a/designformats/specctra/Scanner.java b/src/main/java/net/freerouting/designformats/specctra/Scanner.java similarity index 95% rename from designformats/specctra/Scanner.java rename to src/main/java/net/freerouting/designformats/specctra/Scanner.java index 70c924bc..659c6041 100644 --- a/designformats/specctra/Scanner.java +++ b/src/main/java/net/freerouting/designformats/specctra/Scanner.java @@ -18,7 +18,7 @@ * Created on 4. Juli 2004, 19:13 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; /** * Interface for scanner generated by jflex. diff --git a/designformats/specctra/ScopeKeyword.java b/src/main/java/net/freerouting/designformats/specctra/ScopeKeyword.java similarity index 98% rename from designformats/specctra/ScopeKeyword.java rename to src/main/java/net/freerouting/designformats/specctra/ScopeKeyword.java index f64b2bf1..242727bf 100644 --- a/designformats/specctra/ScopeKeyword.java +++ b/src/main/java/net/freerouting/designformats/specctra/ScopeKeyword.java @@ -18,7 +18,7 @@ * Created on 12. Mai 2004, 08:47 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; /** * diff --git a/designformats/specctra/SessionFile.java b/src/main/java/net/freerouting/designformats/specctra/SessionFile.java similarity index 84% rename from designformats/specctra/SessionFile.java rename to src/main/java/net/freerouting/designformats/specctra/SessionFile.java index cc739b20..7179b47f 100644 --- a/designformats/specctra/SessionFile.java +++ b/src/main/java/net/freerouting/designformats/specctra/SessionFile.java @@ -18,20 +18,20 @@ * Created on 29. Oktober 2004, 08:01 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.Iterator; -import geometry.planar.FloatPoint; -import geometry.planar.Point; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Point; -import board.BasicBoard; -import board.PolylineTrace; -import board.Via; -import board.ConductionArea; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.board.BasicBoard; +import net.freerouting.board.PolylineTrace; +import net.freerouting.board.Via; +import net.freerouting.board.ConductionArea; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** * Methods to handle a Specctra session file. @@ -119,21 +119,21 @@ public static void write_placement(BasicBoard p_board, IdentifierType p_identifi * Writes all components with the package p_package to the session file. */ public static void write_components(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, - IndentFileWriter p_file, library.Package p_package) throws java.io.IOException + IndentFileWriter p_file, net.freerouting.library.Package p_package) throws java.io.IOException { - Collection board_items = p_board.get_items(); + Collection board_items = p_board.get_items(); boolean component_found = false; for (int i = 1; i <= p_board.components.count(); ++i) { - board.Component curr_component = p_board.components.get(i); + net.freerouting.board.Component curr_component = p_board.components.get(i); if (curr_component.get_package() == p_package) { // check, if not all items of the component are deleted boolean undeleted_item_found = false; - Iterator it = board_items.iterator(); + Iterator it = board_items.iterator(); while (it.hasNext()) { - board.Item curr_item = it.next(); + net.freerouting.board.Item curr_item = it.next(); if (curr_item.get_component_no() == curr_component.no) { undeleted_item_found = true; @@ -161,7 +161,7 @@ public static void write_components(BasicBoard p_board, IdentifierType p_identif } public static void write_component(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, - IndentFileWriter p_file, board.Component p_component) throws java.io.IOException + IndentFileWriter p_file, net.freerouting.board.Component p_component) throws java.io.IOException { p_file.new_line(); p_file.write("(place "); @@ -196,20 +196,20 @@ public static void write_was_is(BasicBoard p_board, IdentifierType p_identifier_ { p_file.start_scope(); p_file.write("was_is"); - Collection board_pins = p_board.get_pins(); - for (board.Pin curr_pin : board_pins) + Collection board_pins = p_board.get_pins(); + for (net.freerouting.board.Pin curr_pin : board_pins) { - board.Pin swapped_with = curr_pin.get_changed_to(); + net.freerouting.board.Pin swapped_with = curr_pin.get_changed_to(); if (curr_pin.get_changed_to() != curr_pin) { p_file.new_line(); p_file.write("(pins "); - board.Component curr_cmp = p_board.components.get(curr_pin.get_component_no()); + net.freerouting.board.Component curr_cmp = p_board.components.get(curr_pin.get_component_no()); if (curr_cmp != null) { p_identifier_type.write(curr_cmp.name, p_file); p_file.write("-"); - library.Package.Pin package_pin = curr_cmp.get_package().get_pin(curr_pin.get_index_in_package()); + net.freerouting.library.Package.Pin package_pin = curr_cmp.get_package().get_pin(curr_pin.get_index_in_package()); p_identifier_type.write(package_pin.name, p_file); } else @@ -217,12 +217,12 @@ public static void write_was_is(BasicBoard p_board, IdentifierType p_identifier_ System.out.println("SessionFile.write_was_is: component not found"); } p_file.write(" "); - board.Component swap_cmp = p_board.components.get(swapped_with.get_component_no()); + net.freerouting.board.Component swap_cmp = p_board.components.get(swapped_with.get_component_no()); if (swap_cmp != null) { p_identifier_type.write(swap_cmp.name, p_file); p_file.write("-"); - library.Package.Pin package_pin = swap_cmp.get_package().get_pin(swapped_with.get_index_in_package()); + net.freerouting.library.Package.Pin package_pin = swap_cmp.get_package().get_pin(swapped_with.get_index_in_package()); p_identifier_type.write(package_pin.name, p_file); } else @@ -259,7 +259,7 @@ private static void write_library(BasicBoard p_board, IdentifierType p_identifie p_file.end_scope(); } - private static void write_padstack(library.Padstack p_padstack, BasicBoard p_board, IdentifierType p_identifier_type, + private static void write_padstack(net.freerouting.library.Padstack p_padstack, BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException { @@ -293,12 +293,12 @@ private static void write_padstack(library.Padstack p_padstack, BasicBoard p_boa p_identifier_type.write(p_padstack.name, p_file); for (int i = first_layer_no; i <= last_layer_no; ++i) { - geometry.planar.Shape curr_board_shape = p_padstack.get_shape(i); + net.freerouting.geometry.planar.Shape curr_board_shape = p_padstack.get_shape(i); if (curr_board_shape == null) { continue; } - board.Layer board_layer = p_board.layer_structure.arr[i]; + net.freerouting.board.Layer board_layer = p_board.layer_structure.arr[i]; Layer curr_layer = new Layer(board_layer.name, i, board_layer.is_signal); Shape curr_shape = p_coordinate_transform.board_to_dsn_rel(curr_board_shape, curr_layer); p_file.start_scope(); @@ -331,13 +331,13 @@ private static void write_network(BasicBoard p_board, IdentifierType p_identifie private static void write_net(int p_net_no, BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException { - Collection net_items = p_board.get_connectable_items(p_net_no); + Collection net_items = p_board.get_connectable_items(p_net_no); boolean header_written = false; - Iterator it = net_items.iterator(); + Iterator it = net_items.iterator(); while (it.hasNext()) { - board.Item curr_item = it.next(); - if (curr_item.get_fixed_state() == board.FixedState.SYSTEM_FIXED) + net.freerouting.board.Item curr_item = it.next(); + if (curr_item.get_fixed_state() == net.freerouting.board.FixedState.SYSTEM_FIXED) { continue; } @@ -349,7 +349,7 @@ private static void write_net(int p_net_no, BasicBoard p_board, IdentifierType p { p_file.start_scope(); p_file.write("net "); - rules.Net curr_net = p_board.rules.nets.get(p_net_no); + net.freerouting.rules.Net curr_net = p_board.rules.nets.get(p_net_no); if (curr_net == null) { System.out.println("SessionFile.write_net: net not found"); @@ -384,7 +384,7 @@ private static void write_wire(PolylineTrace p_wire, BasicBoard p_board, Identif CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException { int layer_no = p_wire.get_layer(); - board.Layer board_layer = p_board.layer_structure.arr[layer_no]; + net.freerouting.board.Layer board_layer = p_board.layer_structure.arr[layer_no]; int wire_width = (int) Math.round(p_coordinate_transform.board_to_dsn(2 * p_wire.get_half_width())); p_file.start_scope(); p_file.write("wire"); @@ -425,7 +425,7 @@ private static void write_wire(PolylineTrace p_wire, BasicBoard p_board, Identif private static void write_via(Via p_via, BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException { - library.Padstack via_padstack = p_via.get_padstack(); + net.freerouting.library.Padstack via_padstack = p_via.get_padstack(); FloatPoint via_location = p_via.get_center().to_float(); p_file.start_scope(); p_file.write("via "); @@ -441,15 +441,15 @@ private static void write_via(Via p_via, BasicBoard p_board, IdentifierType p_id p_file.end_scope(); } - static private void write_fixed_state(IndentFileWriter p_file, board.FixedState p_fixed_state) throws java.io.IOException + static private void write_fixed_state(IndentFileWriter p_file, net.freerouting.board.FixedState p_fixed_state) throws java.io.IOException { - if (p_fixed_state.ordinal() <= board.FixedState.SHOVE_FIXED.ordinal()) + if (p_fixed_state.ordinal() <= net.freerouting.board.FixedState.SHOVE_FIXED.ordinal()) { return; } p_file.new_line(); p_file.write("(type "); - if (p_fixed_state == board.FixedState.SYSTEM_FIXED) + if (p_fixed_state == net.freerouting.board.FixedState.SYSTEM_FIXED) { p_file.write("fix)"); } @@ -489,16 +489,16 @@ private static void write_conduction_area( ConductionArea p_conduction_area, Bas System.out.println("SessionFile.write_conduction_area: unexpected net count"); return; } - geometry.planar.Area curr_area = p_conduction_area.get_area(); + net.freerouting.geometry.planar.Area curr_area = p_conduction_area.get_area(); int layer_no = p_conduction_area.get_layer(); - board.Layer board_layer = p_board.layer_structure.arr[ layer_no]; + net.freerouting.board.Layer board_layer = p_board.layer_structure.arr[ layer_no]; Layer conduction_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal); - geometry.planar.Shape boundary_shape; - geometry.planar.Shape [] holes; - if (curr_area instanceof geometry.planar.Shape) + net.freerouting.geometry.planar.Shape boundary_shape; + net.freerouting.geometry.planar.Shape [] holes; + if (curr_area instanceof net.freerouting.geometry.planar.Shape) { - boundary_shape = (geometry.planar.Shape) curr_area; - holes = new geometry.planar.Shape [0]; + boundary_shape = (net.freerouting.geometry.planar.Shape) curr_area; + holes = new net.freerouting.geometry.planar.Shape [0]; } else { diff --git a/designformats/specctra/SessionToEagle.java b/src/main/java/net/freerouting/designformats/specctra/SessionToEagle.java similarity index 94% rename from designformats/specctra/SessionToEagle.java rename to src/main/java/net/freerouting/designformats/specctra/SessionToEagle.java index d1180ad3..9f9a4bb7 100644 --- a/designformats/specctra/SessionToEagle.java +++ b/src/main/java/net/freerouting/designformats/specctra/SessionToEagle.java @@ -18,7 +18,7 @@ * Created on 8. Dezember 2004, 07:42 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; /** @@ -30,7 +30,7 @@ public class SessionToEagle extends javax.swing.JFrame { public static boolean get_instance(java.io.InputStream p_session, java.io.OutputStream p_output_stream, - board.BasicBoard p_board) + net.freerouting.board.BasicBoard p_board) { if (p_output_stream == null) { @@ -73,8 +73,8 @@ public static boolean get_instance(java.io.InputStream p_session, java.io.Output return result; } - SessionToEagle(Scanner p_scanner, java.io.OutputStreamWriter p_out_file, board.BasicBoard p_board, - board.Unit p_unit, double p_session_file_scale_dominator, double p_board_scale_factor) + SessionToEagle(Scanner p_scanner, java.io.OutputStreamWriter p_out_file, net.freerouting.board.BasicBoard p_board, + net.freerouting.board.Unit p_unit, double p_session_file_scale_dominator, double p_board_scale_factor) { scanner = p_scanner; out_file = p_out_file; @@ -139,7 +139,7 @@ else if (i == 1) // Generate Code to remove the complete route. // Write a bounding rectangle with GROUP (Min_X-1 Min_Y-1) (Max_X+1 Max_Y+1); - geometry.planar.IntBox board_bounding_box = this.board.get_bounding_box(); + net.freerouting.geometry.planar.IntBox board_bounding_box = this.board.get_bounding_box(); Float min_x = (float) this.board_scale_factor * (board_bounding_box.ll.x - 1); Float min_y = (float) this.board_scale_factor * (board_bounding_box.ll.y - 1); @@ -533,7 +533,7 @@ else if (next_token instanceof Integer) return false; } - library.Padstack via_padstack = this.board.library.padstacks.get(padstack_name); + net.freerouting.library.Padstack via_padstack = this.board.library.padstacks.get(padstack_name); if (via_padstack == null) { @@ -541,7 +541,7 @@ else if (next_token instanceof Integer) return false; } - geometry.planar.ConvexShape via_shape = via_padstack.get_shape(via_padstack.from_layer()); + net.freerouting.geometry.planar.ConvexShape via_shape = via_padstack.get_shape(via_padstack.from_layer()); Double via_diameter = via_shape.max_width() * this.board_scale_factor; @@ -575,11 +575,11 @@ else if (next_token instanceof Integer) this.out_file.write(via_diameter.toString()); //Shape lesen und einsetzen Square / Round / Octagon - if (via_shape instanceof geometry.planar.Circle) + if (via_shape instanceof net.freerouting.geometry.planar.Circle) { this.out_file.write(" round "); } - else if (via_shape instanceof geometry.planar.IntOctagon) + else if (via_shape instanceof net.freerouting.geometry.planar.IntOctagon) { this.out_file.write(" octagon "); } @@ -625,9 +625,9 @@ private boolean process_swapped_pins() throws java.io.IOException private boolean process_swapped_pins(int p_component_no) throws java.io.IOException { - java.util.Collection component_pins = this.board.get_component_pins(p_component_no); + java.util.Collection component_pins = this.board.get_component_pins(p_component_no); boolean component_has_swapped_pins = false; - for (board.Pin curr_pin : component_pins) + for (net.freerouting.board.Pin curr_pin : component_pins) { if (curr_pin.get_changed_to() != curr_pin) { @@ -641,7 +641,7 @@ private boolean process_swapped_pins(int p_component_no) throws java.io.IOExcept } PinInfo[] pin_info_arr = new PinInfo[component_pins.size()]; int i = 0; - for (board.Pin curr_pin : component_pins) + for (net.freerouting.board.Pin curr_pin : component_pins) { pin_info_arr[i] = new PinInfo(curr_pin); ++i; @@ -672,7 +672,7 @@ private boolean process_swapped_pins(int p_component_no) throws java.io.IOExcept return true; } - private void write_pin_swap( board.Pin p_pin_1, board.Pin p_pin_2) throws java.io.IOException + private void write_pin_swap( net.freerouting.board.Pin p_pin_1, net.freerouting.board.Pin p_pin_2) throws java.io.IOException { int layer_no = Math.max(p_pin_1.first_layer(), p_pin_2.first_layer()); String layer_name = board.layer_structure.arr[layer_no].name; @@ -711,12 +711,12 @@ private void write_pin_swap( board.Pin p_pin_1, board.Pin p_pin_2) throws java.i private final java.io.OutputStreamWriter out_file; /** Some information is read from the board, because it is not contained in the speccctra session file. */ - private final board.BasicBoard board; + private final net.freerouting.board.BasicBoard board; /** The layer structure in specctra format */ private final LayerStructure specctra_layer_structure; - private final board.Unit unit; + private final net.freerouting.board.Unit unit; /** The scale factor for transforming coordinates from the session file to Eagle */ private final double session_file_scale_denominator; @@ -726,13 +726,13 @@ private void write_pin_swap( board.Pin p_pin_1, board.Pin p_pin_2) throws java.i private static class PinInfo { - PinInfo(board.Pin p_pin) + PinInfo(net.freerouting.board.Pin p_pin) { pin = p_pin; curr_changed_to = p_pin; } - final board.Pin pin; - board.Pin curr_changed_to; + final net.freerouting.board.Pin pin; + net.freerouting.board.Pin curr_changed_to; } } diff --git a/designformats/specctra/Shape.java b/src/main/java/net/freerouting/designformats/specctra/Shape.java similarity index 94% rename from designformats/specctra/Shape.java rename to src/main/java/net/freerouting/designformats/specctra/Shape.java index e1da944b..12b04be0 100644 --- a/designformats/specctra/Shape.java +++ b/src/main/java/net/freerouting/designformats/specctra/Shape.java @@ -17,15 +17,15 @@ * * Created on 16. Mai 2004, 11:09 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import geometry.planar.PolylineShape; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.geometry.planar.PolylineShape; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** * Describes a shape in a Specctra dsn file. @@ -695,7 +695,7 @@ else if (next_object instanceof Integer) * The first shape in the Collection p_area is the border, * the other shapes are holes of the area. */ - public static geometry.planar.Area transform_area_to_board(Collection p_area, CoordinateTransform p_coordinate_transform) + public static net.freerouting.geometry.planar.Area transform_area_to_board(Collection p_area, CoordinateTransform p_coordinate_transform) { int hole_count = p_area.size() - 1; if (hole_count <= -1) @@ -705,8 +705,8 @@ public static geometry.planar.Area transform_area_to_board(Collection p_a } Iterator it = p_area.iterator(); Shape boundary = it.next(); - geometry.planar.Shape boundary_shape = boundary.transform_to_board(p_coordinate_transform); - geometry.planar.Area result; + net.freerouting.geometry.planar.Shape boundary_shape = boundary.transform_to_board(p_coordinate_transform); + net.freerouting.geometry.planar.Area result; if (hole_count == 0) { result = boundary_shape; @@ -714,7 +714,7 @@ public static geometry.planar.Area transform_area_to_board(Collection p_a else { // Area with holes - if (!(boundary_shape instanceof geometry.planar.PolylineShape)) + if (!(boundary_shape instanceof net.freerouting.geometry.planar.PolylineShape)) { System.out.println("Shape.transform_area_to_board: PolylineShape expected"); return null; @@ -723,7 +723,7 @@ public static geometry.planar.Area transform_area_to_board(Collection p_a PolylineShape[] holes = new PolylineShape[hole_count]; for (int i = 0; i < holes.length; ++i) { - geometry.planar.Shape hole_shape = it.next().transform_to_board(p_coordinate_transform); + net.freerouting.geometry.planar.Shape hole_shape = it.next().transform_to_board(p_coordinate_transform); if (!(hole_shape instanceof PolylineShape)) { System.out.println("Shape.transform_area_to_board: PolylineShape expected"); @@ -731,7 +731,7 @@ public static geometry.planar.Area transform_area_to_board(Collection p_a } holes[i] = (PolylineShape) hole_shape; } - result = new geometry.planar.PolylineArea(border, holes); + result = new net.freerouting.geometry.planar.PolylineArea(border, holes); } return result; } @@ -741,7 +741,7 @@ public static geometry.planar.Area transform_area_to_board(Collection p_a * The first shape in the Collection p_area is the border, * the other shapes are holes of the area. */ - public static geometry.planar.Area transform_area_to_board_rel(Collection p_area, CoordinateTransform p_coordinate_transform) + public static net.freerouting.geometry.planar.Area transform_area_to_board_rel(Collection p_area, CoordinateTransform p_coordinate_transform) { int hole_count = p_area.size() - 1; if (hole_count <= -1) @@ -751,8 +751,8 @@ public static geometry.planar.Area transform_area_to_board_rel(Collection } Iterator it = p_area.iterator(); Shape boundary = it.next(); - geometry.planar.Shape boundary_shape = boundary.transform_to_board_rel(p_coordinate_transform); - geometry.planar.Area result; + net.freerouting.geometry.planar.Shape boundary_shape = boundary.transform_to_board_rel(p_coordinate_transform); + net.freerouting.geometry.planar.Area result; if (hole_count == 0) { result = boundary_shape; @@ -760,7 +760,7 @@ public static geometry.planar.Area transform_area_to_board_rel(Collection else { // Area with holes - if (!(boundary_shape instanceof geometry.planar.PolylineShape)) + if (!(boundary_shape instanceof net.freerouting.geometry.planar.PolylineShape)) { System.out.println("Shape.transform_area_to_board_rel: PolylineShape expected"); return null; @@ -769,7 +769,7 @@ public static geometry.planar.Area transform_area_to_board_rel(Collection PolylineShape[] holes = new PolylineShape[hole_count]; for (int i = 0; i < holes.length; ++i) { - geometry.planar.Shape hole_shape = it.next().transform_to_board_rel(p_coordinate_transform); + net.freerouting.geometry.planar.Shape hole_shape = it.next().transform_to_board_rel(p_coordinate_transform); if (!(hole_shape instanceof PolylineShape)) { System.out.println("Shape.transform_area_to_board: PolylineShape expected"); @@ -777,7 +777,7 @@ public static geometry.planar.Area transform_area_to_board_rel(Collection } holes[i] = (PolylineShape) hole_shape; } - result = new geometry.planar.PolylineArea(border, holes); + result = new net.freerouting.geometry.planar.PolylineArea(border, holes); } return result; } @@ -793,7 +793,7 @@ public void write_hole_scope(IndentFileWriter p_file, IdentifierType p_identifie /** * Transforms a specctra dsn shape to a geometry.planar.Shape. */ - public abstract geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform); + public abstract net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform); /** * Returns the smallest axis parallel rectangle containing this shape. @@ -803,7 +803,7 @@ public void write_hole_scope(IndentFileWriter p_file, IdentifierType p_identifie /** * Transforms the relative (vector) coordinates of a specctra dsn shape to a geometry.planar.Shape. */ - public abstract geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform); + public abstract net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform); protected Shape(Layer p_layer) { diff --git a/designformats/specctra/SpecctraFileDescription.flex b/src/main/java/net/freerouting/designformats/specctra/SpecctraFileDescription.flex similarity index 100% rename from designformats/specctra/SpecctraFileDescription.flex rename to src/main/java/net/freerouting/designformats/specctra/SpecctraFileDescription.flex diff --git a/designformats/specctra/SpecctraFileScanner.java b/src/main/java/net/freerouting/designformats/specctra/SpecctraFileScanner.java similarity index 99% rename from designformats/specctra/SpecctraFileScanner.java rename to src/main/java/net/freerouting/designformats/specctra/SpecctraFileScanner.java index 32df1f06..455b5c00 100644 --- a/designformats/specctra/SpecctraFileScanner.java +++ b/src/main/java/net/freerouting/designformats/specctra/SpecctraFileScanner.java @@ -1,6 +1,6 @@ /* The following code was generated by JFlex 1.4.1 on 16.10.08 09:27 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; @SuppressWarnings("all") /** diff --git a/designformats/specctra/SpecctraFileScanner.java~ b/src/main/java/net/freerouting/designformats/specctra/SpecctraFileScanner.java~ similarity index 100% rename from designformats/specctra/SpecctraFileScanner.java~ rename to src/main/java/net/freerouting/designformats/specctra/SpecctraFileScanner.java~ diff --git a/designformats/specctra/Structure.java b/src/main/java/net/freerouting/designformats/specctra/Structure.java similarity index 89% rename from designformats/specctra/Structure.java rename to src/main/java/net/freerouting/designformats/specctra/Structure.java index 24d2382e..2beb65f6 100644 --- a/designformats/specctra/Structure.java +++ b/src/main/java/net/freerouting/designformats/specctra/Structure.java @@ -17,28 +17,28 @@ * * Created on 13. Mai 2004, 09:57 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import geometry.planar.IntBox; -import geometry.planar.PolylineShape; -import geometry.planar.TileShape; -import geometry.planar.Point; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.PolylineShape; +import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Point; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import datastructures.UndoableObjects; +import net.freerouting.datastructures.UndoableObjects; -import rules.BoardRules; -import rules.DefaultItemClearanceClasses.ItemClass; +import net.freerouting.rules.BoardRules; +import net.freerouting.rules.DefaultItemClearanceClasses.ItemClass; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; -import datastructures.UndoableObjects.Storable; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.UndoableObjects.Storable; -import board.FixedState; -import board.TestLevel; +import net.freerouting.board.FixedState; +import net.freerouting.board.TestLevel; /** * Class for reading and writing structure scopes from dsn-files. @@ -166,7 +166,7 @@ else if (next_token == Keyword.FLIP_STYLE) else if (next_token == Keyword.SNAP_ANGLE) { - board.AngleRestriction snap_angle = read_snap_angle(p_par.scanner); + net.freerouting.board.AngleRestriction snap_angle = read_snap_angle(p_par.scanner); if (snap_angle != null) { p_par.snap_angle = snap_angle; @@ -188,7 +188,7 @@ else if (next_token == Keyword.SNAP_ANGLE) { result = create_board(p_par, board_construction_info); } - board.RoutingBoard board = p_par.board_handling.get_routing_board(); + net.freerouting.board.RoutingBoard board = p_par.board_handling.get_routing_board(); if (board == null) { return false; @@ -245,13 +245,13 @@ else if (next_token == Keyword.SNAP_ANGLE) board.rules.nets.add(new_net.id.name, new_net.id.subnet_number, true); } } - rules.Net curr_net = board.rules.nets.get(plane_info.net_name, 1); + net.freerouting.rules.Net curr_net = board.rules.nets.get(plane_info.net_name, 1); if (curr_net == null) { System.out.println("Plane.read_scope: net not found"); continue; } - geometry.planar.Area plane_area = + net.freerouting.geometry.planar.Area plane_area = Shape.transform_area_to_board(plane_info.area.shape_list, p_par.coordinate_transform); Layer curr_layer = (plane_info.area.shape_list.iterator().next()).layer; if (curr_layer.no >= 0) @@ -268,7 +268,7 @@ else if (next_token == Keyword.SNAP_ANGLE) } else { - clearance_class_no = curr_net.get_class().default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.AREA); + clearance_class_no = curr_net.get_class().default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.AREA); } int[] net_numbers = new int[1]; net_numbers[0] = curr_net.net_number; @@ -313,7 +313,7 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep { break; } - if (curr_ob instanceof board.BoardOutline) + if (curr_ob instanceof net.freerouting.board.BoardOutline) { break; } @@ -323,7 +323,7 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep System.out.println("Structure.write_scope; outline not found"); return; } - board.BoardOutline outline = (board.BoardOutline) curr_ob; + net.freerouting.board.BoardOutline outline = (net.freerouting.board.BoardOutline) curr_ob; // write the outline for (int i = 0; i < outline.shape_count(); ++i) @@ -358,17 +358,17 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep { break; } - if (!(curr_ob instanceof board.ObstacleArea)) + if (!(curr_ob instanceof net.freerouting.board.ObstacleArea)) { continue; } - board.ObstacleArea curr_keepout = (board.ObstacleArea) curr_ob; + net.freerouting.board.ObstacleArea curr_keepout = (net.freerouting.board.ObstacleArea) curr_ob; if (curr_keepout.get_component_no() != 0) { // keepouts belonging to a component are not written individually. continue; } - if (curr_keepout instanceof board.ConductionArea) + if (curr_keepout instanceof net.freerouting.board.ConductionArea) { // conduction area will be written later. continue; @@ -385,17 +385,17 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep { break; } - if (!(curr_ob instanceof board.ConductionArea)) + if (!(curr_ob instanceof net.freerouting.board.ConductionArea)) { continue; } - board.ConductionArea curr_area = (board.ConductionArea) curr_ob; + net.freerouting.board.ConductionArea curr_area = (net.freerouting.board.ConductionArea) curr_ob; if (p_par.board.layer_structure.arr[curr_area.get_layer()].is_signal) { // These conduction areas are written in the wiring scope. continue; } - Plane.write_scope(p_par, (board.ConductionArea) curr_ob); + Plane.write_scope(p_par, (net.freerouting.board.ConductionArea) curr_ob); } p_par.file.end_scope(); } @@ -414,14 +414,14 @@ static void write_default_rules(WriteScopeParameter p_par) throws java.io.IOExce } } - private static void write_via_padstacks(library.BoardLibrary p_library, IndentFileWriter p_file, + private static void write_via_padstacks(net.freerouting.library.BoardLibrary p_library, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.new_line(); p_file.write("(via"); for (int i = 0; i < p_library.via_padstack_count(); ++i) { - library.Padstack curr_padstack = p_library.get_via_padstack(i); + net.freerouting.library.Padstack curr_padstack = p_library.get_via_padstack(i); if (curr_padstack != null) { p_file.write(" "); @@ -435,7 +435,7 @@ private static void write_via_padstacks(library.BoardLibrary p_library, IndentFi p_file.write(")"); } - private static void write_control_scope(rules.BoardRules p_rules, IndentFileWriter p_file) throws java.io.IOException + private static void write_control_scope(net.freerouting.rules.BoardRules p_rules, IndentFileWriter p_file) throws java.io.IOException { p_file.start_scope(); p_file.write("control"); @@ -461,18 +461,18 @@ private static void write_control_scope(rules.BoardRules p_rules, IndentFileWrit p_file.end_scope(); } - private static void write_keepout_scope(WriteScopeParameter p_par, board.ObstacleArea p_keepout) throws java.io.IOException + private static void write_keepout_scope(WriteScopeParameter p_par, net.freerouting.board.ObstacleArea p_keepout) throws java.io.IOException { - geometry.planar.Area keepout_area = p_keepout.get_area(); + net.freerouting.geometry.planar.Area keepout_area = p_keepout.get_area(); int layer_no = p_keepout.get_layer(); - board.Layer board_layer = p_par.board.layer_structure.arr[layer_no]; + net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[layer_no]; Layer keepout_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal); - geometry.planar.Shape boundary_shape; - geometry.planar.Shape[] holes; - if (keepout_area instanceof geometry.planar.Shape) + net.freerouting.geometry.planar.Shape boundary_shape; + net.freerouting.geometry.planar.Shape[] holes; + if (keepout_area instanceof net.freerouting.geometry.planar.Shape) { - boundary_shape = (geometry.planar.Shape) keepout_area; - holes = new geometry.planar.Shape[0]; + boundary_shape = (net.freerouting.geometry.planar.Shape) keepout_area; + holes = new net.freerouting.geometry.planar.Shape[0]; } else { @@ -480,7 +480,7 @@ private static void write_keepout_scope(WriteScopeParameter p_par, board.Obstacl holes = keepout_area.get_holes(); } p_par.file.start_scope(); - if (p_keepout instanceof board.ViaObstacleArea) + if (p_keepout instanceof net.freerouting.board.ViaObstacleArea) { p_par.file.write("via_keepout"); } @@ -743,23 +743,23 @@ private static boolean read_control_scope(ReadScopeParameter p_par) return true; } - static board.AngleRestriction read_snap_angle(Scanner p_scanner) + static net.freerouting.board.AngleRestriction read_snap_angle(Scanner p_scanner) { try { Object next_token = p_scanner.next_token(); - board.AngleRestriction snap_angle; + net.freerouting.board.AngleRestriction snap_angle; if (next_token == Keyword.NINETY_DEGREE) { - snap_angle = board.AngleRestriction.NINETY_DEGREE; + snap_angle = net.freerouting.board.AngleRestriction.NINETY_DEGREE; } else if (next_token == Keyword.FORTYFIVE_DEGREE) { - snap_angle = board.AngleRestriction.FORTYFIVE_DEGREE; + snap_angle = net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE; } else if (next_token == Keyword.NONE) { - snap_angle = board.AngleRestriction.NONE; + snap_angle = net.freerouting.board.AngleRestriction.NONE; } else { @@ -781,17 +781,17 @@ else if (next_token == Keyword.NONE) } } - static void write_snap_angle(IndentFileWriter p_file, board.AngleRestriction p_angle_restriction) throws java.io.IOException + static void write_snap_angle(IndentFileWriter p_file, net.freerouting.board.AngleRestriction p_angle_restriction) throws java.io.IOException { p_file.start_scope(); p_file.write("snap_angle "); p_file.new_line(); - if (p_angle_restriction == board.AngleRestriction.NINETY_DEGREE) + if (p_angle_restriction == net.freerouting.board.AngleRestriction.NINETY_DEGREE) { p_file.write("ninety_degree"); } - else if (p_angle_restriction == board.AngleRestriction.FORTYFIVE_DEGREE) + else if (p_angle_restriction == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE) { p_file.write("fortyfive_degree"); } @@ -829,7 +829,7 @@ private boolean create_board(ReadScopeParameter p_par, BoardConstructionInfo p_b p_board_construction_info.bounding_shape = bounding_box; } Rectangle bounding_box = p_board_construction_info.bounding_shape.bounding_box(); - board.Layer[] board_layer_arr = new board.Layer[layer_count]; + net.freerouting.board.Layer[] board_layer_arr = new net.freerouting.board.Layer[layer_count]; Iterator it = p_board_construction_info.layer_info.iterator(); for (int i = 0; i < layer_count; ++i) { @@ -839,9 +839,9 @@ private boolean create_board(ReadScopeParameter p_par, BoardConstructionInfo p_b System.out.println("Structure.create_board: illegal layer number"); return false; } - board_layer_arr[i] = new board.Layer(curr_layer.name, curr_layer.is_signal); + board_layer_arr[i] = new net.freerouting.board.Layer(curr_layer.name, curr_layer.is_signal); } - board.LayerStructure board_layer_structure = new board.LayerStructure(board_layer_arr); + net.freerouting.board.LayerStructure board_layer_structure = new net.freerouting.board.LayerStructure(board_layer_arr); p_par.layer_structure = new LayerStructure(p_board_construction_info.layer_info); // Calculate an appropritate scaling between dsn coordinates and board coordinates. @@ -858,7 +858,7 @@ private boolean create_board(ReadScopeParameter p_par, BoardConstructionInfo p_b return false; } // make scalefactor smaller, if there is a danger of integer overflow. - while (5 * max_coor >= geometry.planar.Limits.CRIT_INT) + while (5 * max_coor >= net.freerouting.geometry.planar.Limits.CRIT_INT) { scale_factor /= 10; max_coor /= 10; @@ -895,13 +895,13 @@ private boolean create_board(ReadScopeParameter p_par, BoardConstructionInfo p_b board_outline_shapes.add(curr_board_shape); } Collection hole_shapes = separate_holes(board_outline_shapes); - rules.ClearanceMatrix clearance_matrix = rules.ClearanceMatrix.get_default_instance(board_layer_structure, 0); - rules.BoardRules board_rules = new rules.BoardRules(board_layer_structure, clearance_matrix); - board.Communication.SpecctraParserInfo specctra_parser_info = - new board.Communication.SpecctraParserInfo(p_par.string_quote, p_par.host_cad, + net.freerouting.rules.ClearanceMatrix clearance_matrix = net.freerouting.rules.ClearanceMatrix.get_default_instance(board_layer_structure, 0); + net.freerouting.rules.BoardRules board_rules = new net.freerouting.rules.BoardRules(board_layer_structure, clearance_matrix); + net.freerouting.board.Communication.SpecctraParserInfo specctra_parser_info = + new net.freerouting.board.Communication.SpecctraParserInfo(p_par.string_quote, p_par.host_cad, p_par.host_version, p_par.constants, p_par.write_resolution, p_par.dsn_file_generated_by_host); - board.Communication board_communication = - new board.Communication(p_par.unit, p_par.resolution, specctra_parser_info, + net.freerouting.board.Communication board_communication = + new net.freerouting.board.Communication(p_par.unit, p_par.resolution, specctra_parser_info, p_par.coordinate_transform, p_par.item_id_no_generator, p_par.observers); PolylineShape[] outline_shape_arr = new PolylineShape[board_outline_shapes.size()]; @@ -916,7 +916,7 @@ private boolean create_board(ReadScopeParameter p_par, BoardConstructionInfo p_b p_board_construction_info.outline_clearance_class_name, board_rules, board_communication, p_par.test_level); - board.BasicBoard board = p_par.board_handling.get_routing_board(); + net.freerouting.board.BasicBoard board = p_par.board_handling.get_routing_board(); // Insert the holes in the board outline as keepouts. for (PolylineShape curr_outline_hole : hole_shapes) @@ -933,9 +933,9 @@ private boolean create_board(ReadScopeParameter p_par, BoardConstructionInfo p_b // and insert evtl. a conduction area private static void insert_missing_power_planes(Collection p_layer_info, - NetList p_netlist, board.BasicBoard p_board) + NetList p_netlist, net.freerouting.board.BasicBoard p_board) { - Collection conduction_areas = p_board.get_conduction_areas(); + Collection conduction_areas = p_board.get_conduction_areas(); for (Layer curr_layer : p_layer_info) { if (curr_layer.is_signal) @@ -943,7 +943,7 @@ private static void insert_missing_power_planes(Collection p_layer_info, continue; } boolean conduction_area_found = false; - for (board.ConductionArea curr_conduction_area : conduction_areas) + for (net.freerouting.board.ConductionArea curr_conduction_area : conduction_areas) { if (curr_conduction_area.get_layer() == curr_layer.no) { @@ -963,7 +963,7 @@ private static void insert_missing_power_planes(Collection p_layer_info, p_board.rules.nets.add(new_net.id.name, new_net.id.subnet_number, true); } } - rules.Net curr_net = p_board.rules.nets.get(curr_net_id.name, curr_net_id.subnet_number); + net.freerouting.rules.Net curr_net = p_board.rules.nets.get(curr_net_id.name, curr_net_id.subnet_number); { if (curr_net == null) { @@ -1224,7 +1224,7 @@ static private int append_clearance_class(BoardRules p_board_rules, String p_nam { p_board_rules.clearance_matrix.append_class(p_name); int result = p_board_rules.clearance_matrix.get_no(p_name); - rules.NetClass default_net_class = p_board_rules.get_default_net_class(); + net.freerouting.rules.NetClass default_net_class = p_board_rules.get_default_net_class(); if (p_name.equals("via")) { default_net_class.default_item_clearance_classes.set(ItemClass.VIA, result); @@ -1247,7 +1247,7 @@ else if (p_name.equals("area")) /** * Returns true, if all clearance values on the 2 input layers are equal. */ - private static boolean clearance_equals(rules.ClearanceMatrix p_cl_matrix, int p_layer_1, int p_layer_2) + private static boolean clearance_equals(net.freerouting.rules.ClearanceMatrix p_cl_matrix, int p_layer_1, int p_layer_2) { if (p_layer_1 == p_layer_2) { @@ -1268,14 +1268,14 @@ private static boolean clearance_equals(rules.ClearanceMatrix p_cl_matrix, int p private static boolean insert_keepout(Shape.ReadAreaScopeResult p_area, ReadScopeParameter p_par, KeepoutType p_keepout_type, FixedState p_fixed_state) { - geometry.planar.Area keepout_area = + net.freerouting.geometry.planar.Area keepout_area = Shape.transform_area_to_board(p_area.shape_list, p_par.coordinate_transform); if (keepout_area.dimension() < 2) { System.out.println("Structure.insert_keepout: keepout is not an area"); return true; } - board.BasicBoard board = p_par.board_handling.get_routing_board(); + net.freerouting.board.BasicBoard board = p_par.board_handling.get_routing_board(); if (board == null) { System.out.println("Structure.insert_keepout: board not initialized"); @@ -1305,14 +1305,14 @@ else if (curr_layer.no >= 0) return true; } - private static void insert_keepout(board.BasicBoard p_board, geometry.planar.Area p_area, int p_layer, + private static void insert_keepout(net.freerouting.board.BasicBoard p_board, net.freerouting.geometry.planar.Area p_area, int p_layer, String p_clearance_class_name, KeepoutType p_keepout_type, FixedState p_fixed_state) { int clearance_class_no; if (p_clearance_class_name == null) { clearance_class_no = - p_board.rules.get_default_net_class().default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.AREA); + p_board.rules.get_default_net_class().default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.AREA); } else { diff --git a/designformats/specctra/Wiring.java b/src/main/java/net/freerouting/designformats/specctra/Wiring.java similarity index 85% rename from designformats/specctra/Wiring.java rename to src/main/java/net/freerouting/designformats/specctra/Wiring.java index a4c65193..dede6bb4 100644 --- a/designformats/specctra/Wiring.java +++ b/src/main/java/net/freerouting/designformats/specctra/Wiring.java @@ -18,31 +18,31 @@ * Created on 24. Mai 2004, 07:20 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; import java.util.Collection; import java.util.LinkedList; import java.util.Iterator; -import datastructures.UndoableObjects; +import net.freerouting.datastructures.UndoableObjects; -import geometry.planar.FloatPoint; -import geometry.planar.Point; -import geometry.planar.IntBox; -import geometry.planar.IntPoint; -import geometry.planar.Line; -import geometry.planar.Polyline; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Polyline; -import board.RoutingBoard; -import board.Item; -import board.Via; -import board.Trace; -import board.PolylineTrace; -import board.FixedState; -import board.ItemSelectionFilter; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.Item; +import net.freerouting.board.Via; +import net.freerouting.board.Trace; +import net.freerouting.board.PolylineTrace; +import net.freerouting.board.FixedState; +import net.freerouting.board.ItemSelectionFilter; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** * Class for reading and writing wiring scopes from dsn-files. @@ -137,28 +137,28 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep { break; } - if (!(curr_ob instanceof board.ConductionArea)) + if (!(curr_ob instanceof net.freerouting.board.ConductionArea)) { continue; } - board.ConductionArea curr_area = (board.ConductionArea) curr_ob; + net.freerouting.board.ConductionArea curr_area = (net.freerouting.board.ConductionArea) curr_ob; if (!(p_par.board.layer_structure.arr [curr_area.get_layer()].is_signal)) { // This conduction areas arw written in the structure scope. continue; } - write_conduction_area_scope(p_par, (board.ConductionArea) curr_ob); + write_conduction_area_scope(p_par, (net.freerouting.board.ConductionArea) curr_ob); } p_par.file.end_scope(); } private static void write_via_scope(WriteScopeParameter p_par, Via p_via) throws java.io.IOException { - library.Padstack via_padstack = p_via.get_padstack(); + net.freerouting.library.Padstack via_padstack = p_via.get_padstack(); FloatPoint via_location = p_via.get_center().to_float(); double [] via_coor = p_par.coordinate_transform.board_to_dsn(via_location); int net_no; - rules.Net via_net; + net.freerouting.rules.Net via_net; if (p_via.net_count() > 0) { net_no = p_via.get_net_no(0); @@ -196,10 +196,10 @@ private static void write_wire_scope(WriteScopeParameter p_par, Trace p_wire) th } PolylineTrace curr_wire = (PolylineTrace) p_wire; int layer_no = curr_wire.get_layer(); - board.Layer board_layer = p_par.board.layer_structure.arr[layer_no]; + net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[layer_no]; Layer curr_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal); double wire_width = p_par.coordinate_transform.board_to_dsn(2 * curr_wire.get_half_width()); - rules.Net wire_net = null; + net.freerouting.rules.Net wire_net = null; if (curr_wire.net_count() > 0) { wire_net = p_par.board.rules.nets.get(curr_wire.get_net_no(0)); @@ -237,7 +237,7 @@ private static void write_wire_scope(WriteScopeParameter p_par, Trace p_wire) th p_par.file.end_scope(); } - private static void write_conduction_area_scope(WriteScopeParameter p_par, board.ConductionArea p_conduction_area) throws java.io.IOException + private static void write_conduction_area_scope(WriteScopeParameter p_par, net.freerouting.board.ConductionArea p_conduction_area) throws java.io.IOException { int net_count = p_conduction_area.net_count(); if (net_count <= 0 || net_count > 1) @@ -245,17 +245,17 @@ private static void write_conduction_area_scope(WriteScopeParameter p_par, board System.out.println("Plane.write_scope: unexpected net count"); return; } - rules.Net curr_net = p_par.board.rules.nets.get(p_conduction_area.get_net_no(0)); - geometry.planar.Area curr_area = p_conduction_area.get_area(); + net.freerouting.rules.Net curr_net = p_par.board.rules.nets.get(p_conduction_area.get_net_no(0)); + net.freerouting.geometry.planar.Area curr_area = p_conduction_area.get_area(); int layer_no = p_conduction_area.get_layer(); - board.Layer board_layer = p_par.board.layer_structure.arr[ layer_no]; + net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[ layer_no]; Layer conduction_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal); - geometry.planar.Shape boundary_shape; - geometry.planar.Shape [] holes; - if (curr_area instanceof geometry.planar.Shape) + net.freerouting.geometry.planar.Shape boundary_shape; + net.freerouting.geometry.planar.Shape [] holes; + if (curr_area instanceof net.freerouting.geometry.planar.Shape) { - boundary_shape = (geometry.planar.Shape) curr_area; - holes = new geometry.planar.Shape [0]; + boundary_shape = (net.freerouting.geometry.planar.Shape) curr_area; + holes = new net.freerouting.geometry.planar.Shape [0]; } else { @@ -280,7 +280,7 @@ private static void write_conduction_area_scope(WriteScopeParameter p_par, board p_par.file.end_scope(); } - static private void write_net(rules.Net p_net, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException + static private void write_net(net.freerouting.rules.Net p_net, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.new_line(); p_file.write("("); @@ -314,7 +314,7 @@ private Item read_wire_scope(ReadScopeParameter p_par) { Net.Id net_id = null; String clearance_class_name = null; - board.FixedState fixed = board.FixedState.UNFIXED; + net.freerouting.board.FixedState fixed = net.freerouting.board.FixedState.UNFIXED; Path path = null; // Used, if a trace is read. Shape border_shape = null; // Used, if a conduction area is read. Collection hole_list = new LinkedList(); @@ -411,11 +411,11 @@ else if (next_token == Keyword.TYPE) } RoutingBoard board = p_par.board_handling.get_routing_board(); - rules.NetClass net_class = board.rules.get_default_net_class(); - Collection found_nets = get_subnets(net_id, board.rules); + net.freerouting.rules.NetClass net_class = board.rules.get_default_net_class(); + Collection found_nets = get_subnets(net_id, board.rules); int[] net_no_arr = new int[found_nets.size()]; int curr_index = 0; - for (rules.Net curr_net : found_nets) + for (net.freerouting.rules.Net curr_net : found_nets) { net_no_arr[curr_index] = curr_net.net_number; net_class = curr_net.get_class(); @@ -460,12 +460,12 @@ else if (next_token == Keyword.TYPE) if (clearance_class_no < 0) { clearance_class_no = - net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.AREA); + net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.AREA); } Collection area = new LinkedList(); area.add(border_shape); area.addAll(hole_list); - geometry.planar.Area conduction_area = + net.freerouting.geometry.planar.Area conduction_area = Shape.transform_area_to_board(area, p_par.coordinate_transform); result = board.insert_conduction_area(conduction_area, layer_no, net_no_arr, clearance_class_no, false, fixed); @@ -475,7 +475,7 @@ else if (path instanceof PolygonPath) if (clearance_class_no < 0) { clearance_class_no = - net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.TRACE); + net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.TRACE); } IntPoint [] corner_arr = new IntPoint[path.coordinate_arr.length / 2]; double [] curr_point = new double [2]; @@ -500,7 +500,7 @@ else if (path instanceof PolylinePath) if (clearance_class_no < 0) { clearance_class_no = - net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.TRACE); + net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.TRACE); } Line [] line_arr = new Line[path.coordinate_arr.length / 4]; double [] curr_point = new double [2]; @@ -557,14 +557,14 @@ private void try_correct_net(Item p_item) } } - private static Collection get_subnets(Net.Id p_net_id, rules.BoardRules p_rules) + private static Collection get_subnets(Net.Id p_net_id, net.freerouting.rules.BoardRules p_rules) { - Collection found_nets = new LinkedList(); + Collection found_nets = new LinkedList(); if (p_net_id != null) { if (p_net_id.subnet_number > 0) { - rules.Net found_net = p_rules.nets.get(p_net_id.name, p_net_id.subnet_number); + net.freerouting.rules.Net found_net = p_rules.nets.get(p_net_id.name, p_net_id.subnet_number); if (found_net != null) { found_nets.add(found_net); @@ -582,7 +582,7 @@ private boolean read_via_scope(ReadScopeParameter p_par) { try { - board.FixedState fixed = board.FixedState.UNFIXED; + net.freerouting.board.FixedState fixed = net.freerouting.board.FixedState.UNFIXED; // read the padstack name Object next_token = p_par.scanner.next_token(); if (!(next_token instanceof String)) @@ -647,14 +647,14 @@ else if (next_token == Keyword.TYPE) } } RoutingBoard board = p_par.board_handling.get_routing_board(); - library.Padstack curr_padstack = board.library.padstacks.get(padstack_name); + net.freerouting.library.Padstack curr_padstack = board.library.padstacks.get(padstack_name); if (curr_padstack == null) { System.out.println("Wiring.read_via_scope: via padstack not found"); return false; } - rules.NetClass net_class = board.rules.get_default_net_class(); - Collection found_nets = get_subnets(net_id, board.rules); + net.freerouting.rules.NetClass net_class = board.rules.get_default_net_class(); + Collection found_nets = get_subnets(net_id, board.rules); if (net_id != null && found_nets.isEmpty()) { System.out.print("Wiring.read_via_scope: net with name "); @@ -663,7 +663,7 @@ else if (next_token == Keyword.TYPE) } int[] net_no_arr = new int[found_nets.size()]; int curr_index = 0; - for (rules.Net curr_net : found_nets) + for (net.freerouting.rules.Net curr_net : found_nets) { net_no_arr[curr_index] = curr_net.net_number; net_class = curr_net.get_class(); @@ -675,7 +675,7 @@ else if (next_token == Keyword.TYPE) } if (clearance_class_no < 0) { - clearance_class_no = net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.VIA); + clearance_class_no = net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.VIA); } IntPoint board_location = p_par.coordinate_transform.dsn_to_board(location).round(); if (via_exists(board_location, curr_padstack, net_no_arr, board)) @@ -697,8 +697,8 @@ else if (next_token == Keyword.TYPE) } } - private static boolean via_exists(IntPoint p_location, library.Padstack p_padstack, - int[] p_net_no_arr, board.BasicBoard p_board) + private static boolean via_exists(IntPoint p_location, net.freerouting.library.Padstack p_padstack, + int[] p_net_no_arr, net.freerouting.board.BasicBoard p_board) { ItemSelectionFilter filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.VIAS); int from_layer = p_padstack.from_layer(); @@ -716,36 +716,36 @@ private static boolean via_exists(IntPoint p_location, library.Padstack p_padsta return false; } - static board.FixedState calc_fixed(Scanner p_scanner) + static net.freerouting.board.FixedState calc_fixed(Scanner p_scanner) { try { - board.FixedState result = board.FixedState.UNFIXED; + net.freerouting.board.FixedState result = net.freerouting.board.FixedState.UNFIXED; Object next_token = p_scanner.next_token(); if (next_token == Keyword.SHOVE_FIXED) { - result = board.FixedState.SHOVE_FIXED; + result = net.freerouting.board.FixedState.SHOVE_FIXED; } else if (next_token == Keyword.FIX) { - result = board.FixedState.SYSTEM_FIXED; + result = net.freerouting.board.FixedState.SYSTEM_FIXED; } else if (next_token != Keyword.NORMAL) { - result = board.FixedState.USER_FIXED; + result = net.freerouting.board.FixedState.USER_FIXED; } next_token = p_scanner.next_token(); if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Wiring.is_fixed: ) expected"); - return board.FixedState.UNFIXED; + return net.freerouting.board.FixedState.UNFIXED; } return result; } catch (java.io.IOException e) { System.out.println("Wiring.is_fixed: IO error scanning file"); - return board.FixedState.UNFIXED; + return net.freerouting.board.FixedState.UNFIXED; } } diff --git a/designformats/specctra/WriteScopeParameter.java b/src/main/java/net/freerouting/designformats/specctra/WriteScopeParameter.java similarity index 81% rename from designformats/specctra/WriteScopeParameter.java rename to src/main/java/net/freerouting/designformats/specctra/WriteScopeParameter.java index 2810d08a..5fcd56cc 100644 --- a/designformats/specctra/WriteScopeParameter.java +++ b/src/main/java/net/freerouting/designformats/specctra/WriteScopeParameter.java @@ -18,11 +18,11 @@ * Created on 21. Juni 2004, 08:37 */ -package designformats.specctra; +package net.freerouting.designformats.specctra; -import board.BasicBoard; -import datastructures.IndentFileWriter; -import datastructures.IdentifierType; +import net.freerouting.board.BasicBoard; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.IdentifierType; /** * Default parameter type used while writing a Specctra dsn-file. @@ -37,7 +37,7 @@ public class WriteScopeParameter * If p_compat_mode is true, only standard speecctra dsb scopes are written, so that any * host system with an specctra interface can read them. */ - WriteScopeParameter(BasicBoard p_board, interactive.AutorouteSettings p_autoroute_settings, + WriteScopeParameter(BasicBoard p_board, net.freerouting.interactive.AutorouteSettings p_autoroute_settings, IndentFileWriter p_file, String p_string_quote, CoordinateTransform p_coordinate_transform, boolean p_compat_mode) { @@ -51,7 +51,7 @@ public class WriteScopeParameter } final BasicBoard board; - final interactive.AutorouteSettings autoroute_settings; + final net.freerouting.interactive.AutorouteSettings autoroute_settings; final IndentFileWriter file; final CoordinateTransform coordinate_transform; final boolean compat_mode; diff --git a/designformats/specctra/package.html b/src/main/java/net/freerouting/designformats/specctra/package.html similarity index 100% rename from designformats/specctra/package.html rename to src/main/java/net/freerouting/designformats/specctra/package.html diff --git a/geometry/planar/Area.java b/src/main/java/net/freerouting/geometry/planar/Area.java similarity index 98% rename from geometry/planar/Area.java rename to src/main/java/net/freerouting/geometry/planar/Area.java index 1f936181..315efcc4 100644 --- a/geometry/planar/Area.java +++ b/src/main/java/net/freerouting/geometry/planar/Area.java @@ -18,7 +18,7 @@ * Created on 22. Juni 2003, 10:16 */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * An Area is a not necessarily simply connected Shape, which means, diff --git a/geometry/planar/BigIntDirection.java b/src/main/java/net/freerouting/geometry/planar/BigIntDirection.java similarity index 98% rename from geometry/planar/BigIntDirection.java rename to src/main/java/net/freerouting/geometry/planar/BigIntDirection.java index 57075a91..c3f6c70a 100644 --- a/geometry/planar/BigIntDirection.java +++ b/src/main/java/net/freerouting/geometry/planar/BigIntDirection.java @@ -18,7 +18,7 @@ * Created on 4. Februar 2003, 14:10 */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.math.BigInteger; /** diff --git a/geometry/planar/Circle.java b/src/main/java/net/freerouting/geometry/planar/Circle.java similarity index 99% rename from geometry/planar/Circle.java rename to src/main/java/net/freerouting/geometry/planar/Circle.java index ac2d115b..a74bc5da 100644 --- a/geometry/planar/Circle.java +++ b/src/main/java/net/freerouting/geometry/planar/Circle.java @@ -18,7 +18,7 @@ * Created on 4. Juni 2003, 07:29 */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * Discribes functionality of a circle shape in the plane. diff --git a/geometry/planar/ConvexShape.java b/src/main/java/net/freerouting/geometry/planar/ConvexShape.java similarity index 97% rename from geometry/planar/ConvexShape.java rename to src/main/java/net/freerouting/geometry/planar/ConvexShape.java index 5038438c..63f687a5 100644 --- a/geometry/planar/ConvexShape.java +++ b/src/main/java/net/freerouting/geometry/planar/ConvexShape.java @@ -18,7 +18,7 @@ * Created on 15. November 2002, 08:44 */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * A shape is defined as convex, if for each line segment with both endpoints diff --git a/geometry/planar/Direction.java b/src/main/java/net/freerouting/geometry/planar/Direction.java similarity index 98% rename from geometry/planar/Direction.java rename to src/main/java/net/freerouting/geometry/planar/Direction.java index d0f97c82..589f2da0 100644 --- a/geometry/planar/Direction.java +++ b/src/main/java/net/freerouting/geometry/planar/Direction.java @@ -18,8 +18,8 @@ * Created on 3. Februar 2003, 15:36 */ -package geometry.planar; -import datastructures.Signum; +package net.freerouting.geometry.planar; +import net.freerouting.datastructures.Signum; /** * diff --git a/geometry/planar/Ellipse.java b/src/main/java/net/freerouting/geometry/planar/Ellipse.java similarity index 97% rename from geometry/planar/Ellipse.java rename to src/main/java/net/freerouting/geometry/planar/Ellipse.java index c82f2a45..fd38e2d5 100644 --- a/geometry/planar/Ellipse.java +++ b/src/main/java/net/freerouting/geometry/planar/Ellipse.java @@ -19,7 +19,7 @@ * */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * Describes functionality of an elllipse in the plane. diff --git a/geometry/planar/FloatLine.java b/src/main/java/net/freerouting/geometry/planar/FloatLine.java similarity index 99% rename from geometry/planar/FloatLine.java rename to src/main/java/net/freerouting/geometry/planar/FloatLine.java index 5e4e249c..69ab068f 100644 --- a/geometry/planar/FloatLine.java +++ b/src/main/java/net/freerouting/geometry/planar/FloatLine.java @@ -18,7 +18,7 @@ * Created on 19. Februar 2004, 07:22 */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * Defines a line in the plane by to FloatPoints. diff --git a/geometry/planar/FloatPoint.java b/src/main/java/net/freerouting/geometry/planar/FloatPoint.java similarity index 99% rename from geometry/planar/FloatPoint.java rename to src/main/java/net/freerouting/geometry/planar/FloatPoint.java index 9f475032..901af5f4 100644 --- a/geometry/planar/FloatPoint.java +++ b/src/main/java/net/freerouting/geometry/planar/FloatPoint.java @@ -18,7 +18,7 @@ * Created on 2. Februar 2003, 09:14 */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * diff --git a/geometry/planar/FortyfiveDegreeBoundingDirections.java b/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeBoundingDirections.java similarity index 97% rename from geometry/planar/FortyfiveDegreeBoundingDirections.java rename to src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeBoundingDirections.java index 596c7e67..fc3f2b29 100644 --- a/geometry/planar/FortyfiveDegreeBoundingDirections.java +++ b/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeBoundingDirections.java @@ -14,7 +14,7 @@ * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * diff --git a/geometry/planar/FortyfiveDegreeDirection.java b/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeDirection.java similarity index 97% rename from geometry/planar/FortyfiveDegreeDirection.java rename to src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeDirection.java index 16356aef..7bf8281d 100644 --- a/geometry/planar/FortyfiveDegreeDirection.java +++ b/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeDirection.java @@ -19,7 +19,7 @@ * */ -package geometry.planar; +package net.freerouting.geometry.planar; @SuppressWarnings("all") // Eclipse regards get_direction() as unused /** diff --git a/geometry/planar/IntBox.java b/src/main/java/net/freerouting/geometry/planar/IntBox.java similarity index 99% rename from geometry/planar/IntBox.java rename to src/main/java/net/freerouting/geometry/planar/IntBox.java index cbbbe937..87b5d6c0 100644 --- a/geometry/planar/IntBox.java +++ b/src/main/java/net/freerouting/geometry/planar/IntBox.java @@ -18,7 +18,7 @@ * Created on 2. Februar 2003, 14:09 */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * diff --git a/geometry/planar/IntDirection.java b/src/main/java/net/freerouting/geometry/planar/IntDirection.java similarity index 98% rename from geometry/planar/IntDirection.java rename to src/main/java/net/freerouting/geometry/planar/IntDirection.java index 0e6b2028..875c3663 100644 --- a/geometry/planar/IntDirection.java +++ b/src/main/java/net/freerouting/geometry/planar/IntDirection.java @@ -18,8 +18,8 @@ * Created on 3. Februar 2003, 08:17 */ -package geometry.planar; -import datastructures.Signum; +package net.freerouting.geometry.planar; +import net.freerouting.datastructures.Signum; /** * diff --git a/geometry/planar/IntOctagon.java b/src/main/java/net/freerouting/geometry/planar/IntOctagon.java similarity index 99% rename from geometry/planar/IntOctagon.java rename to src/main/java/net/freerouting/geometry/planar/IntOctagon.java index 1b82c1ec..4e8d5353 100644 --- a/geometry/planar/IntOctagon.java +++ b/src/main/java/net/freerouting/geometry/planar/IntOctagon.java @@ -14,7 +14,7 @@ * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * diff --git a/geometry/planar/IntPoint.java b/src/main/java/net/freerouting/geometry/planar/IntPoint.java similarity index 99% rename from geometry/planar/IntPoint.java rename to src/main/java/net/freerouting/geometry/planar/IntPoint.java index dd8fead8..2f432312 100644 --- a/geometry/planar/IntPoint.java +++ b/src/main/java/net/freerouting/geometry/planar/IntPoint.java @@ -18,7 +18,7 @@ * Created on 1. Februar 2003, 10:31 */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.math.BigInteger; diff --git a/geometry/planar/IntVector.java b/src/main/java/net/freerouting/geometry/planar/IntVector.java similarity index 98% rename from geometry/planar/IntVector.java rename to src/main/java/net/freerouting/geometry/planar/IntVector.java index d7369901..7fa2ed4c 100644 --- a/geometry/planar/IntVector.java +++ b/src/main/java/net/freerouting/geometry/planar/IntVector.java @@ -18,9 +18,9 @@ * Created on 1. Februar 2003, 14:47 */ -package geometry.planar; -import datastructures.BigIntAux; -import datastructures.Signum; +package net.freerouting.geometry.planar; +import net.freerouting.datastructures.BigIntAux; +import net.freerouting.datastructures.Signum; /** * diff --git a/geometry/planar/Limits.java b/src/main/java/net/freerouting/geometry/planar/Limits.java similarity index 97% rename from geometry/planar/Limits.java rename to src/main/java/net/freerouting/geometry/planar/Limits.java index f735b4e4..5c3e6546 100644 --- a/geometry/planar/Limits.java +++ b/src/main/java/net/freerouting/geometry/planar/Limits.java @@ -14,7 +14,7 @@ * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.math.BigInteger; /** diff --git a/geometry/planar/Line.java b/src/main/java/net/freerouting/geometry/planar/Line.java similarity index 99% rename from geometry/planar/Line.java rename to src/main/java/net/freerouting/geometry/planar/Line.java index 4967ec1b..997a2505 100644 --- a/geometry/planar/Line.java +++ b/src/main/java/net/freerouting/geometry/planar/Line.java @@ -14,11 +14,11 @@ * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.math.BigInteger; -import datastructures.Signum; +import net.freerouting.datastructures.Signum; /** * diff --git a/geometry/planar/LineSegment.java b/src/main/java/net/freerouting/geometry/planar/LineSegment.java similarity index 99% rename from geometry/planar/LineSegment.java rename to src/main/java/net/freerouting/geometry/planar/LineSegment.java index 8ccad33e..d14e78a0 100644 --- a/geometry/planar/LineSegment.java +++ b/src/main/java/net/freerouting/geometry/planar/LineSegment.java @@ -13,9 +13,9 @@ * GNU General Public License at * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; -import datastructures.Signum; +import net.freerouting.datastructures.Signum; /** * Implements functionality for line segments. diff --git a/geometry/planar/OrthogonalBoundingDirections.java b/src/main/java/net/freerouting/geometry/planar/OrthogonalBoundingDirections.java similarity index 97% rename from geometry/planar/OrthogonalBoundingDirections.java rename to src/main/java/net/freerouting/geometry/planar/OrthogonalBoundingDirections.java index 70c7cb67..dd3c7575 100644 --- a/geometry/planar/OrthogonalBoundingDirections.java +++ b/src/main/java/net/freerouting/geometry/planar/OrthogonalBoundingDirections.java @@ -14,7 +14,7 @@ * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * diff --git a/geometry/planar/Point.java b/src/main/java/net/freerouting/geometry/planar/Point.java similarity index 99% rename from geometry/planar/Point.java rename to src/main/java/net/freerouting/geometry/planar/Point.java index bc8a9611..e6f4eb1c 100644 --- a/geometry/planar/Point.java +++ b/src/main/java/net/freerouting/geometry/planar/Point.java @@ -18,7 +18,7 @@ * Created on 1. Februar 2003, 11:38 */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.math.BigInteger; diff --git a/geometry/planar/Polygon.java b/src/main/java/net/freerouting/geometry/planar/Polygon.java similarity index 99% rename from geometry/planar/Polygon.java rename to src/main/java/net/freerouting/geometry/planar/Polygon.java index 817e342f..ee6e586f 100644 --- a/geometry/planar/Polygon.java +++ b/src/main/java/net/freerouting/geometry/planar/Polygon.java @@ -14,7 +14,7 @@ * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.util.Collection; import java.util.Iterator; diff --git a/geometry/planar/PolygonShape.java b/src/main/java/net/freerouting/geometry/planar/PolygonShape.java similarity index 99% rename from geometry/planar/PolygonShape.java rename to src/main/java/net/freerouting/geometry/planar/PolygonShape.java index 9330a151..679ddf48 100644 --- a/geometry/planar/PolygonShape.java +++ b/src/main/java/net/freerouting/geometry/planar/PolygonShape.java @@ -18,7 +18,7 @@ * Created on 13. Juni 2003, 12:12 */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.util.Collection; import java.util.Iterator; diff --git a/geometry/planar/Polyline.java b/src/main/java/net/freerouting/geometry/planar/Polyline.java similarity index 99% rename from geometry/planar/Polyline.java rename to src/main/java/net/freerouting/geometry/planar/Polyline.java index a91a9afc..8d5d4968 100644 --- a/geometry/planar/Polyline.java +++ b/src/main/java/net/freerouting/geometry/planar/Polyline.java @@ -14,7 +14,7 @@ * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.util.Collection; import java.util.Iterator; diff --git a/geometry/planar/PolylineArea.java b/src/main/java/net/freerouting/geometry/planar/PolylineArea.java similarity index 98% rename from geometry/planar/PolylineArea.java rename to src/main/java/net/freerouting/geometry/planar/PolylineArea.java index a0c21cf2..0777f761 100644 --- a/geometry/planar/PolylineArea.java +++ b/src/main/java/net/freerouting/geometry/planar/PolylineArea.java @@ -17,7 +17,7 @@ * * Created on 19. Juni 2003, 07:58 */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.util.Collection; import java.util.Iterator; @@ -182,7 +182,7 @@ public TileShape[] split_to_convex() * instead of Polygons, so that no intersection points are needed in the result. * If p_stoppable_thread != null, this function can be interrupted. */ - public TileShape[] split_to_convex(datastructures.Stoppable p_stoppable_thread) + public TileShape[] split_to_convex(net.freerouting.datastructures.Stoppable p_stoppable_thread) { if (precalculated_convex_pieces == null) { diff --git a/geometry/planar/PolylineShape.java b/src/main/java/net/freerouting/geometry/planar/PolylineShape.java similarity index 99% rename from geometry/planar/PolylineShape.java rename to src/main/java/net/freerouting/geometry/planar/PolylineShape.java index 9d2e740f..0355389b 100644 --- a/geometry/planar/PolylineShape.java +++ b/src/main/java/net/freerouting/geometry/planar/PolylineShape.java @@ -18,7 +18,7 @@ * Created on 16. November 2002, 09:34 */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.util.Collection; import java.util.Iterator; diff --git a/geometry/planar/RationalPoint.java b/src/main/java/net/freerouting/geometry/planar/RationalPoint.java similarity index 99% rename from geometry/planar/RationalPoint.java rename to src/main/java/net/freerouting/geometry/planar/RationalPoint.java index 8122c569..1a09ece5 100644 --- a/geometry/planar/RationalPoint.java +++ b/src/main/java/net/freerouting/geometry/planar/RationalPoint.java @@ -18,10 +18,10 @@ * Created on 1. Februar 2003, 13:12 */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.math.BigInteger; -import datastructures.BigIntAux; +import net.freerouting.datastructures.BigIntAux; /** * diff --git a/geometry/planar/RationalVector.java b/src/main/java/net/freerouting/geometry/planar/RationalVector.java similarity index 98% rename from geometry/planar/RationalVector.java rename to src/main/java/net/freerouting/geometry/planar/RationalVector.java index 08868edc..f93e42f7 100644 --- a/geometry/planar/RationalVector.java +++ b/src/main/java/net/freerouting/geometry/planar/RationalVector.java @@ -18,11 +18,11 @@ * Created on 1. Februar 2003, 09:16 */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.math.BigInteger; -import datastructures.BigIntAux; -import datastructures.Signum; +import net.freerouting.datastructures.BigIntAux; +import net.freerouting.datastructures.Signum; /** * diff --git a/geometry/planar/RegularTileShape.java b/src/main/java/net/freerouting/geometry/planar/RegularTileShape.java similarity index 98% rename from geometry/planar/RegularTileShape.java rename to src/main/java/net/freerouting/geometry/planar/RegularTileShape.java index 26bba495..d5a66ddc 100644 --- a/geometry/planar/RegularTileShape.java +++ b/src/main/java/net/freerouting/geometry/planar/RegularTileShape.java @@ -18,7 +18,7 @@ * Created on 16. November 2002, 17:11 */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * TileShapes whose border lines may have only directions out of diff --git a/geometry/planar/Shape.java b/src/main/java/net/freerouting/geometry/planar/Shape.java similarity index 98% rename from geometry/planar/Shape.java rename to src/main/java/net/freerouting/geometry/planar/Shape.java index 98d680b3..6ac7dc07 100644 --- a/geometry/planar/Shape.java +++ b/src/main/java/net/freerouting/geometry/planar/Shape.java @@ -18,7 +18,7 @@ * Created on 14. November 2002, 12:35 */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * Interface describing functionality for connected 2-dimensional shapes in the plane. diff --git a/geometry/planar/ShapeBoundingDirections.java b/src/main/java/net/freerouting/geometry/planar/ShapeBoundingDirections.java similarity index 97% rename from geometry/planar/ShapeBoundingDirections.java rename to src/main/java/net/freerouting/geometry/planar/ShapeBoundingDirections.java index ce1b5840..f49a9f66 100644 --- a/geometry/planar/ShapeBoundingDirections.java +++ b/src/main/java/net/freerouting/geometry/planar/ShapeBoundingDirections.java @@ -14,7 +14,7 @@ * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * diff --git a/geometry/planar/Side.java b/src/main/java/net/freerouting/geometry/planar/Side.java similarity index 98% rename from geometry/planar/Side.java rename to src/main/java/net/freerouting/geometry/planar/Side.java index d062267b..c723c1f8 100644 --- a/geometry/planar/Side.java +++ b/src/main/java/net/freerouting/geometry/planar/Side.java @@ -14,7 +14,7 @@ * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; /** * diff --git a/geometry/planar/Simplex.java b/src/main/java/net/freerouting/geometry/planar/Simplex.java similarity index 99% rename from geometry/planar/Simplex.java rename to src/main/java/net/freerouting/geometry/planar/Simplex.java index 1a79f2bb..d51d7cf6 100644 --- a/geometry/planar/Simplex.java +++ b/src/main/java/net/freerouting/geometry/planar/Simplex.java @@ -14,7 +14,7 @@ * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.util.Collection; import java.util.Iterator; diff --git a/geometry/planar/TileShape.java b/src/main/java/net/freerouting/geometry/planar/TileShape.java similarity index 99% rename from geometry/planar/TileShape.java rename to src/main/java/net/freerouting/geometry/planar/TileShape.java index f13a34b5..edeba9e1 100644 --- a/geometry/planar/TileShape.java +++ b/src/main/java/net/freerouting/geometry/planar/TileShape.java @@ -13,7 +13,7 @@ * GNU General Public License at * for more details. */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.util.Collection; import java.util.Iterator; diff --git a/geometry/planar/Vector.java b/src/main/java/net/freerouting/geometry/planar/Vector.java similarity index 98% rename from geometry/planar/Vector.java rename to src/main/java/net/freerouting/geometry/planar/Vector.java index 3b079f38..f94bb49b 100644 --- a/geometry/planar/Vector.java +++ b/src/main/java/net/freerouting/geometry/planar/Vector.java @@ -18,11 +18,11 @@ * Created on 1. Februar 2003, 14:28 */ -package geometry.planar; +package net.freerouting.geometry.planar; import java.math.BigInteger; -import datastructures.Signum; +import net.freerouting.datastructures.Signum; /** * Abstract class describing functionality of Vectors. diff --git a/geometry/planar/package.html b/src/main/java/net/freerouting/geometry/planar/package.html similarity index 100% rename from geometry/planar/package.html rename to src/main/java/net/freerouting/geometry/planar/package.html diff --git a/gui/BoardFrame.java b/src/main/java/net/freerouting/gui/BoardFrame.java similarity index 96% rename from gui/BoardFrame.java rename to src/main/java/net/freerouting/gui/BoardFrame.java index 49160cf3..2b06872d 100644 --- a/gui/BoardFrame.java +++ b/src/main/java/net/freerouting/gui/BoardFrame.java @@ -14,19 +14,19 @@ * for more details. */ -package gui; +package net.freerouting.gui; -import interactive.ScreenMessages; +import net.freerouting.interactive.ScreenMessages; import java.io.File; -import datastructures.FileFilter; -import datastructures.IdNoGenerator; +import net.freerouting.datastructures.FileFilter; +import net.freerouting.datastructures.IdNoGenerator; -import board.TestLevel; -import board.BoardObservers; +import net.freerouting.board.TestLevel; +import net.freerouting.board.BoardObservers; -import designformats.specctra.DsnFile; +import net.freerouting.designformats.specctra.DsnFile; /** * @@ -48,13 +48,13 @@ public enum Option public static BoardFrame get_embedded_instance(String p_design_file_path_name, BoardObservers p_observers, IdNoGenerator p_id_no_generator, java.util.Locale p_locale) { - final gui.DesignFile design_file = gui.DesignFile.get_instance(p_design_file_path_name, false); + final net.freerouting.gui.DesignFile design_file = net.freerouting.gui.DesignFile.get_instance(p_design_file_path_name, false); if (design_file == null) { WindowMessage.show("designfile not found"); return null; } - gui.BoardFrame board_frame = new gui.BoardFrame(design_file, gui.BoardFrame.Option.SINGLE_FRAME, + net.freerouting.gui.BoardFrame board_frame = new net.freerouting.gui.BoardFrame(design_file, net.freerouting.gui.BoardFrame.Option.SINGLE_FRAME, TestLevel.RELEASE_VERSION, p_observers, p_id_no_generator, p_locale, false); @@ -90,7 +90,7 @@ public BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, java.util.Locale p_locale, boolean p_confirm_cancel) { this(p_design, p_option, p_test_level, - new board.BoardObserverAdaptor(), new board.ItemIdNoGenerator(), + new net.freerouting.board.BoardObserverAdaptor(), new net.freerouting.board.ItemIdNoGenerator(), p_locale, p_confirm_cancel); } @@ -100,7 +100,7 @@ public BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, * if the frame is embedded into a host system, */ BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, BoardObservers p_observers, - datastructures.IdNoGenerator p_item_id_no_generator, java.util.Locale p_locale, boolean p_confirm_cancel) + net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, java.util.Locale p_locale, boolean p_confirm_cancel) { this.design_file = p_design; this.is_web_start = (p_option == Option.WEBSTART); @@ -110,7 +110,7 @@ public BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, this.board_observers = p_observers; this.item_id_no_generator = p_item_id_no_generator; this.locale = p_locale; - this.resources = java.util.ResourceBundle.getBundle("gui.resources.BoardFrame", p_locale); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardFrame", p_locale); BoardMenuBar curr_menubar; boolean session_file_option = (p_option == Option.SESSION_FILE); boolean curr_help_system_used = true; @@ -280,7 +280,7 @@ boolean read(java.io.InputStream p_input_stream, boolean p_is_import, javax.swin } if (defaults_file_found) { - boolean read_ok = gui.GUIDefaultsFile.read(this, board_panel.board_handling, input_stream); + boolean read_ok = net.freerouting.gui.GUIDefaultsFile.read(this, board_panel.board_handling, input_stream); if (!read_ok) { screen_messages.set_status_message(resources.getString("error_1")); @@ -697,7 +697,7 @@ public void repaint_all() private java.util.Locale locale; private final BoardObservers board_observers; - private final datastructures.IdNoGenerator item_id_no_generator; + private final net.freerouting.datastructures.IdNoGenerator item_id_no_generator; WindowAbout about_window = null; WindowRouteParameter route_parameter_window = null; diff --git a/gui/BoardMenuBar.java b/src/main/java/net/freerouting/gui/BoardMenuBar.java similarity index 98% rename from gui/BoardMenuBar.java rename to src/main/java/net/freerouting/gui/BoardMenuBar.java index 630a78ed..42dcc084 100644 --- a/gui/BoardMenuBar.java +++ b/src/main/java/net/freerouting/gui/BoardMenuBar.java @@ -18,7 +18,7 @@ * Created on 11. Februar 2005, 10:17 */ -package gui; +package net.freerouting.gui; /** * Creates the menu bar of a board frame together with its menu items. diff --git a/gui/BoardMenuDisplay.java b/src/main/java/net/freerouting/gui/BoardMenuDisplay.java similarity index 96% rename from gui/BoardMenuDisplay.java rename to src/main/java/net/freerouting/gui/BoardMenuDisplay.java index 24fa2f42..4bdc5835 100644 --- a/gui/BoardMenuDisplay.java +++ b/src/main/java/net/freerouting/gui/BoardMenuDisplay.java @@ -18,7 +18,7 @@ * Created on 12. Februar 2005, 05:42 */ -package gui; +package net.freerouting.gui; /** * Creates the display menu of a board frame. @@ -91,7 +91,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) private BoardMenuDisplay(BoardFrame p_board_frame) { board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("gui.resources.BoardMenuDisplay", p_board_frame.get_locale()); + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuDisplay", p_board_frame.get_locale()); } private final BoardFrame board_frame; diff --git a/gui/BoardMenuFile.java b/src/main/java/net/freerouting/gui/BoardMenuFile.java similarity index 94% rename from gui/BoardMenuFile.java rename to src/main/java/net/freerouting/gui/BoardMenuFile.java index e5940632..e28c9dc4 100644 --- a/gui/BoardMenuFile.java +++ b/src/main/java/net/freerouting/gui/BoardMenuFile.java @@ -17,7 +17,7 @@ * * Created on 11. Februar 2005, 11:26 */ -package gui; +package net.freerouting.gui; /** * Creates the file menu of a board frame. @@ -155,7 +155,7 @@ public void add_design_dependent_items() { return; } - board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); boolean host_cad_is_eagle = routing_board.communication.host_cad_is_eagle(); javax.swing.JMenuItem write_session_file_item = new javax.swing.JMenuItem(); @@ -170,7 +170,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) } }); - if ((routing_board.get_test_level() != board.TestLevel.RELEASE_VERSION || !host_cad_is_eagle)) + if ((routing_board.get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION || !host_cad_is_eagle)) { this.add(write_session_file_item); } @@ -187,7 +187,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) } }); - if (routing_board.get_test_level() != board.TestLevel.RELEASE_VERSION || host_cad_is_eagle) + if (routing_board.get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION || host_cad_is_eagle) { this.add(write_eagle_session_script_item); } @@ -300,7 +300,7 @@ private void save_defaults_action() } else { - write_ok = gui.GUIDefaultsFile.write(board_frame, board_frame.board_panel.board_handling, output_stream); + write_ok = net.freerouting.gui.GUIDefaultsFile.write(board_frame, board_frame.board_panel.board_handling, output_stream); } if (write_ok) { @@ -318,7 +318,7 @@ private BoardMenuFile(BoardFrame p_board_frame, boolean p_session_file_option) { session_file_option = p_session_file_option; board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("gui.resources.BoardMenuFile", p_board_frame.get_locale()); + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); } private final BoardFrame board_frame; private final boolean session_file_option; diff --git a/gui/BoardMenuHelp.java b/src/main/java/net/freerouting/gui/BoardMenuHelp.java similarity index 95% rename from gui/BoardMenuHelp.java rename to src/main/java/net/freerouting/gui/BoardMenuHelp.java index b510707d..76f26dce 100644 --- a/gui/BoardMenuHelp.java +++ b/src/main/java/net/freerouting/gui/BoardMenuHelp.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; import javax.help.CSH; import javax.help.HelpSet; @@ -66,11 +66,11 @@ private void initialize_help(java.util.Locale p_locale) String helpset_name; if (language.equalsIgnoreCase("de")) { - helpset_name = "helpset/de/Help.hs"; + helpset_name = "net/freerouting/helpset/de/Help.hs"; } else { - helpset_name = "helpset/en/Help.hs"; + helpset_name = "net/freerouting/helpset/en/Help.hs"; } try { diff --git a/gui/BoardMenuHelpReduced.java b/src/main/java/net/freerouting/gui/BoardMenuHelpReduced.java similarity index 91% rename from gui/BoardMenuHelpReduced.java rename to src/main/java/net/freerouting/gui/BoardMenuHelpReduced.java index 91427390..b181ea7f 100644 --- a/gui/BoardMenuHelpReduced.java +++ b/src/main/java/net/freerouting/gui/BoardMenuHelpReduced.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; /** * @@ -35,7 +35,7 @@ public class BoardMenuHelpReduced extends javax.swing.JMenu public BoardMenuHelpReduced(BoardFrame p_board_frame) { this.board_frame = p_board_frame; - this.resources = java.util.ResourceBundle.getBundle("gui.resources.BoardMenuHelp", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuHelp", p_board_frame.get_locale()); this.setText(this.resources.getString("help")); javax.swing.JMenuItem about_window = new javax.swing.JMenuItem(); diff --git a/gui/BoardMenuInfo.java b/src/main/java/net/freerouting/gui/BoardMenuInfo.java similarity index 97% rename from gui/BoardMenuInfo.java rename to src/main/java/net/freerouting/gui/BoardMenuInfo.java index b6ae0723..8e10d4ed 100644 --- a/gui/BoardMenuInfo.java +++ b/src/main/java/net/freerouting/gui/BoardMenuInfo.java @@ -18,7 +18,7 @@ * Created on 6. Maerz 2005, 05:37 */ -package gui; +package net.freerouting.gui; /** * @@ -129,7 +129,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) private BoardMenuInfo(BoardFrame p_board_frame) { board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("gui.resources.BoardMenuInfo", p_board_frame.get_locale()); + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuInfo", p_board_frame.get_locale()); } diff --git a/gui/BoardMenuOther.java b/src/main/java/net/freerouting/gui/BoardMenuOther.java similarity index 92% rename from gui/BoardMenuOther.java rename to src/main/java/net/freerouting/gui/BoardMenuOther.java index 6d398323..fa80bbb4 100644 --- a/gui/BoardMenuOther.java +++ b/src/main/java/net/freerouting/gui/BoardMenuOther.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; /** * @@ -55,7 +55,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) private BoardMenuOther(BoardFrame p_board_frame) { board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("gui.resources.BoardMenuOther", p_board_frame.get_locale()); + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuOther", p_board_frame.get_locale()); } private final BoardFrame board_frame; diff --git a/gui/BoardMenuParameter.java b/src/main/java/net/freerouting/gui/BoardMenuParameter.java similarity index 95% rename from gui/BoardMenuParameter.java rename to src/main/java/net/freerouting/gui/BoardMenuParameter.java index c6b72454..16597d47 100644 --- a/gui/BoardMenuParameter.java +++ b/src/main/java/net/freerouting/gui/BoardMenuParameter.java @@ -18,7 +18,7 @@ * Created on 12. Februar 2005, 06:08 */ -package gui; +package net.freerouting.gui; /** * Creates the parameter menu of a board frame. @@ -89,7 +89,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) private BoardMenuParameter(BoardFrame p_board_frame) { board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("gui.resources.BoardMenuParameter", p_board_frame.get_locale()); + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuParameter", p_board_frame.get_locale()); } private final BoardFrame board_frame; diff --git a/gui/BoardMenuRules.java b/src/main/java/net/freerouting/gui/BoardMenuRules.java similarity index 95% rename from gui/BoardMenuRules.java rename to src/main/java/net/freerouting/gui/BoardMenuRules.java index 3b963a87..45e6593c 100644 --- a/gui/BoardMenuRules.java +++ b/src/main/java/net/freerouting/gui/BoardMenuRules.java @@ -18,7 +18,7 @@ * Created on 20. Februar 2005, 06:00 */ -package gui; +package net.freerouting.gui; /** * Creates the rules menu of a board frame. @@ -87,7 +87,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) private BoardMenuRules(BoardFrame p_board_frame) { board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("gui.resources.BoardMenuRules", p_board_frame.get_locale()); + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuRules", p_board_frame.get_locale()); } diff --git a/gui/BoardPanel.java b/src/main/java/net/freerouting/gui/BoardPanel.java similarity index 97% rename from gui/BoardPanel.java rename to src/main/java/net/freerouting/gui/BoardPanel.java index a036ce12..fac4fe6d 100644 --- a/gui/BoardPanel.java +++ b/src/main/java/net/freerouting/gui/BoardPanel.java @@ -18,10 +18,10 @@ * Created on 3. Oktober 2002, 18:47 */ -package gui; +package net.freerouting.gui; -import interactive.BoardHandling; -import interactive.ScreenMessages; +import net.freerouting.interactive.BoardHandling; +import net.freerouting.interactive.ScreenMessages; import java.awt.Dimension; import java.awt.Graphics; @@ -295,8 +295,8 @@ public void center_display(Point2D p_new_center) new java.awt.Point((int)(new_center.getX() - delta.getX()), (int)(new_center.getY() - delta.getY())); move_mouse(new_mouse_location); repaint(); - this.board_handling.logfile.start_scope(interactive.LogfileScope.CENTER_DISPLAY); - geometry.planar.FloatPoint curr_corner = new geometry.planar.FloatPoint(p_new_center.getX(), p_new_center.getY()); + this.board_handling.logfile.start_scope(net.freerouting.interactive.LogfileScope.CENTER_DISPLAY); + net.freerouting.geometry.planar.FloatPoint curr_corner = new net.freerouting.geometry.planar.FloatPoint(p_new_center.getX(), p_new_center.getY()); this.board_handling.logfile.add_corner(curr_corner); } diff --git a/gui/BoardPanelStatus.java b/src/main/java/net/freerouting/gui/BoardPanelStatus.java similarity index 96% rename from gui/BoardPanelStatus.java rename to src/main/java/net/freerouting/gui/BoardPanelStatus.java index ef82dd3c..4ee48eca 100644 --- a/gui/BoardPanelStatus.java +++ b/src/main/java/net/freerouting/gui/BoardPanelStatus.java @@ -18,7 +18,7 @@ * Created on 16. Februar 2005, 08:11 */ -package gui; +package net.freerouting.gui; /** * Panel at the lower border of the board frame containing amongst others the message line @@ -33,7 +33,7 @@ class BoardPanelStatus extends javax.swing.JPanel BoardPanelStatus(java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.BoardPanelStatus", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardPanelStatus", p_locale); this.setLayout(new java.awt.BorderLayout()); this.setPreferredSize(new java.awt.Dimension(300, 20)); diff --git a/gui/BoardSavableSubWindow.java b/src/main/java/net/freerouting/gui/BoardSavableSubWindow.java similarity index 98% rename from gui/BoardSavableSubWindow.java rename to src/main/java/net/freerouting/gui/BoardSavableSubWindow.java index fc321883..33c6c838 100644 --- a/gui/BoardSavableSubWindow.java +++ b/src/main/java/net/freerouting/gui/BoardSavableSubWindow.java @@ -18,7 +18,7 @@ * Created on 20. Dezember 2004, 09:03 */ -package gui; +package net.freerouting.gui; /** * Subwindow of the board frame, whose location and visibility can be saved and read from disc. diff --git a/gui/BoardSubWindow.java b/src/main/java/net/freerouting/gui/BoardSubWindow.java similarity index 97% rename from gui/BoardSubWindow.java rename to src/main/java/net/freerouting/gui/BoardSubWindow.java index 54be86a6..f9953937 100644 --- a/gui/BoardSubWindow.java +++ b/src/main/java/net/freerouting/gui/BoardSubWindow.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; /** * Subwindows of the board frame. diff --git a/gui/BoardTemporarySubWindow.java b/src/main/java/net/freerouting/gui/BoardTemporarySubWindow.java similarity index 98% rename from gui/BoardTemporarySubWindow.java rename to src/main/java/net/freerouting/gui/BoardTemporarySubWindow.java index 9a5bc272..8c681c96 100644 --- a/gui/BoardTemporarySubWindow.java +++ b/src/main/java/net/freerouting/gui/BoardTemporarySubWindow.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; /** * Class for temporary subwindows of the boarrd frame diff --git a/gui/BoardToolbar.java b/src/main/java/net/freerouting/gui/BoardToolbar.java similarity index 94% rename from gui/BoardToolbar.java rename to src/main/java/net/freerouting/gui/BoardToolbar.java index 9368dd02..702ce3d0 100644 --- a/gui/BoardToolbar.java +++ b/src/main/java/net/freerouting/gui/BoardToolbar.java @@ -18,7 +18,7 @@ * Created on 15. Februar 2005, 09:44 */ -package gui; +package net.freerouting.gui; /** * Implements the toolbar panel of the board frame. @@ -34,7 +34,7 @@ class BoardToolbar extends javax.swing.JPanel this.board_frame = p_board_frame; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.BoardToolbar", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardToolbar", p_board_frame.get_locale()); this.setLayout(new java.awt.BorderLayout()); @@ -257,7 +257,7 @@ public void keyTyped(java.awt.event.KeyEvent evt) right_toolbar.add(unit_factor_field); - unit_combo_box.setModel(new javax.swing.DefaultComboBoxModel(board.Unit.values())); + unit_combo_box.setModel(new javax.swing.DefaultComboBoxModel(net.freerouting.board.Unit.values())); unit_combo_box.setFocusTraversalPolicyProvider(true); unit_combo_box.setInheritsPopupMenu(true); unit_combo_box.setMaximumSize(new java.awt.Dimension(60, 18)); @@ -268,7 +268,7 @@ public void keyTyped(java.awt.event.KeyEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) { - board.Unit new_unit = (board.Unit) unit_combo_box.getSelectedItem(); + net.freerouting.board.Unit new_unit = (net.freerouting.board.Unit) unit_combo_box.getSelectedItem(); board_frame.board_panel.board_handling.change_user_unit(new_unit); board_frame.refresh_windows(); } @@ -288,16 +288,16 @@ public void actionPerformed(java.awt.event.ActionEvent evt) */ void hilight_selected_button() { - interactive.InteractiveState interactive_state = this.board_frame.board_panel.board_handling.get_interactive_state(); - if (interactive_state instanceof interactive.RouteMenuState) + net.freerouting.interactive.InteractiveState interactive_state = this.board_frame.board_panel.board_handling.get_interactive_state(); + if (interactive_state instanceof net.freerouting.interactive.RouteMenuState) { this.route_button.setSelected(true); } - else if (interactive_state instanceof interactive.DragMenuState) + else if (interactive_state instanceof net.freerouting.interactive.DragMenuState) { this.drag_button.setSelected(true); } - else if (interactive_state instanceof interactive.SelectMenuState) + else if (interactive_state instanceof net.freerouting.interactive.SelectMenuState) { this.select_button.setSelected(true); } diff --git a/gui/BoardToolbarSelectedItem.java b/src/main/java/net/freerouting/gui/BoardToolbarSelectedItem.java similarity index 97% rename from gui/BoardToolbarSelectedItem.java rename to src/main/java/net/freerouting/gui/BoardToolbarSelectedItem.java index fa4dd916..9b7e4fd8 100644 --- a/gui/BoardToolbarSelectedItem.java +++ b/src/main/java/net/freerouting/gui/BoardToolbarSelectedItem.java @@ -18,7 +18,7 @@ * Created on 16. Februar 2005, 05:59 */ -package gui; +package net.freerouting.gui; /** * Describes the toolbar of the board frame, when it is in the selected item state. @@ -37,7 +37,7 @@ class BoardToolbarSelectedItem extends javax.swing.JToolBar this.board_frame = p_board_frame; this.resources = - java.util.ResourceBundle.getBundle("gui.resources.BoardToolbarSelectedItem", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardToolbarSelectedItem", p_board_frame.get_locale()); javax.swing.JButton cancel_button = new javax.swing.JButton(); cancel_button.setText(resources.getString("cancel")); @@ -323,7 +323,7 @@ private void assign_clearance_class() { return; } - rules.ClearanceMatrix clearance_matrix = board_frame.board_panel.board_handling.get_routing_board().rules.clearance_matrix; + net.freerouting.rules.ClearanceMatrix clearance_matrix = board_frame.board_panel.board_handling.get_routing_board().rules.clearance_matrix; Object [] class_name_arr = new Object[clearance_matrix.get_class_count()]; for (int i = 0; i < class_name_arr.length; ++i) { diff --git a/gui/ColorManager.java b/src/main/java/net/freerouting/gui/ColorManager.java similarity index 96% rename from gui/ColorManager.java rename to src/main/java/net/freerouting/gui/ColorManager.java index 3c8546d4..278fc2c6 100644 --- a/gui/ColorManager.java +++ b/src/main/java/net/freerouting/gui/ColorManager.java @@ -18,7 +18,7 @@ * Created on 3. August 2003, 11:16 */ -package gui; +package net.freerouting.gui; import java.awt.BorderLayout; import java.awt.Color; @@ -41,7 +41,7 @@ import javax.swing.border.Border; import javax.swing.table.TableCellRenderer; -import boardgraphics.GraphicsContext; +import net.freerouting.boardgraphics.GraphicsContext; /** @@ -57,7 +57,7 @@ public ColorManager(BoardFrame p_board_frame) { GraphicsContext graphics_context = p_board_frame.board_panel.board_handling.graphics_context; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); this.setTitle(resources.getString("color_manager")); final JPanel panel = new JPanel(); final int textfield_height = 17; @@ -135,7 +135,7 @@ public void actionPerformed(ActionEvent e) } }; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_locale); final JDialog dialog = JColorChooser.createDialog(button, resources.getString("pick_a_color"), true, colorChooser, okListener, null); diff --git a/gui/ComboBoxClearance.java b/src/main/java/net/freerouting/gui/ComboBoxClearance.java similarity index 97% rename from gui/ComboBoxClearance.java rename to src/main/java/net/freerouting/gui/ComboBoxClearance.java index 1c32058a..526d2c84 100644 --- a/gui/ComboBoxClearance.java +++ b/src/main/java/net/freerouting/gui/ComboBoxClearance.java @@ -18,8 +18,8 @@ * Created on 1. Maerz 2005, 09:27 */ -package gui; -import rules.ClearanceMatrix; +package net.freerouting.gui; +import net.freerouting.rules.ClearanceMatrix; /** * A Combo Box with an item for each clearance class of the board.. diff --git a/gui/ComboBoxLayer.java b/src/main/java/net/freerouting/gui/ComboBoxLayer.java similarity index 91% rename from gui/ComboBoxLayer.java rename to src/main/java/net/freerouting/gui/ComboBoxLayer.java index 5af3a84d..1ea89170 100644 --- a/gui/ComboBoxLayer.java +++ b/src/main/java/net/freerouting/gui/ComboBoxLayer.java @@ -18,8 +18,8 @@ * Created on 20. Februar 2005, 08:14 */ -package gui; -import board.LayerStructure; +package net.freerouting.gui; +import net.freerouting.board.LayerStructure; /** * A Combo Box with items for individuell board layers plus an additional item for all layers. @@ -33,7 +33,7 @@ public class ComboBoxLayer extends javax.swing.JComboBox public ComboBoxLayer(LayerStructure p_layer_structure, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_locale); int signal_layer_count = p_layer_structure.signal_layer_count(); int item_count = signal_layer_count + 1; boolean add_inner_layer_item = signal_layer_count > 2; @@ -52,7 +52,7 @@ public ComboBoxLayer(LayerStructure p_layer_structure, java.util.Locale p_locale for (int i = 0; i < signal_layer_count; ++i) { ++curr_layer_no; - board.Layer curr_signal_layer = p_layer_structure.get_signal_layer(i); + net.freerouting.board.Layer curr_signal_layer = p_layer_structure.get_signal_layer(i); layer_arr[curr_layer_no] = new Layer(curr_signal_layer.name, p_layer_structure.get_no(curr_signal_layer)); } this.setModel(new javax.swing.DefaultComboBoxModel(layer_arr)); diff --git a/gui/Cursor.java b/src/main/java/net/freerouting/gui/Cursor.java similarity index 99% rename from gui/Cursor.java rename to src/main/java/net/freerouting/gui/Cursor.java index 9e3f561b..c8b6c17b 100644 --- a/gui/Cursor.java +++ b/src/main/java/net/freerouting/gui/Cursor.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; import java.awt.AlphaComposite; import java.awt.BasicStroke; diff --git a/gui/DesignFile.java b/src/main/java/net/freerouting/gui/DesignFile.java similarity index 94% rename from gui/DesignFile.java rename to src/main/java/net/freerouting/gui/DesignFile.java index 4b7b9274..6dd61e44 100644 --- a/gui/DesignFile.java +++ b/src/main/java/net/freerouting/gui/DesignFile.java @@ -18,9 +18,9 @@ * Created on 25. Oktober 2006, 07:48 * */ -package gui; +package net.freerouting.gui; -import datastructures.FileFilter; +import net.freerouting.datastructures.FileFilter; /** * File functionality with security restrictions used, when the application is opened with Java Webstart @@ -164,7 +164,7 @@ else if (this.input_file != null) public void save_as_dialog(java.awt.Component p_parent, BoardFrame p_board_frame) { final java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.BoardMenuFile", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); String[] file_name_parts = this.get_name().split("\\.", 2); String design_name = file_name_parts[0]; if (this.is_webstart) @@ -261,7 +261,7 @@ public void save_as_dialog(java.awt.Component p_parent, BoardFrame p_board_frame public boolean write_specctra_session_file(BoardFrame p_board_frame) { final java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.BoardMenuFile", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); String design_file_name = this.get_name(); String[] file_name_parts = design_file_name.split("\\.", 2); String design_name = file_name_parts[0]; @@ -312,7 +312,7 @@ public boolean write_specctra_session_file(BoardFrame p_board_frame) /** * Saves the board rule to file, so that they can be reused later on. */ - private boolean write_rules_file(String p_design_name, interactive.BoardHandling p_board_handling) + private boolean write_rules_file(String p_design_name, net.freerouting.interactive.BoardHandling p_board_handling) { String rules_file_name = p_design_name + RULES_FILE_EXTENSION; java.io.OutputStream output_stream; @@ -332,12 +332,12 @@ private boolean write_rules_file(String p_design_name, interactive.BoardHandling return false; } } - designformats.specctra.RulesFile.write(p_board_handling, output_stream, p_design_name); + net.freerouting.designformats.specctra.RulesFile.write(p_board_handling, output_stream, p_design_name); return true; } public static boolean read_rules_file(String p_design_name, String p_parent_name, - interactive.BoardHandling p_board_handling, boolean p_is_web_start, String p_confirm_message) + net.freerouting.interactive.BoardHandling p_board_handling, boolean p_is_web_start, String p_confirm_message) { boolean result = true; @@ -348,7 +348,7 @@ public static boolean read_rules_file(String p_design_name, String p_parent_name java.io.InputStream input_stream = WebStart.get_file_input_stream(rule_file_name); if (input_stream != null && dsn_file_generated_by_host && WindowMessage.confirm(p_confirm_message)) { - result = designformats.specctra.RulesFile.read(input_stream, p_design_name, p_board_handling); + result = net.freerouting.designformats.specctra.RulesFile.read(input_stream, p_design_name, p_board_handling); try { input_stream.close(); @@ -371,7 +371,7 @@ public static boolean read_rules_file(String p_design_name, String p_parent_name java.io.InputStream input_stream = new java.io.FileInputStream(rules_file); if (input_stream != null && dsn_file_generated_by_host && WindowMessage.confirm(p_confirm_message)) { - result = designformats.specctra.RulesFile.read(input_stream, p_design_name, p_board_handling); + result = net.freerouting.designformats.specctra.RulesFile.read(input_stream, p_design_name, p_board_handling); } else { @@ -399,7 +399,7 @@ public static boolean read_rules_file(String p_design_name, String p_parent_name public void update_eagle(BoardFrame p_board_frame) { final java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.BoardMenuFile", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); String design_file_name = get_name(); java.io.ByteArrayOutputStream session_output_stream = new java.io.ByteArrayOutputStream(); if (!p_board_frame.board_panel.board_handling.export_specctra_session_file(design_file_name, session_output_stream)) @@ -504,7 +504,7 @@ private String secure_write_session_file(BoardFrame p_board_frame) if (!new_session_file_name.equalsIgnoreCase(session_file_name)) { final java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.BoardMenuFile", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); String curr_message = resources.getString("message_20") + " " + session_file_name + "\n" + resources.getString("message_21"); WindowMessage.ok(curr_message); } @@ -543,7 +543,7 @@ private String webstart_update_eagle(BoardFrame p_board_frame, if (!new_script_file_name.endsWith(".scr")) { final java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.BoardMenuFile", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); String curr_message = resources.getString("message_22") + "\n" + resources.getString("message_21"); WindowMessage.ok(curr_message); } diff --git a/gui/GUIDefaultsDescription.flex b/src/main/java/net/freerouting/gui/GUIDefaultsDescription.flex similarity index 100% rename from gui/GUIDefaultsDescription.flex rename to src/main/java/net/freerouting/gui/GUIDefaultsDescription.flex diff --git a/gui/GUIDefaultsFile.java b/src/main/java/net/freerouting/gui/GUIDefaultsFile.java similarity index 98% rename from gui/GUIDefaultsFile.java rename to src/main/java/net/freerouting/gui/GUIDefaultsFile.java index 2002b1a4..20b3d99f 100644 --- a/gui/GUIDefaultsFile.java +++ b/src/main/java/net/freerouting/gui/GUIDefaultsFile.java @@ -18,11 +18,11 @@ * Created on 26. Dezember 2004, 08:29 */ -package gui; +package net.freerouting.gui; -import datastructures.IndentFileWriter; +import net.freerouting.datastructures.IndentFileWriter; -import board.ItemSelectionFilter; +import net.freerouting.board.ItemSelectionFilter; /** * Description of a text file, where the board independent interactive settings are stored. @@ -55,8 +55,8 @@ enum Keyword * Writes the GUI setting of p_board_frame as default to p_file. * Returns false, if an error occured. */ - public static boolean write(gui.BoardFrame p_board_frame, - interactive.BoardHandling p_board_handling, java.io.OutputStream p_output_stream) + public static boolean write(net.freerouting.gui.BoardFrame p_board_frame, + net.freerouting.interactive.BoardHandling p_board_handling, java.io.OutputStream p_output_stream) { if (p_output_stream == null) { @@ -92,8 +92,8 @@ public static boolean write(gui.BoardFrame p_board_frame, * Reads the GUI setting of p_board_frame from file. * Returns false, if an error occured while reading the file. */ - public static boolean read(gui.BoardFrame p_board_frame, - interactive.BoardHandling p_board_handling, java.io.InputStream p_input_stream) + public static boolean read(net.freerouting.gui.BoardFrame p_board_frame, + net.freerouting.interactive.BoardHandling p_board_handling, java.io.InputStream p_input_stream) { if (p_input_stream == null) { @@ -114,7 +114,7 @@ public static boolean read(gui.BoardFrame p_board_frame, return result; } - private GUIDefaultsFile(gui.BoardFrame p_board_frame, interactive.BoardHandling p_board_handling, + private GUIDefaultsFile(net.freerouting.gui.BoardFrame p_board_frame, net.freerouting.interactive.BoardHandling p_board_handling, GUIDefaultsScanner p_scanner, IndentFileWriter p_output_file) { board_frame = p_board_frame; @@ -921,7 +921,7 @@ private java.awt.Color[] read_color_array() throws java.io.IOException private void write_colors_scope() throws java.io.IOException { - boardgraphics.GraphicsContext graphics_context = this.board_handling.graphics_context; + net.freerouting.boardgraphics.GraphicsContext graphics_context = this.board_handling.graphics_context; out_file.start_scope(); out_file.write("colors"); out_file.start_scope(); @@ -1691,7 +1691,7 @@ private void write_selectable_item_scope() throws java.io.IOException private void write_deselected_snapshot_attributes() throws java.io.IOException { - interactive.SnapShot.Attributes attributes = this.board_handling.settings.get_snapshot_attributes(); + net.freerouting.interactive.SnapShot.Attributes attributes = this.board_handling.settings.get_snapshot_attributes(); out_file.start_scope(); out_file.write("deselected_snapshot_attributes "); if (!attributes.object_colors) @@ -1769,7 +1769,7 @@ private void write_deselected_snapshot_attributes() throws java.io.IOException private boolean read_deselected_snapshot_attributes() throws java.io.IOException { - interactive.SnapShot.Attributes attributes = this.board_handling.settings.get_snapshot_attributes(); + net.freerouting.interactive.SnapShot.Attributes attributes = this.board_handling.settings.get_snapshot_attributes(); for (;;) { Object next_token = this.scanner.next_token(); @@ -1879,8 +1879,8 @@ else if (curr_token == Keyword.CLOSED_BRACKET) return true; } - private final gui.BoardFrame board_frame; - private final interactive.BoardHandling board_handling; + private final net.freerouting.gui.BoardFrame board_frame; + private final net.freerouting.interactive.BoardHandling board_handling; /** Used, when reading a defaults file, null otherwise. */ private final GUIDefaultsScanner scanner; /** Used, when writing a defaults file; null otherwise. */ diff --git a/gui/GUIDefaultsScanner.java b/src/main/java/net/freerouting/gui/GUIDefaultsScanner.java similarity index 99% rename from gui/GUIDefaultsScanner.java rename to src/main/java/net/freerouting/gui/GUIDefaultsScanner.java index 18768e50..1eea23ba 100644 --- a/gui/GUIDefaultsScanner.java +++ b/src/main/java/net/freerouting/gui/GUIDefaultsScanner.java @@ -1,6 +1,6 @@ /* The following code was generated by JFlex 1.4 on 16.03.07 09:07 */ -package gui; +package net.freerouting.gui; @SuppressWarnings("all") /** diff --git a/gui/GUIDefaultsScanner.java~ b/src/main/java/net/freerouting/gui/GUIDefaultsScanner.java~ similarity index 100% rename from gui/GUIDefaultsScanner.java~ rename to src/main/java/net/freerouting/gui/GUIDefaultsScanner.java~ diff --git a/gui/MainApplication.java b/src/main/java/net/freerouting/gui/MainApplication.java similarity index 97% rename from gui/MainApplication.java rename to src/main/java/net/freerouting/gui/MainApplication.java index 115f2be7..f5703e36 100644 --- a/gui/MainApplication.java +++ b/src/main/java/net/freerouting/gui/MainApplication.java @@ -18,9 +18,9 @@ * Created on 19. Oktober 2002, 17:58 * */ -package gui; +package net.freerouting.gui; -import board.TestLevel; +import net.freerouting.board.TestLevel; /** * @@ -91,7 +91,7 @@ else if (p_args[i].startsWith("-test")) if (single_design_option) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.MainApplication", current_locale); + java.util.ResourceBundle.getBundle("net.freerouting.gui.MainApplication", current_locale); BoardFrame.Option board_option; if (session_file_option) { @@ -145,7 +145,7 @@ public MainApplication(String p_design_dir, boolean p_is_test_version, this.is_webstart = p_webstart_option; this.locale = p_current_locale; this.resources = - java.util.ResourceBundle.getBundle("gui.resources.MainApplication", p_current_locale); + java.util.ResourceBundle.getBundle("net.freerouting.gui.MainApplication", p_current_locale); main_panel = new javax.swing.JPanel(); getContentPane().add(main_panel); java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); @@ -320,7 +320,7 @@ static private BoardFrame create_board_frame(DesignFile p_design_file, javax.swi BoardFrame.Option p_option, boolean p_is_test_version, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.MainApplication", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.gui.MainApplication", p_locale); java.io.InputStream input_stream = p_design_file.get_input_stream(); if (input_stream == null) diff --git a/gui/PopupMenuChangeLayer.java b/src/main/java/net/freerouting/gui/PopupMenuChangeLayer.java similarity index 90% rename from gui/PopupMenuChangeLayer.java rename to src/main/java/net/freerouting/gui/PopupMenuChangeLayer.java index 8354b460..22df420a 100644 --- a/gui/PopupMenuChangeLayer.java +++ b/src/main/java/net/freerouting/gui/PopupMenuChangeLayer.java @@ -18,7 +18,7 @@ * Created on 17. Februar 2005, 08:58 */ -package gui; +package net.freerouting.gui; /** * Used as submenu in a popup menu for change layer actions. @@ -33,10 +33,10 @@ class PopupMenuChangeLayer extends javax.swing.JMenu { this.board_frame = p_board_frame; - board.LayerStructure layer_structure = board_frame.board_panel.board_handling.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = board_frame.board_panel.board_handling.get_routing_board().layer_structure; this.item_arr = new LayermenuItem[layer_structure.signal_layer_count()]; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); this.setText(resources.getString("change_layer")); this.setToolTipText(resources.getString("change_layer_tooltip")); @@ -80,7 +80,7 @@ private class LayermenuItem extends javax.swing.JMenuItem LayermenuItem(int p_layer_no) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", board_frame.get_locale()); message1 = resources.getString("layer_changed_to") + " "; layer_no = p_layer_no; addActionListener(new java.awt.event.ActionListener() diff --git a/gui/PopupMenuCopy.java b/src/main/java/net/freerouting/gui/PopupMenuCopy.java similarity index 87% rename from gui/PopupMenuCopy.java rename to src/main/java/net/freerouting/gui/PopupMenuCopy.java index d88e5c62..aeea4a66 100644 --- a/gui/PopupMenuCopy.java +++ b/src/main/java/net/freerouting/gui/PopupMenuCopy.java @@ -18,7 +18,7 @@ * Created on 17. Februar 2005, 08:20 */ -package gui; +package net.freerouting.gui; /** * Popup menu used in the interactive copy item state. @@ -32,7 +32,7 @@ public class PopupMenuCopy extends PopupMenuDisplay PopupMenuCopy(BoardFrame p_board_frame) { super(p_board_frame); - board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; if (layer_structure.arr.length > 0) { @@ -44,7 +44,7 @@ public class PopupMenuCopy extends PopupMenuDisplay change_layer_menu = null; } java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem insert_item = new javax.swing.JMenuItem(); insert_item.setText(resources.getString("insert")); insert_item.addActionListener(new java.awt.event.ActionListener() @@ -69,7 +69,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) this.add(done_item, 1); - board.Layer curr_layer = layer_structure.arr[board_panel.board_handling.settings.get_layer()]; + net.freerouting.board.Layer curr_layer = layer_structure.arr[board_panel.board_handling.settings.get_layer()]; disable_layer_item(layer_structure.get_signal_layer_no(curr_layer)); } diff --git a/gui/PopupMenuDisplay.java b/src/main/java/net/freerouting/gui/PopupMenuDisplay.java similarity index 95% rename from gui/PopupMenuDisplay.java rename to src/main/java/net/freerouting/gui/PopupMenuDisplay.java index cbcb4d6b..62d9d589 100644 --- a/gui/PopupMenuDisplay.java +++ b/src/main/java/net/freerouting/gui/PopupMenuDisplay.java @@ -22,7 +22,7 @@ * Open. You can then make changes to the template in the Source Editor. */ -package gui; +package net.freerouting.gui; /** * @@ -36,7 +36,7 @@ public PopupMenuDisplay(BoardFrame p_board_frame) { this.board_panel = p_board_frame.board_panel; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem center_display_item = new javax.swing.JMenuItem(); center_display_item.setText(resources.getString("center_display")); center_display_item.addActionListener(new java.awt.event.ActionListener() diff --git a/gui/PopupMenuDynamicRoute.java b/src/main/java/net/freerouting/gui/PopupMenuDynamicRoute.java similarity index 88% rename from gui/PopupMenuDynamicRoute.java rename to src/main/java/net/freerouting/gui/PopupMenuDynamicRoute.java index 8052c80b..354926be 100644 --- a/gui/PopupMenuDynamicRoute.java +++ b/src/main/java/net/freerouting/gui/PopupMenuDynamicRoute.java @@ -18,7 +18,7 @@ * Created on 17. Februar 2005, 07:08 */ -package gui; +package net.freerouting.gui; /** * Popup menu used in the interactive route state. @@ -34,8 +34,8 @@ public class PopupMenuDynamicRoute extends PopupMenuDisplay super(p_board_frame); java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); - board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); + net.freerouting.board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; javax.swing.JMenuItem end_route_item = new javax.swing.JMenuItem(); @@ -84,7 +84,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) this.change_layer_menu = null; } - board.Layer curr_layer = layer_structure.arr[board_panel.board_handling.settings.get_layer()]; + net.freerouting.board.Layer curr_layer = layer_structure.arr[board_panel.board_handling.settings.get_layer()]; disable_layer_item(layer_structure.get_signal_layer_no(curr_layer)); } diff --git a/gui/PopupMenuInsertCancel.java b/src/main/java/net/freerouting/gui/PopupMenuInsertCancel.java similarity index 93% rename from gui/PopupMenuInsertCancel.java rename to src/main/java/net/freerouting/gui/PopupMenuInsertCancel.java index ee02bd99..e173c15f 100644 --- a/gui/PopupMenuInsertCancel.java +++ b/src/main/java/net/freerouting/gui/PopupMenuInsertCancel.java @@ -18,7 +18,7 @@ * Created on 17. Februar 2005, 08:05 */ -package gui; +package net.freerouting.gui; /** * Popup menu containing the 2 items complete and cancel. @@ -33,7 +33,7 @@ class PopupMenuInsertCancel extends javax.swing.JPopupMenu { this.board_panel = p_board_frame.board_panel; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem insert_item = new javax.swing.JMenuItem(); insert_item.setText(resources.getString("insert")); insert_item.addActionListener(new java.awt.event.ActionListener() diff --git a/gui/PopupMenuMain.java b/src/main/java/net/freerouting/gui/PopupMenuMain.java similarity index 96% rename from gui/PopupMenuMain.java rename to src/main/java/net/freerouting/gui/PopupMenuMain.java index 8ead206f..7fed91a7 100644 --- a/gui/PopupMenuMain.java +++ b/src/main/java/net/freerouting/gui/PopupMenuMain.java @@ -18,7 +18,7 @@ * Created on 17. Februar 2005, 05:42 */ -package gui; +package net.freerouting.gui; /** * Popup Menu used in the interactive select state. @@ -33,7 +33,7 @@ class PopupMenuMain extends PopupMenuDisplay { super(p_board_frame) ; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.PopupMenuMain", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.PopupMenuMain", p_board_frame.get_locale()); // add the item for selecting items @@ -79,7 +79,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) } }); - if (board_panel.board_handling.get_routing_board().get_test_level() != board.TestLevel.RELEASE_VERSION) + if (board_panel.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { create_obstacle_menu.add(create_tile_item); } diff --git a/gui/PopupMenuMove.java b/src/main/java/net/freerouting/gui/PopupMenuMove.java similarity index 93% rename from gui/PopupMenuMove.java rename to src/main/java/net/freerouting/gui/PopupMenuMove.java index ba9462ee..3903fb08 100644 --- a/gui/PopupMenuMove.java +++ b/src/main/java/net/freerouting/gui/PopupMenuMove.java @@ -22,7 +22,7 @@ * Open. You can then make changes to the template in the Source Editor. */ -package gui; +package net.freerouting.gui; /** * @@ -36,7 +36,7 @@ public PopupMenuMove(BoardFrame p_board_frame) { super(p_board_frame); java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.PopupMenuMove", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.PopupMenuMove", p_board_frame.get_locale()); // Add menu for turning the items by a multiple of 90 degree @@ -139,10 +139,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) { - interactive.InteractiveState interactive_state = board_panel.board_handling.get_interactive_state(); - if (interactive_state instanceof interactive.MoveItemState) + net.freerouting.interactive.InteractiveState interactive_state = board_panel.board_handling.get_interactive_state(); + if (interactive_state instanceof net.freerouting.interactive.MoveItemState) { - ((interactive.MoveItemState)interactive_state).reset_rotation(); + ((net.freerouting.interactive.MoveItemState)interactive_state).reset_rotation(); } } }); diff --git a/gui/PopupMenuSelectedItems.java b/src/main/java/net/freerouting/gui/PopupMenuSelectedItems.java similarity index 91% rename from gui/PopupMenuSelectedItems.java rename to src/main/java/net/freerouting/gui/PopupMenuSelectedItems.java index 1b1a926f..e59d840f 100644 --- a/gui/PopupMenuSelectedItems.java +++ b/src/main/java/net/freerouting/gui/PopupMenuSelectedItems.java @@ -18,7 +18,7 @@ * Created on 17. Februar 2005, 07:47 */ -package gui; +package net.freerouting.gui; /** * Popup menu used in the interactive selected item state.. @@ -33,7 +33,7 @@ class PopupMenuSelectedItems extends PopupMenuDisplay { super(p_board_frame); java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem copy_item = new javax.swing.JMenuItem(); copy_item.setText(resources.getString("copy")); copy_item.addActionListener(new java.awt.event.ActionListener() @@ -44,7 +44,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) } }); - if (board_panel.board_handling.get_routing_board().get_test_level() != board.TestLevel.RELEASE_VERSION) + if (board_panel.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { this.add(copy_item); } diff --git a/gui/PopupMenuStitchRoute.java b/src/main/java/net/freerouting/gui/PopupMenuStitchRoute.java similarity index 88% rename from gui/PopupMenuStitchRoute.java rename to src/main/java/net/freerouting/gui/PopupMenuStitchRoute.java index f25a4219..ee9d290b 100644 --- a/gui/PopupMenuStitchRoute.java +++ b/src/main/java/net/freerouting/gui/PopupMenuStitchRoute.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; /** * @@ -32,7 +32,7 @@ public class PopupMenuStitchRoute extends PopupMenuDisplay public PopupMenuStitchRoute(BoardFrame p_board_frame) { super(p_board_frame); - board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; if (layer_structure.arr.length > 0) { @@ -44,7 +44,7 @@ public PopupMenuStitchRoute(BoardFrame p_board_frame) change_layer_menu = null; } java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem insert_item = new javax.swing.JMenuItem(); insert_item.setText(resources.getString("insert")); insert_item.addActionListener(new java.awt.event.ActionListener() @@ -81,7 +81,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) this.add(cancel_item, 2); - board.Layer curr_layer = layer_structure.arr[board_panel.board_handling.settings.get_layer()]; + net.freerouting.board.Layer curr_layer = layer_structure.arr[board_panel.board_handling.settings.get_layer()]; disable_layer_item(layer_structure.get_signal_layer_no(curr_layer)); } diff --git a/gui/PupupMenuCornerItemConstruction.java b/src/main/java/net/freerouting/gui/PupupMenuCornerItemConstruction.java similarity index 95% rename from gui/PupupMenuCornerItemConstruction.java rename to src/main/java/net/freerouting/gui/PupupMenuCornerItemConstruction.java index a1c5e993..afa3b9a4 100644 --- a/gui/PupupMenuCornerItemConstruction.java +++ b/src/main/java/net/freerouting/gui/PupupMenuCornerItemConstruction.java @@ -18,7 +18,7 @@ * Created on 17. Februar 2005, 07:31 */ -package gui; +package net.freerouting.gui; /** * Popup menu used while constructing a cornered shape.. @@ -33,7 +33,7 @@ class PupupMenuCornerItemConstruction extends javax.swing.JPopupMenu { this.board_panel = p_board_frame.board_panel; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem add_corner_item = new javax.swing.JMenuItem(); add_corner_item.setText(resources.getString("add_corner")); add_corner_item.addActionListener(new java.awt.event.ActionListener() diff --git a/gui/WebStart.java b/src/main/java/net/freerouting/gui/WebStart.java similarity index 99% rename from gui/WebStart.java rename to src/main/java/net/freerouting/gui/WebStart.java index 271b40c3..802378ef 100644 --- a/gui/WebStart.java +++ b/src/main/java/net/freerouting/gui/WebStart.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; /** * Function used for Java Websrart. diff --git a/gui/WindowAbout.java b/src/main/java/net/freerouting/gui/WindowAbout.java similarity index 95% rename from gui/WindowAbout.java rename to src/main/java/net/freerouting/gui/WindowAbout.java index 65357a1a..6dededb2 100644 --- a/gui/WindowAbout.java +++ b/src/main/java/net/freerouting/gui/WindowAbout.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; /** @@ -32,7 +32,7 @@ public class WindowAbout extends BoardSavableSubWindow public WindowAbout(java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowAbout", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowAbout", p_locale); this.setTitle(resources.getString("title")); final javax.swing.JPanel window_panel = new javax.swing.JPanel(); diff --git a/gui/WindowAssignNetClass.java b/src/main/java/net/freerouting/gui/WindowAssignNetClass.java similarity index 91% rename from gui/WindowAssignNetClass.java rename to src/main/java/net/freerouting/gui/WindowAssignNetClass.java index dac7f5b1..89059a0d 100644 --- a/gui/WindowAssignNetClass.java +++ b/src/main/java/net/freerouting/gui/WindowAssignNetClass.java @@ -19,10 +19,10 @@ * Created on 12. April 2005, 06:09 */ -package gui; +package net.freerouting.gui; -import rules.Net; -import rules.NetClass; +import net.freerouting.rules.Net; +import net.freerouting.rules.NetClass; /** * @@ -34,7 +34,7 @@ public class WindowAssignNetClass extends BoardSavableSubWindow /** Creates a new instance of AssignNetRulesWindow */ public WindowAssignNetClass(BoardFrame p_board_frame) { - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowAssignNetClass", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowAssignNetClass", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); this.board_frame = p_board_frame; @@ -61,7 +61,7 @@ public WindowAssignNetClass(BoardFrame p_board_frame) private void add_net_class_combo_box() { this.net_rule_combo_box = new javax.swing.JComboBox(); - board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); for(int i = 0; i < routing_board.rules.net_classes.count(); ++i) { net_rule_combo_box.addItem(routing_board.rules.net_classes.get(i)); @@ -136,7 +136,7 @@ public AssignRuleTableModel() column_names[0] = resources.getString("net_name"); column_names[1] = resources.getString("class_name"); - rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; + net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; data = new Object[board_rules.nets.max_net_no()][]; for (int i = 0; i < data.length; ++i) { @@ -148,7 +148,7 @@ public AssignRuleTableModel() /** Calculates the the valus in this table */ public void set_values() { - rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; + net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; Net[] sorted_arr = new Net[this.getRowCount()]; for (int i = 0; i < sorted_arr.length; ++i) { diff --git a/gui/WindowAutorouteDetailParameter.java b/src/main/java/net/freerouting/gui/WindowAutorouteDetailParameter.java similarity index 96% rename from gui/WindowAutorouteDetailParameter.java rename to src/main/java/net/freerouting/gui/WindowAutorouteDetailParameter.java index 0d1ee42d..c4e12053 100644 --- a/gui/WindowAutorouteDetailParameter.java +++ b/src/main/java/net/freerouting/gui/WindowAutorouteDetailParameter.java @@ -18,7 +18,7 @@ * Created on 25. Juli 2006, 08:17 * */ -package gui; +package net.freerouting.gui; /** * @@ -32,7 +32,7 @@ public WindowAutorouteDetailParameter(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowAutorouteParameter", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowAutorouteParameter", p_board_frame.get_locale()); this.setTitle(resources.getString("detail_autoroute_parameter")); // create main panel @@ -116,7 +116,7 @@ public WindowAutorouteDetailParameter(BoardFrame p_board_frame) speed_combo_box.addItem(this.speed_slow); speed_combo_box.addActionListener(new SpeedListener()); - if (this.board_handling.get_routing_board().get_test_level() != board.TestLevel.RELEASE_VERSION) + if (this.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { gridbag_constraints.gridwidth = 2; javax.swing.JLabel speed_label = new javax.swing.JLabel(); @@ -150,7 +150,7 @@ public WindowAutorouteDetailParameter(BoardFrame p_board_frame) gridbag.setConstraints(against_pref_dir_label, gridbag_constraints); main_panel.add(against_pref_dir_label); - board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; int signal_layer_count = layer_structure.signal_layer_count(); layer_name_arr = new javax.swing.JLabel[signal_layer_count]; preferred_direction_trace_cost_arr = new javax.swing.JFormattedTextField[signal_layer_count]; @@ -163,7 +163,7 @@ public WindowAutorouteDetailParameter(BoardFrame p_board_frame) for (int i = 0; i < signal_layer_count; ++i) { layer_name_arr[i] = new javax.swing.JLabel(); - board.Layer curr_signal_layer = layer_structure.get_signal_layer(i); + net.freerouting.board.Layer curr_signal_layer = layer_structure.get_signal_layer(i); layer_name_arr[i].setText(curr_signal_layer.name); gridbag_constraints.gridwidth = 3; gridbag.setConstraints(layer_name_arr[i], gridbag_constraints); @@ -197,8 +197,8 @@ public WindowAutorouteDetailParameter(BoardFrame p_board_frame) */ public void refresh() { - interactive.AutorouteSettings settings = this.board_handling.settings.autoroute_settings; - board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; + net.freerouting.interactive.AutorouteSettings settings = this.board_handling.settings.autoroute_settings; + net.freerouting.board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; this.via_cost_field.setValue(settings.get_via_costs()); this.plane_via_cost_field.setValue(settings.get_plane_via_costs()); this.start_ripup_costs.setValue(settings.get_start_ripup_costs()); @@ -212,7 +212,7 @@ public void refresh() this.against_preferred_direction_trace_cost_arr[i].setValue(settings.get_against_preferred_direction_trace_costs(layer_structure.get_layer_no(i))); } } - private final interactive.BoardHandling board_handling; + private final net.freerouting.interactive.BoardHandling board_handling; private final javax.swing.JFormattedTextField via_cost_field; private final javax.swing.JFormattedTextField plane_via_cost_field; private final javax.swing.JFormattedTextField start_ripup_costs; diff --git a/gui/WindowAutorouteParameter.java b/src/main/java/net/freerouting/gui/WindowAutorouteParameter.java similarity index 92% rename from gui/WindowAutorouteParameter.java rename to src/main/java/net/freerouting/gui/WindowAutorouteParameter.java index 450be440..2fa19baf 100644 --- a/gui/WindowAutorouteParameter.java +++ b/src/main/java/net/freerouting/gui/WindowAutorouteParameter.java @@ -18,7 +18,7 @@ * Created on 24. Juli 2006, 07:20 * */ -package gui; +package net.freerouting.gui; /** * Window handling parameters of the automatic routing. @@ -33,7 +33,7 @@ public WindowAutorouteParameter(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowAutorouteParameter", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowAutorouteParameter", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); @@ -65,7 +65,7 @@ public WindowAutorouteParameter(BoardFrame p_board_frame) this.horizontal = resources.getString("horizontal"); this.vertical = resources.getString("vertical"); - board.LayerStructure layer_structure = board_handling.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = board_handling.get_routing_board().layer_structure; int signal_layer_count = layer_structure.signal_layer_count(); signal_layer_name_arr = new javax.swing.JLabel[signal_layer_count]; signal_layer_active_arr = new javax.swing.JCheckBox[signal_layer_count]; @@ -73,7 +73,7 @@ public WindowAutorouteParameter(BoardFrame p_board_frame) for (int i = 0; i < signal_layer_count; ++i) { signal_layer_name_arr[i] = new javax.swing.JLabel(); - board.Layer curr_signal_layer = layer_structure.get_signal_layer(i); + net.freerouting.board.Layer curr_signal_layer = layer_structure.get_signal_layer(i); signal_layer_name_arr[i].setText(curr_signal_layer.name); gridbag_constraints.gridwidth = 3; gridbag.setConstraints(signal_layer_name_arr[i], gridbag_constraints); @@ -165,8 +165,8 @@ public WindowAutorouteParameter(BoardFrame p_board_frame) */ public void refresh() { - interactive.AutorouteSettings settings = this.board_handling.settings.autoroute_settings; - board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; + net.freerouting.interactive.AutorouteSettings settings = this.board_handling.settings.autoroute_settings; + net.freerouting.board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; this.vias_allowed.setSelected(settings.get_vias_allowed()); this.fanout_pass_button.setSelected(settings.get_with_fanout()); @@ -209,7 +209,7 @@ public void parent_deiconified() detail_window.parent_deiconified(); super.parent_deiconified(); } - private final interactive.BoardHandling board_handling; + private final net.freerouting.interactive.BoardHandling board_handling; private final javax.swing.JLabel[] signal_layer_name_arr; private final javax.swing.JCheckBox[] signal_layer_active_arr; private final javax.swing.JComboBox[] combo_box_arr; @@ -285,7 +285,7 @@ private class FanoutListener implements java.awt.event.ActionListener public void actionPerformed(java.awt.event.ActionEvent p_evt) { - interactive.AutorouteSettings autoroute_settings = board_handling.settings.autoroute_settings; + net.freerouting.interactive.AutorouteSettings autoroute_settings = board_handling.settings.autoroute_settings; autoroute_settings.set_with_fanout(fanout_pass_button.isSelected()); autoroute_settings.set_pass_no(1); } @@ -296,7 +296,7 @@ private class AutorouteListener implements java.awt.event.ActionListener public void actionPerformed(java.awt.event.ActionEvent p_evt) { - interactive.AutorouteSettings autoroute_settings = board_handling.settings.autoroute_settings; + net.freerouting.interactive.AutorouteSettings autoroute_settings = board_handling.settings.autoroute_settings; autoroute_settings.set_with_autoroute(autoroute_pass_button.isSelected()); autoroute_settings.set_pass_no(1); } @@ -307,7 +307,7 @@ private class PostrouteListener implements java.awt.event.ActionListener public void actionPerformed(java.awt.event.ActionEvent p_evt) { - interactive.AutorouteSettings autoroute_settings = board_handling.settings.autoroute_settings; + net.freerouting.interactive.AutorouteSettings autoroute_settings = board_handling.settings.autoroute_settings; autoroute_settings.set_with_postroute(postroute_pass_button.isSelected()); autoroute_settings.set_pass_no(1); } diff --git a/gui/WindowClearanceMatrix.java b/src/main/java/net/freerouting/gui/WindowClearanceMatrix.java similarity index 91% rename from gui/WindowClearanceMatrix.java rename to src/main/java/net/freerouting/gui/WindowClearanceMatrix.java index 56d1c579..474a8a52 100644 --- a/gui/WindowClearanceMatrix.java +++ b/src/main/java/net/freerouting/gui/WindowClearanceMatrix.java @@ -18,11 +18,11 @@ * Created on 20. Februar 2005, 06:09 */ -package gui; +package net.freerouting.gui; -import rules.ClearanceMatrix; +import net.freerouting.rules.ClearanceMatrix; -import datastructures.UndoableObjects; +import net.freerouting.datastructures.UndoableObjects; /** * Window for interactive editing of the clearance Matrix. @@ -36,7 +36,7 @@ public class WindowClearanceMatrix extends BoardSavableSubWindow public WindowClearanceMatrix(BoardFrame p_board_frame) { this.board_frame = p_board_frame; - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowClearanceMatrix", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowClearanceMatrix", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); @@ -52,7 +52,7 @@ public WindowClearanceMatrix(BoardFrame p_board_frame) layer_label.setToolTipText(resources.getString("layer_tooltip")); north_panel.add(layer_label); - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; layer_combo_box = new ComboBoxLayer(board_handling.get_routing_board().layer_structure, p_board_frame.get_locale()); north_panel.add(this.layer_combo_box); this.layer_combo_box.addActionListener(new ComboBoxListener()); @@ -96,7 +96,7 @@ public WindowClearanceMatrix(BoardFrame p_board_frame) */ public void refresh() { - board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); if (this.clearance_table_model.getRowCount() != routing_board.rules.clearance_matrix.get_class_count()) { this.adjust_clearance_table(); @@ -176,8 +176,8 @@ private void add_class() break; } } - final board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); - final rules.ClearanceMatrix clearance_matrix = routing_board.rules.clearance_matrix; + final net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); + final net.freerouting.rules.ClearanceMatrix clearance_matrix = routing_board.rules.clearance_matrix; // Check, if the name exists already. boolean name_exists = false; @@ -194,7 +194,7 @@ private void add_class() return; } clearance_matrix.append_class(new_name); - if (routing_board.get_test_level() == board.TestLevel.RELEASE_VERSION) + if (routing_board.get_test_level() == net.freerouting.board.TestLevel.RELEASE_VERSION) { // clearance compensation is only used, if there are only the clearance classes default and null. routing_board.search_tree_manager.set_clearance_compensation_used(false); @@ -207,7 +207,7 @@ private void add_class() */ private void prune_clearance_matrix() { - final board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); + final net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); ClearanceMatrix clearance_matrix = routing_board.rules.clearance_matrix; for (int i = clearance_matrix.get_class_count() - 1; i >= 2; --i) { @@ -224,7 +224,7 @@ private void prune_clearance_matrix() javax.swing.JOptionPane.showConfirmDialog(this, message, null, javax.swing.JOptionPane.YES_NO_OPTION); if (selected_option == javax.swing.JOptionPane.YES_OPTION) { - java.util.Collection board_items = routing_board.get_items(); + java.util.Collection board_items = routing_board.get_items(); routing_board.rules.change_clearance_class_no(i, j, board_items); if (!routing_board.rules.remove_clearance_class(i, board_items)) { @@ -278,7 +278,7 @@ private boolean is_legal_class_name(String p_string) private int max_name_length() { int result = 1; - rules.ClearanceMatrix clearance_matrix = board_frame.board_panel.board_handling.get_routing_board().rules.clearance_matrix; + net.freerouting.rules.ClearanceMatrix clearance_matrix = board_frame.board_panel.board_handling.get_routing_board().rules.clearance_matrix; for (int i = 0; i < clearance_matrix.get_class_count(); ++i) { result = Math.max(result, clearance_matrix.get_name(i).length()); @@ -326,9 +326,9 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) */ private class ClearanceTableModel extends javax.swing.table.AbstractTableModel implements java.io.Serializable { - public ClearanceTableModel(interactive.BoardHandling p_board_handling) + public ClearanceTableModel(net.freerouting.interactive.BoardHandling p_board_handling) { - rules.ClearanceMatrix clearance_matrix = p_board_handling.get_routing_board().rules.clearance_matrix; + net.freerouting.rules.ClearanceMatrix clearance_matrix = p_board_handling.get_routing_board().rules.clearance_matrix; column_names = new String[clearance_matrix.get_class_count() + 1]; column_names[0] = resources.getString("class"); @@ -393,14 +393,14 @@ public void setValueAt(Object p_value, int p_row, int p_col) // check, if there are items on the board assigned to clearance class i or j. - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; - datastructures.UndoableObjects item_list = board_handling.get_routing_board().item_list; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.datastructures.UndoableObjects item_list = board_handling.get_routing_board().item_list; boolean items_already_assigned_row = false; boolean items_already_assigned_column = false; java.util.Iterator it = item_list.start_read_object(); for(;;) { - board.Item curr_item = (board.Item) item_list.read_object(it); + net.freerouting.board.Item curr_item = (net.freerouting.board.Item) item_list.read_object(it); if (curr_item == null) { break; @@ -491,7 +491,7 @@ public Class getColumnClass(int p_col) */ private void set_values(int p_layer) { - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; ClearanceMatrix clearance_matrix = board_handling.get_routing_board().rules.clearance_matrix; for (int i = 0; i < clearance_matrix.get_class_count(); ++i) diff --git a/gui/WindowClearanceViolations.java b/src/main/java/net/freerouting/gui/WindowClearanceViolations.java similarity index 76% rename from gui/WindowClearanceViolations.java rename to src/main/java/net/freerouting/gui/WindowClearanceViolations.java index 5665fd8e..8a7b8dcc 100644 --- a/gui/WindowClearanceViolations.java +++ b/src/main/java/net/freerouting/gui/WindowClearanceViolations.java @@ -18,12 +18,12 @@ * Created on 22. Maerz 2005, 05:40 */ -package gui; +package net.freerouting.gui; -import geometry.planar.FloatPoint; -import board.ClearanceViolation; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.board.ClearanceViolation; -import interactive.ClearanceViolations; +import net.freerouting.interactive.ClearanceViolations; /** * @@ -36,7 +36,7 @@ public class WindowClearanceViolations extends WindowObjectListWithFilter public WindowClearanceViolations(BoardFrame p_board_frame) { super(p_board_frame); - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowClearanceViolations", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowClearanceViolations", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); this.list_empty_message.setText(resources.getString("list_empty_message")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_ClearanceViolations"); @@ -45,7 +45,7 @@ public WindowClearanceViolations(BoardFrame p_board_frame) protected void fill_list() { - interactive.BoardHandling board_handling = this.board_frame.board_panel.board_handling; + net.freerouting.interactive.BoardHandling board_handling = this.board_frame.board_panel.board_handling; ClearanceViolations clearance_violations = new ClearanceViolations(board_handling.get_routing_board().get_items()); @@ -68,7 +68,7 @@ protected void select_instances() { return; } - java.util.Set selected_items = new java.util.TreeSet(); + java.util.Set selected_items = new java.util.TreeSet(); for (int i = 0; i < selected_violations.length; ++i) { ClearanceViolation curr_violation = ((ViolationInfo) selected_violations[i]).violation; @@ -76,44 +76,44 @@ protected void select_instances() selected_items.add(curr_violation.second_item); } - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; board_handling.select_items(selected_items); board_handling.toggle_selected_item_violations(); board_handling.zoom_selection(); } - private String item_info(board.Item p_item) + private String item_info(net.freerouting.board.Item p_item) { String result; - if (p_item instanceof board.Pin) + if (p_item instanceof net.freerouting.board.Pin) { result = resources.getString("pin"); } - else if (p_item instanceof board.Via) + else if (p_item instanceof net.freerouting.board.Via) { result = resources.getString("via"); } - else if (p_item instanceof board.Trace) + else if (p_item instanceof net.freerouting.board.Trace) { result = resources.getString("trace"); } - else if (p_item instanceof board.ConductionArea) + else if (p_item instanceof net.freerouting.board.ConductionArea) { result = resources.getString("conduction_area"); } - else if (p_item instanceof board.ObstacleArea) + else if (p_item instanceof net.freerouting.board.ObstacleArea) { result = resources.getString("keepout"); } - else if (p_item instanceof board.ViaObstacleArea) + else if (p_item instanceof net.freerouting.board.ViaObstacleArea) { result = resources.getString("via_keepout"); } - else if (p_item instanceof board.ComponentObstacleArea) + else if (p_item instanceof net.freerouting.board.ComponentObstacleArea) { result = resources.getString("component_keepout"); } - else if (p_item instanceof board.BoardOutline) + else if (p_item instanceof net.freerouting.board.BoardOutline) { result = resources.getString("board_outline"); } @@ -137,14 +137,14 @@ public ViolationInfo(ClearanceViolation p_violation) public String toString() { - board.LayerStructure layer_structure = board_frame.board_panel.board_handling.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = board_frame.board_panel.board_handling.get_routing_board().layer_structure; String result = item_info(violation.first_item) + " - " + item_info(violation.second_item) + " " + resources.getString("at") + " " + location.to_string(board_frame.get_locale()) + " " + resources.getString("on_layer") + " " + layer_structure.arr[violation.layer].name; return result; } - public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale) + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { this.violation.print_info(p_window, p_locale); } diff --git a/gui/WindowComponents.java b/src/main/java/net/freerouting/gui/WindowComponents.java similarity index 78% rename from gui/WindowComponents.java rename to src/main/java/net/freerouting/gui/WindowComponents.java index d6a742d6..19a45222 100644 --- a/gui/WindowComponents.java +++ b/src/main/java/net/freerouting/gui/WindowComponents.java @@ -18,9 +18,9 @@ * Created on 8. Maerz 2005, 05:56 */ -package gui; -import board.Component; -import board.Components; +package net.freerouting.gui; +import net.freerouting.board.Component; +import net.freerouting.board.Components; /** * Window displaying the components on the board. @@ -35,7 +35,7 @@ public WindowComponents(BoardFrame p_board_frame) { super(p_board_frame); java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); this.setTitle(resources.getString("components")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_BoardComponents"); } @@ -66,14 +66,14 @@ protected void select_instances() { return; } - board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); - java.util.Set selected_items = new java.util.TreeSet(); - java.util.Collection board_items = routing_board.get_items(); - for (board.Item curr_item : board_items) + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + java.util.Set selected_items = new java.util.TreeSet(); + java.util.Collection board_items = routing_board.get_items(); + for (net.freerouting.board.Item curr_item : board_items) { if (curr_item.get_component_no() > 0) { - board.Component curr_component = routing_board.components.get(curr_item.get_component_no()); + net.freerouting.board.Component curr_component = routing_board.components.get(curr_item.get_component_no()); boolean component_matches = false; for (int i = 0; i < selected_components.length; ++i) { diff --git a/gui/WindowDisplayMisc.java b/src/main/java/net/freerouting/gui/WindowDisplayMisc.java similarity index 94% rename from gui/WindowDisplayMisc.java rename to src/main/java/net/freerouting/gui/WindowDisplayMisc.java index 0797a2c6..97128059 100644 --- a/gui/WindowDisplayMisc.java +++ b/src/main/java/net/freerouting/gui/WindowDisplayMisc.java @@ -18,7 +18,7 @@ * Created on 20. Dezember 2004, 08:23 */ -package gui; +package net.freerouting.gui; /** * Window for interactive changing of miscellanious display properties. @@ -33,7 +33,7 @@ public WindowDisplayMisc(BoardFrame p_board_frame) { this.panel = p_board_frame.board_panel; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.DisplayMisc", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.DisplayMisc", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); // Create main panel @@ -260,7 +260,7 @@ private class RotationNoneListener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - boardgraphics.CoordinateTransform coordinate_transform + net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; coordinate_transform.set_rotation(0); panel.repaint(); @@ -271,7 +271,7 @@ private class Rotation90Listener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - boardgraphics.CoordinateTransform coordinate_transform + net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; coordinate_transform.set_rotation(0.5 * Math.PI); panel.repaint(); @@ -282,7 +282,7 @@ private class Rotation180Listener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - boardgraphics.CoordinateTransform coordinate_transform + net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; coordinate_transform.set_rotation(Math.PI); panel.repaint(); @@ -293,7 +293,7 @@ private class Rotation270Listener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - boardgraphics.CoordinateTransform coordinate_transform + net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; coordinate_transform.set_rotation(1.5 * Math.PI); panel.repaint(); @@ -304,14 +304,14 @@ private class MirrorNoneListener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - boardgraphics.CoordinateTransform coordinate_transform + net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; if(!(coordinate_transform.is_mirror_left_right() || coordinate_transform.is_mirror_top_bottom())) { return; // mirroring already switched off } // remember the old viewort center to retain the displayed section of the board. - geometry.planar.FloatPoint old_viewport_center = + net.freerouting.geometry.planar.FloatPoint old_viewport_center = coordinate_transform.screen_to_board(panel.get_viewport_center()); coordinate_transform.set_mirror_left_right(false); coordinate_transform.set_mirror_top_bottom(false); @@ -325,14 +325,14 @@ private class VerticalMirrorListener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - boardgraphics.CoordinateTransform coordinate_transform + net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; if (coordinate_transform.is_mirror_left_right()) { return; // already mirrored } // remember the old viewort center to retain the displayed section of the board. - geometry.planar.FloatPoint old_viewport_center = + net.freerouting.geometry.planar.FloatPoint old_viewport_center = coordinate_transform.screen_to_board(panel.get_viewport_center()); coordinate_transform.set_mirror_left_right(true); coordinate_transform.set_mirror_top_bottom(false); @@ -345,14 +345,14 @@ private class HorizontalMirrorListener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - boardgraphics.CoordinateTransform coordinate_transform + net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; if (coordinate_transform.is_mirror_top_bottom()) { return; // already mirrored } // remember the old viewort center to retain the displayed section of the board. - geometry.planar.FloatPoint old_viewport_center = + net.freerouting.geometry.planar.FloatPoint old_viewport_center = coordinate_transform.screen_to_board(panel.get_viewport_center()); coordinate_transform.set_mirror_top_bottom(true); coordinate_transform.set_mirror_left_right(false); diff --git a/gui/WindowEditVias.java b/src/main/java/net/freerouting/gui/WindowEditVias.java similarity index 90% rename from gui/WindowEditVias.java rename to src/main/java/net/freerouting/gui/WindowEditVias.java index 1fa010a6..7fb68ea7 100644 --- a/gui/WindowEditVias.java +++ b/src/main/java/net/freerouting/gui/WindowEditVias.java @@ -18,11 +18,11 @@ * Created on 4. April 2005, 07:05 */ -package gui; +package net.freerouting.gui; -import rules.ViaInfo; -import rules.ViaInfos; -import rules.BoardRules; +import net.freerouting.rules.ViaInfo; +import net.freerouting.rules.ViaInfos; +import net.freerouting.rules.BoardRules; /** * Edit window for the table of available vias. @@ -35,7 +35,7 @@ public class WindowEditVias extends BoardSavableSubWindow /** Creates a new instance of ViaTablePanel */ public WindowEditVias(BoardFrame p_board_frame) { - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowEditVias", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowEditVias", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); this.board_frame = p_board_frame; @@ -96,7 +96,7 @@ private void add_table() private void add_combobox_items() { - board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); for (int i = 0; i < routing_board.rules.clearance_matrix.get_class_count(); ++i) { cl_class_combo_box.addItem(routing_board.rules.clearance_matrix.get_name(i)); @@ -140,7 +140,7 @@ private class AddViaListener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); ViaInfos via_infos = routing_board.rules.via_infos; Integer no = 1; String new_name = null; @@ -154,9 +154,9 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) } ++no; } - rules.NetClass default_net_class = routing_board.rules.get_default_net_class(); + net.freerouting.rules.NetClass default_net_class = routing_board.rules.get_default_net_class(); ViaInfo new_via = new ViaInfo(new_name, routing_board.library.get_via_padstack(0), - default_net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.VIA), + default_net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.VIA), false, routing_board.rules); via_infos.add(new_via); adjust_table(); @@ -185,7 +185,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; ViaInfo via_info = board_rules.via_infos.get((String) via_name); // Check, if via_info is used in a via rule. - for (rules.ViaRule curr_rule : board_rules.via_rules) + for (net.freerouting.rules.ViaRule curr_rule : board_rules.via_rules) { if (curr_rule.contains(via_info)) { @@ -217,7 +217,7 @@ public ViaTableModel() { column_names[i] = resources.getString((ColumnName.values()[i]).toString()); } - rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; + net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; data = new Object[board_rules.via_infos.count()][]; for (int i = 0; i < data.length; ++i) { @@ -229,7 +229,7 @@ public ViaTableModel() /** Calculates the the valus in this table */ public void set_values() { - rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; + net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; for (int i = 0; i < data.length; ++i) { ViaInfo curr_via = board_rules.via_infos.get(i); @@ -262,7 +262,7 @@ public Object getValueAt(int p_row, int p_col) public void setValueAt(Object p_value, int p_row, int p_col) { - board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); BoardRules board_rules = routing_board.rules; Object via_name = getValueAt(p_row, ColumnName.NAME.ordinal()); if (!(via_name instanceof String)) @@ -298,7 +298,7 @@ else if (p_col == ColumnName.PADSTACK.ordinal()) return; } String new_name = (String) p_value; - library.Padstack new_padstack = routing_board.library.get_via_padstack(new_name); + net.freerouting.library.Padstack new_padstack = routing_board.library.get_via_padstack(new_name); if (new_padstack == null) { System.out.println("ViaVindow.setValueAt: via padstack not found"); diff --git a/gui/WindowIncompletes.java b/src/main/java/net/freerouting/gui/WindowIncompletes.java similarity index 88% rename from gui/WindowIncompletes.java rename to src/main/java/net/freerouting/gui/WindowIncompletes.java index 44aefc53..cabad7fd 100644 --- a/gui/WindowIncompletes.java +++ b/src/main/java/net/freerouting/gui/WindowIncompletes.java @@ -18,9 +18,9 @@ * Created on 21. Maerz 2005, 05:30 */ -package gui; +package net.freerouting.gui; -import interactive.RatsNest; +import net.freerouting.interactive.RatsNest; /** * @@ -34,7 +34,7 @@ public WindowIncompletes(BoardFrame p_board_frame) { super(p_board_frame); java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); this.setTitle(resources.getString("incompletes")); this.list_empty_message.setText(resources.getString("route_completed")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_Incompletes"); @@ -64,7 +64,7 @@ protected void select_instances() { return; } - java.util.Set selected_items = new java.util.TreeSet(); + java.util.Set selected_items = new java.util.TreeSet(); for (int i = 0; i < selected_incompletes.length; ++i) { RatsNest.AirLine curr_airline = (RatsNest.AirLine) selected_incompletes[i]; diff --git a/gui/WindowLayerVisibility.java b/src/main/java/net/freerouting/gui/WindowLayerVisibility.java similarity index 88% rename from gui/WindowLayerVisibility.java rename to src/main/java/net/freerouting/gui/WindowLayerVisibility.java index 35eb5199..22930f95 100644 --- a/gui/WindowLayerVisibility.java +++ b/src/main/java/net/freerouting/gui/WindowLayerVisibility.java @@ -18,7 +18,7 @@ * Created on 5. November 2004, 11:29 */ -package gui; +package net.freerouting.gui; /** * Interactive Frame to adjust the visibility of the individual board layers @@ -32,10 +32,10 @@ public static WindowLayerVisibility get_instance(BoardFrame p_board_frame) { BoardPanel board_panel = p_board_frame.board_panel; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); String title = resources.getString("layer_visibility"); String header_message = resources.getString("layer_visibility_header"); - board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; String [] message_arr = new String [layer_structure.arr.length]; for (int i = 0; i < message_arr.length; ++i) { @@ -80,7 +80,7 @@ protected void set_all_minimum() */ public void refresh() { - boardgraphics.GraphicsContext graphics_context = this.get_board_handling().graphics_context; + net.freerouting.boardgraphics.GraphicsContext graphics_context = this.get_board_handling().graphics_context; for (int i = 0; i < graphics_context.layer_count(); ++i) { this.set_slider_value(i, graphics_context.get_raw_layer_visibility(i)); diff --git a/gui/WindowLengthViolations.java b/src/main/java/net/freerouting/gui/WindowLengthViolations.java similarity index 86% rename from gui/WindowLengthViolations.java rename to src/main/java/net/freerouting/gui/WindowLengthViolations.java index 67ff4fcb..b64ecfbc 100644 --- a/gui/WindowLengthViolations.java +++ b/src/main/java/net/freerouting/gui/WindowLengthViolations.java @@ -19,13 +19,13 @@ * */ -package gui; +package net.freerouting.gui; -import rules.Net; -import rules.Nets; -import rules.NetClass; +import net.freerouting.rules.Net; +import net.freerouting.rules.Nets; +import net.freerouting.rules.NetClass; -import interactive.RatsNest; +import net.freerouting.interactive.RatsNest; /** * @@ -38,7 +38,7 @@ public class WindowLengthViolations extends WindowObjectListWithFilter public WindowLengthViolations(BoardFrame p_board_frame) { super(p_board_frame); - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowLengthViolations", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowLengthViolations", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); this.list_empty_message.setText(resources.getString("list_empty")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_LengthViolations"); @@ -73,13 +73,13 @@ protected void select_instances() { return; } - java.util.Set selected_items = new java.util.TreeSet(); + java.util.Set selected_items = new java.util.TreeSet(); for (int i = 0; i < selected_violations.length; ++i) { LengthViolation curr_violation = ((LengthViolation) selected_violations[i]); selected_items.addAll(curr_violation.net.get_items()); } - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; board_handling.select_items(selected_items); board_handling.zoom_selection(); } @@ -101,7 +101,7 @@ public int compareTo(LengthViolation p_other) public String toString() { - board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; + net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; NetClass net_class = this.net.get_class(); Float allowed_length; String allowed_string; diff --git a/gui/WindowManualRules.java b/src/main/java/net/freerouting/gui/WindowManualRules.java similarity index 95% rename from gui/WindowManualRules.java rename to src/main/java/net/freerouting/gui/WindowManualRules.java index 3cf21eee..e5d9fbed 100644 --- a/gui/WindowManualRules.java +++ b/src/main/java/net/freerouting/gui/WindowManualRules.java @@ -17,7 +17,7 @@ * * Created on 18. November 2004, 09:08 */ -package gui; +package net.freerouting.gui; /** * Used for manual choice of trace widths in interactive routing. @@ -32,7 +32,7 @@ public WindowManualRules(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowManualRule", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowManualRule", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); // create main panel @@ -50,7 +50,7 @@ public WindowManualRules(BoardFrame p_board_frame) gridbag.setConstraints(via_rule_label, gridbag_constraints); main_panel.add(via_rule_label); - board.RoutingBoard routing_board = this.board_handling.get_routing_board(); + net.freerouting.board.RoutingBoard routing_board = this.board_handling.get_routing_board(); this.via_rule_combo_box = new javax.swing.JComboBox(routing_board.rules.via_rules); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag.setConstraints(this.via_rule_combo_box, gridbag_constraints); @@ -116,10 +116,10 @@ public WindowManualRules(BoardFrame p_board_frame) */ public void refresh() { - board.RoutingBoard routing_board = board_handling.get_routing_board(); + net.freerouting.board.RoutingBoard routing_board = board_handling.get_routing_board(); javax.swing.ComboBoxModel new_model = new javax.swing.DefaultComboBoxModel(routing_board.rules.via_rules); this.via_rule_combo_box.setModel(new_model); - rules.ClearanceMatrix clearance_matrix = board_handling.get_routing_board().rules.clearance_matrix; + net.freerouting.rules.ClearanceMatrix clearance_matrix = board_handling.get_routing_board().rules.clearance_matrix; if (this.clearance_combo_box.get_class_count() != routing_board.rules.clearance_matrix.get_class_count()) { this.clearance_combo_box.adjust(clearance_matrix); @@ -204,7 +204,7 @@ else if (p_layer.index == ComboBoxLayer.INNER_LAYER_INDEX) set_trace_width_field(curr_half_width); } - private final interactive.BoardHandling board_handling; + private final net.freerouting.interactive.BoardHandling board_handling; private final ComboBoxLayer layer_combo_box; private final ComboBoxClearance clearance_combo_box; private final javax.swing.JComboBox via_rule_combo_box; diff --git a/gui/WindowMessage.java b/src/main/java/net/freerouting/gui/WindowMessage.java similarity index 99% rename from gui/WindowMessage.java rename to src/main/java/net/freerouting/gui/WindowMessage.java index 0f81d755..b4629171 100644 --- a/gui/WindowMessage.java +++ b/src/main/java/net/freerouting/gui/WindowMessage.java @@ -18,7 +18,7 @@ * Created on 8. Dezember 2005, 06:20 * */ -package gui; +package net.freerouting.gui; /** * Startup window visible when the program is loading. diff --git a/gui/WindowMoveParameter.java b/src/main/java/net/freerouting/gui/WindowMoveParameter.java similarity index 97% rename from gui/WindowMoveParameter.java rename to src/main/java/net/freerouting/gui/WindowMoveParameter.java index 79fe9850..e082991c 100644 --- a/gui/WindowMoveParameter.java +++ b/src/main/java/net/freerouting/gui/WindowMoveParameter.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; /** * Window with the parameters for moving components. @@ -34,7 +34,7 @@ public WindowMoveParameter(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowMoveParameter", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowMoveParameter", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); // create main panel @@ -151,7 +151,7 @@ private void set_vertical_grid_field(double p_value) } - private final interactive.BoardHandling board_handling; + private final net.freerouting.interactive.BoardHandling board_handling; private final javax.swing.JFormattedTextField horizontal_grid_field; private final javax.swing.JFormattedTextField vertical_grid_field; private boolean key_input_completed = true; diff --git a/gui/WindowNetClasses.java b/src/main/java/net/freerouting/gui/WindowNetClasses.java similarity index 92% rename from gui/WindowNetClasses.java rename to src/main/java/net/freerouting/gui/WindowNetClasses.java index 69327cac..103717f1 100644 --- a/gui/WindowNetClasses.java +++ b/src/main/java/net/freerouting/gui/WindowNetClasses.java @@ -17,13 +17,13 @@ * * Created on 10. April 2005, 07:49 */ -package gui; +package net.freerouting.gui; -import rules.NetClass; -import rules.ViaRule; -import rules.BoardRules; +import net.freerouting.rules.NetClass; +import net.freerouting.rules.ViaRule; +import net.freerouting.rules.BoardRules; -import board.ObjectInfoPanel.Printable; +import net.freerouting.board.ObjectInfoPanel.Printable; /** * Edit window for the table of net rules. @@ -36,7 +36,7 @@ public class WindowNetClasses extends BoardSavableSubWindow /** Creates a new instance of NetClassesWindow */ public WindowNetClasses(BoardFrame p_board_frame) { - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowNetClasses", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowNetClasses", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); this.board_frame = p_board_frame; @@ -44,7 +44,7 @@ public WindowNetClasses(BoardFrame p_board_frame) this.main_panel = new javax.swing.JPanel(); this.main_panel.setLayout(new java.awt.BorderLayout()); - board.BasicBoard routing_board = p_board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.BasicBoard routing_board = p_board_frame.board_panel.board_handling.get_routing_board(); this.cl_class_combo_box = new javax.swing.JComboBox(); this.via_rule_combo_box = new javax.swing.JComboBox(); @@ -162,7 +162,7 @@ private void add_table() private void add_combobox_items() { - board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); for (int i = 0; i < routing_board.rules.clearance_matrix.get_class_count(); ++i) { cl_class_combo_box.addItem(routing_board.rules.clearance_matrix.get_name(i)); @@ -235,7 +235,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) // Check, if net_rule is used in a net of the net list for (int i = 1; i < board_rules.nets.max_net_no(); ++i) { - rules.Net curr_net = board_rules.nets.get(i); + net.freerouting.rules.Net curr_net = board_rules.nets.get(i); if (curr_net.get_class() == net_rule) { String message = resources.getString("message_2") + " " + curr_net.name; @@ -272,21 +272,21 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) { return; } - board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); NetClass[] selected_class_arr = new NetClass[selected_rows.length]; for (int i = 0; i < selected_class_arr.length; ++i) { selected_class_arr[i] = routing_board.rules.net_classes.get((String) table.getValueAt(selected_rows[i], ColumnName.NAME.ordinal())); } - rules.Nets nets = routing_board.rules.nets; - java.util.Set selected_items = new java.util.TreeSet(); - java.util.Collection board_items = routing_board.get_items(); - for (board.Item curr_item : board_items) + net.freerouting.rules.Nets nets = routing_board.rules.nets; + java.util.Set selected_items = new java.util.TreeSet(); + java.util.Collection board_items = routing_board.get_items(); + for (net.freerouting.board.Item curr_item : board_items) { boolean item_matches = false; for (int i = 0; i < curr_item.net_count(); ++i) { - rules.NetClass curr_net_class = nets.get(curr_item.get_net_no(i)).get_class(); + net.freerouting.rules.NetClass curr_net_class = nets.get(curr_item.get_net_no(i)).get_class(); if (curr_net_class == null) { continue; @@ -324,8 +324,8 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) { return; } - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; - rules.BoardRules board_rules = board_handling.get_routing_board().rules; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.rules.BoardRules board_rules = board_handling.get_routing_board().rules; NetClass[] selected_class_arr = new NetClass[selected_rows.length]; for (int i = 0; i < selected_class_arr.length; ++i) { @@ -360,8 +360,8 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) { return; } - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; - rules.BoardRules board_rules = board_handling.get_routing_board().rules; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.rules.BoardRules board_rules = board_handling.get_routing_board().rules; NetClass[] selected_class_arr = new NetClass[selected_rows.length]; for (int i = 0; i < selected_class_arr.length; ++i) { @@ -371,7 +371,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) int max_net_no = board_rules.nets.max_net_no(); for (int i = 1; i <= max_net_no; ++i) { - rules.Net curr_net = board_rules.nets.get(i); + net.freerouting.rules.Net curr_net = board_rules.nets.get(i); NetClass curr_net_class = curr_net.get_class(); for (int j = 0; j < selected_class_arr.length; ++j) { @@ -382,7 +382,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) } } } - board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; + net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; WindowObjectInfo new_window = WindowObjectInfo.display(resources.getString("contained_nets"), contained_nets, board_frame, coordinate_transform); java.awt.Point loc = getLocation(); @@ -448,7 +448,7 @@ public NetClassTableModel() /** Calculates the the valus in this table */ public void set_values() { - rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; + net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; this.data = new Object[board_rules.net_classes.count()][]; for (int i = 0; i < data.length; ++i) { @@ -489,8 +489,8 @@ public void set_values() void set_trace_width_field(int p_rule_no, ComboBoxLayer.Layer p_layer) { Float trace_width; - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; - rules.BoardRules board_rules = board_handling.get_routing_board().rules; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.rules.BoardRules board_rules = board_handling.get_routing_board().rules; NetClass curr_net_class = board_rules.net_classes.get(p_rule_no); if (p_layer.index == ComboBoxLayer.ALL_LAYER_INDEX) { @@ -517,7 +517,7 @@ else if (p_layer.index == ComboBoxLayer.INNER_LAYER_INDEX) else { int first_inner_signal_layer_no = 1; - board.LayerStructure layer_structure = board_handling.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = board_handling.get_routing_board().layer_structure; while (!layer_structure.arr[first_inner_signal_layer_no].is_signal) { ++first_inner_signal_layer_no; @@ -563,7 +563,7 @@ public Object getValueAt(int p_row, int p_col) public void setValueAt(Object p_value, int p_row, int p_col) { - board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); BoardRules board_rules = routing_board.rules; Object net_class_name = getValueAt(p_row, ColumnName.NAME.ordinal()); if (!(net_class_name instanceof String)) diff --git a/gui/WindowNetDemonstrations.java b/src/main/java/net/freerouting/gui/WindowNetDemonstrations.java similarity index 99% rename from gui/WindowNetDemonstrations.java rename to src/main/java/net/freerouting/gui/WindowNetDemonstrations.java index cb1624f2..45fffe08 100644 --- a/gui/WindowNetDemonstrations.java +++ b/src/main/java/net/freerouting/gui/WindowNetDemonstrations.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; import java.util.zip.ZipInputStream; diff --git a/gui/WindowNetSampleDesigns.java b/src/main/java/net/freerouting/gui/WindowNetSampleDesigns.java similarity index 98% rename from gui/WindowNetSampleDesigns.java rename to src/main/java/net/freerouting/gui/WindowNetSampleDesigns.java index 5c62049b..9c76f34b 100644 --- a/gui/WindowNetSampleDesigns.java +++ b/src/main/java/net/freerouting/gui/WindowNetSampleDesigns.java @@ -18,7 +18,7 @@ * Created on 14. November 2006, 10:13 * */ -package gui; +package net.freerouting.gui; /** * diff --git a/gui/WindowNetSamples.java b/src/main/java/net/freerouting/gui/WindowNetSamples.java similarity index 97% rename from gui/WindowNetSamples.java rename to src/main/java/net/freerouting/gui/WindowNetSamples.java index 6d32bb74..8e54e053 100644 --- a/gui/WindowNetSamples.java +++ b/src/main/java/net/freerouting/gui/WindowNetSamples.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; import java.util.zip.ZipInputStream; @@ -38,7 +38,7 @@ public abstract class WindowNetSamples extends BoardSubWindow public WindowNetSamples(java.util.Locale p_locale, String p_title, String p_button_name, int p_row_count) { this.locale = p_locale; - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowNetSamples", p_locale); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowNetSamples", p_locale); this.setTitle(resources.getString(p_title)); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE ); @@ -177,7 +177,7 @@ protected static BoardFrame open_design(String p_archive_name, String p_design_n } DesignFile design_file = DesignFile.get_instance("sharc_routed.dsn", true); BoardFrame new_frame = - new BoardFrame(design_file, BoardFrame.Option.WEBSTART, board.TestLevel.RELEASE_VERSION, + new BoardFrame(design_file, BoardFrame.Option.WEBSTART, net.freerouting.board.TestLevel.RELEASE_VERSION, p_locale, false); boolean read_ok = new_frame.read(zip_input_stream, true, null); if (!read_ok) diff --git a/gui/WindowNets.java b/src/main/java/net/freerouting/gui/WindowNets.java similarity index 82% rename from gui/WindowNets.java rename to src/main/java/net/freerouting/gui/WindowNets.java index f7943be8..2d73eed6 100644 --- a/gui/WindowNets.java +++ b/src/main/java/net/freerouting/gui/WindowNets.java @@ -18,10 +18,10 @@ * Created on 24. Maerz 2005, 07:41 */ -package gui; +package net.freerouting.gui; -import rules.Net; -import rules.Nets; +import net.freerouting.rules.Net; +import net.freerouting.rules.Nets; @@ -37,7 +37,7 @@ public class WindowNets extends WindowObjectListWithFilter public WindowNets(BoardFrame p_board_frame) { super(p_board_frame); - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowNets", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowNets", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); javax.swing.JPanel curr_button_panel = new javax.swing.JPanel(); @@ -86,10 +86,10 @@ protected void select_instances() { selected_net_numbers[i] = ((Net) selected_nets[i]).net_number; } - board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); - java.util.Set selected_items = new java.util.TreeSet(); - java.util.Collection board_items = routing_board.get_items(); - for (board.Item curr_item : board_items) + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + java.util.Set selected_items = new java.util.TreeSet(); + java.util.Collection board_items = routing_board.get_items(); + for (net.freerouting.board.Item curr_item : board_items) { boolean item_matches = false; for (int curr_net_no : selected_net_numbers) @@ -120,8 +120,8 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) { return; } - rules.NetClasses net_classes = board_frame.board_panel.board_handling.get_routing_board().rules.net_classes; - rules.NetClass [] class_arr = new rules.NetClass [net_classes.count()]; + net.freerouting.rules.NetClasses net_classes = board_frame.board_panel.board_handling.get_routing_board().rules.net_classes; + net.freerouting.rules.NetClass [] class_arr = new net.freerouting.rules.NetClass [net_classes.count()]; for(int i = 0; i < class_arr.length; ++i) { class_arr[i] = net_classes.get(i); @@ -129,11 +129,11 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) Object selected_value = javax.swing.JOptionPane.showInputDialog(null, resources.getString("message_1"), resources.getString("message_2"), javax.swing.JOptionPane.INFORMATION_MESSAGE, null, class_arr, class_arr[0]); - if (!(selected_value instanceof rules.NetClass)) + if (!(selected_value instanceof net.freerouting.rules.NetClass)) { return; } - rules.NetClass selected_class = (rules.NetClass) selected_value; + net.freerouting.rules.NetClass selected_class = (net.freerouting.rules.NetClass) selected_value; for (int i = 0; i < selected_nets.length; ++i) { ((Net) selected_nets[i]).set_class(selected_class); @@ -151,7 +151,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) { return; } - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; int max_net_no = board_handling.get_routing_board().rules.nets.max_net_no(); for (int i = 1; i <= max_net_no; ++i) { diff --git a/gui/WindowObjectInfo.java b/src/main/java/net/freerouting/gui/WindowObjectInfo.java similarity index 90% rename from gui/WindowObjectInfo.java rename to src/main/java/net/freerouting/gui/WindowObjectInfo.java index 3ebbda29..322da537 100644 --- a/gui/WindowObjectInfo.java +++ b/src/main/java/net/freerouting/gui/WindowObjectInfo.java @@ -18,7 +18,7 @@ * Created on 1. Januar 2005, 07:28 */ -package gui; +package net.freerouting.gui; import java.util.Collection; @@ -28,15 +28,15 @@ * * @author Alfons Wirtz */ -public class WindowObjectInfo extends BoardTemporarySubWindow implements board.ObjectInfoPanel +public class WindowObjectInfo extends BoardTemporarySubWindow implements net.freerouting.board.ObjectInfoPanel { /** * Displays a new ObjectInfoWindow with information about the items in p_item_list. * p_coordinate_transform is for transforming board to user coordinates, * and p_location is the location of the window. */ - public static void display(Collection p_item_list, - BoardFrame p_board_frame, board.CoordinateTransform p_coordinate_transform, java.awt.Point p_location) + public static void display(Collection p_item_list, + BoardFrame p_board_frame, net.freerouting.board.CoordinateTransform p_coordinate_transform, java.awt.Point p_location) { WindowObjectInfo new_instance = new WindowObjectInfo(p_board_frame, p_coordinate_transform); new_instance.setTitle(new_instance.resources.getString("title")); @@ -47,18 +47,18 @@ public static void display(Collection p_item_list, for (WindowObjectInfo.Printable curr_object : p_item_list) { curr_object.print_info(new_instance, p_board_frame.get_locale()); - if (curr_object instanceof board.Pin) + if (curr_object instanceof net.freerouting.board.Pin) { ++pin_count; } - else if (curr_object instanceof board.Via) + else if (curr_object instanceof net.freerouting.board.Via) { ++via_count; } - else if (curr_object instanceof board.Trace) + else if (curr_object instanceof net.freerouting.board.Trace) { ++trace_count; - cumulative_trace_length += ((board.Trace) curr_object).get_length(); + cumulative_trace_length += ((net.freerouting.board.Trace) curr_object).get_length(); } } new_instance.append_bold(new_instance.resources.getString("summary") + " "); @@ -128,7 +128,7 @@ else if (curr_object instanceof board.Trace) * and p_location is the location of the window. */ public static WindowObjectInfo display(String p_title, Collection p_object_list, - BoardFrame p_board_frame, board.CoordinateTransform p_coordinate_transform) + BoardFrame p_board_frame, net.freerouting.board.CoordinateTransform p_coordinate_transform) { WindowObjectInfo new_window = new WindowObjectInfo(p_board_frame, p_coordinate_transform); new_window.setTitle(p_title); @@ -153,11 +153,11 @@ public static WindowObjectInfo display(String p_title, Collection p_o } /** Creates a new instance of ItemInfoWindow */ - private WindowObjectInfo(BoardFrame p_board_frame, board.CoordinateTransform p_coordinate_transform) + private WindowObjectInfo(BoardFrame p_board_frame, net.freerouting.board.CoordinateTransform p_coordinate_transform) { super(p_board_frame); this.resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowObjectInfo", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowObjectInfo", p_board_frame.get_locale()); this.coordinate_transform = p_coordinate_transform; // create the text pane @@ -259,9 +259,9 @@ public boolean append_without_transforming(double p_value) * after transforming to the user coordinate sytem. * Returns false, if that was not possible. */ - public boolean append(geometry.planar.FloatPoint p_point) + public boolean append(net.freerouting.geometry.planar.FloatPoint p_point) { - geometry.planar.FloatPoint transformed_point = this.coordinate_transform.board_to_user(p_point); + net.freerouting.geometry.planar.FloatPoint transformed_point = this.coordinate_transform.board_to_user(p_point); return append(transformed_point.to_string(board_frame.get_locale())); } @@ -270,9 +270,9 @@ public boolean append(geometry.planar.FloatPoint p_point) * after transforming to the user coordinate sytem. * Returns false, if that was not possible. */ - public boolean append(geometry.planar.Shape p_shape, java.util.Locale p_locale) + public boolean append(net.freerouting.geometry.planar.Shape p_shape, java.util.Locale p_locale) { - board.PrintableShape transformed_shape = this.coordinate_transform.board_to_user(p_shape, p_locale); + net.freerouting.board.PrintableShape transformed_shape = this.coordinate_transform.board_to_user(p_shape, p_locale); if (transformed_shape == null) { return false; @@ -311,7 +311,7 @@ public boolean append( String p_button_name, String p_window_title, WindowObject * Appends a button for creating a new ObjectInfoWindow with the information * of p_items to the text pane. Returns false, if that was not possible. */ - public boolean append_items( String p_button_name, String p_window_title, java.util.Collection p_items) + public boolean append_items( String p_button_name, String p_window_title, java.util.Collection p_items) { java.util.Collection object_list = new java.util.LinkedList(); object_list.addAll(p_items); @@ -371,7 +371,7 @@ public void dispose() } private final javax.swing.JTextPane text_pane; - private final board.CoordinateTransform coordinate_transform; + private final net.freerouting.board.CoordinateTransform coordinate_transform; private final java.util.ResourceBundle resources; private final java.text.NumberFormat number_format; diff --git a/gui/WindowObjectList.java b/src/main/java/net/freerouting/gui/WindowObjectList.java similarity index 97% rename from gui/WindowObjectList.java rename to src/main/java/net/freerouting/gui/WindowObjectList.java index 058fbf10..ae6e2aed 100644 --- a/gui/WindowObjectList.java +++ b/src/main/java/net/freerouting/gui/WindowObjectList.java @@ -18,7 +18,7 @@ * Created on 7. Maerz 2005, 09:26 */ -package gui; +package net.freerouting.gui; /** * Abstract class for windows displaying a list of objects @@ -32,7 +32,7 @@ public abstract class WindowObjectList extends BoardSavableSubWindow public WindowObjectList(BoardFrame p_board_frame) { this.board_frame = p_board_frame; - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowObjectList", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowObjectList", p_board_frame.get_locale()); // create main panel this.main_panel = new javax.swing.JPanel(); @@ -195,7 +195,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) { object_list.add((WindowObjectInfo.Printable)(selected_objects[i])); } - board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; + net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; WindowObjectInfo new_window = WindowObjectInfo.display(resources.getString("window_title"), object_list, board_frame, coordinate_transform); java.awt.Point loc = getLocation(); diff --git a/gui/WindowObjectListWithFilter.java b/src/main/java/net/freerouting/gui/WindowObjectListWithFilter.java similarity index 96% rename from gui/WindowObjectListWithFilter.java rename to src/main/java/net/freerouting/gui/WindowObjectListWithFilter.java index 1443487d..8f2fc07b 100644 --- a/gui/WindowObjectListWithFilter.java +++ b/src/main/java/net/freerouting/gui/WindowObjectListWithFilter.java @@ -18,7 +18,7 @@ * Created on 24. Maerz 2005, 10:10 */ -package gui; +package net.freerouting.gui; /** * Abstract class for windows displaying a list of objects @@ -32,7 +32,7 @@ public WindowObjectListWithFilter(BoardFrame p_board_frame) { super(p_board_frame); java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowObjectList", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowObjectList", p_board_frame.get_locale()); javax.swing.JPanel input_panel = new javax.swing.JPanel(); this.south_panel.add(input_panel, java.awt.BorderLayout.SOUTH); diff --git a/gui/WindowObjectVisibility.java b/src/main/java/net/freerouting/gui/WindowObjectVisibility.java similarity index 86% rename from gui/WindowObjectVisibility.java rename to src/main/java/net/freerouting/gui/WindowObjectVisibility.java index 32fb1043..0e1382b3 100644 --- a/gui/WindowObjectVisibility.java +++ b/src/main/java/net/freerouting/gui/WindowObjectVisibility.java @@ -18,9 +18,9 @@ * Created on 7. November 2004, 07:38 */ -package gui; +package net.freerouting.gui; -import boardgraphics.ColorIntensityTable.ObjectNames; +import net.freerouting.boardgraphics.ColorIntensityTable.ObjectNames; /** * Interactive Frame to adjust the visibility of the individual board items @@ -33,7 +33,7 @@ public class WindowObjectVisibility extends WindowVisibility public static WindowObjectVisibility get_instance(BoardFrame p_board_frame) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowObjectVisibility", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowObjectVisibility", p_board_frame.get_locale()); String title = resources.getString("title"); String header_message = resources.getString("header_message"); String [] message_arr = new String [ObjectNames.values().length]; @@ -59,7 +59,7 @@ private WindowObjectVisibility(BoardFrame p_board_frame, String p_title, String */ public void refresh() { - boardgraphics.ColorIntensityTable color_intensity_table = this.get_board_handling().graphics_context.color_intensity_table; + net.freerouting.boardgraphics.ColorIntensityTable color_intensity_table = this.get_board_handling().graphics_context.color_intensity_table; for (int i = 0; i < ObjectNames.values().length; ++i) { this.set_slider_value(i, color_intensity_table.get_value(i)); diff --git a/gui/WindowPackages.java b/src/main/java/net/freerouting/gui/WindowPackages.java similarity index 79% rename from gui/WindowPackages.java rename to src/main/java/net/freerouting/gui/WindowPackages.java index a6e2676f..2deca7a3 100644 --- a/gui/WindowPackages.java +++ b/src/main/java/net/freerouting/gui/WindowPackages.java @@ -18,10 +18,10 @@ * Created on 7. Maerz 2005, 09:14 */ -package gui; +package net.freerouting.gui; -import library.Packages; -import library.Package; +import net.freerouting.library.Packages; +import net.freerouting.library.Package; /** * Window displaying the library packagess. @@ -36,7 +36,7 @@ public WindowPackages(BoardFrame p_board_frame) { super(p_board_frame); java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); this.setTitle(resources.getString("packages")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_LibraryPackages"); } @@ -67,14 +67,14 @@ protected void select_instances() { return; } - board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); - java.util.Set board_instances = new java.util.TreeSet(); - java.util.Collection board_items = routing_board.get_items(); - for (board.Item curr_item : board_items) + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + java.util.Set board_instances = new java.util.TreeSet(); + java.util.Collection board_items = routing_board.get_items(); + for (net.freerouting.board.Item curr_item : board_items) { if (curr_item.get_component_no() > 0) { - board.Component curr_component = routing_board.components.get(curr_item.get_component_no()); + net.freerouting.board.Component curr_component = routing_board.components.get(curr_item.get_component_no()); Package curr_package = curr_component.get_package(); boolean package_matches = false; for (int i = 0; i < selected_packages.length; ++i) diff --git a/gui/WindowPadstacks.java b/src/main/java/net/freerouting/gui/WindowPadstacks.java similarity index 76% rename from gui/WindowPadstacks.java rename to src/main/java/net/freerouting/gui/WindowPadstacks.java index ad7bc9d4..6377fd37 100644 --- a/gui/WindowPadstacks.java +++ b/src/main/java/net/freerouting/gui/WindowPadstacks.java @@ -18,12 +18,12 @@ * Created on 6. Maerz 2005, 06:47 */ -package gui; +package net.freerouting.gui; -import datastructures.UndoableObjects; +import net.freerouting.datastructures.UndoableObjects; -import library.Padstack; -import library.Padstacks; +import net.freerouting.library.Padstack; +import net.freerouting.library.Padstacks; /** * Window displaying the library padstacks. @@ -38,7 +38,7 @@ public WindowPadstacks(BoardFrame p_board_frame) { super(p_board_frame); java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); this.setTitle(resources.getString("padstacks")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_LibraryPadstacks"); } @@ -74,24 +74,24 @@ protected void select_instances() { padstack_list.add((Padstack)selected_padstacks[i]); } - board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); - java.util.Set board_instances = new java.util.TreeSet(); + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + java.util.Set board_instances = new java.util.TreeSet(); java.util.Iterator it = routing_board.item_list.start_read_object(); for(;;) { - datastructures.UndoableObjects.Storable curr_object = routing_board.item_list.read_object(it); + net.freerouting.datastructures.UndoableObjects.Storable curr_object = routing_board.item_list.read_object(it); if (curr_object == null) { break; } - if (curr_object instanceof board.DrillItem) + if (curr_object instanceof net.freerouting.board.DrillItem) { - library.Padstack curr_padstack = ((board.DrillItem) curr_object).get_padstack(); + net.freerouting.library.Padstack curr_padstack = ((net.freerouting.board.DrillItem) curr_object).get_padstack(); for (Padstack curr_selected_padstack : padstack_list) { if (curr_padstack == curr_selected_padstack) { - board_instances.add((board.Item)curr_object); + board_instances.add((net.freerouting.board.Item)curr_object); break; } } diff --git a/gui/WindowRouteDetail.java b/src/main/java/net/freerouting/gui/WindowRouteDetail.java similarity index 96% rename from gui/WindowRouteDetail.java rename to src/main/java/net/freerouting/gui/WindowRouteDetail.java index 9072458a..94510e66 100644 --- a/gui/WindowRouteDetail.java +++ b/src/main/java/net/freerouting/gui/WindowRouteDetail.java @@ -17,10 +17,9 @@ * * Created on 18. November 2004, 07:31 */ -package gui; +package net.freerouting.gui; -import board.BasicBoard; -import board.BoardOutline; +import net.freerouting.board.BoardOutline; /** * Window handling detail parameters of the interactive routing. @@ -35,7 +34,7 @@ public WindowRouteDetail(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowRouteDetail", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowRouteDetail", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); // create main panel @@ -137,7 +136,7 @@ public void refresh() int accuracy_slider_value = c_max_slider_value - this.board_handling.settings.get_trace_pull_tight_accuracy() / c_accuracy_scale_factor + 1; accuracy_slider.setValue(accuracy_slider_value); } - private final interactive.BoardHandling board_handling; + private final net.freerouting.interactive.BoardHandling board_handling; private final javax.swing.JSlider accuracy_slider; private final javax.swing.JRadioButton on_button; private final javax.swing.JRadioButton off_button; diff --git a/gui/WindowRouteParameter.java b/src/main/java/net/freerouting/gui/WindowRouteParameter.java similarity index 93% rename from gui/WindowRouteParameter.java rename to src/main/java/net/freerouting/gui/WindowRouteParameter.java index f87279ba..c9b3e26f 100644 --- a/gui/WindowRouteParameter.java +++ b/src/main/java/net/freerouting/gui/WindowRouteParameter.java @@ -18,7 +18,7 @@ * Created on 17. November 2004, 07:11 */ -package gui; +package net.freerouting.gui; import java.util.Collection; @@ -39,7 +39,7 @@ public WindowRouteParameter(BoardFrame p_board_frame) this.manual_rule_window = new WindowManualRules(p_board_frame); java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowRouteParameter", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowRouteParameter", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE ); @@ -264,7 +264,7 @@ public WindowRouteParameter(BoardFrame p_board_frame) this.detail_listener = new DetailListener(); detail_button.addActionListener(detail_listener); gridbag.setConstraints(detail_button, gridbag_constraints); - if (this.board_handling.get_routing_board().get_test_level() != board.TestLevel.RELEASE_VERSION) + if (this.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { main_panel.add(detail_button); } @@ -327,13 +327,13 @@ public void save(java.io.ObjectOutputStream p_object_stream) */ public void refresh() { - board.AngleRestriction snap_angle = this.board_handling.get_routing_board().rules.get_trace_angle_restriction(); + net.freerouting.board.AngleRestriction snap_angle = this.board_handling.get_routing_board().rules.get_trace_angle_restriction(); - if (snap_angle == board.AngleRestriction.NINETY_DEGREE) + if (snap_angle == net.freerouting.board.AngleRestriction.NINETY_DEGREE) { snap_angle_90_button.setSelected(true); } - else if (snap_angle == board.AngleRestriction.FORTYFIVE_DEGREE) + else if (snap_angle == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE) { snap_angle_45_button.setSelected(true); } @@ -425,7 +425,7 @@ private void set_pull_tight_region_width(int p_slider_value) } - private final interactive.BoardHandling board_handling; + private final net.freerouting.interactive.BoardHandling board_handling; private final java.util.Locale current_locale; final WindowManualRules manual_rule_window; final WindowRouteDetail detail_window; @@ -459,17 +459,17 @@ private class SnapAngle90Listener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - if (board_handling.get_routing_board().rules.get_trace_angle_restriction() == board.AngleRestriction.NINETY_DEGREE) + if (board_handling.get_routing_board().rules.get_trace_angle_restriction() == net.freerouting.board.AngleRestriction.NINETY_DEGREE) { return; } - Collection trace_list = board_handling.get_routing_board().get_traces(); + Collection trace_list = board_handling.get_routing_board().get_traces(); boolean free_angle_traces_found = false; - for (board.Trace curr_trace : trace_list) + for (net.freerouting.board.Trace curr_trace : trace_list) { - if (curr_trace instanceof board.PolylineTrace) + if (curr_trace instanceof net.freerouting.board.PolylineTrace) { - if (!((board.PolylineTrace)curr_trace).polyline().is_orthogonal()) + if (!((net.freerouting.board.PolylineTrace)curr_trace).polyline().is_orthogonal()) { free_angle_traces_found = true; break; @@ -479,7 +479,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) if (free_angle_traces_found) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowRouteParameter", current_locale); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowRouteParameter", current_locale); String curr_message = resources.getString("change_snap_angle_90"); if (!WindowMessage.confirm(curr_message)) { @@ -487,7 +487,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) return; } } - board_handling.set_current_snap_angle(board.AngleRestriction.NINETY_DEGREE); + board_handling.set_current_snap_angle(net.freerouting.board.AngleRestriction.NINETY_DEGREE); } } @@ -495,17 +495,17 @@ private class SnapAngle45Listener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - if (board_handling.get_routing_board().rules.get_trace_angle_restriction() == board.AngleRestriction.FORTYFIVE_DEGREE) + if (board_handling.get_routing_board().rules.get_trace_angle_restriction() == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE) { return; } - Collection trace_list = board_handling.get_routing_board().get_traces(); + Collection trace_list = board_handling.get_routing_board().get_traces(); boolean free_angle_traces_found = false; - for (board.Trace curr_trace : trace_list) + for (net.freerouting.board.Trace curr_trace : trace_list) { - if (curr_trace instanceof board.PolylineTrace) + if (curr_trace instanceof net.freerouting.board.PolylineTrace) { - if (!((board.PolylineTrace)curr_trace).polyline().is_multiple_of_45_degree()) + if (!((net.freerouting.board.PolylineTrace)curr_trace).polyline().is_multiple_of_45_degree()) { free_angle_traces_found = true; break; @@ -515,7 +515,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) if (free_angle_traces_found) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowRouteParameter", current_locale); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowRouteParameter", current_locale); String curr_message = resources.getString("change_snap_angle_45"); if (!WindowMessage.confirm(curr_message)) { @@ -523,7 +523,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) return; } } - board_handling.set_current_snap_angle(board.AngleRestriction.FORTYFIVE_DEGREE); + board_handling.set_current_snap_angle(net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE); } } @@ -531,7 +531,7 @@ private class SnapAngleNoneListener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - board_handling.set_current_snap_angle(board.AngleRestriction.NONE); + board_handling.set_current_snap_angle(net.freerouting.board.AngleRestriction.NONE); } } @@ -650,7 +650,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) { if (restrict_pin_exit_directions_check_box.isSelected()) { - rules.BoardRules board_rules = board_handling.get_routing_board().rules; + net.freerouting.rules.BoardRules board_rules = board_handling.get_routing_board().rules; double edge_to_turn_dist = board_handling.coordinate_transform.board_to_user(board_rules.get_min_trace_half_width()); board_handling.set_pin_edge_to_turn_dist(edge_to_turn_dist); diff --git a/gui/WindowRouteStubs.java b/src/main/java/net/freerouting/gui/WindowRouteStubs.java similarity index 84% rename from gui/WindowRouteStubs.java rename to src/main/java/net/freerouting/gui/WindowRouteStubs.java index fa30457b..12e24dd0 100644 --- a/gui/WindowRouteStubs.java +++ b/src/main/java/net/freerouting/gui/WindowRouteStubs.java @@ -19,17 +19,17 @@ * */ -package gui; +package net.freerouting.gui; import java.util.Collection; import java.util.Set; import java.util.SortedSet; import java.util.Iterator; -import datastructures.Signum; -import geometry.planar.FloatPoint; +import net.freerouting.datastructures.Signum; +import net.freerouting.geometry.planar.FloatPoint; -import board.Item; +import net.freerouting.board.Item; /** * @@ -42,7 +42,7 @@ public class WindowRouteStubs extends WindowObjectListWithFilter public WindowRouteStubs(BoardFrame p_board_frame) { super(p_board_frame); - this.resources = java.util.ResourceBundle.getBundle("gui.resources.CleanupWindows", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.CleanupWindows", p_board_frame.get_locale()); this.setTitle(resources.getString("route_stubs")); this.list_empty_message.setText(resources.getString("no_route_stubs_found")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_RouteStubs"); @@ -50,14 +50,14 @@ public WindowRouteStubs(BoardFrame p_board_frame) protected void fill_list() { - board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); SortedSet route_stub_info_set = new java.util.TreeSet(); Collection board_items = routing_board.get_items(); for (Item curr_item : board_items) { - if (!(curr_item instanceof board.Trace || curr_item instanceof board.Via)) + if (!(curr_item instanceof net.freerouting.board.Trace || curr_item instanceof net.freerouting.board.Via)) { continue; } @@ -68,7 +68,7 @@ protected void fill_list() FloatPoint stub_location; int stub_layer; - if (curr_item instanceof board.Via) + if (curr_item instanceof net.freerouting.board.Via) { Collection contact_list = curr_item.get_all_contacts(); if (contact_list.isEmpty()) @@ -106,11 +106,11 @@ protected void fill_list() stub_layer = first_contact_last_layer; } } - stub_location = ((board.Via)curr_item).get_center().to_float(); + stub_location = ((net.freerouting.board.Via)curr_item).get_center().to_float(); } else { - board.Trace curr_trace = (board.Trace) curr_item; + net.freerouting.board.Trace curr_trace = (net.freerouting.board.Trace) curr_item; if (curr_trace.get_start_contacts().isEmpty()) { stub_location = curr_trace.first_corner().to_float(); @@ -143,12 +143,12 @@ protected void select_instances() { return; } - Set selected_items = new java.util.TreeSet(); + Set selected_items = new java.util.TreeSet(); for (int i = 0; i < selected_list_values.length; ++i) { selected_items.add(((RouteStubInfo)selected_list_values[i]).stub_item); } - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; board_handling.select_items(selected_items); board_handling.zoom_selection(); } @@ -162,7 +162,7 @@ private class RouteStubInfo implements Comparable { public RouteStubInfo(Item p_stub, FloatPoint p_location, int p_layer_no) { - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; this.stub_item = p_stub; this.location = board_handling.coordinate_transform.board_to_user(p_location); this.layer_no = p_layer_no; @@ -173,7 +173,7 @@ public RouteStubInfo(Item p_stub, FloatPoint p_location, int p_layer_no) public String toString() { String item_string; - if (this.stub_item instanceof board.Trace) + if (this.stub_item instanceof net.freerouting.board.Trace) { item_string = resources.getString("trace"); } @@ -207,7 +207,7 @@ public int compareTo(RouteStubInfo p_other) } private final Item stub_item; - private final rules.Net net; + private final net.freerouting.rules.Net net; private final FloatPoint location; private final int layer_no; } diff --git a/gui/WindowSelectParameter.java b/src/main/java/net/freerouting/gui/WindowSelectParameter.java similarity index 93% rename from gui/WindowSelectParameter.java rename to src/main/java/net/freerouting/gui/WindowSelectParameter.java index 877519de..c2174f65 100644 --- a/gui/WindowSelectParameter.java +++ b/src/main/java/net/freerouting/gui/WindowSelectParameter.java @@ -18,9 +18,9 @@ * Created on 19. November 2004, 11:12 */ -package gui; +package net.freerouting.gui; -import board.ItemSelectionFilter; +import net.freerouting.board.ItemSelectionFilter; /** * Window for the handling of the interactive selection parameters, @@ -36,7 +36,7 @@ public WindowSelectParameter(BoardFrame p_board_frame) this.board_handling = p_board_frame.board_panel.board_handling; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowSelectParameter", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowSelectParameter", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); // create main panel @@ -101,7 +101,7 @@ public WindowSelectParameter(BoardFrame p_board_frame) // Create buttongroup for the current layer: - board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; int signal_layer_count = layer_structure.signal_layer_count(); javax.swing.JLabel current_layer_label = new javax.swing.JLabel(resources.getString("current_layer")); current_layer_label.setToolTipText(resources.getString("current_layer_tooltip")); @@ -113,7 +113,7 @@ public WindowSelectParameter(BoardFrame p_board_frame) gridbag_constraints.gridheight = 1; for (int i = 0; i < signal_layer_count; ++i) { - board.Layer curr_signal_layer = layer_structure.get_signal_layer(i); + net.freerouting.board.Layer curr_signal_layer = layer_structure.get_signal_layer(i); layer_name_arr[i] = new javax.swing.JRadioButton(); layer_name_arr[i].setText(curr_signal_layer.name); gridbag.setConstraints(layer_name_arr[i], gridbag_constraints); @@ -159,8 +159,8 @@ public void refresh() this.item_selection_choices[i].setSelected(item_selection_filter.is_selected(filter_values[i])) ; } } - board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; - board.Layer current_layer = layer_structure.arr[this.board_handling.settings.get_layer()]; + net.freerouting.board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; + net.freerouting.board.Layer current_layer = layer_structure.arr[this.board_handling.settings.get_layer()]; layer_name_arr[layer_structure.get_signal_layer_no(current_layer)].setSelected(true); } @@ -172,7 +172,7 @@ public void select(int p_signal_layer_no) layer_name_arr[p_signal_layer_no].setSelected(true); } - private final interactive.BoardHandling board_handling; + private final net.freerouting.interactive.BoardHandling board_handling; private final javax.swing.JRadioButton [] layer_name_arr; diff --git a/gui/WindowSnapshot.java b/src/main/java/net/freerouting/gui/WindowSnapshot.java similarity index 93% rename from gui/WindowSnapshot.java rename to src/main/java/net/freerouting/gui/WindowSnapshot.java index bccbfaea..bd128893 100644 --- a/gui/WindowSnapshot.java +++ b/src/main/java/net/freerouting/gui/WindowSnapshot.java @@ -18,7 +18,7 @@ * Created on 9. November 2004, 09:42 */ -package gui; +package net.freerouting.gui; /** * Window handling snapshots of the interactive situation. @@ -33,7 +33,7 @@ public WindowSnapshot(BoardFrame p_board_frame) { this.board_frame = p_board_frame; this.settings_window = new WindowSnapshotSettings(p_board_frame); - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowSnapshot", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowSnapshot", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE ); @@ -187,17 +187,17 @@ void goto_selected() int index = list.getSelectedIndex(); if (index >= 0 && list_model.getSize() > index) { - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; - interactive.SnapShot curr_snapshot = (interactive.SnapShot) list_model.elementAt(index); + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.interactive.SnapShot curr_snapshot = (net.freerouting.interactive.SnapShot) list_model.elementAt(index); curr_snapshot.go_to(board_handling); if (curr_snapshot.settings.get_snapshot_attributes().object_colors) { board_handling.graphics_context.item_color_table = - new boardgraphics.ItemColorTableModel(curr_snapshot.graphics_context.item_color_table); + new net.freerouting.boardgraphics.ItemColorTableModel(curr_snapshot.graphics_context.item_color_table); board_handling.graphics_context.other_color_table = - new boardgraphics.OtherColorTableModel(curr_snapshot.graphics_context.other_color_table); + new net.freerouting.boardgraphics.OtherColorTableModel(curr_snapshot.graphics_context.other_color_table); board_frame.color_manager.set_table_models(board_handling.graphics_context); } @@ -207,7 +207,7 @@ void goto_selected() java.awt.Point viewport_position = curr_snapshot.copy_viewport_position(); if (viewport_position != null) { - board_handling.graphics_context.coordinate_transform = new boardgraphics.CoordinateTransform(curr_snapshot.graphics_context.coordinate_transform); + board_handling.graphics_context.coordinate_transform = new net.freerouting.boardgraphics.CoordinateTransform(curr_snapshot.graphics_context.coordinate_transform); java.awt.Dimension panel_size = board_handling.graphics_context.get_panel_size(); board_frame.board_panel.setSize(panel_size); board_frame.board_panel.setPreferredSize(panel_size); @@ -243,7 +243,7 @@ private class AddListener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - interactive.SnapShot new_snapshot = interactive.SnapShot.get_instance(name_field.getText(), board_frame.board_panel.board_handling); + net.freerouting.interactive.SnapShot new_snapshot = net.freerouting.interactive.SnapShot.get_instance(name_field.getText(), board_frame.board_panel.board_handling); if (new_snapshot != null) { ++snapshot_count; diff --git a/gui/WindowSnapshotSettings.java b/src/main/java/net/freerouting/gui/WindowSnapshotSettings.java similarity index 97% rename from gui/WindowSnapshotSettings.java rename to src/main/java/net/freerouting/gui/WindowSnapshotSettings.java index 63e9640f..e4d54d0a 100644 --- a/gui/WindowSnapshotSettings.java +++ b/src/main/java/net/freerouting/gui/WindowSnapshotSettings.java @@ -19,7 +19,7 @@ * */ -package gui; +package net.freerouting.gui; /** * Window for the settinngs of interactive snapshots. @@ -35,7 +35,7 @@ public WindowSnapshotSettings(BoardFrame p_board_frame) this.board_handling = p_board_frame.board_panel.board_handling; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.WindowSnapshotSettings", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowSnapshotSettings", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); // create main panel @@ -193,7 +193,7 @@ public WindowSnapshotSettings(BoardFrame p_board_frame) */ public void refresh() { - interactive.SnapShot.Attributes attributes = this.board_handling.settings.get_snapshot_attributes(); + net.freerouting.interactive.SnapShot.Attributes attributes = this.board_handling.settings.get_snapshot_attributes(); this.object_color_check_box.setSelected(attributes.object_colors); this.object_visibility_check_box.setSelected(attributes.object_visibility); this.layer_visibility_check_box.setSelected(attributes.layer_visibility); @@ -211,7 +211,7 @@ public void refresh() info_list_filter_check_box.setSelected(attributes.info_list_selections); } - private final interactive.BoardHandling board_handling; + private final net.freerouting.interactive.BoardHandling board_handling; final javax.swing.JCheckBox object_color_check_box; final javax.swing.JCheckBox object_visibility_check_box; diff --git a/gui/WindowUnconnectedRoute.java b/src/main/java/net/freerouting/gui/WindowUnconnectedRoute.java similarity index 81% rename from gui/WindowUnconnectedRoute.java rename to src/main/java/net/freerouting/gui/WindowUnconnectedRoute.java index dbb6f83a..cb22183e 100644 --- a/gui/WindowUnconnectedRoute.java +++ b/src/main/java/net/freerouting/gui/WindowUnconnectedRoute.java @@ -19,13 +19,13 @@ * */ -package gui; +package net.freerouting.gui; import java.util.Collection; import java.util.Set; import java.util.SortedSet; -import board.Item; +import net.freerouting.board.Item; /** * @@ -38,7 +38,7 @@ public class WindowUnconnectedRoute extends WindowObjectListWithFilter public WindowUnconnectedRoute(BoardFrame p_board_frame) { super(p_board_frame); - this.resources = java.util.ResourceBundle.getBundle("gui.resources.CleanupWindows", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.CleanupWindows", p_board_frame.get_locale()); this.setTitle(resources.getString("unconnected_route")); this.list_empty_message.setText(resources.getString("no_unconnected_route_found")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_UnconnectedRoute"); @@ -46,7 +46,7 @@ public WindowUnconnectedRoute(BoardFrame p_board_frame) protected void fill_list() { - board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); Set handled_items = new java.util.TreeSet(); @@ -55,7 +55,7 @@ protected void fill_list() Collection board_items = routing_board.get_items(); for (Item curr_item : board_items) { - if (!(curr_item instanceof board.Trace || curr_item instanceof board.Via)) + if (!(curr_item instanceof net.freerouting.board.Trace || curr_item instanceof net.freerouting.board.Via)) { continue; } @@ -68,7 +68,7 @@ protected void fill_list() for (Item curr_connnected_item : curr_connected_set) { handled_items.add(curr_connnected_item); - if (!(curr_connnected_item instanceof board.Trace || curr_connnected_item instanceof board.Via)) + if (!(curr_connnected_item instanceof net.freerouting.board.Trace || curr_connnected_item instanceof net.freerouting.board.Via)) { terminal_item_found = true; } @@ -78,7 +78,7 @@ protected void fill_list() // We have found unconnnected route if (curr_item.net_count() == 1) { - rules.Net curr_net = routing_board.rules.nets.get(curr_item.get_net_no(0)); + net.freerouting.rules.Net curr_net = routing_board.rules.nets.get(curr_item.get_net_no(0)); if (curr_net != null) { UnconnectedRouteInfo curr_unconnected_route_info = @@ -107,12 +107,12 @@ protected void select_instances() { return; } - Set selected_items = new java.util.TreeSet(); + Set selected_items = new java.util.TreeSet(); for (int i = 0; i < selected_list_values.length; ++i) { selected_items.addAll(((UnconnectedRouteInfo)selected_list_values[i]).item_list); } - interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; board_handling.select_items(selected_items); board_handling.zoom_selection(); } @@ -125,7 +125,7 @@ protected void select_instances() */ private class UnconnectedRouteInfo implements Comparable { - public UnconnectedRouteInfo(rules.Net p_net, Collection p_item_list) + public UnconnectedRouteInfo(net.freerouting.rules.Net p_net, Collection p_item_list) { this.net = p_net; this.item_list = p_item_list; @@ -135,11 +135,11 @@ public UnconnectedRouteInfo(rules.Net p_net, Collection p_item_list) int curr_via_count = 0; for (Item curr_item: p_item_list) { - if (curr_item instanceof board.Trace) + if (curr_item instanceof net.freerouting.board.Trace) { ++curr_trace_count; } - else if (curr_item instanceof board.Via) + else if (curr_item instanceof net.freerouting.board.Via) { ++curr_via_count; } @@ -168,7 +168,7 @@ public int compareTo(UnconnectedRouteInfo p_other) return result; } - private final rules.Net net; + private final net.freerouting.rules.Net net; private final Collection item_list; private final int id_no; private final Integer trace_count; diff --git a/gui/WindowVia.java b/src/main/java/net/freerouting/gui/WindowVia.java similarity index 89% rename from gui/WindowVia.java rename to src/main/java/net/freerouting/gui/WindowVia.java index e1ea91f7..49c06a7a 100644 --- a/gui/WindowVia.java +++ b/src/main/java/net/freerouting/gui/WindowVia.java @@ -18,12 +18,12 @@ * Created on 31. Maerz 2005, 08:36 */ -package gui; +package net.freerouting.gui; -import rules.ViaRule; -import rules.BoardRules; +import net.freerouting.rules.ViaRule; +import net.freerouting.rules.BoardRules; -import board.Layer; +import net.freerouting.board.Layer; /** * Window for interactive editing of via rules. @@ -36,7 +36,7 @@ public class WindowVia extends BoardSavableSubWindow /** Creates a new instance of ViaWindow */ public WindowVia(BoardFrame p_board_frame) { - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowVia", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowVia", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); this.board_frame = p_board_frame; @@ -223,12 +223,12 @@ private class ShowPadstacksListener implements java.awt.event.ActionListener public void actionPerformed(java.awt.event.ActionEvent p_evt) { java.util.Collection object_list = new java.util.LinkedList(); - library.BoardLibrary board_library = board_frame.board_panel.board_handling.get_routing_board().library; + net.freerouting.library.BoardLibrary board_library = board_frame.board_panel.board_handling.get_routing_board().library; for (int i = 0; i < board_library.via_padstack_count(); ++i) { object_list.add( board_library.get_via_padstack(i)); } - board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; + net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; WindowObjectInfo new_window = WindowObjectInfo.display(resources.getString("available_via_padstacks"), object_list, board_frame, coordinate_transform); java.awt.Point loc = getLocation(); @@ -243,7 +243,7 @@ private class AddPadstackListener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - board.BasicBoard pcb = board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.board.BasicBoard pcb = board_frame.board_panel.board_handling.get_routing_board(); if (pcb.layer_structure.arr.length <= 1) { return; @@ -270,7 +270,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) } else { - Layer[] possible_start_layers = new board.Layer[pcb.layer_structure.arr.length - 1]; + Layer[] possible_start_layers = new net.freerouting.board.Layer[pcb.layer_structure.arr.length - 1]; for (int i = 0; i < possible_start_layers.length; ++i) { possible_start_layers[i] = pcb.layer_structure.arr[i]; @@ -291,7 +291,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) if (!layers_selected) { int first_possible_end_layer_no = pcb.layer_structure.get_no(start_layer) + 1; - Layer[] possible_end_layers = new board.Layer[pcb.layer_structure.arr.length - first_possible_end_layer_no]; + Layer[] possible_end_layers = new net.freerouting.board.Layer[pcb.layer_structure.arr.length - first_possible_end_layer_no]; for (int i = first_possible_end_layer_no; i < pcb.layer_structure.arr.length; ++i) { possible_end_layers[i - first_possible_end_layer_no] = pcb.layer_structure.arr[i]; @@ -332,8 +332,8 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) resources.getString("adjust_circles"), javax.swing.JOptionPane.PLAIN_MESSAGE); int from_layer_no = pcb.layer_structure.get_no(start_layer); int to_layer_no = pcb.layer_structure.get_no(end_layer); - geometry.planar.ConvexShape[] padstack_shapes = new geometry.planar.ConvexShape[pcb.layer_structure.arr.length]; - board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; + net.freerouting.geometry.planar.ConvexShape[] padstack_shapes = new net.freerouting.geometry.planar.ConvexShape[pcb.layer_structure.arr.length]; + net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; boolean shape_exists = false; for (int i = from_layer_no; i <= to_layer_no; ++i) { @@ -346,7 +346,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) int circle_radius = (int) Math.round(coordinate_transform.user_to_board(radius)); if (circle_radius > 0) { - padstack_shapes[i] = new geometry.planar.Circle(geometry.planar.Point.ZERO, circle_radius); + padstack_shapes[i] = new net.freerouting.geometry.planar.Circle(net.freerouting.geometry.planar.Point.ZERO, circle_radius); shape_exists = true; } } @@ -354,7 +354,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) { return; } - library.Padstack new_padstack = pcb.library.padstacks.add(padstack_name, padstack_shapes, true, true); + net.freerouting.library.Padstack new_padstack = pcb.library.padstacks.add(padstack_name, padstack_shapes, true, true); pcb.library.add_via_padstack(new_padstack); } } @@ -369,7 +369,7 @@ private class PadstackInputPanel extends javax.swing.JPanel this.setLayout(gridbag); java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); - board.LayerStructure layer_structure = board_frame.board_panel.board_handling.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = board_frame.board_panel.board_handling.get_routing_board().layer_structure; int from_layer_no = layer_structure.get_no(p_from_layer); int to_layer_no = layer_structure.get_no(p_to_layer); int layer_count = to_layer_no - from_layer_no + 1; @@ -401,8 +401,8 @@ private class RemovePadstackListener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent p_evt) { - board.BasicBoard pcb = board_frame.board_panel.board_handling.get_routing_board(); - library.Padstack[] via_padstacks = pcb.library.get_via_padstacks(); + net.freerouting.board.BasicBoard pcb = board_frame.board_panel.board_handling.get_routing_board(); + net.freerouting.library.Padstack[] via_padstacks = pcb.library.get_via_padstacks(); Object selected_value = javax.swing.JOptionPane.showInputDialog(null, resources.getString("choose_padstack_to_remove"), resources.getString("remove_via_padstack"), javax.swing.JOptionPane.INFORMATION_MESSAGE, null, via_padstacks, via_padstacks[0]); @@ -410,8 +410,8 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) { return; } - library.Padstack selected_padstack = (library.Padstack)selected_value; - rules.ViaInfo via_with_selected_padstack = null; + net.freerouting.library.Padstack selected_padstack = (net.freerouting.library.Padstack)selected_value; + net.freerouting.rules.ViaInfo via_with_selected_padstack = null; for (int i = 0; i < pcb.rules.via_infos.count(); ++i) { if (pcb.rules.via_infos.get(i).get_padstack() == selected_padstack) @@ -436,12 +436,12 @@ private class ShowViasListener implements java.awt.event.ActionListener public void actionPerformed(java.awt.event.ActionEvent p_evt) { java.util.Collection object_list = new java.util.LinkedList(); - rules.ViaInfos via_infos = board_frame.board_panel.board_handling.get_routing_board().rules.via_infos; + net.freerouting.rules.ViaInfos via_infos = board_frame.board_panel.board_handling.get_routing_board().rules.via_infos; for (int i = 0; i < via_infos.count(); ++i) { object_list.add(via_infos.get(i)); } - board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; + net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; WindowObjectInfo new_window = WindowObjectInfo.display(resources.getString("available_vias"), object_list, board_frame, coordinate_transform); java.awt.Point loc = getLocation(); @@ -474,7 +474,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) { object_list.add((WindowObjectInfo.Printable)(selected_objects[i])); } - board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; + net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; WindowObjectInfo new_window = WindowObjectInfo.display(resources.getString("selected_rule"), object_list, board_frame, coordinate_transform); java.awt.Point loc = getLocation(); @@ -494,7 +494,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) { return; } - rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; + net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; WindowViaRule new_window = new WindowViaRule((ViaRule) selected_object, board_rules.via_infos, board_frame); java.awt.Point loc = getLocation(); java.awt.Point new_window_location = @@ -519,7 +519,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) return; } ViaRule new_via_rule = new ViaRule(new_name); - rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; + net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; board_rules.via_rules.add(new_via_rule); rule_list_model.addElement(new_via_rule); board_frame.refresh_windows(); @@ -539,7 +539,7 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) String message = resources.getString("remove_via_rule") + " " + selected_rule.name + "?"; if (WindowMessage.confirm(message)) { - rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; + net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; board_rules.via_rules.remove(selected_rule); rule_list_model.removeElement(selected_rule); } diff --git a/gui/WindowViaRule.java b/src/main/java/net/freerouting/gui/WindowViaRule.java similarity index 96% rename from gui/WindowViaRule.java rename to src/main/java/net/freerouting/gui/WindowViaRule.java index 7a90ab71..7970dbf8 100644 --- a/gui/WindowViaRule.java +++ b/src/main/java/net/freerouting/gui/WindowViaRule.java @@ -18,11 +18,11 @@ * Created on 5. April 2005, 06:29 */ -package gui; +package net.freerouting.gui; -import rules.ViaRule; -import rules.ViaInfo; -import rules.ViaInfos; +import net.freerouting.rules.ViaRule; +import net.freerouting.rules.ViaInfo; +import net.freerouting.rules.ViaInfos; /** * Window for editing a single via rule. @@ -38,7 +38,7 @@ public WindowViaRule(ViaRule p_via_rule, ViaInfos p_via_list, BoardFrame p_board this.via_rule = p_via_rule; this.via_list = p_via_list; - this.resources = java.util.ResourceBundle.getBundle("gui.resources.WindowViaRule", p_board_frame.get_locale()); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowViaRule", p_board_frame.get_locale()); this.setTitle(resources.getString("title") + " " + p_via_rule.name); this.main_panel = new javax.swing.JPanel(); diff --git a/gui/WindowVisibility.java b/src/main/java/net/freerouting/gui/WindowVisibility.java similarity index 96% rename from gui/WindowVisibility.java rename to src/main/java/net/freerouting/gui/WindowVisibility.java index 5f3a0642..c2883658 100644 --- a/gui/WindowVisibility.java +++ b/src/main/java/net/freerouting/gui/WindowVisibility.java @@ -18,7 +18,7 @@ * Created on 7. November 2004, 11:29 */ -package gui; +package net.freerouting.gui; /** * Interactive Frame to adjust the visibility of a set of objects @@ -69,7 +69,7 @@ public WindowVisibility(BoardFrame p_board_frame, String p_title, String p_heade main_panel.add(empty_label); gridbag_constraints.gridwidth = 2; java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("gui.resources.Default", p_board_frame.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JButton min_all_button = new javax.swing.JButton(resources.getString("minimum_all")); min_all_button.setToolTipText(resources.getString("minimum_all_tooltip")); min_all_button.addActionListener(new MinAllButtonListener()); @@ -93,7 +93,7 @@ public void set_slider_value( int p_no, double p_value) slider_arr[p_no].setValue(visibility); } - protected interactive.BoardHandling get_board_handling() + protected net.freerouting.interactive.BoardHandling get_board_handling() { return board_panel.board_handling; } diff --git a/gui/package.html b/src/main/java/net/freerouting/gui/package.html similarity index 100% rename from gui/package.html rename to src/main/java/net/freerouting/gui/package.html diff --git a/helpset/de/Help.hs b/src/main/java/net/freerouting/helpset/de/Help.hs similarity index 100% rename from helpset/de/Help.hs rename to src/main/java/net/freerouting/helpset/de/Help.hs diff --git a/helpset/de/HelpIndex.xml b/src/main/java/net/freerouting/helpset/de/HelpIndex.xml similarity index 100% rename from helpset/de/HelpIndex.xml rename to src/main/java/net/freerouting/helpset/de/HelpIndex.xml diff --git a/helpset/de/HelpTOC.xml b/src/main/java/net/freerouting/helpset/de/HelpTOC.xml similarity index 100% rename from helpset/de/HelpTOC.xml rename to src/main/java/net/freerouting/helpset/de/HelpTOC.xml diff --git a/helpset/de/JavaHelpSearch/DOCS b/src/main/java/net/freerouting/helpset/de/JavaHelpSearch/DOCS similarity index 100% rename from helpset/de/JavaHelpSearch/DOCS rename to src/main/java/net/freerouting/helpset/de/JavaHelpSearch/DOCS diff --git a/helpset/de/JavaHelpSearch/DOCS.TAB b/src/main/java/net/freerouting/helpset/de/JavaHelpSearch/DOCS.TAB similarity index 100% rename from helpset/de/JavaHelpSearch/DOCS.TAB rename to src/main/java/net/freerouting/helpset/de/JavaHelpSearch/DOCS.TAB diff --git a/helpset/de/JavaHelpSearch/OFFSETS b/src/main/java/net/freerouting/helpset/de/JavaHelpSearch/OFFSETS similarity index 100% rename from helpset/de/JavaHelpSearch/OFFSETS rename to src/main/java/net/freerouting/helpset/de/JavaHelpSearch/OFFSETS diff --git a/helpset/de/JavaHelpSearch/POSITIONS b/src/main/java/net/freerouting/helpset/de/JavaHelpSearch/POSITIONS similarity index 100% rename from helpset/de/JavaHelpSearch/POSITIONS rename to src/main/java/net/freerouting/helpset/de/JavaHelpSearch/POSITIONS diff --git a/helpset/de/JavaHelpSearch/SCHEMA b/src/main/java/net/freerouting/helpset/de/JavaHelpSearch/SCHEMA similarity index 100% rename from helpset/de/JavaHelpSearch/SCHEMA rename to src/main/java/net/freerouting/helpset/de/JavaHelpSearch/SCHEMA diff --git a/helpset/de/JavaHelpSearch/TMAP b/src/main/java/net/freerouting/helpset/de/JavaHelpSearch/TMAP similarity index 100% rename from helpset/de/JavaHelpSearch/TMAP rename to src/main/java/net/freerouting/helpset/de/JavaHelpSearch/TMAP diff --git a/helpset/de/Map.jhm b/src/main/java/net/freerouting/helpset/de/Map.jhm similarity index 100% rename from helpset/de/Map.jhm rename to src/main/java/net/freerouting/helpset/de/Map.jhm diff --git a/helpset/de/html_files/FileMenu.html b/src/main/java/net/freerouting/helpset/de/html_files/FileMenu.html similarity index 100% rename from helpset/de/html_files/FileMenu.html rename to src/main/java/net/freerouting/helpset/de/html_files/FileMenu.html diff --git a/helpset/de/html_files/MenuState.html b/src/main/java/net/freerouting/helpset/de/html_files/MenuState.html similarity index 100% rename from helpset/de/html_files/MenuState.html rename to src/main/java/net/freerouting/helpset/de/html_files/MenuState.html diff --git a/helpset/de/html_files/MoveItemState.html b/src/main/java/net/freerouting/helpset/de/html_files/MoveItemState.html similarity index 100% rename from helpset/de/html_files/MoveItemState.html rename to src/main/java/net/freerouting/helpset/de/html_files/MoveItemState.html diff --git a/helpset/de/html_files/RouteState.html b/src/main/java/net/freerouting/helpset/de/html_files/RouteState.html similarity index 100% rename from helpset/de/html_files/RouteState.html rename to src/main/java/net/freerouting/helpset/de/html_files/RouteState.html diff --git a/helpset/de/html_files/SelectedItemState.html b/src/main/java/net/freerouting/helpset/de/html_files/SelectedItemState.html similarity index 100% rename from helpset/de/html_files/SelectedItemState.html rename to src/main/java/net/freerouting/helpset/de/html_files/SelectedItemState.html diff --git a/helpset/de/html_files/WindowAutorouteDetailParameter.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteDetailParameter.html similarity index 100% rename from helpset/de/html_files/WindowAutorouteDetailParameter.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteDetailParameter.html diff --git a/helpset/de/html_files/WindowAutorouteParameter.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteParameter.html similarity index 100% rename from helpset/de/html_files/WindowAutorouteParameter.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteParameter.html diff --git a/helpset/de/html_files/WindowClearanceMatrix.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowClearanceMatrix.html similarity index 100% rename from helpset/de/html_files/WindowClearanceMatrix.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowClearanceMatrix.html diff --git a/helpset/de/html_files/WindowDisplay.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowDisplay.html similarity index 100% rename from helpset/de/html_files/WindowDisplay.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowDisplay.html diff --git a/helpset/de/html_files/WindowManualRules.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowManualRules.html similarity index 100% rename from helpset/de/html_files/WindowManualRules.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowManualRules.html diff --git a/helpset/de/html_files/WindowMoveParameter.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowMoveParameter.html similarity index 100% rename from helpset/de/html_files/WindowMoveParameter.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowMoveParameter.html diff --git a/helpset/de/html_files/WindowNetClasses.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowNetClasses.html similarity index 100% rename from helpset/de/html_files/WindowNetClasses.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowNetClasses.html diff --git a/helpset/de/html_files/WindowObjectList.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowObjectList.html similarity index 100% rename from helpset/de/html_files/WindowObjectList.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowObjectList.html diff --git a/helpset/de/html_files/WindowRouteParameter.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowRouteParameter.html similarity index 100% rename from helpset/de/html_files/WindowRouteParameter.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowRouteParameter.html diff --git a/helpset/de/html_files/WindowSelectParameter.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowSelectParameter.html similarity index 100% rename from helpset/de/html_files/WindowSelectParameter.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowSelectParameter.html diff --git a/helpset/de/html_files/WindowSnapshots.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowSnapshots.html similarity index 100% rename from helpset/de/html_files/WindowSnapshots.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowSnapshots.html diff --git a/helpset/de/html_files/WindowVia.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowVia.html similarity index 100% rename from helpset/de/html_files/WindowVia.html rename to src/main/java/net/freerouting/helpset/de/html_files/WindowVia.html diff --git a/helpset/de/index.html b/src/main/java/net/freerouting/helpset/de/index.html similarity index 100% rename from helpset/de/index.html rename to src/main/java/net/freerouting/helpset/de/index.html diff --git a/helpset/en/Help.hs b/src/main/java/net/freerouting/helpset/en/Help.hs similarity index 100% rename from helpset/en/Help.hs rename to src/main/java/net/freerouting/helpset/en/Help.hs diff --git a/helpset/en/HelpIndex.xml b/src/main/java/net/freerouting/helpset/en/HelpIndex.xml similarity index 100% rename from helpset/en/HelpIndex.xml rename to src/main/java/net/freerouting/helpset/en/HelpIndex.xml diff --git a/helpset/en/HelpTOC.xml b/src/main/java/net/freerouting/helpset/en/HelpTOC.xml similarity index 100% rename from helpset/en/HelpTOC.xml rename to src/main/java/net/freerouting/helpset/en/HelpTOC.xml diff --git a/helpset/en/JavaHelpSearch/DOCS b/src/main/java/net/freerouting/helpset/en/JavaHelpSearch/DOCS similarity index 100% rename from helpset/en/JavaHelpSearch/DOCS rename to src/main/java/net/freerouting/helpset/en/JavaHelpSearch/DOCS diff --git a/helpset/en/JavaHelpSearch/DOCS.TAB b/src/main/java/net/freerouting/helpset/en/JavaHelpSearch/DOCS.TAB similarity index 100% rename from helpset/en/JavaHelpSearch/DOCS.TAB rename to src/main/java/net/freerouting/helpset/en/JavaHelpSearch/DOCS.TAB diff --git a/helpset/en/JavaHelpSearch/OFFSETS b/src/main/java/net/freerouting/helpset/en/JavaHelpSearch/OFFSETS similarity index 100% rename from helpset/en/JavaHelpSearch/OFFSETS rename to src/main/java/net/freerouting/helpset/en/JavaHelpSearch/OFFSETS diff --git a/helpset/en/JavaHelpSearch/POSITIONS b/src/main/java/net/freerouting/helpset/en/JavaHelpSearch/POSITIONS similarity index 100% rename from helpset/en/JavaHelpSearch/POSITIONS rename to src/main/java/net/freerouting/helpset/en/JavaHelpSearch/POSITIONS diff --git a/helpset/en/JavaHelpSearch/SCHEMA b/src/main/java/net/freerouting/helpset/en/JavaHelpSearch/SCHEMA similarity index 100% rename from helpset/en/JavaHelpSearch/SCHEMA rename to src/main/java/net/freerouting/helpset/en/JavaHelpSearch/SCHEMA diff --git a/helpset/en/JavaHelpSearch/TMAP b/src/main/java/net/freerouting/helpset/en/JavaHelpSearch/TMAP similarity index 100% rename from helpset/en/JavaHelpSearch/TMAP rename to src/main/java/net/freerouting/helpset/en/JavaHelpSearch/TMAP diff --git a/helpset/en/Map.jhm b/src/main/java/net/freerouting/helpset/en/Map.jhm similarity index 100% rename from helpset/en/Map.jhm rename to src/main/java/net/freerouting/helpset/en/Map.jhm diff --git a/helpset/en/html_files/FileMenu.html b/src/main/java/net/freerouting/helpset/en/html_files/FileMenu.html similarity index 100% rename from helpset/en/html_files/FileMenu.html rename to src/main/java/net/freerouting/helpset/en/html_files/FileMenu.html diff --git a/helpset/en/html_files/MenuState.html b/src/main/java/net/freerouting/helpset/en/html_files/MenuState.html similarity index 100% rename from helpset/en/html_files/MenuState.html rename to src/main/java/net/freerouting/helpset/en/html_files/MenuState.html diff --git a/helpset/en/html_files/MoveItemState.html b/src/main/java/net/freerouting/helpset/en/html_files/MoveItemState.html similarity index 100% rename from helpset/en/html_files/MoveItemState.html rename to src/main/java/net/freerouting/helpset/en/html_files/MoveItemState.html diff --git a/helpset/en/html_files/RouteState.html b/src/main/java/net/freerouting/helpset/en/html_files/RouteState.html similarity index 100% rename from helpset/en/html_files/RouteState.html rename to src/main/java/net/freerouting/helpset/en/html_files/RouteState.html diff --git a/helpset/en/html_files/SelectedItemState.html b/src/main/java/net/freerouting/helpset/en/html_files/SelectedItemState.html similarity index 100% rename from helpset/en/html_files/SelectedItemState.html rename to src/main/java/net/freerouting/helpset/en/html_files/SelectedItemState.html diff --git a/helpset/en/html_files/WindowAutorouteDetailParameter.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteDetailParameter.html similarity index 100% rename from helpset/en/html_files/WindowAutorouteDetailParameter.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteDetailParameter.html diff --git a/helpset/en/html_files/WindowAutorouteParameter.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteParameter.html similarity index 100% rename from helpset/en/html_files/WindowAutorouteParameter.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteParameter.html diff --git a/helpset/en/html_files/WindowClearanceMatrix.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowClearanceMatrix.html similarity index 100% rename from helpset/en/html_files/WindowClearanceMatrix.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowClearanceMatrix.html diff --git a/helpset/en/html_files/WindowDisplay.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowDisplay.html similarity index 100% rename from helpset/en/html_files/WindowDisplay.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowDisplay.html diff --git a/helpset/en/html_files/WindowManualRules.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowManualRules.html similarity index 100% rename from helpset/en/html_files/WindowManualRules.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowManualRules.html diff --git a/helpset/en/html_files/WindowMoveParameter.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowMoveParameter.html similarity index 100% rename from helpset/en/html_files/WindowMoveParameter.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowMoveParameter.html diff --git a/helpset/en/html_files/WindowNetClasses.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowNetClasses.html similarity index 100% rename from helpset/en/html_files/WindowNetClasses.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowNetClasses.html diff --git a/helpset/en/html_files/WindowObjectList.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowObjectList.html similarity index 100% rename from helpset/en/html_files/WindowObjectList.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowObjectList.html diff --git a/helpset/en/html_files/WindowRouteParameter.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowRouteParameter.html similarity index 100% rename from helpset/en/html_files/WindowRouteParameter.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowRouteParameter.html diff --git a/helpset/en/html_files/WindowSelectParameter.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowSelectParameter.html similarity index 100% rename from helpset/en/html_files/WindowSelectParameter.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowSelectParameter.html diff --git a/helpset/en/html_files/WindowSnapshots.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowSnapshots.html similarity index 100% rename from helpset/en/html_files/WindowSnapshots.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowSnapshots.html diff --git a/helpset/en/html_files/WindowVia.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowVia.html similarity index 100% rename from helpset/en/html_files/WindowVia.html rename to src/main/java/net/freerouting/helpset/en/html_files/WindowVia.html diff --git a/helpset/en/images/popup.gif b/src/main/java/net/freerouting/helpset/en/images/popup.gif similarity index 100% rename from helpset/en/images/popup.gif rename to src/main/java/net/freerouting/helpset/en/images/popup.gif diff --git a/helpset/en/index.html b/src/main/java/net/freerouting/helpset/en/index.html similarity index 100% rename from helpset/en/index.html rename to src/main/java/net/freerouting/helpset/en/index.html diff --git a/interactive/AutorouteSettings.java b/src/main/java/net/freerouting/interactive/AutorouteSettings.java similarity index 98% rename from interactive/AutorouteSettings.java rename to src/main/java/net/freerouting/interactive/AutorouteSettings.java index 8cbdf81c..20da8002 100644 --- a/interactive/AutorouteSettings.java +++ b/src/main/java/net/freerouting/interactive/AutorouteSettings.java @@ -18,10 +18,10 @@ * Created on 27. Juli 2006, 09:16 * */ -package interactive; +package net.freerouting.interactive; -import board.RoutingBoard; -import autoroute.AutorouteControl.ExpansionCostFactor; +import net.freerouting.board.RoutingBoard; +import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; /** * Contains the interactive settings for the autorouter. diff --git a/interactive/BatchAutorouterThread.java b/src/main/java/net/freerouting/interactive/BatchAutorouterThread.java similarity index 89% rename from interactive/BatchAutorouterThread.java rename to src/main/java/net/freerouting/interactive/BatchAutorouterThread.java index efa99661..41cb8eae 100644 --- a/interactive/BatchAutorouterThread.java +++ b/src/main/java/net/freerouting/interactive/BatchAutorouterThread.java @@ -18,16 +18,16 @@ * Created on 25. April 2006, 07:58 * */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; -import geometry.planar.FloatLine; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatLine; -import board.Unit; +import net.freerouting.board.Unit; -import autoroute.BatchAutorouter; -import autoroute.BatchFanout; -import autoroute.BatchOptRoute; +import net.freerouting.autoroute.BatchAutorouter; +import net.freerouting.autoroute.BatchFanout; +import net.freerouting.autoroute.BatchOptRoute; /** * Thread for the batch autorouter. @@ -52,7 +52,7 @@ protected void thread_action() try { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("interactive.resources.InteractiveState", hdlg.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", hdlg.get_locale()); boolean saved_board_read_only = hdlg.is_board_read_only(); hdlg.set_board_read_only(true); boolean ratsnest_hidden_before = hdlg.get_ratsnest().is_hidden(); @@ -117,9 +117,9 @@ protected void thread_action() } hdlg.get_panel().board_frame.refresh_windows(); - if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == board.AngleRestriction.FORTYFIVE_DEGREE && hdlg.get_routing_board().get_test_level() != board.TestLevel.RELEASE_VERSION) + if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE && hdlg.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { - tests.Validate.multiple_of_45_degree("after autoroute: ", hdlg.get_routing_board()); + net.freerouting.tests.Validate.multiple_of_45_degree("after autoroute: ", hdlg.get_routing_board()); } } catch (Exception e) { diff --git a/interactive/BoardHandling.java b/src/main/java/net/freerouting/interactive/BoardHandling.java similarity index 95% rename from interactive/BoardHandling.java rename to src/main/java/net/freerouting/interactive/BoardHandling.java index c0d58f7c..2a6cdd48 100644 --- a/interactive/BoardHandling.java +++ b/src/main/java/net/freerouting/interactive/BoardHandling.java @@ -18,7 +18,7 @@ * Created on 5. November 2003, 13:02 * */ -package interactive; +package net.freerouting.interactive; import java.awt.Dimension; import java.awt.Graphics; @@ -31,25 +31,25 @@ import java.util.Collection; import java.util.Set; -import geometry.planar.FloatPoint; -import geometry.planar.IntBox; -import geometry.planar.IntPoint; -import geometry.planar.PolylineShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.PolylineShape; -import rules.BoardRules; -import board.LayerStructure; -import board.RoutingBoard; -import board.Item; -import board.PolylineTrace; -import board.FixedState; -import board.ItemSelectionFilter; +import net.freerouting.rules.BoardRules; +import net.freerouting.board.LayerStructure; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.Item; +import net.freerouting.board.PolylineTrace; +import net.freerouting.board.FixedState; +import net.freerouting.board.ItemSelectionFilter; -import boardgraphics.GraphicsContext; -import board.CoordinateTransform; -import board.Unit; -import board.TestLevel; +import net.freerouting.boardgraphics.GraphicsContext; +import net.freerouting.board.CoordinateTransform; +import net.freerouting.board.Unit; +import net.freerouting.board.TestLevel; -import designformats.specctra.DsnFile; +import net.freerouting.designformats.specctra.DsnFile; /** * @@ -64,14 +64,14 @@ public class BoardHandling /** * Creates a new BoardHandling */ - public BoardHandling(gui.BoardPanel p_panel, java.util.Locale p_locale) + public BoardHandling(net.freerouting.gui.BoardPanel p_panel, java.util.Locale p_locale) { this.locale = p_locale; this.panel = p_panel; this.screen_messages = p_panel.screen_messages; this.logfile = new Logfile(); this.set_interactive_state(SelectMenuState.get_instance(this, logfile)); - this.resources = java.util.ResourceBundle.getBundle("interactive.resources.BoardHandling", p_locale); + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.BoardHandling", p_locale); } /** @@ -161,8 +161,8 @@ public void set_pin_edge_to_turn_dist(double p_value) if (edge_to_turn_dist != board.rules.get_pin_edge_to_turn_dist()) { // unfix the pin exit stubs - Collection pin_list = board.get_pins(); - for (board.Pin curr_pin : pin_list) + Collection pin_list = board.get_pins(); + for (net.freerouting.board.Pin curr_pin : pin_list) { if (curr_pin.has_trace_exit_restrictions()) { @@ -236,12 +236,12 @@ public boolean is_active_routing_layer(int p_net_no, int p_layer) { return true; } - rules.Net curr_net = this.board.rules.nets.get(p_net_no); + net.freerouting.rules.Net curr_net = this.board.rules.nets.get(p_net_no); if (curr_net == null) { return true; } - rules.NetClass curr_net_class = curr_net.get_class(); + net.freerouting.rules.NetClass curr_net_class = curr_net.get_class(); if (curr_net_class == null) { return true; @@ -265,9 +265,9 @@ public int get_trace_clearance_class(int p_net_no) } /** Gets the via rule used in interactive routing. */ - public rules.ViaRule get_via_rule(int p_net_no) + public net.freerouting.rules.ViaRule get_via_rule(int p_net_no) { - rules.ViaRule result = null; + net.freerouting.rules.ViaRule result = null; if (settings.manual_rule_selection) { result = board.rules.via_rules.get(this.settings.manual_via_rule_index); @@ -312,7 +312,7 @@ public void set_clearance_compensation(boolean p_value) /** * Changes the current snap angle in the interactive board handling. */ - public void set_current_snap_angle(board.AngleRestriction p_snap_angle) + public void set_current_snap_angle(net.freerouting.board.AngleRestriction p_snap_angle) { if (board_is_read_only) { @@ -343,7 +343,7 @@ public void set_current_layer(int p_layer) */ void set_layer(int p_layer_no) { - board.Layer curr_layer = board.layer_structure.arr[p_layer_no]; + net.freerouting.board.Layer curr_layer = board.layer_structure.arr[p_layer_no]; screen_messages.set_layer(curr_layer.name); settings.layer = p_layer_no; @@ -371,7 +371,7 @@ void set_layer(int p_layer_no) public void display_layer_messsage() { screen_messages.clear_add_field(); - board.Layer curr_layer = board.layer_structure.arr[this.settings.layer]; + net.freerouting.board.Layer curr_layer = board.layer_structure.arr[this.settings.layer]; screen_messages.set_layer(curr_layer.name); } @@ -392,14 +392,14 @@ public void initialize_manual_trace_half_widths() */ public void set_manual_trace_half_width(int p_layer_no, int p_value) { - if (p_layer_no == gui.ComboBoxLayer.ALL_LAYER_INDEX) + if (p_layer_no == net.freerouting.gui.ComboBoxLayer.ALL_LAYER_INDEX) { for (int i = 0; i < settings.manual_trace_half_width_arr.length; ++i) { this.settings.set_manual_trace_half_width(i, p_value); } } - else if (p_layer_no == gui.ComboBoxLayer.INNER_LAYER_INDEX) + else if (p_layer_no == net.freerouting.gui.ComboBoxLayer.INNER_LAYER_INDEX) { for (int i = 1; i < settings.manual_trace_half_width_arr.length - 1; ++i) { @@ -585,7 +585,7 @@ public void set_incompletes_filter(int p_net_no, boolean p_value) */ public void create_board(IntBox p_bounding_box, LayerStructure p_layer_structure, PolylineShape[] p_outline_shapes, String p_outline_clearance_class_name, - BoardRules p_rules, board.Communication p_board_communication, TestLevel p_test_level) + BoardRules p_rules, net.freerouting.board.Communication p_board_communication, TestLevel p_test_level) { if (this.board != null) { @@ -603,7 +603,7 @@ public void create_board(IntBox p_bounding_box, LayerStructure p_layer_structure else { outline_cl_class_no = - p_rules.get_default_net_class().default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.AREA); + p_rules.get_default_net_class().default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.AREA); } } this.board = @@ -688,7 +688,7 @@ public void repaint(Rectangle p_rect) /** * Gets the panel for graphical display of the board. */ - gui.BoardPanel get_panel() + net.freerouting.gui.BoardPanel get_panel() { return this.panel; } @@ -1069,8 +1069,8 @@ public boolean read_design(java.io.ObjectInputStream p_design, TestLevel p_test_ * Returns false, if the dsn-file is currupted. */ public DsnFile.ReadResult import_design(java.io.InputStream p_design, - board.BoardObservers p_observers, - datastructures.IdNoGenerator p_item_id_no_generator, TestLevel p_test_level) + net.freerouting.board.BoardObservers p_observers, + net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, TestLevel p_test_level) { if (p_design == null) { @@ -1122,7 +1122,7 @@ public boolean export_to_dsn_file(OutputStream p_output_stream, String p_design_ { return false; } - return designformats.specctra.DsnFile.write(this, p_output_stream, p_design_name, p_compat_mode); + return net.freerouting.designformats.specctra.DsnFile.write(this, p_output_stream, p_design_name, p_compat_mode); } /** @@ -1134,7 +1134,7 @@ public boolean export_eagle_session_file(java.io.InputStream p_input_stream, Out { return false; } - return designformats.specctra.SessionToEagle.get_instance(p_input_stream, p_output_stream, this.board); + return net.freerouting.designformats.specctra.SessionToEagle.get_instance(p_input_stream, p_output_stream, this.board); } /** @@ -1146,7 +1146,7 @@ public boolean export_specctra_session_file(String p_design_name, OutputStream p { return false; } - return designformats.specctra.SessionFile.write(this.get_routing_board(), p_output_stream, p_design_name); + return net.freerouting.designformats.specctra.SessionFile.write(this.get_routing_board(), p_output_stream, p_design_name); } /** @@ -1797,7 +1797,7 @@ public void dispose() /** The board database used in this interactive handling. */ private RoutingBoard board = null; /** The graphical panel used for displaying the board. */ - private final gui.BoardPanel panel; + private final net.freerouting.gui.BoardPanel panel; /** * The file used for logging interactive action, * so that they can be replayed later diff --git a/interactive/CircleConstructionState.java b/src/main/java/net/freerouting/interactive/CircleConstructionState.java similarity index 93% rename from interactive/CircleConstructionState.java rename to src/main/java/net/freerouting/interactive/CircleConstructionState.java index 9603921f..c0977d2d 100644 --- a/interactive/CircleConstructionState.java +++ b/src/main/java/net/freerouting/interactive/CircleConstructionState.java @@ -18,18 +18,18 @@ * Created on 6. November 2003, 09:37 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.Circle; -import geometry.planar.ConvexShape; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Circle; +import net.freerouting.geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; -import rules.BoardRules; +import net.freerouting.rules.BoardRules; -import board.AngleRestriction; -import board.RoutingBoard; -import board.FixedState; +import net.freerouting.board.AngleRestriction; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.FixedState; /** * Interactive creation of a circle obstacle diff --git a/interactive/ClearanceViolations.java b/src/main/java/net/freerouting/interactive/ClearanceViolations.java similarity index 93% rename from interactive/ClearanceViolations.java rename to src/main/java/net/freerouting/interactive/ClearanceViolations.java index 8fe90d6f..3b87df32 100644 --- a/interactive/ClearanceViolations.java +++ b/src/main/java/net/freerouting/interactive/ClearanceViolations.java @@ -18,7 +18,7 @@ * Created on 3. Oktober 2004, 09:13 */ -package interactive; +package net.freerouting.interactive; import java.util.Collection; import java.util.LinkedList; @@ -27,10 +27,10 @@ import java.awt.Graphics; -import boardgraphics.GraphicsContext; +import net.freerouting.boardgraphics.GraphicsContext; -import board.Item; -import board.ClearanceViolation; +import net.freerouting.board.Item; +import net.freerouting.board.ClearanceViolation; /** * To display the clearance violations between items on the screen. diff --git a/interactive/CopyItemState.java b/src/main/java/net/freerouting/interactive/CopyItemState.java similarity index 94% rename from interactive/CopyItemState.java rename to src/main/java/net/freerouting/interactive/CopyItemState.java index dd844a2a..4aec7832 100644 --- a/interactive/CopyItemState.java +++ b/src/main/java/net/freerouting/interactive/CopyItemState.java @@ -18,12 +18,12 @@ * Created on 11. November 2003, 08:23 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; -import geometry.planar.Point; -import geometry.planar.Vector; -import geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.ConvexShape; import java.util.Collection; import java.util.Iterator; @@ -31,15 +31,15 @@ import java.util.Map; import java.util.TreeMap; -import library.Padstack; -import library.Package; +import net.freerouting.library.Padstack; +import net.freerouting.library.Package; -import board.Item; -import board.DrillItem; -import board.ObstacleArea; -import board.Via; -import board.Component; -import board.RoutingBoard; +import net.freerouting.board.Item; +import net.freerouting.board.DrillItem; +import net.freerouting.board.ObstacleArea; +import net.freerouting.board.Via; +import net.freerouting.board.Component; +import net.freerouting.board.RoutingBoard; /** * Interactive copying of items. @@ -106,10 +106,10 @@ private void change_position(FloatPoint p_new_position) if (!current_position.equals(previous_position)) { Vector translate_vector = current_position.difference_by(previous_position); - Iterator it = item_list.iterator(); + Iterator it = item_list.iterator(); while (it.hasNext()) { - board.Item curr_item = it.next(); + net.freerouting.board.Item curr_item = it.next(); curr_item.translate_by(translate_vector); } previous_position = current_position; diff --git a/interactive/CornerItemConstructionState.java b/src/main/java/net/freerouting/interactive/CornerItemConstructionState.java similarity index 96% rename from interactive/CornerItemConstructionState.java rename to src/main/java/net/freerouting/interactive/CornerItemConstructionState.java index 613de873..a4567007 100644 --- a/interactive/CornerItemConstructionState.java +++ b/src/main/java/net/freerouting/interactive/CornerItemConstructionState.java @@ -18,11 +18,11 @@ * Created on 7. November 2003, 09:26 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import board.AngleRestriction; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.board.AngleRestriction; /** * Common class for constructing an obstacle with a polygonal shape. diff --git a/interactive/CutoutRouteState.java b/src/main/java/net/freerouting/interactive/CutoutRouteState.java similarity index 92% rename from interactive/CutoutRouteState.java rename to src/main/java/net/freerouting/interactive/CutoutRouteState.java index 19361858..77090574 100644 --- a/interactive/CutoutRouteState.java +++ b/src/main/java/net/freerouting/interactive/CutoutRouteState.java @@ -19,19 +19,19 @@ * */ -package interactive; +package net.freerouting.interactive; import java.util.Collection; import java.util.LinkedList; import java.util.Set; import java.util.TreeSet; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.IntBox; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.IntBox; -import board.Item; -import board.PolylineTrace; +import net.freerouting.board.Item; +import net.freerouting.board.PolylineTrace; /** * @@ -121,7 +121,7 @@ private void cutout_route() for (PolylineTrace curr_trace : this.trace_list) { - board.ShapeTraceEntries.cutout_trace(curr_trace, cut_box, 0); + net.freerouting.board.ShapeTraceEntries.cutout_trace(curr_trace, cut_box, 0); for (int i = 0; i < curr_trace.net_count(); ++i) { changed_nets.add(curr_trace.get_net_no(i)); diff --git a/interactive/DragItemState.java b/src/main/java/net/freerouting/interactive/DragItemState.java similarity index 95% rename from interactive/DragItemState.java rename to src/main/java/net/freerouting/interactive/DragItemState.java index 66b914aa..d5f877db 100644 --- a/interactive/DragItemState.java +++ b/src/main/java/net/freerouting/interactive/DragItemState.java @@ -18,19 +18,19 @@ * Created on 9. November 2003, 08:13 */ -package interactive; +package net.freerouting.interactive; import java.util.Collection; import java.util.Set; import java.util.TreeSet; import java.util.Iterator; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.Vector; -import board.AngleRestriction; -import board.Item; -import board.MoveComponent; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.board.AngleRestriction; +import net.freerouting.board.Item; +import net.freerouting.board.MoveComponent; /** * Class for interactive dragging items with the mouse on a routing board diff --git a/interactive/DragMenuState.java b/src/main/java/net/freerouting/interactive/DragMenuState.java similarity index 94% rename from interactive/DragMenuState.java rename to src/main/java/net/freerouting/interactive/DragMenuState.java index 3aefd97d..2519a663 100644 --- a/interactive/DragMenuState.java +++ b/src/main/java/net/freerouting/interactive/DragMenuState.java @@ -18,9 +18,9 @@ * Created on 4. November 2004, 11:14 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; /** * Class implementing the different functionality in the drag menu diff --git a/interactive/DragState.java b/src/main/java/net/freerouting/interactive/DragState.java similarity index 96% rename from interactive/DragState.java rename to src/main/java/net/freerouting/interactive/DragState.java index c5849259..2b161c53 100644 --- a/interactive/DragState.java +++ b/src/main/java/net/freerouting/interactive/DragState.java @@ -18,15 +18,15 @@ * Created on 10. Dezember 2003, 09:08 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; import java.util.Iterator; -import board.Trace; -import board.DrillItem; -import board.Item; +import net.freerouting.board.Trace; +import net.freerouting.board.DrillItem; +import net.freerouting.board.Item; /** * Class implementing functionality when the mouse is dragged on a routing board diff --git a/interactive/DynamicRouteState.java b/src/main/java/net/freerouting/interactive/DynamicRouteState.java similarity index 96% rename from interactive/DynamicRouteState.java rename to src/main/java/net/freerouting/interactive/DynamicRouteState.java index aebbdc72..1a7e2c0c 100644 --- a/interactive/DynamicRouteState.java +++ b/src/main/java/net/freerouting/interactive/DynamicRouteState.java @@ -18,9 +18,9 @@ * Created on 8. Dezember 2003, 10:00 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; /** * State for dynamic interactive routing, which is routing while moving the mouse pointer. diff --git a/interactive/ExpandTestState.java b/src/main/java/net/freerouting/interactive/ExpandTestState.java similarity index 92% rename from interactive/ExpandTestState.java rename to src/main/java/net/freerouting/interactive/ExpandTestState.java index 6dacb246..0b88dc5d 100644 --- a/interactive/ExpandTestState.java +++ b/src/main/java/net/freerouting/interactive/ExpandTestState.java @@ -17,10 +17,10 @@ * * Created on 23. Dezember 2003, 07:56 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.TileShape; import java.util.Collection; import java.util.Set; @@ -28,16 +28,16 @@ import java.util.TreeSet; import java.util.Iterator; -import autoroute.AutorouteControl; -import autoroute.CompleteFreeSpaceExpansionRoom; -import autoroute.IncompleteFreeSpaceExpansionRoom; -import autoroute.InsertFoundConnectionAlgo; -import autoroute.LocateFoundConnectionAlgo; -import autoroute.MazeSearchAlgo; -import autoroute.AutorouteEngine; +import net.freerouting.autoroute.AutorouteControl; +import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.IncompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.InsertFoundConnectionAlgo; +import net.freerouting.autoroute.LocateFoundConnectionAlgo; +import net.freerouting.autoroute.MazeSearchAlgo; +import net.freerouting.autoroute.AutorouteEngine; -import board.Item; -import board.RoutingBoard; +import net.freerouting.board.Item; +import net.freerouting.board.RoutingBoard; /** * State for testing the expanding algorithm of the autorouter. @@ -188,7 +188,7 @@ private void init(FloatPoint p_location) while (it.hasNext()) { Item curr_ob = it.next(); - if (curr_ob instanceof board.Connectable) + if (curr_ob instanceof net.freerouting.board.Connectable) { Item curr_item = curr_ob; if (curr_item.net_count() == 1 && curr_item.get_net_no(0) > 0) @@ -238,7 +238,7 @@ private void complete_autoroute() LocateFoundConnectionAlgo.get_instance(search_result, control_settings, this.autoroute_engine.autoroute_search_tree, hdlg.get_routing_board().rules.get_trace_angle_restriction(), - ripped_item_list, board.TestLevel.ALL_DEBUGGING_OUTPUT); + ripped_item_list, net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT); hdlg.get_routing_board().generate_snapshot(); SortedSet ripped_connections = new TreeSet(); for (Item curr_ripped_item : ripped_item_list) diff --git a/interactive/HoleConstructionState.java b/src/main/java/net/freerouting/interactive/HoleConstructionState.java similarity index 89% rename from interactive/HoleConstructionState.java rename to src/main/java/net/freerouting/interactive/HoleConstructionState.java index 20b01f34..6fc59c6e 100644 --- a/interactive/HoleConstructionState.java +++ b/src/main/java/net/freerouting/interactive/HoleConstructionState.java @@ -18,21 +18,21 @@ * Created on 7. November 2003, 18:40 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.Area; -import geometry.planar.Circle; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.PolygonShape; -import geometry.planar.PolylineArea; -import geometry.planar.PolylineShape; -import geometry.planar.Shape; +import net.freerouting.geometry.planar.Area; +import net.freerouting.geometry.planar.Circle; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.PolygonShape; +import net.freerouting.geometry.planar.PolylineArea; +import net.freerouting.geometry.planar.PolylineShape; +import net.freerouting.geometry.planar.Shape; import java.util.Iterator; -import board.ObstacleArea; -import board.ItemSelectionFilter; +import net.freerouting.board.ObstacleArea; +import net.freerouting.board.ItemSelectionFilter; /** * Interactive cutting a hole into an obstacle shape @@ -75,14 +75,14 @@ private boolean start_ok(FloatPoint p_location) ItemSelectionFilter.SelectableChoices.CONDUCTION }; ItemSelectionFilter selection_filter = new ItemSelectionFilter(selectable_choices); - java.util.Collection found_items = hdlg.get_routing_board().pick_items(pick_location, + java.util.Collection found_items = hdlg.get_routing_board().pick_items(pick_location, hdlg.settings.layer, selection_filter); if (found_items.size() != 1) { hdlg.screen_messages.set_status_message(resources.getString("no_item_found_for_adding_hole")); return false; } - board.Item found_item = found_items.iterator().next(); + net.freerouting.board.Item found_item = found_items.iterator().next(); if (!(found_item instanceof ObstacleArea)) { hdlg.screen_messages.set_status_message(resources.getString("no_obstacle_area_found_for_adding_hole")); @@ -183,7 +183,7 @@ public InteractiveState complete() hdlg.get_routing_board().generate_snapshot(); hdlg.get_routing_board().remove_item( item_to_modify); hdlg.get_routing_board().insert_obstacle(new_obs_area, item_to_modify.get_layer(), - item_to_modify.clearance_class_no(), board.FixedState.UNFIXED); + item_to_modify.clearance_class_no(), net.freerouting.board.FixedState.UNFIXED); if (this.observers_activated) { hdlg.get_routing_board().end_notify_observers(); diff --git a/interactive/InteractiveActionThread.java b/src/main/java/net/freerouting/interactive/InteractiveActionThread.java similarity index 97% rename from interactive/InteractiveActionThread.java rename to src/main/java/net/freerouting/interactive/InteractiveActionThread.java index 2637768f..eed00d27 100644 --- a/interactive/InteractiveActionThread.java +++ b/src/main/java/net/freerouting/interactive/InteractiveActionThread.java @@ -18,7 +18,7 @@ * Created on 2. Maerz 2006, 07:23 * */ -package interactive; +package net.freerouting.interactive; /** * Used for running an interactive action in a seperate Thread, @@ -26,7 +26,7 @@ * * @author Alfons Wirtz */ -public abstract class InteractiveActionThread extends Thread implements datastructures.Stoppable +public abstract class InteractiveActionThread extends Thread implements net.freerouting.datastructures.Stoppable { public static InteractiveActionThread get_autoroute_instance(BoardHandling p_board_handling) @@ -155,7 +155,7 @@ protected void thread_action() { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("interactive.resources.InteractiveState", hdlg.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", hdlg.get_locale()); boolean saved_board_read_only = hdlg.is_board_read_only(); hdlg.set_board_read_only(true); String start_message = resources.getString("logfile") + " " + resources.getString("stop_message"); diff --git a/interactive/InteractiveState.java b/src/main/java/net/freerouting/interactive/InteractiveState.java similarity index 96% rename from interactive/InteractiveState.java rename to src/main/java/net/freerouting/interactive/InteractiveState.java index 5cab9b70..9755aebb 100644 --- a/interactive/InteractiveState.java +++ b/src/main/java/net/freerouting/interactive/InteractiveState.java @@ -18,9 +18,9 @@ * Created on 5. November 2003, 12:55 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; import java.awt.Graphics; @@ -39,7 +39,7 @@ protected InteractiveState(InteractiveState p_return_state, BoardHandling p_boar this.hdlg = p_board_handling; this.logfile = p_logfile; this.resources = - java.util.ResourceBundle.getBundle("interactive.resources.InteractiveState", p_board_handling.get_locale()); + java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", p_board_handling.get_locale()); } /** @@ -174,7 +174,7 @@ else if (p_key_char == java.awt.event.KeyEvent.VK_ESCAPE) else if (Character.isDigit(p_key_char)) { // change the current layer to the p_key_char-ths signal layer - board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int d = Character.digit(p_key_char, 10); d = Math.min(d, layer_structure.signal_layer_count()); // Board layers start at 0, keyboard input for layers starts at 1. diff --git a/interactive/Logfile.java b/src/main/java/net/freerouting/interactive/Logfile.java similarity index 98% rename from interactive/Logfile.java rename to src/main/java/net/freerouting/interactive/Logfile.java index 289955e9..f66321da 100644 --- a/interactive/Logfile.java +++ b/src/main/java/net/freerouting/interactive/Logfile.java @@ -14,9 +14,9 @@ * for more details. */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; import java.io.File; import java.io.FileWriter; diff --git a/interactive/LogfileDescription.flex b/src/main/java/net/freerouting/interactive/LogfileDescription.flex similarity index 100% rename from interactive/LogfileDescription.flex rename to src/main/java/net/freerouting/interactive/LogfileDescription.flex diff --git a/interactive/LogfileScanner.java b/src/main/java/net/freerouting/interactive/LogfileScanner.java similarity index 99% rename from interactive/LogfileScanner.java rename to src/main/java/net/freerouting/interactive/LogfileScanner.java index 9b9d9015..fea60b12 100644 --- a/interactive/LogfileScanner.java +++ b/src/main/java/net/freerouting/interactive/LogfileScanner.java @@ -1,6 +1,6 @@ /* The following code was generated by JFlex 1.4 on 06.07.05 18:12 */ -package interactive; +package net.freerouting.interactive; @SuppressWarnings("all") /** diff --git a/interactive/LogfileScope.java b/src/main/java/net/freerouting/interactive/LogfileScope.java similarity index 98% rename from interactive/LogfileScope.java rename to src/main/java/net/freerouting/interactive/LogfileScope.java index d2bdb26d..e87c5e06 100644 --- a/interactive/LogfileScope.java +++ b/src/main/java/net/freerouting/interactive/LogfileScope.java @@ -18,9 +18,9 @@ * Created on 12. November 2003, 11:10 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; /** @@ -345,7 +345,7 @@ public InteractiveState start_scope( FloatPoint p_location, InteractiveState result; if (p_return_state instanceof SelectedItemState) { - java.util.Collection item_list = ((SelectedItemState) p_return_state).get_item_list(); + java.util.Collection item_list = ((SelectedItemState) p_return_state).get_item_list(); result = CopyItemState.get_instance(p_location, item_list, p_return_state.return_state, p_board_handling, null); } else @@ -371,7 +371,7 @@ public InteractiveState start_scope( FloatPoint p_location, InteractiveState result; if (p_return_state instanceof SelectedItemState) { - java.util.Collection item_list = ((SelectedItemState) p_return_state).get_item_list(); + java.util.Collection item_list = ((SelectedItemState) p_return_state).get_item_list(); result = MoveItemState.get_instance(p_location, item_list, p_return_state.return_state, p_board_handling, null); } else @@ -602,7 +602,7 @@ public InteractiveState read_scope(Logfile p_logfile, { System.out.println("CutoutRouteScope.read_scope: electedItemState expected"); } - java.util.Collection item_list = ((SelectedItemState) p_return_state).get_item_list(); + java.util.Collection item_list = ((SelectedItemState) p_return_state).get_item_list(); FloatPoint lower_left = p_logfile.read_corner(); if (lower_left == null) { @@ -1162,7 +1162,7 @@ public SetSnapAngleScope(String p_name) public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int new_snap_angle_no = p_logfile.read_int(); - p_board_handling.get_routing_board().rules.set_trace_angle_restriction(board.AngleRestriction.arr[new_snap_angle_no]); + p_board_handling.get_routing_board().rules.set_trace_angle_restriction(net.freerouting.board.AngleRestriction.arr[new_snap_angle_no]); return p_return_state; } } @@ -1209,7 +1209,7 @@ public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_ { int item_type_no = p_logfile.read_int(); int selection = p_logfile.read_int(); - board.ItemSelectionFilter.SelectableChoices item_type = board.ItemSelectionFilter.SelectableChoices.values()[item_type_no]; + net.freerouting.board.ItemSelectionFilter.SelectableChoices item_type = net.freerouting.board.ItemSelectionFilter.SelectableChoices.values()[item_type_no]; if (selection == 0) { p_board_handling.settings.item_selection_filter.set_selected(item_type, false); diff --git a/interactive/MakeSpaceState.java b/src/main/java/net/freerouting/interactive/MakeSpaceState.java similarity index 89% rename from interactive/MakeSpaceState.java rename to src/main/java/net/freerouting/interactive/MakeSpaceState.java index edade1e0..e4448cbc 100644 --- a/interactive/MakeSpaceState.java +++ b/src/main/java/net/freerouting/interactive/MakeSpaceState.java @@ -18,12 +18,12 @@ * Created on 10. Dezember 2003, 10:53 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; -import geometry.planar.Point; -import board.AngleRestriction; -import board.BasicBoard; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.board.AngleRestriction; +import net.freerouting.board.BasicBoard; /** * Class for shoving items out of a region to make space to insert something else. @@ -48,9 +48,9 @@ public MakeSpaceState(FloatPoint p_location, InteractiveState p_parent_state, Bo layer_active_arr[i] = true; } int [] route_net_no_arr = new int[1]; - route_net_no_arr[0] = rules.Nets.hidden_net_no; + route_net_no_arr[0] = net.freerouting.rules.Nets.hidden_net_no; route = new Route(p_location.round(), hdlg.settings.layer, shove_trace_width_arr, layer_active_arr, - route_net_no_arr, 0, rules.ViaRule.EMPTY, true, hdlg.settings.trace_pull_tight_region_width, + route_net_no_arr, 0, net.freerouting.rules.ViaRule.EMPTY, true, hdlg.settings.trace_pull_tight_region_width, hdlg.settings.trace_pull_tight_accuracy, null, null, hdlg.get_routing_board(), false, false, false, hdlg.settings.hilight_routing_obstacle); } @@ -91,7 +91,7 @@ public InteractiveState move_to(FloatPoint p_to_location) public InteractiveState button_released() { - int delete_net_no = rules.Nets.hidden_net_no; + int delete_net_no = net.freerouting.rules.Nets.hidden_net_no; BasicBoard board = hdlg.get_routing_board(); board.remove_items(board.get_connectable_items(delete_net_no), false); if (this.observers_activated) diff --git a/interactive/MenuState.java b/src/main/java/net/freerouting/interactive/MenuState.java similarity index 91% rename from interactive/MenuState.java rename to src/main/java/net/freerouting/interactive/MenuState.java index 4824ed1f..667ee85d 100644 --- a/interactive/MenuState.java +++ b/src/main/java/net/freerouting/interactive/MenuState.java @@ -18,15 +18,15 @@ * Created on 28. November 2003, 10:04 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; import java.util.Collection; -import board.Item; -import board.ItemSelectionFilter; -import board.TestLevel; +import net.freerouting.board.Item; +import net.freerouting.board.ItemSelectionFilter; +import net.freerouting.board.TestLevel; /** * Common base class for the main menus, which can be selected in the tool bar. @@ -84,12 +84,12 @@ public InteractiveState swap_pin(FloatPoint p_location) if (picked_items.size() > 0) { Item first_item = picked_items.iterator().next(); - if (!(first_item instanceof board.Pin)) + if (!(first_item instanceof net.freerouting.board.Pin)) { System.out.println("MenuState.swap_pin: Pin expected"); return this; } - board.Pin selected_pin = (board.Pin) first_item; + net.freerouting.board.Pin selected_pin = (net.freerouting.board.Pin) first_item; result = PinSwapState.get_instance(selected_pin, this, hdlg, this.logfile); } else @@ -161,7 +161,7 @@ else if (p_key_char == 'w') else if (p_key_char == '+') { // increase the current layer to the next signal layer - board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int current_layer_no = hdlg.settings.layer; for(;;) { @@ -179,7 +179,7 @@ else if (p_key_char == '+') else if (p_key_char == '-') { // decrease the current layer to the previous signal layer - board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int current_layer_no = hdlg.settings.layer; for(;;) { diff --git a/interactive/MoveItemState.java b/src/main/java/net/freerouting/interactive/MoveItemState.java similarity index 94% rename from interactive/MoveItemState.java rename to src/main/java/net/freerouting/interactive/MoveItemState.java index a6e3af2c..cd15c2b8 100644 --- a/interactive/MoveItemState.java +++ b/src/main/java/net/freerouting/interactive/MoveItemState.java @@ -18,25 +18,25 @@ * Created on 11. Mai 2005, 06:34 */ -package interactive; +package net.freerouting.interactive; import java.util.Collection; import java.util.LinkedList; import java.util.Set; import java.util.TreeSet; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.Vector; -import geometry.planar.Point; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Point; -import library.BoardLibrary; +import net.freerouting.library.BoardLibrary; -import board.Component; -import board.Item; -import board.Via; -import board.ClearanceViolation; -import board.LayerStructure; +import net.freerouting.board.Component; +import net.freerouting.board.Item; +import net.freerouting.board.Via; +import net.freerouting.board.ClearanceViolation; +import net.freerouting.board.LayerStructure; /** * @@ -51,7 +51,7 @@ public class MoveItemState extends InteractiveState public static MoveItemState get_instance(FloatPoint p_location, Collection p_item_list, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { - java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("interactive.resources.InteractiveState", p_board_handling.get_locale()); + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", p_board_handling.get_locale()); if (p_item_list.isEmpty()) { p_board_handling.screen_messages.set_status_message(resources.getString("move_component_failed_because_no_item_selected")); @@ -60,7 +60,7 @@ public static MoveItemState get_instance(FloatPoint p_location, Collection // extend p_item_list to full components Set item_list = new TreeSet(); Set component_list = new TreeSet(); - board.BasicBoard routing_board = p_board_handling.get_routing_board(); + net.freerouting.board.BasicBoard routing_board = p_board_handling.get_routing_board(); Component grid_snap_component = null; for (Item curr_item : p_item_list) { @@ -117,7 +117,7 @@ else if (curr_item.is_connected()) { for (Item curr_contact : contacts) { - if (curr_contact instanceof board.ConductionArea) + if (curr_contact instanceof net.freerouting.board.ConductionArea) { continue; @@ -187,7 +187,7 @@ private MoveItemState(FloatPoint p_location, Set p_item_list, Set net_pins = this.net.get_pins(); - for (board.Pin curr_pin : net_pins) + Collection net_pins = this.net.get_pins(); + for (net.freerouting.board.Pin curr_pin : net_pins) { draw_length_violation_marker(curr_pin.get_center().to_float(), this.length_violation, p_graphics, p_graphics_context); } @@ -321,7 +322,7 @@ public int compareTo(Edge p_other) result = this.to_corner.y - p_other.to_corner.y; } } - return datastructures.Signum.as_int(result); + return Signum.as_int(result); } } diff --git a/interactive/PinSwapState.java b/src/main/java/net/freerouting/interactive/PinSwapState.java similarity index 96% rename from interactive/PinSwapState.java rename to src/main/java/net/freerouting/interactive/PinSwapState.java index 73673b34..dacd8be2 100644 --- a/interactive/PinSwapState.java +++ b/src/main/java/net/freerouting/interactive/PinSwapState.java @@ -18,13 +18,13 @@ * Created on 28. Maerz 2005, 09:25 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; -import board.Pin; -import board.Item; -import board.ItemSelectionFilter; +import net.freerouting.board.Pin; +import net.freerouting.board.Item; +import net.freerouting.board.ItemSelectionFilter; /** * diff --git a/interactive/PolygonShapeConstructionState.java b/src/main/java/net/freerouting/interactive/PolygonShapeConstructionState.java similarity index 93% rename from interactive/PolygonShapeConstructionState.java rename to src/main/java/net/freerouting/interactive/PolygonShapeConstructionState.java index cffcd89d..121de0d7 100644 --- a/interactive/PolygonShapeConstructionState.java +++ b/src/main/java/net/freerouting/interactive/PolygonShapeConstructionState.java @@ -18,15 +18,15 @@ * Created on 7. November 2003, 17:19 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.PolygonShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.PolygonShape; import java.util.Iterator; -import rules.BoardRules; +import net.freerouting.rules.BoardRules; /** * Interactive state for constructing an obstacle with a polygon shape. @@ -92,7 +92,7 @@ public InteractiveState complete() hdlg.get_routing_board().start_notify_observers(); } hdlg.get_routing_board().generate_snapshot(); - hdlg.get_routing_board().insert_obstacle(obstacle_shape, hdlg.settings.layer, cl_class, board.FixedState.UNFIXED); + hdlg.get_routing_board().insert_obstacle(obstacle_shape, hdlg.settings.layer, cl_class, net.freerouting.board.FixedState.UNFIXED); hdlg.get_routing_board().end_notify_observers(); if (this.observers_activated) { diff --git a/interactive/RatsNest.java b/src/main/java/net/freerouting/interactive/RatsNest.java similarity index 89% rename from interactive/RatsNest.java rename to src/main/java/net/freerouting/interactive/RatsNest.java index cd181228..68915c7e 100644 --- a/interactive/RatsNest.java +++ b/src/main/java/net/freerouting/interactive/RatsNest.java @@ -18,7 +18,7 @@ * Created on 18. Maerz 2004, 07:30 */ -package interactive; +package net.freerouting.interactive; import java.util.Collection; import java.util.LinkedList; @@ -27,16 +27,16 @@ import java.awt.Graphics; -import datastructures.UndoableObjects; +import net.freerouting.datastructures.UndoableObjects; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; -import rules.Net; +import net.freerouting.rules.Net; -import board.BasicBoard; -import board.Item; -import board.Connectable; -import boardgraphics.GraphicsContext; +import net.freerouting.board.BasicBoard; +import net.freerouting.board.Item; +import net.freerouting.board.Connectable; +import net.freerouting.boardgraphics.GraphicsContext; /** * Creates all Incompletes (Ratsnest) to display them on the screen @@ -242,7 +242,7 @@ public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) /** * Describes a single incomplete connection of the ratsnest. */ - public static class AirLine implements Comparable, board.ObjectInfoPanel.Printable + public static class AirLine implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable { AirLine(Net p_net, Item p_from_item, FloatPoint p_from_corner, Item p_to_item, FloatPoint p_to_corner, java.util.Locale p_locale) @@ -270,22 +270,22 @@ public String toString() private String item_info(Item p_item) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("interactive.resources.RatsNest", this.locale); + java.util.ResourceBundle.getBundle("net.freerouting.interactive.RatsNest", this.locale); String result; - if (p_item instanceof board.Pin) + if (p_item instanceof net.freerouting.board.Pin) { - board.Pin curr_pin = (board.Pin) p_item; + net.freerouting.board.Pin curr_pin = (net.freerouting.board.Pin) p_item; result = curr_pin.component_name() + ", " + curr_pin.name(); } - else if (p_item instanceof board.Via) + else if (p_item instanceof net.freerouting.board.Via) { result = resources.getString("via"); } - else if (p_item instanceof board.Trace) + else if (p_item instanceof net.freerouting.board.Trace) { result = resources.getString("trace"); } - else if (p_item instanceof board.ConductionArea) + else if (p_item instanceof net.freerouting.board.ConductionArea) { result = resources.getString("conduction_area"); } @@ -296,10 +296,10 @@ else if (p_item instanceof board.ConductionArea) return result; } - public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale) + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("interactive.resources.RatsNest", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.interactive.RatsNest", p_locale); p_window.append_bold(resources.getString("incomplete")); p_window.append(" " + resources.getString("net") + " "); p_window.append(net.name); diff --git a/interactive/Route.java b/src/main/java/net/freerouting/interactive/Route.java similarity index 92% rename from interactive/Route.java rename to src/main/java/net/freerouting/interactive/Route.java index dced98d2..7fb5f7ec 100644 --- a/interactive/Route.java +++ b/src/main/java/net/freerouting/interactive/Route.java @@ -13,19 +13,19 @@ * GNU General Public License at * for more details. */ -package interactive; +package net.freerouting.interactive; -import datastructures.TimeLimit; +import net.freerouting.datastructures.TimeLimit; -import geometry.planar.Area; -import geometry.planar.FloatPoint; -import geometry.planar.IntBox; -import geometry.planar.IntOctagon; -import geometry.planar.IntPoint; -import geometry.planar.Vector; -import geometry.planar.Point; -import geometry.planar.Polyline; -import geometry.planar.Ellipse; +import net.freerouting.geometry.planar.Area; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.Ellipse; import java.awt.Graphics; import java.util.Collection; @@ -33,24 +33,24 @@ import java.util.LinkedList; import java.util.Set; -import library.Padstack; +import net.freerouting.library.Padstack; -import rules.ViaRule; -import rules.ViaInfo; -import rules.Net; +import net.freerouting.rules.ViaRule; +import net.freerouting.rules.ViaInfo; +import net.freerouting.rules.Net; -import board.AngleRestriction; -import board.Trace; -import board.ConductionArea; -import board.DrillItem; -import board.Item; -import board.PolylineTrace; -import board.RoutingBoard; -import board.ItemSelectionFilter; -import board.TestLevel; -import board.Unit; +import net.freerouting.board.AngleRestriction; +import net.freerouting.board.Trace; +import net.freerouting.board.ConductionArea; +import net.freerouting.board.DrillItem; +import net.freerouting.board.Item; +import net.freerouting.board.PolylineTrace; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.ItemSelectionFilter; +import net.freerouting.board.TestLevel; +import net.freerouting.board.Unit; -import boardgraphics.GraphicsContext; +import net.freerouting.boardgraphics.GraphicsContext; /** * @@ -315,12 +315,12 @@ private boolean snap_to_smd_center(int p_layer) { ItemSelectionFilter selection_filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.PINS); java.util.Collection picked_items = board.pick_items(this.prev_corner, p_layer, selection_filter); - board.Pin found_smd_pin = null; + net.freerouting.board.Pin found_smd_pin = null; for (Item curr_item : picked_items) { - if (curr_item instanceof board.Pin && curr_item.shares_net_no(this.net_no_arr)) + if (curr_item instanceof net.freerouting.board.Pin && curr_item.shares_net_no(this.net_no_arr)) { - board.Pin curr_pin = (board.Pin) curr_item; + net.freerouting.board.Pin curr_pin = (net.freerouting.board.Pin) curr_item; if (curr_pin.first_layer() == p_layer && curr_pin.last_layer() == p_layer) { found_smd_pin = curr_pin; @@ -463,10 +463,10 @@ private Set calculate_swap_pin_infos() } for (Item curr_item : this.target_set) { - if (curr_item instanceof board.Pin) + if (curr_item instanceof net.freerouting.board.Pin) { - Collection curr_swapppable_pins = ((board.Pin) curr_item).get_swappable_pins(); - for (board.Pin curr_swappable_pin : curr_swapppable_pins) + Collection curr_swapppable_pins = ((net.freerouting.board.Pin) curr_item).get_swappable_pins(); + for (net.freerouting.board.Pin curr_swappable_pin : curr_swapppable_pins) { result.add(new SwapPinInfo(curr_swappable_pin)); } @@ -477,10 +477,10 @@ private Set calculate_swap_pin_infos() java.util.Collection picked_items = board.pick_items(this.prev_corner, this.layer, selection_filter); for (Item curr_item : picked_items) { - if (curr_item instanceof board.Pin) + if (curr_item instanceof net.freerouting.board.Pin) { - Collection curr_swapppable_pins = ((board.Pin) curr_item).get_swappable_pins(); - for (board.Pin curr_swappable_pin : curr_swapppable_pins) + Collection curr_swapppable_pins = ((net.freerouting.board.Pin) curr_item).get_swappable_pins(); + for (net.freerouting.board.Pin curr_swappable_pin : curr_swapppable_pins) { result.add(new SwapPinInfo(curr_swappable_pin)); } @@ -550,7 +550,7 @@ public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) if (max_trace_length <= 0) { // max_trace_length not provided. Create an ellipse containing the whole board. - max_trace_length = 0.3 * geometry.planar.Limits.CRIT_INT; + max_trace_length = 0.3 * net.freerouting.geometry.planar.Limits.CRIT_INT; } double curr_max_trace_length = max_trace_length - (curr_net.get_trace_length() + trace_length_add); double curr_min_trace_length = min_trace_length - (curr_net.get_trace_length() + trace_length_add); @@ -772,11 +772,11 @@ private void set_shove_failing_obstacle(Item p_item) */ private Point try_neckdown_at_start(IntPoint p_to_corner) { - if (!(this.start_item instanceof board.Pin)) + if (!(this.start_item instanceof net.freerouting.board.Pin)) { return this.prev_corner; } - board.Pin start_pin = (board.Pin) this.start_item; + net.freerouting.board.Pin start_pin = (net.freerouting.board.Pin) this.start_item; if (!start_pin.is_on_layer(this.layer)) { return this.prev_corner; @@ -824,11 +824,11 @@ private Point try_neckdown_at_start(IntPoint p_to_corner) */ private Point try_neckdown_at_end(Point p_from_corner, Point p_to_corner) { - if (!(this.nearest_target_item instanceof board.Pin)) + if (!(this.nearest_target_item instanceof net.freerouting.board.Pin)) { return p_from_corner; } - board.Pin target_pin = (board.Pin) this.nearest_target_item; + net.freerouting.board.Pin target_pin = (net.freerouting.board.Pin) this.nearest_target_item; if (!target_pin.is_on_layer(this.layer)) { return p_from_corner; @@ -903,7 +903,7 @@ private static class TargetPoint private class SwapPinInfo implements Comparable { - SwapPinInfo(board.Pin p_pin) + SwapPinInfo(net.freerouting.board.Pin p_pin) { pin = p_pin; incomplete = null; @@ -932,7 +932,7 @@ private class SwapPinInfo implements Comparable } if (nearest_point != null) { - incomplete = new geometry.planar.FloatLine(pin_center, nearest_point); + incomplete = new net.freerouting.geometry.planar.FloatLine(pin_center, nearest_point); } } @@ -940,7 +940,7 @@ public int compareTo(SwapPinInfo p_other) { return this.pin.compareTo(p_other.pin); } - final board.Pin pin; - geometry.planar.FloatLine incomplete; + final net.freerouting.board.Pin pin; + net.freerouting.geometry.planar.FloatLine incomplete; } } \ No newline at end of file diff --git a/interactive/RouteMenuState.java b/src/main/java/net/freerouting/interactive/RouteMenuState.java similarity index 95% rename from interactive/RouteMenuState.java rename to src/main/java/net/freerouting/interactive/RouteMenuState.java index 565be016..67a3b1de 100644 --- a/interactive/RouteMenuState.java +++ b/src/main/java/net/freerouting/interactive/RouteMenuState.java @@ -18,9 +18,9 @@ * Created on 29. November 2003, 07:50 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; /** * Class implementing the different functionality in the route menu, diff --git a/interactive/RouteState.java b/src/main/java/net/freerouting/interactive/RouteState.java similarity index 93% rename from interactive/RouteState.java rename to src/main/java/net/freerouting/interactive/RouteState.java index 7bbff13c..90a2f6e7 100644 --- a/interactive/RouteState.java +++ b/src/main/java/net/freerouting/interactive/RouteState.java @@ -17,23 +17,22 @@ * * Created on 8. November 2003, 08:22 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.Point; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Point; import java.util.Collection; import java.util.Set; -import board.Trace; -import board.Via; -import board.PolylineTrace; -import board.ConductionArea; -import board.DrillItem; -import board.Item; -import board.RoutingBoard; -import board.ItemSelectionFilter; +import net.freerouting.board.Trace; +import net.freerouting.board.Via; +import net.freerouting.board.PolylineTrace; +import net.freerouting.board.ConductionArea; +import net.freerouting.board.DrillItem; +import net.freerouting.board.Item; +import net.freerouting.board.ItemSelectionFilter; /** * Interactive routing state. @@ -68,10 +67,10 @@ public static RouteState get_instance(FloatPoint p_location, InteractiveState p_ return null; } int[] route_net_no_arr; - if (picked_item instanceof board.Pin && net_count > 1) + if (picked_item instanceof net.freerouting.board.Pin && net_count > 1) { // tie pin, remove nets, which are already conneccted to this pin on the current layer. - route_net_no_arr = get_route_net_numbers_at_tie_pin((board.Pin) picked_item, p_board_handling.settings.layer); + route_net_no_arr = get_route_net_numbers_at_tie_pin((net.freerouting.board.Pin) picked_item, p_board_handling.settings.layer); } else { @@ -85,7 +84,7 @@ public static RouteState get_instance(FloatPoint p_location, InteractiveState p_ { return null; } - board.RoutingBoard routing_board = p_board_handling.get_routing_board(); + net.freerouting.board.RoutingBoard routing_board = p_board_handling.get_routing_board(); int[] trace_half_widths = new int[routing_board.get_layer_count()]; boolean[] layer_active_arr = new boolean[trace_half_widths.length]; for (int i = 0; i < trace_half_widths.length; ++i) @@ -151,7 +150,7 @@ else if (picked_item instanceof DrillItem) } - rules.Net curr_net = routing_board.rules.nets.get(route_net_no_arr[0]); + net.freerouting.rules.Net curr_net = routing_board.rules.nets.get(route_net_no_arr[0]); if (curr_net == null) { return null; @@ -211,7 +210,7 @@ protected RouteState(InteractiveState p_parent_state, BoardHandling p_board_hand */ static protected Item start_ok(IntPoint p_location, BoardHandling p_hdlg) { - board.RoutingBoard routing_board = p_hdlg.get_routing_board(); + net.freerouting.board.RoutingBoard routing_board = p_hdlg.get_routing_board(); /** * look if an already exististing trace ends at p_start_corner @@ -290,12 +289,12 @@ public InteractiveState key_typed(char p_key_char) if (Character.isDigit(p_key_char)) { // change to the p_key_char-ths signal layer - board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int d = Character.digit(p_key_char, 10); d = Math.min(d, layer_structure.signal_layer_count()); // Board layers start at 0, keyboard input for layers starts at 1. d = Math.max(d - 1, 0); - board.Layer new_layer = layer_structure.get_signal_layer(d); + net.freerouting.board.Layer new_layer = layer_structure.get_signal_layer(d); d = layer_structure.get_no(new_layer); if (d >= 0) @@ -306,7 +305,7 @@ public InteractiveState key_typed(char p_key_char) else if (p_key_char == '+') { // change to the next signal layer - board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int current_layer_no = hdlg.settings.layer; for (;;) { @@ -324,7 +323,7 @@ else if (p_key_char == '+') else if (p_key_char == '-') { // change to the to the previous signal layer - board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; + net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int current_layer_no = hdlg.settings.layer; for (;;) { @@ -521,7 +520,7 @@ public boolean change_layer_action(int p_new_layer) /** * get nets of p_tie_pin except nets of traces, which are already conneccted to this pin on p_layer. */ - static int[] get_route_net_numbers_at_tie_pin(board.Pin p_pin, int p_layer) + static int[] get_route_net_numbers_at_tie_pin(net.freerouting.board.Pin p_pin, int p_layer) { Set net_number_list = new java.util.TreeSet(); for (int i = 0; i < p_pin.net_count(); ++i) @@ -561,7 +560,7 @@ public void display_default_message() { if (route != null) { - rules.Net curr_net = hdlg.get_routing_board().rules.nets.get(route.net_no_arr[0]); + net.freerouting.rules.Net curr_net = hdlg.get_routing_board().rules.nets.get(route.net_no_arr[0]); hdlg.screen_messages.set_status_message(resources.getString("routing_net") + " " + curr_net.name); } } diff --git a/interactive/ScreenMessages.java b/src/main/java/net/freerouting/interactive/ScreenMessages.java similarity index 96% rename from interactive/ScreenMessages.java rename to src/main/java/net/freerouting/interactive/ScreenMessages.java index d3ef389e..9e509f9e 100644 --- a/interactive/ScreenMessages.java +++ b/src/main/java/net/freerouting/interactive/ScreenMessages.java @@ -18,7 +18,7 @@ * Created on 8. August 2003, 19:10 */ -package interactive; +package net.freerouting.interactive; import javax.swing.JLabel; @@ -34,7 +34,7 @@ public class ScreenMessages public ScreenMessages(JLabel p_status_field, JLabel p_add_field, JLabel p_layer_field, JLabel p_mouse_position, java.util.Locale p_locale) { - resources = java.util.ResourceBundle.getBundle("interactive.resources.ScreenMessages", p_locale); + resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.ScreenMessages", p_locale); locale = p_locale; active_layer_string = resources.getString("current_layer") + " "; target_layer_string = resources.getString("target_layer") + " "; @@ -121,7 +121,7 @@ public void set_target_layer(String p_layer_name) } } - public void set_mouse_position(geometry.planar.FloatPoint p_pos) + public void set_mouse_position(net.freerouting.geometry.planar.FloatPoint p_pos) { if (p_pos == null || this.mouse_position == null || this.write_protected) { diff --git a/interactive/SelectItemsInRegionState.java b/src/main/java/net/freerouting/interactive/SelectItemsInRegionState.java similarity index 95% rename from interactive/SelectItemsInRegionState.java rename to src/main/java/net/freerouting/interactive/SelectItemsInRegionState.java index 44611094..54be881c 100644 --- a/interactive/SelectItemsInRegionState.java +++ b/src/main/java/net/freerouting/interactive/SelectItemsInRegionState.java @@ -17,17 +17,17 @@ * * Created on 9. November 2003, 12:02 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; -import geometry.planar.IntBox; -import geometry.planar.IntPoint; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntPoint; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; -import board.Item; +import net.freerouting.board.Item; /** * Interactive state for selecting all items in a rectangle. diff --git a/interactive/SelectMenuState.java b/src/main/java/net/freerouting/interactive/SelectMenuState.java similarity index 95% rename from interactive/SelectMenuState.java rename to src/main/java/net/freerouting/interactive/SelectMenuState.java index 49d3de06..171bb5b7 100644 --- a/interactive/SelectMenuState.java +++ b/src/main/java/net/freerouting/interactive/SelectMenuState.java @@ -18,9 +18,9 @@ * Created on 28. November 2003, 10:13 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; /** * Class implementing the different functionality in the select menu, diff --git a/interactive/SelectRegionState.java b/src/main/java/net/freerouting/interactive/SelectRegionState.java similarity index 95% rename from interactive/SelectRegionState.java rename to src/main/java/net/freerouting/interactive/SelectRegionState.java index 45c9f55e..32d074c6 100644 --- a/interactive/SelectRegionState.java +++ b/src/main/java/net/freerouting/interactive/SelectRegionState.java @@ -18,9 +18,9 @@ * Created on 9. November 2003, 11:34 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; /** * Common base class for interactive selection of a rectangle. diff --git a/interactive/SelectedItemState.java b/src/main/java/net/freerouting/interactive/SelectedItemState.java similarity index 95% rename from interactive/SelectedItemState.java rename to src/main/java/net/freerouting/interactive/SelectedItemState.java index 0bddcff5..de65a9a9 100644 --- a/interactive/SelectedItemState.java +++ b/src/main/java/net/freerouting/interactive/SelectedItemState.java @@ -17,38 +17,38 @@ * * Created on 10. November 2003, 08:02 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.Point; -import geometry.planar.Vector; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Vector; import java.util.Collection; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; -import datastructures.Stoppable; +import net.freerouting.datastructures.Stoppable; -import library.Package; +import net.freerouting.library.Package; -import rules.Net; +import net.freerouting.rules.Net; -import autoroute.AutorouteEngine; +import net.freerouting.autoroute.AutorouteEngine; -import board.Component; -import board.Connectable; -import board.DrillItem; -import board.Via; -import board.Pin; -import board.Item; -import board.ObstacleArea; -import board.PolylineTrace; -import board.RoutingBoard; -import board.FixedState; -import board.OptViaAlgo; -import board.TestLevel; +import net.freerouting.board.Component; +import net.freerouting.board.Connectable; +import net.freerouting.board.DrillItem; +import net.freerouting.board.Via; +import net.freerouting.board.Pin; +import net.freerouting.board.Item; +import net.freerouting.board.ObstacleArea; +import net.freerouting.board.PolylineTrace; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.FixedState; +import net.freerouting.board.OptViaAlgo; +import net.freerouting.board.TestLevel; /** * Class implementing actions on the currently selected items. @@ -434,7 +434,7 @@ public InteractiveState autoroute(Stoppable p_stoppable_thread) continue; } boolean contains_plane = false; - rules.Net route_net = hdlg.get_routing_board().rules.nets.get(curr_item.get_net_no(0)); + net.freerouting.rules.Net route_net = hdlg.get_routing_board().rules.nets.get(curr_item.get_net_no(0)); if (route_net != null) { contains_plane = route_net.contains_plane(); @@ -658,7 +658,7 @@ else if (curr_item instanceof Via) */ public InteractiveState assign_clearance_class(int p_cl_class_index) { - board.BasicBoard routing_board = this.hdlg.get_routing_board(); + net.freerouting.board.BasicBoard routing_board = this.hdlg.get_routing_board(); if (p_cl_class_index < 0 || p_cl_class_index >= routing_board.rules.clearance_matrix.get_class_count()) { return this.return_state; @@ -901,7 +901,7 @@ public InteractiveState filter() */ public SelectedItemState info() { - gui.WindowObjectInfo.display(this.item_list, hdlg.get_panel().board_frame, hdlg.coordinate_transform, new java.awt.Point(100, 100)); + net.freerouting.gui.WindowObjectInfo.display(this.item_list, hdlg.get_panel().board_frame, hdlg.coordinate_transform, new java.awt.Point(100, 100)); return this; } @@ -917,7 +917,7 @@ public void draw(java.awt.Graphics p_graphics) return; } - for (board.Item curr_item : item_list) + for (net.freerouting.board.Item curr_item : item_list) { curr_item.draw(p_graphics, hdlg.graphics_context, hdlg.graphics_context.get_hilight_color(), hdlg.graphics_context.get_hilight_color_intensity()); diff --git a/interactive/Settings.java b/src/main/java/net/freerouting/interactive/Settings.java similarity index 99% rename from interactive/Settings.java rename to src/main/java/net/freerouting/interactive/Settings.java index bdbda158..b2ea3f48 100644 --- a/interactive/Settings.java +++ b/src/main/java/net/freerouting/interactive/Settings.java @@ -18,10 +18,10 @@ * Created on 29. August 2003, 11:33 */ -package interactive; +package net.freerouting.interactive; -import board.ItemSelectionFilter; -import board.RoutingBoard; +import net.freerouting.board.ItemSelectionFilter; +import net.freerouting.board.RoutingBoard; /** * Contains the values of the interactive settings of the board handling. diff --git a/interactive/SnapShot.java b/src/main/java/net/freerouting/interactive/SnapShot.java similarity index 92% rename from interactive/SnapShot.java rename to src/main/java/net/freerouting/interactive/SnapShot.java index 926eee42..14e5ec49 100644 --- a/interactive/SnapShot.java +++ b/src/main/java/net/freerouting/interactive/SnapShot.java @@ -18,7 +18,7 @@ * Created on 8. November 2004, 08:01 */ -package interactive; +package net.freerouting.interactive; /** * Snapshot of the client situation in an interactive session. @@ -47,7 +47,7 @@ private SnapShot(String p_name, BoardHandling p_board_handling) this.name = p_name; this.settings = new Settings(p_board_handling.settings); this.interactive_state_no = get_no(p_board_handling.interactive_state); - this.graphics_context = new boardgraphics.GraphicsContext(p_board_handling.graphics_context); + this.graphics_context = new net.freerouting.boardgraphics.GraphicsContext(p_board_handling.graphics_context); this.viewport_position = new java.awt.Point(p_board_handling.get_panel().get_viewport_position()); this.subwindow_filters = p_board_handling.get_panel().board_frame.get_snapshot_subwindow_selections(); } @@ -70,14 +70,14 @@ public java.awt.Point copy_viewport_position() /** * Goes to this shnapshot in interactive board etiting. */ - public void go_to(interactive.BoardHandling p_board_handling) + public void go_to(net.freerouting.interactive.BoardHandling p_board_handling) { - interactive.SnapShot.Attributes snapshot_attributes = this.settings.snapshot_attributes; + net.freerouting.interactive.SnapShot.Attributes snapshot_attributes = this.settings.snapshot_attributes; if (snapshot_attributes.object_visibility) { p_board_handling.graphics_context.color_intensity_table = - new boardgraphics.ColorIntensityTable(this.graphics_context.color_intensity_table); + new net.freerouting.boardgraphics.ColorIntensityTable(this.graphics_context.color_intensity_table); } if (snapshot_attributes.layer_visibility) { @@ -94,7 +94,7 @@ public void go_to(interactive.BoardHandling p_board_handling) } if (snapshot_attributes.selectable_items) { - p_board_handling.settings.item_selection_filter = new board.ItemSelectionFilter(this.settings.item_selection_filter); + p_board_handling.settings.item_selection_filter = new net.freerouting.board.ItemSelectionFilter(this.settings.item_selection_filter); } if (snapshot_attributes.current_layer) { @@ -181,9 +181,9 @@ else if (p_interactive_state instanceof DragMenuState) private final String name; public final Settings settings; private final int interactive_state_no; - public final boardgraphics.GraphicsContext graphics_context; + public final net.freerouting.boardgraphics.GraphicsContext graphics_context; private final java.awt.Point viewport_position; - public final gui.BoardFrame.SubwindowSelections subwindow_filters; + public final net.freerouting.gui.BoardFrame.SubwindowSelections subwindow_filters; /** * Defines the data of the snapshot selected for restoring. diff --git a/interactive/StitchRouteState.java b/src/main/java/net/freerouting/interactive/StitchRouteState.java similarity index 91% rename from interactive/StitchRouteState.java rename to src/main/java/net/freerouting/interactive/StitchRouteState.java index 2d49eb21..ca339064 100644 --- a/interactive/StitchRouteState.java +++ b/src/main/java/net/freerouting/interactive/StitchRouteState.java @@ -18,10 +18,10 @@ * Created on 8. Dezember 2003, 08:05 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; /** * State for interactive routing by adding corners with the left mouse button. @@ -82,8 +82,8 @@ public void draw(java.awt.Graphics p_graphics) double display_width = hdlg.get_trace_halfwidth(route.net_no_arr[0], hdlg.settings.layer); int clearance_draw_width = 50; double radius_with_clearance = display_width; - rules.NetClass default_net_class = hdlg.get_routing_board().rules.get_default_net_class(); - int cl_class = default_net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.TRACE); + net.freerouting.rules.NetClass default_net_class = hdlg.get_routing_board().rules.get_default_net_class(); + int cl_class = default_net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.TRACE); radius_with_clearance += hdlg.get_routing_board().clearance_value(cl_class, cl_class, hdlg.settings.layer); hdlg.graphics_context.draw(draw_points, display_width, draw_color, p_graphics, 0.5); // draw the clearance boundary around the end point diff --git a/interactive/TileConstructionState.java b/src/main/java/net/freerouting/interactive/TileConstructionState.java similarity index 95% rename from interactive/TileConstructionState.java rename to src/main/java/net/freerouting/interactive/TileConstructionState.java index 3466a385..42b67f50 100644 --- a/interactive/TileConstructionState.java +++ b/src/main/java/net/freerouting/interactive/TileConstructionState.java @@ -18,22 +18,22 @@ * Created on 6. November 2003, 14:46 */ -package interactive; +package net.freerouting.interactive; import java.util.Iterator; -import geometry.planar.FloatPoint; -import geometry.planar.IntPoint; -import geometry.planar.Line; -import geometry.planar.Side; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Line; +import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.TileShape; -import rules.BoardRules; +import net.freerouting.rules.BoardRules; -import board.AngleRestriction; -import board.RoutingBoard; -import board.FixedState; +import net.freerouting.board.AngleRestriction; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.FixedState; /** * Class for interactive construction of a tile shaped obstacle diff --git a/interactive/ZoomRegionState.java b/src/main/java/net/freerouting/interactive/ZoomRegionState.java similarity index 93% rename from interactive/ZoomRegionState.java rename to src/main/java/net/freerouting/interactive/ZoomRegionState.java index a541be3d..772f8bf3 100644 --- a/interactive/ZoomRegionState.java +++ b/src/main/java/net/freerouting/interactive/ZoomRegionState.java @@ -18,9 +18,9 @@ * Created on 9. November 2003, 13:05 */ -package interactive; +package net.freerouting.interactive; -import geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.FloatPoint; import java.awt.geom.Point2D; @@ -56,7 +56,7 @@ public ZoomRegionState(InteractiveState p_parent_state, BoardHandling p_board_ha super(p_parent_state, p_board_handling, p_logfile); if (this.logfile != null) { - logfile.start_scope(interactive.LogfileScope.ZOOM_FRAME); + logfile.start_scope(net.freerouting.interactive.LogfileScope.ZOOM_FRAME); } } diff --git a/interactive/package.html b/src/main/java/net/freerouting/interactive/package.html similarity index 100% rename from interactive/package.html rename to src/main/java/net/freerouting/interactive/package.html diff --git a/library/BoardLibrary.java b/src/main/java/net/freerouting/library/BoardLibrary.java similarity index 90% rename from library/BoardLibrary.java rename to src/main/java/net/freerouting/library/BoardLibrary.java index 2a2b2481..5eb924d6 100644 --- a/library/BoardLibrary.java +++ b/src/main/java/net/freerouting/library/BoardLibrary.java @@ -18,7 +18,7 @@ * Created on 4. Juni 2004, 06:37 */ -package library; +package net.freerouting.library; import java.util.List; import java.util.Vector; @@ -129,7 +129,7 @@ public boolean add_via_padstack(Padstack p_padstack) * Returns false, if p_padstack was not found in the list. * If the padstack is no more used on the board, it will also be removed from the board padstacks. */ - public boolean remove_via_padstack(Padstack p_padstack, board.BasicBoard p_board) + public boolean remove_via_padstack(Padstack p_padstack, net.freerouting.board.BasicBoard p_board) { boolean result = via_padstacks.remove(p_padstack); return result; @@ -162,19 +162,19 @@ public Padstack get_mirrored_via_padstack(Padstack p_via_padstack) /** * Looks, if the input padstack is used on p_board in a Package or in drill. */ - public boolean is_used (Padstack p_padstack, board.BasicBoard p_board) + public boolean is_used (Padstack p_padstack, net.freerouting.board.BasicBoard p_board) { - java.util.Iterator it = p_board.item_list.start_read_object(); + java.util.Iterator it = p_board.item_list.start_read_object(); for(;;) { - datastructures.UndoableObjects.Storable curr_item = p_board.item_list.read_object(it); + net.freerouting.datastructures.UndoableObjects.Storable curr_item = p_board.item_list.read_object(it); if (curr_item == null) { break; } - if (curr_item instanceof board.DrillItem) + if (curr_item instanceof net.freerouting.board.DrillItem) { - if (((board.DrillItem) curr_item).get_padstack() == p_padstack) + if (((net.freerouting.board.DrillItem) curr_item).get_padstack() == p_padstack) { return true; } diff --git a/library/LogicalPart.java b/src/main/java/net/freerouting/library/LogicalPart.java similarity index 92% rename from library/LogicalPart.java rename to src/main/java/net/freerouting/library/LogicalPart.java index 3023a68c..171f487a 100644 --- a/library/LogicalPart.java +++ b/src/main/java/net/freerouting/library/LogicalPart.java @@ -18,14 +18,14 @@ * Created on 26. Maerz 2005, 06:14 */ -package library; +package net.freerouting.library; /** * Contains contain information for gate swap and pin swap for a single component. * * @author Alfons Wirtz */ -public class LogicalPart implements board.ObjectInfoPanel.Printable, java.io.Serializable +public class LogicalPart implements net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { /** @@ -56,10 +56,10 @@ public PartPin get_pin(int p_no) return part_pin_arr[p_no]; } - public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale) + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("logical_part_2") + " "); p_window.append_bold(this.name); for (int i = 0; i < this.part_pin_arr.length; ++i) diff --git a/library/LogicalParts.java b/src/main/java/net/freerouting/library/LogicalParts.java similarity index 98% rename from library/LogicalParts.java rename to src/main/java/net/freerouting/library/LogicalParts.java index 32301a86..ee791e75 100644 --- a/library/LogicalParts.java +++ b/src/main/java/net/freerouting/library/LogicalParts.java @@ -18,7 +18,7 @@ * Created on 26. Maerz 2005, 06:08 */ -package library; +package net.freerouting.library; import java.util.Vector; diff --git a/library/Package.java b/src/main/java/net/freerouting/library/Package.java similarity index 92% rename from library/Package.java rename to src/main/java/net/freerouting/library/Package.java index fba52741..6bf82a1b 100644 --- a/library/Package.java +++ b/src/main/java/net/freerouting/library/Package.java @@ -18,11 +18,11 @@ * Created on 27. Mai 2004, 06:53 */ -package library; +package net.freerouting.library; -import geometry.planar.Vector; -import geometry.planar.Shape; -import geometry.planar.Area; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.Area; /** * Component package templates describing the padstacks and @@ -31,7 +31,7 @@ * * @author alfons */ -public class Package implements Comparable, board.ObjectInfoPanel.Printable, java.io.Serializable +public class Package implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { /** @@ -103,10 +103,10 @@ public String toString() return this.name; } - public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale) + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("package") + " "); p_window.append_bold(this.name); for (int i = 0; i < this.pin_arr.length; ++i) diff --git a/library/Packages.java b/src/main/java/net/freerouting/library/Packages.java similarity index 97% rename from library/Packages.java rename to src/main/java/net/freerouting/library/Packages.java index 1fa2ef7c..50ad3b67 100644 --- a/library/Packages.java +++ b/src/main/java/net/freerouting/library/Packages.java @@ -18,12 +18,12 @@ * Created on 3. Juni 2004, 09:29 */ -package library; +package net.freerouting.library; import java.util.Iterator; import java.util.Vector; -import geometry.planar.Shape; +import net.freerouting.geometry.planar.Shape; /** * Describes a library of component packages. diff --git a/library/Padstack.java b/src/main/java/net/freerouting/library/Padstack.java similarity index 90% rename from library/Padstack.java rename to src/main/java/net/freerouting/library/Padstack.java index 11aea3ec..f7507ee0 100644 --- a/library/Padstack.java +++ b/src/main/java/net/freerouting/library/Padstack.java @@ -18,19 +18,19 @@ * Created on 27. Mai 2004, 06:35 */ -package library; +package net.freerouting.library; -import geometry.planar.ConvexShape; -import geometry.planar.Direction; -import geometry.planar.IntBox; -import geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.Direction; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntOctagon; /** * Describes padstack masks for pins or vias located at the origin. * * @author alfons */ -public class Padstack implements Comparable, board.ObjectInfoPanel.Printable, java.io.Serializable +public class Padstack implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { /** @@ -152,10 +152,10 @@ public java.util.Collection get_trace_exit_directions(int p_layer, do return result; } - public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale) + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("padstack") + " "); p_window.append_bold(this.name); for (int i = 0; i < shapes.length; ++i) diff --git a/library/Padstacks.java b/src/main/java/net/freerouting/library/Padstacks.java similarity index 94% rename from library/Padstacks.java rename to src/main/java/net/freerouting/library/Padstacks.java index 532fd797..8d568c9e 100644 --- a/library/Padstacks.java +++ b/src/main/java/net/freerouting/library/Padstacks.java @@ -18,12 +18,12 @@ * Created on 3. Juni 2004, 09:42 */ -package library; +package net.freerouting.library; import java.util.Iterator; import java.util.Vector; -import geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.ConvexShape; /** * Describes a library of padstacks for pins or vias. @@ -33,7 +33,7 @@ public class Padstacks implements java.io.Serializable { /** Creates a new instance of Padstacks */ - public Padstacks(board.LayerStructure p_layer_structure) + public Padstacks(net.freerouting.board.LayerStructure p_layer_structure) { board_layer_structure = p_layer_structure; padstack_arr = new Vector(); @@ -130,5 +130,5 @@ public Padstack add(ConvexShape p_shape, int p_from_layer, int p_to_layer) private Vector padstack_arr; /** The layer structure of each padstack. */ - public final board.LayerStructure board_layer_structure; + public final net.freerouting.board.LayerStructure board_layer_structure; } diff --git a/library/package.html b/src/main/java/net/freerouting/library/package.html similarity index 100% rename from library/package.html rename to src/main/java/net/freerouting/library/package.html diff --git a/rules/BoardRules.java b/src/main/java/net/freerouting/rules/BoardRules.java similarity index 91% rename from rules/BoardRules.java rename to src/main/java/net/freerouting/rules/BoardRules.java index 98250b41..8f0f17d8 100644 --- a/rules/BoardRules.java +++ b/src/main/java/net/freerouting/rules/BoardRules.java @@ -18,9 +18,9 @@ * Created on 1. Juni 2004, 07:16 */ -package rules; +package net.freerouting.rules; -import geometry.planar.ConvexShape; +import net.freerouting.geometry.planar.ConvexShape; /** * Contains the rules and constraints required for items @@ -33,12 +33,12 @@ public class BoardRules implements java.io.Serializable /** * Creates a new instance of this class. */ - public BoardRules(board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) + public BoardRules(net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) { layer_structure = p_layer_structure; clearance_matrix = p_clearance_matrix; nets = new Nets(); - this.trace_angle_restriction = board.AngleRestriction.FORTYFIVE_DEGREE; + this.trace_angle_restriction = net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE; this.min_trace_half_width = 100000; this.max_trace_half_width = 100; @@ -181,7 +181,7 @@ public void create_default_via_rule(NetClass p_net_class, String p_name) ViaInfo curr_via_info = this.via_infos.get(i); if (curr_via_info.get_clearance_class() == default_via_cl_class) { - library.Padstack curr_padstack = curr_via_info.get_padstack(); + net.freerouting.library.Padstack curr_padstack = curr_via_info.get_padstack(); int curr_from_layer = curr_padstack.from_layer(); int curr_to_layer = curr_padstack.to_layer(); ViaInfo existing_via = default_rule.get_layer_range(curr_from_layer, curr_to_layer); @@ -279,9 +279,9 @@ public ViaRule get_via_rule(String p_name) * Changes the clearance class index of all objects on the board with index p_from_no * to p_to_no. */ - public void change_clearance_class_no(int p_from_no, int p_to_no, java.util.Collection p_board_items) + public void change_clearance_class_no(int p_from_no, int p_to_no, java.util.Collection p_board_items) { - for(board.Item curr_item : p_board_items) + for(net.freerouting.board.Item curr_item : p_board_items) { if (curr_item.clearance_class_no() == p_from_no) { @@ -291,7 +291,7 @@ public void change_clearance_class_no(int p_from_no, int p_to_no, java.util.Coll for (int i = 0; i < this.net_classes.count(); ++i) { - rules.NetClass curr_net_class = this.net_classes.get(i); + net.freerouting.rules.NetClass curr_net_class = this.net_classes.get(i); if (curr_net_class.get_trace_clearance_class() == p_from_no) { curr_net_class.set_trace_clearance_class(p_to_no); @@ -307,7 +307,7 @@ public void change_clearance_class_no(int p_from_no, int p_to_no, java.util.Coll for (int i = 0; i < this.via_infos.count(); ++i) { - rules.ViaInfo curr_via = this.via_infos.get(i); + net.freerouting.rules.ViaInfo curr_via = this.via_infos.get(i); if (curr_via.get_clearance_class() == p_from_no) { curr_via.set_clearance_class(p_to_no); @@ -320,9 +320,9 @@ public void change_clearance_class_no(int p_from_no, int p_to_no, java.util.Coll * Removes the clearance class with number p_index. * Returns false, if that was not possible, because there were still items assigned to this class. */ - public boolean remove_clearance_class(int p_index, java.util.Collection p_board_items) + public boolean remove_clearance_class(int p_index, java.util.Collection p_board_items) { - for(board.Item curr_item : p_board_items) + for(net.freerouting.board.Item curr_item : p_board_items) { if (curr_item.clearance_class_no() == p_index) { @@ -331,7 +331,7 @@ public boolean remove_clearance_class(int p_index, java.util.Collection p_index) { @@ -364,7 +364,7 @@ public boolean remove_clearance_class(int p_index, java.util.Collection p_index) { curr_net_class.set_trace_clearance_class(curr_net_class.get_trace_clearance_class() - 1); @@ -381,7 +381,7 @@ public boolean remove_clearance_class(int p_index, java.util.Collection p_index) { curr_via.set_clearance_class(curr_via.get_clearance_class() - 1); @@ -429,13 +429,13 @@ public boolean get_ignore_conduction() } /** The angle restriction for tracese: 90 degree, 45 degree or none. */ - public board.AngleRestriction get_trace_angle_restriction() + public net.freerouting.board.AngleRestriction get_trace_angle_restriction() { return this.trace_angle_restriction; } /** Sets the angle restriction for tracese: 90 degree, 45 degree or none. */ - public void set_trace_angle_restriction(board.AngleRestriction p_angle_restriction) + public void set_trace_angle_restriction(net.freerouting.board.AngleRestriction p_angle_restriction) { this.trace_angle_restriction = p_angle_restriction; } @@ -475,7 +475,7 @@ public double get_default_via_diameter() { return 0; } - library.Padstack via_padstack = default_via_rule.get_via(0).get_padstack(); + net.freerouting.library.Padstack via_padstack = default_via_rule.get_via(0).get_padstack(); ConvexShape curr_shape = via_padstack.get_shape(via_padstack.from_layer()); double result = curr_shape.max_width(); curr_shape = via_padstack.get_shape(via_padstack.to_layer()); @@ -498,7 +498,7 @@ private void readObject(java.io.ObjectInputStream p_stream) { p_stream.defaultReadObject(); int snap_angle_no = p_stream.readInt(); - this.trace_angle_restriction = board.AngleRestriction.arr[snap_angle_no]; + this.trace_angle_restriction = net.freerouting.board.AngleRestriction.arr[snap_angle_no]; } /** @@ -515,14 +515,14 @@ private void readObject(java.io.ObjectInputStream p_stream) /** The angle restriction for traces: 90 degree, 45 degree or none. */ - private transient board.AngleRestriction trace_angle_restriction; + private transient net.freerouting.board.AngleRestriction trace_angle_restriction; /** * If true, the router ignores conduction areas. */ private boolean ignore_conduction = true; - private final board.LayerStructure layer_structure; + private final net.freerouting.board.LayerStructure layer_structure; public final ViaInfos via_infos = new ViaInfos(); diff --git a/rules/ClearanceMatrix.java b/src/main/java/net/freerouting/rules/ClearanceMatrix.java similarity index 95% rename from rules/ClearanceMatrix.java rename to src/main/java/net/freerouting/rules/ClearanceMatrix.java index b755557b..54a6b3f5 100644 --- a/rules/ClearanceMatrix.java +++ b/src/main/java/net/freerouting/rules/ClearanceMatrix.java @@ -14,7 +14,7 @@ * for more details. */ -package rules; +package net.freerouting.rules; /** * @@ -31,7 +31,7 @@ public class ClearanceMatrix implements java.io.Serializable * Creates a new instance with the 2 clearance classes "none"and "default" * ans initializes it with p_default_value. */ - public static ClearanceMatrix get_default_instance(board.LayerStructure p_layer_structure, int p_default_value) + public static ClearanceMatrix get_default_instance(net.freerouting.board.LayerStructure p_layer_structure, int p_default_value) { String [] name_arr = new String [2]; name_arr[0] = "null"; @@ -46,7 +46,7 @@ public static ClearanceMatrix get_default_instance(board.LayerStructure p_layer_ * p_layer_count layers. * p_names is an array of dimension p_class_count; */ - public ClearanceMatrix(int p_class_count, board.LayerStructure p_layer_structure, String [] p_name_arr) + public ClearanceMatrix(int p_class_count, net.freerouting.board.LayerStructure p_layer_structure, String [] p_name_arr) { class_count = Math.max(p_class_count, 1); layer_structure = p_layer_structure; @@ -385,7 +385,7 @@ public boolean is_equal(int p_1, int p_2) */ private int class_count; - private final board.LayerStructure layer_structure; + private final net.freerouting.board.LayerStructure layer_structure; private Row [] row; // vector of class_count rows of the clearance matrix private int [] max_value_on_layer; // maximum clearance value for each layer @@ -393,7 +393,7 @@ public boolean is_equal(int p_1, int p_2) /** * contains a row of entries of the clearance matrix */ - private class Row implements board.ObjectInfoPanel.Printable, java.io.Serializable + private class Row implements net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { private Row(String p_name) { @@ -406,10 +406,10 @@ private Row(String p_name) max_value = new int[layer_structure.arr.length]; } - public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale) + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("spacing_from_clearance_class") + " "); p_window.append_bold(this.name); for (int i = 1; i < this.column.length; ++i) diff --git a/rules/DefaultItemClearanceClasses.java b/src/main/java/net/freerouting/rules/DefaultItemClearanceClasses.java similarity index 98% rename from rules/DefaultItemClearanceClasses.java rename to src/main/java/net/freerouting/rules/DefaultItemClearanceClasses.java index 36b87bbf..6d8764aa 100644 --- a/rules/DefaultItemClearanceClasses.java +++ b/src/main/java/net/freerouting/rules/DefaultItemClearanceClasses.java @@ -19,7 +19,7 @@ * */ -package rules; +package net.freerouting.rules; /** * diff --git a/rules/Net.java b/src/main/java/net/freerouting/rules/Net.java similarity index 81% rename from rules/Net.java rename to src/main/java/net/freerouting/rules/Net.java index 110c3c8c..5da312bf 100644 --- a/rules/Net.java +++ b/src/main/java/net/freerouting/rules/Net.java @@ -17,19 +17,19 @@ * * Created on 11. Juni 2004, 08:17 */ -package rules; +package net.freerouting.rules; -import board.Item; -import board.ObjectInfoPanel.Printable; +import net.freerouting.board.Item; +import net.freerouting.board.ObjectInfoPanel.Printable; -import datastructures.UndoableObjects; +import net.freerouting.datastructures.UndoableObjects; /** * Describes properties for an individual electrical net. * * @author Alfons Wirtz */ -public class Net implements Comparable, board.ObjectInfoPanel.Printable, java.io.Serializable +public class Net implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { /** @@ -78,7 +78,7 @@ public void set_class(NetClass p_rule) public java.util.Collection get_terminal_items() { java.util.Collection result = new java.util.LinkedList(); - board.BasicBoard board = this.net_list.get_board(); + net.freerouting.board.BasicBoard board = this.net_list.get_board(); java.util.Iterator it = board.item_list.start_read_object(); for (;;) { @@ -87,7 +87,7 @@ public java.util.Collection get_terminal_items() { break; } - if (curr_item instanceof board.Connectable) + if (curr_item instanceof net.freerouting.board.Connectable) { if (curr_item.contains_net(this.net_number) && !curr_item.is_route()) { @@ -101,10 +101,10 @@ public java.util.Collection get_terminal_items() /** * Returns the pins of this net. */ - public java.util.Collection get_pins() + public java.util.Collection get_pins() { - java.util.Collection result = new java.util.LinkedList(); - board.BasicBoard board = this.net_list.get_board(); + java.util.Collection result = new java.util.LinkedList(); + net.freerouting.board.BasicBoard board = this.net_list.get_board(); java.util.Iterator it = board.item_list.start_read_object(); for (;;) { @@ -113,11 +113,11 @@ public java.util.Collection get_pins() { break; } - if (curr_item instanceof board.Pin) + if (curr_item instanceof net.freerouting.board.Pin) { if (curr_item.contains_net(this.net_number)) { - result.add((board.Pin) curr_item); + result.add((net.freerouting.board.Pin) curr_item); } } } @@ -127,10 +127,10 @@ public java.util.Collection get_pins() /** * Returns all items of this net. */ - public java.util.Collection get_items() + public java.util.Collection get_items() { - java.util.Collection result = new java.util.LinkedList(); - board.BasicBoard board = this.net_list.get_board(); + java.util.Collection result = new java.util.LinkedList(); + net.freerouting.board.BasicBoard board = this.net_list.get_board(); java.util.Iterator it = board.item_list.start_read_object(); for (;;) { @@ -157,9 +157,9 @@ public double get_trace_length() for (Item curr_item : net_items) { - if (curr_item instanceof board.Trace) + if (curr_item instanceof net.freerouting.board.Trace) { - cumulative_trace_length += ((board.Trace) curr_item).get_length(); + cumulative_trace_length += ((net.freerouting.board.Trace) curr_item).get_length(); } } return cumulative_trace_length; @@ -174,7 +174,7 @@ public int get_via_count() java.util.Collection net_items = net_list.get_board().get_connectable_items(this.net_number); for (Item curr_item : net_items) { - if (curr_item instanceof board.Via) + if (curr_item instanceof net.freerouting.board.Via) { ++result; } @@ -198,7 +198,7 @@ public boolean contains_plane() return contains_plane; } - public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale) + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { Integer via_count = this.get_via_count(); double cumulative_trace_length = this.get_trace_length(); @@ -208,7 +208,7 @@ public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale Integer terminal_item_count = terminals.size(); java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("net") + " "); p_window.append_bold(this.name); p_window.append_bold(": "); diff --git a/rules/NetClass.java b/src/main/java/net/freerouting/rules/NetClass.java similarity index 95% rename from rules/NetClass.java rename to src/main/java/net/freerouting/rules/NetClass.java index fbf17af2..931c06b7 100644 --- a/rules/NetClass.java +++ b/src/main/java/net/freerouting/rules/NetClass.java @@ -17,18 +17,18 @@ * * Created on 7. April 2005, 06:08 */ -package rules; +package net.freerouting.rules; /** * Describes routing rules for individual nets. * * @author Alfons Wirtz */ -public class NetClass implements java.io.Serializable, board.ObjectInfoPanel.Printable +public class NetClass implements java.io.Serializable, net.freerouting.board.ObjectInfoPanel.Printable { /** Creates a new instance of NetClass */ - public NetClass(String p_name, board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) + public NetClass(String p_name, net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) { this.name = p_name; this.board_layer_structure = p_layer_structure; @@ -267,10 +267,10 @@ public void set_all_inner_layers_active(boolean p_value) } } - public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale) + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("net_class_2") + " "); p_window.append_bold(this.name); p_window.append_bold(":"); @@ -365,7 +365,7 @@ public boolean trace_width_is_inner_layer_dependent() private double minimum_trace_length = 0; private double maximum_trace_length = 0; private final ClearanceMatrix clearance_matrix; - private final board.LayerStructure board_layer_structure; + private final net.freerouting.board.LayerStructure board_layer_structure; /** * The clearance classes of the item types, if this net class comes from a class in a Speccctra dsn-file * Should evtl be moved to designformats.specctra.NetClass and used only when reading a dsn-file. diff --git a/rules/NetClasses.java b/src/main/java/net/freerouting/rules/NetClasses.java similarity index 92% rename from rules/NetClasses.java rename to src/main/java/net/freerouting/rules/NetClasses.java index f962d178..66ad7e39 100644 --- a/rules/NetClasses.java +++ b/src/main/java/net/freerouting/rules/NetClasses.java @@ -18,7 +18,7 @@ * Created on 7. April 2005, 07:52 */ -package rules; +package net.freerouting.rules; /** @@ -63,7 +63,7 @@ public NetClass get(String p_name) /** * Appends a new empty class with name p_name to the class array */ - NetClass append(String p_name, board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) + NetClass append(String p_name, net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) { NetClass new_class = new NetClass(p_name, p_layer_structure, p_clearance_matrix); class_arr.add(new_class); @@ -73,10 +73,10 @@ NetClass append(String p_name, board.LayerStructure p_layer_structure, Clearance /** * Appends a new empty class to the class array. A name for the class is created internally */ - NetClass append(board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix, java.util.Locale p_locale) + NetClass append(net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("rules.resources.Default", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.rules.Default", p_locale); String name_front = resources.getString("class"); String new_name = null; Integer index = 0; diff --git a/rules/Nets.java b/src/main/java/net/freerouting/rules/Nets.java similarity index 94% rename from rules/Nets.java rename to src/main/java/net/freerouting/rules/Nets.java index 7e6432b5..2de62295 100644 --- a/rules/Nets.java +++ b/src/main/java/net/freerouting/rules/Nets.java @@ -17,7 +17,7 @@ * * Created on 9. Juni 2004, 10:24 */ -package rules; +package net.freerouting.rules; import java.util.Vector; import java.util.Collection; @@ -98,7 +98,7 @@ public Net get(int p_net_no) */ public Net new_net(java.util.Locale p_locale) { - java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("rules.resources.Default", p_locale); + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.rules.Default", p_locale); String net_name = resources.getString("net#") + (new Integer(net_arr.size() + 1)).toString(); return add(net_name, 1, false); } @@ -133,7 +133,7 @@ public static boolean is_normal_net_no(int p_net_no) * Sets the Board of this net list. * Used for example to get access to the Items of the net. */ - public void set_board(board.BasicBoard p_board) + public void set_board(net.freerouting.board.BasicBoard p_board) { this.board = p_board; } @@ -142,7 +142,7 @@ public void set_board(board.BasicBoard p_board) * Gets the Board of this net list. * Used for example to get access to the Items of the net. */ - public board.BasicBoard get_board() + public net.freerouting.board.BasicBoard get_board() { return this.board; } @@ -155,5 +155,5 @@ public board.BasicBoard get_board() public static final int hidden_net_no = 10000001; /** The list of electrical nets on the board */ private Vector net_arr; - private board.BasicBoard board; + private net.freerouting.board.BasicBoard board; } diff --git a/rules/ViaInfo.java b/src/main/java/net/freerouting/rules/ViaInfo.java similarity index 89% rename from rules/ViaInfo.java rename to src/main/java/net/freerouting/rules/ViaInfo.java index d6176c4d..01324d5d 100644 --- a/rules/ViaInfo.java +++ b/src/main/java/net/freerouting/rules/ViaInfo.java @@ -18,8 +18,8 @@ * Created on 31. Maerz 2005, 05:34 */ -package rules; -import library.Padstack; +package net.freerouting.rules; +import net.freerouting.library.Padstack; /** * Information about a combination of via_padstack, via clearance class and drill_to_smd_allowed @@ -27,7 +27,7 @@ * * @author Alfons Wirtz */ -public class ViaInfo implements Comparable, board.ObjectInfoPanel.Printable, java.io.Serializable +public class ViaInfo implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { /** Creates a new instance of ViaRule */ @@ -91,10 +91,10 @@ public int compareTo(ViaInfo p_other) return this.name.compareTo(p_other.name); } - public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale) + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("via") + " "); p_window.append_bold(this.name); p_window.append_bold(": "); diff --git a/rules/ViaInfos.java b/src/main/java/net/freerouting/rules/ViaInfos.java similarity index 91% rename from rules/ViaInfos.java rename to src/main/java/net/freerouting/rules/ViaInfos.java index a9aa4f22..ded1c67b 100644 --- a/rules/ViaInfos.java +++ b/src/main/java/net/freerouting/rules/ViaInfos.java @@ -18,7 +18,7 @@ * Created on 2. April 2005, 06:49 */ -package rules; +package net.freerouting.rules; import java.util.List; import java.util.LinkedList; @@ -28,7 +28,7 @@ * * @author Alfons Wirtz */ -public class ViaInfos implements java.io.Serializable, board.ObjectInfoPanel.Printable +public class ViaInfos implements java.io.Serializable, net.freerouting.board.ObjectInfoPanel.Printable { /** * Adds a via info consisting of padstack, clearance class and drill_to_smd_allowed. @@ -100,10 +100,10 @@ public boolean remove(ViaInfo p_via_info) return this.list.remove(p_via_info); } - public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale) + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("vias") + ": "); int counter = 0; boolean first_time = true; diff --git a/rules/ViaRule.java b/src/main/java/net/freerouting/rules/ViaRule.java similarity index 91% rename from rules/ViaRule.java rename to src/main/java/net/freerouting/rules/ViaRule.java index 6145e4be..2cca28c8 100644 --- a/rules/ViaRule.java +++ b/src/main/java/net/freerouting/rules/ViaRule.java @@ -18,7 +18,7 @@ * Created on 31. Maerz 2005, 06:44 */ -package rules; +package net.freerouting.rules; import java.util.List; import java.util.LinkedList; @@ -29,7 +29,7 @@ * * @author Alfons Wirtz */ -public class ViaRule implements java.io.Serializable, board.ObjectInfoPanel.Printable +public class ViaRule implements java.io.Serializable, net.freerouting.board.ObjectInfoPanel.Printable { /** Empty via rule. Must nott be changed. */ @@ -88,7 +88,7 @@ public boolean contains(ViaInfo p_via_info) /** * Returns true, if this rule contains a via with padstack p_padstack */ - public boolean contains_padstack(library.Padstack p_padstack) + public boolean contains_padstack(net.freerouting.library.Padstack p_padstack) { for (ViaInfo curr_info : this.list) { @@ -137,10 +137,10 @@ public boolean swap(ViaInfo p_1, ViaInfo p_2) return true; } - public void print_info(board.ObjectInfoPanel p_window, java.util.Locale p_locale) + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", p_locale); + java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("via_rule_2") + " "); p_window.append_bold(this.name); p_window.append_bold(":"); diff --git a/rules/package.html b/src/main/java/net/freerouting/rules/package.html similarity index 100% rename from rules/package.html rename to src/main/java/net/freerouting/rules/package.html diff --git a/tests/Validate.java b/src/main/java/net/freerouting/tests/Validate.java similarity index 93% rename from tests/Validate.java rename to src/main/java/net/freerouting/tests/Validate.java index 5dac01a9..808c1c9b 100644 --- a/tests/Validate.java +++ b/src/main/java/net/freerouting/tests/Validate.java @@ -18,20 +18,20 @@ * Created on 7. Dezember 2002, 18:26 */ -package tests; +package net.freerouting.tests; -import geometry.planar.IntOctagon; -import geometry.planar.IntPoint; -import geometry.planar.Polyline; -import geometry.planar.TileShape; +import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Polyline; +import net.freerouting.geometry.planar.TileShape; import java.util.Collection; import java.util.Iterator; -import board.Item; -import board.BasicBoard; -import board.PolylineTrace; -import board.SearchTreeObject; +import net.freerouting.board.Item; +import net.freerouting.board.BasicBoard; +import net.freerouting.board.PolylineTrace; +import net.freerouting.board.SearchTreeObject; /** @@ -48,7 +48,7 @@ public class Validate */ public static boolean check(String p_s, BasicBoard p_board) { - if (p_board.get_test_level() == board.TestLevel.RELEASE_VERSION) + if (p_board.get_test_level() == net.freerouting.board.TestLevel.RELEASE_VERSION) { return true; } @@ -271,11 +271,11 @@ static public boolean has_cycles(String p_s, BasicBoard p_board) while (it.hasNext()) { Item curr_item = it.next(); - if (!(curr_item instanceof board.Trace)) + if (!(curr_item instanceof net.freerouting.board.Trace)) { continue; } - if(((board.Trace)curr_item).is_cycle()) + if(((net.freerouting.board.Trace)curr_item).is_cycle()) { System.out.print(p_s); System.out.println(": cycle found"); @@ -295,9 +295,9 @@ static public boolean trace_count_exceeded(String p_s, BasicBoard p_board, int p while (it.hasNext()) { Item curr_ob = it.next(); - if(curr_ob instanceof board.Trace) + if(curr_ob instanceof net.freerouting.board.Trace) { - if (((board.Trace)curr_ob).contains_net(p_net_no)) + if (((net.freerouting.board.Trace)curr_ob).contains_net(p_net_no)) { ++found_traces; } diff --git a/tests/package.html b/src/main/java/net/freerouting/tests/package.html similarity index 100% rename from tests/package.html rename to src/main/java/net/freerouting/tests/package.html diff --git a/board/resources/FixedState_de.properties b/src/main/resources/net/freerouting/board/FixedState_de.properties similarity index 100% rename from board/resources/FixedState_de.properties rename to src/main/resources/net/freerouting/board/FixedState_de.properties diff --git a/board/resources/FixedState_en.properties b/src/main/resources/net/freerouting/board/FixedState_en.properties similarity index 100% rename from board/resources/FixedState_en.properties rename to src/main/resources/net/freerouting/board/FixedState_en.properties diff --git a/board/resources/ObjectInfoPanel_de.properties b/src/main/resources/net/freerouting/board/ObjectInfoPanel_de.properties similarity index 100% rename from board/resources/ObjectInfoPanel_de.properties rename to src/main/resources/net/freerouting/board/ObjectInfoPanel_de.properties diff --git a/board/resources/ObjectInfoPanel_en.properties b/src/main/resources/net/freerouting/board/ObjectInfoPanel_en.properties similarity index 100% rename from board/resources/ObjectInfoPanel_en.properties rename to src/main/resources/net/freerouting/board/ObjectInfoPanel_en.properties diff --git a/boardgraphics/resources/ColorTableModel_de.properties b/src/main/resources/net/freerouting/boardgraphics/ColorTableModel_de.properties similarity index 100% rename from boardgraphics/resources/ColorTableModel_de.properties rename to src/main/resources/net/freerouting/boardgraphics/ColorTableModel_de.properties diff --git a/boardgraphics/resources/ColorTableModel_en.properties b/src/main/resources/net/freerouting/boardgraphics/ColorTableModel_en.properties similarity index 100% rename from boardgraphics/resources/ColorTableModel_en.properties rename to src/main/resources/net/freerouting/boardgraphics/ColorTableModel_en.properties diff --git a/gui/resources/BoardFrame_de.properties b/src/main/resources/net/freerouting/gui/BoardFrame_de.properties similarity index 100% rename from gui/resources/BoardFrame_de.properties rename to src/main/resources/net/freerouting/gui/BoardFrame_de.properties diff --git a/gui/resources/BoardFrame_en.properties b/src/main/resources/net/freerouting/gui/BoardFrame_en.properties similarity index 100% rename from gui/resources/BoardFrame_en.properties rename to src/main/resources/net/freerouting/gui/BoardFrame_en.properties diff --git a/gui/resources/BoardMenuDisplay_de.properties b/src/main/resources/net/freerouting/gui/BoardMenuDisplay_de.properties similarity index 100% rename from gui/resources/BoardMenuDisplay_de.properties rename to src/main/resources/net/freerouting/gui/BoardMenuDisplay_de.properties diff --git a/gui/resources/BoardMenuDisplay_en.properties b/src/main/resources/net/freerouting/gui/BoardMenuDisplay_en.properties similarity index 100% rename from gui/resources/BoardMenuDisplay_en.properties rename to src/main/resources/net/freerouting/gui/BoardMenuDisplay_en.properties diff --git a/gui/resources/BoardMenuFile_de.properties b/src/main/resources/net/freerouting/gui/BoardMenuFile_de.properties similarity index 100% rename from gui/resources/BoardMenuFile_de.properties rename to src/main/resources/net/freerouting/gui/BoardMenuFile_de.properties diff --git a/gui/resources/BoardMenuFile_en.properties b/src/main/resources/net/freerouting/gui/BoardMenuFile_en.properties similarity index 100% rename from gui/resources/BoardMenuFile_en.properties rename to src/main/resources/net/freerouting/gui/BoardMenuFile_en.properties diff --git a/gui/resources/BoardMenuHelp_de.properties b/src/main/resources/net/freerouting/gui/BoardMenuHelp_de.properties similarity index 100% rename from gui/resources/BoardMenuHelp_de.properties rename to src/main/resources/net/freerouting/gui/BoardMenuHelp_de.properties diff --git a/gui/resources/BoardMenuHelp_en.properties b/src/main/resources/net/freerouting/gui/BoardMenuHelp_en.properties similarity index 100% rename from gui/resources/BoardMenuHelp_en.properties rename to src/main/resources/net/freerouting/gui/BoardMenuHelp_en.properties diff --git a/gui/resources/BoardMenuInfo_de.properties b/src/main/resources/net/freerouting/gui/BoardMenuInfo_de.properties similarity index 100% rename from gui/resources/BoardMenuInfo_de.properties rename to src/main/resources/net/freerouting/gui/BoardMenuInfo_de.properties diff --git a/gui/resources/BoardMenuInfo_en.properties b/src/main/resources/net/freerouting/gui/BoardMenuInfo_en.properties similarity index 100% rename from gui/resources/BoardMenuInfo_en.properties rename to src/main/resources/net/freerouting/gui/BoardMenuInfo_en.properties diff --git a/gui/resources/BoardMenuOther_de.properties b/src/main/resources/net/freerouting/gui/BoardMenuOther_de.properties similarity index 100% rename from gui/resources/BoardMenuOther_de.properties rename to src/main/resources/net/freerouting/gui/BoardMenuOther_de.properties diff --git a/gui/resources/BoardMenuOther_en.properties b/src/main/resources/net/freerouting/gui/BoardMenuOther_en.properties similarity index 100% rename from gui/resources/BoardMenuOther_en.properties rename to src/main/resources/net/freerouting/gui/BoardMenuOther_en.properties diff --git a/gui/resources/BoardMenuParameter_de.properties b/src/main/resources/net/freerouting/gui/BoardMenuParameter_de.properties similarity index 100% rename from gui/resources/BoardMenuParameter_de.properties rename to src/main/resources/net/freerouting/gui/BoardMenuParameter_de.properties diff --git a/gui/resources/BoardMenuParameter_en.properties b/src/main/resources/net/freerouting/gui/BoardMenuParameter_en.properties similarity index 100% rename from gui/resources/BoardMenuParameter_en.properties rename to src/main/resources/net/freerouting/gui/BoardMenuParameter_en.properties diff --git a/gui/resources/BoardMenuRules_de.properties b/src/main/resources/net/freerouting/gui/BoardMenuRules_de.properties similarity index 100% rename from gui/resources/BoardMenuRules_de.properties rename to src/main/resources/net/freerouting/gui/BoardMenuRules_de.properties diff --git a/gui/resources/BoardMenuRules_en.properties b/src/main/resources/net/freerouting/gui/BoardMenuRules_en.properties similarity index 100% rename from gui/resources/BoardMenuRules_en.properties rename to src/main/resources/net/freerouting/gui/BoardMenuRules_en.properties diff --git a/gui/resources/BoardPanelStatus_de.properties b/src/main/resources/net/freerouting/gui/BoardPanelStatus_de.properties similarity index 100% rename from gui/resources/BoardPanelStatus_de.properties rename to src/main/resources/net/freerouting/gui/BoardPanelStatus_de.properties diff --git a/gui/resources/BoardPanelStatus_en.properties b/src/main/resources/net/freerouting/gui/BoardPanelStatus_en.properties similarity index 100% rename from gui/resources/BoardPanelStatus_en.properties rename to src/main/resources/net/freerouting/gui/BoardPanelStatus_en.properties diff --git a/gui/resources/BoardToolbarSelectedItem_de.properties b/src/main/resources/net/freerouting/gui/BoardToolbarSelectedItem_de.properties similarity index 100% rename from gui/resources/BoardToolbarSelectedItem_de.properties rename to src/main/resources/net/freerouting/gui/BoardToolbarSelectedItem_de.properties diff --git a/gui/resources/BoardToolbarSelectedItem_en.properties b/src/main/resources/net/freerouting/gui/BoardToolbarSelectedItem_en.properties similarity index 100% rename from gui/resources/BoardToolbarSelectedItem_en.properties rename to src/main/resources/net/freerouting/gui/BoardToolbarSelectedItem_en.properties diff --git a/gui/resources/BoardToolbar_de.properties b/src/main/resources/net/freerouting/gui/BoardToolbar_de.properties similarity index 100% rename from gui/resources/BoardToolbar_de.properties rename to src/main/resources/net/freerouting/gui/BoardToolbar_de.properties diff --git a/gui/resources/BoardToolbar_en.properties b/src/main/resources/net/freerouting/gui/BoardToolbar_en.properties similarity index 100% rename from gui/resources/BoardToolbar_en.properties rename to src/main/resources/net/freerouting/gui/BoardToolbar_en.properties diff --git a/gui/resources/CleanupWindows_de.properties b/src/main/resources/net/freerouting/gui/CleanupWindows_de.properties similarity index 100% rename from gui/resources/CleanupWindows_de.properties rename to src/main/resources/net/freerouting/gui/CleanupWindows_de.properties diff --git a/gui/resources/CleanupWindows_en.properties b/src/main/resources/net/freerouting/gui/CleanupWindows_en.properties similarity index 100% rename from gui/resources/CleanupWindows_en.properties rename to src/main/resources/net/freerouting/gui/CleanupWindows_en.properties diff --git a/gui/resources/Default_de.properties b/src/main/resources/net/freerouting/gui/Default_de.properties similarity index 100% rename from gui/resources/Default_de.properties rename to src/main/resources/net/freerouting/gui/Default_de.properties diff --git a/gui/resources/Default_en.properties b/src/main/resources/net/freerouting/gui/Default_en.properties similarity index 100% rename from gui/resources/Default_en.properties rename to src/main/resources/net/freerouting/gui/Default_en.properties diff --git a/gui/resources/DisplayMisc_de.properties b/src/main/resources/net/freerouting/gui/DisplayMisc_de.properties similarity index 100% rename from gui/resources/DisplayMisc_de.properties rename to src/main/resources/net/freerouting/gui/DisplayMisc_de.properties diff --git a/gui/resources/DisplayMisc_en.properties b/src/main/resources/net/freerouting/gui/DisplayMisc_en.properties similarity index 100% rename from gui/resources/DisplayMisc_en.properties rename to src/main/resources/net/freerouting/gui/DisplayMisc_en.properties diff --git a/gui/resources/MainApplication_de.properties b/src/main/resources/net/freerouting/gui/MainApplication_de.properties similarity index 100% rename from gui/resources/MainApplication_de.properties rename to src/main/resources/net/freerouting/gui/MainApplication_de.properties diff --git a/gui/resources/MainApplication_en.properties b/src/main/resources/net/freerouting/gui/MainApplication_en.properties similarity index 100% rename from gui/resources/MainApplication_en.properties rename to src/main/resources/net/freerouting/gui/MainApplication_en.properties diff --git a/gui/resources/PopupMenuMain_de.properties b/src/main/resources/net/freerouting/gui/PopupMenuMain_de.properties similarity index 100% rename from gui/resources/PopupMenuMain_de.properties rename to src/main/resources/net/freerouting/gui/PopupMenuMain_de.properties diff --git a/gui/resources/PopupMenuMain_en.properties b/src/main/resources/net/freerouting/gui/PopupMenuMain_en.properties similarity index 100% rename from gui/resources/PopupMenuMain_en.properties rename to src/main/resources/net/freerouting/gui/PopupMenuMain_en.properties diff --git a/gui/resources/PopupMenuMove_de.properties b/src/main/resources/net/freerouting/gui/PopupMenuMove_de.properties similarity index 100% rename from gui/resources/PopupMenuMove_de.properties rename to src/main/resources/net/freerouting/gui/PopupMenuMove_de.properties diff --git a/gui/resources/PopupMenuMove_en.properties b/src/main/resources/net/freerouting/gui/PopupMenuMove_en.properties similarity index 100% rename from gui/resources/PopupMenuMove_en.properties rename to src/main/resources/net/freerouting/gui/PopupMenuMove_en.properties diff --git a/gui/resources/WindowAbout_de.properties b/src/main/resources/net/freerouting/gui/WindowAbout_de.properties similarity index 100% rename from gui/resources/WindowAbout_de.properties rename to src/main/resources/net/freerouting/gui/WindowAbout_de.properties diff --git a/gui/resources/WindowAbout_en.properties b/src/main/resources/net/freerouting/gui/WindowAbout_en.properties similarity index 100% rename from gui/resources/WindowAbout_en.properties rename to src/main/resources/net/freerouting/gui/WindowAbout_en.properties diff --git a/gui/resources/WindowAssignNetClass_de.properties b/src/main/resources/net/freerouting/gui/WindowAssignNetClass_de.properties similarity index 100% rename from gui/resources/WindowAssignNetClass_de.properties rename to src/main/resources/net/freerouting/gui/WindowAssignNetClass_de.properties diff --git a/gui/resources/WindowAssignNetClass_en.properties b/src/main/resources/net/freerouting/gui/WindowAssignNetClass_en.properties similarity index 100% rename from gui/resources/WindowAssignNetClass_en.properties rename to src/main/resources/net/freerouting/gui/WindowAssignNetClass_en.properties diff --git a/gui/resources/WindowAutorouteParameter_de.properties b/src/main/resources/net/freerouting/gui/WindowAutorouteParameter_de.properties similarity index 100% rename from gui/resources/WindowAutorouteParameter_de.properties rename to src/main/resources/net/freerouting/gui/WindowAutorouteParameter_de.properties diff --git a/gui/resources/WindowAutorouteParameter_en.properties b/src/main/resources/net/freerouting/gui/WindowAutorouteParameter_en.properties similarity index 100% rename from gui/resources/WindowAutorouteParameter_en.properties rename to src/main/resources/net/freerouting/gui/WindowAutorouteParameter_en.properties diff --git a/gui/resources/WindowClearanceMatrix_de.properties b/src/main/resources/net/freerouting/gui/WindowClearanceMatrix_de.properties similarity index 100% rename from gui/resources/WindowClearanceMatrix_de.properties rename to src/main/resources/net/freerouting/gui/WindowClearanceMatrix_de.properties diff --git a/gui/resources/WindowClearanceMatrix_en.properties b/src/main/resources/net/freerouting/gui/WindowClearanceMatrix_en.properties similarity index 100% rename from gui/resources/WindowClearanceMatrix_en.properties rename to src/main/resources/net/freerouting/gui/WindowClearanceMatrix_en.properties diff --git a/gui/resources/WindowClearanceViolations_de.properties b/src/main/resources/net/freerouting/gui/WindowClearanceViolations_de.properties similarity index 100% rename from gui/resources/WindowClearanceViolations_de.properties rename to src/main/resources/net/freerouting/gui/WindowClearanceViolations_de.properties diff --git a/gui/resources/WindowClearanceViolations_en.properties b/src/main/resources/net/freerouting/gui/WindowClearanceViolations_en.properties similarity index 100% rename from gui/resources/WindowClearanceViolations_en.properties rename to src/main/resources/net/freerouting/gui/WindowClearanceViolations_en.properties diff --git a/gui/resources/WindowEditVias_de.properties b/src/main/resources/net/freerouting/gui/WindowEditVias_de.properties similarity index 100% rename from gui/resources/WindowEditVias_de.properties rename to src/main/resources/net/freerouting/gui/WindowEditVias_de.properties diff --git a/gui/resources/WindowEditVias_en.properties b/src/main/resources/net/freerouting/gui/WindowEditVias_en.properties similarity index 100% rename from gui/resources/WindowEditVias_en.properties rename to src/main/resources/net/freerouting/gui/WindowEditVias_en.properties diff --git a/gui/resources/WindowLengthViolations_de.properties b/src/main/resources/net/freerouting/gui/WindowLengthViolations_de.properties similarity index 100% rename from gui/resources/WindowLengthViolations_de.properties rename to src/main/resources/net/freerouting/gui/WindowLengthViolations_de.properties diff --git a/gui/resources/WindowLengthViolations_en.properties b/src/main/resources/net/freerouting/gui/WindowLengthViolations_en.properties similarity index 100% rename from gui/resources/WindowLengthViolations_en.properties rename to src/main/resources/net/freerouting/gui/WindowLengthViolations_en.properties diff --git a/gui/resources/WindowManualRule_de.properties b/src/main/resources/net/freerouting/gui/WindowManualRule_de.properties similarity index 100% rename from gui/resources/WindowManualRule_de.properties rename to src/main/resources/net/freerouting/gui/WindowManualRule_de.properties diff --git a/gui/resources/WindowManualRule_en.properties b/src/main/resources/net/freerouting/gui/WindowManualRule_en.properties similarity index 100% rename from gui/resources/WindowManualRule_en.properties rename to src/main/resources/net/freerouting/gui/WindowManualRule_en.properties diff --git a/gui/resources/WindowMoveParameter_de.properties b/src/main/resources/net/freerouting/gui/WindowMoveParameter_de.properties similarity index 100% rename from gui/resources/WindowMoveParameter_de.properties rename to src/main/resources/net/freerouting/gui/WindowMoveParameter_de.properties diff --git a/gui/resources/WindowMoveParameter_en.properties b/src/main/resources/net/freerouting/gui/WindowMoveParameter_en.properties similarity index 100% rename from gui/resources/WindowMoveParameter_en.properties rename to src/main/resources/net/freerouting/gui/WindowMoveParameter_en.properties diff --git a/gui/resources/WindowNetClasses_de.properties b/src/main/resources/net/freerouting/gui/WindowNetClasses_de.properties similarity index 100% rename from gui/resources/WindowNetClasses_de.properties rename to src/main/resources/net/freerouting/gui/WindowNetClasses_de.properties diff --git a/gui/resources/WindowNetClasses_en.properties b/src/main/resources/net/freerouting/gui/WindowNetClasses_en.properties similarity index 100% rename from gui/resources/WindowNetClasses_en.properties rename to src/main/resources/net/freerouting/gui/WindowNetClasses_en.properties diff --git a/gui/resources/WindowNetSamples_de.properties b/src/main/resources/net/freerouting/gui/WindowNetSamples_de.properties similarity index 100% rename from gui/resources/WindowNetSamples_de.properties rename to src/main/resources/net/freerouting/gui/WindowNetSamples_de.properties diff --git a/gui/resources/WindowNetSamples_en.properties b/src/main/resources/net/freerouting/gui/WindowNetSamples_en.properties similarity index 100% rename from gui/resources/WindowNetSamples_en.properties rename to src/main/resources/net/freerouting/gui/WindowNetSamples_en.properties diff --git a/gui/resources/WindowNets_de.properties b/src/main/resources/net/freerouting/gui/WindowNets_de.properties similarity index 100% rename from gui/resources/WindowNets_de.properties rename to src/main/resources/net/freerouting/gui/WindowNets_de.properties diff --git a/gui/resources/WindowNets_en.properties b/src/main/resources/net/freerouting/gui/WindowNets_en.properties similarity index 100% rename from gui/resources/WindowNets_en.properties rename to src/main/resources/net/freerouting/gui/WindowNets_en.properties diff --git a/gui/resources/WindowObjectInfo_de.properties b/src/main/resources/net/freerouting/gui/WindowObjectInfo_de.properties similarity index 100% rename from gui/resources/WindowObjectInfo_de.properties rename to src/main/resources/net/freerouting/gui/WindowObjectInfo_de.properties diff --git a/gui/resources/WindowObjectInfo_en.properties b/src/main/resources/net/freerouting/gui/WindowObjectInfo_en.properties similarity index 100% rename from gui/resources/WindowObjectInfo_en.properties rename to src/main/resources/net/freerouting/gui/WindowObjectInfo_en.properties diff --git a/gui/resources/WindowObjectList_de.properties b/src/main/resources/net/freerouting/gui/WindowObjectList_de.properties similarity index 100% rename from gui/resources/WindowObjectList_de.properties rename to src/main/resources/net/freerouting/gui/WindowObjectList_de.properties diff --git a/gui/resources/WindowObjectList_en.properties b/src/main/resources/net/freerouting/gui/WindowObjectList_en.properties similarity index 100% rename from gui/resources/WindowObjectList_en.properties rename to src/main/resources/net/freerouting/gui/WindowObjectList_en.properties diff --git a/gui/resources/WindowObjectVisibility_de.properties b/src/main/resources/net/freerouting/gui/WindowObjectVisibility_de.properties similarity index 100% rename from gui/resources/WindowObjectVisibility_de.properties rename to src/main/resources/net/freerouting/gui/WindowObjectVisibility_de.properties diff --git a/gui/resources/WindowObjectVisibility_en.properties b/src/main/resources/net/freerouting/gui/WindowObjectVisibility_en.properties similarity index 100% rename from gui/resources/WindowObjectVisibility_en.properties rename to src/main/resources/net/freerouting/gui/WindowObjectVisibility_en.properties diff --git a/gui/resources/WindowRouteDetail_de.properties b/src/main/resources/net/freerouting/gui/WindowRouteDetail_de.properties similarity index 100% rename from gui/resources/WindowRouteDetail_de.properties rename to src/main/resources/net/freerouting/gui/WindowRouteDetail_de.properties diff --git a/gui/resources/WindowRouteDetail_en.properties b/src/main/resources/net/freerouting/gui/WindowRouteDetail_en.properties similarity index 100% rename from gui/resources/WindowRouteDetail_en.properties rename to src/main/resources/net/freerouting/gui/WindowRouteDetail_en.properties diff --git a/gui/resources/WindowRouteParameter_de.properties b/src/main/resources/net/freerouting/gui/WindowRouteParameter_de.properties similarity index 100% rename from gui/resources/WindowRouteParameter_de.properties rename to src/main/resources/net/freerouting/gui/WindowRouteParameter_de.properties diff --git a/gui/resources/WindowRouteParameter_en.properties b/src/main/resources/net/freerouting/gui/WindowRouteParameter_en.properties similarity index 100% rename from gui/resources/WindowRouteParameter_en.properties rename to src/main/resources/net/freerouting/gui/WindowRouteParameter_en.properties diff --git a/gui/resources/WindowSelectParameter_de.properties b/src/main/resources/net/freerouting/gui/WindowSelectParameter_de.properties similarity index 100% rename from gui/resources/WindowSelectParameter_de.properties rename to src/main/resources/net/freerouting/gui/WindowSelectParameter_de.properties diff --git a/gui/resources/WindowSelectParameter_en.properties b/src/main/resources/net/freerouting/gui/WindowSelectParameter_en.properties similarity index 100% rename from gui/resources/WindowSelectParameter_en.properties rename to src/main/resources/net/freerouting/gui/WindowSelectParameter_en.properties diff --git a/gui/resources/WindowSnapshotSettings_de.properties b/src/main/resources/net/freerouting/gui/WindowSnapshotSettings_de.properties similarity index 100% rename from gui/resources/WindowSnapshotSettings_de.properties rename to src/main/resources/net/freerouting/gui/WindowSnapshotSettings_de.properties diff --git a/gui/resources/WindowSnapshotSettings_en.properties b/src/main/resources/net/freerouting/gui/WindowSnapshotSettings_en.properties similarity index 100% rename from gui/resources/WindowSnapshotSettings_en.properties rename to src/main/resources/net/freerouting/gui/WindowSnapshotSettings_en.properties diff --git a/gui/resources/WindowSnapshot_de.properties b/src/main/resources/net/freerouting/gui/WindowSnapshot_de.properties similarity index 100% rename from gui/resources/WindowSnapshot_de.properties rename to src/main/resources/net/freerouting/gui/WindowSnapshot_de.properties diff --git a/gui/resources/WindowSnapshot_en.properties b/src/main/resources/net/freerouting/gui/WindowSnapshot_en.properties similarity index 100% rename from gui/resources/WindowSnapshot_en.properties rename to src/main/resources/net/freerouting/gui/WindowSnapshot_en.properties diff --git a/gui/resources/WindowViaRule_de.properties b/src/main/resources/net/freerouting/gui/WindowViaRule_de.properties similarity index 100% rename from gui/resources/WindowViaRule_de.properties rename to src/main/resources/net/freerouting/gui/WindowViaRule_de.properties diff --git a/gui/resources/WindowViaRule_en.properties b/src/main/resources/net/freerouting/gui/WindowViaRule_en.properties similarity index 100% rename from gui/resources/WindowViaRule_en.properties rename to src/main/resources/net/freerouting/gui/WindowViaRule_en.properties diff --git a/gui/resources/WindowVia_de.properties b/src/main/resources/net/freerouting/gui/WindowVia_de.properties similarity index 100% rename from gui/resources/WindowVia_de.properties rename to src/main/resources/net/freerouting/gui/WindowVia_de.properties diff --git a/gui/resources/WindowVia_en.properties b/src/main/resources/net/freerouting/gui/WindowVia_en.properties similarity index 100% rename from gui/resources/WindowVia_en.properties rename to src/main/resources/net/freerouting/gui/WindowVia_en.properties diff --git a/interactive/resources/BoardHandling_de.properties b/src/main/resources/net/freerouting/interactive/BoardHandling_de.properties similarity index 100% rename from interactive/resources/BoardHandling_de.properties rename to src/main/resources/net/freerouting/interactive/BoardHandling_de.properties diff --git a/interactive/resources/BoardHandling_en.properties b/src/main/resources/net/freerouting/interactive/BoardHandling_en.properties similarity index 100% rename from interactive/resources/BoardHandling_en.properties rename to src/main/resources/net/freerouting/interactive/BoardHandling_en.properties diff --git a/interactive/resources/InteractiveState_de.properties b/src/main/resources/net/freerouting/interactive/InteractiveState_de.properties similarity index 100% rename from interactive/resources/InteractiveState_de.properties rename to src/main/resources/net/freerouting/interactive/InteractiveState_de.properties diff --git a/interactive/resources/InteractiveState_en.properties b/src/main/resources/net/freerouting/interactive/InteractiveState_en.properties similarity index 100% rename from interactive/resources/InteractiveState_en.properties rename to src/main/resources/net/freerouting/interactive/InteractiveState_en.properties diff --git a/interactive/resources/RatsNest_de.properties b/src/main/resources/net/freerouting/interactive/RatsNest_de.properties similarity index 100% rename from interactive/resources/RatsNest_de.properties rename to src/main/resources/net/freerouting/interactive/RatsNest_de.properties diff --git a/interactive/resources/RatsNest_en.properties b/src/main/resources/net/freerouting/interactive/RatsNest_en.properties similarity index 100% rename from interactive/resources/RatsNest_en.properties rename to src/main/resources/net/freerouting/interactive/RatsNest_en.properties diff --git a/interactive/resources/ScreenMessages_de.properties b/src/main/resources/net/freerouting/interactive/ScreenMessages_de.properties similarity index 100% rename from interactive/resources/ScreenMessages_de.properties rename to src/main/resources/net/freerouting/interactive/ScreenMessages_de.properties diff --git a/interactive/resources/ScreenMessages_en.properties b/src/main/resources/net/freerouting/interactive/ScreenMessages_en.properties similarity index 100% rename from interactive/resources/ScreenMessages_en.properties rename to src/main/resources/net/freerouting/interactive/ScreenMessages_en.properties diff --git a/rules/resources/Default_de.properties b/src/main/resources/net/freerouting/rules/Default_de.properties similarity index 100% rename from rules/resources/Default_de.properties rename to src/main/resources/net/freerouting/rules/Default_de.properties diff --git a/rules/resources/Default_en.properties b/src/main/resources/net/freerouting/rules/Default_en.properties similarity index 100% rename from rules/resources/Default_en.properties rename to src/main/resources/net/freerouting/rules/Default_en.properties From 29097e4f0a104c51c451ec61e3bea9fc87cca482 Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Mon, 29 Dec 2014 10:35:40 +0300 Subject: [PATCH 02/14] Disabled help --- src/main/java/net/freerouting/gui/BoardFrame.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/freerouting/gui/BoardFrame.java b/src/main/java/net/freerouting/gui/BoardFrame.java index 2b06872d..7e7b4f44 100644 --- a/src/main/java/net/freerouting/gui/BoardFrame.java +++ b/src/main/java/net/freerouting/gui/BoardFrame.java @@ -380,7 +380,8 @@ public void set_context_sensitive_help(java.awt.Component p_component, String p_ javax.help.CSH.setHelpIDString(curr_component, help_id); if (!this.is_web_start) { - help_broker.enableHelpKey(curr_component, help_id, help_set); + //FIXME +// help_broker.enableHelpKey(curr_component, help_id, help_set); } } } From c4f5205f54a3e07381a11aed94bc16f684d4bbff Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Mon, 29 Dec 2014 10:44:17 +0300 Subject: [PATCH 03/14] Added README section about running as a standalone app --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 92321185..1b313c85 100644 --- a/README.md +++ b/README.md @@ -76,3 +76,11 @@ Here are some instructions how to run the Freerouting project in the NetBeans ID For optional parameters of the Freerouting outfile check the usage of the variable p_args in the source file gui/MainApplication.java. +How to run the Freerouting project as a standalone application +=========================================================================================== + +```shell +$ mvn package + +$ java -jar target/freerouting-1.0-SNAPSHOT-jar-with-dependencies.jar +``` \ No newline at end of file From 05e43d1cc59939713de4e8fad4581bb06778daa9 Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Thu, 17 Sep 2015 20:05:23 +0300 Subject: [PATCH 04/14] Changed jnlp-api implementation --- pom.xml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 2730d1f5..bcfd65db 100644 --- a/pom.xml +++ b/pom.xml @@ -27,11 +27,9 @@ 2.0.05 - javax.jnlp - jnlp-api - 7.0 - system - /usr/share/icedtea-web/netx.jar + org.jvnet.hudson + netx + 0.5-hudson-2 From 1913c059b327887067c4a9c356b35b4895ea6d09 Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Thu, 17 Sep 2015 20:05:04 +0300 Subject: [PATCH 05/14] Added support for building via gradle --- .gitignore | 8 ++++++-- build.gradle | 43 +++++++++++++++++++++++++++++++++++++++++++ settings.gradle | 19 +++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 build.gradle create mode 100644 settings.gradle diff --git a/.gitignore b/.gitignore index ec105515..611048e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ -target/ -.idea/ +/target +.idea +/.gradle +/build *.iml +*.swp + diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..9f9e2e1d --- /dev/null +++ b/build.gradle @@ -0,0 +1,43 @@ +/* + * This build file was auto generated by running the Gradle 'init' task + * by 'Anand.Tamariya' at '5/31/15 6:50 PM' with Gradle 2.2.1 + * + * This generated file contains a commented-out sample Java project to get you started. + * For more details take a look at the Java Quickstart chapter in the Gradle + * user guide available at http://gradle.org/docs/2.2.1/userguide/tutorial_java_projects.html + */ + +// Apply the java plugin to add support for Java +apply plugin: 'application' +mainClassName = "net.freerouting.gui.MainApplication" + + +// In this section you declare where to find the dependencies of your project +repositories { + // Use 'jcenter' for resolving your dependencies. + // You can declare any Maven/Ivy/file repository here. + mavenLocal() + mavenCentral() + jcenter() +} + +// In this section you declare the dependencies for your production and test code +dependencies { + compile 'com.sun.woodstock.dependlibs:jh:2.0' + compile 'javax.help:javahelp:2.0.05' + compile 'org.jvnet.hudson:netx:0.5-hudson-2' + + + // Declare the dependency for your favourite test framework you want to use in your tests. + // TestNG is also supported by the Gradle Test task. Just change the + // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add + // 'test.useTestNG()' to your build script. + testCompile "junit:junit:4.11" +} + +jar { + manifest { + attributes 'Main-Class': "$mainClassName" + } +} + diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..e63cad7c --- /dev/null +++ b/settings.gradle @@ -0,0 +1,19 @@ +/* + * This settings file was auto generated by the Gradle buildInit task + * by 'Anand.Tamariya' at '5/31/15 6:50 PM' with Gradle 2.2.1 + * + * The settings file is used to specify which projects to include in your build. + * In a single project build this file can be empty or even removed. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user guide at http://gradle.org/docs/2.2.1/userguide/multi_project_builds.html + */ + +/* +// To declare projects as part of a multi-project build use the 'include' method +include 'shared' +include 'api' +include 'services:webservice' +*/ + +rootProject.name = 'FreeRouting' From b801b106eb24d497b0074fa25bd6bcef3d1833e6 Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Thu, 17 Sep 2015 20:09:47 +0300 Subject: [PATCH 06/14] Added to README.md how to build via Gradle --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b313c85..ad690350 100644 --- a/README.md +++ b/README.md @@ -78,9 +78,18 @@ For optional parameters of the Freerouting outfile check the usage of the variab How to run the Freerouting project as a standalone application =========================================================================================== +Using maven ```shell $ mvn package $ java -jar target/freerouting-1.0-SNAPSHOT-jar-with-dependencies.jar -``` \ No newline at end of file +``` + +Using gradle + +```shell +$ gradle build + +$ java -jar build/libs/FreeRouting.jar +``` From 128c1bc20d967368e76103b0672ed336c073588d Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Thu, 17 Sep 2015 20:54:55 +0300 Subject: [PATCH 07/14] Fixed issue mentioned in https://github.com/nikropht/FreeRouting/issues/4 --- .../net/freerouting/boardgraphics/GraphicsContext.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/freerouting/boardgraphics/GraphicsContext.java b/src/main/java/net/freerouting/boardgraphics/GraphicsContext.java index 05683957..28eb10f4 100644 --- a/src/main/java/net/freerouting/boardgraphics/GraphicsContext.java +++ b/src/main/java/net/freerouting/boardgraphics/GraphicsContext.java @@ -127,7 +127,7 @@ public void draw(FloatPoint[] p_points, double p_half_width, Color p_color, Grap return; } Graphics2D g2 = (Graphics2D)p_g; - Rectangle clip_shape = (Rectangle)p_g.getClip() ; + Rectangle clip_shape = p_g.getClip().getBounds() ; // the class member update_box cannot be used here, because // the dirty rectangle is internally enlarged by the system. // Therefore we can not improve the performance by using an @@ -270,7 +270,7 @@ public void fill_circle(Circle p_circle, Graphics p_g, Color p_color, double p_t } Point2D center = coordinate_transform.board_to_screen(p_circle.center.to_float()); double radius = coordinate_transform.board_to_screen(p_circle.radius); - if (!point_near_rectangle(center.getX(), center.getY(), (Rectangle)p_g.getClip(), radius)) + if (!point_near_rectangle(center.getX(), center.getY(), p_g.getClip().getBounds(), radius)) { return; } @@ -310,7 +310,7 @@ public void fill_ellipse_arr(Ellipse [] p_ellipse_arr, Graphics p_g, Color p_co { Point2D center = coordinate_transform.board_to_screen(curr_ellipse.center); double bigger_radius = coordinate_transform.board_to_screen(curr_ellipse.bigger_radius); - if (!point_near_rectangle(center.getX(), center.getY(), (Rectangle)p_g.getClip(), bigger_radius)) + if (!point_near_rectangle(center.getX(), center.getY(), p_g.getClip().getBounds(), bigger_radius)) { continue; } @@ -429,7 +429,7 @@ public void fill_area(Area p_area, Graphics p_g, Color p_color, double p_translu System.out.println("GraphicsContext.fill_area: shape not bounded"); return; } - Rectangle clip_shape = (Rectangle)p_g.getClip() ; + Rectangle clip_shape = p_g.getClip().getBounds() ; IntBox clip_box = coordinate_transform.screen_to_board(clip_shape); if (!border.bounding_box().intersects(clip_box)) { From 1cc5477740e5f2474dc0a90f9f5038301ba2f09e Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Thu, 17 Sep 2015 21:35:43 +0300 Subject: [PATCH 08/14] Got rid of Web Start --- .../java/net/freerouting/gui/BoardFrame.java | 70 +++--- .../net/freerouting/gui/BoardMenuFile.java | 134 +++++------- .../java/net/freerouting/gui/BoardPanel.java | 39 +--- .../java/net/freerouting/gui/DesignFile.java | 138 ++++-------- .../net/freerouting/gui/MainApplication.java | 133 +----------- .../gui/WindowNetDemonstrations.java | 155 ------------- .../gui/WindowNetSampleDesigns.java | 66 ------ .../net/freerouting/gui/WindowNetSamples.java | 204 ------------------ .../gui/WindowNetSamples_de.properties | 12 -- .../gui/WindowNetSamples_en.properties | 12 -- 10 files changed, 131 insertions(+), 832 deletions(-) delete mode 100644 src/main/java/net/freerouting/gui/WindowNetDemonstrations.java delete mode 100644 src/main/java/net/freerouting/gui/WindowNetSampleDesigns.java delete mode 100644 src/main/java/net/freerouting/gui/WindowNetSamples.java delete mode 100644 src/main/resources/net/freerouting/gui/WindowNetSamples_de.properties delete mode 100644 src/main/resources/net/freerouting/gui/WindowNetSamples_en.properties diff --git a/src/main/java/net/freerouting/gui/BoardFrame.java b/src/main/java/net/freerouting/gui/BoardFrame.java index 7e7b4f44..8622216f 100644 --- a/src/main/java/net/freerouting/gui/BoardFrame.java +++ b/src/main/java/net/freerouting/gui/BoardFrame.java @@ -16,17 +16,15 @@ package net.freerouting.gui; -import net.freerouting.interactive.ScreenMessages; - -import java.io.File; - +import net.freerouting.board.BoardObservers; +import net.freerouting.board.TestLevel; import net.freerouting.datastructures.FileFilter; import net.freerouting.datastructures.IdNoGenerator; - -import net.freerouting.board.TestLevel; -import net.freerouting.board.BoardObservers; - import net.freerouting.designformats.specctra.DsnFile; +import net.freerouting.interactive.ScreenMessages; + +import java.io.File; +import java.io.InputStream; /** * @@ -39,7 +37,7 @@ public class BoardFrame extends javax.swing.JFrame { public enum Option { - FROM_START_MENU, SINGLE_FRAME, SESSION_FILE, WEBSTART, EXTENDED_TOOL_BAR + FROM_START_MENU, SINGLE_FRAME, SESSION_FILE, EXTENDED_TOOL_BAR } /** @@ -48,7 +46,7 @@ public enum Option public static BoardFrame get_embedded_instance(String p_design_file_path_name, BoardObservers p_observers, IdNoGenerator p_id_no_generator, java.util.Locale p_locale) { - final net.freerouting.gui.DesignFile design_file = net.freerouting.gui.DesignFile.get_instance(p_design_file_path_name, false); + final net.freerouting.gui.DesignFile design_file = net.freerouting.gui.DesignFile.get_instance(p_design_file_path_name); if (design_file == null) { WindowMessage.show("designfile not found"); @@ -56,14 +54,9 @@ public static BoardFrame get_embedded_instance(String p_design_file_path_name, } net.freerouting.gui.BoardFrame board_frame = new net.freerouting.gui.BoardFrame(design_file, net.freerouting.gui.BoardFrame.Option.SINGLE_FRAME, TestLevel.RELEASE_VERSION, p_observers, p_id_no_generator, p_locale, false); - - - if (board_frame == null) - { - WindowMessage.show("board_frame is null"); - return null; - } - java.io.InputStream input_stream = design_file.get_input_stream(); + + + InputStream input_stream = design_file.get_input_stream(); boolean read_ok = board_frame.read(input_stream, true, null); if (!read_ok) { @@ -79,7 +72,6 @@ public static BoardFrame get_embedded_instance(String p_design_file_path_name, * If p_option = FROM_START_MENU this frame is created from a start menu frame. * If p_option = SINGLE_FRAME, this frame is created directly a single frame. * If p_option = Option.IN_SAND_BOX, no security sensitive actions like for example choosing - * If p_option = Option.WEBSTART, the application has been started with Java Webstart. * files are allowed, so that the frame can be used in an applet. * Currently Option.EXTENDED_TOOL_BAR is used only if a new board is * created by the application from scratch. @@ -103,7 +95,6 @@ public BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, java.util.Locale p_locale, boolean p_confirm_cancel) { this.design_file = p_design; - this.is_web_start = (p_option == Option.WEBSTART); this.test_level = p_test_level; this.confirm_cancel = p_confirm_cancel; @@ -145,8 +136,8 @@ public BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, this.scroll_pane.setPreferredSize(new java.awt.Dimension(1150, 800)); this.scroll_pane.setVerifyInputWhenFocusTarget(false); this.add(scroll_pane, java.awt.BorderLayout.CENTER); - - this.board_panel = new BoardPanel(screen_messages, this, this.is_web_start, p_locale); + + this.board_panel = new BoardPanel(screen_messages, this, p_locale); this.scroll_pane.setViewportView(board_panel); this.setTitle(resources.getString("title")); @@ -158,7 +149,7 @@ public BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, /** * Reads interactive actions from a logfile. */ - void read_logfile(java.io.InputStream p_input_stream) + void read_logfile(InputStream p_input_stream) { board_panel.board_handling.read_logfile(p_input_stream); } @@ -169,7 +160,7 @@ void read_logfile(java.io.InputStream p_input_stream) * If p_is_import, the design is read from a scpecctra dsn file. * Returns false, if the file is invalid. */ - boolean read(java.io.InputStream p_input_stream, boolean p_is_import, javax.swing.JTextField p_message_field) + boolean read(InputStream p_input_stream, boolean p_is_import, javax.swing.JTextField p_message_field) { java.awt.Point viewport_position = null; if (p_is_import) @@ -258,25 +249,16 @@ boolean read(java.io.InputStream p_input_stream, boolean p_is_import, javax.swin if (p_is_import) { // Read the default gui settings, if gui default file exists. - java.io.InputStream input_stream = null; + InputStream input_stream = null; boolean defaults_file_found; - if (this.is_web_start) + File defaults_file = new File(this.design_file.get_parent(), GUI_DEFAULTS_FILE_NAME); + defaults_file_found = true; + try { - input_stream = WebStart.get_file_input_stream(BoardFrame.GUI_DEFAULTS_FILE_NAME); - defaults_file_found = (input_stream != null); - } - else + input_stream = new java.io.FileInputStream(defaults_file); + } catch (java.io.FileNotFoundException e) { - File defaults_file = new File(this.design_file.get_parent(), GUI_DEFAULTS_FILE_NAME); - defaults_file_found = true; - try - { - input_stream = new java.io.FileInputStream(defaults_file); - } - catch (java.io.FileNotFoundException e) - { - defaults_file_found = false; - } + defaults_file_found = false; } if (defaults_file_found) { @@ -378,11 +360,7 @@ public void set_context_sensitive_help(java.awt.Component p_component, String p_ } String help_id = "html_files." + p_help_id; javax.help.CSH.setHelpIDString(curr_component, help_id); - if (!this.is_web_start) - { - //FIXME -// help_broker.enableHelpKey(curr_component, help_id, help_set); - } + help_broker.enableHelpKey(curr_component, help_id, help_set); } } @@ -686,7 +664,7 @@ public void repaint_all() private final TestLevel test_level; /** true, if the frame is created by an application running under Java Web Start */ - final boolean is_web_start; + final boolean is_web_start = false; private final boolean help_system_used; static javax.help.HelpSet help_set = null; diff --git a/src/main/java/net/freerouting/gui/BoardMenuFile.java b/src/main/java/net/freerouting/gui/BoardMenuFile.java index e28c9dc4..2a85a62e 100644 --- a/src/main/java/net/freerouting/gui/BoardMenuFile.java +++ b/src/main/java/net/freerouting/gui/BoardMenuFile.java @@ -35,7 +35,7 @@ public static BoardMenuFile get_instance(BoardFrame p_board_frame, boolean p_ses // Create the menu items. - if (!p_session_file_option && !p_board_frame.is_web_start) + if (!p_session_file_option) { javax.swing.JMenuItem save_item = new javax.swing.JMenuItem(); save_item.setText(file_menu.resources.getString("save")); @@ -57,30 +57,27 @@ public void actionPerformed(java.awt.event.ActionEvent evt) file_menu.add(save_item); } - if (!p_board_frame.is_web_start) + javax.swing.JMenuItem save_and_exit_item = new javax.swing.JMenuItem(); + save_and_exit_item.setText(file_menu.resources.getString("save_and_exit")); + save_and_exit_item.setToolTipText(file_menu.resources.getString("save_and_exit_tooltip")); + save_and_exit_item.addActionListener(new java.awt.event.ActionListener() { - javax.swing.JMenuItem save_and_exit_item = new javax.swing.JMenuItem(); - save_and_exit_item.setText(file_menu.resources.getString("save_and_exit")); - save_and_exit_item.setToolTipText(file_menu.resources.getString("save_and_exit_tooltip")); - save_and_exit_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) + public void actionPerformed(java.awt.event.ActionEvent evt) + { + if (file_menu.session_file_option) { - if (file_menu.session_file_option) - { - file_menu.board_frame.design_file.write_specctra_session_file(file_menu.board_frame); - } - else - { - file_menu.board_frame.save(); - } - file_menu.board_frame.dispose(); + file_menu.board_frame.design_file.write_specctra_session_file(file_menu.board_frame); } - }); + else + { + file_menu.board_frame.save(); + } + file_menu.board_frame.dispose(); + } + }); - file_menu.add(save_and_exit_item); - } + file_menu.add(save_and_exit_item); javax.swing.JMenuItem cancel_and_exit_item = new javax.swing.JMenuItem(); cancel_and_exit_item.setText(file_menu.resources.getString("cancel_and_exit")); @@ -112,36 +109,33 @@ public void actionPerformed(java.awt.event.ActionEvent evt) file_menu.add(save_as_item); - if (!p_board_frame.is_web_start) + javax.swing.JMenuItem write_logfile_item = new javax.swing.JMenuItem(); + write_logfile_item.setText(file_menu.resources.getString("generate_logfile")); + write_logfile_item.setToolTipText(file_menu.resources.getString("generate_logfile_tooltip")); + write_logfile_item.addActionListener(new java.awt.event.ActionListener() { - javax.swing.JMenuItem write_logfile_item = new javax.swing.JMenuItem(); - write_logfile_item.setText(file_menu.resources.getString("generate_logfile")); - write_logfile_item.setToolTipText(file_menu.resources.getString("generate_logfile_tooltip")); - write_logfile_item.addActionListener(new java.awt.event.ActionListener() + + public void actionPerformed(java.awt.event.ActionEvent evt) { + file_menu.write_logfile_action(); + } + }); - public void actionPerformed(java.awt.event.ActionEvent evt) - { - file_menu.write_logfile_action(); - } - }); + file_menu.add(write_logfile_item); - file_menu.add(write_logfile_item); + javax.swing.JMenuItem replay_logfile_item = new javax.swing.JMenuItem(); + replay_logfile_item.setText(file_menu.resources.getString("replay_logfile")); + replay_logfile_item.setToolTipText(file_menu.resources.getString("replay_logfile_tooltip")); + replay_logfile_item.addActionListener(new java.awt.event.ActionListener() + { - javax.swing.JMenuItem replay_logfile_item = new javax.swing.JMenuItem(); - replay_logfile_item.setText(file_menu.resources.getString("replay_logfile")); - replay_logfile_item.setToolTipText(file_menu.resources.getString("replay_logfile_tooltip")); - replay_logfile_item.addActionListener(new java.awt.event.ActionListener() + public void actionPerformed(java.awt.event.ActionEvent evt) { + file_menu.read_logfile_action(); + } + }); - public void actionPerformed(java.awt.event.ActionEvent evt) - { - file_menu.read_logfile_action(); - } - }); - - file_menu.add(replay_logfile_item); - } + file_menu.add(replay_logfile_item); } file_menu.add_save_settings_item(); @@ -265,49 +259,27 @@ private void read_logfile_action() } } - private void save_defaults_action() - { + private void save_defaults_action() { java.io.OutputStream output_stream = null; - if (board_frame.is_web_start) - { - output_stream = WebStart.get_file_output_stream(BoardFrame.GUI_DEFAULTS_FILE_NAME); - } - else - { - java.io.File defaults_file = new java.io.File(board_frame.design_file.get_parent(), BoardFrame.GUI_DEFAULTS_FILE_NAME); - if (defaults_file.exists()) - { - // Make a backup copy of the old defaulds file. - java.io.File defaults_file_backup = new java.io.File(board_frame.design_file.get_parent(), BoardFrame.GUI_DEFAULTS_FILE_BACKUP_NAME); - if (defaults_file_backup.exists()) - { - defaults_file_backup.delete(); - } - defaults_file.renameTo(defaults_file_backup); + java.io.File defaults_file = new java.io.File(board_frame.design_file.get_parent(), BoardFrame.GUI_DEFAULTS_FILE_NAME); + if (defaults_file.exists()) { + // Make a backup copy of the old defaulds file. + java.io.File defaults_file_backup = new java.io.File(board_frame.design_file.get_parent(), BoardFrame.GUI_DEFAULTS_FILE_BACKUP_NAME); + if (defaults_file_backup.exists()) { + defaults_file_backup.delete(); } - try - { - output_stream = new java.io.FileOutputStream(defaults_file); - } catch (Exception e) - { - output_stream = null; - } - } - boolean write_ok; - if (output_stream == null) - { - write_ok = false; + defaults_file.renameTo(defaults_file_backup); } - else - { - write_ok = net.freerouting.gui.GUIDefaultsFile.write(board_frame, board_frame.board_panel.board_handling, output_stream); + try { + output_stream = new java.io.FileOutputStream(defaults_file); + } catch (Exception e) { + output_stream = null; } - if (write_ok) - { + boolean write_ok; + write_ok = output_stream != null && GUIDefaultsFile.write(board_frame, board_frame.board_panel.board_handling, output_stream); + if (write_ok) { board_frame.screen_messages.set_status_message(resources.getString("message_17")); - } - else - { + } else { board_frame.screen_messages.set_status_message(resources.getString("message_18")); } diff --git a/src/main/java/net/freerouting/gui/BoardPanel.java b/src/main/java/net/freerouting/gui/BoardPanel.java index fac4fe6d..0bf59871 100644 --- a/src/main/java/net/freerouting/gui/BoardPanel.java +++ b/src/main/java/net/freerouting/gui/BoardPanel.java @@ -23,16 +23,11 @@ import net.freerouting.interactive.BoardHandling; import net.freerouting.interactive.ScreenMessages; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.geom.Point2D; - -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JViewport; +import javax.swing.*; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; +import java.awt.*; +import java.awt.geom.Point2D; /** @@ -46,20 +41,15 @@ public class BoardPanel extends javax.swing.JPanel /** Creates a new BoardPanel in an Application */ public BoardPanel(ScreenMessages p_screen_messages, BoardFrame p_board_frame, - boolean p_is_web_application, java.util.Locale p_locale) + java.util.Locale p_locale) { screen_messages = p_screen_messages; - if (!p_is_web_application) + try { - try - { - // used to be able to change the location of the mouse pointer - robot = new java.awt.Robot(); - } - catch (java.awt.AWTException e) - { - System.out.println("unable to create robot"); - } + // used to be able to change the location of the mouse pointer + robot = new java.awt.Robot(); + } catch (java.awt.AWTException e) { + System.out.println("unable to create robot"); } board_frame = p_board_frame; this.scroll_pane = board_frame.scroll_pane; @@ -197,17 +187,6 @@ else if (evt.getButton() == 3) { int curr_x = evt.getX(); int curr_y = evt.getY(); - if (curr_menu == popup_menu_dynamic_route && board_frame.is_web_start) - { - int dx = curr_menu.getWidth(); - if (dx <= 0) - { - // force the width to be calculated - curr_menu.show(this, curr_x, curr_y); - dx = curr_menu.getWidth(); - } - curr_x -= dx; - } curr_menu.show(this, curr_x, curr_y); } right_button_click_location = evt.getPoint(); diff --git a/src/main/java/net/freerouting/gui/DesignFile.java b/src/main/java/net/freerouting/gui/DesignFile.java index 6dd61e44..165aba3a 100644 --- a/src/main/java/net/freerouting/gui/DesignFile.java +++ b/src/main/java/net/freerouting/gui/DesignFile.java @@ -21,6 +21,7 @@ package net.freerouting.gui; import net.freerouting.datastructures.FileFilter; +import net.freerouting.interactive.BoardHandling; /** * File functionality with security restrictions used, when the application is opened with Java Webstart @@ -34,51 +35,39 @@ public class DesignFile public static final String[] text_file_extensions = {"dsn"}; public static final String binary_file_extension = "bin"; - public static DesignFile get_instance(String p_design_file_name, boolean p_is_webstart) + public static DesignFile get_instance(String p_design_file_name) { if (p_design_file_name == null) { return null; } - DesignFile result = new DesignFile(p_is_webstart, null, new java.io.File(p_design_file_name), null); - return result; + return new DesignFile(null, new java.io.File(p_design_file_name), null); } /** * Shows a file chooser for opening a design file. * If p_is_webstart there are security restrictions because the application was opened with java web start. */ - public static DesignFile open_dialog(boolean p_is_webstart, String p_design_dir_name) + public static DesignFile open_dialog(String p_design_dir_name) { - DesignFile result; - if (p_is_webstart) - { - result = webstart_open_dialog(p_design_dir_name); - } - else + javax.swing.JFileChooser file_chooser = new javax.swing.JFileChooser(p_design_dir_name); + FileFilter file_filter = new FileFilter(all_file_extensions); + file_chooser.setFileFilter(file_filter); + file_chooser.showOpenDialog(null); + java.io.File curr_design_file = file_chooser.getSelectedFile(); + if (curr_design_file == null) { - javax.swing.JFileChooser file_chooser = new javax.swing.JFileChooser(p_design_dir_name); - FileFilter file_filter = new FileFilter(all_file_extensions); - file_chooser.setFileFilter(file_filter); - file_chooser.showOpenDialog(null); - java.io.File curr_design_file = file_chooser.getSelectedFile(); - if (curr_design_file == null) - { - return null; - } - result = new DesignFile(false, null, curr_design_file, file_chooser); + return null; } - return result; + return new DesignFile(null, curr_design_file, file_chooser); } /** * Creates a new instance of DesignFile. - * If p_is_webstart, the application was opened with Java Web Start. */ - private DesignFile(boolean p_is_webstart, javax.jnlp.FileContents p_file_contents, - java.io.File p_design_file, javax.swing.JFileChooser p_file_chooser) + private DesignFile(javax.jnlp.FileContents p_file_contents, + java.io.File p_design_file, javax.swing.JFileChooser p_file_chooser) { - this.is_webstart = p_is_webstart; this.file_contents = p_file_contents; this.file_chooser = p_file_chooser; this.input_file = p_design_file; @@ -101,34 +90,16 @@ private DesignFile(boolean p_is_webstart, javax.jnlp.FileContents p_file_content public java.io.InputStream get_input_stream() { java.io.InputStream result; - if (this.is_webstart) + if (this.input_file == null) { - - if (this.file_contents == null) - { - return null; - } - try - { - result = this.file_contents.getInputStream(); - } catch (Exception e) - { - result = null; - } + return null; } - else + try { - if (this.input_file == null) - { - return null; - } - try - { - result = new java.io.FileInputStream(this.input_file); - } catch (Exception e) - { - result = null; - } + result = new java.io.FileInputStream(this.input_file); + } catch (Exception e) + { + result = null; } return result; } @@ -337,61 +308,23 @@ private boolean write_rules_file(String p_design_name, net.freerouting.interacti } public static boolean read_rules_file(String p_design_name, String p_parent_name, - net.freerouting.interactive.BoardHandling p_board_handling, boolean p_is_web_start, String p_confirm_message) + BoardHandling p_board_handling, String p_confirm_message) { - - boolean result = true; + boolean result; String rule_file_name = p_design_name + ".rules"; boolean dsn_file_generated_by_host = p_board_handling.get_routing_board().communication.specctra_parser_info.dsn_file_generated_by_host; - if (p_is_web_start) - { - java.io.InputStream input_stream = WebStart.get_file_input_stream(rule_file_name); - if (input_stream != null && dsn_file_generated_by_host && WindowMessage.confirm(p_confirm_message)) - { - result = net.freerouting.designformats.specctra.RulesFile.read(input_stream, p_design_name, p_board_handling); - try - { - input_stream.close(); - } catch (Exception e) - { - result = false; - } - } - else - { - result = false; - } - WebStart.delete_files(RULES_FILE_EXTENSION, null); - } - else - { - try - { - java.io.File rules_file = new java.io.File(p_parent_name, rule_file_name); - java.io.InputStream input_stream = new java.io.FileInputStream(rules_file); - if (input_stream != null && dsn_file_generated_by_host && WindowMessage.confirm(p_confirm_message)) - { - result = net.freerouting.designformats.specctra.RulesFile.read(input_stream, p_design_name, p_board_handling); - } - else - { - result = false; - } - try - { - if (input_stream != null) - { - input_stream.close(); - } - rules_file.delete(); - } catch (java.io.IOException e) - { - result = false; - } - } catch (java.io.FileNotFoundException e) - { + try { + java.io.File rules_file = new java.io.File(p_parent_name, rule_file_name); + java.io.InputStream input_stream = new java.io.FileInputStream(rules_file); + result = dsn_file_generated_by_host && WindowMessage.confirm(p_confirm_message) && net.freerouting.designformats.specctra.RulesFile.read(input_stream, p_design_name, p_board_handling); + try { + input_stream.close(); + rules_file.delete(); + } catch (java.io.IOException e) { result = false; } + } catch (java.io.FileNotFoundException e) { + result = false; } return result; } @@ -458,7 +391,7 @@ private static DesignFile webstart_open_dialog(String p_design_dir_name) (javax.jnlp.FileOpenService) javax.jnlp.ServiceManager.lookup("javax.jnlp.FileOpenService"); javax.jnlp.FileContents file_contents = file_open_service.openFileDialog(p_design_dir_name, DesignFile.text_file_extensions); - return new DesignFile(true, file_contents, null, null); + return new DesignFile(file_contents, null, null); } catch (Exception e) { return null; @@ -587,7 +520,8 @@ public boolean is_created_from_text_file() { return this.is_webstart || this.input_file != this.output_file; } - private final boolean is_webstart; + + private final boolean is_webstart = false; /** Used, if the application is run with Java Web Start. */ private javax.jnlp.FileContents file_contents; /** Used, if the application is run without Java Web Start. */ diff --git a/src/main/java/net/freerouting/gui/MainApplication.java b/src/main/java/net/freerouting/gui/MainApplication.java index f5703e36..54c67b72 100644 --- a/src/main/java/net/freerouting/gui/MainApplication.java +++ b/src/main/java/net/freerouting/gui/MainApplication.java @@ -22,6 +22,8 @@ import net.freerouting.board.TestLevel; +import java.util.Locale; + /** * * Main application for creating frames with new or existing board designs. @@ -39,7 +41,6 @@ public static void main(String p_args[]) boolean single_design_option = false; boolean test_version_option = false; boolean session_file_option = false; - boolean webstart_option = false; String design_file_name = null; String design_dir_name = null; java.util.Locale current_locale = java.util.Locale.ENGLISH; @@ -74,19 +75,11 @@ else if (p_args[i].startsWith("-s")) { session_file_option = true; } - else if (p_args[i].startsWith("-w")) - { - webstart_option = true; - } else if (p_args[i].startsWith("-test")) { test_version_option = true; } } - if (!(OFFLINE_ALLOWED || webstart_option)) - { - Runtime.getRuntime().exit(1); - } if (single_design_option) { @@ -101,7 +94,7 @@ else if (p_args[i].startsWith("-test")) { board_option = BoardFrame.Option.SINGLE_FRAME; } - DesignFile design_file = DesignFile.get_instance(design_file_name, false); + DesignFile design_file = DesignFile.get_instance(design_file_name); if (design_file == null) { System.out.print(resources.getString("message_6") + " "); @@ -129,7 +122,7 @@ public void windowClosed(java.awt.event.WindowEvent evt) } else { - new MainApplication(design_dir_name, test_version_option, webstart_option, current_locale).setVisible(true); + new MainApplication(design_dir_name, test_version_option, current_locale).setVisible(true); } } @@ -138,11 +131,10 @@ public void windowClosed(java.awt.event.WindowEvent evt) * It takes the directory of the board designs as optional argument. */ public MainApplication(String p_design_dir, boolean p_is_test_version, - boolean p_webstart_option, java.util.Locale p_current_locale) + Locale p_current_locale) { this.design_dir_name = p_design_dir; this.is_test_version = p_is_test_version; - this.is_webstart = p_webstart_option; this.locale = p_current_locale; this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.MainApplication", p_current_locale); @@ -161,49 +153,9 @@ public MainApplication(String p_design_dir, boolean p_is_test_version, restore_defaults_button = new javax.swing.JButton(); message_field = new javax.swing.JTextField(); message_field.setText(""); - this.window_net_demonstrations = new WindowNetDemonstrations(p_current_locale); java.awt.Point location = getLocation(); - this.window_net_demonstrations.setLocation((int) location.getX() + 50, (int) location.getY() + 50); - this.window_net_sample_designs = new WindowNetSampleDesigns(p_current_locale); - this.window_net_sample_designs.setLocation((int) location.getX() + 90, (int) location.getY() + 90); setTitle(resources.getString("title")); - boolean add_buttons = true; - - if (p_webstart_option) - { - - if (add_buttons) - { - demonstration_button.setText(resources.getString("router_demonstrations")); - demonstration_button.setToolTipText(resources.getString("router_demonstrations_tooltip")); - demonstration_button.addActionListener(new java.awt.event.ActionListener() - { - - public void actionPerformed(java.awt.event.ActionEvent evt) - { - window_net_demonstrations.setVisible(true); - } - }); - - gridbag.setConstraints(demonstration_button, gridbag_constraints); - main_panel.add(demonstration_button, gridbag_constraints); - - sample_board_button.setText(resources.getString("sample_designs")); - sample_board_button.setToolTipText(resources.getString("sample_designs_tooltip")); - sample_board_button.addActionListener(new java.awt.event.ActionListener() - { - - public void actionPerformed(java.awt.event.ActionEvent evt) - { - window_net_sample_designs.setVisible(true); - } - }); - - gridbag.setConstraints(sample_board_button, gridbag_constraints); - main_panel.add(sample_board_button, gridbag_constraints); - } - } open_board_button.setText(resources.getString("open_own_design")); open_board_button.setToolTipText(resources.getString("open_own_design_tooltip")); @@ -217,30 +169,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) }); gridbag.setConstraints(open_board_button, gridbag_constraints); - if (add_buttons) - { - main_panel.add(open_board_button, gridbag_constraints); - } - - if (p_webstart_option && add_buttons) - { - restore_defaults_button.setText(resources.getString("restore_defaults")); - restore_defaults_button.setToolTipText(resources.getString("restore_defaults_tooltip")); - restore_defaults_button.addActionListener(new java.awt.event.ActionListener() - { - - public void actionPerformed(java.awt.event.ActionEvent evt) - { - if (is_webstart) - { - restore_defaults_action(evt); - } - } - }); - - gridbag.setConstraints(restore_defaults_button, gridbag_constraints); - main_panel.add(restore_defaults_button, gridbag_constraints); - } + main_panel.add(open_board_button, gridbag_constraints); message_field.setPreferredSize(new java.awt.Dimension(230, 20)); message_field.setRequestFocusEnabled(false); @@ -255,7 +184,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) private void open_board_design_action(java.awt.event.ActionEvent evt) { - DesignFile design_file = DesignFile.open_dialog(this.is_webstart, this.design_dir_name); + DesignFile design_file = DesignFile.open_dialog(this.design_dir_name); if (design_file == null) { @@ -264,14 +193,7 @@ private void open_board_design_action(java.awt.event.ActionEvent evt) } BoardFrame.Option option; - if (this.is_webstart) - { - option = BoardFrame.Option.WEBSTART; - } - else - { - option = BoardFrame.Option.FROM_START_MENU; - } + option = BoardFrame.Option.FROM_START_MENU; String message = resources.getString("loading_design") + " " + design_file.get_name(); message_field.setText(message); WindowMessage welcome_window = WindowMessage.show(message); @@ -294,24 +216,6 @@ private void exitForm(java.awt.event.WindowEvent evt) System.exit(0); } - /** deletes the setting stored by the user if the application is run by Java Web Start */ - private void restore_defaults_action(java.awt.event.ActionEvent evt) - { - if (!is_webstart) - { - return; - } - boolean file_deleted = WebStart.delete_files(BoardFrame.GUI_DEFAULTS_FILE_NAME, resources.getString("confirm_delete")); - if (file_deleted) - { - message_field.setText(resources.getString("defaults_restored")); - } - else - { - message_field.setText(resources.getString("nothing_to_restore")); - } - } - /** * Creates a new board frame containing the data of the input design file. * Returns null, if an error occured. @@ -356,7 +260,7 @@ static private BoardFrame create_board_frame(DesignFile p_design_file, javax.swi String[] name_parts = file_name.split("\\."); String confirm_import_rules_message = resources.getString("confirm_import_rules"); DesignFile.read_rules_file(name_parts[0], p_design_file.get_parent(), - new_frame.board_panel.board_handling, p_option == BoardFrame.Option.WEBSTART, + new_frame.board_panel.board_handling, confirm_import_rules_message); new_frame.refresh_windows(); } @@ -369,19 +273,10 @@ static private BoardFrame create_board_frame(DesignFile p_design_file, javax.swi private final javax.swing.JButton restore_defaults_button; private javax.swing.JTextField message_field; private javax.swing.JPanel main_panel; - /** - * A Frame with routing demonstrations in the net. - */ - private final WindowNetSamples window_net_demonstrations; - /** - * A Frame with sample board designs in the net. - */ - private final WindowNetSamples window_net_sample_designs; /** The list of open board frames */ private java.util.Collection board_frames = new java.util.LinkedList(); private String design_dir_name = null; private final boolean is_test_version; - private final boolean is_webstart; private final java.util.Locale locale; private static final TestLevel DEBUG_LEVEL = TestLevel.CRITICAL_DEBUGGING_OUTPUT; @@ -428,16 +323,6 @@ public void windowClosing(java.awt.event.WindowEvent evt) exitForm(evt); } } - - public void windowIconified(java.awt.event.WindowEvent evt) - { - window_net_sample_designs.parent_iconified(); - } - - public void windowDeiconified(java.awt.event.WindowEvent evt) - { - window_net_sample_designs.parent_deiconified(); - } } static final String WEB_FILE_BASE_NAME = "http://www.freerouting.net/java/"; private static final boolean OFFLINE_ALLOWED = true; diff --git a/src/main/java/net/freerouting/gui/WindowNetDemonstrations.java b/src/main/java/net/freerouting/gui/WindowNetDemonstrations.java deleted file mode 100644 index 45fffe08..00000000 --- a/src/main/java/net/freerouting/gui/WindowNetDemonstrations.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2014 Alfons Wirtz - * website www.freerouting.net - * - * 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 3 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 at - * for more details. - * - * WindowNetDemonstration.java - * - * Created on 14. November 2006, 12:20 - * - */ - -package net.freerouting.gui; - -import java.util.zip.ZipInputStream; - -/** - * Window with a list for selecting router demonstrations in the net. - * - * @author Alfons Wirtz - */ -public class WindowNetDemonstrations extends WindowNetSamples -{ - - /** Creates a new instance of WindowNetDemonstration */ - public WindowNetDemonstrations(java.util.Locale p_locale) - { - super(p_locale, "router_demonstrations", "replay_example", 7); - } - - /** - * To be edited when the demonstration examples change. - * For every String in the second column a String has to be added to the resource file WindowNetSamples. - */ - protected void fill_list() - { - add("sample_45.dsn", "45_degree_logfile", AdditionalAction.READ_LOGFILE); - add("int_ar.dsn", "drag_component_logfile", AdditionalAction.READ_LOGFILE); - add("single_layer.dsn", "any_angle_logfile", AdditionalAction.READ_LOGFILE); - add("hexapod_empty.dsn", "autorouter_example_1", AdditionalAction.AUTOROUTE); - add("at14_empty.dsn", "autorouter_example_2", AdditionalAction.AUTOROUTE); - add("sharp_empty.dsn", "autorouter_example_3", AdditionalAction.AUTOROUTE); - } - - protected void button_pushed() - { - int index = list.getSelectedIndex(); - if (index < 0 || index >= list_model.getSize()) - { - return; - } - ListElement selected_element = (ListElement) list_model.elementAt(index); - String[] name_parts = selected_element.design_name.split("\\."); - String archive_name = name_parts[0]; - BoardFrame new_frame = open_design(archive_name, selected_element.design_name, this.locale); - if (new_frame != null) - { - selected_element.additional_action.perform(new_frame, archive_name); - } - } - - /** - * Adds an element to the list. - */ - private void add(String p_design_name, String p_message_name, AdditionalAction p_additional_action) - { - list_model.addElement(new ListElement(p_design_name, - resources.getString(p_message_name), p_additional_action)); - } - - - /** - * Replays a zipped logfile from an URL in the net. - */ - private static void read_zipped_logfile(BoardFrame p_board_frame, String p_archive_name, String p_logfile_name) - { - if (p_board_frame == null) - { - return; - } - ZipInputStream zip_input_stream = WindowNetSamples.open_zipped_file(p_archive_name, p_logfile_name); - if (zip_input_stream == null) - { - return; - } - p_board_frame.read_logfile(zip_input_stream); - } - - /** - * Additional Acction to be performed after opening the board. - */ - private enum AdditionalAction - { - READ_LOGFILE - { - void perform(BoardFrame p_board_frame, String p_archive_name) - { - String logfile_archive_name = "route_" + p_archive_name; - read_zipped_logfile(p_board_frame, logfile_archive_name, logfile_archive_name + ".log"); - } - }, - - - AUTOROUTE - { - void perform(BoardFrame p_board_frame, String p_archive_name) - { - p_board_frame.board_panel.board_handling.start_batch_autorouter(); - } - }, - - NONE - { - void perform(BoardFrame p_board_frame, String p_archive_name) - { - - } - }; - - abstract void perform(BoardFrame p_board_frame, String p_archive_name); - } - - /** - * Structure of the elements in the list - * For every instance in a String has to be added to the resource file WindowNetSamples fo the - * String in the field message_name. - */ - private static class ListElement - { - ListElement(String p_design_name, String p_message_name, AdditionalAction p_additional_action) - { - design_name = p_design_name; - message_name = p_message_name; - additional_action = p_additional_action; - } - - public String toString() - { - return message_name; - } - - final String design_name; - final String message_name; - final AdditionalAction additional_action; - } -} diff --git a/src/main/java/net/freerouting/gui/WindowNetSampleDesigns.java b/src/main/java/net/freerouting/gui/WindowNetSampleDesigns.java deleted file mode 100644 index 9c76f34b..00000000 --- a/src/main/java/net/freerouting/gui/WindowNetSampleDesigns.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2014 Alfons Wirtz - * website www.freerouting.net - * - * 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 3 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 at - * for more details. - * - * WindowNeetSampleDesigns.java - * - * Created on 14. November 2006, 10:13 - * - */ -package net.freerouting.gui; - -/** - * - * Window with a list for selecting sample board designs in the net. - * - * @author Alfons Wirtz - */ -public class WindowNetSampleDesigns extends WindowNetSamples -{ - - /** Creates a new instance of WindowNeetSampleDesigns */ - public WindowNetSampleDesigns(java.util.Locale p_locale) - { - super(p_locale, "sample_designs", "open_sample_design", 11); - } - - protected void fill_list() - { - list_model.addElement("hexapod_empty.dsn"); - list_model.addElement("hexapod_autorouted.dsn"); - list_model.addElement("sharc_handrouted.dsn"); - list_model.addElement("at14_empty.dsn"); - list_model.addElement("at14_autorouted.dsn"); - list_model.addElement("sharp_empty.dsn"); - list_model.addElement("sharp_autorouted.dsn"); - list_model.addElement("bigdesign_unrouted.dsn"); - list_model.addElement("int_empty.dsn"); - list_model.addElement("int_autorouted.dsn"); - list_model.addElement("single_layer_empty.dsn"); - list_model.addElement("single_layer_handrouted.dsn"); - } - - protected void button_pushed() - { - int index = list.getSelectedIndex(); - if (index < 0 || index >= list_model.getSize()) - { - return; - } - String design_name = (String) list_model.elementAt(index); - String[] name_parts = design_name.split("\\."); - String archive_name = name_parts[0]; - open_design(archive_name, design_name, this.locale); - } -} diff --git a/src/main/java/net/freerouting/gui/WindowNetSamples.java b/src/main/java/net/freerouting/gui/WindowNetSamples.java deleted file mode 100644 index 8e54e053..00000000 --- a/src/main/java/net/freerouting/gui/WindowNetSamples.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (C) 2014 Alfons Wirtz - * website www.freerouting.net - * - * 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 3 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 at - * for more details. - * - * WindowNetSampleDesigns.java - * - * Created on 11. November 2006, 07:49 - * - */ - -package net.freerouting.gui; - -import java.util.zip.ZipInputStream; - -import java.net.URL; -import java.net.URLConnection; - -/** - * Window with a list for selecting samples in the net. - * - * @author Alfons Wirtz - */ -public abstract class WindowNetSamples extends BoardSubWindow -{ - - /** Creates a new instance of WindowNetSampleDesigns */ - public WindowNetSamples(java.util.Locale p_locale, String p_title, String p_button_name, int p_row_count) - { - this.locale = p_locale; - this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowNetSamples", p_locale); - this.setTitle(resources.getString(p_title)); - - this.setDefaultCloseOperation(DISPOSE_ON_CLOSE ); - - // create main panel - final javax.swing.JPanel main_panel = new javax.swing.JPanel(); - this.add(main_panel); - main_panel.setLayout(new java.awt.BorderLayout()); - javax.swing.border.Border panel_border = javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10); - main_panel.setBorder(panel_border); - - - // create open button - javax.swing.JButton open_button = new javax.swing.JButton(resources.getString(p_button_name)); - open_button.addActionListener(new OpenListener()); - main_panel.add(open_button, java.awt.BorderLayout.SOUTH); - - // create list with the sample designs - this.list = new javax.swing.JList(this.list_model); - fill_list(); - this.list.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - this.list.setSelectedIndex(0); - this.list.setVisibleRowCount(p_row_count); - this.list.addMouseListener(new java.awt.event.MouseAdapter() - { - public void mouseClicked(java.awt.event.MouseEvent evt) - { - if (evt.getClickCount() > 1) - { - button_pushed(); - } - } - }); - - javax.swing.JScrollPane list_scroll_pane = new javax.swing.JScrollPane(this.list); - list_scroll_pane.setPreferredSize(new java.awt.Dimension(200, 20 * p_row_count)); - main_panel.add(list_scroll_pane, java.awt.BorderLayout.CENTER); - this.pack(); - } - - - /** - * Fill the list with the examples. - */ - protected abstract void fill_list(); - - /** - * Action to be perfomed. when the button is pushed after selecting an item in the list. - */ - protected abstract void button_pushed(); - - /** - * Opens a zipped archive from an URL in the net. - * Returns a zipped input stream, who is positioned at the start of p_file_name, - * or null, if an error occured, - */ - protected static ZipInputStream open_zipped_file(String p_archive_name, String p_file_name) - { - String archive_path_name = MainApplication.WEB_FILE_BASE_NAME + p_archive_name + ".zip"; - URL archive_url = null; - try - { - archive_url = new URL(archive_path_name); - } - catch(java.net.MalformedURLException e) - { - return null; - } - java.io.InputStream input_stream = null; - ZipInputStream zip_input_stream = null; - URLConnection net_connection = null; - try - { - net_connection = archive_url.openConnection(); - } - catch (Exception e) - { - return null; - } - try - { - input_stream = net_connection.getInputStream(); - } - catch (java.io.IOException e) - { - return null; - } - catch (java.security.AccessControlException e) - { - return null; - } - try - { - zip_input_stream = new ZipInputStream(input_stream); - } - catch (Exception e) - { - WindowMessage.show("unable to get zip input stream"); - return null; - } - String compare_name = p_archive_name + "/" + p_file_name; - java.util.zip.ZipEntry curr_entry = null; - for (;;) - { - try - { - curr_entry = zip_input_stream.getNextEntry(); - } - catch (Exception E) - { - return null; - } - if (curr_entry == null) - { - return null; - } - String design_name = curr_entry.getName(); - if (design_name.equals(compare_name)) - { - break; - } - } - return zip_input_stream; - } - - - /** - * Opens a sample design on the website. - */ - protected static BoardFrame open_design(String p_archive_name, String p_design_name, java.util.Locale p_locale) - { - ZipInputStream zip_input_stream = open_zipped_file(p_archive_name, p_design_name); - if (zip_input_stream == null) - { - return null; - } - DesignFile design_file = DesignFile.get_instance("sharc_routed.dsn", true); - BoardFrame new_frame = - new BoardFrame(design_file, BoardFrame.Option.WEBSTART, net.freerouting.board.TestLevel.RELEASE_VERSION, - p_locale, false); - boolean read_ok = new_frame.read(zip_input_stream, true, null); - if (!read_ok) - { - return null; - } - new_frame.setVisible(true); - return new_frame; - } - - protected final java.util.ResourceBundle resources; - protected final java.util.Locale locale; - - protected javax.swing.DefaultListModel list_model = new javax.swing.DefaultListModel(); - protected final javax.swing.JList list; - - private class OpenListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - button_pushed(); - } - } -} diff --git a/src/main/resources/net/freerouting/gui/WindowNetSamples_de.properties b/src/main/resources/net/freerouting/gui/WindowNetSamples_de.properties deleted file mode 100644 index 5864c932..00000000 --- a/src/main/resources/net/freerouting/gui/WindowNetSamples_de.properties +++ /dev/null @@ -1,12 +0,0 @@ -# German version of language dependent text of the subclasses of WindowNetSamples - -router_demonstrations = Demonstrations-Beispiele -open_sample_design = Beispiel-Design öffnen -sample_designs = Beispiel-Designs -replay_example = Beispiel abspielen -45_degree_logfile = Router-Beispiel für 45 Grad -drag_component_logfile = Beispiel für das Ziehen von Bauteilen -any_angle_logfile = Router-Beispiel für beliebige Winkel -autorouter_example_1 = erstes Autorouter-Beispiel -autorouter_example_2 = zweites Autorouter-Beispiel -autorouter_example_3 = drittes Autorouter-Beispiel diff --git a/src/main/resources/net/freerouting/gui/WindowNetSamples_en.properties b/src/main/resources/net/freerouting/gui/WindowNetSamples_en.properties deleted file mode 100644 index d2ad0bde..00000000 --- a/src/main/resources/net/freerouting/gui/WindowNetSamples_en.properties +++ /dev/null @@ -1,12 +0,0 @@ -# English version of language dependent text of the subclasses of WindowNetSamples - -router_demonstrations = Router Demonstrations -open_sample_design = Open Sample Design -sample_designs = Sample Designs -replay_example = Replay Example -45_degree_logfile = 45 degree routing example -drag_component_logfile = Example for dragging components -any_angle_logfile = Free angle routing example -autorouter_example_1 = first autorouter example -autorouter_example_2 = second autorouter example -autorouter_example_3 = third autorouter example From c20327823ee126b5a6b81da79abc708297c72d6f Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Mon, 21 Sep 2015 21:49:15 +0300 Subject: [PATCH 09/14] Removed webstart related code --- build.gradle | 1 - pom.xml | 5 - .../java/net/freerouting/gui/DesignFile.java | 266 +++--------------- .../java/net/freerouting/gui/WebStart.java | 200 ------------- 4 files changed, 40 insertions(+), 432 deletions(-) delete mode 100644 src/main/java/net/freerouting/gui/WebStart.java diff --git a/build.gradle b/build.gradle index 9f9e2e1d..37386838 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,6 @@ repositories { dependencies { compile 'com.sun.woodstock.dependlibs:jh:2.0' compile 'javax.help:javahelp:2.0.05' - compile 'org.jvnet.hudson:netx:0.5-hudson-2' // Declare the dependency for your favourite test framework you want to use in your tests. diff --git a/pom.xml b/pom.xml index bcfd65db..1c5eac93 100644 --- a/pom.xml +++ b/pom.xml @@ -26,11 +26,6 @@ javahelp 2.0.05 - - org.jvnet.hudson - netx - 0.5-hudson-2 - diff --git a/src/main/java/net/freerouting/gui/DesignFile.java b/src/main/java/net/freerouting/gui/DesignFile.java index 165aba3a..809ab58a 100644 --- a/src/main/java/net/freerouting/gui/DesignFile.java +++ b/src/main/java/net/freerouting/gui/DesignFile.java @@ -21,6 +21,7 @@ package net.freerouting.gui; import net.freerouting.datastructures.FileFilter; +import net.freerouting.designformats.specctra.RulesFile; import net.freerouting.interactive.BoardHandling; /** @@ -41,12 +42,11 @@ public static DesignFile get_instance(String p_design_file_name) { return null; } - return new DesignFile(null, new java.io.File(p_design_file_name), null); + return new DesignFile(new java.io.File(p_design_file_name), null); } /** * Shows a file chooser for opening a design file. - * If p_is_webstart there are security restrictions because the application was opened with java web start. */ public static DesignFile open_dialog(String p_design_dir_name) { @@ -59,16 +59,14 @@ public static DesignFile open_dialog(String p_design_dir_name) { return null; } - return new DesignFile(null, curr_design_file, file_chooser); + return new DesignFile(curr_design_file, file_chooser); } /** * Creates a new instance of DesignFile. */ - private DesignFile(javax.jnlp.FileContents p_file_contents, - java.io.File p_design_file, javax.swing.JFileChooser p_file_chooser) + private DesignFile(java.io.File p_design_file, javax.swing.JFileChooser p_file_chooser) { - this.file_contents = p_file_contents; this.file_chooser = p_file_chooser; this.input_file = p_design_file; this.output_file = p_design_file; @@ -111,17 +109,7 @@ public String get_name() { String result; - if (this.file_contents != null) - { - try - { - result = this.file_contents.getName(); - } catch (Exception e) - { - result = null; - } - } - else if (this.input_file != null) + if (this.input_file != null) { result = this.input_file.getName(); } @@ -138,34 +126,6 @@ public void save_as_dialog(java.awt.Component p_parent, BoardFrame p_board_frame java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); String[] file_name_parts = this.get_name().split("\\.", 2); String design_name = file_name_parts[0]; - if (this.is_webstart) - { - javax.jnlp.FileContents new_file_contents; - java.io.ByteArrayOutputStream output_stream = new java.io.ByteArrayOutputStream(); - - if (p_board_frame.board_panel.board_handling.export_to_dsn_file(output_stream, design_name, false)) - { - java.io.InputStream input_stream = new java.io.ByteArrayInputStream(output_stream.toByteArray()); - new_file_contents = WebStart.save_dialog(this.get_parent(), DesignFile.text_file_extensions, - input_stream, this.get_name()); - } - else - { - new_file_contents = null; - } - - - if (new_file_contents != null) - { - this.file_contents = new_file_contents; - p_board_frame.screen_messages.set_status_message(resources.getString("message_4") + " " + this.get_name() + " " + resources.getString("message_5")); - } - else - { - p_board_frame.screen_messages.set_status_message(resources.getString("message_19")); - } - return; - } if (this.file_chooser == null) { @@ -236,42 +196,27 @@ public boolean write_specctra_session_file(BoardFrame p_board_frame) String design_file_name = this.get_name(); String[] file_name_parts = design_file_name.split("\\.", 2); String design_name = file_name_parts[0]; - if (this.is_webstart) + String output_file_name = design_name + ".ses"; + java.io.File curr_output_file = new java.io.File(get_parent(), output_file_name); + java.io.OutputStream output_stream; + try + { + output_stream = new java.io.FileOutputStream(curr_output_file); + } catch (Exception e) + { + output_stream = null; + } + + if (p_board_frame.board_panel.board_handling.export_specctra_session_file(design_file_name, output_stream)) { - String session_file_name = secure_write_session_file(p_board_frame); - if (session_file_name == null) - { - p_board_frame.screen_messages.set_status_message(resources.getString("message_13") + " " + - resources.getString("message_7")); - return false; - } p_board_frame.screen_messages.set_status_message(resources.getString("message_11") + " " + - session_file_name + " " + resources.getString("message_12")); + output_file_name + " " + resources.getString("message_12")); } else { - String output_file_name = design_name + ".ses"; - java.io.File curr_output_file = new java.io.File(get_parent(), output_file_name); - java.io.OutputStream output_stream; - try - { - output_stream = new java.io.FileOutputStream(curr_output_file); - } catch (Exception e) - { - output_stream = null; - } - - if (p_board_frame.board_panel.board_handling.export_specctra_session_file(design_file_name, output_stream)) - { - p_board_frame.screen_messages.set_status_message(resources.getString("message_11") + " " + - output_file_name + " " + resources.getString("message_12")); - } - else - { - p_board_frame.screen_messages.set_status_message(resources.getString("message_13") + " " + - output_file_name + " " + resources.getString("message_7")); - return false; - } + p_board_frame.screen_messages.set_status_message(resources.getString("message_13") + " " + + output_file_name + " " + resources.getString("message_7")); + return false; } if (WindowMessage.confirm(resources.getString("confirm"))) { @@ -287,23 +232,16 @@ private boolean write_rules_file(String p_design_name, net.freerouting.interacti { String rules_file_name = p_design_name + RULES_FILE_EXTENSION; java.io.OutputStream output_stream; - if (this.is_webstart) + java.io.File rules_file = new java.io.File(this.get_parent(), rules_file_name); + try { - output_stream = WebStart.get_file_output_stream(rules_file_name); - } - else + output_stream = new java.io.FileOutputStream(rules_file); + } catch (java.io.IOException e) { - java.io.File rules_file = new java.io.File(this.get_parent(), rules_file_name); - try - { - output_stream = new java.io.FileOutputStream(rules_file); - } catch (java.io.IOException e) - { - System.out.println("unable to create rules file"); - return false; - } + System.out.println("unable to create rules file"); + return false; } - net.freerouting.designformats.specctra.RulesFile.write(p_board_handling, output_stream, p_design_name); + RulesFile.write(p_board_handling, output_stream, p_design_name); return true; } @@ -316,7 +254,7 @@ public static boolean read_rules_file(String p_design_name, String p_parent_name try { java.io.File rules_file = new java.io.File(p_parent_name, rule_file_name); java.io.InputStream input_stream = new java.io.FileInputStream(rules_file); - result = dsn_file_generated_by_host && WindowMessage.confirm(p_confirm_message) && net.freerouting.designformats.specctra.RulesFile.read(input_stream, p_design_name, p_board_handling); + result = dsn_file_generated_by_host && WindowMessage.confirm(p_confirm_message) && RulesFile.read(input_stream, p_design_name, p_board_handling); try { input_stream.close(); rules_file.delete(); @@ -344,144 +282,28 @@ public void update_eagle(BoardFrame p_board_frame) String[] file_name_parts = design_file_name.split("\\.", 2); String design_name = file_name_parts[0]; String output_file_name = design_name + ".scr"; - if (this.is_webstart) - { - String script_file_name = webstart_update_eagle(p_board_frame, output_file_name, input_stream); - - if (script_file_name == null) - { - p_board_frame.screen_messages.set_status_message(resources.getString("message_16") + " " + - resources.getString("message_7")); - return; - } - p_board_frame.screen_messages.set_status_message(resources.getString("message_14") + " " + script_file_name + " " + resources.getString("message_15")); - } - else - { - java.io.File curr_output_file = new java.io.File(get_parent(), output_file_name); - java.io.OutputStream output_stream; - try - { - output_stream = new java.io.FileOutputStream(curr_output_file); - } catch (Exception e) - { - output_stream = null; - } - - if (p_board_frame.board_panel.board_handling.export_eagle_session_file(input_stream, output_stream)) - { - p_board_frame.screen_messages.set_status_message(resources.getString("message_14") + " " + output_file_name + " " + resources.getString("message_15")); - } - else - { - p_board_frame.screen_messages.set_status_message(resources.getString("message_16") + " " + output_file_name + " " + resources.getString("message_7")); - } - } - if (WindowMessage.confirm(resources.getString("confirm"))) - { - write_rules_file(design_name, p_board_frame.board_panel.board_handling); - } - } - - private static DesignFile webstart_open_dialog(String p_design_dir_name) - { - try - { - javax.jnlp.FileOpenService file_open_service = - (javax.jnlp.FileOpenService) javax.jnlp.ServiceManager.lookup("javax.jnlp.FileOpenService"); - javax.jnlp.FileContents file_contents = - file_open_service.openFileDialog(p_design_dir_name, DesignFile.text_file_extensions); - return new DesignFile(file_contents, null, null); - } catch (Exception e) - { - return null; - } - } - - /** - * Returns the name of the created session file or null, if the write failed. - * Put into a separate function to avoid undefines in the offline version. - */ - private String secure_write_session_file(BoardFrame p_board_frame) - { - java.io.ByteArrayOutputStream output_stream = new java.io.ByteArrayOutputStream(); - String file_name = this.get_name(); - if (file_name == null) - { - return null; - } - String session_file_name = file_name.replace(".dsn", ".ses"); - - if (!p_board_frame.board_panel.board_handling.export_specctra_session_file(file_name, output_stream)) - { - return null; - } - - java.io.InputStream input_stream = new java.io.ByteArrayInputStream(output_stream.toByteArray()); - - javax.jnlp.FileContents session_file_contents = - WebStart.save_dialog(this.get_parent(), null, input_stream, session_file_name); - - if (session_file_contents == null) - { - return null; - } - String new_session_file_name; + java.io.File curr_output_file = new java.io.File(get_parent(), output_file_name); + java.io.OutputStream output_stream; try { - new_session_file_name = session_file_contents.getName(); + output_stream = new java.io.FileOutputStream(curr_output_file); } catch (Exception e) { - return null; - } - if (!new_session_file_name.equalsIgnoreCase(session_file_name)) - { - final java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); - String curr_message = resources.getString("message_20") + " " + session_file_name + "\n" + resources.getString("message_21"); - WindowMessage.ok(curr_message); - } - return new_session_file_name; - } - - /** - * Returns the name of the created script file or null, if the write failed. - * Put into a separate function to avoid undefines in the offline version. - */ - private String webstart_update_eagle(BoardFrame p_board_frame, - String p_outfile_name, java.io.InputStream p_input_stream) - { - java.io.ByteArrayOutputStream output_stream = new java.io.ByteArrayOutputStream(); - if (!p_board_frame.board_panel.board_handling.export_eagle_session_file(p_input_stream, output_stream)) - { - return null; + output_stream = null; } - java.io.InputStream input_stream = new java.io.ByteArrayInputStream(output_stream.toByteArray()); - javax.jnlp.FileContents script_file_contents = - WebStart.save_dialog(this.get_parent(), null, input_stream, p_outfile_name); - if (script_file_contents == null) + if (p_board_frame.board_panel.board_handling.export_eagle_session_file(input_stream, output_stream)) { - return null; + p_board_frame.screen_messages.set_status_message(resources.getString("message_14") + " " + output_file_name + " " + resources.getString("message_15")); } - String new_script_file_name; - try - { - new_script_file_name = script_file_contents.getName(); - } catch (Exception e) + else { - return null; + p_board_frame.screen_messages.set_status_message(resources.getString("message_16") + " " + output_file_name + " " + resources.getString("message_7")); } - - if (!new_script_file_name.endsWith(".scr")) + if (WindowMessage.confirm(resources.getString("confirm"))) { - final java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); - String curr_message = resources.getString("message_22") + "\n" + resources.getString("message_21"); - WindowMessage.ok(curr_message); + write_rules_file(design_name, p_board_frame.board_panel.board_handling); } - - return new_script_file_name; } /** @@ -493,11 +315,6 @@ public java.io.File get_output_file() return this.output_file; } - public java.io.File get_input_file() - { - return this.input_file; - } - public String get_parent() { if (input_file != null) @@ -518,12 +335,9 @@ public java.io.File get_parent_file() public boolean is_created_from_text_file() { - return this.is_webstart || this.input_file != this.output_file; + return this.input_file != this.output_file; } - private final boolean is_webstart = false; - /** Used, if the application is run with Java Web Start. */ - private javax.jnlp.FileContents file_contents; /** Used, if the application is run without Java Web Start. */ private java.io.File output_file; private final java.io.File input_file; diff --git a/src/main/java/net/freerouting/gui/WebStart.java b/src/main/java/net/freerouting/gui/WebStart.java deleted file mode 100644 index 802378ef..00000000 --- a/src/main/java/net/freerouting/gui/WebStart.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (C) 2014 Alfons Wirtz - * website www.freerouting.net - * - * 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 3 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 at - * for more details. - * - * WebStart.java - * - * Created on 4. Dezember 2006, 07:01 - * - */ - -package net.freerouting.gui; - -/** - * Function used for Java Websrart. - * Some put to a separate class to avoid runtime undefined in offline applications. - * @author Alfons Wirtz - */ -public class WebStart -{ - /* - * Separate function to avoid runtime undefines in an offline application. - */ - public static java.net.URL get_code_base() - { - try - { - javax.jnlp.BasicService basic_service = - (javax.jnlp.BasicService)javax.jnlp.ServiceManager.lookup("javax.jnlp.BasicService"); - return basic_service.getCodeBase(); - } - catch(Exception e) - { - return null; - } - } - - - public static javax.jnlp.FileContents save_dialog(String p_parent, String[] p_file_extensions, - java.io.InputStream p_input_stream, String p_name) - { - try - { - javax.jnlp.FileSaveService file_save_service = - (javax.jnlp.FileSaveService)javax.jnlp.ServiceManager.lookup("javax.jnlp.FileSaveService"); - javax.jnlp.FileContents curr_file_contents = - file_save_service.saveFileDialog(p_parent, p_file_extensions, p_input_stream, p_name); - return curr_file_contents; - } - catch (Exception e) - { - return null; - } - } - - /** - * Looks up a file with the input name in the Cookie file system of Java Web Start. - * Returns an input stream from that file or null, if no such file was found. - */ - public static java.io.InputStream get_file_input_stream(String p_file_name) - { - java.net.URL code_base = WebStart.get_code_base(); - if (code_base != null) - { - try - { - javax.jnlp.PersistenceService persistence_service = - (javax.jnlp.PersistenceService)javax.jnlp.ServiceManager.lookup("javax.jnlp.PersistenceService"); - String [] muffins = persistence_service.getNames(code_base); - for (int i = 0; i < muffins.length; ++i) - { - if (muffins[i].equals(p_file_name)) - { - java.net.URL defaults_file_url = new java.net.URL(code_base.toString() + muffins[i]); - javax.jnlp.FileContents file_contents = persistence_service.get(defaults_file_url); - return file_contents.getInputStream(); - } - } - } - catch(Exception e) - { - - } - } - return null; - } - - /** - * Looks up a file with the input name in the Cookie file system of Java Web Start. - * This file will be overwritten. - * Creates a new file, if no such file exists yet. - */ - public static java.io.OutputStream get_file_output_stream(String p_file_name) - { - java.io.OutputStream output_stream = null; - String [] muffins = null; - javax.jnlp.PersistenceService persistence_service = null; - java.net.URL code_base = get_code_base(); - if (code_base != null) - { - try - { - persistence_service = - (javax.jnlp.PersistenceService)javax.jnlp.ServiceManager.lookup("javax.jnlp.PersistenceService"); - muffins = persistence_service.getNames(code_base); - } - catch(Exception e) - { - muffins = null; - } - } - try - { - boolean file_exists = false; - java.net.URL file_url = null; - if (muffins != null) - { - for (int i = 0; i < muffins.length; ++i) - { - if (muffins[i].equals(p_file_name)) - { - file_url = new java.net.URL(code_base.toString() + muffins[i]); - file_exists = true; - } - } - } - if (!file_exists) - { - file_url = new java.net.URL(code_base.toString() + p_file_name); - long act_size = persistence_service.create(file_url, MAX_FILE_SIZE); - if (act_size < MAX_FILE_SIZE) - { - return null; - } - } - javax.jnlp.FileContents file_contents = persistence_service.get(file_url); - output_stream = file_contents.getOutputStream(true); - - } - catch(Exception e) - { - return null; - } - return output_stream; - } - - /* - * Deletes all files ending with p_file_ending from the cookie file system. - * Return false, if no file to delete was found - * If p_confirm_message != null, the user is asked to confirm the delete action. - */ - public static boolean delete_files(String p_file_ending, String p_confirm_messsage) - { - boolean file_deleted = false; - try - { - java.net.URL code_base = WebStart.get_code_base(); - if (code_base == null) - { - return false; - } - javax.jnlp.PersistenceService persistence_service = - (javax.jnlp.PersistenceService)javax.jnlp.ServiceManager.lookup("javax.jnlp.PersistenceService"); - String [] muffins = persistence_service.getNames(code_base); - java.net.URL file_url = null; - if (muffins != null) - { - for (int i = 0; i < muffins.length; ++i) - { - if (muffins[i].endsWith(p_file_ending)) - { - file_url = new java.net.URL(code_base.toString() + muffins[i]); - if (p_confirm_messsage == null || WindowMessage.confirm(p_confirm_messsage)) - { - persistence_service.delete(file_url); - file_deleted = true; - } - } - } - } - } - catch(Exception e) - { - file_deleted = false; - } - return file_deleted; - } - - private static final long MAX_FILE_SIZE = 100000; -} From 2e48413181412a90b281b7c6ba8da459a6fc1b3d Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Mon, 21 Sep 2015 21:51:18 +0300 Subject: [PATCH 10/14] All code has been reformatted using default IDEA settings --- .../autoroute/AutorouteControl.java | 295 +- .../autoroute/AutorouteEngine.java | 439 +-- .../autoroute/BatchAutorouter.java | 290 +- .../freerouting/autoroute/BatchFanout.java | 164 +- .../freerouting/autoroute/BatchOptRoute.java | 292 +- .../autoroute/CompleteExpansionRoom.java | 10 +- .../CompleteFreeSpaceExpansionRoom.java | 190 +- .../net/freerouting/autoroute/Connection.java | 147 +- .../autoroute/DestinationDistance.java | 402 +- .../net/freerouting/autoroute/DrillPage.java | 214 +- .../freerouting/autoroute/DrillPageArray.java | 160 +- .../autoroute/ExpandableObject.java | 9 +- .../freerouting/autoroute/ExpansionDoor.java | 156 +- .../freerouting/autoroute/ExpansionDrill.java | 96 +- .../freerouting/autoroute/ExpansionRoom.java | 24 +- .../autoroute/FreeSpaceExpansionRoom.java | 93 +- .../IncompleteFreeSpaceExpansionRoom.java | 37 +- .../autoroute/InsertFoundConnectionAlgo.java | 227 +- .../autoroute/ItemAutorouteInfo.java | 107 +- .../autoroute/LocateFoundConnectionAlgo.java | 546 ++- .../LocateFoundConnectionAlgo45Degree.java | 313 +- .../LocateFoundConnectionAlgoAnyAngle.java | 340 +- .../autoroute/MazeListElement.java | 106 +- .../freerouting/autoroute/MazeSearchAlgo.java | 1034 ++---- .../autoroute/MazeSearchElement.java | 37 +- .../autoroute/MazeShoveTraceAlgo.java | 295 +- .../autoroute/ObstacleExpansionRoom.java | 153 +- .../Sorted45DegreeRoomNeighbours.java | 987 ++--- .../SortedOrthogonalRoomNeighbours.java | 612 ++- .../autoroute/SortedRoomNeighbours.java | 699 ++-- .../autoroute/TargetItemExpansionDoor.java | 56 +- .../net/freerouting/autoroute/package.html | 6 +- .../freerouting/board/AngleRestriction.java | 40 +- .../net/freerouting/board/BasicBoard.java | 833 ++--- .../board/BoardObserverAdaptor.java | 50 +- .../net/freerouting/board/BoardObservers.java | 4 +- .../net/freerouting/board/BoardOutline.java | 235 +- .../net/freerouting/board/CalcFromSide.java | 91 +- .../board/CalcShapeAndFromSide.java | 92 +- .../net/freerouting/board/ChangedArea.java | 84 +- .../freerouting/board/ClearanceViolation.java | 48 +- .../net/freerouting/board/Communication.java | 135 +- .../java/net/freerouting/board/Component.java | 229 +- .../board/ComponentObstacleArea.java | 60 +- .../freerouting/board/ComponentOutline.java | 162 +- .../net/freerouting/board/Components.java | 141 +- .../net/freerouting/board/ConductionArea.java | 149 +- .../net/freerouting/board/Connectable.java | 24 +- .../board/CoordinateTransform.java | 122 +- .../java/net/freerouting/board/DrillItem.java | 419 +-- .../net/freerouting/board/FixedState.java | 3 +- .../net/freerouting/board/ForcedPadAlgo.java | 541 ++- .../net/freerouting/board/ForcedViaAlgo.java | 188 +- src/main/java/net/freerouting/board/Item.java | 796 ++-- .../freerouting/board/ItemIdNoGenerator.java | 29 +- .../board/ItemSearchTreesInfo.java | 93 +- .../board/ItemSelectionFilter.java | 77 +- .../java/net/freerouting/board/Layer.java | 38 +- .../net/freerouting/board/LayerStructure.java | 88 +- .../net/freerouting/board/MoveComponent.java | 136 +- .../freerouting/board/MoveDrillItemAlgo.java | 222 +- .../freerouting/board/ObjectInfoPanel.java | 38 +- .../net/freerouting/board/ObstacleArea.java | 316 +- .../net/freerouting/board/OptViaAlgo.java | 538 ++- src/main/java/net/freerouting/board/Pin.java | 602 ++- .../net/freerouting/board/PolylineTrace.java | 748 ++-- .../net/freerouting/board/PrintableShape.java | 90 +- .../net/freerouting/board/PullTightAlgo.java | 349 +- .../freerouting/board/PullTightAlgo45.java | 438 +-- .../freerouting/board/PullTightAlgo90.java | 135 +- .../board/PullTightAlgoAnyAngle.java | 794 ++-- .../net/freerouting/board/RoutingBoard.java | 799 ++-- .../freerouting/board/SearchTreeManager.java | 261 +- .../freerouting/board/SearchTreeObject.java | 13 +- .../freerouting/board/ShapeSearchTree.java | 585 +-- .../board/ShapeSearchTree45Degree.java | 394 +- .../board/ShapeSearchTree90Degree.java | 242 +- .../freerouting/board/ShapeTraceEntries.java | 773 ++-- .../net/freerouting/board/ShoveTraceAlgo.java | 654 ++-- .../java/net/freerouting/board/TestLevel.java | 3 +- .../java/net/freerouting/board/Trace.java | 349 +- src/main/java/net/freerouting/board/Unit.java | 140 +- src/main/java/net/freerouting/board/Via.java | 172 +- .../freerouting/board/ViaObstacleArea.java | 66 +- .../java/net/freerouting/board/package.html | 62 +- .../boardgraphics/ColorIntensityTable.java | 51 +- .../boardgraphics/ColorTableModel.java | 35 +- .../boardgraphics/CoordinateTransform.java | 235 +- .../freerouting/boardgraphics/Drawable.java | 22 +- .../boardgraphics/GraphicsContext.java | 785 ++-- .../boardgraphics/ItemColorTableModel.java | 263 +- .../boardgraphics/ItemDrawInfo.java | 29 +- .../boardgraphics/OtherColorTableModel.java | 157 +- .../freerouting/boardgraphics/package.html | 6 +- .../datastructures/ArrayStack.java | 51 +- .../freerouting/datastructures/BigIntAux.java | 85 +- .../datastructures/FileFilter.java | 51 +- .../datastructures/IdNoGenerator.java | 5 +- .../datastructures/IdentifierType.java | 49 +- .../datastructures/IndentFileWriter.java | 64 +- .../datastructures/MinAreaTree.java | 193 +- .../freerouting/datastructures/Observers.java | 21 +- .../PlanarDelaunayTriangulation.java | 1030 +++-- .../freerouting/datastructures/ShapeTree.java | 259 +- .../freerouting/datastructures/Signum.java | 69 +- .../freerouting/datastructures/Stoppable.java | 5 +- .../freerouting/datastructures/TimeLimit.java | 28 +- .../datastructures/UndoableObjects.java | 243 +- .../freerouting/datastructures/package.html | 8 +- .../specctra/AutorouteSettings.java | 185 +- .../designformats/specctra/Circle.java | 63 +- .../designformats/specctra/Circuit.java | 127 +- .../designformats/specctra/Component.java | 315 +- .../specctra/ComponentPlacement.java | 103 +- .../specctra/CoordinateTransform.java | 183 +- .../designformats/specctra/DsnFile.java | 250 +- .../designformats/specctra/Keyword.java | 25 +- .../designformats/specctra/Layer.java | 44 +- .../specctra/LayerStructure.java | 61 +- .../designformats/specctra/Library.java | 477 +-- .../designformats/specctra/Net.java | 125 +- .../designformats/specctra/NetClass.java | 203 +- .../designformats/specctra/NetList.java | 56 +- .../designformats/specctra/Network.java | 1208 +++--- .../designformats/specctra/Package.java | 418 +-- .../designformats/specctra/Parser.java | 219 +- .../designformats/specctra/PartLibrary.java | 328 +- .../designformats/specctra/Path.java | 26 +- .../designformats/specctra/PlaceControl.java | 107 +- .../designformats/specctra/Placement.java | 25 +- .../designformats/specctra/Plane.java | 97 +- .../designformats/specctra/Polygon.java | 85 +- .../designformats/specctra/PolygonPath.java | 115 +- .../designformats/specctra/PolylinePath.java | 59 +- .../specctra/ReadScopeParameter.java | 86 +- .../designformats/specctra/Rectangle.java | 82 +- .../designformats/specctra/Resolution.java | 61 +- .../designformats/specctra/Rule.java | 240 +- .../designformats/specctra/RulesFile.java | 233 +- .../designformats/specctra/Scanner.java | 7 +- .../designformats/specctra/ScopeKeyword.java | 74 +- .../designformats/specctra/SessionFile.java | 330 +- .../specctra/SessionToEagle.java | 564 ++- .../designformats/specctra/Shape.java | 509 +-- .../specctra/SpecctraFileScanner.java | 2921 ++++++++------- .../designformats/specctra/Structure.java | 1353 +++---- .../designformats/specctra/Wiring.java | 711 ++-- .../specctra/WriteScopeParameter.java | 31 +- .../designformats/specctra/package.html | 8 +- .../net/freerouting/geometry/planar/Area.java | 47 +- .../geometry/planar/BigIntDirection.java | 132 +- .../freerouting/geometry/planar/Circle.java | 316 +- .../geometry/planar/ConvexShape.java | 13 +- .../geometry/planar/Direction.java | 161 +- .../freerouting/geometry/planar/Ellipse.java | 39 +- .../geometry/planar/FloatLine.java | 211 +- .../geometry/planar/FloatPoint.java | 489 +-- .../FortyfiveDegreeBoundingDirections.java | 44 +- .../planar/FortyfiveDegreeDirection.java | 52 +- .../freerouting/geometry/planar/IntBox.java | 694 ++-- .../geometry/planar/IntDirection.java | 185 +- .../geometry/planar/IntOctagon.java | 1414 +++---- .../freerouting/geometry/planar/IntPoint.java | 421 +-- .../geometry/planar/IntVector.java | 242 +- .../freerouting/geometry/planar/Limits.java | 8 +- .../net/freerouting/geometry/planar/Line.java | 462 +-- .../geometry/planar/LineSegment.java | 394 +- .../planar/OrthogonalBoundingDirections.java | 47 +- .../freerouting/geometry/planar/Point.java | 202 +- .../freerouting/geometry/planar/Polygon.java | 129 +- .../geometry/planar/PolygonShape.java | 576 ++- .../freerouting/geometry/planar/Polyline.java | 885 ++--- .../geometry/planar/PolylineArea.java | 181 +- .../geometry/planar/PolylineShape.java | 210 +- .../geometry/planar/RationalPoint.java | 276 +- .../geometry/planar/RationalVector.java | 235 +- .../geometry/planar/RegularTileShape.java | 68 +- .../freerouting/geometry/planar/Shape.java | 42 +- .../planar/ShapeBoundingDirections.java | 8 +- .../net/freerouting/geometry/planar/Side.java | 81 +- .../freerouting/geometry/planar/Simplex.java | 937 ++--- .../geometry/planar/TileShape.java | 543 +-- .../freerouting/geometry/planar/Vector.java | 210 +- .../freerouting/geometry/planar/package.html | 116 +- .../java/net/freerouting/gui/BoardFrame.java | 612 ++- .../net/freerouting/gui/BoardMenuBar.java | 28 +- .../net/freerouting/gui/BoardMenuDisplay.java | 73 +- .../net/freerouting/gui/BoardMenuFile.java | 151 +- .../net/freerouting/gui/BoardMenuHelp.java | 54 +- .../freerouting/gui/BoardMenuHelpReduced.java | 20 +- .../net/freerouting/gui/BoardMenuInfo.java | 105 +- .../net/freerouting/gui/BoardMenuOther.java | 50 +- .../freerouting/gui/BoardMenuParameter.java | 75 +- .../net/freerouting/gui/BoardMenuRules.java | 73 +- .../java/net/freerouting/gui/BoardPanel.java | 377 +- .../net/freerouting/gui/BoardPanelStatus.java | 45 +- .../gui/BoardSavableSubWindow.java | 51 +- .../net/freerouting/gui/BoardSubWindow.java | 18 +- .../gui/BoardTemporarySubWindow.java | 39 +- .../net/freerouting/gui/BoardToolbar.java | 210 +- .../gui/BoardToolbarSelectedItem.java | 246 +- .../net/freerouting/gui/ColorManager.java | 196 +- .../freerouting/gui/ComboBoxClearance.java | 61 +- .../net/freerouting/gui/ComboBoxLayer.java | 72 +- src/main/java/net/freerouting/gui/Cursor.java | 82 +- .../java/net/freerouting/gui/DesignFile.java | 231 +- .../net/freerouting/gui/GUIDefaultsFile.java | 1390 +++---- .../freerouting/gui/GUIDefaultsScanner.java | 3298 +++++++++-------- .../net/freerouting/gui/MainApplication.java | 330 +- .../freerouting/gui/PopupMenuChangeLayer.java | 70 +- .../net/freerouting/gui/PopupMenuCopy.java | 55 +- .../net/freerouting/gui/PopupMenuDisplay.java | 51 +- .../gui/PopupMenuDynamicRoute.java | 71 +- .../gui/PopupMenuInsertCancel.java | 36 +- .../net/freerouting/gui/PopupMenuMain.java | 108 +- .../net/freerouting/gui/PopupMenuMove.java | 125 +- .../gui/PopupMenuSelectedItems.java | 35 +- .../freerouting/gui/PopupMenuStitchRoute.java | 66 +- .../gui/PupupMenuCornerItemConstruction.java | 46 +- .../java/net/freerouting/gui/WindowAbout.java | 24 +- .../freerouting/gui/WindowAssignNetClass.java | 181 +- .../gui/WindowAutorouteDetailParameter.java | 290 +- .../gui/WindowAutorouteParameter.java | 122 +- .../gui/WindowClearanceMatrix.java | 398 +- .../gui/WindowClearanceViolations.java | 133 +- .../net/freerouting/gui/WindowComponents.java | 49 +- .../freerouting/gui/WindowDisplayMisc.java | 242 +- .../net/freerouting/gui/WindowEditVias.java | 265 +- .../freerouting/gui/WindowIncompletes.java | 42 +- .../gui/WindowLayerVisibility.java | 61 +- .../gui/WindowLengthViolations.java | 86 +- .../freerouting/gui/WindowManualRules.java | 137 +- .../net/freerouting/gui/WindowMessage.java | 66 +- .../freerouting/gui/WindowMoveParameter.java | 191 +- .../net/freerouting/gui/WindowNetClasses.java | 460 +-- .../java/net/freerouting/gui/WindowNets.java | 110 +- .../net/freerouting/gui/WindowObjectInfo.java | 326 +- .../net/freerouting/gui/WindowObjectList.java | 288 +- .../gui/WindowObjectListWithFilter.java | 102 +- .../gui/WindowObjectVisibility.java | 51 +- .../net/freerouting/gui/WindowPackages.java | 50 +- .../net/freerouting/gui/WindowPadstacks.java | 56 +- .../freerouting/gui/WindowRouteDetail.java | 71 +- .../freerouting/gui/WindowRouteParameter.java | 559 ++- .../net/freerouting/gui/WindowRouteStubs.java | 158 +- .../gui/WindowSelectParameter.java | 181 +- .../net/freerouting/gui/WindowSnapshot.java | 278 +- .../gui/WindowSnapshotSettings.java | 269 +- .../gui/WindowUnconnectedRoute.java | 128 +- .../java/net/freerouting/gui/WindowVia.java | 391 +- .../net/freerouting/gui/WindowViaRule.java | 150 +- .../net/freerouting/gui/WindowVisibility.java | 107 +- .../java/net/freerouting/gui/package.html | 6 +- .../net/freerouting/helpset/de/HelpIndex.xml | 185 +- .../net/freerouting/helpset/de/HelpTOC.xml | 196 +- .../java/net/freerouting/helpset/de/Map.jhm | 203 +- .../helpset/de/html_files/FileMenu.html | 144 +- .../helpset/de/html_files/MenuState.html | 200 +- .../helpset/de/html_files/MoveItemState.html | 98 +- .../helpset/de/html_files/RouteState.html | 146 +- .../de/html_files/SelectedItemState.html | 196 +- .../WindowAutorouteDetailParameter.html | 66 +- .../html_files/WindowAutorouteParameter.html | 42 +- .../de/html_files/WindowClearanceMatrix.html | 53 +- .../helpset/de/html_files/WindowDisplay.html | 97 +- .../de/html_files/WindowManualRules.html | 53 +- .../de/html_files/WindowMoveParameter.html | 28 +- .../de/html_files/WindowNetClasses.html | 190 +- .../de/html_files/WindowObjectList.html | 200 +- .../de/html_files/WindowRouteParameter.html | 160 +- .../de/html_files/WindowSelectParameter.html | 57 +- .../de/html_files/WindowSnapshots.html | 237 +- .../helpset/de/html_files/WindowVia.html | 180 +- .../net/freerouting/helpset/de/index.html | 45 +- .../net/freerouting/helpset/en/HelpIndex.xml | 177 +- .../net/freerouting/helpset/en/HelpTOC.xml | 195 +- .../java/net/freerouting/helpset/en/Map.jhm | 207 +- .../helpset/en/html_files/FileMenu.html | 137 +- .../helpset/en/html_files/MenuState.html | 187 +- .../helpset/en/html_files/MoveItemState.html | 86 +- .../helpset/en/html_files/RouteState.html | 134 +- .../en/html_files/SelectedItemState.html | 186 +- .../WindowAutorouteDetailParameter.html | 66 +- .../html_files/WindowAutorouteParameter.html | 43 +- .../en/html_files/WindowClearanceMatrix.html | 49 +- .../helpset/en/html_files/WindowDisplay.html | 93 +- .../en/html_files/WindowManualRules.html | 58 +- .../en/html_files/WindowMoveParameter.html | 28 +- .../en/html_files/WindowNetClasses.html | 182 +- .../en/html_files/WindowObjectList.html | 178 +- .../en/html_files/WindowRouteParameter.html | 135 +- .../en/html_files/WindowSelectParameter.html | 63 +- .../en/html_files/WindowSnapshots.html | 205 +- .../helpset/en/html_files/WindowVia.html | 169 +- .../net/freerouting/helpset/en/index.html | 40 +- .../interactive/AutorouteSettings.java | 217 +- .../interactive/BatchAutorouterThread.java | 81 +- .../interactive/BoardHandling.java | 1013 ++--- .../interactive/CircleConstructionState.java | 118 +- .../interactive/ClearanceViolations.java | 69 +- .../interactive/CopyItemState.java | 283 +- .../CornerItemConstructionState.java | 118 +- .../interactive/CutoutRouteState.java | 132 +- .../interactive/DragItemState.java | 125 +- .../interactive/DragMenuState.java | 35 +- .../freerouting/interactive/DragState.java | 115 +- .../interactive/DynamicRouteState.java | 55 +- .../interactive/ExpandTestState.java | 167 +- .../interactive/HoleConstructionState.java | 154 +- .../interactive/InteractiveActionThread.java | 135 +- .../interactive/InteractiveState.java | 176 +- .../net/freerouting/interactive/Logfile.java | 176 +- .../interactive/LogfileScanner.java | 973 +++-- .../freerouting/interactive/LogfileScope.java | 1334 +++---- .../interactive/MakeSpaceState.java | 75 +- .../freerouting/interactive/MenuState.java | 158 +- .../interactive/MoveItemState.java | 527 +-- .../interactive/NetIncompletes.java | 302 +- .../freerouting/interactive/PinSwapState.java | 105 +- .../PolygonShapeConstructionState.java | 81 +- .../net/freerouting/interactive/RatsNest.java | 257 +- .../net/freerouting/interactive/Route.java | 575 +-- .../interactive/RouteMenuState.java | 42 +- .../freerouting/interactive/RouteState.java | 377 +- .../interactive/ScreenMessages.java | 133 +- .../interactive/SelectItemsInRegionState.java | 82 +- .../interactive/SelectMenuState.java | 47 +- .../interactive/SelectRegionState.java | 44 +- .../interactive/SelectedItemState.java | 545 +-- .../net/freerouting/interactive/Settings.java | 690 ++-- .../net/freerouting/interactive/SnapShot.java | 213 +- .../interactive/StitchRouteState.java | 51 +- .../interactive/TileConstructionState.java | 164 +- .../interactive/ZoomRegionState.java | 53 +- .../net/freerouting/interactive/package.html | 8 +- .../net/freerouting/library/BoardLibrary.java | 189 +- .../net/freerouting/library/LogicalPart.java | 99 +- .../net/freerouting/library/LogicalParts.java | 42 +- .../java/net/freerouting/library/Package.java | 165 +- .../net/freerouting/library/Packages.java | 70 +- .../net/freerouting/library/Padstack.java | 128 +- .../net/freerouting/library/Padstacks.java | 76 +- .../java/net/freerouting/library/package.html | 7 +- .../net/freerouting/rules/BoardRules.java | 435 +-- .../freerouting/rules/ClearanceMatrix.java | 352 +- .../rules/DefaultItemClearanceClasses.java | 63 +- src/main/java/net/freerouting/rules/Net.java | 141 +- .../java/net/freerouting/rules/NetClass.java | 241 +- .../net/freerouting/rules/NetClasses.java | 91 +- src/main/java/net/freerouting/rules/Nets.java | 115 +- .../java/net/freerouting/rules/ViaInfo.java | 91 +- .../java/net/freerouting/rules/ViaInfos.java | 71 +- .../java/net/freerouting/rules/ViaRule.java | 110 +- .../java/net/freerouting/rules/package.html | 6 +- .../java/net/freerouting/tests/Validate.java | 230 +- .../java/net/freerouting/tests/package.html | 6 +- 356 files changed, 33386 insertions(+), 47473 deletions(-) diff --git a/src/main/java/net/freerouting/autoroute/AutorouteControl.java b/src/main/java/net/freerouting/autoroute/AutorouteControl.java index 07cf7e63..297452d7 100644 --- a/src/main/java/net/freerouting/autoroute/AutorouteControl.java +++ b/src/main/java/net/freerouting/autoroute/AutorouteControl.java @@ -19,39 +19,137 @@ */ package net.freerouting.autoroute; +import net.freerouting.board.RoutingBoard; import net.freerouting.geometry.planar.ConvexShape; - import net.freerouting.rules.ViaInfo; import net.freerouting.rules.ViaRule; -import net.freerouting.board.RoutingBoard; - /** * Structure for controlling the autoroute algorithm. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class AutorouteControl -{ +public class AutorouteControl { - /** Creates a new instance of AutorouteControl for the input net */ - public AutorouteControl(RoutingBoard p_board, int p_net_no, net.freerouting.interactive.Settings p_settings) - { + /** + * The horizontal and vertical trace costs on each layer + */ + public final ExpansionCostFactor[] trace_costs; + public final boolean with_neckdown; + final int layer_count; + /** + * Defines for each layer, if it may used for routing. + */ + final boolean[] layer_active; + /** + * The currently used trace half widths in the autoroute algorithm on each layer + */ + final int[] trace_half_width; + /** + * The currently used compensated trace half widths in the autoroute algorithm on each layer. + * Equal to trace_half_width if no clearance compensation is used. + */ + final int[] compensated_trace_half_width; + final double[] via_radius_arr; + /** + * the additiomal costs to min_normal via_cost for inserting a via between 2 layers + */ + final ViaCost[] add_via_costs; + /** + * The currently used clearance class for traces in the autoroute algorithm + */ + public int trace_clearance_class_no; + /** + * True, if layer change by inserting of vias is allowed + */ + public boolean vias_allowed; + /** + * True, if vias may drill to the pad of SMD pins + */ + public boolean attach_smd_allowed; + /** + * The minimum cost valua of all normal vias + */ + public double min_normal_via_cost; + public boolean ripup_allowed; + public int ripup_costs; + public int ripup_pass_no; + /** + * If true, the autoroute algorithm completes after the first drill + */ + public boolean is_fanout; + /** + * Normally true, if the autorouter contains no fanout pass + */ + public boolean remove_unconnected_vias; + /** + * The currently used net number in the autoroute algorithm + */ + int net_no; + /** + * The currently used clearance class for vias in the autoroute algorithm + */ + int via_clearance_class; + /** + * The possible (partial) vias, which can be used by the autorouter + */ + ViaRule via_rule; + /** + * The array of possible via ranges used bei the autorouter + */ + ViaMask[] via_info_arr; + /** + * The lower bound for the first layer of vias + */ + int via_lower_bound; + /** + * The upper bound for the last layer of vias + */ + int via_upper_bound; + double max_via_radius; + /** + * The width of the region around changed traces, where traces are pulled tight + */ + int tidy_region_width; + /** + * The pull tight accuracy of traces + */ + int pull_tight_accuracy; + /** + * The maximum recursion depth for shoving traces + */ + int max_shove_trace_recursion_depth; + /** + * The maximum recursion depth for shoving obstacles + */ + int max_shove_via_recursion_depth; + /** + * The maximum recursion depth for traces springing over obstacles + */ + int max_spring_over_recursion_depth; + /** + * The minimal cost value of all cheap vias + */ + double min_cheap_via_cost; + /** + * Creates a new instance of AutorouteControl for the input net + */ + public AutorouteControl(RoutingBoard p_board, int p_net_no, net.freerouting.interactive.Settings p_settings) { this(p_board, p_settings, p_settings.autoroute_settings.get_trace_cost_arr()); init_net(p_net_no, p_board, p_settings.autoroute_settings.get_via_costs()); } - - /** Creates a new instance of AutorouteControl for the input net */ - public AutorouteControl(RoutingBoard p_board, int p_net_no, net.freerouting.interactive.Settings p_settings, int p_via_costs, ExpansionCostFactor[] p_trace_cost_arr) - { + /** + * Creates a new instance of AutorouteControl for the input net + */ + public AutorouteControl(RoutingBoard p_board, int p_net_no, net.freerouting.interactive.Settings p_settings, int p_via_costs, ExpansionCostFactor[] p_trace_cost_arr) { this(p_board, p_settings, p_trace_cost_arr); init_net(p_net_no, p_board, p_via_costs); } - - /** Creates a new instance of AutorouteControl */ + /** + * Creates a new instance of AutorouteControl + */ private AutorouteControl(RoutingBoard p_board, net.freerouting.interactive.Settings p_settings, - ExpansionCostFactor[] p_trace_costs_arr) - { + ExpansionCostFactor[] p_trace_costs_arr) { layer_count = p_board.get_layer_count(); trace_half_width = new int[layer_count]; compensated_trace_half_width = new int[layer_count]; @@ -60,8 +158,7 @@ private AutorouteControl(RoutingBoard p_board, net.freerouting.interactive.Setti via_radius_arr = new double[layer_count]; add_via_costs = new ViaCost[layer_count]; - for (int i = 0; i < layer_count; ++i) - { + for (int i = 0; i < layer_count; ++i) { add_via_costs[i] = new ViaCost(layer_count); layer_active[i] = p_settings.autoroute_settings.get_layer_active(i); } @@ -73,10 +170,8 @@ private AutorouteControl(RoutingBoard p_board, net.freerouting.interactive.Setti max_shove_trace_recursion_depth = 20; max_shove_via_recursion_depth = 5; max_spring_over_recursion_depth = 5; - for (int i = 0; i < layer_count; ++i) - { - for (int j = 0; j < layer_count; ++j) - { + for (int i = 0; i < layer_count; ++i) { + for (int j = 0; j < layer_count; ++j) { add_via_costs[i].to_layer[j] = 0; } } @@ -90,76 +185,57 @@ private AutorouteControl(RoutingBoard p_board, net.freerouting.interactive.Setti ripup_pass_no = 1; } - private void init_net(int p_net_no, RoutingBoard p_board, int p_via_costs) - { + private void init_net(int p_net_no, RoutingBoard p_board, int p_via_costs) { net_no = p_net_no; net.freerouting.rules.Net curr_net = p_board.rules.nets.get(p_net_no); net.freerouting.rules.NetClass curr_net_class; - if (curr_net != null) - { + if (curr_net != null) { curr_net_class = curr_net.get_class(); trace_clearance_class_no = curr_net_class.get_trace_clearance_class(); via_rule = curr_net_class.get_via_rule(); - } - else - { + } else { trace_clearance_class_no = 1; via_rule = p_board.rules.via_rules.firstElement(); curr_net_class = null; } - for (int i = 0; i < layer_count; ++i) - { - if (net_no > 0) - { + for (int i = 0; i < layer_count; ++i) { + if (net_no > 0) { trace_half_width[i] = p_board.rules.get_trace_half_width(net_no, i); - } - else - { + } else { trace_half_width[i] = p_board.rules.get_trace_half_width(1, i); } compensated_trace_half_width[i] = trace_half_width[i] + p_board.rules.clearance_matrix.clearance_compensation_value(trace_clearance_class_no, i); - if (curr_net_class != null && !curr_net_class.is_active_routing_layer(i)) - { + if (curr_net_class != null && !curr_net_class.is_active_routing_layer(i)) { layer_active[i] = false; } } - if (via_rule.via_count() > 0) - { + if (via_rule.via_count() > 0) { this.via_clearance_class = via_rule.get_via(0).get_clearance_class(); - } - else - { + } else { this.via_clearance_class = 1; } this.via_info_arr = new ViaMask[via_rule.via_count()]; - for (int i = 0; i < via_rule.via_count(); ++i) - { + for (int i = 0; i < via_rule.via_count(); ++i) { ViaInfo curr_via = via_rule.get_via(i); - if (curr_via.attach_smd_allowed()) - { + if (curr_via.attach_smd_allowed()) { this.attach_smd_allowed = true; } net.freerouting.library.Padstack curr_via_padstack = curr_via.get_padstack(); int from_layer = curr_via_padstack.from_layer(); int to_layer = curr_via_padstack.to_layer(); - for (int j = from_layer; j <= to_layer; ++j) - { + for (int j = from_layer; j <= to_layer; ++j) { ConvexShape curr_shape = curr_via_padstack.get_shape(j); double curr_radius; - if( curr_shape != null) - { - curr_radius = 0.5 * curr_shape.max_width(); - } - else - { + if (curr_shape != null) { + curr_radius = 0.5 * curr_shape.max_width(); + } else { curr_radius = 0; } this.via_radius_arr[j] = Math.max(this.via_radius_arr[j], curr_radius); } via_info_arr[i] = new ViaMask(from_layer, to_layer, curr_via.attach_smd_allowed()); } - for (int j = 0; j < this.layer_count; ++j) - { + for (int j = 0; j < this.layer_count; ++j) { this.via_radius_arr[j] = Math.max(this.via_radius_arr[j], trace_half_width[j]); this.max_via_radius = Math.max(this.max_via_radius, this.via_radius_arr[j]); } @@ -168,102 +244,47 @@ private void init_net(int p_net_no, RoutingBoard p_board, int p_via_costs) min_normal_via_cost = p_via_costs * via_cost_factor; min_cheap_via_cost = 0.8 * min_normal_via_cost; } - final int layer_count; - /** The horizontal and vertical trace costs on each layer */ - public final ExpansionCostFactor[] trace_costs; - /** Defines for each layer, if it may used for routing. */ - final boolean[] layer_active; - /** The currently used net number in the autoroute algorithm */ - int net_no; - /** The currently used trace half widths in the autoroute algorithm on each layer */ - final int[] trace_half_width; - /** - * The currently used compensated trace half widths in the autoroute algorithm on each layer. - * Equal to trace_half_width if no clearance compensation is used. - */ - final int[] compensated_trace_half_width; - /** The currently used clearance class for traces in the autoroute algorithm */ - public int trace_clearance_class_no; - /** The currently used clearance class for vias in the autoroute algorithm */ - int via_clearance_class; - /** The possible (partial) vias, which can be used by the autorouter */ - ViaRule via_rule; - /** The array of possible via ranges used bei the autorouter */ - ViaMask[] via_info_arr; - /** The lower bound for the first layer of vias */ - int via_lower_bound; - /** The upper bound for the last layer of vias */ - int via_upper_bound; - final double[] via_radius_arr; - double max_via_radius; - /** The width of the region around changed traces, where traces are pulled tight */ - int tidy_region_width; - /** The pull tight accuracy of traces*/ - int pull_tight_accuracy; - /** The maximum recursion depth for shoving traces */ - int max_shove_trace_recursion_depth; - /** The maximum recursion depth for shoving obstacles */ - int max_shove_via_recursion_depth; - /** The maximum recursion depth for traces springing over obstacles */ - int max_spring_over_recursion_depth; - /** True, if layer change by inserting of vias is allowed */ - public boolean vias_allowed; - /** True, if vias may drill to the pad of SMD pins */ - public boolean attach_smd_allowed; - /** the additiomal costs to min_normal via_cost for inserting a via between 2 layers */ - final ViaCost[] add_via_costs; - /** The minimum cost valua of all normal vias */ - public double min_normal_via_cost; - /** The minimal cost value of all cheap vias */ - double min_cheap_via_cost; - public boolean ripup_allowed; - public int ripup_costs; - public int ripup_pass_no; - public final boolean with_neckdown; - /** If true, the autoroute algorithm completes after the first drill */ - public boolean is_fanout; + /** - * Normally true, if the autorouter contains no fanout pass + * horizontal and vertical costs for traces on a board layer */ - public boolean remove_unconnected_vias; - - /** horizontal and vertical costs for traces on a board layer */ - public static class ExpansionCostFactor - { + public static class ExpansionCostFactor { - public ExpansionCostFactor(double p_horizontal, double p_vertical) - { + /** + * The horizontal expansion cost factor on a layer of the board + */ + public final double horizontal; + /** + * The verical expansion cost factor on a layer of the board + */ + public final double vertical; + public ExpansionCostFactor(double p_horizontal, double p_vertical) { horizontal = p_horizontal; vertical = p_vertical; } - /** The horizontal expansion cost factor on a layer of the board */ - public final double horizontal; - /** The verical expansion cost factor on a layer of the board */ - public final double vertical; } - /** Array of via costs from one layer to the other layers */ - static class ViaCost - { + /** + * Array of via costs from one layer to the other layers + */ + static class ViaCost { + + public int[] to_layer; - private ViaCost(int p_layer_count) - { + private ViaCost(int p_layer_count) { to_layer = new int[p_layer_count]; } - public int[] to_layer; } - static class ViaMask - { + static class ViaMask { - ViaMask(int p_from_layer, int p_to_layer, boolean p_attach_smd_allowed) - { + final int from_layer; + final int to_layer; + final boolean attach_smd_allowed; + ViaMask(int p_from_layer, int p_to_layer, boolean p_attach_smd_allowed) { from_layer = p_from_layer; to_layer = p_to_layer; attach_smd_allowed = p_attach_smd_allowed; } - final int from_layer; - final int to_layer; - final boolean attach_smd_allowed; } } diff --git a/src/main/java/net/freerouting/autoroute/AutorouteEngine.java b/src/main/java/net/freerouting/autoroute/AutorouteEngine.java index b7fa2964..adef2f14 100644 --- a/src/main/java/net/freerouting/autoroute/AutorouteEngine.java +++ b/src/main/java/net/freerouting/autoroute/AutorouteEngine.java @@ -19,44 +19,72 @@ */ package net.freerouting.autoroute; +import net.freerouting.board.*; +import net.freerouting.datastructures.Stoppable; +import net.freerouting.datastructures.TimeLimit; import net.freerouting.geometry.planar.Line; import net.freerouting.geometry.planar.Simplex; import net.freerouting.geometry.planar.TileShape; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.TreeSet; -import java.util.Set; -import java.util.SortedSet; - -import net.freerouting.datastructures.Stoppable; -import net.freerouting.datastructures.TimeLimit; - -import net.freerouting.board.SearchTreeObject; -import net.freerouting.board.Item; -import net.freerouting.board.RoutingBoard; -import net.freerouting.board.ShapeSearchTree; -import net.freerouting.board.ShapeSearchTree90Degree; -import net.freerouting.board.ShapeSearchTree45Degree; -import net.freerouting.board.TestLevel; +import java.util.*; /** * Temporary autoroute data stored on the RoutingBoard. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class AutorouteEngine -{ +public class AutorouteEngine { + + static final int TRACE_WIDTH_TOLERANCE = 2; + /** + * The current search tree used in autorouting. + * It depends on the trac clearance class used in the autoroute algorithm. + */ + public final ShapeSearchTree autoroute_search_tree; + /** + * If maintain_database, the autorouter database is maintained after a connection is + * completed for performance reasons. + */ + public final boolean maintain_database; + /** + * The 2-dimensional array of rectangular pages of ExpansionDrills + */ + final DrillPageArray drill_page_array; + /** + * The PCB-board of this autoroute algorithm. + */ + final RoutingBoard board; + /** + * To be able to stop the expansion algorithm. + */ + Stoppable stoppable_thread; + /** + * The net number used for routing in this autoroute algorithm. + */ + private int net_no; + /** + * To stop the expansion algorithm after a time limit is exceeded. + */ + private TimeLimit time_limit; + /** + * The list of incomplete expansion rooms on the routing board + */ + private List incomplete_expansion_rooms = null; + /** + * The list of complete expansion rooms on the routing board + */ + private List complete_expansion_rooms = null; + /** + * The count of expansion rooms created so far + */ + private int expansion_room_instance_count = 0; /** * Creates a new instance of BoardAoutorouteEngine * If p_maintain_database, the autorouter database is maintained after a connection is * completed for performance reasons. */ - public AutorouteEngine(RoutingBoard p_board, int p_trace_clearance_class_no, boolean p_maintain_database) - { + public AutorouteEngine(RoutingBoard p_board, int p_trace_clearance_class_no, boolean p_maintain_database) { this.board = p_board; this.maintain_database = p_maintain_database; this.net_no = -1; @@ -67,34 +95,25 @@ public AutorouteEngine(RoutingBoard p_board, int p_trace_clearance_class_no, boo this.stoppable_thread = null; } - public void init_connection(int p_net_no, Stoppable p_stoppable_thread, TimeLimit p_time_limit) - { - if (this.maintain_database) - { - if (p_net_no != this.net_no) - { - if (this.complete_expansion_rooms != null) - { + public void init_connection(int p_net_no, Stoppable p_stoppable_thread, TimeLimit p_time_limit) { + if (this.maintain_database) { + if (p_net_no != this.net_no) { + if (this.complete_expansion_rooms != null) { // invalidate the net dependent complete free space expansion rooms. Collection rooms_to_remove = new LinkedList(); - for (CompleteFreeSpaceExpansionRoom curr_room : complete_expansion_rooms) - { - if (curr_room.is_net_dependent()) - { + for (CompleteFreeSpaceExpansionRoom curr_room : complete_expansion_rooms) { + if (curr_room.is_net_dependent()) { rooms_to_remove.add(curr_room); } } - for (CompleteFreeSpaceExpansionRoom curr_room : rooms_to_remove) - { + for (CompleteFreeSpaceExpansionRoom curr_room : rooms_to_remove) { this.remove_complete_expansion_room(curr_room); } } // invalidate the neighbour rooms of the items of p_net_no Collection item_list = this.board.get_items(); - for (Item curr_item : item_list) - { - if (curr_item.contains_net(p_net_no)) - { + for (Item curr_item : item_list) { + if (curr_item.contains_net(p_net_no)) { this.board.additional_update_after_change(curr_item); } } @@ -109,58 +128,43 @@ public void init_connection(int p_net_no, Stoppable p_stoppable_thread, TimeLimi * Returns ALREADY_CONNECTED, ROUTED, NOT_ROUTED, or INSERT_ERROR. */ public AutorouteResult autoroute_connection(Set p_start_set, Set p_dest_set, - AutorouteControl p_ctrl, SortedSet p_ripped_item_list) - { + AutorouteControl p_ctrl, SortedSet p_ripped_item_list) { MazeSearchAlgo maze_search_algo; - try - { + try { maze_search_algo = MazeSearchAlgo.get_instance(p_start_set, p_dest_set, this, p_ctrl); - } catch (Exception e) - { + } catch (Exception e) { System.out.println("AutorouteEngine.autoroute_connection: Exception in MazeSearchAlgo.get_instance"); System.out.println(e); maze_search_algo = null; } MazeSearchAlgo.Result search_result = null; - if (maze_search_algo != null) - { - try - { + if (maze_search_algo != null) { + try { search_result = maze_search_algo.find_connection(); - } catch (Exception e) - { + } catch (Exception e) { System.out.println("AutorouteEngine.autoroute_connection: Exception in maze_search_algo.find_connection"); } } LocateFoundConnectionAlgo autoroute_result = null; - if (search_result != null) - { - try - { + if (search_result != null) { + try { autoroute_result = LocateFoundConnectionAlgo.get_instance(search_result, p_ctrl, this.autoroute_search_tree, - board.rules.get_trace_angle_restriction(), p_ripped_item_list, board.get_test_level()); - } catch (Exception e) - { + board.rules.get_trace_angle_restriction(), p_ripped_item_list, board.get_test_level()); + } catch (Exception e) { System.out.println("AutorouteEngine.autoroute_connection: Exception in LocateFoundConnectionAlgo.get_instance"); } } - if (!this.maintain_database) - { + if (!this.maintain_database) { this.clear(); - } - else - { + } else { this.reset_all_doors(); } - if (autoroute_result == null) - { + if (autoroute_result == null) { return AutorouteResult.NOT_ROUTED; } - if (autoroute_result.connection_items == null) - { - if (this.board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) - { + if (autoroute_result.connection_items == null) { + if (this.board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("AutorouteEngine.autoroute_connection: result_items != null expected"); } return AutorouteResult.ALREADY_CONNECTED; @@ -169,45 +173,36 @@ public AutorouteResult autoroute_connection(Set p_start_set, Set p_d SortedSet ripped_connections = new TreeSet(); Set changed_nets = new TreeSet(); Item.StopConnectionOption stop_connection_option; - if (p_ctrl.remove_unconnected_vias) - { + if (p_ctrl.remove_unconnected_vias) { stop_connection_option = Item.StopConnectionOption.NONE; - } - else - { + } else { stop_connection_option = Item.StopConnectionOption.FANOUT_VIA; } - for (Item curr_ripped_item : p_ripped_item_list) - { + for (Item curr_ripped_item : p_ripped_item_list) { ripped_connections.addAll(curr_ripped_item.get_connection_items(stop_connection_option)); - for (int i = 0; i < curr_ripped_item.net_count(); ++i) - { + for (int i = 0; i < curr_ripped_item.net_count(); ++i) { changed_nets.add(curr_ripped_item.get_net_no(i)); } } // let the observers know the changes in the board database. boolean observers_activated = !this.board.observers_active(); - if (observers_activated) - { + if (observers_activated) { this.board.start_notify_observers(); } board.remove_items(ripped_connections, false); - for (int curr_net_no : changed_nets) - { + for (int curr_net_no : changed_nets) { this.board.remove_trace_tails(curr_net_no, stop_connection_option); } InsertFoundConnectionAlgo insert_found_connection_algo = InsertFoundConnectionAlgo.get_instance(autoroute_result, board, p_ctrl); - if (observers_activated) - { + if (observers_activated) { this.board.end_notify_observers(); } - if (insert_found_connection_algo == null) - { + if (insert_found_connection_algo == null) { return AutorouteResult.INSERT_ERROR; } return AutorouteResult.ROUTED; @@ -216,25 +211,20 @@ public AutorouteResult autoroute_connection(Set p_start_set, Set p_d /** * Returns the net number of the current connection to route. */ - public int get_net_no() - { + public int get_net_no() { return this.net_no; } /** * Returns if the user has stopped the autorouter. */ - public boolean is_stop_requested() - { - if (this.time_limit != null) - { - if (this.time_limit.limit_exceeded()) - { + public boolean is_stop_requested() { + if (this.time_limit != null) { + if (this.time_limit.limit_exceeded()) { return true; } } - if (this.stoppable_thread == null) - { + if (this.stoppable_thread == null) { return false; } return this.stoppable_thread.is_stop_requested(); @@ -243,12 +233,9 @@ public boolean is_stop_requested() /** * Clears all temporary data */ - public void clear() - { - if (complete_expansion_rooms != null) - { - for (CompleteFreeSpaceExpansionRoom curr_room : complete_expansion_rooms) - { + public void clear() { + if (complete_expansion_rooms != null) { + for (CompleteFreeSpaceExpansionRoom curr_room : complete_expansion_rooms) { curr_room.remove_from_tree(this.autoroute_search_tree); } } @@ -261,26 +248,21 @@ public void clear() /** * Draws the shapes of the expansion rooms created so far. */ - public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) - { - if (complete_expansion_rooms == null) - { + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { + if (complete_expansion_rooms == null) { return; } - for (CompleteFreeSpaceExpansionRoom curr_room : complete_expansion_rooms) - { + for (CompleteFreeSpaceExpansionRoom curr_room : complete_expansion_rooms) { curr_room.draw(p_graphics, p_graphics_context, p_intensity); } Collection item_list = this.board.get_items(); - for (Item curr_item : item_list) - { + for (Item curr_item : item_list) { ItemAutorouteInfo autoroute_info = curr_item.get_autoroute_info(); - if (autoroute_info != null) - { + if (autoroute_info != null) { autoroute_info.draw(p_graphics, p_graphics_context, p_intensity); } } - // this.drill_page_array.draw(p_graphics, p_graphics_context, p_intensity); + // this.drill_page_array.draw(p_graphics, p_graphics_context, p_intensity); } /** @@ -290,11 +272,9 @@ public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.Gra * does not overlap with any obstacle, and it is as big as possible. * p_contained_points will remain contained in the shape, after it is completed. */ - public IncompleteFreeSpaceExpansionRoom add_incomplete_expansion_room(TileShape p_shape, int p_layer, TileShape p_contained_shape) - { + public IncompleteFreeSpaceExpansionRoom add_incomplete_expansion_room(TileShape p_shape, int p_layer, TileShape p_contained_shape) { IncompleteFreeSpaceExpansionRoom new_room = new IncompleteFreeSpaceExpansionRoom(p_shape, p_layer, p_contained_shape); - if (this.incomplete_expansion_rooms == null) - { + if (this.incomplete_expansion_rooms == null) { this.incomplete_expansion_rooms = new LinkedList(); } this.incomplete_expansion_rooms.add(new_room); @@ -304,14 +284,11 @@ public IncompleteFreeSpaceExpansionRoom add_incomplete_expansion_room(TileShape /** * Returns the first elemment in the list of incomplete expansion rooms or null, if the list is empty. */ - public IncompleteFreeSpaceExpansionRoom get_first_incomplete_expansion_room() - { - if (incomplete_expansion_rooms == null) - { + public IncompleteFreeSpaceExpansionRoom get_first_incomplete_expansion_room() { + if (incomplete_expansion_rooms == null) { return null; } - if (incomplete_expansion_rooms.isEmpty()) - { + if (incomplete_expansion_rooms.isEmpty()) { return null; } Iterator it = incomplete_expansion_rooms.iterator(); @@ -321,8 +298,7 @@ public IncompleteFreeSpaceExpansionRoom get_first_incomplete_expansion_room() /** * Removes an incomplete room from the database. */ - public void remove_incomplete_expansion_room(IncompleteFreeSpaceExpansionRoom p_room) - { + public void remove_incomplete_expansion_room(IncompleteFreeSpaceExpansionRoom p_room) { this.remove_all_doors(p_room); incomplete_expansion_rooms.remove(p_room); } @@ -331,22 +307,18 @@ public void remove_incomplete_expansion_room(IncompleteFreeSpaceExpansionRoom p_ * Removes a complete expansion room from the database and creates * new incomplete expansion rooms for the neighbours. */ - public void remove_complete_expansion_room(CompleteFreeSpaceExpansionRoom p_room) - { + public void remove_complete_expansion_room(CompleteFreeSpaceExpansionRoom p_room) { // create new incomplete expansion rooms for all neighbours TileShape room_shape = p_room.get_shape(); int room_layer = p_room.get_layer(); Collection room_doors = p_room.get_doors(); - for (ExpansionDoor curr_door : room_doors) - { + for (ExpansionDoor curr_door : room_doors) { ExpansionRoom curr_neighbour = curr_door.other_room(p_room); - if (curr_neighbour != null) - { + if (curr_neighbour != null) { curr_neighbour.remove_door(curr_door); TileShape neighbour_shape = curr_neighbour.get_shape(); TileShape intersection = room_shape.intersection(neighbour_shape); - if (intersection.dimension() == 1) - { + if (intersection.dimension() == 1) { // add a new incomplete room to curr_neighbour. int[] touching_sides = room_shape.touching_sides(neighbour_shape); Line[] line_arr = new Line[1]; @@ -362,12 +334,9 @@ public void remove_complete_expansion_room(CompleteFreeSpaceExpansionRoom p_room } this.remove_all_doors(p_room); p_room.remove_from_tree(this.autoroute_search_tree); - if (complete_expansion_rooms != null) - { + if (complete_expansion_rooms != null) { complete_expansion_rooms.remove(p_room); - } - else - { + } else { System.out.println("AutorouteEngine.remove_complete_expansion_room: this.complete_expansion_rooms is null"); } this.drill_page_array.invalidate(room_shape); @@ -378,20 +347,16 @@ public void remove_complete_expansion_room(CompleteFreeSpaceExpansionRoom p_room * Returns the resulting rooms after completing the shape. * p_room will no more exist after this function. */ - public Collection complete_expansion_room(IncompleteFreeSpaceExpansionRoom p_room) - { + public Collection complete_expansion_room(IncompleteFreeSpaceExpansionRoom p_room) { - try - { + try { Collection result = new LinkedList(); TileShape from_door_shape = null; SearchTreeObject ignore_object = null; Collection room_doors = p_room.get_doors(); - for (ExpansionDoor curr_door : room_doors) - { + for (ExpansionDoor curr_door : room_doors) { ExpansionRoom other_room = curr_door.other_room(p_room); - if (other_room instanceof CompleteFreeSpaceExpansionRoom && curr_door.dimension == 2) - { + if (other_room instanceof CompleteFreeSpaceExpansionRoom && curr_door.dimension == 2) { from_door_shape = curr_door.get_shape(); ignore_object = (CompleteFreeSpaceExpansionRoom) other_room; break; @@ -402,45 +367,36 @@ public Collection complete_expansion_room(Incomp this.remove_incomplete_expansion_room(p_room); Iterator it = completed_shapes.iterator(); boolean is_first_completed_room = true; - while (it.hasNext()) - { + while (it.hasNext()) { IncompleteFreeSpaceExpansionRoom curr_incomplete_room = it.next(); - if (curr_incomplete_room.get_shape().dimension() != 2) - { + if (curr_incomplete_room.get_shape().dimension() != 2) { continue; } - if (is_first_completed_room) - { + if (is_first_completed_room) { is_first_completed_room = false; CompleteFreeSpaceExpansionRoom completed_room = this.add_complete_room(curr_incomplete_room); - if (completed_room != null) - { + if (completed_room != null) { result.add(completed_room); } - } - else - { + } else { // the shape of the first completed room may have changed and may // intersect now with the other shapes. Therefore the completed shapes // have to be recalculated. Collection curr_completed_shapes = this.autoroute_search_tree.complete_shape(curr_incomplete_room, this.net_no, - ignore_object, from_door_shape); + ignore_object, from_door_shape); Iterator it2 = curr_completed_shapes.iterator(); - while (it2.hasNext()) - { + while (it2.hasNext()) { IncompleteFreeSpaceExpansionRoom tmp_room = it2.next(); CompleteFreeSpaceExpansionRoom completed_room = this.add_complete_room(tmp_room); - if (completed_room != null) - { + if (completed_room != null) { result.add(completed_room); } } } } return result; - } catch (Exception e) - { + } catch (Exception e) { System.out.print("AutorouteEngine.complete_expansion_room: "); System.out.println(e); return new LinkedList(); @@ -451,22 +407,17 @@ public Collection complete_expansion_room(Incomp /** * Calculates the doors and adds the completed room to the room database. */ - private CompleteFreeSpaceExpansionRoom add_complete_room(IncompleteFreeSpaceExpansionRoom p_room) - { + private CompleteFreeSpaceExpansionRoom add_complete_room(IncompleteFreeSpaceExpansionRoom p_room) { CompleteFreeSpaceExpansionRoom completed_room = (CompleteFreeSpaceExpansionRoom) calculate_doors(p_room); CompleteFreeSpaceExpansionRoom result; - if (completed_room != null && completed_room.get_shape().dimension() == 2) - { - if (complete_expansion_rooms == null) - { + if (completed_room != null && completed_room.get_shape().dimension() == 2) { + if (complete_expansion_rooms == null) { complete_expansion_rooms = new LinkedList(); } complete_expansion_rooms.add(completed_room); this.autoroute_search_tree.insert(completed_room); result = completed_room; - } - else - { + } else { result = null; } return result; @@ -477,53 +428,40 @@ private CompleteFreeSpaceExpansionRoom add_complete_room(IncompleteFreeSpaceExpa * the new created neighbour rooms. * The shape of the result room may be different to the shape of p_room */ - private CompleteExpansionRoom calculate_doors(ExpansionRoom p_room) - { + private CompleteExpansionRoom calculate_doors(ExpansionRoom p_room) { CompleteExpansionRoom result; - if (this.autoroute_search_tree instanceof ShapeSearchTree90Degree) - { + if (this.autoroute_search_tree instanceof ShapeSearchTree90Degree) { result = SortedOrthogonalRoomNeighbours.calculate(p_room, this); - } - else if (this.autoroute_search_tree instanceof ShapeSearchTree45Degree) - { + } else if (this.autoroute_search_tree instanceof ShapeSearchTree45Degree) { result = Sorted45DegreeRoomNeighbours.calculate(p_room, this); - } - else - { + } else { result = SortedRoomNeighbours.calculate(p_room, this); } return result; } - /** Completes the shapes of the neigbour rooms of p_room, so that the + /** + * Completes the shapes of the neigbour rooms of p_room, so that the * doors of p_room will not change later on. */ - public void complete_neigbour_rooms(CompleteExpansionRoom p_room) - { - if (p_room.get_doors() == null) - { + public void complete_neigbour_rooms(CompleteExpansionRoom p_room) { + if (p_room.get_doors() == null) { return; } Iterator it = p_room.get_doors().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { ExpansionDoor curr_door = it.next(); // cast to ExpansionRoom becaus ExpansionDoor.other_room works differently with // parameter type CompleteExpansionRoom. ExpansionRoom neighbour_room = curr_door.other_room((ExpansionRoom) p_room); - if (neighbour_room != null) - { - if (neighbour_room instanceof IncompleteFreeSpaceExpansionRoom) - { + if (neighbour_room != null) { + if (neighbour_room instanceof IncompleteFreeSpaceExpansionRoom) { this.complete_expansion_room((IncompleteFreeSpaceExpansionRoom) neighbour_room); // restart reading because the doors have changed it = p_room.get_doors().iterator(); - } - else if (neighbour_room instanceof ObstacleExpansionRoom) - { + } else if (neighbour_room instanceof ObstacleExpansionRoom) { ObstacleExpansionRoom obstacle_neighbour_room = (ObstacleExpansionRoom) neighbour_room; - if (!obstacle_neighbour_room.all_doors_calculated()) - { + if (!obstacle_neighbour_room.all_doors_calculated()) { this.calculate_doors(obstacle_neighbour_room); obstacle_neighbour_room.set_doors_calculated(true); } @@ -536,27 +474,22 @@ else if (neighbour_room instanceof ObstacleExpansionRoom) * Invalidates all drill pages intersecting with p_shape, so the they must be recalculated at the next * call of get_ddrills() */ - public void invalidate_drill_pages(TileShape p_shape) - { + public void invalidate_drill_pages(TileShape p_shape) { this.drill_page_array.invalidate(p_shape); } /** * Removes all doors from p_room */ - void remove_all_doors(ExpansionRoom p_room) - { + void remove_all_doors(ExpansionRoom p_room) { Iterator it = p_room.get_doors().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { ExpansionDoor curr_door = it.next(); ExpansionRoom other_room = curr_door.other_room(p_room); - if (other_room != null) - { + if (other_room != null) { other_room.remove_door(curr_door); - if (other_room instanceof IncompleteFreeSpaceExpansionRoom) - { + if (other_room instanceof IncompleteFreeSpaceExpansionRoom) { this.remove_incomplete_expansion_room((IncompleteFreeSpaceExpansionRoom) other_room); } } @@ -567,19 +500,14 @@ void remove_all_doors(ExpansionRoom p_room) /** * Returns all complete free space expansion rooms with a target door to an item in the set p_items. */ - Set get_rooms_with_target_items(Set p_items) - { + Set get_rooms_with_target_items(Set p_items) { Set result = new TreeSet(); - if (this.complete_expansion_rooms != null) - { - for (CompleteFreeSpaceExpansionRoom curr_room : this.complete_expansion_rooms) - { + if (this.complete_expansion_rooms != null) { + for (CompleteFreeSpaceExpansionRoom curr_room : this.complete_expansion_rooms) { Collection target_door_list = curr_room.get_target_doors(); - for (TargetItemExpansionDoor curr_target_door : target_door_list) - { + for (TargetItemExpansionDoor curr_target_door : target_door_list) { Item curr_target_item = curr_target_door.item; - if (p_items.contains(curr_target_item)) - { + if (p_items.contains(curr_target_item)) { result.add(curr_room); } } @@ -591,17 +519,13 @@ Set get_rooms_with_target_items(Set p_item /** * Checks, if the internal datastructure is valid. */ - public boolean validate() - { - if (complete_expansion_rooms == null) - { + public boolean validate() { + if (complete_expansion_rooms == null) { return true; } boolean result = true; - for (CompleteFreeSpaceExpansionRoom curr_room : complete_expansion_rooms) - { - if (!curr_room.validate(this)) - { + for (CompleteFreeSpaceExpansionRoom curr_room : complete_expansion_rooms) { + if (!curr_room.validate(this)) { result = false; } } @@ -611,21 +535,16 @@ public boolean validate() /** * Reset all doors for autorouting the next connnection, in case the autorouting database is retained. */ - private void reset_all_doors() - { - if (this.complete_expansion_rooms != null) - { - for (ExpansionRoom curr_room : this.complete_expansion_rooms) - { + private void reset_all_doors() { + if (this.complete_expansion_rooms != null) { + for (ExpansionRoom curr_room : this.complete_expansion_rooms) { curr_room.reset_doors(); } } Collection item_list = this.board.get_items(); - for (Item curr_item : item_list) - { + for (Item curr_item : item_list) { ItemAutorouteInfo curr_autoroute_info = curr_item.get_autoroute_info_pur(); - if (curr_autoroute_info != null) - { + if (curr_autoroute_info != null) { curr_autoroute_info.reset_doors(); curr_autoroute_info.set_precalculated_connection(null); } @@ -633,51 +552,15 @@ private void reset_all_doors() this.drill_page_array.reset(); } - protected int generate_room_id_no() - { + protected int generate_room_id_no() { ++expansion_room_instance_count; return expansion_room_instance_count; } - /** - * The current search tree used in autorouting. - * It depends on the trac clearance class used in the autoroute algorithm. - */ - public final ShapeSearchTree autoroute_search_tree; - /** If maintain_database, the autorouter database is maintained after a connection is - * completed for performance reasons. - */ - public final boolean maintain_database; - static final int TRACE_WIDTH_TOLERANCE = 2; - /** - * The net number used for routing in this autoroute algorithm. - */ - private int net_no; - /** - * The 2-dimensional array of rectangular pages of ExpansionDrills - */ - final DrillPageArray drill_page_array; - /** - * To be able to stop the expansion algorithm. - */ - Stoppable stoppable_thread; - /** - * To stop the expansion algorithm after a time limit is exceeded. - */ - private TimeLimit time_limit; - /** The PCB-board of this autoroute algorithm. */ - final RoutingBoard board; - /** The list of incomplete expansion rooms on the routing board */ - private List incomplete_expansion_rooms = null; - /** The list of complete expansion rooms on the routing board */ - private List complete_expansion_rooms = null; - /** The count of expansion rooms created so far */ - private int expansion_room_instance_count = 0; /** - * The pussible results of autorouting a connection + * The pussible results of autorouting a connection */ - public enum AutorouteResult - { + public enum AutorouteResult { ALREADY_CONNECTED, ROUTED, NOT_ROUTED, INSERT_ERROR } diff --git a/src/main/java/net/freerouting/autoroute/BatchAutorouter.java b/src/main/java/net/freerouting/autoroute/BatchAutorouter.java index 48d22db1..e86247da 100644 --- a/src/main/java/net/freerouting/autoroute/BatchAutorouter.java +++ b/src/main/java/net/freerouting/autoroute/BatchAutorouter.java @@ -15,87 +15,54 @@ */ package net.freerouting.autoroute; -import java.util.Iterator; -import java.util.Collection; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import net.freerouting.datastructures.TimeLimit; -import net.freerouting.datastructures.UndoableObjects; - -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.FloatLine; - import net.freerouting.board.Connectable; -import net.freerouting.board.Item; import net.freerouting.board.DrillItem; +import net.freerouting.board.Item; import net.freerouting.board.RoutingBoard; - +import net.freerouting.datastructures.TimeLimit; +import net.freerouting.datastructures.UndoableObjects; +import net.freerouting.geometry.planar.FloatLine; +import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.interactive.BoardHandling; import net.freerouting.interactive.InteractiveActionThread; +import java.util.*; + /** * Handles the sequencing of the batch autoroute passes. - * - * @author Alfons Wirtz + * + * @author Alfons Wirtz */ -public class BatchAutorouter -{ +public class BatchAutorouter { + private static final int TIME_LIMIT_TO_PREVENT_ENDLESS_LOOP = 1000; + private final InteractiveActionThread thread; + private final BoardHandling hdlg; + private final RoutingBoard routing_board; + private final boolean remove_unconnected_vias; + private final AutorouteControl.ExpansionCostFactor[] trace_cost_arr; + private final boolean retain_autoroute_database; + private final int start_ripup_costs; + private boolean is_interrupted = false; /** - * Autoroutes ripup passes until the board is completed or the autorouter is stopped by the user, - * or if p_max_pass_count is exceeded. Is currently used in the optimize via batch pass. - * Returns the number of oasses to complete the board or p_max_pass_count + 1, - * if the board is not completed. + * Used to draw the airline of the current routed incomplete. */ - public static int autoroute_passes_for_optimizing_item(InteractiveActionThread p_thread, - int p_max_pass_count, int p_ripup_costs, boolean p_with_prefered_directions) - { - BatchAutorouter router_instance = new BatchAutorouter(p_thread, true, p_with_prefered_directions, p_ripup_costs); - boolean still_unrouted_items = true; - int curr_pass_no = 1; - while (still_unrouted_items && !router_instance.is_interrupted && curr_pass_no <= p_max_pass_count) - { - if (p_thread.is_stop_requested()) - { - router_instance.is_interrupted = true; - } - still_unrouted_items = router_instance.autoroute_pass(curr_pass_no, false); - if (still_unrouted_items && !router_instance.is_interrupted) - { - p_thread.hdlg.settings.autoroute_settings.increment_pass_no(); - } - ++curr_pass_no; - } - router_instance.remove_tails(Item.StopConnectionOption.NONE); - if (!still_unrouted_items) - { - --curr_pass_no; - } - return curr_pass_no; - } - + private FloatLine air_line = null; /** * Creates a new batch autorouter. */ public BatchAutorouter(InteractiveActionThread p_thread, boolean p_remove_unconnected_vias, boolean p_with_preferred_directions, - int p_start_ripup_costs) - { + int p_start_ripup_costs) { this.thread = p_thread; this.hdlg = p_thread.hdlg; this.routing_board = this.hdlg.get_routing_board(); this.remove_unconnected_vias = p_remove_unconnected_vias; - if (p_with_preferred_directions) - { + if (p_with_preferred_directions) { this.trace_cost_arr = this.hdlg.settings.autoroute_settings.get_trace_cost_arr(); - } - else - { + } else { // remove prefered direction this.trace_cost_arr = new AutorouteControl.ExpansionCostFactor[this.routing_board.get_layer_count()]; - for (int i = 0; i < this.trace_cost_arr.length; ++i) - { + for (int i = 0; i < this.trace_cost_arr.length; ++i) { double curr_min_cost = this.hdlg.settings.autoroute_settings.get_preferred_direction_trace_costs(i); this.trace_cost_arr[i] = new AutorouteControl.ExpansionCostFactor(curr_min_cost, curr_min_cost); } @@ -106,31 +73,54 @@ public BatchAutorouter(InteractiveActionThread p_thread, boolean p_remove_unconn } /** - * Autoroutes ripup passes until the board is completed or the autorouter is stopped by the user. - * Returns true if the board is completed. + * Autoroutes ripup passes until the board is completed or the autorouter is stopped by the user, + * or if p_max_pass_count is exceeded. Is currently used in the optimize via batch pass. + * Returns the number of oasses to complete the board or p_max_pass_count + 1, + * if the board is not completed. + */ + public static int autoroute_passes_for_optimizing_item(InteractiveActionThread p_thread, + int p_max_pass_count, int p_ripup_costs, boolean p_with_prefered_directions) { + BatchAutorouter router_instance = new BatchAutorouter(p_thread, true, p_with_prefered_directions, p_ripup_costs); + boolean still_unrouted_items = true; + int curr_pass_no = 1; + while (still_unrouted_items && !router_instance.is_interrupted && curr_pass_no <= p_max_pass_count) { + if (p_thread.is_stop_requested()) { + router_instance.is_interrupted = true; + } + still_unrouted_items = router_instance.autoroute_pass(curr_pass_no, false); + if (still_unrouted_items && !router_instance.is_interrupted) { + p_thread.hdlg.settings.autoroute_settings.increment_pass_no(); + } + ++curr_pass_no; + } + router_instance.remove_tails(Item.StopConnectionOption.NONE); + if (!still_unrouted_items) { + --curr_pass_no; + } + return curr_pass_no; + } + + /** + * Autoroutes ripup passes until the board is completed or the autorouter is stopped by the user. + * Returns true if the board is completed. */ - public boolean autoroute_passes() - { + public boolean autoroute_passes() { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", hdlg.get_locale()); boolean still_unrouted_items = true; - while (still_unrouted_items && !this.is_interrupted) - { - if (thread.is_stop_requested()) - { + while (still_unrouted_items && !this.is_interrupted) { + if (thread.is_stop_requested()) { this.is_interrupted = true; } Integer curr_pass_no = hdlg.settings.autoroute_settings.get_pass_no(); String start_message = resources.getString("batch_autorouter") + " " + resources.getString("stop_message") + " " + resources.getString("pass") + " " + curr_pass_no.toString() + ": "; hdlg.screen_messages.set_status_message(start_message); still_unrouted_items = autoroute_pass(curr_pass_no, true); - if (still_unrouted_items && !is_interrupted) - { + if (still_unrouted_items && !is_interrupted) { hdlg.settings.autoroute_settings.increment_pass_no(); } } - if (!(this.remove_unconnected_vias || still_unrouted_items || this.is_interrupted)) - { + if (!(this.remove_unconnected_vias || still_unrouted_items || this.is_interrupted)) { // clean up the route if the board is completed and if fanout is used. remove_tails(Item.StopConnectionOption.NONE); } @@ -141,41 +131,30 @@ public boolean autoroute_passes() * Autoroutes one ripup pass of all items of the board. * Returns false, if the board is already completely routed. */ - private boolean autoroute_pass(int p_pass_no, boolean p_with_screen_message) - { - try - { + private boolean autoroute_pass(int p_pass_no, boolean p_with_screen_message) { + try { Collection autoroute_item_list = new java.util.LinkedList(); Set handeled_items = new TreeSet(); Iterator it = routing_board.item_list.start_read_object(); - for (;;) - { + for (; ; ) { UndoableObjects.Storable curr_ob = routing_board.item_list.read_object(it); - if (curr_ob == null) - { + if (curr_ob == null) { break; } - if (curr_ob instanceof Connectable && curr_ob instanceof Item) - { + if (curr_ob instanceof Connectable && curr_ob instanceof Item) { Item curr_item = (Item) curr_ob; - if (!curr_item.is_route()) - { - if (!handeled_items.contains(curr_item)) - { - for (int i = 0; i < curr_item.net_count(); ++i) - { + if (!curr_item.is_route()) { + if (!handeled_items.contains(curr_item)) { + for (int i = 0; i < curr_item.net_count(); ++i) { int curr_net_no = curr_item.get_net_no(i); Set connected_set = curr_item.get_connected_set(curr_net_no); - for (Item curr_connected_item : connected_set) - { - if (curr_connected_item.net_count() <= 1) - { + for (Item curr_connected_item : connected_set) { + if (curr_connected_item.net_count() <= 1) { handeled_items.add(curr_connected_item); } } int net_item_count = routing_board.connectable_item_count(curr_net_no); - if (connected_set.size() < net_item_count) - { + if (connected_set.size() < net_item_count) { autoroute_item_list.add(curr_item); } } @@ -183,8 +162,7 @@ private boolean autoroute_pass(int p_pass_no, boolean p_with_screen_message) } } } - if (autoroute_item_list.isEmpty()) - { + if (autoroute_item_list.isEmpty()) { this.air_line = null; return false; } @@ -192,90 +170,69 @@ private boolean autoroute_pass(int p_pass_no, boolean p_with_screen_message) int ripped_item_count = 0; int not_found = 0; int routed = 0; - if (p_with_screen_message) - { + if (p_with_screen_message) { hdlg.screen_messages.set_batch_autoroute_info(items_to_go_count, routed, ripped_item_count, not_found); } - for (Item curr_item : autoroute_item_list) - { - if (this.is_interrupted) - { + for (Item curr_item : autoroute_item_list) { + if (this.is_interrupted) { break; } - for (int i = 0; i < curr_item.net_count(); ++i) - { - if (this.thread.is_stop_requested()) - { + for (int i = 0; i < curr_item.net_count(); ++i) { + if (this.thread.is_stop_requested()) { this.is_interrupted = true; break; } routing_board.start_marking_changed_area(); SortedSet ripped_item_list = new TreeSet(); - if (autoroute_item(curr_item, curr_item.get_net_no(i), ripped_item_list, p_pass_no)) - { + if (autoroute_item(curr_item, curr_item.get_net_no(i), ripped_item_list, p_pass_no)) { ++routed; hdlg.repaint(); - } - else - { + } else { ++not_found; } --items_to_go_count; ripped_item_count += ripped_item_list.size(); - if (p_with_screen_message) - { + if (p_with_screen_message) { hdlg.screen_messages.set_batch_autoroute_info(items_to_go_count, routed, ripped_item_count, not_found); } } } - if (routing_board.get_test_level() != net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT) - { + if (routing_board.get_test_level() != net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT) { Item.StopConnectionOption stop_connection_option; - if (this.remove_unconnected_vias) - { + if (this.remove_unconnected_vias) { stop_connection_option = Item.StopConnectionOption.NONE; - } - else - { + } else { stop_connection_option = Item.StopConnectionOption.FANOUT_VIA; } remove_tails(stop_connection_option); } this.air_line = null; return true; - } catch (Exception e) - { + } catch (Exception e) { this.air_line = null; return false; } } - private void remove_tails(Item.StopConnectionOption p_stop_connection_option) - { + private void remove_tails(Item.StopConnectionOption p_stop_connection_option) { routing_board.start_marking_changed_area(); routing_board.remove_trace_tails(-1, p_stop_connection_option); routing_board.opt_changed_area(new int[0], null, this.hdlg.settings.get_trace_pull_tight_accuracy(), this.trace_cost_arr, this.thread, TIME_LIMIT_TO_PREVENT_ENDLESS_LOOP); } - private boolean autoroute_item(Item p_item, int p_route_net_no, SortedSet p_ripped_item_list, int p_ripup_pass_no) - { - try - { + private boolean autoroute_item(Item p_item, int p_route_net_no, SortedSet p_ripped_item_list, int p_ripup_pass_no) { + try { boolean contains_plane = false; net.freerouting.rules.Net route_net = routing_board.rules.nets.get(p_route_net_no); - if (route_net != null) - { + if (route_net != null) { contains_plane = route_net.contains_plane(); } int curr_via_costs; - if (contains_plane) - { + if (contains_plane) { curr_via_costs = hdlg.settings.autoroute_settings.get_plane_via_costs(); - } - else - { + } else { curr_via_costs = hdlg.settings.autoroute_settings.get_via_costs(); } AutorouteControl autoroute_control = new AutorouteControl(this.routing_board, p_route_net_no, hdlg.settings, curr_via_costs, this.trace_cost_arr); @@ -284,32 +241,25 @@ private boolean autoroute_item(Item p_item, int p_route_net_no, SortedSet autoroute_control.remove_unconnected_vias = this.remove_unconnected_vias; Set unconnected_set = p_item.get_unconnected_set(p_route_net_no); - if (unconnected_set.size() == 0) - { + if (unconnected_set.size() == 0) { return true; // p_item is already routed. } Set connected_set = p_item.get_connected_set(p_route_net_no); Set route_start_set; Set route_dest_set; - if (contains_plane) - { - for (Item curr_item : connected_set) - { - if (curr_item instanceof net.freerouting.board.ConductionArea) - { + if (contains_plane) { + for (Item curr_item : connected_set) { + if (curr_item instanceof net.freerouting.board.ConductionArea) { return true; // already connected to plane } } } - if (contains_plane) - { + if (contains_plane) { route_start_set = connected_set; route_dest_set = unconnected_set; - } - else - { + } else { route_start_set = unconnected_set; route_dest_set = connected_set; } @@ -322,58 +272,47 @@ private boolean autoroute_item(Item p_item, int p_route_net_no, SortedSet autoroute_control.trace_clearance_class_no, this.thread, time_limit, this.retain_autoroute_database); AutorouteEngine.AutorouteResult autoroute_result = autoroute_engine.autoroute_connection(route_start_set, route_dest_set, autoroute_control, p_ripped_item_list); - if (autoroute_result == AutorouteEngine.AutorouteResult.ROUTED) - { + if (autoroute_result == AutorouteEngine.AutorouteResult.ROUTED) { routing_board.opt_changed_area(new int[0], null, this.hdlg.settings.get_trace_pull_tight_accuracy(), autoroute_control.trace_costs, this.thread, TIME_LIMIT_TO_PREVENT_ENDLESS_LOOP); } // tests.Validate.check("Autoroute ", hdlg.get_routing_board()); boolean result = autoroute_result == AutorouteEngine.AutorouteResult.ROUTED || autoroute_result == AutorouteEngine.AutorouteResult.ALREADY_CONNECTED; return result; - } catch (Exception e) - { + } catch (Exception e) { return false; } } /** - * Returns the airline of the current autorouted connnection or null, - * if no such airline exists + * Returns the airline of the current autorouted connnection or null, + * if no such airline exists */ - public FloatLine get_air_line() - { - if (this.air_line == null) - { + public FloatLine get_air_line() { + if (this.air_line == null) { return null; } - if (this.air_line.a == null || this.air_line.b == null) - { + if (this.air_line.a == null || this.air_line.b == null) { return null; } return this.air_line; } - private void calc_airline(Collection p_from_items, Collection p_to_items) - { + private void calc_airline(Collection p_from_items, Collection p_to_items) { FloatPoint from_corner = null; FloatPoint to_corner = null; double min_distance = Double.MAX_VALUE; - for (Item curr_from_item : p_from_items) - { - if (!(curr_from_item instanceof DrillItem)) - { + for (Item curr_from_item : p_from_items) { + if (!(curr_from_item instanceof DrillItem)) { continue; } FloatPoint curr_from_corner = ((DrillItem) curr_from_item).get_center().to_float(); - for (Item curr_to_item : p_to_items) - { - if (!(curr_to_item instanceof DrillItem)) - { + for (Item curr_to_item : p_to_items) { + if (!(curr_to_item instanceof DrillItem)) { continue; } FloatPoint curr_to_corner = ((DrillItem) curr_to_item).get_center().to_float(); double curr_distance = curr_from_corner.distance_square(curr_to_corner); - if (curr_distance < min_distance) - { + if (curr_distance < min_distance) { min_distance = curr_distance; from_corner = curr_from_corner; to_corner = curr_to_corner; @@ -382,15 +321,4 @@ private void calc_airline(Collection p_from_items, Collection p_to_i } this.air_line = new FloatLine(from_corner, to_corner); } - private final InteractiveActionThread thread; - private final BoardHandling hdlg; - private final RoutingBoard routing_board; - private boolean is_interrupted = false; - private final boolean remove_unconnected_vias; - private final AutorouteControl.ExpansionCostFactor[] trace_cost_arr; - private final boolean retain_autoroute_database; - private final int start_ripup_costs; - /** Used to draw the airline of the current routed incomplete. */ - private FloatLine air_line = null; - private static final int TIME_LIMIT_TO_PREVENT_ENDLESS_LOOP = 1000; } diff --git a/src/main/java/net/freerouting/autoroute/BatchFanout.java b/src/main/java/net/freerouting/autoroute/BatchFanout.java index 77844995..f2a99b24 100644 --- a/src/main/java/net/freerouting/autoroute/BatchFanout.java +++ b/src/main/java/net/freerouting/autoroute/BatchFanout.java @@ -15,132 +15,114 @@ */ package net.freerouting.autoroute; -import java.util.Collection; -import java.util.SortedSet; - +import net.freerouting.board.RoutingBoard; import net.freerouting.datastructures.TimeLimit; - import net.freerouting.geometry.planar.FloatPoint; - -import net.freerouting.board.RoutingBoard; - import net.freerouting.interactive.InteractiveActionThread; +import java.util.Collection; +import java.util.SortedSet; + /** * Handles the sequencing of the fanout inside the batch autorouter. - * - * @author Alfons Wirtz + * + * @author Alfons Wirtz */ -public class BatchFanout -{ +public class BatchFanout { - public static void fanout_board(InteractiveActionThread p_thread) - { - BatchFanout fanout_instance = new BatchFanout(p_thread); - final int MAX_PASS_COUNT = 20; - for (int i = 0; i < MAX_PASS_COUNT; ++i) - { - int routed_count = fanout_instance.fanout_pass(i); - if (routed_count == 0) - { - break; - } - } - } + private final InteractiveActionThread thread; + private final RoutingBoard routing_board; + private final SortedSet sorted_components; - private BatchFanout(InteractiveActionThread p_thread) - { + private BatchFanout(InteractiveActionThread p_thread) { this.thread = p_thread; this.routing_board = p_thread.hdlg.get_routing_board(); Collection board_smd_pin_list = routing_board.get_smd_pins(); this.sorted_components = new java.util.TreeSet(); - for (int i = 1; i <= routing_board.components.count(); ++i) - { + for (int i = 1; i <= routing_board.components.count(); ++i) { net.freerouting.board.Component curr_board_component = routing_board.components.get(i); Component curr_component = new Component(curr_board_component, board_smd_pin_list); - if (curr_component.smd_pin_count > 0) - { + if (curr_component.smd_pin_count > 0) { sorted_components.add(curr_component); } } } + public static void fanout_board(InteractiveActionThread p_thread) { + BatchFanout fanout_instance = new BatchFanout(p_thread); + final int MAX_PASS_COUNT = 20; + for (int i = 0; i < MAX_PASS_COUNT; ++i) { + int routed_count = fanout_instance.fanout_pass(i); + if (routed_count == 0) { + break; + } + } + } + /** - * Routes a fanout pass and returns the number of new fanouted SMD-pins - * in this pass. + * Routes a fanout pass and returns the number of new fanouted SMD-pins + * in this pass. */ - private int fanout_pass(int p_pass_no) - { + private int fanout_pass(int p_pass_no) { int components_to_go = this.sorted_components.size(); int routed_count = 0; int not_routed_count = 0; int insert_error_count = 0; int ripup_costs = this.thread.hdlg.settings.autoroute_settings.get_start_ripup_costs() * (p_pass_no + 1); - for (Component curr_component : this.sorted_components) - { + for (Component curr_component : this.sorted_components) { this.thread.hdlg.screen_messages.set_batch_fanout_info(p_pass_no + 1, components_to_go); - for (Component.Pin curr_pin : curr_component.smd_pins) - { + for (Component.Pin curr_pin : curr_component.smd_pins) { double max_milliseconds = 10000 * (p_pass_no + 1); TimeLimit time_limit = new TimeLimit((int) max_milliseconds); this.routing_board.start_marking_changed_area(); AutorouteEngine.AutorouteResult curr_result = this.routing_board.fanout(curr_pin.board_pin, this.thread.hdlg.settings, ripup_costs, this.thread, time_limit); - if (curr_result == AutorouteEngine.AutorouteResult.ROUTED) - { + if (curr_result == AutorouteEngine.AutorouteResult.ROUTED) { ++routed_count; - } - else if (curr_result == AutorouteEngine.AutorouteResult.NOT_ROUTED) - { + } else if (curr_result == AutorouteEngine.AutorouteResult.NOT_ROUTED) { ++not_routed_count; - } - else if (curr_result == AutorouteEngine.AutorouteResult.INSERT_ERROR) - { + } else if (curr_result == AutorouteEngine.AutorouteResult.INSERT_ERROR) { ++insert_error_count; } - if (curr_result != AutorouteEngine.AutorouteResult.NOT_ROUTED) - { + if (curr_result != AutorouteEngine.AutorouteResult.NOT_ROUTED) { this.thread.hdlg.repaint(); } - if (this.thread.is_stop_requested()) - { + if (this.thread.is_stop_requested()) { return routed_count; } } --components_to_go; } - if (this.routing_board.get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) - { - System.out.println("fanout pass: " + (p_pass_no + 1) + ", routed: " + routed_count + if (this.routing_board.get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { + System.out.println("fanout pass: " + (p_pass_no + 1) + ", routed: " + routed_count + ", not routed: " + not_routed_count + ", errors: " + insert_error_count); } return routed_count; } - - private final InteractiveActionThread thread; - private final RoutingBoard routing_board; - private static class Component implements Comparable - { + private static class Component implements Comparable { - Component(net.freerouting.board.Component p_board_component, Collection p_board_smd_pin_list) - { + final net.freerouting.board.Component board_component; + final int smd_pin_count; + final SortedSet smd_pins; + /** + * The center of gravity of all SMD pins of this component. + */ + final FloatPoint gravity_center_of_smd_pins; + Component(net.freerouting.board.Component p_board_component, Collection p_board_smd_pin_list) { this.board_component = p_board_component; // calcoulate the center of gravity of all SMD pins of this component. Collection curr_pin_list = new java.util.LinkedList(); int cmp_no = p_board_component.no; - for (net.freerouting.board.Pin curr_board_pin : p_board_smd_pin_list) - { - if (curr_board_pin.get_component_no() == cmp_no) - { + for (net.freerouting.board.Pin curr_board_pin : p_board_smd_pin_list) { + if (curr_board_pin.get_component_no() == cmp_no) { curr_pin_list.add(curr_board_pin); } } double x = 0; double y = 0; - for (net.freerouting.board.Pin curr_pin : curr_pin_list) - { + for (net.freerouting.board.Pin curr_pin : curr_pin_list) { FloatPoint curr_point = curr_pin.get_center().to_float(); x += curr_point.x; y += curr_point.y; @@ -153,71 +135,51 @@ private static class Component implements Comparable // calculate the sorted SMD pins of this component this.smd_pins = new java.util.TreeSet(); - for (net.freerouting.board.Pin curr_board_pin : curr_pin_list) - { + for (net.freerouting.board.Pin curr_board_pin : curr_pin_list) { this.smd_pins.add(new Pin(curr_board_pin)); } } /** - * Sort the components, so that components with maor pins come first + * Sort the components, so that components with maor pins come first */ - public int compareTo(Component p_other) - { + public int compareTo(Component p_other) { int compare_value = this.smd_pin_count - p_other.smd_pin_count; int result; - if (compare_value > 0) - { + if (compare_value > 0) { result = -1; - } - else if (compare_value < 0) - { + } else if (compare_value < 0) { result = 1; - } - else - { + } else { result = this.board_component.no - p_other.board_component.no; } return result; } - final net.freerouting.board.Component board_component; - final int smd_pin_count; - final SortedSet smd_pins; - /** The center of gravity of all SMD pins of this component. */ - final FloatPoint gravity_center_of_smd_pins; - class Pin implements Comparable - { + class Pin implements Comparable { - Pin(net.freerouting.board.Pin p_board_pin) - { + final net.freerouting.board.Pin board_pin; + final double distance_to_component_center; + + Pin(net.freerouting.board.Pin p_board_pin) { this.board_pin = p_board_pin; FloatPoint pin_location = p_board_pin.get_center().to_float(); this.distance_to_component_center = pin_location.distance(gravity_center_of_smd_pins); } - public int compareTo(Pin p_other) - { + public int compareTo(Pin p_other) { int result; double delta_dist = this.distance_to_component_center - p_other.distance_to_component_center; - if (delta_dist > 0) - { + if (delta_dist > 0) { result = 1; - } - else if (delta_dist < 0) - { + } else if (delta_dist < 0) { result = -1; - } - else - { + } else { result = this.board_pin.pin_no - p_other.board_pin.pin_no; } return result; } - final net.freerouting.board.Pin board_pin; - final double distance_to_component_center; } } - private final SortedSet sorted_components; } diff --git a/src/main/java/net/freerouting/autoroute/BatchOptRoute.java b/src/main/java/net/freerouting/autoroute/BatchOptRoute.java index 2b7f101e..4daabc21 100644 --- a/src/main/java/net/freerouting/autoroute/BatchOptRoute.java +++ b/src/main/java/net/freerouting/autoroute/BatchOptRoute.java @@ -15,56 +15,89 @@ */ package net.freerouting.autoroute; -import java.util.Iterator; -import java.util.Collection; -import java.util.Set; - +import net.freerouting.board.*; import net.freerouting.datastructures.UndoableObjects; - import net.freerouting.geometry.planar.FloatPoint; - -import net.freerouting.board.Item; -import net.freerouting.board.Via; -import net.freerouting.board.Trace; -import net.freerouting.board.RoutingBoard; -import net.freerouting.board.FixedState; -import net.freerouting.board.TestLevel; - import net.freerouting.interactive.InteractiveActionThread; +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; + /** * To optimize the vias and traces after the batch autorouter has completed the board. - * - * @author Alfons Wirtz + * + * @author Alfons Wirtz */ -public class BatchOptRoute -{ +public class BatchOptRoute { + + private static int MAX_AUTOROUTE_PASSES = 6; + private static int ADDITIONAL_RIPUP_COST_FACTOR_AT_START = 10; + private final InteractiveActionThread thread; + private final RoutingBoard routing_board; + private ReadSortedRouteItems sorted_route_items; + private boolean use_increased_ripup_costs; // in the first passes the ripup costs are icreased for better performance. + private double min_cumulative_trace_length_before = 0; /** - * To optimize the route on the board after the autoroute task is finished. + * To optimize the route on the board after the autoroute task is finished. */ - public BatchOptRoute(InteractiveActionThread p_thread) - { + public BatchOptRoute(InteractiveActionThread p_thread) { this.thread = p_thread; this.routing_board = p_thread.hdlg.get_routing_board(); this.sorted_route_items = null; } + static boolean contains_only_unfixed_traces(Collection p_item_list) { + for (Item curr_item : p_item_list) { + if (curr_item.is_user_fixed() || !(curr_item instanceof Trace)) { + return false; + } + } + return true; + } + + /** + * Calculates the cumulative trace lengths multiplied by the trace radius of all traces + * on the board, which are not shove_fixed. + */ + private static double calc_weighted_trace_length(RoutingBoard p_board) { + double result = 0; + int default_clearance_class = net.freerouting.rules.BoardRules.default_clearance_class(); + Iterator it = p_board.item_list.start_read_object(); + for (; ; ) { + UndoableObjects.Storable curr_item = p_board.item_list.read_object(it); + if (curr_item == null) { + break; + } + if (curr_item instanceof Trace) { + Trace curr_trace = (Trace) curr_item; + FixedState fixed_state = curr_trace.get_fixed_state(); + if (fixed_state == FixedState.UNFIXED || fixed_state == FixedState.SHOVE_FIXED) { + double weighted_trace_length = curr_trace.get_length() * (curr_trace.get_half_width() + p_board.clearance_value(curr_trace.clearance_class_no(), default_clearance_class, curr_trace.get_layer())); + if (fixed_state == FixedState.SHOVE_FIXED) { + // to produce less violations with pin exit directions. + weighted_trace_length /= 2; + } + result += weighted_trace_length; + } + } + } + return result; + } + /** * Optimize the route on the board. */ - public void optimize_board() - { - if (routing_board.get_test_level() != TestLevel.RELEASE_VERSION) - { + public void optimize_board() { + if (routing_board.get_test_level() != TestLevel.RELEASE_VERSION) { System.out.println("Before optimize: Via count: " + routing_board.get_vias().size() + ", trace length: " + Math.round(routing_board.cumulative_trace_length())); } boolean route_improved = true; int curr_pass_no = 0; use_increased_ripup_costs = true; - while (route_improved) - { + while (route_improved) { ++curr_pass_no; boolean with_prefered_directions = (curr_pass_no % 2 != 0); // to create more variations route_improved = opt_route_pass(curr_pass_no, with_prefered_directions); @@ -75,33 +108,27 @@ public void optimize_board() * Pass to reduce the number of vias an to shorten the trace lengthon a completely routed board. * Returns true, if the route was improved. */ - private boolean opt_route_pass(int p_pass_no, boolean p_with_prefered_directions) - { + private boolean opt_route_pass(int p_pass_no, boolean p_with_prefered_directions) { boolean route_improved = false; int via_count_before = this.routing_board.get_vias().size(); double trace_length_before = this.thread.hdlg.coordinate_transform.board_to_user(this.routing_board.cumulative_trace_length()); this.thread.hdlg.screen_messages.set_post_route_info(via_count_before, trace_length_before); this.sorted_route_items = new ReadSortedRouteItems(); this.min_cumulative_trace_length_before = calc_weighted_trace_length(routing_board); - for (;;) - { - if (this.thread.is_stop_requested()) - { + for (; ; ) { + if (this.thread.is_stop_requested()) { return route_improved; } Item curr_item = sorted_route_items.next(); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (opt_route_item(curr_item, p_pass_no, p_with_prefered_directions)) - { + if (opt_route_item(curr_item, p_pass_no, p_with_prefered_directions)) { route_improved = true; } } this.sorted_route_items = null; - if (this.use_increased_ripup_costs && !route_improved) - { + if (this.use_increased_ripup_costs && !route_improved) { this.use_increased_ripup_costs = false; route_improved = true; // to keep the optimizer going with lower ripup costs } @@ -111,8 +138,7 @@ private boolean opt_route_pass(int p_pass_no, boolean p_with_prefered_directions /** * Trie to improve the route by retouting the connections containing p_item. */ - private boolean opt_route_item(Item p_item, int p_pass_no, boolean p_with_prefered_directions) - { + private boolean opt_route_item(Item p_item, int p_pass_no, boolean p_with_prefered_directions) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", this.thread.hdlg.get_locale()); String start_message = resources.getString("batch_optimizer") + " " + resources.getString("stop_message") + " " + resources.getString("pass") + " " + (new Integer(p_pass_no)).toString() + ": "; @@ -122,46 +148,37 @@ private boolean opt_route_item(Item p_item, int p_pass_no, boolean p_with_prefer int via_count_before = this.routing_board.get_vias().size(); Set ripped_items = new java.util.TreeSet(); ripped_items.add(p_item); - if (p_item instanceof Trace) - { - // add also the fork items, especially because not all fork items may be + if (p_item instanceof Trace) { + // add also the fork items, especially because not all fork items may be // returned by ReadSortedRouteItems because of matching end points. Trace curr_trace = (Trace) p_item; Set curr_contact_list = curr_trace.get_start_contacts(); - for (int i = 0; i < 2; ++i) - { - if (contains_only_unfixed_traces(curr_contact_list)) - { + for (int i = 0; i < 2; ++i) { + if (contains_only_unfixed_traces(curr_contact_list)) { ripped_items.addAll(curr_contact_list); } curr_contact_list = curr_trace.get_end_contacts(); } } Set ripped_connections = new java.util.TreeSet(); - for (Item curr_item : ripped_items) - { + for (Item curr_item : ripped_items) { ripped_connections.addAll(curr_item.get_connection_items(Item.StopConnectionOption.NONE)); } - for (Item curr_item : ripped_connections) - { - if (curr_item.is_user_fixed()) - { + for (Item curr_item : ripped_connections) { + if (curr_item.is_user_fixed()) { return false; } } routing_board.generate_snapshot(); this.routing_board.remove_items(ripped_connections, false); - for (int i = 0; i < p_item.net_count(); ++i) - { + for (int i = 0; i < p_item.net_count(); ++i) { this.routing_board.combine_traces(p_item.get_net_no(i)); } int ripup_costs = this.thread.hdlg.settings.autoroute_settings.get_start_ripup_costs(); - if (this.use_increased_ripup_costs) - { + if (this.use_increased_ripup_costs) { ripup_costs *= ADDITIONAL_RIPUP_COST_FACTOR_AT_START; } - if (p_item instanceof Trace) - { + if (p_item instanceof Trace) { // taking less ripup costs seems to produce better results ripup_costs = (int) Math.round(0.6 * (double) ripup_costs); } @@ -173,18 +190,14 @@ private boolean opt_route_item(Item p_item, int p_pass_no, boolean p_with_prefer double trace_length_after = calc_weighted_trace_length(routing_board); boolean route_improved = !this.thread.is_stop_requested() && (incomplete_count_after < incomplete_count_before || incomplete_count_after == incomplete_count_before && - (via_count_after < via_count_before || - via_count_after == via_count_before && - this.min_cumulative_trace_length_before > trace_length_after)); - if (route_improved) - { + (via_count_after < via_count_before || + via_count_after == via_count_before && + this.min_cumulative_trace_length_before > trace_length_after)); + if (route_improved) { if (incomplete_count_after < incomplete_count_before || - incomplete_count_after == incomplete_count_before && via_count_after < via_count_before) - { + incomplete_count_after == incomplete_count_before && via_count_after < via_count_before) { this.min_cumulative_trace_length_before = trace_length_after; - } - else - { + } else { // Only cumulative trace length shortened. // Catch unexpected increase of cumulative trace length somewhere for examole by removing acid trapsw. this.min_cumulative_trace_length_before = Math.min(this.min_cumulative_trace_length_before, trace_length_after); @@ -192,120 +205,56 @@ private boolean opt_route_item(Item p_item, int p_pass_no, boolean p_with_prefer routing_board.pop_snapshot(); double new_trace_length = this.thread.hdlg.coordinate_transform.board_to_user(this.routing_board.cumulative_trace_length()); this.thread.hdlg.screen_messages.set_post_route_info(via_count_after, new_trace_length); - } - else - { + } else { routing_board.undo(null); } return route_improved; } - static boolean contains_only_unfixed_traces(Collection p_item_list) - { - for (Item curr_item : p_item_list) - { - if (curr_item.is_user_fixed() || !(curr_item instanceof Trace)) - { - return false; - } - } - return true; - } - - /** - * Calculates the cumulative trace lengths multiplied by the trace radius of all traces - * on the board, which are not shove_fixed. - */ - private static double calc_weighted_trace_length(RoutingBoard p_board) - { - double result = 0; - int default_clearance_class = net.freerouting.rules.BoardRules.default_clearance_class(); - Iterator it = p_board.item_list.start_read_object(); - for (;;) - { - UndoableObjects.Storable curr_item = p_board.item_list.read_object(it); - if (curr_item == null) - { - break; - } - if (curr_item instanceof Trace) - { - Trace curr_trace = (Trace) curr_item; - FixedState fixed_state = curr_trace.get_fixed_state(); - if (fixed_state == FixedState.UNFIXED || fixed_state == FixedState.SHOVE_FIXED) - { - double weighted_trace_length = curr_trace.get_length() * (curr_trace.get_half_width() + p_board.clearance_value(curr_trace.clearance_class_no(), default_clearance_class, curr_trace.get_layer())); - if (fixed_state == FixedState.SHOVE_FIXED) - { - // to produce less violations with pin exit directions. - weighted_trace_length /= 2; - } - result += weighted_trace_length; - } - } - } - return result; - } - /** - * Returns the current position of the item, which will be rerouted or null, if the optimizer is not active. + * Returns the current position of the item, which will be rerouted or null, if the optimizer is not active. */ - public FloatPoint get_current_position() - { - if (sorted_route_items == null) - { + public FloatPoint get_current_position() { + if (sorted_route_items == null) { return null; } return sorted_route_items.get_current_position(); } - private final InteractiveActionThread thread; - private final RoutingBoard routing_board; - private ReadSortedRouteItems sorted_route_items; - private boolean use_increased_ripup_costs; // in the first passes the ripup costs are icreased for better performance. - private double min_cumulative_trace_length_before = 0; - private static int MAX_AUTOROUTE_PASSES = 6; - private static int ADDITIONAL_RIPUP_COST_FACTOR_AT_START = 10; /** - * Reads the vias and traces on the board in ascending x order. - * Because the vias and traces on the board change while optimizing the item list - * of the board is read from scratch each time the next route item is returned. + * Reads the vias and traces on the board in ascending x order. + * Because the vias and traces on the board change while optimizing the item list + * of the board is read from scratch each time the next route item is returned. */ - private class ReadSortedRouteItems - { + private class ReadSortedRouteItems { - ReadSortedRouteItems() - { + private FloatPoint min_item_coor; + private int min_item_layer; + + ReadSortedRouteItems() { min_item_coor = new FloatPoint(Integer.MIN_VALUE, Integer.MIN_VALUE); min_item_layer = -1; } - Item next() - { + Item next() { Item result = null; FloatPoint curr_min_coor = new FloatPoint(Integer.MAX_VALUE, Integer.MAX_VALUE); int curr_min_layer = Integer.MAX_VALUE; Iterator it = routing_board.item_list.start_read_object(); - for (;;) - { + for (; ; ) { UndoableObjects.Storable curr_item = routing_board.item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof Via) - { + if (curr_item instanceof Via) { Via curr_via = (Via) curr_item; - if (!curr_via.is_user_fixed()) - { + if (!curr_via.is_user_fixed()) { FloatPoint curr_via_center = curr_via.get_center().to_float(); int curr_via_min_layer = curr_via.first_layer(); if (curr_via_center.x > min_item_coor.x || - curr_via_center.x == min_item_coor.x && (curr_via_center.y > min_item_coor.y || curr_via_center.y == min_item_coor.y && curr_via_min_layer > min_item_layer)) - { + curr_via_center.x == min_item_coor.x && (curr_via_center.y > min_item_coor.y || curr_via_center.y == min_item_coor.y && curr_via_min_layer > min_item_layer)) { if (curr_via_center.x < curr_min_coor.x || curr_via_center.x == curr_min_coor.x && (curr_via_center.y < curr_min_coor.y || - curr_via_center.y == curr_min_coor.y && curr_via_min_layer < curr_min_layer)) - { + curr_via_center.y == curr_min_coor.y && curr_via_min_layer < curr_min_layer)) { curr_min_coor = curr_via_center; curr_min_layer = curr_via_min_layer; result = curr_via; @@ -316,49 +265,37 @@ Item next() } // Read traces last to prefer vias to traces at the same location it = routing_board.item_list.start_read_object(); - for (;;) - { + for (; ; ) { UndoableObjects.Storable curr_item = routing_board.item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof Trace) - { + if (curr_item instanceof Trace) { Trace curr_trace = (Trace) curr_item; - if (!curr_trace.is_shove_fixed()) - { + if (!curr_trace.is_shove_fixed()) { FloatPoint first_corner = curr_trace.first_corner().to_float(); FloatPoint last_corner = curr_trace.last_corner().to_float(); FloatPoint compare_corner; if (first_corner.x < last_corner.x || - first_corner.x == last_corner.x && first_corner.y < last_corner.y) - { + first_corner.x == last_corner.x && first_corner.y < last_corner.y) { compare_corner = last_corner; - } - else - { + } else { compare_corner = first_corner; } int curr_trace_layer = curr_trace.get_layer(); if (compare_corner.x > min_item_coor.x || - compare_corner.x == min_item_coor.x && (compare_corner.y > min_item_coor.y || compare_corner.y == min_item_coor.y && curr_trace_layer > min_item_layer)) - { + compare_corner.x == min_item_coor.x && (compare_corner.y > min_item_coor.y || compare_corner.y == min_item_coor.y && curr_trace_layer > min_item_layer)) { if (compare_corner.x < curr_min_coor.x || compare_corner.x == curr_min_coor.x && - (compare_corner.y < curr_min_coor.y || compare_corner.y == curr_min_coor.y && curr_trace_layer < curr_min_layer)) - { + (compare_corner.y < curr_min_coor.y || compare_corner.y == curr_min_coor.y && curr_trace_layer < curr_min_layer)) { boolean is_connected_to_via = false; Set trace_contacts = curr_trace.get_normal_contacts(); - for (Item curr_contact : trace_contacts) - { - if (curr_contact instanceof Via && !curr_contact.is_user_fixed()) - { + for (Item curr_contact : trace_contacts) { + if (curr_contact instanceof Via && !curr_contact.is_user_fixed()) { is_connected_to_via = true; break; } } - if (!is_connected_to_via) - { + if (!is_connected_to_via) { curr_min_coor = compare_corner; curr_min_layer = curr_trace_layer; result = curr_trace; @@ -374,11 +311,8 @@ Item next() } - FloatPoint get_current_position() - { + FloatPoint get_current_position() { return min_item_coor; } - private FloatPoint min_item_coor; - private int min_item_layer; } } diff --git a/src/main/java/net/freerouting/autoroute/CompleteExpansionRoom.java b/src/main/java/net/freerouting/autoroute/CompleteExpansionRoom.java index 06ac7b70..8c1e10af 100644 --- a/src/main/java/net/freerouting/autoroute/CompleteExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/CompleteExpansionRoom.java @@ -24,22 +24,20 @@ import java.util.Collection; /** - * * @author alfons */ -public interface CompleteExpansionRoom extends ExpansionRoom -{ - +public interface CompleteExpansionRoom extends ExpansionRoom { + /** * Returns the list of doors to target items of this room */ Collection get_target_doors(); - + /** * Returns the object of tthis complete_expansion_rooom. */ net.freerouting.board.SearchTreeObject get_object(); - + /** * Draws the shape of this room for test purposes */ diff --git a/src/main/java/net/freerouting/autoroute/CompleteFreeSpaceExpansionRoom.java b/src/main/java/net/freerouting/autoroute/CompleteFreeSpaceExpansionRoom.java index 1ecf115b..0b51b601 100644 --- a/src/main/java/net/freerouting/autoroute/CompleteFreeSpaceExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/CompleteFreeSpaceExpansionRoom.java @@ -20,248 +20,210 @@ package net.freerouting.autoroute; +import net.freerouting.board.Connectable; +import net.freerouting.board.Item; +import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.datastructures.ShapeTree; import net.freerouting.geometry.planar.TileShape; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import net.freerouting.datastructures.ShapeTree; - -import net.freerouting.board.SearchTreeObject; -import net.freerouting.board.ShapeSearchTree; -import net.freerouting.board.Connectable; -import net.freerouting.board.Item; - /** * An expansion room, whose shape is completely calculated, * so that it can be stored in a shape tree. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class CompleteFreeSpaceExpansionRoom extends FreeSpaceExpansionRoom implements CompleteExpansionRoom, SearchTreeObject -{ - +public class CompleteFreeSpaceExpansionRoom extends FreeSpaceExpansionRoom implements CompleteExpansionRoom, SearchTreeObject { + + //** identification number for implementong the Comparable interfacw */ + private final int id_no; + /** + * The array of entries in the SearchTree. Consists of just one element + */ + private ShapeTree.Leaf[] tree_entries = null; + /** + * The list of doors to items of the own net + */ + private Collection target_doors; + private boolean room_is_net_dependent = false; + /** * Creates a new instance of CompleteFreeSpaceExpansionRoom */ - public CompleteFreeSpaceExpansionRoom(TileShape p_shape, int p_layer, int p_id_no) - { + public CompleteFreeSpaceExpansionRoom(TileShape p_shape, int p_layer, int p_id_no) { super(p_shape, p_layer); target_doors = new LinkedList(); id_no = p_id_no; } - - public void set_search_tree_entries(ShapeTree.Leaf [] p_entries, ShapeTree p_tree) - { + + public void set_search_tree_entries(ShapeTree.Leaf[] p_entries, ShapeTree p_tree) { tree_entries = p_entries; } - - public int compareTo(Object p_other) - { + + public int compareTo(Object p_other) { int result; - if (p_other instanceof FreeSpaceExpansionRoom) - { + if (p_other instanceof FreeSpaceExpansionRoom) { result = ((CompleteFreeSpaceExpansionRoom) p_other).id_no - this.id_no; - } - else - { + } else { result = -1; } return result; } - + /** * Removes the tree entries of this roomm from p_shape_tree. */ - public void remove_from_tree(ShapeTree p_shape_tree) - { + public void remove_from_tree(ShapeTree p_shape_tree) { p_shape_tree.remove(this.tree_entries); } - - public int tree_shape_count(ShapeTree p_shape_tree) - { + + public int tree_shape_count(ShapeTree p_shape_tree) { return 1; } - - public TileShape get_tree_shape(ShapeTree p_shape_tree, int p_index) - { + + public TileShape get_tree_shape(ShapeTree p_shape_tree, int p_index) { return this.get_shape(); } - - public int shape_layer(int p_index) - { + + public int shape_layer(int p_index) { return this.get_layer(); } - - public boolean is_obstacle(int p_net_no) - { + + public boolean is_obstacle(int p_net_no) { return true; } - - public boolean is_trace_obstacle(int p_net_no) - { + + public boolean is_trace_obstacle(int p_net_no) { return true; } - + /** * Will be called, when the room overlaps with net dependent objects. */ - public void set_net_dependent() - { + public void set_net_dependent() { this.room_is_net_dependent = true; } - + /** * Returns, if the room overlaps with net dependent objects. * In this case it cannot be retained, when the net number changes in autorouting. */ - public boolean is_net_dependent() - { + public boolean is_net_dependent() { return this.room_is_net_dependent; } - + /** * Returns the list doors to target items of this room */ - public Collection get_target_doors() - { + public Collection get_target_doors() { return this.target_doors; } - + /** * Adds p_door to the list of target doors of this room. */ - public void add_target_door(TargetItemExpansionDoor p_door) - { + public void add_target_door(TargetItemExpansionDoor p_door) { this.target_doors.add(p_door); } - - public boolean remove_door(ExpandableObject p_door) - { + + public boolean remove_door(ExpandableObject p_door) { boolean result; - if (p_door instanceof TargetItemExpansionDoor) - { + if (p_door instanceof TargetItemExpansionDoor) { result = this.target_doors.remove(p_door); - } - else - { + } else { result = super.remove_door(p_door); } return result; } - - public SearchTreeObject get_object() - { + + public SearchTreeObject get_object() { return this; } - + /** * Calculates the doors to the start and destination items of the autoroute algorithm. */ - public void calculate_target_doors(ShapeTree.TreeEntry p_own_net_object, int p_net_no, ShapeSearchTree p_autoroute_search_tree) - { + public void calculate_target_doors(ShapeTree.TreeEntry p_own_net_object, int p_net_no, ShapeSearchTree p_autoroute_search_tree) { this.set_net_dependent(); - - if (p_own_net_object.object instanceof Connectable) - { + + if (p_own_net_object.object instanceof Connectable) { Connectable curr_object = (Connectable) p_own_net_object.object; - if (curr_object.contains_net(p_net_no)) - { + if (curr_object.contains_net(p_net_no)) { TileShape curr_connection_shape = curr_object.get_trace_connection_shape(p_autoroute_search_tree, p_own_net_object.shape_index_in_object); - if (curr_connection_shape != null && this.get_shape().intersects(curr_connection_shape)) - { + if (curr_connection_shape != null && this.get_shape().intersects(curr_connection_shape)) { Item curr_item = (Item) curr_object; TargetItemExpansionDoor new_target_door = new TargetItemExpansionDoor(curr_item, p_own_net_object.shape_index_in_object, this, - p_autoroute_search_tree); + p_autoroute_search_tree); this.add_target_door(new_target_door); } } } } - + /** * Draws the shape of this room. */ - public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) - { + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { java.awt.Color draw_color = p_graphics_context.get_trace_colors(false)[this.get_layer()]; double layer_visibility = p_graphics_context.get_layer_visibility(this.get_layer()); p_graphics_context.fill_area(this.get_shape(), p_graphics, draw_color, p_intensity * layer_visibility); p_graphics_context.draw_boundary(this.get_shape(), 0, draw_color, p_graphics, layer_visibility); } - + /** * Check, if this FreeSpaceExpansionRoom is valid. */ - public boolean validate( AutorouteEngine p_autoroute_engine) - { + public boolean validate(AutorouteEngine p_autoroute_engine) { boolean result = true; Collection overlapping_objects = new LinkedList(); - int [] net_no_arr = new int[1]; + int[] net_no_arr = new int[1]; net_no_arr[0] = p_autoroute_engine.get_net_no(); - p_autoroute_engine.autoroute_search_tree.overlapping_tree_entries( this.get_shape(), this.get_layer(), + p_autoroute_engine.autoroute_search_tree.overlapping_tree_entries(this.get_shape(), this.get_layer(), net_no_arr, overlapping_objects); Iterator it = overlapping_objects.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { ShapeTree.TreeEntry curr_entry = it.next(); - if (curr_entry.object == this) - { + if (curr_entry.object == this) { continue; } SearchTreeObject curr_object = (SearchTreeObject) curr_entry.object; - if (!curr_object.is_trace_obstacle(p_autoroute_engine.get_net_no())) - { + if (!curr_object.is_trace_obstacle(p_autoroute_engine.get_net_no())) { continue; } - if (curr_object.shape_layer(curr_entry.shape_index_in_object) != get_layer()) - { + if (curr_object.shape_layer(curr_entry.shape_index_in_object) != get_layer()) { continue; } TileShape curr_shape = curr_object.get_tree_shape(p_autoroute_engine.autoroute_search_tree, curr_entry.shape_index_in_object); TileShape intersection = this.get_shape().intersection(curr_shape); - if (intersection.dimension() > 1) - { + if (intersection.dimension() > 1) { System.out.println("ExpansionRoom overlap conflict"); result = false; } } return result; } - + /** * Removes all doors and target doors from this room. */ - public void clear_doors() - { + public void clear_doors() { super.clear_doors(); this.target_doors = new LinkedList(); } - - public void reset_doors() - { + + public void reset_doors() { super.reset_doors(); - for (ExpandableObject curr_door : this.target_doors) - { + for (ExpandableObject curr_door : this.target_doors) { curr_door.reset(); } } - - - /** The array of entries in the SearchTree. Consists of just one element */ - private ShapeTree.Leaf [] tree_entries = null; - - //** identification number for implementong the Comparable interfacw */ - private final int id_no; - - /** The list of doors to items of the own net */ - private Collection target_doors; - - private boolean room_is_net_dependent = false; } diff --git a/src/main/java/net/freerouting/autoroute/Connection.java b/src/main/java/net/freerouting/autoroute/Connection.java index 6e5c2fc8..d6b2734b 100644 --- a/src/main/java/net/freerouting/autoroute/Connection.java +++ b/src/main/java/net/freerouting/autoroute/Connection.java @@ -21,90 +21,97 @@ package net.freerouting.autoroute; +import net.freerouting.board.Item; +import net.freerouting.board.Trace; +import net.freerouting.geometry.planar.Point; + import java.util.Collection; import java.util.Set; import java.util.TreeSet; -import net.freerouting.geometry.planar.Point; - -import net.freerouting.board.Item; -import net.freerouting.board.Trace; - /** * Describes a routing connection ending at the next fork or terminal item. * * @author Alfons Wirtz */ -public class Connection -{ - +public class Connection { + + private static final double DETOUR_ADD = 100; + private static final double DETOUR_ITEM_COST = 0.1; + /** + * If the connection ens in empty space, start_point or end_point may be null. + */ + public final Point start_point; + public final int start_layer; + public final Point end_point; + public final int end_layer; + public final Set item_list; + /** + * Creates a new instance of Connection + */ + private Connection(Point p_start_point, int p_start_layer, Point p_end_point, int p_end_layer, Set p_item_list) { + start_point = p_start_point; + start_layer = p_start_layer; + end_point = p_end_point; + end_layer = p_end_layer; + item_list = p_item_list; + } + /** * Gets the connection this item belongs to. A connection ends at the next fork or terminal item. * Returns null, if p_item is not a route item, or if it is a via belonging to more than 1 connection. */ - public static Connection get(Item p_item) - { - if (!p_item.is_route()) - { + public static Connection get(Item p_item) { + if (!p_item.is_route()) { return null; } - Connection precalculated_connection = p_item.get_autoroute_info().get_precalculated_connection(); - if (precalculated_connection != null) - { + Connection precalculated_connection = p_item.get_autoroute_info().get_precalculated_connection(); + if (precalculated_connection != null) { return precalculated_connection; } Set contacts = p_item.get_normal_contacts(); Set connection_items = new TreeSet(); connection_items.add(p_item); - + Point start_point = null; int start_layer = 0; Point end_point = null; int end_layer = 0; - - for (Item curr_item : contacts) - { + + for (Item curr_item : contacts) { Point prev_contact_point = p_item.normal_contact_point(curr_item); - if (prev_contact_point == null) - { + if (prev_contact_point == null) { // no unique contact point continue; } int prev_contact_layer = p_item.first_common_layer(curr_item); boolean fork_found = false; - if (p_item instanceof Trace) - { + if (p_item instanceof Trace) { // Check, that there is only 1 contact at this location. // Only for pins and vias items of more than 1 connection // are collected Trace start_trace = (Trace) p_item; Collection check_contacts = start_trace.get_normal_contacts(prev_contact_point, false); - if (check_contacts.size() != 1) - { + if (check_contacts.size() != 1) { fork_found = true; } } // Search from curr_item along the contacts // until the next fork or nonroute item. - for (;;) - { - if(!curr_item.is_route() || fork_found) - { + for (; ; ) { + if (!curr_item.is_route() || fork_found) { // connection ends - if (start_point == null) - { + if (start_point == null) { start_point = prev_contact_point; start_layer = prev_contact_layer; - } - else if (!prev_contact_point.equals(start_point)) - { + } else if (!prev_contact_point.equals(start_point)) { end_point = prev_contact_point; end_layer = prev_contact_layer; } break; } connection_items.add(curr_item); - Collection curr_item_contacts = curr_item.get_normal_contacts(); + Collection curr_item_contacts = curr_item.get_normal_contacts(); // filter the contacts at the previous contact point, // because we were already there. // If then there is not exactly 1 new contact left, there is @@ -112,25 +119,20 @@ else if (!prev_contact_point.equals(start_point)) Point next_contact_point = null; int next_contact_layer = -1; Item next_contact = null; - for (Item tmp_contact : curr_item_contacts) - { + for (Item tmp_contact : curr_item_contacts) { int tmp_contact_layer = curr_item.first_common_layer(tmp_contact); - if (tmp_contact_layer >= 0) - { + if (tmp_contact_layer >= 0) { Point tmp_contact_point = curr_item.normal_contact_point(tmp_contact); - if (tmp_contact_point == null) - { + if (tmp_contact_point == null) { // no unique contact point fork_found = true; break; } if (prev_contact_layer != tmp_contact_layer || - !prev_contact_point.equals(tmp_contact_point)) - { + !prev_contact_point.equals(tmp_contact_point)) { next_contact_point = tmp_contact_point; next_contact_layer = tmp_contact_layer; - if (next_contact != null) - { + if (next_contact != null) { // second new contact found fork_found = true; break; @@ -139,8 +141,7 @@ else if (!prev_contact_point.equals(start_point)) } } } - if (next_contact == null) - { + if (next_contact == null) { break; } curr_item = next_contact; @@ -149,67 +150,35 @@ else if (!prev_contact_point.equals(start_point)) } } Connection result = new Connection(start_point, start_layer, end_point, end_layer, connection_items); - for (Item curr_item : connection_items) - { + for (Item curr_item : connection_items) { curr_item.get_autoroute_info().set_precalculated_connection(result); } return result; } - - /** - * Creates a new instance of Connection - */ - private Connection(Point p_start_point, int p_start_layer, Point p_end_point, int p_end_layer, Set p_item_list) - { - start_point = p_start_point; - start_layer = p_start_layer; - end_point = p_end_point; - end_layer = p_end_layer; - item_list = p_item_list; - } - + /** * Returns the cumulative length of the traces in this connection. */ - public double trace_length() - { + public double trace_length() { double result = 0; - for (Item curr_item : item_list) - { - if (curr_item instanceof Trace) - { - result += ((Trace) curr_item).get_length(); + for (Item curr_item : item_list) { + if (curr_item instanceof Trace) { + result += ((Trace) curr_item).get_length(); } } return result; } - - + /** * Returns an estimation of the actual length of the connection divided by the minimal possible length. */ - public double get_detour() - { - if (start_point == null || end_point == null) - { + public double get_detour() { + if (start_point == null || end_point == null) { return Integer.MAX_VALUE; } double min_trace_length = start_point.to_float().distance(end_point.to_float()); - double detour = (this.trace_length() + DETOUR_ADD) / (min_trace_length + DETOUR_ADD) + + double detour = (this.trace_length() + DETOUR_ADD) / (min_trace_length + DETOUR_ADD) + DETOUR_ITEM_COST * (item_list.size() - 1); return detour; } - - - /** - * If the connection ens in empty space, start_point or end_point may be null. - */ - public final Point start_point; - public final int start_layer; - public final Point end_point; - public final int end_layer; - public final Set item_list; - - private static final double DETOUR_ADD = 100; - private static final double DETOUR_ITEM_COST = 0.1; } diff --git a/src/main/java/net/freerouting/autoroute/DestinationDistance.java b/src/main/java/net/freerouting/autoroute/DestinationDistance.java index a12c2b3a..ac80270f 100644 --- a/src/main/java/net/freerouting/autoroute/DestinationDistance.java +++ b/src/main/java/net/freerouting/autoroute/DestinationDistance.java @@ -20,378 +20,335 @@ package net.freerouting.autoroute; +import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntBox; -import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; - /** * Calculation of a good lower bound for the distance between a new MazeExpansionElement * and the destination set of the expansion. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class DestinationDistance -{ - +public class DestinationDistance { + + private final ExpansionCostFactor[] trace_costs; + private final boolean[] layer_active; + private final int layer_count; + private final int active_layer_count; + double min_component_side_trace_cost; + double max_component_side_trace_cost; + double min_solder_side_trace_cost; + double max_solder_side_trace_cost; + double max_inner_side_trace_cost; + // minimum of the maximal trace costs on each inner layer + double min_component_inner_trace_cost; + // minimum of min_component_side_trace_cost and + // max_inner_side_trace_cost + double min_solder_inner_trace_cost; + // minimum of min_solder_side_trace_cost and max_inner_side_trace_cost + double min_component_solder_inner_trace_cost; + private double min_normal_via_cost; + private double min_cheap_via_cost; + // minimum of min_component_inner_trace_cost and + // min_solder_inner_trace_cost + private IntBox component_side_box = IntBox.EMPTY; + private IntBox solder_side_box = IntBox.EMPTY; + private IntBox inner_side_box = IntBox.EMPTY; + private boolean box_is_empty = true; + private boolean component_side_box_is_empty = true; + private boolean solder_side_box_is_empty = true; + private boolean inner_side_box_is_empty = true; /** * Creates a new instance of DestinationDistance. * p_trace_costs and p_layer_active are arrays of dimension layer_count. */ - public DestinationDistance( ExpansionCostFactor [] p_trace_costs, - boolean [] p_layer_active, double p_min_normal_via_cost, double p_min_cheap_via_cost) - { + public DestinationDistance(ExpansionCostFactor[] p_trace_costs, + boolean[] p_layer_active, double p_min_normal_via_cost, double p_min_cheap_via_cost) { trace_costs = p_trace_costs; layer_active = p_layer_active; layer_count = p_layer_active.length; min_normal_via_cost = p_min_normal_via_cost; min_cheap_via_cost = p_min_cheap_via_cost; int curr_active_layer_count = 0; - for (int ind = 0; ind < layer_count; ++ind) - { - if (layer_active[ind]) - { + for (int ind = 0; ind < layer_count; ++ind) { + if (layer_active[ind]) { ++curr_active_layer_count; } } this.active_layer_count = curr_active_layer_count; - - if (layer_active[0]) - { - if (trace_costs[0].horizontal < trace_costs[0].vertical) - { + + if (layer_active[0]) { + if (trace_costs[0].horizontal < trace_costs[0].vertical) { min_component_side_trace_cost = trace_costs[0].horizontal; max_component_side_trace_cost = trace_costs[0].vertical; - } - else - { + } else { min_component_side_trace_cost = trace_costs[0].vertical; max_component_side_trace_cost = trace_costs[0].horizontal; } } - - if (layer_active[layer_count - 1]) - { + + if (layer_active[layer_count - 1]) { ExpansionCostFactor curr_trace_cost = trace_costs[layer_count - 1]; - - if (curr_trace_cost.horizontal < curr_trace_cost.vertical) - { + + if (curr_trace_cost.horizontal < curr_trace_cost.vertical) { min_solder_side_trace_cost = curr_trace_cost.horizontal; max_solder_side_trace_cost = curr_trace_cost.vertical; - } - else - { + } else { min_solder_side_trace_cost = curr_trace_cost.vertical; max_solder_side_trace_cost = curr_trace_cost.horizontal; } } - + // Note: for inner layers we assume, that cost in preferred direction is 1 max_inner_side_trace_cost = Math.min(max_component_side_trace_cost, max_solder_side_trace_cost); - for (int ind2 = 1; ind2 < layer_count - 1; ++ind2) - { - if (!layer_active[ind2]) - { + for (int ind2 = 1; ind2 < layer_count - 1; ++ind2) { + if (!layer_active[ind2]) { continue; } double curr_max_cost = Math.max(trace_costs[ind2].horizontal, trace_costs[ind2].vertical); - + max_inner_side_trace_cost = Math.min(max_inner_side_trace_cost, curr_max_cost); } min_component_inner_trace_cost = Math.min(min_component_side_trace_cost, max_inner_side_trace_cost); min_solder_inner_trace_cost = Math.min(min_solder_side_trace_cost, max_inner_side_trace_cost); min_component_solder_inner_trace_cost = Math.min(min_component_inner_trace_cost, min_solder_inner_trace_cost); } - - public void join(IntBox p_box, int p_layer) - { - if (p_layer == 0) - { + + public void join(IntBox p_box, int p_layer) { + if (p_layer == 0) { component_side_box = component_side_box.union(p_box); component_side_box_is_empty = false; - } - else if (p_layer == layer_count - 1) - { - solder_side_box =solder_side_box.union(p_box); + } else if (p_layer == layer_count - 1) { + solder_side_box = solder_side_box.union(p_box); solder_side_box_is_empty = false; - } - else - { + } else { inner_side_box = inner_side_box.union(p_box); inner_side_box_is_empty = false; } box_is_empty = false; } - - public double calculate(FloatPoint p_point, int p_layer) - { - return calculate( p_point.bounding_box(), p_layer); + + public double calculate(FloatPoint p_point, int p_layer) { + return calculate(p_point.bounding_box(), p_layer); } - - public double calculate(IntBox p_box, int p_layer) - { - if (box_is_empty) - { + + public double calculate(IntBox p_box, int p_layer) { + if (box_is_empty) { return Integer.MAX_VALUE; } - + double component_side_delta_x; double component_side_delta_y; - - if (p_box.ll.x > component_side_box.ur.x) - { + + if (p_box.ll.x > component_side_box.ur.x) { component_side_delta_x = p_box.ll.x - component_side_box.ur.x; - } - else if (p_box.ur.x < component_side_box.ll.x) - { + } else if (p_box.ur.x < component_side_box.ll.x) { component_side_delta_x = component_side_box.ll.x - p_box.ur.x; - } - else - { + } else { component_side_delta_x = 0; } - - if (p_box.ll.y > component_side_box.ur.y) - { + + if (p_box.ll.y > component_side_box.ur.y) { component_side_delta_y = p_box.ll.y - component_side_box.ur.y; - } - else if (p_box.ur.y < component_side_box.ll.y) - { + } else if (p_box.ur.y < component_side_box.ll.y) { component_side_delta_y = component_side_box.ll.y - p_box.ur.y; - } - else - { + } else { component_side_delta_y = 0; } - + double solder_side_delta_x; double solder_side_delta_y; - - if (p_box.ll.x > solder_side_box.ur.x) - { + + if (p_box.ll.x > solder_side_box.ur.x) { solder_side_delta_x = p_box.ll.x - solder_side_box.ur.x; - } - else if (p_box.ur.x < solder_side_box.ll.x) - { + } else if (p_box.ur.x < solder_side_box.ll.x) { solder_side_delta_x = solder_side_box.ll.x - p_box.ur.x; - } - else - { + } else { solder_side_delta_x = 0; } - - if (p_box.ll.y > solder_side_box.ur.y) - { + + if (p_box.ll.y > solder_side_box.ur.y) { solder_side_delta_y = p_box.ll.y - solder_side_box.ur.y; - } - else if (p_box.ur.y < solder_side_box.ll.y) - { + } else if (p_box.ur.y < solder_side_box.ll.y) { solder_side_delta_y = solder_side_box.ll.y - p_box.ur.y; - } - else - { + } else { solder_side_delta_y = 0; } - + double inner_side_delta_x; double inner_side_delta_y; - - if (p_box.ll.x > inner_side_box.ur.x) - { + + if (p_box.ll.x > inner_side_box.ur.x) { inner_side_delta_x = p_box.ll.x - inner_side_box.ur.x; - } - else if (p_box.ur.x < inner_side_box.ll.x) - { + } else if (p_box.ur.x < inner_side_box.ll.x) { inner_side_delta_x = inner_side_box.ll.x - p_box.ur.x; - } - else - { + } else { inner_side_delta_x = 0; } - - if (p_box.ll.y > inner_side_box.ur.y) - { + + if (p_box.ll.y > inner_side_box.ur.y) { inner_side_delta_y = p_box.ll.y - inner_side_box.ur.y; - } - else if (p_box.ur.y < inner_side_box.ll.y) - { + } else if (p_box.ur.y < inner_side_box.ll.y) { inner_side_delta_y = inner_side_box.ll.y - p_box.ur.y; - } - else - { + } else { inner_side_delta_y = 0; } - + double component_side_max_delta; double component_side_min_delta; - - if (component_side_delta_x > component_side_delta_y) - { + + if (component_side_delta_x > component_side_delta_y) { component_side_max_delta = component_side_delta_x; component_side_min_delta = component_side_delta_y; - } - else - { + } else { component_side_max_delta = component_side_delta_y; component_side_min_delta = component_side_delta_x; } - + double solder_side_max_delta; double solder_side_min_delta; - - if (solder_side_delta_x > solder_side_delta_y) - { + + if (solder_side_delta_x > solder_side_delta_y) { solder_side_max_delta = solder_side_delta_x; solder_side_min_delta = solder_side_delta_y; - } - else - { + } else { solder_side_max_delta = solder_side_delta_y; solder_side_min_delta = solder_side_delta_x; } - + double inner_side_max_delta; double inner_side_min_delta; - - if (inner_side_delta_x > inner_side_delta_y) - { + + if (inner_side_delta_x > inner_side_delta_y) { inner_side_max_delta = inner_side_delta_x; inner_side_min_delta = inner_side_delta_y; - } - else - { + } else { inner_side_max_delta = inner_side_delta_y; inner_side_min_delta = inner_side_delta_x; } - + double result = Integer.MAX_VALUE; - + if (p_layer == 0) - // calculate shortest distance to component side box + // calculate shortest distance to component side box { // calculate one layer distance - - if (!component_side_box_is_empty) - { + + if (!component_side_box_is_empty) { result = p_box.weighted_distance(component_side_box, - trace_costs[0].horizontal, trace_costs[0].vertical); + trace_costs[0].horizontal, trace_costs[0].vertical); } - - if (active_layer_count <= 1) - { + + if (active_layer_count <= 1) { return result; } - + // calculate two layer distance on component and solder side - + double tmp_distance; if (min_solder_side_trace_cost < min_component_side_trace_cost) tmp_distance = min_solder_side_trace_cost * solder_side_max_delta - + min_component_side_trace_cost * solder_side_min_delta - + min_normal_via_cost; + + min_component_side_trace_cost * solder_side_min_delta + + min_normal_via_cost; else tmp_distance = min_component_side_trace_cost * solder_side_max_delta - + min_solder_side_trace_cost * solder_side_min_delta - + min_normal_via_cost; - + + min_solder_side_trace_cost * solder_side_min_delta + + min_normal_via_cost; + result = Math.min(result, tmp_distance); - + // calculate two layer distance on component and solde side // with two vias - + tmp_distance = component_side_max_delta + component_side_min_delta * min_component_inner_trace_cost + 2 * min_normal_via_cost; - + result = Math.min(result, tmp_distance); - + if (active_layer_count <= 2) return result; - + // calculate two layer distance on component side and an inner side - + tmp_distance = inner_side_max_delta + inner_side_min_delta * min_component_inner_trace_cost + min_normal_via_cost; - + result = Math.min(result, tmp_distance); - + // calculate three layer distance - + tmp_distance = solder_side_max_delta + +min_component_solder_inner_trace_cost * solder_side_min_delta + 2 * min_normal_via_cost; result = Math.min(result, tmp_distance); - + tmp_distance = component_side_max_delta + component_side_min_delta + 2 * min_normal_via_cost; result = Math.min(result, tmp_distance); - + if (active_layer_count <= 3) return result; - + tmp_distance = inner_side_max_delta + inner_side_min_delta + 2 * min_normal_via_cost; - + result = Math.min(result, tmp_distance); - + // calculate four layer distance - + tmp_distance = solder_side_max_delta + solder_side_min_delta + 3 * min_normal_via_cost; - + result = Math.min(result, tmp_distance); - + return result; } if (p_layer == layer_count - 1) - // calculate shortest distance to solder side box + // calculate shortest distance to solder side box { // calculate one layer distance - - if (!solder_side_box_is_empty) - { + + if (!solder_side_box_is_empty) { result = p_box.weighted_distance(solder_side_box, - trace_costs[p_layer].horizontal, trace_costs[p_layer].vertical); + trace_costs[p_layer].horizontal, trace_costs[p_layer].vertical); } - + // calculate two layer distance double tmp_distance; - if (min_component_side_trace_cost < min_solder_side_trace_cost) - { + if (min_component_side_trace_cost < min_solder_side_trace_cost) { tmp_distance = min_component_side_trace_cost * component_side_max_delta - + min_solder_side_trace_cost * component_side_min_delta - + min_normal_via_cost; - } - else - { + + min_solder_side_trace_cost * component_side_min_delta + + min_normal_via_cost; + } else { tmp_distance = min_solder_side_trace_cost * component_side_max_delta - + min_component_side_trace_cost * component_side_min_delta - + min_normal_via_cost; + + min_component_side_trace_cost * component_side_min_delta + + min_normal_via_cost; } result = Math.min(result, tmp_distance); tmp_distance = solder_side_max_delta + solder_side_min_delta * min_solder_inner_trace_cost + 2 * min_normal_via_cost; result = Math.min(result, tmp_distance); - if (active_layer_count <= 2) - { + if (active_layer_count <= 2) { return result; } tmp_distance = inner_side_min_delta * min_solder_inner_trace_cost + inner_side_max_delta + min_normal_via_cost; result = Math.min(result, tmp_distance); - + // calculate three layer distance - + tmp_distance = component_side_max_delta + min_component_solder_inner_trace_cost * component_side_min_delta + 2 * min_normal_via_cost; @@ -404,30 +361,29 @@ else if (p_box.ur.y < inner_side_box.ll.y) tmp_distance = inner_side_max_delta + inner_side_min_delta + 2 * min_normal_via_cost; result = Math.min(result, tmp_distance); - + // calculate four layer distance - + tmp_distance = component_side_max_delta + component_side_min_delta + 3 * min_normal_via_cost; result = Math.min(result, tmp_distance); return result; } - + // calculate distance to inner layer box - + // calculate one layer distance - - if (!inner_side_box_is_empty) - { + + if (!inner_side_box_is_empty) { result = p_box.weighted_distance(inner_side_box, - trace_costs[p_layer].horizontal, trace_costs[p_layer].vertical); + trace_costs[p_layer].horizontal, trace_costs[p_layer].vertical); } - + // calculate two layer distance - + double tmp_distance = inner_side_max_delta + inner_side_min_delta + min_normal_via_cost; - + result = Math.min(result, tmp_distance); tmp_distance = component_side_max_delta + component_side_min_delta * min_component_inner_trace_cost @@ -437,60 +393,26 @@ else if (p_box.ur.y < inner_side_box.ll.y) + solder_side_min_delta * min_solder_inner_trace_cost + min_normal_via_cost; result = Math.min(result, tmp_distance); - + // calculate three layer distance - + tmp_distance = component_side_max_delta + component_side_min_delta + 2 * min_normal_via_cost; result = Math.min(result, tmp_distance); tmp_distance = solder_side_max_delta + solder_side_min_delta + 2 * min_normal_via_cost; result = Math.min(result, tmp_distance); - + return result; } - - public double calculate_cheap_distance(IntBox p_box, int p_layer) - { + + public double calculate_cheap_distance(IntBox p_box, int p_layer) { double min_normal_via_cost_save = min_normal_via_cost; - + min_normal_via_cost = min_cheap_via_cost; double result = calculate(p_box, p_layer); - + min_normal_via_cost = min_normal_via_cost_save; return result; } - - - - - private final ExpansionCostFactor [] trace_costs; - private final boolean [] layer_active; - private final int layer_count; - private final int active_layer_count; - - private double min_normal_via_cost; - private double min_cheap_via_cost; - double min_component_side_trace_cost; - double max_component_side_trace_cost; - double min_solder_side_trace_cost; - double max_solder_side_trace_cost; - double max_inner_side_trace_cost; - // minimum of the maximal trace costs on each inner layer - double min_component_inner_trace_cost; - // minimum of min_component_side_trace_cost and - // max_inner_side_trace_cost - double min_solder_inner_trace_cost; - // minimum of min_solder_side_trace_cost and max_inner_side_trace_cost - double min_component_solder_inner_trace_cost; - // minimum of min_component_inner_trace_cost and - // min_solder_inner_trace_cost - private IntBox component_side_box = IntBox.EMPTY; - private IntBox solder_side_box = IntBox.EMPTY; - private IntBox inner_side_box = IntBox.EMPTY; - - private boolean box_is_empty = true; - private boolean component_side_box_is_empty = true; - private boolean solder_side_box_is_empty = true; - private boolean inner_side_box_is_empty = true; } diff --git a/src/main/java/net/freerouting/autoroute/DrillPage.java b/src/main/java/net/freerouting/autoroute/DrillPage.java index 15c941b9..9071cbe2 100644 --- a/src/main/java/net/freerouting/autoroute/DrillPage.java +++ b/src/main/java/net/freerouting/autoroute/DrillPage.java @@ -21,48 +21,75 @@ package net.freerouting.autoroute; -import java.util.Collection; -import java.util.LinkedList; -import java.util.Iterator; - -import net.freerouting.geometry.planar.Point; +import net.freerouting.board.Item; +import net.freerouting.board.RoutingBoard; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.datastructures.ShapeTree.TreeEntry; import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.Point; import net.freerouting.geometry.planar.PolylineArea; +import net.freerouting.geometry.planar.TileShape; -import net.freerouting.datastructures.ShapeTree.TreeEntry; - -import net.freerouting.board.RoutingBoard; -import net.freerouting.board.ShapeSearchTree; -import net.freerouting.board.Item; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; /** - * * @author Alfons Wirtz */ -class DrillPage implements ExpandableObject -{ - - /** Creates a new instance of DrillPage */ - public DrillPage(IntBox p_shape, RoutingBoard p_board) - { +class DrillPage implements ExpandableObject { + + /** + * The shape of the page + */ + final IntBox shape; + private final MazeSearchElement[] maze_search_info_arr; + private final RoutingBoard board; + /** + * The list of expansion drills on this page. Null, if not yet calculated. + */ + private Collection drills = null; + /** + * The number of the net, for which the drills are calculated + */ + private int net_no = -1; + + /** + * Creates a new instance of DrillPage + */ + public DrillPage(IntBox p_shape, RoutingBoard p_board) { shape = p_shape; board = p_board; - maze_search_info_arr = new MazeSearchElement[p_board.get_layer_count()]; - for (int i = 0; i < maze_search_info_arr.length; ++i) - { - maze_search_info_arr[i] = new MazeSearchElement(); + maze_search_info_arr = new MazeSearchElement[p_board.get_layer_count()]; + for (int i = 0; i < maze_search_info_arr.length; ++i) { + maze_search_info_arr[i] = new MazeSearchElement(); + } + } + + /** + * Looks if p_drill_shape contains the center of a drillable Pin on p_layer. + * Returns null, if no such Pin was found. + */ + private static Point calc_pin_center_in_drill(TileShape p_drill_shape, int p_layer, RoutingBoard p_board) { + Collection overlapping_items = p_board.overlapping_items(p_drill_shape, p_layer); + Point result = null; + for (Item curr_item : overlapping_items) { + if (curr_item instanceof net.freerouting.board.Pin) { + net.freerouting.board.Pin curr_pin = (net.freerouting.board.Pin) curr_item; + if (curr_pin.drill_allowed() && p_drill_shape.contains_inside(curr_pin.get_center())) { + result = curr_pin.get_center(); + } + } } + return result; } - + /** * Returns the drills on this page. * If p_atttach_smd, drilling to smd pins is allowed. */ - public Collection get_drills(AutorouteEngine p_autoroute_engine, boolean p_attach_smd) - { - if (this.drills == null || p_autoroute_engine.get_net_no() != this.net_no) - { + public Collection get_drills(AutorouteEngine p_autoroute_engine, boolean p_attach_smd) { + if (this.drills == null || p_autoroute_engine.get_net_no() != this.net_no) { this.net_no = p_autoroute_engine.get_net_no(); this.drills = new LinkedList(); ShapeSearchTree search_tree = this.board.search_tree_manager.get_default_tree(); @@ -71,32 +98,25 @@ public Collection get_drills(AutorouteEngine p_autoroute_engine, Collection cutout_shapes = new LinkedList(); // drills on top of existing vias are used in the ripup algorithm TileShape prev_obstacle_shape = IntBox.EMPTY; - for (TreeEntry curr_entry : overlaps) - { - if (!(curr_entry.object instanceof Item)) - { + for (TreeEntry curr_entry : overlaps) { + if (!(curr_entry.object instanceof Item)) { continue; } Item curr_item = (Item) curr_entry.object; - if (curr_item.is_drillable(this.net_no)) - { + if (curr_item.is_drillable(this.net_no)) { continue; } - if (curr_item instanceof net.freerouting.board.Pin) - { - if (p_attach_smd && ((net.freerouting.board.Pin) curr_item).drill_allowed()) - { + if (curr_item instanceof net.freerouting.board.Pin) { + if (p_attach_smd && ((net.freerouting.board.Pin) curr_item).drill_allowed()) { continue; } } TileShape curr_obstacle_shape = curr_item.get_tree_shape(search_tree, curr_entry.shape_index_in_object); - if (!prev_obstacle_shape.contains(curr_obstacle_shape)) - { + if (!prev_obstacle_shape.contains(curr_obstacle_shape)) { // Checked to avoid multiple cutout for example for vias with the same shape on all layers. TileShape curr_cutout_shape = curr_obstacle_shape.intersection(this.shape); - if (curr_cutout_shape.dimension() == 2) - { + if (curr_cutout_shape.dimension() == 2) { cutout_shapes.add(curr_cutout_shape); } } @@ -104,144 +124,90 @@ public Collection get_drills(AutorouteEngine p_autoroute_engine, } TileShape[] holes = new TileShape[cutout_shapes.size()]; Iterator it = cutout_shapes.iterator(); - for (int i = 0; i < holes.length; ++i) - { + for (int i = 0; i < holes.length; ++i) { holes[i] = it.next(); } PolylineArea shape_with_holes = new PolylineArea(this.shape, holes); - TileShape [] drill_shapes = shape_with_holes.split_to_convex(p_autoroute_engine.stoppable_thread); - + TileShape[] drill_shapes = shape_with_holes.split_to_convex(p_autoroute_engine.stoppable_thread); + // Use the center points of these drill shapes to try making a via. int drill_first_layer = 0; int drill_last_layer = this.board.get_layer_count() - 1; - for (int i = 0; i < drill_shapes.length; ++i) - { + for (int i = 0; i < drill_shapes.length; ++i) { TileShape curr_drill_shape = drill_shapes[i]; Point curr_drill_location = null; - if (p_attach_smd) - { + if (p_attach_smd) { curr_drill_location = calc_pin_center_in_drill(curr_drill_shape, drill_first_layer, p_autoroute_engine.board); - if (curr_drill_location == null) - { + if (curr_drill_location == null) { curr_drill_location = calc_pin_center_in_drill(curr_drill_shape, drill_last_layer, p_autoroute_engine.board); } } - if (curr_drill_location == null) - { + if (curr_drill_location == null) { curr_drill_location = curr_drill_shape.centre_of_gravity().round(); } ExpansionDrill new_drill = new ExpansionDrill(curr_drill_shape, curr_drill_location, drill_first_layer, drill_last_layer); - if (new_drill.calculate_expansion_rooms(p_autoroute_engine)) - { + if (new_drill.calculate_expansion_rooms(p_autoroute_engine)) { this.drills.add(new_drill); } } } return this.drills; } - - public TileShape get_shape() - { + + public TileShape get_shape() { return this.shape; } - - public int get_dimension() - { + + public int get_dimension() { return 2; } - - public int maze_search_element_count() - { + + public int maze_search_element_count() { return this.maze_search_info_arr.length; } - - public MazeSearchElement get_maze_search_element (int p_no) - { + + public MazeSearchElement get_maze_search_element(int p_no) { return this.maze_search_info_arr[p_no]; } - + /** * Resets all drills of this page for autorouting the next connection. */ - public void reset() - { - if (this.drills != null) - { - for (ExpansionDrill curr_drill : this.drills) - { + public void reset() { + if (this.drills != null) { + for (ExpansionDrill curr_drill : this.drills) { curr_drill.reset(); } } - for (MazeSearchElement curr_info : maze_search_info_arr) - { + for (MazeSearchElement curr_info : maze_search_info_arr) { curr_info.reset(); } } - + /** * Invalidates the drills of this page so that they are recalculated at the next call of get_drills(). */ - public void invalidate() - { + public void invalidate() { this.drills = null; } - + /* * Test draw of the drills on this page. */ public void draw(java.awt.Graphics p_graphics, - net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) - { - if (true || drills == null) - { + net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { + if (true || drills == null) { return; } - for (ExpansionDrill curr_drill : drills) - { + for (ExpansionDrill curr_drill : drills) { curr_drill.draw(p_graphics, p_graphics_context, p_intensity); } } - - public CompleteExpansionRoom other_room(CompleteExpansionRoom p_room) - { + + public CompleteExpansionRoom other_room(CompleteExpansionRoom p_room) { return null; } - - /** - * Looks if p_drill_shape contains the center of a drillable Pin on p_layer. - * Returns null, if no such Pin was found. - */ - private static Point calc_pin_center_in_drill(TileShape p_drill_shape, int p_layer, RoutingBoard p_board) - { - Collection overlapping_items = p_board.overlapping_items(p_drill_shape, p_layer); - Point result = null; - for (Item curr_item : overlapping_items) - { - if (curr_item instanceof net.freerouting.board.Pin) - { - net.freerouting.board.Pin curr_pin = (net.freerouting.board.Pin) curr_item; - if (curr_pin.drill_allowed() && p_drill_shape.contains_inside(curr_pin.get_center())) - { - result = curr_pin.get_center(); - } - } - } - return result; - } - - private final MazeSearchElement[] maze_search_info_arr; - - /** The shape of the page */ - final IntBox shape; - - /** The list of expansion drills on this page. Null, if not yet calculated. */ - private Collection drills = null; - - private final RoutingBoard board; - - /** The number of the net, for which the drills are calculated */ - private int net_no = -1; } diff --git a/src/main/java/net/freerouting/autoroute/DrillPageArray.java b/src/main/java/net/freerouting/autoroute/DrillPageArray.java index d10464c3..36332152 100644 --- a/src/main/java/net/freerouting/autoroute/DrillPageArray.java +++ b/src/main/java/net/freerouting/autoroute/DrillPageArray.java @@ -21,13 +21,12 @@ package net.freerouting.autoroute; -import java.util.Collection; -import java.util.LinkedList; - +import net.freerouting.board.RoutingBoard; import net.freerouting.geometry.planar.IntBox; import net.freerouting.geometry.planar.TileShape; -import net.freerouting.board.RoutingBoard; +import java.util.Collection; +import java.util.LinkedList; /** * Describes the 2 dimensional array of pages of ExpansionDrill`s used in the maze search algorithm. @@ -35,143 +34,118 @@ * * @author Alfons Wirtz */ -public class DrillPageArray -{ - - /** Creates a new instance of DrillPageArray */ - public DrillPageArray(RoutingBoard p_board, int p_max_page_width) - { +public class DrillPageArray { + + private final IntBox bounds; + /** + * The number of colums in the array. + */ + private final int COLUMN_COUNT; + /** + * The number of rows in the array. + */ + private final int ROW_COUNT; + /** + * The width of a single page in this array. + */ + private final int PAGE_WIDTH; + /** + * The height of a single page in this array. + */ + private final int PAGE_HEIGHT; + private final DrillPage[][] page_arr; + + /** + * Creates a new instance of DrillPageArray + */ + public DrillPageArray(RoutingBoard p_board, int p_max_page_width) { this.bounds = p_board.bounding_box; double length = bounds.ur.x - bounds.ll.x; double height = bounds.ur.y - bounds.ll.y; this.COLUMN_COUNT = (int) Math.ceil(length / p_max_page_width); - this.ROW_COUNT = (int) Math.ceil(height/ p_max_page_width); + this.ROW_COUNT = (int) Math.ceil(height / p_max_page_width); this.PAGE_WIDTH = (int) Math.ceil(length / COLUMN_COUNT); this.PAGE_HEIGHT = (int) Math.ceil(height / ROW_COUNT); - this.page_arr = new DrillPage[ROW_COUNT] [COLUMN_COUNT]; - for (int j = 0; j < this.ROW_COUNT; ++j) - { - for (int i = 0; i < this.COLUMN_COUNT; ++i) - { + this.page_arr = new DrillPage[ROW_COUNT][COLUMN_COUNT]; + for (int j = 0; j < this.ROW_COUNT; ++j) { + for (int i = 0; i < this.COLUMN_COUNT; ++i) { int ll_x = bounds.ll.x + i * PAGE_WIDTH; int ur_x; - if (i == COLUMN_COUNT - 1) - { + if (i == COLUMN_COUNT - 1) { ur_x = bounds.ur.x; - } - else - { + } else { ur_x = ll_x + PAGE_WIDTH; } int ll_y = bounds.ll.y + j * PAGE_HEIGHT; int ur_y; - if (j == ROW_COUNT - 1) - { + if (j == ROW_COUNT - 1) { ur_y = bounds.ur.y; - } - else - { + } else { ur_y = ll_y + PAGE_HEIGHT; } - page_arr [j] [i] = new DrillPage(new IntBox(ll_x, ll_y, ur_x, ur_y), p_board); + page_arr[j][i] = new DrillPage(new IntBox(ll_x, ll_y, ur_x, ur_y), p_board); } } } - + /** * Invalidates all drill pages intersecting with p_shape, so the they must be recalculated at the next * call of get_ddrills() */ - public void invalidate(TileShape p_shape) - { - Collection overlaps = overlapping_pages( p_shape); - for (DrillPage curr_page : overlaps) - { + public void invalidate(TileShape p_shape) { + Collection overlaps = overlapping_pages(p_shape); + for (DrillPage curr_page : overlaps) { curr_page.invalidate(); } } - + /** * Collects all drill pages with a 2-dimensional overlap with p_shape. */ - public Collection overlapping_pages(TileShape p_shape) - { + public Collection overlapping_pages(TileShape p_shape) { Collection result = new LinkedList(); - + IntBox shape_box = p_shape.bounding_box().intersection(this.bounds); - - int min_j = (int) Math.floor(((double)(shape_box.ll.y - bounds.ll.y))/ (double) PAGE_HEIGHT); + + int min_j = (int) Math.floor(((double) (shape_box.ll.y - bounds.ll.y)) / (double) PAGE_HEIGHT); double max_j = ((double) (shape_box.ur.y - bounds.ll.y)) / (double) PAGE_HEIGHT; - - int min_i = (int) Math.floor(((double) (shape_box.ll.x - bounds.ll.x))/ (double) PAGE_WIDTH ); + + int min_i = (int) Math.floor(((double) (shape_box.ll.x - bounds.ll.x)) / (double) PAGE_WIDTH); double max_i = ((double) (shape_box.ur.x - bounds.ll.x)) / (double) PAGE_WIDTH; - - for (int j = min_j; j < max_j; ++j) - { - for (int i = min_i; i < max_i; ++i) - { - DrillPage curr_page = this.page_arr[j] [i]; + + for (int j = min_j; j < max_j; ++j) { + for (int i = min_i; i < max_i; ++i) { + DrillPage curr_page = this.page_arr[j][i]; TileShape intersection = p_shape.intersection(curr_page.shape); - if (intersection.dimension() > 1) - { - result.add(this.page_arr[j] [i]); + if (intersection.dimension() > 1) { + result.add(this.page_arr[j][i]); } } } return result; } - + /** * Resets all drill pages for autorouting the next connection. */ - public void reset() - { - for (int j = 0; j < page_arr.length; ++j) - { - DrillPage [] curr_row = page_arr[j]; - for (int i = 0; i < curr_row.length; ++i) - { + public void reset() { + for (int j = 0; j < page_arr.length; ++j) { + DrillPage[] curr_row = page_arr[j]; + for (int i = 0; i < curr_row.length; ++i) { curr_row[i].reset(); } } } - - /* - * Test draw of the all drills - */ - public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) - { - for (int j = 0; j < page_arr.length; ++j) - { - DrillPage [] curr_row = page_arr[j]; - for (int i = 0; i < curr_row.length; ++i) - { + + /* + * Test draw of the all drills + */ + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { + for (int j = 0; j < page_arr.length; ++j) { + DrillPage[] curr_row = page_arr[j]; + for (int i = 0; i < curr_row.length; ++i) { curr_row[i].draw(p_graphics, p_graphics_context, p_intensity); } } } - - private final IntBox bounds; - - /** - * The number of colums in the array. - */ - private final int COLUMN_COUNT; - - /** - * The number of rows in the array. - */ - private final int ROW_COUNT; - - /** - * The width of a single page in this array. - */ - private final int PAGE_WIDTH; - - /** - * The height of a single page in this array. - */ - private final int PAGE_HEIGHT; - - private final DrillPage [][] page_arr; } diff --git a/src/main/java/net/freerouting/autoroute/ExpandableObject.java b/src/main/java/net/freerouting/autoroute/ExpandableObject.java index 38eebea0..1c571de8 100644 --- a/src/main/java/net/freerouting/autoroute/ExpandableObject.java +++ b/src/main/java/net/freerouting/autoroute/ExpandableObject.java @@ -24,10 +24,9 @@ /** * An object, which can be expanded by the maze expansion algorithm. * - * @author alfons + * @author alfons */ -public interface ExpandableObject -{ +public interface ExpandableObject { /** * Calculates the intersection of the shapes of the 2 objecta belonging to this door. @@ -46,12 +45,12 @@ public interface ExpandableObject CompleteExpansionRoom other_room(CompleteExpansionRoom p_room); /** - * Returns the count of MazeSearchElements in this expandable object + * Returns the count of MazeSearchElements in this expandable object */ int maze_search_element_count(); /** - * Returns the p_no-th MazeSearchElements in this expandable object + * Returns the p_no-th MazeSearchElements in this expandable object */ MazeSearchElement get_maze_search_element(int p_no); diff --git a/src/main/java/net/freerouting/autoroute/ExpansionDoor.java b/src/main/java/net/freerouting/autoroute/ExpansionDoor.java index c2faea31..281272ab 100644 --- a/src/main/java/net/freerouting/autoroute/ExpansionDoor.java +++ b/src/main/java/net/freerouting/autoroute/ExpansionDoor.java @@ -19,31 +19,48 @@ */ package net.freerouting.autoroute; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.FloatLine; +import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.TileShape; /** * An ExpansionDoor is a common edge between two ExpansionRooms * - * * @author Alfons Wirtz */ -public class ExpansionDoor implements ExpandableObject -{ +public class ExpansionDoor implements ExpandableObject { - /** Creates a new instance of ExpansionDoor */ - public ExpansionDoor(ExpansionRoom p_first_room, ExpansionRoom p_second_room, int p_dimension) - { + /** + * The first room of this door. + */ + public final ExpansionRoom first_room; + /** + * The second room of this door. + */ + public final ExpansionRoom second_room; + /** + * The dimension of a door may be 1 or 2. + */ + public final int dimension; + /** + * each section of the following arrray can be expanded seperately by the maze search algorithm + */ + MazeSearchElement[] section_arr = null; + + /** + * Creates a new instance of ExpansionDoor + */ + public ExpansionDoor(ExpansionRoom p_first_room, ExpansionRoom p_second_room, int p_dimension) { first_room = p_first_room; second_room = p_second_room; dimension = p_dimension; } - /** Creates a new instance of ExpansionDoor */ - public ExpansionDoor(ExpansionRoom p_first_room, ExpansionRoom p_second_room) - { + /** + * Creates a new instance of ExpansionDoor + */ + public ExpansionDoor(ExpansionRoom p_first_room, ExpansionRoom p_second_room) { first_room = p_first_room; second_room = p_second_room; dimension = first_room.get_shape().intersection(second_room.get_shape()).dimension(); @@ -52,8 +69,7 @@ public ExpansionDoor(ExpansionRoom p_first_room, ExpansionRoom p_second_room) /** * Calculates the intersection of the shapes of the 2 rooms belonging to this door. */ - public TileShape get_shape() - { + public TileShape get_shape() { TileShape first_shape = first_room.get_shape(); TileShape second_shape = second_room.get_shape(); return first_shape.intersection(second_shape); @@ -63,8 +79,7 @@ public TileShape get_shape() * The dimension of a door may be 1 or 2. * 2-dimensional doors can only exist between ObstacleExpansionRooms */ - public int get_dimension() - { + public int get_dimension() { return this.dimension; } @@ -72,19 +87,13 @@ public int get_dimension() * Returns the other room of this door, or null, if p_roon * is neither equal to this.first_room nor to this.second_room. */ - public ExpansionRoom other_room(ExpansionRoom p_room) - { + public ExpansionRoom other_room(ExpansionRoom p_room) { ExpansionRoom result; - if (p_room == first_room) - { + if (p_room == first_room) { result = second_room; - } - else if (p_room == second_room) - { + } else if (p_room == second_room) { result = first_room; - } - else - { + } else { result = null; } return result; @@ -95,77 +104,59 @@ else if (p_room == second_room) * is neither equal to this.first_room nor to this.second_room, * or if the other room is not a CompleteExpansionRoom. */ - public CompleteExpansionRoom other_room(CompleteExpansionRoom p_room) - { + public CompleteExpansionRoom other_room(CompleteExpansionRoom p_room) { ExpansionRoom result; - if (p_room == first_room) - { + if (p_room == first_room) { result = second_room; - } - else if (p_room == second_room) - { + } else if (p_room == second_room) { result = first_room; - } - else - { + } else { result = null; } - if (!(result instanceof CompleteExpansionRoom)) - { + if (!(result instanceof CompleteExpansionRoom)) { result = null; } return (CompleteExpansionRoom) result; } - public int maze_search_element_count() - { + public int maze_search_element_count() { return this.section_arr.length; } - public MazeSearchElement get_maze_search_element(int p_no) - { + public MazeSearchElement get_maze_search_element(int p_no) { return this.section_arr[p_no]; } /** * Calculates the Line segments of the sections of this door. */ - public FloatLine[] get_section_segments(double p_offset) - { + public FloatLine[] get_section_segments(double p_offset) { double offset = p_offset + AutorouteEngine.TRACE_WIDTH_TOLERANCE; TileShape door_shape = this.get_shape(); { - if (door_shape.is_empty()) - { + if (door_shape.is_empty()) { return new FloatLine[0]; } } FloatLine door_line_segment; FloatLine shrinked_line_segment; - if (this.dimension == 1) - { + if (this.dimension == 1) { door_line_segment = door_shape.diagonal_corner_segment(); shrinked_line_segment = door_line_segment.shrink_segment(offset); - } - else if (this.dimension == 2 && this.first_room instanceof CompleteFreeSpaceExpansionRoom && this.second_room instanceof CompleteFreeSpaceExpansionRoom) - { + } else if (this.dimension == 2 && this.first_room instanceof CompleteFreeSpaceExpansionRoom && this.second_room instanceof CompleteFreeSpaceExpansionRoom) { // Overlapping doors at a corner possible in case of 90- or 45-degree routing. // In case of freeangle routing the corners are cut off. door_line_segment = calc_door_line_segment(door_shape); - if (door_line_segment == null) - { + if (door_line_segment == null) { // CompleteFreeSpaceExpansionRoom inside other room return new FloatLine[0]; } - if (door_line_segment.b.distance_square(door_line_segment.a) < 4 * offset * offset) - { + if (door_line_segment.b.distance_square(door_line_segment.a) < 4 * offset * offset) { // door is small, 2 dimensional small doors are not yet expanded. return new FloatLine[0]; } shrinked_line_segment = door_line_segment.shrink_segment(offset); - } - else - { + } else { FloatPoint gravity_point = door_shape.centre_of_gravity(); door_line_segment = new FloatLine(gravity_point, gravity_point); shrinked_line_segment = door_line_segment; @@ -181,32 +172,25 @@ else if (this.dimension == 2 && this.first_room instanceof CompleteFreeSpaceExpa * Calculates a diagonal line of the 2-dimensional p_door_shape which represents the restraint line * between the shapes of this.first_room and this.second_room. */ - private FloatLine calc_door_line_segment(TileShape p_door_shape) - { + private FloatLine calc_door_line_segment(TileShape p_door_shape) { TileShape first_room_shape = this.first_room.get_shape(); TileShape second_room_shape = this.second_room.get_shape(); Point first_corner = null; Point second_corner = null; int corner_count = p_door_shape.border_line_count(); - for (int i = 0; i < corner_count; ++i) - { + for (int i = 0; i < corner_count; ++i) { Point curr_corner = p_door_shape.corner(i); - if (!first_room_shape.contains_inside(curr_corner) && !second_room_shape.contains_inside(curr_corner)) - { + if (!first_room_shape.contains_inside(curr_corner) && !second_room_shape.contains_inside(curr_corner)) { // curr_corner is on the border of both room shapes. - if (first_corner == null) - { + if (first_corner == null) { first_corner = curr_corner; - } - else if (second_corner == null && !first_corner.equals(curr_corner)) - { + } else if (second_corner == null && !first_corner.equals(curr_corner)) { second_corner = curr_corner; break; } } } - if (first_corner == null || second_corner == null) - { + if (first_corner == null || second_corner == null) { return null; } return new FloatLine(first_corner.to_float(), second_corner.to_float()); @@ -215,38 +199,24 @@ else if (second_corner == null && !first_corner.equals(curr_corner)) /** * Resets this ExpandableObject for autorouting the next connection. */ - public void reset() - { - if (section_arr != null) - { - for (MazeSearchElement curr_section : section_arr) - { + public void reset() { + if (section_arr != null) { + for (MazeSearchElement curr_section : section_arr) { curr_section.reset(); } } } - /** allocates and initialises p_section_count sections */ - void allocate_sections(int p_section_count) - { - if (section_arr != null && section_arr.length == p_section_count) - { + /** + * allocates and initialises p_section_count sections + */ + void allocate_sections(int p_section_count) { + if (section_arr != null && section_arr.length == p_section_count) { return; // already allocated } section_arr = new MazeSearchElement[p_section_count]; - for (int i = 0; i < section_arr.length; ++i) - { + for (int i = 0; i < section_arr.length; ++i) { section_arr[i] = new MazeSearchElement(); } } - /** each section of the following arrray can be expanded seperately by the maze search algorithm */ - MazeSearchElement[] section_arr = null; - /** The first room of this door. */ - public final ExpansionRoom first_room; - /** The second room of this door. */ - public final ExpansionRoom second_room; - /** - * The dimension of a door may be 1 or 2. - */ - public final int dimension; } diff --git a/src/main/java/net/freerouting/autoroute/ExpansionDrill.java b/src/main/java/net/freerouting/autoroute/ExpansionDrill.java index 006e54b8..14a7b822 100644 --- a/src/main/java/net/freerouting/autoroute/ExpansionDrill.java +++ b/src/main/java/net/freerouting/autoroute/ExpansionDrill.java @@ -28,14 +28,36 @@ /** * Layer change expansion object in the maze search algorithm. * - * @author alfons + * @author alfons */ -public class ExpansionDrill implements ExpandableObject -{ +public class ExpansionDrill implements ExpandableObject { - /** Creates a new instance of Drill */ - public ExpansionDrill(TileShape p_shape, Point p_location, int p_first_layer, int p_last_layer) - { + /** + * The location, where the drill is checked. + */ + public final Point location; + /** + * The first layer of the drill + */ + public final int first_layer; + /** + * The last layer of the drill + */ + public final int last_layer; + /** + * Array of dimension last_layer - first_layer + 1. + */ + public final CompleteExpansionRoom[] room_arr; + private final MazeSearchElement[] maze_search_info_arr; + /** + * The shape of the drill. + */ + private final TileShape shape; + + /** + * Creates a new instance of Drill + */ + public ExpansionDrill(TileShape p_shape, Point p_location, int p_first_layer, int p_last_layer) { shape = p_shape; location = p_location; first_layer = p_first_layer; @@ -43,8 +65,7 @@ public ExpansionDrill(TileShape p_shape, Point p_location, int p_first_layer, in int layer_count = p_last_layer - p_first_layer + 1; room_arr = new CompleteExpansionRoom[layer_count]; maze_search_info_arr = new MazeSearchElement[layer_count]; - for (int i = 0; i < maze_search_info_arr.length; ++i) - { + for (int i = 0; i < maze_search_info_arr.length; ++i) { maze_search_info_arr[i] = new MazeSearchElement(); } } @@ -55,45 +76,37 @@ public ExpansionDrill(TileShape p_shape, Point p_location, int p_first_layer, in * Returns false, if that was not possible because of an obstacle at this.location * on some layer in the compensated search tree. */ - public boolean calculate_expansion_rooms(AutorouteEngine p_autoroute_engine) - { + public boolean calculate_expansion_rooms(AutorouteEngine p_autoroute_engine) { TileShape search_shape = TileShape.get_instance(location); Collection overlaps = p_autoroute_engine.autoroute_search_tree.overlapping_objects(search_shape, -1); - for (int i = this.first_layer; i <= this.last_layer; ++i) - { + for (int i = this.first_layer; i <= this.last_layer; ++i) { CompleteExpansionRoom found_room = null; Iterator it = overlaps.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { net.freerouting.board.SearchTreeObject curr_ob = it.next(); - if (!(curr_ob instanceof CompleteExpansionRoom)) - { + if (!(curr_ob instanceof CompleteExpansionRoom)) { it.remove(); continue; } CompleteExpansionRoom curr_room = (CompleteExpansionRoom) curr_ob; - if (curr_room.get_layer() == i) - { + if (curr_room.get_layer() == i) { found_room = curr_room; it.remove(); break; } } - if (found_room == null) - { + if (found_room == null) { // create a new expansion romm on this layer IncompleteFreeSpaceExpansionRoom new_incomplete_room = new IncompleteFreeSpaceExpansionRoom(null, i, search_shape); Collection new_rooms = p_autoroute_engine.complete_expansion_room(new_incomplete_room); - if (new_rooms.size() != 1) - { + if (new_rooms.size() != 1) { // the size may be 0 because of an obstacle in the compensated tree at this.location return false; } Iterator it2 = new_rooms.iterator(); - if (it2.hasNext()) - { + if (it2.hasNext()) { found_room = it2.next(); } } @@ -102,35 +115,28 @@ public boolean calculate_expansion_rooms(AutorouteEngine p_autoroute_engine) return true; } - public TileShape get_shape() - { + public TileShape get_shape() { return this.shape; } - public int get_dimension() - { + public int get_dimension() { return 2; } - public CompleteExpansionRoom other_room(CompleteExpansionRoom p_room) - { + public CompleteExpansionRoom other_room(CompleteExpansionRoom p_room) { return null; } - public int maze_search_element_count() - { + public int maze_search_element_count() { return this.maze_search_info_arr.length; } - public MazeSearchElement get_maze_search_element(int p_no) - { + public MazeSearchElement get_maze_search_element(int p_no) { return this.maze_search_info_arr[p_no]; } - public void reset() - { - for (MazeSearchElement curr_info : maze_search_info_arr) - { + public void reset() { + for (MazeSearchElement curr_info : maze_search_info_arr) { curr_info.reset(); } } @@ -139,21 +145,9 @@ public void reset() * Test draw of the the shape of this drill. */ public void draw(java.awt.Graphics p_graphics, - net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) - { + net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { java.awt.Color draw_color = p_graphics_context.get_hilight_color(); p_graphics_context.fill_area(this.shape, p_graphics, draw_color, p_intensity); p_graphics_context.draw_boundary(this.shape, 0, draw_color, p_graphics, 1); } - private final MazeSearchElement[] maze_search_info_arr; - /** The shape of the drill. */ - private final TileShape shape; - /** The location, where the drill is checked. */ - public final Point location; - /** The first layer of the drill */ - public final int first_layer; - /** The last layer of the drill */ - public final int last_layer; - /** Array of dimension last_layer - first_layer + 1. */ - public final CompleteExpansionRoom[] room_arr; } diff --git a/src/main/java/net/freerouting/autoroute/ExpansionRoom.java b/src/main/java/net/freerouting/autoroute/ExpansionRoom.java index 1df40ffc..acb8a9cd 100644 --- a/src/main/java/net/freerouting/autoroute/ExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/ExpansionRoom.java @@ -21,52 +21,50 @@ package net.freerouting.autoroute; -import java.util.List; - import net.freerouting.geometry.planar.TileShape; +import java.util.List; + /** - * * @author alfons */ -public interface ExpansionRoom -{ +public interface ExpansionRoom { /** * Adds p_door to the list of doors of this room. */ void add_door(ExpansionDoor p_door); - + /** * Returns the list of doors of this room to neighbour expansion rooms */ List get_doors(); - + /** * Removes all doors from this room. */ void clear_doors(); - + /** * Clears the autorouting info of all doors for routing the next connection. */ void reset_doors(); - + /** * Checks, if this room has already a door to p_other */ boolean door_exists(ExpansionRoom p_other); - + /** * Removes p_door from this room. * Returns false, if p_room did not contain p_door. */ - boolean remove_door (ExpandableObject p_door); - + boolean remove_door(ExpandableObject p_door); + /** * Gets the shape of this room. */ TileShape get_shape(); - + /** * Returns the layer of this expansion room. */ diff --git a/src/main/java/net/freerouting/autoroute/FreeSpaceExpansionRoom.java b/src/main/java/net/freerouting/autoroute/FreeSpaceExpansionRoom.java index fdbd070a..b03dd6a6 100644 --- a/src/main/java/net/freerouting/autoroute/FreeSpaceExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/FreeSpaceExpansionRoom.java @@ -22,23 +22,31 @@ import net.freerouting.geometry.planar.TileShape; - import java.util.Iterator; import java.util.LinkedList; import java.util.List; - - - /** * Expansion Areas used by the maze search algorithm. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public abstract class FreeSpaceExpansionRoom implements ExpansionRoom -{ - +public abstract class FreeSpaceExpansionRoom implements ExpansionRoom { + + /** + * The layer of this room + */ + private final int layer; + /** + * The shape of this room + */ + private TileShape shape; + /** + * The list of doors to neighbour expansion rooms + */ + private List doors; + /** * Creates a new instance of FreeSpaceExpansionRoom. * The shape is normally unbounded at construction time of this room. @@ -46,98 +54,75 @@ public abstract class FreeSpaceExpansionRoom implements ExpansionRoom * does not overlap with any obstacle, and is as big as possible. * p_contained_points will remain contained in the shape, after it is completed. */ - public FreeSpaceExpansionRoom(TileShape p_shape, int p_layer) - { + public FreeSpaceExpansionRoom(TileShape p_shape, int p_layer) { shape = p_shape; layer = p_layer; doors = new LinkedList(); } - + /** * Adds p_door to the list of doors of this room. */ - public void add_door(ExpansionDoor p_door) - { + public void add_door(ExpansionDoor p_door) { this.doors.add(p_door); } - + /** * Returns the list of doors of this room to neighbour expansion rooms */ - public List get_doors() - { + public List get_doors() { return this.doors; } - + /** * Removes all doors from this room. */ - public void clear_doors() - { + public void clear_doors() { this.doors = new LinkedList(); } - - public void reset_doors() - { - for (ExpandableObject curr_door : this.doors) - { + + public void reset_doors() { + for (ExpandableObject curr_door : this.doors) { curr_door.reset(); } } - - public boolean remove_door(ExpandableObject p_door) - { + + public boolean remove_door(ExpandableObject p_door) { return this.doors.remove(p_door); } - + /** * Gets the shape of this room */ - public TileShape get_shape() - { + public TileShape get_shape() { return this.shape; } - + /** * sets the shape of this room */ - public void set_shape(TileShape p_shape) - { + public void set_shape(TileShape p_shape) { this.shape = p_shape; } - - public int get_layer() - { + + public int get_layer() { return this.layer; } - + /** * Checks, if this room has already a door to p_other */ - public boolean door_exists(ExpansionRoom p_other) - { - if (doors == null) - { + public boolean door_exists(ExpansionRoom p_other) { + if (doors == null) { return false; } Iterator it = doors.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { ExpansionDoor curr_door = it.next(); - if (curr_door.first_room == p_other || curr_door.second_room == p_other) - { + if (curr_door.first_room == p_other || curr_door.second_room == p_other) { return true; } } return false; } - - /** The layer of this room */ - private final int layer; - - /** The shape of this room */ - private TileShape shape; - - /** The list of doors to neighbour expansion rooms */ - private List doors; } diff --git a/src/main/java/net/freerouting/autoroute/IncompleteFreeSpaceExpansionRoom.java b/src/main/java/net/freerouting/autoroute/IncompleteFreeSpaceExpansionRoom.java index f2bd9852..54b62528 100644 --- a/src/main/java/net/freerouting/autoroute/IncompleteFreeSpaceExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/IncompleteFreeSpaceExpansionRoom.java @@ -20,44 +20,41 @@ package net.freerouting.autoroute; -import java.util.Collection; - import net.freerouting.geometry.planar.TileShape; +import java.util.Collection; + /** * An expansion room, whose shape is not yet completely calculated. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class IncompleteFreeSpaceExpansionRoom extends FreeSpaceExpansionRoom -{ - +public class IncompleteFreeSpaceExpansionRoom extends FreeSpaceExpansionRoom { + + /** + * A shape which should be contained in the completed shape. + */ + private TileShape contained_shape; + /** * Creates a new instance of IncompleteFreeSpaceExpansionRoom. * If p_shape == null means p_shape is the whole plane. */ - public IncompleteFreeSpaceExpansionRoom(TileShape p_shape, int p_layer, TileShape p_contained_shape) - { + public IncompleteFreeSpaceExpansionRoom(TileShape p_shape, int p_layer, TileShape p_contained_shape) { super(p_shape, p_layer); contained_shape = p_contained_shape; } - - public TileShape get_contained_shape() - { + + public TileShape get_contained_shape() { return this.contained_shape; } - - public void set_contained_shape(TileShape p_shape) - { + + public void set_contained_shape(TileShape p_shape) { this.contained_shape = p_shape; } - - public Collection get_target_doors() - { + + public Collection get_target_doors() { return new java.util.LinkedList(); } - - /** A shape which should be contained in the completed shape. */ - private TileShape contained_shape; } diff --git a/src/main/java/net/freerouting/autoroute/InsertFoundConnectionAlgo.java b/src/main/java/net/freerouting/autoroute/InsertFoundConnectionAlgo.java index 91c1eff6..6ad7cefc 100644 --- a/src/main/java/net/freerouting/autoroute/InsertFoundConnectionAlgo.java +++ b/src/main/java/net/freerouting/autoroute/InsertFoundConnectionAlgo.java @@ -19,76 +19,71 @@ */ package net.freerouting.autoroute; +import net.freerouting.board.*; +import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntPoint; import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.Polyline; - -import java.util.Iterator; -import java.util.Set; - import net.freerouting.library.Padstack; import net.freerouting.rules.ViaInfo; -import net.freerouting.board.ForcedViaAlgo; -import net.freerouting.board.PolylineTrace; -import net.freerouting.board.Trace; -import net.freerouting.board.Item; -import net.freerouting.board.RoutingBoard; -import net.freerouting.board.ItemSelectionFilter; -import net.freerouting.board.TestLevel; +import java.util.Iterator; +import java.util.Set; /** * Inserts the traces and vias of the connection found by the autoroute algorithm. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class InsertFoundConnectionAlgo -{ +public class InsertFoundConnectionAlgo { + + private final RoutingBoard board; + private final AutorouteControl ctrl; + private IntPoint last_corner = null; + private IntPoint first_corner = null; + + /** + * Creates a new instance of InsertFoundConnectionAlgo + */ + private InsertFoundConnectionAlgo(RoutingBoard p_board, AutorouteControl p_ctrl) { + this.board = p_board; + this.ctrl = p_ctrl; + } /** * Creates a new instance of InsertFoundConnectionAlgo . * Returns null, if the insertion did not succeed. */ public static InsertFoundConnectionAlgo get_instance(LocateFoundConnectionAlgo p_connection, - RoutingBoard p_board, AutorouteControl p_ctrl) - { - if (p_connection == null || p_connection.connection_items == null) - { + RoutingBoard p_board, AutorouteControl p_ctrl) { + if (p_connection == null || p_connection.connection_items == null) { return null; } int curr_layer = p_connection.target_layer; InsertFoundConnectionAlgo new_instance = new InsertFoundConnectionAlgo(p_board, p_ctrl); Iterator it = p_connection.connection_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { LocateFoundConnectionAlgoAnyAngle.ResultItem curr_new_item = it.next(); - if (!new_instance.insert_via(curr_new_item.corners[0], curr_layer, curr_new_item.layer)) - { + if (!new_instance.insert_via(curr_new_item.corners[0], curr_layer, curr_new_item.layer)) { return null; } curr_layer = curr_new_item.layer; - if (!new_instance.insert_trace(curr_new_item)) - { - if (p_board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) - { + if (!new_instance.insert_trace(curr_new_item)) { + if (p_board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) { System.out.print("InsertFoundConnectionAlgo: insert trace failed for net "); System.out.println(p_ctrl.net_no); } return null; } } - if (!new_instance.insert_via(new_instance.last_corner, curr_layer, p_connection.start_layer)) - { + if (!new_instance.insert_via(new_instance.last_corner, curr_layer, p_connection.start_layer)) { return null; } - if (p_connection.target_item instanceof PolylineTrace) - { + if (p_connection.target_item instanceof PolylineTrace) { PolylineTrace to_trace = (PolylineTrace) p_connection.target_item; p_board.connect_to_trace(new_instance.first_corner, to_trace, p_ctrl.trace_half_width[p_connection.start_layer], p_ctrl.trace_clearance_class_no); } - if (p_connection.start_item instanceof PolylineTrace) - { + if (p_connection.start_item instanceof PolylineTrace) { PolylineTrace to_trace = (PolylineTrace) p_connection.start_item; p_board.connect_to_trace(new_instance.last_corner, to_trace, p_ctrl.trace_half_width[p_connection.target_layer], p_ctrl.trace_clearance_class_no); } @@ -96,21 +91,12 @@ public static InsertFoundConnectionAlgo get_instance(LocateFoundConnectionAlgo p return new_instance; } - /** Creates a new instance of InsertFoundConnectionAlgo */ - private InsertFoundConnectionAlgo(RoutingBoard p_board, AutorouteControl p_ctrl) - { - this.board = p_board; - this.ctrl = p_ctrl; - } - /** * Inserts the trace by shoving aside obstacle traces and vias. * Returns false, that was not possible for the whole trace. */ - private boolean insert_trace(LocateFoundConnectionAlgoAnyAngle.ResultItem p_trace) - { - if (p_trace.corners.length == 1) - { + private boolean insert_trace(LocateFoundConnectionAlgoAnyAngle.ResultItem p_trace) { + if (p_trace.corners.length == 1) { this.last_corner = p_trace.corners[0]; return true; } @@ -123,24 +109,17 @@ private boolean insert_trace(LocateFoundConnectionAlgoAnyAngle.ResultItem p_trac // Look for pins att the start and the end of p_trace in case that neckdown is necessecary. net.freerouting.board.Pin start_pin = null; net.freerouting.board.Pin end_pin = null; - if (ctrl.with_neckdown) - { + if (ctrl.with_neckdown) { ItemSelectionFilter item_filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.PINS); Point curr_end_corner = p_trace.corners[0]; - for (int i = 0; i < 2; ++i) - { + for (int i = 0; i < 2; ++i) { Set picked_items = this.board.pick_items(curr_end_corner, p_trace.layer, item_filter); - for (Item curr_item : picked_items) - { + for (Item curr_item : picked_items) { net.freerouting.board.Pin curr_pin = (net.freerouting.board.Pin) curr_item; - if (curr_pin.contains_net(ctrl.net_no) && curr_pin.get_center().equals(curr_end_corner)) - { - if (i == 0) - { + if (curr_pin.contains_net(ctrl.net_no) && curr_pin.get_center().equals(curr_end_corner)) { + if (i == 0) { start_pin = curr_pin; - } - else - { + } else { end_pin = curr_pin; } } @@ -152,11 +131,9 @@ private boolean insert_trace(LocateFoundConnectionAlgoAnyAngle.ResultItem p_trac net_no_arr[0] = ctrl.net_no; int from_corner_no = 0; - for (int i = 1; i < p_trace.corners.length; ++i) - { + for (int i = 1; i < p_trace.corners.length; ++i) { Point[] curr_corner_arr = new Point[i - from_corner_no + 1]; - for (int j = from_corner_no; j <= i; ++j) - { + for (int j = from_corner_no; j <= i; ++j) { curr_corner_arr[j - from_corner_no] = p_trace.corners[j]; } Polyline insert_polyline = new Polyline(curr_corner_arr); @@ -165,86 +142,66 @@ private boolean insert_trace(LocateFoundConnectionAlgoAnyAngle.ResultItem p_trac ctrl.max_shove_trace_recursion_depth, ctrl.max_shove_via_recursion_depth, ctrl.max_spring_over_recursion_depth, Integer.MAX_VALUE, ctrl.pull_tight_accuracy, true, null); boolean neckdown_inserted = false; - if (ok_point != null && ok_point != insert_polyline.last_corner() && ctrl.with_neckdown && curr_corner_arr.length == 2) - { + if (ok_point != null && ok_point != insert_polyline.last_corner() && ctrl.with_neckdown && curr_corner_arr.length == 2) { neckdown_inserted = insert_neckdown(ok_point, curr_corner_arr[1], p_trace.layer, start_pin, end_pin); } - if (ok_point == insert_polyline.last_corner() || neckdown_inserted) - { + if (ok_point == insert_polyline.last_corner() || neckdown_inserted) { from_corner_no = i; - } - else if (ok_point == insert_polyline.first_corner() && i != p_trace.corners.length - 1) - { + } else if (ok_point == insert_polyline.first_corner() && i != p_trace.corners.length - 1) { // if ok_point == insert_polyline.first_corner() the spring over may have failed. // Spring over may correct the situation because an insertion, which is ok with clearance compensation // may cause violations without clearance compensation. // In this case repeating the insertion with more distant corners may allow the spring_over to correct the situation. - if (from_corner_no > 0) - { + if (from_corner_no > 0) { // p_trace.corners[i] may be inside the offset for the substitute trace around // a spring_over obstacle (if clearance compensation is off). - if (curr_corner_arr.length < 3) - { + if (curr_corner_arr.length < 3) { // first correction --from_corner_no; } } - if (board.get_test_level().ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (board.get_test_level().ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("InsertFoundConnectionAlgo: violation corrected"); } - } - else - { + } else { result = false; break; } } - if (board.get_test_level().ordinal() < TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { - for (int i = 0; i < p_trace.corners.length - 1; ++i) - { + if (board.get_test_level().ordinal() < TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { + for (int i = 0; i < p_trace.corners.length - 1; ++i) { Trace trace_stub = board.get_trace_tail(p_trace.corners[i], p_trace.layer, net_no_arr); - if (trace_stub != null) - { + if (trace_stub != null) { board.remove_item(trace_stub); } } } board.rules.set_pin_edge_to_turn_dist(saved_edge_to_turn_dist); - if (this.first_corner == null) - { + if (this.first_corner == null) { this.first_corner = p_trace.corners[0]; } this.last_corner = p_trace.corners[p_trace.corners.length - 1]; return result; } - boolean insert_neckdown(Point p_from_corner, Point p_to_corner, int p_layer, net.freerouting.board.Pin p_start_pin, net.freerouting.board.Pin p_end_pin) - { - if (p_start_pin != null) - { + boolean insert_neckdown(Point p_from_corner, Point p_to_corner, int p_layer, net.freerouting.board.Pin p_start_pin, net.freerouting.board.Pin p_end_pin) { + if (p_start_pin != null) { Point ok_point = try_neck_down(p_to_corner, p_from_corner, p_layer, p_start_pin, true); - if (ok_point == p_from_corner) - { + if (ok_point == p_from_corner) { return true; } } - if (p_end_pin != null) - { + if (p_end_pin != null) { Point ok_point = try_neck_down(p_from_corner, p_to_corner, p_layer, p_end_pin, false); - if (ok_point == p_to_corner) - { + if (ok_point == p_to_corner) { return true; } } return false; } - private Point try_neck_down(Point p_from_corner, Point p_to_corner, int p_layer, net.freerouting.board.Pin p_pin, boolean p_at_start) - { - if (!p_pin.is_on_layer(p_layer)) - { + private Point try_neck_down(Point p_from_corner, Point p_to_corner, int p_layer, net.freerouting.board.Pin p_pin, boolean p_at_start) { + if (!p_pin.is_on_layer(p_layer)) { return null; } FloatPoint pin_center = p_pin.get_center().to_float(); @@ -252,14 +209,12 @@ private Point try_neck_down(Point p_from_corner, Point p_to_corner, int p_layer, this.board.rules.clearance_matrix.value(ctrl.trace_clearance_class_no, p_pin.clearance_class_no(), p_layer); double pin_neck_down_distance = 2 * (0.5 * p_pin.get_max_width(p_layer) + curr_clearance); - if (pin_center.distance(p_to_corner.to_float()) >= pin_neck_down_distance) - { + if (pin_center.distance(p_to_corner.to_float()) >= pin_neck_down_distance) { return null; } int neck_down_halfwidth = p_pin.get_trace_neckdown_halfwidth(p_layer); - if (neck_down_halfwidth >= ctrl.trace_half_width[p_layer]) - { + if (neck_down_halfwidth >= ctrl.trace_half_width[p_layer]) { return null; } @@ -273,34 +228,29 @@ private Point try_neck_down(Point p_from_corner, Point p_to_corner, int p_layer, double ok_length = board.check_trace_segment(p_from_corner, p_to_corner, p_layer, net_no_arr, ctrl.trace_half_width[p_layer], ctrl.trace_clearance_class_no, true); - if (ok_length >= Integer.MAX_VALUE) - { + if (ok_length >= Integer.MAX_VALUE) { return p_from_corner; } ok_length -= TOLERANCE; Point neck_down_end_point; - if (ok_length <= TOLERANCE) - { + if (ok_length <= TOLERANCE) { neck_down_end_point = p_from_corner; - } - else - { + } else { FloatPoint float_neck_down_end_point = float_from_corner.change_length(float_to_corner, ok_length); neck_down_end_point = float_neck_down_end_point.round(); // add a corner in case neck_down_end_point is not exactly on the line from p_from_corner to p_to_corner boolean horizontal_first = Math.abs(float_from_corner.x - float_neck_down_end_point.x) >= - Math.abs(float_from_corner.y - float_neck_down_end_point.y); + Math.abs(float_from_corner.y - float_neck_down_end_point.y); IntPoint add_corner = LocateFoundConnectionAlgo.calculate_additional_corner(float_from_corner, float_neck_down_end_point, - horizontal_first, board.rules.get_trace_angle_restriction()).round(); + horizontal_first, board.rules.get_trace_angle_restriction()).round(); Point curr_ok_point = board.insert_forced_trace_segment(p_from_corner, add_corner, ctrl.trace_half_width[p_layer], p_layer, net_no_arr, ctrl.trace_clearance_class_no, ctrl.max_shove_trace_recursion_depth, ctrl.max_shove_via_recursion_depth, ctrl.max_spring_over_recursion_depth, Integer.MAX_VALUE, ctrl.pull_tight_accuracy, true, null); - if (curr_ok_point != add_corner) - { + if (curr_ok_point != add_corner) { return p_from_corner; } curr_ok_point = board.insert_forced_trace_segment(add_corner, @@ -308,22 +258,19 @@ private Point try_neck_down(Point p_from_corner, Point p_to_corner, int p_layer, ctrl.max_shove_trace_recursion_depth, ctrl.max_shove_via_recursion_depth, ctrl.max_spring_over_recursion_depth, Integer.MAX_VALUE, ctrl.pull_tight_accuracy, true, null); - if (curr_ok_point != neck_down_end_point) - { + if (curr_ok_point != neck_down_end_point) { return p_from_corner; } add_corner = LocateFoundConnectionAlgo.calculate_additional_corner(float_neck_down_end_point, float_to_corner, - !horizontal_first, board.rules.get_trace_angle_restriction()).round(); - if (!add_corner.equals(p_to_corner)) - { + !horizontal_first, board.rules.get_trace_angle_restriction()).round(); + if (!add_corner.equals(p_to_corner)) { curr_ok_point = board.insert_forced_trace_segment(neck_down_end_point, add_corner, ctrl.trace_half_width[p_layer], p_layer, net_no_arr, ctrl.trace_clearance_class_no, ctrl.max_shove_trace_recursion_depth, ctrl.max_shove_via_recursion_depth, ctrl.max_spring_over_recursion_depth, Integer.MAX_VALUE, ctrl.pull_tight_accuracy, true, null); - if (curr_ok_point != add_corner) - { + if (curr_ok_point != add_corner) { return p_from_corner; } neck_down_end_point = add_corner; @@ -343,47 +290,37 @@ private Point try_neck_down(Point p_from_corner, Point p_to_corner, int p_layer, * is possible at p_location with this mask and inserts the via. * Returns false, if no suitable via mmask was found or if the algorithm failed. */ - private boolean insert_via(Point p_location, int p_from_layer, int p_to_layer) - { - if (p_from_layer == p_to_layer) - { + private boolean insert_via(Point p_location, int p_from_layer, int p_to_layer) { + if (p_from_layer == p_to_layer) { return true; // no via necessary } int from_layer; int to_layer; // sort the input layers - if (p_from_layer < p_to_layer) - { + if (p_from_layer < p_to_layer) { from_layer = p_from_layer; to_layer = p_to_layer; - } - else - { + } else { from_layer = p_to_layer; to_layer = p_from_layer; } int[] net_no_arr = new int[1]; net_no_arr[0] = ctrl.net_no; ViaInfo via_info = null; - for (int i = 0; i < this.ctrl.via_rule.via_count(); ++i) - { + for (int i = 0; i < this.ctrl.via_rule.via_count(); ++i) { ViaInfo curr_via_info = this.ctrl.via_rule.get_via(i); Padstack curr_via_padstack = curr_via_info.get_padstack(); - if (curr_via_padstack.from_layer() > from_layer || curr_via_padstack.to_layer() < to_layer) - { + if (curr_via_padstack.from_layer() > from_layer || curr_via_padstack.to_layer() < to_layer) { continue; } if (ForcedViaAlgo.check(curr_via_info, p_location, net_no_arr, - this.ctrl.max_shove_trace_recursion_depth, this.ctrl.max_shove_via_recursion_depth, this.board)) - { + this.ctrl.max_shove_trace_recursion_depth, this.ctrl.max_shove_via_recursion_depth, this.board)) { via_info = curr_via_info; break; } } - if (via_info == null) - { - if (this.board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) - { + if (via_info == null) { + if (this.board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) { System.out.print("InsertFoundConnectionAlgo: via mask not found for net "); System.out.println(ctrl.net_no); } @@ -392,10 +329,8 @@ private boolean insert_via(Point p_location, int p_from_layer, int p_to_layer) // insert the via if (!ForcedViaAlgo.insert(via_info, p_location, net_no_arr, this.ctrl.trace_clearance_class_no, this.ctrl.trace_half_width, - this.ctrl.max_shove_trace_recursion_depth, this.ctrl.max_shove_via_recursion_depth, this.board)) - { - if (this.board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) - { + this.ctrl.max_shove_trace_recursion_depth, this.ctrl.max_shove_via_recursion_depth, this.board)) { + if (this.board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) { System.out.print("InsertFoundConnectionAlgo: forced via failed for net "); System.out.println(ctrl.net_no); } @@ -403,8 +338,4 @@ private boolean insert_via(Point p_location, int p_from_layer, int p_to_layer) } return true; } - private final RoutingBoard board; - private final AutorouteControl ctrl; - private IntPoint last_corner = null; - private IntPoint first_corner = null; } diff --git a/src/main/java/net/freerouting/autoroute/ItemAutorouteInfo.java b/src/main/java/net/freerouting/autoroute/ItemAutorouteInfo.java index 43d5affa..8042718c 100644 --- a/src/main/java/net/freerouting/autoroute/ItemAutorouteInfo.java +++ b/src/main/java/net/freerouting/autoroute/ItemAutorouteInfo.java @@ -20,128 +20,107 @@ package net.freerouting.autoroute; -import net.freerouting.board.ShapeSearchTree; - import net.freerouting.board.Item; +import net.freerouting.board.ShapeSearchTree; /** * Temporary data stored in board Items used in the autoroute algorithm * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class ItemAutorouteInfo -{ - public ItemAutorouteInfo(Item p_item) - { +public class ItemAutorouteInfo { + private final Item item; + /** + * Defines, if this item belongs to the start or destination set of + * the maze search algorithm + */ + private boolean start_info; + private Connection precalculated_connnection = null; + /** + * ExpansionRoom for pushing or ripping the this object for each tree shape. + */ + private ObstacleExpansionRoom[] expansion_room_arr; + + public ItemAutorouteInfo(Item p_item) { this.item = p_item; } + /** * Looks, if the corresponding item belongs to the start or destination set of the autoroute algorithm. * Only used, if the item belongs to the net, which will be currently routed. */ - public boolean is_start_info() - { + public boolean is_start_info() { return start_info; } - + /** * Sets, if the corresponding item belongs to the start or destination set of the autoroute algorithm. * Only used, if the item belongs to the net, which will be currently routed. */ - public void set_start_info(boolean p_value) - { + public void set_start_info(boolean p_value) { start_info = p_value; } - + /** - * Returns the precalculated connection of this item - * or null, if it is not yet precalculated. + * Returns the precalculated connection of this item + * or null, if it is not yet precalculated. */ - public Connection get_precalculated_connection() - { + public Connection get_precalculated_connection() { return this.precalculated_connnection; } - + /** - * Sets the precalculated connnection of this item. + * Sets the precalculated connnection of this item. */ - public void set_precalculated_connection(Connection p_connection) - { + public void set_precalculated_connection(Connection p_connection) { this.precalculated_connnection = p_connection; } - + /** * Gets the ExpansionRoom of of index p_index. * Creates it, if it is not yet existing. */ - public ObstacleExpansionRoom get_expansion_room(int p_index, ShapeSearchTree p_autoroute_tree) - { - if (expansion_room_arr == null) - { + public ObstacleExpansionRoom get_expansion_room(int p_index, ShapeSearchTree p_autoroute_tree) { + if (expansion_room_arr == null) { expansion_room_arr = new ObstacleExpansionRoom[this.item.tree_shape_count(p_autoroute_tree)]; } - if (p_index < 0 || p_index >= expansion_room_arr.length) - { + if (p_index < 0 || p_index >= expansion_room_arr.length) { System.out.println("ItemAutorouteInfo.get_expansion_room: p_index out of range"); return null; } - if (expansion_room_arr[p_index] == null) - { - expansion_room_arr[p_index] = new ObstacleExpansionRoom(this.item, p_index, p_autoroute_tree); + if (expansion_room_arr[p_index] == null) { + expansion_room_arr[p_index] = new ObstacleExpansionRoom(this.item, p_index, p_autoroute_tree); } return expansion_room_arr[p_index]; } - + /** * Resets the expansion rooms for autorouting the next connnection. */ - public void reset_doors() - { - if (expansion_room_arr != null) - { - for (ObstacleExpansionRoom curr_room: expansion_room_arr) - { - if (curr_room != null) - { + public void reset_doors() { + if (expansion_room_arr != null) { + for (ObstacleExpansionRoom curr_room : expansion_room_arr) { + if (curr_room != null) { curr_room.reset_doors(); } } } } - + /** * Draws the shapes of the expansion rooms of this info for testing purposes. */ - public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) - { - if (expansion_room_arr == null) - { + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { + if (expansion_room_arr == null) { return; } - for (ObstacleExpansionRoom curr_room : expansion_room_arr) - { - if (curr_room != null) - { + for (ObstacleExpansionRoom curr_room : expansion_room_arr) { + if (curr_room != null) { curr_room.draw(p_graphics, p_graphics_context, p_intensity); } } } - - /** - * Defines, if this item belongs to the start or destination set of - * the maze search algorithm - */ - private boolean start_info; - - private final Item item; - - private Connection precalculated_connnection = null; - - /** - * ExpansionRoom for pushing or ripping the this object for each tree shape. - */ - private ObstacleExpansionRoom[] expansion_room_arr; } diff --git a/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo.java b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo.java index 3126a341..e0c6db11 100644 --- a/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo.java +++ b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo.java @@ -20,71 +20,74 @@ */ package net.freerouting.autoroute; -import java.util.Collection; -import java.util.SortedSet; -import java.util.LinkedList; -import java.util.Iterator; - -import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.board.*; import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; import net.freerouting.geometry.planar.TileShape; -import net.freerouting.board.Connectable; -import net.freerouting.board.Item; -import net.freerouting.board.AngleRestriction; -import net.freerouting.board.ShapeSearchTree; -import net.freerouting.board.TestLevel; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.SortedSet; /** - * * @author Alfons Wirtz */ -public abstract class LocateFoundConnectionAlgo -{ +public abstract class LocateFoundConnectionAlgo { /** - * Returns a new Instance of LocateFoundConnectionAlgo or null, - * if p_destination_door is null. + * The new items implementing the found connection + */ + public final Collection connection_items; + /** + * The start item of the new routed connection + */ + public final Item start_item; + /** + * The layer of the connection to the start item + */ + public final int start_layer; + /** + * The destination item of the new routed connection + */ + public final Item target_item; + /** + * The layer of the connection to the target item + */ + public final int target_layer; + /** + * The array of backtrack doors from the destination to the start of a found + * connection of the maze search algorithm. + */ + protected final BacktrackElement[] backtrack_array; + protected final AutorouteControl ctrl; + protected final AngleRestriction angle_restriction; + protected final TestLevel test_level; + protected final TargetItemExpansionDoor start_door; + protected FloatPoint current_from_point; + protected FloatPoint previous_from_point; + protected int current_trace_layer; + protected int current_from_door_index; + protected int current_to_door_index; + protected int current_target_door_index; + protected TileShape current_target_shape; + /** + * Creates a new instance of LocateFoundConnectionAlgo */ - public static LocateFoundConnectionAlgo get_instance(MazeSearchAlgo.Result p_maze_search_result, AutorouteControl p_ctrl, - ShapeSearchTree p_search_tree, AngleRestriction p_angle_restriction, SortedSet p_ripped_item_list, TestLevel p_test_level) - { - if (p_maze_search_result == null) - { - return null; - } - LocateFoundConnectionAlgo result; - if (p_angle_restriction == AngleRestriction.NINETY_DEGREE || p_angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) - { - result = new LocateFoundConnectionAlgo45Degree(p_maze_search_result, p_ctrl, p_search_tree, p_angle_restriction, - p_ripped_item_list, p_test_level); - } - else - { - result = new LocateFoundConnectionAlgoAnyAngle(p_maze_search_result, p_ctrl, p_search_tree, p_angle_restriction, - p_ripped_item_list, p_test_level); - } - return result; - } - - /** Creates a new instance of LocateFoundConnectionAlgo */ protected LocateFoundConnectionAlgo(MazeSearchAlgo.Result p_maze_search_result, AutorouteControl p_ctrl, - ShapeSearchTree p_search_tree, AngleRestriction p_angle_restriction, SortedSet p_ripped_item_list, TestLevel p_test_level) - { + ShapeSearchTree p_search_tree, AngleRestriction p_angle_restriction, SortedSet p_ripped_item_list, TestLevel p_test_level) { this.ctrl = p_ctrl; this.angle_restriction = p_angle_restriction; this.test_level = p_test_level; Collection backtrack_list = backtrack(p_maze_search_result, p_ripped_item_list); this.backtrack_array = new BacktrackElement[backtrack_list.size()]; Iterator it = backtrack_list.iterator(); - for (int i = 0; i < backtrack_array.length; ++i) - { + for (int i = 0; i < backtrack_array.length; ++i) { this.backtrack_array[i] = it.next(); } this.connection_items = new LinkedList(); BacktrackElement start_info = this.backtrack_array[backtrack_array.length - 1]; - if (!(start_info.door instanceof TargetItemExpansionDoor)) - { + if (!(start_info.door instanceof TargetItemExpansionDoor)) { System.out.println("LocateFoundConnectionAlgo: ItemExpansionDoor expected for start_info.door"); this.start_item = null; this.start_layer = 0; @@ -98,25 +101,20 @@ protected LocateFoundConnectionAlgo(MazeSearchAlgo.Result p_maze_search_result, this.start_layer = start_door.room.get_layer(); this.current_from_door_index = 0; boolean at_fanout_end = false; - if (p_maze_search_result.destination_door instanceof TargetItemExpansionDoor) - { + if (p_maze_search_result.destination_door instanceof TargetItemExpansionDoor) { TargetItemExpansionDoor curr_destination_door = (TargetItemExpansionDoor) p_maze_search_result.destination_door; this.target_item = curr_destination_door.item; this.target_layer = curr_destination_door.room.get_layer(); this.current_from_point = calculate_starting_point(curr_destination_door, p_search_tree); - } - else if (p_maze_search_result.destination_door instanceof ExpansionDrill) - { + } else if (p_maze_search_result.destination_door instanceof ExpansionDrill) { // may happen only in case of fanout this.target_item = null; ExpansionDrill curr_drill = (ExpansionDrill) p_maze_search_result.destination_door; this.current_from_point = curr_drill.location.to_float(); this.target_layer = curr_drill.first_layer + p_maze_search_result.section_no_of_door; at_fanout_end = true; - } - else - { + } else { System.out.println("LocateFoundConnectionAlgo: unexpected type of destination_door"); this.target_item = null; this.target_layer = 0; @@ -127,50 +125,37 @@ else if (p_maze_search_result.destination_door instanceof ExpansionDrill) boolean connection_done = false; - while (!connection_done) - { + while (!connection_done) { boolean layer_changed = false; - if (at_fanout_end) - { + if (at_fanout_end) { // do not increase this.current_target_door_index layer_changed = true; - } - else - { + } else { this.current_target_door_index = this.current_from_door_index + 1; - while (current_target_door_index < this.backtrack_array.length && !layer_changed) - { - if (this.backtrack_array[this.current_target_door_index].door instanceof ExpansionDrill) - { + while (current_target_door_index < this.backtrack_array.length && !layer_changed) { + if (this.backtrack_array[this.current_target_door_index].door instanceof ExpansionDrill) { layer_changed = true; - } - else - { + } else { ++this.current_target_door_index; } } } - if (layer_changed) - { + if (layer_changed) { // the next trace leads to a via ExpansionDrill current_target_drill = (ExpansionDrill) this.backtrack_array[this.current_target_door_index].door; this.current_target_shape = TileShape.get_instance(current_target_drill.location); - } - else - { + } else { // the next trace leads to the final target connection_done = true; this.current_target_door_index = this.backtrack_array.length - 1; TileShape target_shape = ((Connectable) start_item).get_trace_connection_shape(p_search_tree, start_door.tree_entry_no); this.current_target_shape = target_shape.intersection(start_door.room.get_shape()); - if (this.current_target_shape.dimension() >= 2) - { + if (this.current_target_shape.dimension() >= 2) { // the target is a conduction area, make a save connection // by shrinking the shape by the trace halfwidth. double trace_half_width = this.ctrl.compensated_trace_half_width[start_door.room.get_layer()]; TileShape shrinked_shape = (TileShape) this.current_target_shape.offset(-trace_half_width); - if (!shrinked_shape.is_empty()) - { + if (!shrinked_shape.is_empty()) { this.current_target_shape = shrinked_shape; } } @@ -183,116 +168,31 @@ else if (p_maze_search_result.destination_door instanceof ExpansionDrill) } /** - * Calclates the next trace trace of the connection under construction. - * Returns null, if all traces are returned. + * Returns a new Instance of LocateFoundConnectionAlgo or null, + * if p_destination_door is null. */ - private ResultItem calculate_next_trace(boolean p_layer_changed, boolean p_at_fanout_end) - { - Collection corner_list = new LinkedList(); - corner_list.add(this.current_from_point); - if (!p_at_fanout_end) - { - FloatPoint adjusted_start_corner = this.adjust_start_corner(); - if (adjusted_start_corner != this.current_from_point) - { - FloatPoint add_corner = calculate_additional_corner(this.current_from_point, adjusted_start_corner, - true, this.angle_restriction); - corner_list.add(add_corner); - corner_list.add(adjusted_start_corner); - this.previous_from_point = this.current_from_point; - this.current_from_point = adjusted_start_corner; - } - } - FloatPoint prev_corner = this.current_from_point; - for (;;) - { - Collection next_corners = calculate_next_trace_corners(); - if (next_corners.isEmpty()) - { - break; - } - Iterator it = next_corners.iterator(); - while (it.hasNext()) - { - FloatPoint curr_next_corner = it.next(); - if (curr_next_corner != prev_corner) - { - corner_list.add(curr_next_corner); - this.previous_from_point = this.current_from_point; - this.current_from_point = curr_next_corner; - prev_corner = curr_next_corner; - } - } - } - - int next_layer = this.current_trace_layer; - if (p_layer_changed) - { - this.current_from_door_index = this.current_target_door_index + 1; - CompleteExpansionRoom next_room = this.backtrack_array[this.current_from_door_index].next_room; - if (next_room != null) - { - next_layer = next_room.get_layer(); - } - } - - // Round the new trace corners to Integer. - Collection rounded_corner_list = new LinkedList(); - Iterator it = corner_list.iterator(); - IntPoint prev_point = null; - while (it.hasNext()) - { - IntPoint curr_point = (it.next()).round(); - if (!curr_point.equals(prev_point)) - { - rounded_corner_list.add(curr_point); - prev_point = curr_point; - } + public static LocateFoundConnectionAlgo get_instance(MazeSearchAlgo.Result p_maze_search_result, AutorouteControl p_ctrl, + ShapeSearchTree p_search_tree, AngleRestriction p_angle_restriction, SortedSet p_ripped_item_list, TestLevel p_test_level) { + if (p_maze_search_result == null) { + return null; } - - // Construct the result item - IntPoint[] corner_arr = new IntPoint[rounded_corner_list.size()]; - Iterator it2 = rounded_corner_list.iterator(); - for (int i = 0; i < corner_arr.length; ++i) - { - corner_arr[i] = it2.next(); + LocateFoundConnectionAlgo result; + if (p_angle_restriction == AngleRestriction.NINETY_DEGREE || p_angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) { + result = new LocateFoundConnectionAlgo45Degree(p_maze_search_result, p_ctrl, p_search_tree, p_angle_restriction, + p_ripped_item_list, p_test_level); + } else { + result = new LocateFoundConnectionAlgoAnyAngle(p_maze_search_result, p_ctrl, p_search_tree, p_angle_restriction, + p_ripped_item_list, p_test_level); } - ResultItem result = new ResultItem(corner_arr, this.current_trace_layer); - this.current_trace_layer = next_layer; return result; } - /** - * Returns the next list of corners for the construction of the trace - * in calculate_next_trace. If the result is emppty, the trace is already completed. - */ - protected abstract Collection calculate_next_trace_corners(); - - /** Test display of the baktrack rooms. */ - public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { - for (int i = 0; i < backtrack_array.length; ++i) - { - CompleteExpansionRoom next_room = backtrack_array[i].next_room; - if (next_room != null) - { - next_room.draw(p_graphics, p_graphics_context, 0.2); - } - ExpandableObject next_door = backtrack_array[i].door; - if (next_door instanceof ExpansionDrill) - { - ((ExpansionDrill) next_door).draw(p_graphics, p_graphics_context, 0.2); - } - } - } - /** * Calculates the starting point of the next trace on p_from_door.item. * The implementation is not yet optimal for starting points on traces * or areas. */ - private static FloatPoint calculate_starting_point(TargetItemExpansionDoor p_from_door, ShapeSearchTree p_search_tree) - { + private static FloatPoint calculate_starting_point(TargetItemExpansionDoor p_from_door, ShapeSearchTree p_search_tree) { TileShape connection_shape = ((Connectable) p_from_door.item).get_trace_connection_shape(p_search_tree, p_from_door.tree_entry_no); connection_shape = connection_shape.intersection(p_from_door.room.get_shape()); @@ -304,65 +204,49 @@ private static FloatPoint calculate_starting_point(TargetItemExpansionDoor p_fro * the start door. * Returns null, if p_destination_door is null. */ - private static Collection backtrack(MazeSearchAlgo.Result p_maze_search_result, SortedSet p_ripped_item_list) - { - if (p_maze_search_result == null) - { + private static Collection backtrack(MazeSearchAlgo.Result p_maze_search_result, SortedSet p_ripped_item_list) { + if (p_maze_search_result == null) { return null; } Collection result = new LinkedList(); CompleteExpansionRoom curr_next_room = null; ExpandableObject curr_backtrack_door = p_maze_search_result.destination_door; MazeSearchElement curr_maze_search_element = curr_backtrack_door.get_maze_search_element(p_maze_search_result.section_no_of_door); - if (curr_backtrack_door instanceof TargetItemExpansionDoor) - { + if (curr_backtrack_door instanceof TargetItemExpansionDoor) { curr_next_room = ((TargetItemExpansionDoor) curr_backtrack_door).room; - } - else if (curr_backtrack_door instanceof ExpansionDrill) - { + } else if (curr_backtrack_door instanceof ExpansionDrill) { ExpansionDrill curr_drill = (ExpansionDrill) curr_backtrack_door; curr_next_room = curr_drill.room_arr[curr_drill.first_layer + p_maze_search_result.section_no_of_door]; - if (curr_maze_search_element.room_ripped) - { - for (CompleteExpansionRoom tmp_room : curr_drill.room_arr) - { - if (tmp_room instanceof ObstacleExpansionRoom) - { + if (curr_maze_search_element.room_ripped) { + for (CompleteExpansionRoom tmp_room : curr_drill.room_arr) { + if (tmp_room instanceof ObstacleExpansionRoom) { p_ripped_item_list.add(((ObstacleExpansionRoom) tmp_room).get_item()); } } } } BacktrackElement curr_backtrack_element = new BacktrackElement(curr_backtrack_door, p_maze_search_result.section_no_of_door, curr_next_room); - for (;;) - { + for (; ; ) { result.add(curr_backtrack_element); curr_backtrack_door = curr_maze_search_element.backtrack_door; - if (curr_backtrack_door == null) - { + if (curr_backtrack_door == null) { break; } int curr_section_no = curr_maze_search_element.section_no_of_backtrack_door; - if (curr_section_no >= curr_backtrack_door.maze_search_element_count()) - { + if (curr_section_no >= curr_backtrack_door.maze_search_element_count()) { System.out.println("LocateFoundConnectionAlgo: curr_section_no to big"); curr_section_no = curr_backtrack_door.maze_search_element_count() - 1; } - if (curr_backtrack_door instanceof ExpansionDrill) - { + if (curr_backtrack_door instanceof ExpansionDrill) { ExpansionDrill curr_drill = (ExpansionDrill) curr_backtrack_door; curr_next_room = curr_drill.room_arr[curr_section_no]; - } - else - { + } else { curr_next_room = curr_backtrack_door.other_room(curr_next_room); } curr_maze_search_element = curr_backtrack_door.get_maze_search_element(curr_section_no); curr_backtrack_element = new BacktrackElement(curr_backtrack_door, curr_section_no, curr_next_room); - if (curr_maze_search_element.room_ripped) - { - if (curr_next_room instanceof ObstacleExpansionRoom) - { + if (curr_maze_search_element.room_ripped) { + if (curr_next_room instanceof ObstacleExpansionRoom) { p_ripped_item_list.add(((ObstacleExpansionRoom) curr_next_room).get_item()); } } @@ -370,42 +254,14 @@ else if (curr_backtrack_door instanceof ExpansionDrill) return result; } - /** - * Adjusts the start corner, so that a trace starting at this corner is completely - * contained in the start room. - */ - private FloatPoint adjust_start_corner() - { - if (this.current_from_door_index < 0) - { - return this.current_from_point; - } - BacktrackElement curr_from_info = this.backtrack_array[this.current_from_door_index]; - if (curr_from_info.next_room == null) - { - return this.current_from_point; - } - double trace_half_width = this.ctrl.compensated_trace_half_width[this.current_trace_layer]; - TileShape shrinked_room_shape = (TileShape) curr_from_info.next_room.get_shape().offset(-trace_half_width); - if (shrinked_room_shape.is_empty() || shrinked_room_shape.contains(this.current_from_point)) - { - return this.current_from_point; - } - return shrinked_room_shape.nearest_point_approx(this.current_from_point).round().to_float(); - } - private static FloatPoint ninety_degree_corner(FloatPoint p_from_point, FloatPoint p_to_point, - boolean p_horizontal_first) - { + boolean p_horizontal_first) { double x; double y; - if (p_horizontal_first) - { + if (p_horizontal_first) { x = p_to_point.x; y = p_from_point.y; - } - else - { + } else { x = p_from_point.x; y = p_to_point.y; } @@ -413,63 +269,41 @@ private static FloatPoint ninety_degree_corner(FloatPoint p_from_point, FloatPoi } private static FloatPoint fortyfive_degree_corner(FloatPoint p_from_point, FloatPoint p_to_point, - boolean p_horizontal_first) - { + boolean p_horizontal_first) { double abs_dx = Math.abs(p_to_point.x - p_from_point.x); double abs_dy = Math.abs(p_to_point.y - p_from_point.y); double x; double y; - if (abs_dx <= abs_dy) - { - if (p_horizontal_first) - { + if (abs_dx <= abs_dy) { + if (p_horizontal_first) { x = p_to_point.x; - if (p_to_point.y >= p_from_point.y) - { + if (p_to_point.y >= p_from_point.y) { y = p_from_point.y + abs_dx; - } - else - { + } else { y = p_from_point.y - abs_dx; } - } - else - { + } else { x = p_from_point.x; - if (p_to_point.y > p_from_point.y) - { + if (p_to_point.y > p_from_point.y) { y = p_to_point.y - abs_dx; - } - else - { + } else { y = p_to_point.y + abs_dx; } } - } - else - { - if (p_horizontal_first) - { + } else { + if (p_horizontal_first) { y = p_from_point.y; - if (p_to_point.x > p_from_point.x) - { + if (p_to_point.x > p_from_point.x) { x = p_to_point.x - abs_dy; - } - else - { + } else { x = p_to_point.x + abs_dy; } - } - else - { + } else { y = p_to_point.y; - if (p_to_point.x > p_from_point.x) - { + if (p_to_point.x > p_from_point.x) { x = p_from_point.x + abs_dy; - } - else - { + } else { x = p_from_point.x - abs_dy; } } @@ -482,64 +316,140 @@ private static FloatPoint fortyfive_degree_corner(FloatPoint p_from_point, Float * and from the result corner to p_to_point p_angle_restriction is fulfilled. */ static FloatPoint calculate_additional_corner(FloatPoint p_from_point, FloatPoint p_to_point, - boolean p_horizontal_first, AngleRestriction p_angle_restriction) - { + boolean p_horizontal_first, AngleRestriction p_angle_restriction) { FloatPoint result; - if (p_angle_restriction == AngleRestriction.NINETY_DEGREE) - { + if (p_angle_restriction == AngleRestriction.NINETY_DEGREE) { result = ninety_degree_corner(p_from_point, p_to_point, p_horizontal_first); - } - else if (p_angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (p_angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) { result = fortyfive_degree_corner(p_from_point, p_to_point, p_horizontal_first); - } - else - { + } else { result = p_to_point; } return result; } - /** The new items implementing the found connection */ - public final Collection connection_items; - /** The start item of the new routed connection */ - public final Item start_item; - /** The layer of the connection to the start item */ - public final int start_layer; - /** The destination item of the new routed connection */ - public final Item target_item; - /** The layer of the connection to the target item */ - public final int target_layer; + /** - * The array of backtrack doors from the destination to the start of a found - * connection of the maze search algorithm. + * Calclates the next trace trace of the connection under construction. + * Returns null, if all traces are returned. */ - protected final BacktrackElement[] backtrack_array; - protected final AutorouteControl ctrl; - protected final AngleRestriction angle_restriction; - protected final TestLevel test_level; - protected final TargetItemExpansionDoor start_door; - protected FloatPoint current_from_point; - protected FloatPoint previous_from_point; - protected int current_trace_layer; - protected int current_from_door_index; - protected int current_to_door_index; - protected int current_target_door_index; - protected TileShape current_target_shape; + private ResultItem calculate_next_trace(boolean p_layer_changed, boolean p_at_fanout_end) { + Collection corner_list = new LinkedList(); + corner_list.add(this.current_from_point); + if (!p_at_fanout_end) { + FloatPoint adjusted_start_corner = this.adjust_start_corner(); + if (adjusted_start_corner != this.current_from_point) { + FloatPoint add_corner = calculate_additional_corner(this.current_from_point, adjusted_start_corner, + true, this.angle_restriction); + corner_list.add(add_corner); + corner_list.add(adjusted_start_corner); + this.previous_from_point = this.current_from_point; + this.current_from_point = adjusted_start_corner; + } + } + FloatPoint prev_corner = this.current_from_point; + for (; ; ) { + Collection next_corners = calculate_next_trace_corners(); + if (next_corners.isEmpty()) { + break; + } + Iterator it = next_corners.iterator(); + while (it.hasNext()) { + FloatPoint curr_next_corner = it.next(); + if (curr_next_corner != prev_corner) { + corner_list.add(curr_next_corner); + this.previous_from_point = this.current_from_point; + this.current_from_point = curr_next_corner; + prev_corner = curr_next_corner; + } + } + } + + int next_layer = this.current_trace_layer; + if (p_layer_changed) { + this.current_from_door_index = this.current_target_door_index + 1; + CompleteExpansionRoom next_room = this.backtrack_array[this.current_from_door_index].next_room; + if (next_room != null) { + next_layer = next_room.get_layer(); + } + } + + // Round the new trace corners to Integer. + Collection rounded_corner_list = new LinkedList(); + Iterator it = corner_list.iterator(); + IntPoint prev_point = null; + while (it.hasNext()) { + IntPoint curr_point = (it.next()).round(); + if (!curr_point.equals(prev_point)) { + rounded_corner_list.add(curr_point); + prev_point = curr_point; + } + } + + // Construct the result item + IntPoint[] corner_arr = new IntPoint[rounded_corner_list.size()]; + Iterator it2 = rounded_corner_list.iterator(); + for (int i = 0; i < corner_arr.length; ++i) { + corner_arr[i] = it2.next(); + } + ResultItem result = new ResultItem(corner_arr, this.current_trace_layer); + this.current_trace_layer = next_layer; + return result; + } + + /** + * Returns the next list of corners for the construction of the trace + * in calculate_next_trace. If the result is emppty, the trace is already completed. + */ + protected abstract Collection calculate_next_trace_corners(); + + /** + * Test display of the baktrack rooms. + */ + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { + for (int i = 0; i < backtrack_array.length; ++i) { + CompleteExpansionRoom next_room = backtrack_array[i].next_room; + if (next_room != null) { + next_room.draw(p_graphics, p_graphics_context, 0.2); + } + ExpandableObject next_door = backtrack_array[i].door; + if (next_door instanceof ExpansionDrill) { + ((ExpansionDrill) next_door).draw(p_graphics, p_graphics_context, 0.2); + } + } + } + + /** + * Adjusts the start corner, so that a trace starting at this corner is completely + * contained in the start room. + */ + private FloatPoint adjust_start_corner() { + if (this.current_from_door_index < 0) { + return this.current_from_point; + } + BacktrackElement curr_from_info = this.backtrack_array[this.current_from_door_index]; + if (curr_from_info.next_room == null) { + return this.current_from_point; + } + double trace_half_width = this.ctrl.compensated_trace_half_width[this.current_trace_layer]; + TileShape shrinked_room_shape = (TileShape) curr_from_info.next_room.get_shape().offset(-trace_half_width); + if (shrinked_room_shape.is_empty() || shrinked_room_shape.contains(this.current_from_point)) { + return this.current_from_point; + } + return shrinked_room_shape.nearest_point_approx(this.current_from_point).round().to_float(); + } /** * Type of a single item in the result list connection_items. * Used to create a new PolylineTrace. */ - protected static class ResultItem - { + protected static class ResultItem { - public ResultItem(IntPoint[] p_corners, int p_layer) - { + public final IntPoint[] corners; + public final int layer; + public ResultItem(IntPoint[] p_corners, int p_layer) { corners = p_corners; layer = p_layer; } - public final IntPoint[] corners; - public final int layer; } /** @@ -547,17 +457,15 @@ public ResultItem(IntPoint[] p_corners, int p_layer) * Next_room is the common room of the current door and the next * door in the backtrack list. */ - protected static class BacktrackElement - { + protected static class BacktrackElement { - private BacktrackElement(ExpandableObject p_door, int p_section_no_of_door, CompleteExpansionRoom p_room) - { + public final ExpandableObject door; + public final int section_no_of_door; + public final CompleteExpansionRoom next_room; + private BacktrackElement(ExpandableObject p_door, int p_section_no_of_door, CompleteExpansionRoom p_room) { door = p_door; section_no_of_door = p_section_no_of_door; next_room = p_room; } - public final ExpandableObject door; - public final int section_no_of_door; - public final CompleteExpansionRoom next_room; } } diff --git a/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo45Degree.java b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo45Degree.java index 51954b57..6b7b138a 100644 --- a/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo45Degree.java +++ b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgo45Degree.java @@ -21,75 +21,121 @@ package net.freerouting.autoroute; -import java.util.Collection; -import java.util.LinkedList; -import java.util.SortedSet; - -import net.freerouting.datastructures.Signum; - -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.FloatLine; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.Simplex; - -import net.freerouting.board.ShapeSearchTree; import net.freerouting.board.AngleRestriction; import net.freerouting.board.Item; +import net.freerouting.board.ShapeSearchTree; import net.freerouting.board.TestLevel; +import net.freerouting.datastructures.Signum; +import net.freerouting.geometry.planar.*; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.SortedSet; /** - * * @author Alfons Wirtz */ -public class LocateFoundConnectionAlgo45Degree extends LocateFoundConnectionAlgo -{ - +public class LocateFoundConnectionAlgo45Degree extends LocateFoundConnectionAlgo { + /** * Creates a new instance of LocateFoundConnectionAlgo45Degree */ public LocateFoundConnectionAlgo45Degree(MazeSearchAlgo.Result p_maze_search_result, - AutorouteControl p_ctrl, ShapeSearchTree p_search_tree, AngleRestriction p_angle_restriction, - SortedSet p_ripped_item_list, TestLevel p_test_level) - { + AutorouteControl p_ctrl, ShapeSearchTree p_search_tree, AngleRestriction p_angle_restriction, + SortedSet p_ripped_item_list, TestLevel p_test_level) { super(p_maze_search_result, p_ctrl, p_search_tree, p_angle_restriction, p_ripped_item_list, p_test_level); } - - protected Collection calculate_next_trace_corners() - { - Collection result = new LinkedList(); - - if (this.current_to_door_index > this.current_target_door_index) - { + + private static FloatPoint round_to_integer(FloatPoint p_point) { + return p_point.round().to_float(); + } + + /** + * Calculates, if the next 45-degree angle should be horizontal first when coming fromm + * p_from_point on p_from_door. + */ + private static boolean calc_horizontal_first_from_door(ExpandableObject p_from_door, + FloatPoint p_from_point, FloatPoint p_to_point) { + TileShape door_shape = p_from_door.get_shape(); + IntBox from_door_box = door_shape.bounding_box(); + if (p_from_door.get_dimension() != 1) { + return from_door_box.height() >= from_door_box.width(); + } + + FloatLine door_line_segment = door_shape.diagonal_corner_segment(); + FloatPoint left_corner; + FloatPoint right_corner; + if (door_line_segment.a.x < door_line_segment.b.x || door_line_segment.a.x == door_line_segment.b.x + && door_line_segment.a.y <= door_line_segment.b.y) { + left_corner = door_line_segment.a; + right_corner = door_line_segment.b; + } else { + left_corner = door_line_segment.b; + right_corner = door_line_segment.a; + } + double door_dx = right_corner.x - left_corner.x; + double door_dy = right_corner.y - left_corner.y; + double abs_door_dy = Math.abs(door_dy); + double door_max_width = Math.max(door_dx, abs_door_dy); + boolean result; + double door_half_max_width = 0.5 * door_max_width; + if (from_door_box.width() <= door_half_max_width) { + // door is about vertical + result = true; + } else if (from_door_box.height() <= door_half_max_width) { + // door is about horizontal + result = false; + } else { + double dx = p_to_point.x - p_from_point.x; + double dy = p_to_point.y - p_from_point.y; + if (left_corner.y < right_corner.y) { + // door is about right diagonal + if (Signum.of(dx) == Signum.of(dy)) { + result = Math.abs(dx) > Math.abs(dy); + } else { + result = Math.abs(dx) < Math.abs(dy); + } + + } else { + // door is about left diagonal + if (Signum.of(dx) == Signum.of(dy)) { + result = Math.abs(dx) < Math.abs(dy); + } else { + result = Math.abs(dx) > Math.abs(dy); + } + } + } + return result; + } + + protected Collection calculate_next_trace_corners() { + Collection result = new LinkedList(); + + if (this.current_to_door_index > this.current_target_door_index) { return result; } - + BacktrackElement curr_from_info = this.backtrack_array[this.current_to_door_index - 1]; - - if (curr_from_info.next_room == null) - { + + if (curr_from_info.next_room == null) { System.out.println("LocateFoundConnectionAlgo45Degree.calculate_next_trace_corners: next_room is null"); return result; } - + TileShape room_shape = curr_from_info.next_room.get_shape(); - + int trace_halfwidth = this.ctrl.compensated_trace_half_width[this.current_trace_layer]; int trace_halfwidth_add = trace_halfwidth + AutorouteEngine.TRACE_WIDTH_TOLERANCE; // add some tolerance for free space expansion rooms. int shrink_offset; - if (curr_from_info.next_room instanceof ObstacleExpansionRoom) - { - + if (curr_from_info.next_room instanceof ObstacleExpansionRoom) { + shrink_offset = trace_halfwidth; - } - else - { + } else { shrink_offset = trace_halfwidth_add; } - + TileShape shrinked_room_shape = (TileShape) room_shape.offset(-shrink_offset); - if (!shrinked_room_shape.is_empty()) - { + if (!shrinked_room_shape.is_empty()) { // enter the shrinked room shape by a 45 degree angle first FloatPoint nearest_room_point = shrinked_room_shape.nearest_point_approx(this.current_from_point); boolean horizontal_first = @@ -99,19 +145,15 @@ protected Collection calculate_next_trace_corners() horizontal_first, this.angle_restriction)); result.add(nearest_room_point); this.current_from_point = nearest_room_point; - } - else - { + } else { shrinked_room_shape = room_shape; } - - if (this.current_to_door_index == this.current_target_door_index) - { + + if (this.current_to_door_index == this.current_target_door_index) { FloatPoint nearest_point = this.current_target_shape.nearest_point_approx(this.current_from_point); nearest_point = round_to_integer(nearest_point); FloatPoint add_corner = calculate_additional_corner(this.current_from_point, nearest_point, true, this.angle_restriction); - if (!shrinked_room_shape.contains(add_corner)) - { + if (!shrinked_room_shape.contains(add_corner)) { add_corner = calculate_additional_corner(this.current_from_point, nearest_point, false, this.angle_restriction); } result.add(add_corner); @@ -119,53 +161,45 @@ protected Collection calculate_next_trace_corners() ++this.current_to_door_index; return result; } - + BacktrackElement curr_to_info = this.backtrack_array[this.current_to_door_index]; - if (!(curr_to_info.door instanceof ExpansionDoor)) - { + if (!(curr_to_info.door instanceof ExpansionDoor)) { System.out.println("LocateFoundConnectionAlgo45Degree.calculate_next_trace_corners: ExpansionDoor expected"); return result; } ExpansionDoor curr_to_door = (ExpansionDoor) curr_to_info.door; - - + + FloatPoint nearest_to_door_point; - if (curr_to_door.dimension == 2) - { + if (curr_to_door.dimension == 2) { // May not happen in free angle routing mode because then corners are cut off. TileShape to_door_shape = curr_to_door.get_shape(); - + TileShape shrinked_to_door_shape = (TileShape) to_door_shape.shrink(shrink_offset); nearest_to_door_point = shrinked_to_door_shape.nearest_point_approx(this.current_from_point); nearest_to_door_point = round_to_integer(nearest_to_door_point); - } - else - { + } else { FloatLine[] line_sections = curr_to_door.get_section_segments(trace_halfwidth); - if (curr_to_info.section_no_of_door >= line_sections.length) - { + if (curr_to_info.section_no_of_door >= line_sections.length) { System.out.println("LocateFoundConnectionAlgo45Degree.calculate_next_trace_corners: line_sections inconsistent"); return result; } FloatLine curr_line_section = line_sections[curr_to_info.section_no_of_door]; - nearest_to_door_point = curr_line_section.nearest_segment_point(this.current_from_point); - + nearest_to_door_point = curr_line_section.nearest_segment_point(this.current_from_point); + boolean nearest_to_door_point_ok = true; - if (curr_to_info.next_room != null) - { + if (curr_to_info.next_room != null) { Simplex next_room_shape = curr_to_info.next_room.get_shape().to_Simplex(); // with IntBox or IntOctagon the next calculation will not work, because they have // border lines of lenght 0. FloatPoint[] nearest_points = next_room_shape.nearest_border_points_approx(nearest_to_door_point, 2); - if (nearest_points.length >= 2) - { + if (nearest_points.length >= 2) { nearest_to_door_point_ok = nearest_points[1].distance(nearest_to_door_point) >= trace_halfwidth_add; } } - if (!nearest_to_door_point_ok) - { + if (!nearest_to_door_point_ok) { // may be the room has an acute (45 degree) angle at a corner of the door - nearest_to_door_point = curr_line_section.a.middle_point(curr_line_section.b); + nearest_to_door_point = curr_line_section.a.middle_point(curr_line_section.b); } } nearest_to_door_point = round_to_integer(nearest_to_door_point); @@ -177,163 +211,62 @@ protected Collection calculate_next_trace_corners() ++this.current_to_door_index; return result; } - - private static FloatPoint round_to_integer(FloatPoint p_point) - { - return p_point.round().to_float(); - } - - /** - * Calculates, if the next 45-degree angle should be horizontal first when coming fromm - * p_from_point on p_from_door. - */ - private static boolean calc_horizontal_first_from_door(ExpandableObject p_from_door, - FloatPoint p_from_point, FloatPoint p_to_point) - { - TileShape door_shape = p_from_door.get_shape(); - IntBox from_door_box = door_shape.bounding_box(); - if (p_from_door.get_dimension() != 1) - { - return from_door_box.height() >= from_door_box.width(); - } - - FloatLine door_line_segment = door_shape.diagonal_corner_segment(); - FloatPoint left_corner; - FloatPoint right_corner; - if (door_line_segment.a.x < door_line_segment.b.x || door_line_segment.a.x == door_line_segment.b.x - && door_line_segment.a.y <= door_line_segment.b.y) - { - left_corner = door_line_segment.a; - right_corner = door_line_segment.b; - } - else - { - left_corner = door_line_segment.b; - right_corner = door_line_segment.a; - } - double door_dx = right_corner.x - left_corner.x; - double door_dy = right_corner.y - left_corner.y; - double abs_door_dy = Math.abs(door_dy); - double door_max_width = Math.max(door_dx, abs_door_dy); - boolean result; - double door_half_max_width = 0.5 * door_max_width; - if (from_door_box.width() <= door_half_max_width) - { - // door is about vertical - result = true; - } - else if (from_door_box.height() <= door_half_max_width) - { - // door is about horizontal - result = false; - } - else - { - double dx = p_to_point.x - p_from_point.x; - double dy = p_to_point.y - p_from_point.y; - if (left_corner.y < right_corner.y) - { - // door is about right diagonal - if (Signum.of(dx) == Signum.of(dy)) - { - result = Math.abs(dx) > Math.abs(dy); - } - else - { - result = Math.abs(dx) < Math.abs(dy); - } - - } - else - { - // door is about left diagonal - if (Signum.of(dx) == Signum.of(dy)) - { - result = Math.abs(dx) < Math.abs(dy); - } - else - { - result = Math.abs(dx) > Math.abs(dy); - } - } - } - return result; - } - + /** * Calculates, if the 45-degree angle to the next door shape should be horizontal first when coming fromm * p_from_point. */ private boolean calc_horizontal_first_to_door(ExpandableObject p_to_door, - FloatPoint p_from_point, FloatPoint p_to_point) - { + FloatPoint p_from_point, FloatPoint p_to_point) { TileShape door_shape = p_to_door.get_shape(); IntBox from_door_box = door_shape.bounding_box(); - if (p_to_door.get_dimension() != 1) - { + if (p_to_door.get_dimension() != 1) { return from_door_box.height() <= from_door_box.width(); } FloatLine door_line_segment = door_shape.diagonal_corner_segment(); FloatPoint left_corner; FloatPoint right_corner; if (door_line_segment.a.x < door_line_segment.b.x || door_line_segment.a.x == door_line_segment.b.x - && door_line_segment.a.y <= door_line_segment.b.y) - { + && door_line_segment.a.y <= door_line_segment.b.y) { left_corner = door_line_segment.a; right_corner = door_line_segment.b; - } - else - { + } else { left_corner = door_line_segment.b; right_corner = door_line_segment.a; } double door_dx = right_corner.x - left_corner.x; double door_dy = right_corner.y - left_corner.y; - double abs_door_dy = Math.abs(door_dy); + double abs_door_dy = Math.abs(door_dy); double door_max_width = Math.max(door_dx, abs_door_dy); boolean result; double door_half_max_width = 0.5 * door_max_width; - if (from_door_box.width() <= door_half_max_width) - { + if (from_door_box.width() <= door_half_max_width) { // door is about vertical result = false; - } - else if (from_door_box.height() <= door_half_max_width) - { + } else if (from_door_box.height() <= door_half_max_width) { // door is about horizontal result = true; - } - else - { + } else { double dx = p_to_point.x - p_from_point.x; double dy = p_to_point.y - p_from_point.y; - if (left_corner.y < right_corner.y) - { + if (left_corner.y < right_corner.y) { // door is about right diagonal - if (Signum.of(dx) == Signum.of(dy)) - { + if (Signum.of(dx) == Signum.of(dy)) { result = Math.abs(dx) < Math.abs(dy); - } - else - { + } else { result = Math.abs(dx) > Math.abs(dy); } - - } - else - { + + } else { // door is about left diagonal - if (Signum.of(dx) == Signum.of(dy)) - { + if (Signum.of(dx) == Signum.of(dy)) { result = Math.abs(dx) > Math.abs(dy); - } - else - { + } else { result = Math.abs(dx) < Math.abs(dy); } } } return result; } - + } diff --git a/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgoAnyAngle.java b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgoAnyAngle.java index 14ed4313..0b5c1a2b 100644 --- a/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgoAnyAngle.java +++ b/src/main/java/net/freerouting/autoroute/LocateFoundConnectionAlgoAnyAngle.java @@ -20,169 +20,172 @@ package net.freerouting.autoroute; +import net.freerouting.board.AngleRestriction; +import net.freerouting.board.Item; +import net.freerouting.board.ShapeSearchTree; +import net.freerouting.board.TestLevel; import net.freerouting.geometry.planar.FloatLine; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.Side; import net.freerouting.geometry.planar.TileShape; import java.util.Collection; -import java.util.SortedSet; import java.util.LinkedList; - -import net.freerouting.board.ShapeSearchTree; -import net.freerouting.board.AngleRestriction; -import net.freerouting.board.Item; -import net.freerouting.board.TestLevel; +import java.util.SortedSet; /** * Calculates from the backtrack list the location of the traces and vias, * which realize a connection found by the maze search algorithm. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -class LocateFoundConnectionAlgoAnyAngle extends LocateFoundConnectionAlgo -{ - - /** Creates a new instance of LocateFoundConnectionAlgo */ +class LocateFoundConnectionAlgoAnyAngle extends LocateFoundConnectionAlgo { + + static private final double c_tolerance = 1.0; + + /** + * Creates a new instance of LocateFoundConnectionAlgo + */ protected LocateFoundConnectionAlgoAnyAngle(MazeSearchAlgo.Result p_maze_search_result, AutorouteControl p_ctrl, - ShapeSearchTree p_search_tree, AngleRestriction p_angle_restriction, - SortedSet p_ripped_item_list, TestLevel p_test_level) - { + ShapeSearchTree p_search_tree, AngleRestriction p_angle_restriction, + SortedSet p_ripped_item_list, TestLevel p_test_level) { super(p_maze_search_result, p_ctrl, p_search_tree, p_angle_restriction, p_ripped_item_list, p_test_level); } - + + /** + * Calculates the left most corner of the shape of p_to_info.door + * seen from the center of the common room with the previous door. + */ + private static FloatPoint calc_door_left_corner(BacktrackElement p_to_info) { + CompleteExpansionRoom from_room = p_to_info.door.other_room(p_to_info.next_room); + FloatPoint pole = from_room.get_shape().centre_of_gravity(); + TileShape curr_to_door_shape = p_to_info.door.get_shape(); + int left_most_corner_no = curr_to_door_shape.index_of_left_most_corner(pole); + return curr_to_door_shape.corner_approx(left_most_corner_no); + } + + /** + * Calculates the right most corner of the shape of p_to_info.door + * seen from the center of the common room with the previous door. + */ + private static FloatPoint calc_door_right_corner(BacktrackElement p_to_info) { + CompleteExpansionRoom from_room = p_to_info.door.other_room(p_to_info.next_room); + FloatPoint pole = from_room.get_shape().centre_of_gravity(); + TileShape curr_to_door_shape = p_to_info.door.get_shape(); + int right_most_corner_no = curr_to_door_shape.index_of_right_most_corner(pole); + return curr_to_door_shape.corner_approx(right_most_corner_no); + } + /** * Calculates a list with the next point of the trace under construction. * If the trace is completed, the result list will be empty. */ - protected Collection calculate_next_trace_corners() - { + protected Collection calculate_next_trace_corners() { Collection result = new LinkedList(); - if (this.current_to_door_index >= this.current_target_door_index) - { - if (this.current_to_door_index == this.current_target_door_index) - { + if (this.current_to_door_index >= this.current_target_door_index) { + if (this.current_to_door_index == this.current_target_door_index) { FloatPoint nearest_point = this.current_target_shape.nearest_point(this.current_from_point.round()).to_float(); ++this.current_to_door_index; result.add(nearest_point); } return result; } - + double trace_halfwidth_exact = this.ctrl.compensated_trace_half_width[this.current_trace_layer]; double trace_halfwidth_max = trace_halfwidth_exact + AutorouteEngine.TRACE_WIDTH_TOLERANCE; double trace_halfwidth_middle = trace_halfwidth_exact + c_tolerance; - + BacktrackElement curr_to_info = this.backtrack_array[this.current_to_door_index]; FloatPoint door_left_corner = calc_door_left_corner(curr_to_info); FloatPoint door_right_corner = calc_door_right_corner(curr_to_info); - if (this.current_from_point.side_of(door_left_corner, door_right_corner) != Side.ON_THE_RIGHT) - { + if (this.current_from_point.side_of(door_left_corner, door_right_corner) != Side.ON_THE_RIGHT) { // the door is already crossed at this.from_point - if (this.current_from_point.scalar_product(this.previous_from_point, door_left_corner) >= 0) - { + if (this.current_from_point.scalar_product(this.previous_from_point, door_left_corner) >= 0) { // Also the left corner of the door is passed. // That may not be the case if the door line is crossed almost parallel. door_left_corner = null; } - if(this.current_from_point.scalar_product(this.previous_from_point, door_right_corner) >= 0) - { + if (this.current_from_point.scalar_product(this.previous_from_point, door_right_corner) >= 0) { // Also the right corner of the door is passed. door_right_corner = null; } - if (door_left_corner == null && door_right_corner == null) - { + if (door_left_corner == null && door_right_corner == null) { // The door is completely passed. ++this.current_to_door_index; result.add(this.current_from_point); return result; } } - + // Calculate the visibility range for a trace line from current_from_point // through the interval from left_most_visible_point to right_most_visible_point, // by advancing the door index as far as possible, so that still somthing is visible. - + boolean end_of_trace = false; FloatPoint left_tangent_point = null; FloatPoint right_tangent_point = null; int new_door_ind = this.current_to_door_index; int left_ind = new_door_ind; int right_ind = new_door_ind; - int curr_door_ind = this.current_to_door_index + 1; + int curr_door_ind = this.current_to_door_index + 1; FloatPoint result_corner = null; - + // construct a maximum lenght straight line through the doors - - for (;;) - { + + for (; ; ) { left_tangent_point = this.current_from_point.right_tangential_point(door_left_corner, trace_halfwidth_max); - if (door_left_corner != null && left_tangent_point == null) - { - if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (door_left_corner != null && left_tangent_point == null) { + if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("LocateFoundConnectionAlgo.calculate_next_trace_corner: left tangent point is null"); } left_tangent_point = door_left_corner; } right_tangent_point = this.current_from_point.left_tangential_point(door_right_corner, trace_halfwidth_max); - if (door_right_corner != null && right_tangent_point == null) - { - if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (door_right_corner != null && right_tangent_point == null) { + if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("LocateFoundConnectionAlgo.calculate_next_trace_corner: right tangent point is null"); } right_tangent_point = door_right_corner; } if (left_tangent_point != null && right_tangent_point != null && - right_tangent_point.side_of(this.current_from_point, left_tangent_point) != Side.ON_THE_RIGHT) - { + right_tangent_point.side_of(this.current_from_point, left_tangent_point) != Side.ON_THE_RIGHT) { // The gap between left_most_visible_point and right_most_visible_point ist to small // for a trace with the current half width. - + double left_corner_distance = door_left_corner.distance(this.current_from_point); double right_corner_distance = door_right_corner.distance(this.current_from_point); - if ( left_corner_distance <= right_corner_distance) - { + if (left_corner_distance <= right_corner_distance) { new_door_ind = left_ind; result_corner = left_turn_next_corner(this.current_from_point, trace_halfwidth_max, door_left_corner, door_right_corner); - } - else - { + } else { new_door_ind = right_ind; result_corner = right_turn_next_corner(this.current_from_point, trace_halfwidth_max, door_right_corner, door_left_corner); } break; } - if (curr_door_ind >= this.current_target_door_index) - { + if (curr_door_ind >= this.current_target_door_index) { end_of_trace = true; break; } BacktrackElement next_to_info = this.backtrack_array[curr_door_ind]; FloatPoint next_left_corner = calc_door_left_corner(next_to_info); FloatPoint next_right_corner = calc_door_right_corner(next_to_info); - if (this.current_from_point.side_of(next_left_corner, next_right_corner) != Side.ON_THE_RIGHT) - { + if (this.current_from_point.side_of(next_left_corner, next_right_corner) != Side.ON_THE_RIGHT) { // the door may be already crossed at this.from_point - if (door_left_corner == null && this.current_from_point.scalar_product(this.previous_from_point, next_left_corner) >= 0) - { + if (door_left_corner == null && this.current_from_point.scalar_product(this.previous_from_point, next_left_corner) >= 0) { // Also the left corner of the door is passed. // That may not be the case if the door line is crossed almost parallel. next_left_corner = null; } - if(door_right_corner == null && this.current_from_point.scalar_product(this.previous_from_point, next_right_corner) >= 0) - { + if (door_right_corner == null && this.current_from_point.scalar_product(this.previous_from_point, next_right_corner) >= 0) { // Also the right corner of the door is passed. next_right_corner = null; } - if (next_left_corner == null && next_right_corner == null) - { + if (next_left_corner == null && next_right_corner == null) { // The door is completely passed. // Should not happen because the previous door was not passed compledtely. - if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("LocateFoundConnectionAlgo.calculate_next_trace_corner: next door passed unexpected"); } ++this.current_to_door_index; @@ -191,19 +194,17 @@ protected Collection calculate_next_trace_corners() } } if (door_left_corner != null && door_right_corner != null) - // otherwise the following side_of conditions may not be correct - // even if all parameter points are defined + // otherwise the following side_of conditions may not be correct + // even if all parameter points are defined { - if (next_left_corner.side_of(this.current_from_point, door_right_corner) == Side.ON_THE_RIGHT) - { + if (next_left_corner.side_of(this.current_from_point, door_right_corner) == Side.ON_THE_RIGHT) { // bend to the right new_door_ind = right_ind + 1; result_corner = right_turn_next_corner(this.current_from_point, trace_halfwidth_max, door_right_corner, next_left_corner); break; } - - if (next_right_corner.side_of(this.current_from_point, door_left_corner) == Side.ON_THE_LEFT) - { + + if (next_right_corner.side_of(this.current_from_point, door_left_corner) == Side.ON_THE_LEFT) { // bend to the left new_door_ind = left_ind + 1; result_corner = left_turn_next_corner(this.current_from_point, trace_halfwidth_max, door_left_corner, next_right_corner); @@ -211,99 +212,80 @@ protected Collection calculate_next_trace_corners() } } boolean visability_range_gets_smaller_on_the_right_side = (door_right_corner == null); - if (door_right_corner != null && next_right_corner.side_of(this.current_from_point, door_right_corner) != Side.ON_THE_RIGHT) - { + if (door_right_corner != null && next_right_corner.side_of(this.current_from_point, door_right_corner) != Side.ON_THE_RIGHT) { FloatPoint curr_tangential_point = this.current_from_point.left_tangential_point(next_right_corner, trace_halfwidth_max); - if (curr_tangential_point != null) - { + if (curr_tangential_point != null) { FloatLine check_line = new FloatLine(this.current_from_point, curr_tangential_point); - if ( check_line.segment_distance(door_right_corner) >= trace_halfwidth_max) - { + if (check_line.segment_distance(door_right_corner) >= trace_halfwidth_max) { visability_range_gets_smaller_on_the_right_side = true; } } } - if (visability_range_gets_smaller_on_the_right_side) - { + if (visability_range_gets_smaller_on_the_right_side) { // The visibility range gets smaller on the right side. door_right_corner = next_right_corner; right_ind = curr_door_ind; } boolean visability_range_gets_smaller_on_the_left_side = (door_left_corner == null); - if (door_left_corner != null && next_left_corner.side_of(this.current_from_point, door_left_corner) != Side.ON_THE_LEFT) - { + if (door_left_corner != null && next_left_corner.side_of(this.current_from_point, door_left_corner) != Side.ON_THE_LEFT) { FloatPoint curr_tangential_point = this.current_from_point.right_tangential_point(next_left_corner, trace_halfwidth_max); - if (curr_tangential_point != null) - { + if (curr_tangential_point != null) { FloatLine check_line = new FloatLine(this.current_from_point, curr_tangential_point); - if ( check_line.segment_distance(door_left_corner) >= trace_halfwidth_max) - { + if (check_line.segment_distance(door_left_corner) >= trace_halfwidth_max) { visability_range_gets_smaller_on_the_left_side = true; } } } - if (visability_range_gets_smaller_on_the_left_side) - { + if (visability_range_gets_smaller_on_the_left_side) { // The visibility range gets smaller on the left side. door_left_corner = next_left_corner; left_ind = curr_door_ind; } ++curr_door_ind; } - - if (end_of_trace) - { + + if (end_of_trace) { FloatPoint nearest_point = this.current_target_shape.nearest_point(this.current_from_point.round()).to_float(); result_corner = nearest_point; - if (left_tangent_point != null && nearest_point.side_of(this.current_from_point, left_tangent_point) == Side.ON_THE_LEFT) - { + if (left_tangent_point != null && nearest_point.side_of(this.current_from_point, left_tangent_point) == Side.ON_THE_LEFT) { // The nearest target point is to the left of the visible range, add another corner new_door_ind = left_ind + 1; FloatPoint target_right_corner = this.current_target_shape.corner_approx(this.current_target_shape.index_of_right_most_corner(this.current_from_point)); - FloatPoint curr_corner = right_left_tangential_point(this.current_from_point, target_right_corner, door_left_corner, trace_halfwidth_max); - if (curr_corner != null) - { + FloatPoint curr_corner = right_left_tangential_point(this.current_from_point, target_right_corner, door_left_corner, trace_halfwidth_max); + if (curr_corner != null) { result_corner = curr_corner; end_of_trace = false; } - } - else if (right_tangent_point != null && nearest_point.side_of(this.current_from_point, right_tangent_point) == Side.ON_THE_RIGHT) - { + } else if (right_tangent_point != null && nearest_point.side_of(this.current_from_point, right_tangent_point) == Side.ON_THE_RIGHT) { // The nearest target point is to the right of the visible range, add another corner FloatPoint target_left_corner = this.current_target_shape.corner_approx(this.current_target_shape.index_of_left_most_corner(this.current_from_point)); new_door_ind = right_ind + 1; - FloatPoint curr_corner = left_right_tangential_point(this.current_from_point, target_left_corner, door_right_corner, trace_halfwidth_max); - if (curr_corner != null) - { + FloatPoint curr_corner = left_right_tangential_point(this.current_from_point, target_left_corner, door_right_corner, trace_halfwidth_max); + if (curr_corner != null) { result_corner = curr_corner; end_of_trace = false; } } } - if (end_of_trace) - { + if (end_of_trace) { new_door_ind = this.current_target_door_index; } - + // Check clearance violation with the previous door shapes // and correct them in this case. - + FloatLine check_line = new FloatLine(this.current_from_point, result_corner); - int check_from_door_index = Math.max( this.current_to_door_index - 5 , this.current_from_door_index + 1); + int check_from_door_index = Math.max(this.current_to_door_index - 5, this.current_from_door_index + 1); FloatPoint corrected_result = null; int corrected_door_ind = 0; - for (int i = check_from_door_index; i < new_door_ind; ++i) - { + for (int i = check_from_door_index; i < new_door_ind; ++i) { FloatPoint curr_left_corner = calc_door_left_corner(this.backtrack_array[i]); double curr_dist = check_line.segment_distance(curr_left_corner); - if (Math.abs(curr_dist) < trace_halfwidth_middle) - { - FloatPoint curr_corrected_result = right_left_tangential_point(check_line.a, check_line.b, curr_left_corner, trace_halfwidth_max); - if (curr_corrected_result != null) - { - if(corrected_result == null || - curr_corrected_result.side_of(this.current_from_point, corrected_result) == Side.ON_THE_RIGHT) - { + if (Math.abs(curr_dist) < trace_halfwidth_middle) { + FloatPoint curr_corrected_result = right_left_tangential_point(check_line.a, check_line.b, curr_left_corner, trace_halfwidth_max); + if (curr_corrected_result != null) { + if (corrected_result == null || + curr_corrected_result.side_of(this.current_from_point, corrected_result) == Side.ON_THE_RIGHT) { corrected_door_ind = i; corrected_result = curr_corrected_result; } @@ -311,61 +293,29 @@ else if (right_tangent_point != null && nearest_point.side_of(this.current_from_ } FloatPoint curr_right_corner = calc_door_right_corner(this.backtrack_array[i]); curr_dist = check_line.segment_distance(curr_right_corner); - if (Math.abs(curr_dist) < trace_halfwidth_middle) - { - FloatPoint curr_corrected_result = left_right_tangential_point(check_line.a, check_line.b, curr_right_corner, trace_halfwidth_max); - if (curr_corrected_result != null) - { - if(corrected_result == null || - curr_corrected_result.side_of(this.current_from_point, corrected_result) == Side.ON_THE_LEFT) - { + if (Math.abs(curr_dist) < trace_halfwidth_middle) { + FloatPoint curr_corrected_result = left_right_tangential_point(check_line.a, check_line.b, curr_right_corner, trace_halfwidth_max); + if (curr_corrected_result != null) { + if (corrected_result == null || + curr_corrected_result.side_of(this.current_from_point, corrected_result) == Side.ON_THE_LEFT) { corrected_door_ind = i; corrected_result = curr_corrected_result; } } } } - if (corrected_result != null) - { + if (corrected_result != null) { result_corner = corrected_result; new_door_ind = Math.max(corrected_door_ind, this.current_to_door_index); } - + this.current_to_door_index = new_door_ind; - if(result_corner != null && result_corner != this.current_from_point) - { + if (result_corner != null && result_corner != this.current_from_point) { result.add(result_corner); } return result; } - - - /** - * Calculates the left most corner of the shape of p_to_info.door - * seen from the center of the common room with the previous door. - */ - private static FloatPoint calc_door_left_corner(BacktrackElement p_to_info) - { - CompleteExpansionRoom from_room = p_to_info.door.other_room(p_to_info.next_room); - FloatPoint pole = from_room.get_shape().centre_of_gravity(); - TileShape curr_to_door_shape = p_to_info.door.get_shape(); - int left_most_corner_no = curr_to_door_shape.index_of_left_most_corner(pole); - return curr_to_door_shape.corner_approx(left_most_corner_no); - } - - /** - * Calculates the right most corner of the shape of p_to_info.door - * seen from the center of the common room with the previous door. - */ - private static FloatPoint calc_door_right_corner(BacktrackElement p_to_info) - { - CompleteExpansionRoom from_room = p_to_info.door.other_room(p_to_info.next_room); - FloatPoint pole = from_room.get_shape().centre_of_gravity(); - TileShape curr_to_door_shape = p_to_info.door.get_shape(); - int right_most_corner_no = curr_to_door_shape.index_of_right_most_corner(pole); - return curr_to_door_shape.corner_approx(right_most_corner_no); - } - + /** * Calculates as first line the left side tangent from p_from_corner to * the circle with center p_to_corner and radius p_dist. @@ -374,23 +324,18 @@ private static FloatPoint calc_door_right_corner(BacktrackElement p_to_info) * The second line is than translated by the distance p_dist to the left. * Returned is the intersection of the first and the second line. */ - private FloatPoint right_turn_next_corner(FloatPoint p_from_corner, double p_dist, FloatPoint p_to_corner, FloatPoint p_next_corner) - { + private FloatPoint right_turn_next_corner(FloatPoint p_from_corner, double p_dist, FloatPoint p_to_corner, FloatPoint p_next_corner) { FloatPoint curr_tangential_point = p_from_corner.left_tangential_point(p_to_corner, p_dist); - if (curr_tangential_point == null) - { - if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (curr_tangential_point == null) { + if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("LocateFoundConnectionAlgo.right_turn_next_corner: left tangential point is null"); } return p_from_corner; } FloatLine first_line = new FloatLine(p_from_corner, curr_tangential_point); curr_tangential_point = p_to_corner.right_tangential_point(p_next_corner, 2 * p_dist + c_tolerance); - if (curr_tangential_point == null) - { - if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (curr_tangential_point == null) { + if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("LocateFoundConnectionAlgo.right_turn_next_corner: right tangential point is null"); } return p_from_corner; @@ -399,7 +344,7 @@ private FloatPoint right_turn_next_corner(FloatPoint p_from_corner, double p_dis second_line = second_line.translate(p_dist); return first_line.intersection(second_line); } - + /** * Calculates as first line the right side tangent from p_from_corner to * the circle with center p_to_corner and radius p_dist. @@ -408,23 +353,18 @@ private FloatPoint right_turn_next_corner(FloatPoint p_from_corner, double p_dis * The second line is than translated by the distance p_dist to the right. * Returned is the intersection of the first and the second line. */ - private FloatPoint left_turn_next_corner(FloatPoint p_from_corner, double p_dist, FloatPoint p_to_corner, FloatPoint p_next_corner) - { + private FloatPoint left_turn_next_corner(FloatPoint p_from_corner, double p_dist, FloatPoint p_to_corner, FloatPoint p_next_corner) { FloatPoint curr_tangential_point = p_from_corner.right_tangential_point(p_to_corner, p_dist); - if (curr_tangential_point == null) - { - if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (curr_tangential_point == null) { + if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("LocateFoundConnectionAlgo.left_turn_next_corner: right tangential point is null"); } return p_from_corner; } - FloatLine first_line = new FloatLine( p_from_corner, curr_tangential_point); + FloatLine first_line = new FloatLine(p_from_corner, curr_tangential_point); curr_tangential_point = p_to_corner.left_tangential_point(p_next_corner, 2 * p_dist + c_tolerance); - if (curr_tangential_point == null) - { - if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (curr_tangential_point == null) { + if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("LocateFoundConnectionAlgo.left_turn_next_corner: left tangential point is null"); } return p_from_corner; @@ -433,30 +373,25 @@ private FloatPoint left_turn_next_corner(FloatPoint p_from_corner, double p_dist second_line = second_line.translate(-p_dist); return first_line.intersection(second_line); } - + /** * Calculates the right tangential line from p_from_point and the * left tangential line from p_to_point to the circle * with center p_center and radius p_dist. * Returns the intersection of the 2 lines. */ - private FloatPoint right_left_tangential_point(FloatPoint p_from_point, FloatPoint p_to_point, FloatPoint p_center, double p_dist) - { + private FloatPoint right_left_tangential_point(FloatPoint p_from_point, FloatPoint p_to_point, FloatPoint p_center, double p_dist) { FloatPoint curr_tangential_point = p_from_point.right_tangential_point(p_center, p_dist); - if (curr_tangential_point == null) - { - if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (curr_tangential_point == null) { + if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("LocateFoundConnectionAlgo. right_left_tangential_point: right tangential point is null"); } return null; } FloatLine first_line = new FloatLine(p_from_point, curr_tangential_point); curr_tangential_point = p_to_point.left_tangential_point(p_center, p_dist); - if (curr_tangential_point == null) - { - if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (curr_tangential_point == null) { + if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("LocateFoundConnectionAlgo. right_left_tangential_point: left tangential point is null"); } return null; @@ -464,30 +399,25 @@ private FloatPoint right_left_tangential_point(FloatPoint p_from_point, FloatPoi FloatLine second_line = new FloatLine(p_to_point, curr_tangential_point); return first_line.intersection(second_line); } - + /** * Calculates the left tangential line from p_from_point and the * right tangential line from p_to_point to the circle * with center p_center and radius p_dist. * Returns the intersection of the 2 lines. */ - private FloatPoint left_right_tangential_point(FloatPoint p_from_point, FloatPoint p_to_point, FloatPoint p_center, double p_dist) - { + private FloatPoint left_right_tangential_point(FloatPoint p_from_point, FloatPoint p_to_point, FloatPoint p_center, double p_dist) { FloatPoint curr_tangential_point = p_from_point.left_tangential_point(p_center, p_dist); - if (curr_tangential_point == null) - { - if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (curr_tangential_point == null) { + if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("LocateFoundConnectionAlgo. left_right_tangential_point: left tangential point is null"); } return null; } FloatLine first_line = new FloatLine(p_from_point, curr_tangential_point); curr_tangential_point = p_to_point.right_tangential_point(p_center, p_dist); - if (curr_tangential_point == null) - { - if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (curr_tangential_point == null) { + if (this.test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("LocateFoundConnectionAlgo. left_right_tangential_point: right tangential point is null"); } return null; @@ -495,7 +425,5 @@ private FloatPoint left_right_tangential_point(FloatPoint p_from_point, FloatPoi FloatLine second_line = new FloatLine(p_to_point, curr_tangential_point); return first_line.intersection(second_line); } - - static private final double c_tolerance = 1.0; - + } diff --git a/src/main/java/net/freerouting/autoroute/MazeListElement.java b/src/main/java/net/freerouting/autoroute/MazeListElement.java index 40014525..b3b9827a 100644 --- a/src/main/java/net/freerouting/autoroute/MazeListElement.java +++ b/src/main/java/net/freerouting/autoroute/MazeListElement.java @@ -26,18 +26,56 @@ * Information for the maze expand Algorithm contained in expansion doors and drills * while the maze expanding algorithm is in progress. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class MazeListElement implements Comparable -{ - - /** Creates a new instance of ExpansionInfo */ +public class MazeListElement implements Comparable { + + /** + * The door or drill belonging to this MazeListElement + */ + final ExpandableObject door; + /** + * The section number of the door (or the layer of the drill) + */ + final int section_no_of_door; + /** + * The door, from which this door was expanded + */ + final ExpandableObject backtrack_door; + /** + * The section number of the backtrack door + */ + final int section_no_of_backtrack_door; + /** + * The wheighted distance to the start of the expansion + */ + final double expansion_value; + /** + * The expansion value plus the shortest distance to a destination. + * The list is sorted in ascending order by this value. + */ + final double sorting_value; + /** + * The the next room, which will be expanded from this maze search element + */ + final CompleteExpansionRoom next_room; + /** + * Point of the region of the expansion door, + * which has the shortest distance to the backtrack door. + */ + final FloatLine shape_entry; + final boolean room_ripped; + final MazeSearchElement.Adjustment adjustment; + final boolean already_checked; + + /** + * Creates a new instance of ExpansionInfo + */ public MazeListElement(ExpandableObject p_door, int p_section_no_of_door, - ExpandableObject p_backtrack_door, int p_section_no_of_backtrack_door, - double p_expansion_value, double p_sorting_value, - CompleteExpansionRoom p_next_room, FloatLine p_shape_entry, - boolean p_room_ripped, MazeSearchElement.Adjustment p_adjustment, boolean p_already_checked) - { + ExpandableObject p_backtrack_door, int p_section_no_of_backtrack_door, + double p_expansion_value, double p_sorting_value, + CompleteExpansionRoom p_next_room, FloatLine p_shape_entry, + boolean p_room_ripped, MazeSearchElement.Adjustment p_adjustment, boolean p_already_checked) { door = p_door; section_no_of_door = p_section_no_of_door; backtrack_door = p_backtrack_door; @@ -50,57 +88,17 @@ public MazeListElement(ExpandableObject p_door, int p_section_no_of_door, adjustment = p_adjustment; already_checked = p_already_checked; } - - public int compareTo(MazeListElement p_other) - { + + public int compareTo(MazeListElement p_other) { double compare_value = (this.sorting_value - p_other.sorting_value); // make shure, that the result cannot be 0, so that no element in the set is // skipped because of equal size. int result; - if (compare_value >= 0) - { + if (compare_value >= 0) { result = 1; - } - else - { + } else { result = -1; } return result; } - - /** The door or drill belonging to this MazeListElement */ - final ExpandableObject door; - - /** The section number of the door (or the layer of the drill) */ - final int section_no_of_door; - - /** The door, from which this door was expanded */ - final ExpandableObject backtrack_door; - - /** The section number of the backtrack door */ - final int section_no_of_backtrack_door; - - /** The wheighted distance to the start of the expansion */ - final double expansion_value; - - /** - * The expansion value plus the shortest distance to a destination. - * The list is sorted in ascending order by this value. - */ - final double sorting_value; - - /** The the next room, which will be expanded from this maze search element */ - final CompleteExpansionRoom next_room; - - /** - * Point of the region of the expansion door, - * which has the shortest distance to the backtrack door. - */ - final FloatLine shape_entry; - - final boolean room_ripped; - - final MazeSearchElement.Adjustment adjustment; - - final boolean already_checked; } diff --git a/src/main/java/net/freerouting/autoroute/MazeSearchAlgo.java b/src/main/java/net/freerouting/autoroute/MazeSearchAlgo.java index 97705208..4b60546e 100644 --- a/src/main/java/net/freerouting/autoroute/MazeSearchAlgo.java +++ b/src/main/java/net/freerouting/autoroute/MazeSearchAlgo.java @@ -19,39 +19,57 @@ */ package net.freerouting.autoroute; -import net.freerouting.geometry.planar.ConvexShape; -import net.freerouting.geometry.planar.FloatLine; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.IntOctagon; -import net.freerouting.geometry.planar.Line; - -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.TreeSet; -import java.util.Set; - -import net.freerouting.board.Connectable; -import net.freerouting.board.ForcedViaAlgo; -import net.freerouting.board.Item; -import net.freerouting.board.PolylineTrace; -import net.freerouting.board.ShapeSearchTree; -import net.freerouting.board.AngleRestriction; -import net.freerouting.board.SearchTreeObject; -import net.freerouting.board.ItemSelectionFilter; +import net.freerouting.board.*; +import net.freerouting.geometry.planar.*; + +import java.util.*; /** * Class for autorouting an incomplete connection via a maze search algorithm. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class MazeSearchAlgo -{ +public class MazeSearchAlgo { + + private static final int ALREADY_RIPPED_COSTS = 1; + /** + * The autoroute engine of this expansion algorithm. + */ + public final AutorouteEngine autoroute_engine; + final AutorouteControl ctrl; + /** + * The queue of of expanded elements used in this search algorithm. + */ + final java.util.SortedSet maze_expansion_list; + /** + * Used for calculating of a good lower bound for the distance between a new MazeExpansionElement + * and the destination set of the expansion. + */ + final DestinationDistance destination_distance; + /** + * The seach tree for expanding. It is the tree compensated for the current net. + */ + private final ShapeSearchTree search_tree; + private final java.util.Random random_generator = new java.util.Random(); + /** + * The destination door found by the expanding algorithm. + */ + private ExpandableObject destination_door = null; + private int section_no_of_destination_door = 0; + + /** + * Creates a new instance of MazeSearchAlgo + */ + MazeSearchAlgo(AutorouteEngine p_autoroute_engine, AutorouteControl p_ctrl) { + autoroute_engine = p_autoroute_engine; + ctrl = p_ctrl; + random_generator.setSeed(p_ctrl.ripup_costs); // To get reproducable random numbers in the ripup algorithm. + this.search_tree = p_autoroute_engine.autoroute_search_tree; + maze_expansion_list = new TreeSet(); + destination_distance = + new DestinationDistance(ctrl.trace_costs, ctrl.layer_active, + ctrl.min_normal_via_cost, ctrl.min_cheap_via_cost); + } /** * Initializes a new instance of MazeSearchAlgo for secrching a connection @@ -59,32 +77,109 @@ public class MazeSearchAlgo * Returns null, if the initialisation failed. */ public static MazeSearchAlgo get_instance(Set p_start_items, - Set p_destination_items, AutorouteEngine p_autoroute_database, AutorouteControl p_ctrl) - { + Set p_destination_items, AutorouteEngine p_autoroute_database, AutorouteControl p_ctrl) { MazeSearchAlgo new_instance = new MazeSearchAlgo(p_autoroute_database, p_ctrl); MazeSearchAlgo result; - if (new_instance.init(p_start_items, p_destination_items)) - { + if (new_instance.init(p_start_items, p_destination_items)) { result = new_instance; - } - else - { + } else { result = null; } return result; } - /** Creates a new instance of MazeSearchAlgo */ - MazeSearchAlgo(AutorouteEngine p_autoroute_engine, AutorouteControl p_ctrl) - { - autoroute_engine = p_autoroute_engine; - ctrl = p_ctrl; - random_generator.setSeed(p_ctrl.ripup_costs); // To get reproducable random numbers in the ripup algorithm. - this.search_tree = p_autoroute_engine.autoroute_search_tree; - maze_expansion_list = new TreeSet(); - destination_distance = - new DestinationDistance(ctrl.trace_costs, ctrl.layer_active, - ctrl.min_normal_via_cost, ctrl.min_cheap_via_cost); + /** + * Looks for pins with more than 1 nets and reduces shapes of thraces of foreign nets, + * which are already connected to such a pin, so that the pin center is not blocked for connection. + */ + private static void reduce_trace_shapes_at_tie_pins(Collection p_item_list, int p_own_net_no, ShapeSearchTree p_autoroute_tree) { + for (Item curr_item : p_item_list) { + if ((curr_item instanceof net.freerouting.board.Pin) && curr_item.net_count() > 1) { + Collection pin_contacts = curr_item.get_normal_contacts(); + net.freerouting.board.Pin curr_tie_pin = (net.freerouting.board.Pin) curr_item; + for (Item curr_contact : pin_contacts) { + if (!(curr_contact instanceof net.freerouting.board.PolylineTrace) || curr_contact.contains_net(p_own_net_no)) { + continue; + } + p_autoroute_tree.reduce_trace_shape_at_tie_pin(curr_tie_pin, (net.freerouting.board.PolylineTrace) curr_contact); + } + } + } + } + + /** + * Return the addditional cost factor for ripping the trace, if it is connected to a fanout via + * or 1, if no fanout via was found. + */ + private static double calc_fanout_via_ripup_cost_factor(net.freerouting.board.Trace p_trace) { + final double FANOUT_COST_CONST = 20000; + Collection curr_end_contacts; + for (int i = 0; i < 2; ++i) { + if (i == 0) { + curr_end_contacts = p_trace.get_start_contacts(); + } else { + curr_end_contacts = p_trace.get_end_contacts(); + } + if (curr_end_contacts.size() != 1) { + continue; + } + Item curr_trace_contact = curr_end_contacts.iterator().next(); + boolean protect_fanout_via = false; + if (curr_trace_contact instanceof net.freerouting.board.Pin && curr_trace_contact.first_layer() == curr_trace_contact.last_layer()) { + protect_fanout_via = true; + } else if (curr_trace_contact instanceof PolylineTrace && curr_trace_contact.get_fixed_state() == net.freerouting.board.FixedState.SHOVE_FIXED) { + // look for shove fixed exit traces of SMD-pins + PolylineTrace contact_trace = (PolylineTrace) curr_trace_contact; + if (contact_trace.corner_count() == 2) { + protect_fanout_via = true; + } + } + + + if (protect_fanout_via) { + double fanout_via_cost_factor = p_trace.get_half_width() / p_trace.get_length(); + fanout_via_cost_factor *= fanout_via_cost_factor; + fanout_via_cost_factor *= FANOUT_COST_CONST; + fanout_via_cost_factor = Math.max(fanout_via_cost_factor, 1); + return fanout_via_cost_factor; + } + } + return 1; + } + + /** + * Returns the perpendicular projection of p_from_segment onto p_to_segment. + * Returns null, if the projection is empty. + */ + private static FloatLine segment_projection(FloatLine p_from_segment, FloatLine p_to_segment) { + FloatLine check_segment = p_from_segment.adjust_direction(p_to_segment); + FloatLine first_projection = p_to_segment.segment_projection(check_segment); + FloatLine second_projection = p_to_segment.segment_projection_2(check_segment); + FloatLine result; + if (first_projection != null && second_projection != null) { + FloatPoint result_a; + if (first_projection.a == p_to_segment.a || second_projection.a == p_to_segment.a) { + result_a = p_to_segment.a; + } else if (first_projection.a.distance_square(p_to_segment.a) <= second_projection.a.distance_square(p_to_segment.a)) { + result_a = first_projection.a; + } else { + result_a = second_projection.a; + } + FloatPoint result_b; + if (first_projection.b == p_to_segment.b || second_projection.b == p_to_segment.b) { + result_b = p_to_segment.b; + } else if (first_projection.b.distance_square(p_to_segment.b) <= second_projection.b.distance_square(p_to_segment.b)) { + result_b = first_projection.b; + } else { + result_b = second_projection.b; + } + result = new FloatLine(result_a, result_b); + } else if (first_projection != null) { + result = first_projection; + } else { + result = second_projection; + } + return result; } /** @@ -93,13 +188,10 @@ public static MazeSearchAlgo get_instance(Set p_start_items, * the found destination is returned, from where the whole found connection * can be backtracked. Otherwise the return value will be null. */ - public Result find_connection() - { - while (occupy_next_element()) - { + public Result find_connection() { + while (occupy_next_element()) { } - if (this.destination_door == null) - { + if (this.destination_door == null) { return null; } return new Result(this.destination_door, this.section_no_of_destination_door); @@ -109,20 +201,16 @@ public Result find_connection() * Expands the next element in the maze expansion list. * Returns false, if the expansion list is exhausted or the destination is reached. */ - public boolean occupy_next_element() - { - if (this.destination_door != null) - { + public boolean occupy_next_element() { + if (this.destination_door != null) { return false; // destination already reached } MazeListElement list_element = null; MazeSearchElement curr_door_section = null; // Search the next element, which is not yet expanded. boolean next_element_found = false; - while (!maze_expansion_list.isEmpty()) - { - if (this.autoroute_engine.is_stop_requested()) - { + while (!maze_expansion_list.isEmpty()) { + if (this.autoroute_engine.is_stop_requested()) { return false; } Iterator it = maze_expansion_list.iterator(); @@ -130,14 +218,12 @@ public boolean occupy_next_element() int curr_section_no = list_element.section_no_of_door; curr_door_section = list_element.door.get_maze_search_element(curr_section_no); it.remove(); - if (!curr_door_section.is_occupied) - { + if (!curr_door_section.is_occupied) { next_element_found = true; break; } } - if (!next_element_found) - { + if (!next_element_found) { return false; } curr_door_section.backtrack_door = list_element.backtrack_door; @@ -145,40 +231,33 @@ public boolean occupy_next_element() curr_door_section.room_ripped = list_element.room_ripped; curr_door_section.adjustment = list_element.adjustment; - if (list_element.door instanceof DrillPage) - { + if (list_element.door instanceof DrillPage) { expand_to_drills_of_page(list_element); return true; } - if (list_element.door instanceof TargetItemExpansionDoor) - { + if (list_element.door instanceof TargetItemExpansionDoor) { TargetItemExpansionDoor curr_door = (TargetItemExpansionDoor) list_element.door; - if (curr_door.is_destination_door()) - { + if (curr_door.is_destination_door()) { // The destination is reached. this.destination_door = curr_door; this.section_no_of_destination_door = list_element.section_no_of_door; return false; } } - if (ctrl.is_fanout && list_element.door instanceof ExpansionDrill && list_element.backtrack_door instanceof ExpansionDrill) - { + if (ctrl.is_fanout && list_element.door instanceof ExpansionDrill && list_element.backtrack_door instanceof ExpansionDrill) { // algorithm completed after the first drill; this.destination_door = list_element.door; this.section_no_of_destination_door = list_element.section_no_of_door; return false; } if (ctrl.vias_allowed && list_element.door instanceof ExpansionDrill - && !(list_element.backtrack_door instanceof ExpansionDrill)) - { + && !(list_element.backtrack_door instanceof ExpansionDrill)) { expand_to_other_layers(list_element); } - if (list_element.next_room != null) - { - if (!expand_to_room_doors(list_element)) - { + if (list_element.next_room != null) { + if (!expand_to_room_doors(list_element)) { return true; // occupation by ripup is delayed or nothing was expanded // In case nothing was expanded allow the section to be occupied from // somewhere else, if the next room is thin. @@ -193,34 +272,28 @@ public boolean occupy_next_element() * Returns true, if the from door section has to be occupied, * and false, if the occupation for is delayed. */ - private boolean expand_to_room_doors(MazeListElement p_list_element) - { + private boolean expand_to_room_doors(MazeListElement p_list_element) { // Complete the neigbour rooms to make shure, that the // doors of this room will not change later on. int layer_no = p_list_element.next_room.get_layer(); boolean layer_active = ctrl.layer_active[layer_no]; - if (!layer_active) - { - if (autoroute_engine.board.layer_structure.arr[layer_no].is_signal) - { + if (!layer_active) { + if (autoroute_engine.board.layer_structure.arr[layer_no].is_signal) { return true; } } double half_width = ctrl.compensated_trace_half_width[layer_no]; boolean curr_door_is_small = false; - if (p_list_element.door instanceof ExpansionDoor) - { + if (p_list_element.door instanceof ExpansionDoor) { double half_width_add = half_width + AutorouteEngine.TRACE_WIDTH_TOLERANCE; ExpansionDoor curr_door = (ExpansionDoor) p_list_element.door; - if (this.ctrl.with_neckdown) - { + if (this.ctrl.with_neckdown) { // try evtl. neckdown at a destination pin double neck_down_half_width = check_neck_down_at_dest_pin(p_list_element.next_room); - if (neck_down_half_width > 0) - { + if (neck_down_half_width > 0) { half_width_add = Math.min(half_width_add, neck_down_half_width); half_width = half_width_add; } @@ -232,15 +305,12 @@ private boolean expand_to_room_doors(MazeListElement p_list_element) FloatPoint shape_entry_middle = p_list_element.shape_entry.a.middle_point(p_list_element.shape_entry.b); - if (this.ctrl.with_neckdown && p_list_element.door instanceof TargetItemExpansionDoor) - { + if (this.ctrl.with_neckdown && p_list_element.door instanceof TargetItemExpansionDoor) { // try evtl. neckdown at a start pin Item start_item = ((TargetItemExpansionDoor) p_list_element.door).item; - if (start_item instanceof net.freerouting.board.Pin) - { + if (start_item instanceof net.freerouting.board.Pin) { double neckdown_half_width = ((net.freerouting.board.Pin) start_item).get_trace_neckdown_halfwidth(layer_no); - if (neckdown_half_width > 0) - { + if (neckdown_half_width > 0) { half_width = Math.min(half_width, neckdown_half_width); } } @@ -248,158 +318,121 @@ private boolean expand_to_room_doors(MazeListElement p_list_element) } boolean next_room_is_thick = true; - if (p_list_element.next_room instanceof ObstacleExpansionRoom) - { + if (p_list_element.next_room instanceof ObstacleExpansionRoom) { next_room_is_thick = room_shape_is_thick((ObstacleExpansionRoom) p_list_element.next_room); - } - else - { + } else { TileShape next_room_shape = p_list_element.next_room.get_shape(); - if (next_room_shape.min_width() < 2 * half_width) - { + if (next_room_shape.min_width() < 2 * half_width) { next_room_is_thick = false; // to prevent probles with the opposite side - } - else if (!p_list_element.already_checked && p_list_element.door.get_dimension() == 1 && !curr_door_is_small) - { + } else if (!p_list_element.already_checked && p_list_element.door.get_dimension() == 1 && !curr_door_is_small) { // The algorithm below works only, if p_location is on the border of p_room_shape. // That is only the case for 1 dimensional doors. // For small doors the check is done in check_leaving_via below. FloatPoint[] nearest_points = next_room_shape.nearest_border_points_approx(shape_entry_middle, 2); - if (nearest_points.length < 2) - { + if (nearest_points.length < 2) { System.out.println("MazeSearchAlgo.expand_to_room_doors: nearest_points.length == 2 expected"); next_room_is_thick = false; - } - else - { + } else { double curr_dist = nearest_points[1].distance(shape_entry_middle); next_room_is_thick = (curr_dist > half_width + 1); } } } - if (!layer_active && p_list_element.door instanceof ExpansionDrill) - { + if (!layer_active && p_list_element.door instanceof ExpansionDrill) { // check for drill to a foreign conduction area on split plane. Point drill_location = ((ExpansionDrill) p_list_element.door).location; ItemSelectionFilter filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.CONDUCTION); Set picked_items = autoroute_engine.board.pick_items(drill_location, layer_no, filter); - for (Item curr_item : picked_items) - { - if (!curr_item.contains_net(ctrl.net_no)) - { + for (Item curr_item : picked_items) { + if (!curr_item.contains_net(ctrl.net_no)) { return true; } } } boolean something_expanded = false; - if (expand_to_target_doors(p_list_element, next_room_is_thick, curr_door_is_small, shape_entry_middle)) - { + if (expand_to_target_doors(p_list_element, next_room_is_thick, curr_door_is_small, shape_entry_middle)) { something_expanded = true; } - if (!layer_active) - { + if (!layer_active) { return true; } int ripup_costs = 0; - if (p_list_element.next_room instanceof FreeSpaceExpansionRoom) - { - if (!p_list_element.already_checked) - { - if (curr_door_is_small) - { + if (p_list_element.next_room instanceof FreeSpaceExpansionRoom) { + if (!p_list_element.already_checked) { + if (curr_door_is_small) { boolean enter_through_small_door = false; - if (next_room_is_thick) - { + if (next_room_is_thick) { // check to enter the thick room from a ripped item through a small door (after ripup) enter_through_small_door = check_leaving_ripped_item(p_list_element); } - if (!enter_through_small_door) - { + if (!enter_through_small_door) { return something_expanded; } } } - } - else if (p_list_element.next_room instanceof ObstacleExpansionRoom) - { + } else if (p_list_element.next_room instanceof ObstacleExpansionRoom) { ObstacleExpansionRoom obstacle_room = (ObstacleExpansionRoom) p_list_element.next_room; - if (!p_list_element.already_checked) - { + if (!p_list_element.already_checked) { boolean room_rippable = false; - if (this.ctrl.ripup_allowed) - { + if (this.ctrl.ripup_allowed) { ripup_costs = check_ripup(p_list_element, obstacle_room.get_item(), curr_door_is_small); room_rippable = (ripup_costs >= 0); } - if (ripup_costs != ALREADY_RIPPED_COSTS && next_room_is_thick) - { + if (ripup_costs != ALREADY_RIPPED_COSTS && next_room_is_thick) { Item obstacle_item = obstacle_room.get_item(); - if (!curr_door_is_small && this.ctrl.max_shove_trace_recursion_depth > 0 && obstacle_item instanceof net.freerouting.board.PolylineTrace) - { - if (!shove_trace_room(p_list_element, obstacle_room)) - { - if (ripup_costs > 0) - { + if (!curr_door_is_small && this.ctrl.max_shove_trace_recursion_depth > 0 && obstacle_item instanceof net.freerouting.board.PolylineTrace) { + if (!shove_trace_room(p_list_element, obstacle_room)) { + if (ripup_costs > 0) { // delay the occupation by ripup to allow shoving the room by another door sections. MazeListElement new_element = new MazeListElement(p_list_element.door, p_list_element.section_no_of_door, - p_list_element.backtrack_door, p_list_element.section_no_of_backtrack_door, - p_list_element.expansion_value + ripup_costs, p_list_element.sorting_value + ripup_costs, - p_list_element.next_room, p_list_element.shape_entry, true, - p_list_element.adjustment, true); + p_list_element.backtrack_door, p_list_element.section_no_of_backtrack_door, + p_list_element.expansion_value + ripup_costs, p_list_element.sorting_value + ripup_costs, + p_list_element.next_room, p_list_element.shape_entry, true, + p_list_element.adjustment, true); this.maze_expansion_list.add(new_element); } return something_expanded; } } } - if (!room_rippable) - { + if (!room_rippable) { return true; } } } - for (ExpansionDoor to_door : p_list_element.next_room.get_doors()) - { - if (to_door == p_list_element.door) - { + for (ExpansionDoor to_door : p_list_element.next_room.get_doors()) { + if (to_door == p_list_element.door) { continue; } - if (expand_to_door(to_door, p_list_element, ripup_costs, next_room_is_thick, MazeSearchElement.Adjustment.NONE)) - { + if (expand_to_door(to_door, p_list_element, ripup_costs, next_room_is_thick, MazeSearchElement.Adjustment.NONE)) { something_expanded = true; } } // Expand also the drill pages intersecting the room. - if (ctrl.vias_allowed && !(p_list_element.door instanceof ExpansionDrill)) - { - if ((something_expanded || next_room_is_thick) && p_list_element.next_room instanceof CompleteFreeSpaceExpansionRoom) - { + if (ctrl.vias_allowed && !(p_list_element.door instanceof ExpansionDrill)) { + if ((something_expanded || next_room_is_thick) && p_list_element.next_room instanceof CompleteFreeSpaceExpansionRoom) { // avoid setting something_expanded to true when next_room is thin to allow occupying by different sections of the door Collection overlapping_drill_pages = this.autoroute_engine.drill_page_array.overlapping_pages(p_list_element.next_room.get_shape()); { - for (DrillPage to_drill_page : overlapping_drill_pages) - { + for (DrillPage to_drill_page : overlapping_drill_pages) { expand_to_drill_page(to_drill_page, p_list_element); something_expanded = true; } } - } - else if (p_list_element.next_room instanceof ObstacleExpansionRoom) - { + } else if (p_list_element.next_room instanceof ObstacleExpansionRoom) { Item curr_obstacle_item = ((ObstacleExpansionRoom) p_list_element.next_room).get_item(); - if (curr_obstacle_item instanceof net.freerouting.board.Via) - { + if (curr_obstacle_item instanceof net.freerouting.board.Via) { net.freerouting.board.Via curr_via = (net.freerouting.board.Via) curr_obstacle_item; ExpansionDrill via_drill_info = curr_via.get_autoroute_drill_info(this.autoroute_engine.autoroute_search_tree); expand_to_drill(via_drill_info, p_list_element, ripup_costs); @@ -410,39 +443,33 @@ else if (p_list_element.next_room instanceof ObstacleExpansionRoom) return something_expanded; } - /** Expand the target doors of the room. Returns true, if at leat 1 target door was expanded */ + /** + * Expand the target doors of the room. Returns true, if at leat 1 target door was expanded + */ private boolean expand_to_target_doors(MazeListElement p_list_element, - boolean p_next_room_is_thick, boolean p_curr_door_is_small, FloatPoint p_shape_entry_middle) - { - if (p_curr_door_is_small) - { + boolean p_next_room_is_thick, boolean p_curr_door_is_small, FloatPoint p_shape_entry_middle) { + if (p_curr_door_is_small) { boolean enter_through_small_door = false; - if (p_list_element.door instanceof ExpansionDoor) - { + if (p_list_element.door instanceof ExpansionDoor) { CompleteExpansionRoom from_room = ((ExpansionDoor) p_list_element.door).other_room(p_list_element.next_room); - if (from_room instanceof ObstacleExpansionRoom) - { + if (from_room instanceof ObstacleExpansionRoom) { // otherwise entering through the small door may fail, because it was not checked. enter_through_small_door = true; } } - if (!enter_through_small_door) - { + if (!enter_through_small_door) { return false; } } boolean result = false; - for (TargetItemExpansionDoor to_door : p_list_element.next_room.get_target_doors()) - { - if (to_door == p_list_element.door) - { + for (TargetItemExpansionDoor to_door : p_list_element.next_room.get_target_doors()) { + if (to_door == p_list_element.door) { continue; } TileShape target_shape = ((Connectable) to_door.item).get_trace_connection_shape(this.autoroute_engine.autoroute_search_tree, to_door.tree_entry_no); FloatPoint connection_point = target_shape.nearest_point_approx(p_shape_entry_middle); - if (!p_next_room_is_thick) - { + if (!p_next_room_is_thick) { // check the line from p_shape_entry_middle to the nearest point. int[] curr_net_no_arr = new int[1]; curr_net_no_arr[0] = this.ctrl.net_no; @@ -450,15 +477,13 @@ private boolean expand_to_target_doors(MazeListElement p_list_element, IntPoint[] check_points = new IntPoint[2]; check_points[0] = p_shape_entry_middle.round(); check_points[1] = connection_point.round(); - if (!check_points[0].equals(check_points[1])) - { + if (!check_points[0].equals(check_points[1])) { Polyline check_polyline = new Polyline(check_points); boolean check_ok = autoroute_engine.board.check_forced_trace_polyline(check_polyline, ctrl.trace_half_width[curr_layer], curr_layer, curr_net_no_arr, ctrl.trace_clearance_class_no, ctrl.max_shove_trace_recursion_depth, ctrl.max_shove_via_recursion_depth, ctrl.max_spring_over_recursion_depth); - if (!check_ok) - { + if (!check_ok) { continue; } } @@ -467,8 +492,7 @@ private boolean expand_to_target_doors(MazeListElement p_list_element, FloatLine new_shape_entry = new FloatLine(connection_point, connection_point); if (expand_to_door_section(to_door, 0, new_shape_entry, p_list_element, - 0, MazeSearchElement.Adjustment.NONE)) - { + 0, MazeSearchElement.Adjustment.NONE)) { result = true; } } @@ -479,56 +503,44 @@ private boolean expand_to_target_doors(MazeListElement p_list_element, * Return true, if at least 1 door ection was expanded. */ private boolean expand_to_door(ExpansionDoor p_to_door, MazeListElement p_list_element, int p_add_costs, - boolean p_next_room_is_thick, MazeSearchElement.Adjustment p_adjustment) - { + boolean p_next_room_is_thick, MazeSearchElement.Adjustment p_adjustment) { double half_width = ctrl.compensated_trace_half_width[p_list_element.next_room.get_layer()]; boolean something_expanded = false; FloatLine[] line_sections = p_to_door.get_section_segments(half_width); - for (int i = 0; i < line_sections.length; ++i) - { - if (p_to_door.section_arr[i].is_occupied) - { + for (int i = 0; i < line_sections.length; ++i) { + if (p_to_door.section_arr[i].is_occupied) { continue; } FloatLine new_shape_entry; - if (p_next_room_is_thick) - { + if (p_next_room_is_thick) { new_shape_entry = line_sections[i]; - if (p_to_door.dimension == 1 && line_sections.length == 1 && p_to_door.first_room instanceof CompleteFreeSpaceExpansionRoom && p_to_door.second_room instanceof CompleteFreeSpaceExpansionRoom) - { + if (p_to_door.dimension == 1 && line_sections.length == 1 && p_to_door.first_room instanceof CompleteFreeSpaceExpansionRoom && p_to_door.second_room instanceof CompleteFreeSpaceExpansionRoom) { // check entering the p_to_door at an acute corner of the shape of p_list_element.next_room FloatPoint shape_entry_middle = new_shape_entry.a.middle_point(new_shape_entry.b); TileShape room_shape = p_list_element.next_room.get_shape(); - if (room_shape.min_width() < 2 * half_width) - { + if (room_shape.min_width() < 2 * half_width) { return false; } FloatPoint[] nearest_points = room_shape.nearest_border_points_approx(shape_entry_middle, 2); - if (nearest_points.length < 2 || nearest_points[1].distance(shape_entry_middle) <= half_width + 1) - { + if (nearest_points.length < 2 || nearest_points[1].distance(shape_entry_middle) <= half_width + 1) { return false; } } - } - else - { + } else { // expand only doors on the opposite side of the room from the shape_entry. - if (p_to_door.dimension == 1 && i == 0 && line_sections[0].b.distance_square(line_sections[0].a) < 1) - { + if (p_to_door.dimension == 1 && i == 0 && line_sections[0].b.distance_square(line_sections[0].a) < 1) { // p_to_door is small belonging to a via or thin room continue; } new_shape_entry = segment_projection(p_list_element.shape_entry, line_sections[i]); - if (new_shape_entry == null) - { + if (new_shape_entry == null) { continue; } } if (expand_to_door_section(p_to_door, i, new_shape_entry, p_list_element, - p_add_costs, p_adjustment)) - { + p_add_costs, p_adjustment)) { something_expanded = true; } } @@ -538,15 +550,11 @@ private boolean expand_to_door(ExpansionDoor p_to_door, MazeListElement p_list_e /** * Checks, if the width p_door is big enough for a trace with width p_trace_width. */ - private boolean door_is_small(ExpansionDoor p_door, double p_trace_width) - { - if (p_door.dimension == 1 || p_door.first_room instanceof CompleteFreeSpaceExpansionRoom && p_door.second_room instanceof CompleteFreeSpaceExpansionRoom) - { + private boolean door_is_small(ExpansionDoor p_door, double p_trace_width) { + if (p_door.dimension == 1 || p_door.first_room instanceof CompleteFreeSpaceExpansionRoom && p_door.second_room instanceof CompleteFreeSpaceExpansionRoom) { TileShape door_shape = p_door.get_shape(); - if (door_shape.is_empty()) - { - if (this.autoroute_engine.board.get_test_level().ordinal() >= net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (door_shape.is_empty()) { + if (this.autoroute_engine.board.get_test_level().ordinal() >= net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("MazeSearchAlgo:check_door_width door_shape is empty"); } return true; @@ -554,23 +562,17 @@ private boolean door_is_small(ExpansionDoor p_door, double p_trace_width) double door_length; AngleRestriction angle_restriction = autoroute_engine.board.rules.get_trace_angle_restriction(); - if (angle_restriction == AngleRestriction.NINETY_DEGREE) - { + if (angle_restriction == AngleRestriction.NINETY_DEGREE) { IntBox door_box = door_shape.bounding_box(); door_length = door_box.max_width(); - } - else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) { IntOctagon door_oct = door_shape.bounding_octagon(); door_length = door_oct.max_width(); - } - else - { + } else { FloatLine door_line_segment = door_shape.diagonal_corner_segment(); door_length = door_line_segment.b.distance(door_line_segment.a); } - if (door_length < p_trace_width) - { + if (door_length < p_trace_width) { return true; } } @@ -582,10 +584,8 @@ else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) */ private boolean expand_to_door_section(ExpandableObject p_door, int p_section_no, FloatLine p_shape_entry, MazeListElement p_from_element, - int p_add_costs, MazeSearchElement.Adjustment p_adjustment) - { - if (p_door.get_maze_search_element(p_section_no).is_occupied || p_shape_entry == null) - { + int p_add_costs, MazeSearchElement.Adjustment p_adjustment) { + if (p_door.get_maze_search_element(p_section_no).is_occupied || p_shape_entry == null) { return false; } CompleteExpansionRoom next_room = p_door.other_room(p_from_element.next_room); @@ -599,23 +599,20 @@ private boolean expand_to_door_section(ExpandableObject p_door, int p_section_no MazeListElement new_element = new MazeListElement(p_door, p_section_no, p_from_element.door, p_from_element.section_no_of_door, - expansion_value, sorting_value, next_room, p_shape_entry, room_ripped, p_adjustment, false); + expansion_value, sorting_value, next_room, p_shape_entry, room_ripped, p_adjustment, false); this.maze_expansion_list.add(new_element); return true; } - private void expand_to_drill(ExpansionDrill p_drill, MazeListElement p_from_element, int p_add_costs) - { + private void expand_to_drill(ExpansionDrill p_drill, MazeListElement p_from_element, int p_add_costs) { int layer = p_from_element.next_room.get_layer(); int trace_half_width = this.ctrl.compensated_trace_half_width[layer]; boolean room_shape_is_thin = p_from_element.next_room.get_shape().min_width() < 2 * trace_half_width; - if (room_shape_is_thin) - { + if (room_shape_is_thin) { // expand only drills intersecting the backtrack door - if (p_from_element.backtrack_door == null || !p_drill.get_shape().intersects(p_from_element.backtrack_door.get_shape())) - { + if (p_from_element.backtrack_door == null || !p_drill.get_shape().intersects(p_from_element.backtrack_door.get_shape())) { return; } } @@ -623,16 +620,13 @@ private void expand_to_drill(ExpansionDrill p_drill, MazeListElement p_from_elem double via_radius = ctrl.via_radius_arr[layer]; ConvexShape shrinked_drill_shape = p_drill.get_shape().shrink(via_radius); FloatPoint compare_corner = p_from_element.shape_entry.a.middle_point(p_from_element.shape_entry.b); - if (p_from_element.door instanceof DrillPage && p_from_element.backtrack_door instanceof TargetItemExpansionDoor) - { + if (p_from_element.door instanceof DrillPage && p_from_element.backtrack_door instanceof TargetItemExpansionDoor) { // If expansion comes from a pin with trace exit directions the eapansion_value is calculated // from the nearest trace exit point instead from the center olf the pin. Item from_item = ((TargetItemExpansionDoor) p_from_element.backtrack_door).item; - if (from_item instanceof net.freerouting.board.Pin) - { + if (from_item instanceof net.freerouting.board.Pin) { FloatPoint nearest_exit_corner = ((net.freerouting.board.Pin) from_item).nearest_trace_exit_corner(p_drill.location.to_float(), trace_half_width, layer); - if (nearest_exit_corner != null) - { + if (nearest_exit_corner != null) { compare_corner = nearest_exit_corner; } } @@ -646,13 +640,10 @@ private void expand_to_drill(ExpansionDrill p_drill, MazeListElement p_from_elem ctrl.trace_costs[layer].horizontal, ctrl.trace_costs[layer].vertical); ExpandableObject new_backtrack_door; int new_section_no_of_backtrack_door; - if (p_from_element.door instanceof DrillPage) - { + if (p_from_element.door instanceof DrillPage) { new_backtrack_door = p_from_element.backtrack_door; new_section_no_of_backtrack_door = p_from_element.section_no_of_backtrack_door; - } - else - { + } else { // Expanded directly through already existing via // The step expand_to_drill_page is skipped new_backtrack_door = p_from_element.door; @@ -662,8 +653,8 @@ private void expand_to_drill(ExpansionDrill p_drill, MazeListElement p_from_elem double sorting_value = expansion_value + this.destination_distance.calculate(nearest_point, layer); MazeListElement new_element = new MazeListElement(p_drill, section_no, new_backtrack_door, - new_section_no_of_backtrack_door, expansion_value, sorting_value, null, shape_entry, - p_from_element.room_ripped, MazeSearchElement.Adjustment.NONE, false); + new_section_no_of_backtrack_door, expansion_value, sorting_value, null, shape_entry, + p_from_element.room_ripped, MazeSearchElement.Adjustment.NONE, false); this.maze_expansion_list.add(new_element); } @@ -671,8 +662,7 @@ private void expand_to_drill(ExpansionDrill p_drill, MazeListElement p_from_elem * A drill page is inserted between an expansion roomm and the drill to expand * in order to prevent performance problems with rooms with big shapes containing many drills. */ - private void expand_to_drill_page(DrillPage p_drill_page, MazeListElement p_from_element) - { + private void expand_to_drill_page(DrillPage p_drill_page, MazeListElement p_from_element) { int layer = p_from_element.next_room.get_layer(); FloatPoint from_element_shape_entry_middle = p_from_element.shape_entry.a.middle_point(p_from_element.shape_entry.b); @@ -681,28 +671,24 @@ private void expand_to_drill_page(DrillPage p_drill_page, MazeListElement p_from double expansion_value = p_from_element.expansion_value + ctrl.min_normal_via_cost; double sorting_value = expansion_value + nearest_point.weighted_distance(from_element_shape_entry_middle, - ctrl.trace_costs[layer].horizontal, ctrl.trace_costs[layer].vertical) + this.destination_distance.calculate(nearest_point, layer); + ctrl.trace_costs[layer].horizontal, ctrl.trace_costs[layer].vertical) + this.destination_distance.calculate(nearest_point, layer); MazeListElement new_element = new MazeListElement(p_drill_page, layer, p_from_element.door, p_from_element.section_no_of_door, - expansion_value, sorting_value, p_from_element.next_room, p_from_element.shape_entry, - p_from_element.room_ripped, MazeSearchElement.Adjustment.NONE, false); + expansion_value, sorting_value, p_from_element.next_room, p_from_element.shape_entry, + p_from_element.room_ripped, MazeSearchElement.Adjustment.NONE, false); this.maze_expansion_list.add(new_element); } - private void expand_to_drills_of_page(MazeListElement p_from_element) - { + private void expand_to_drills_of_page(MazeListElement p_from_element) { int from_room_layer = p_from_element.section_no_of_door; DrillPage drill_page = (DrillPage) p_from_element.door; Collection drill_list = drill_page.get_drills(this.autoroute_engine, this.ctrl.attach_smd_allowed); - for (ExpansionDrill curr_drill : drill_list) - { + for (ExpansionDrill curr_drill : drill_list) { int section_no = from_room_layer - curr_drill.first_layer; - if (section_no < 0 || section_no >= curr_drill.room_arr.length) - { + if (section_no < 0 || section_no >= curr_drill.room_arr.length) { continue; } - if (curr_drill.room_arr[section_no] == p_from_element.next_room && !curr_drill.get_maze_search_element(section_no).is_occupied) - { + if (curr_drill.room_arr[section_no] == p_from_element.next_room && !curr_drill.get_maze_search_element(section_no).is_occupied) { expand_to_drill(curr_drill, p_from_element, 0); } } @@ -711,8 +697,7 @@ private void expand_to_drills_of_page(MazeListElement p_from_element) /** * Tries to expand other layers by inserting a via. */ - private void expand_to_other_layers(MazeListElement p_list_element) - { + private void expand_to_other_layers(MazeListElement p_list_element) { int via_lower_bound = 0; int via_upper_bound = -1; ExpansionDrill curr_drill = (ExpansionDrill) p_list_element.door; @@ -720,30 +705,24 @@ private void expand_to_other_layers(MazeListElement p_list_element) boolean smd_attached_on_component_side = false; boolean smd_attached_on_solder_side = false; boolean room_ripped; - if (curr_drill.room_arr[p_list_element.section_no_of_door] instanceof ObstacleExpansionRoom) - { + if (curr_drill.room_arr[p_list_element.section_no_of_door] instanceof ObstacleExpansionRoom) { // check ripup of an existing via - if (!this.ctrl.ripup_allowed) - { + if (!this.ctrl.ripup_allowed) { return; } Item curr_obstacle_item = ((ObstacleExpansionRoom) curr_drill.room_arr[p_list_element.section_no_of_door]).get_item(); - if (!(curr_obstacle_item instanceof net.freerouting.board.Via)) - { + if (!(curr_obstacle_item instanceof net.freerouting.board.Via)) { return; } net.freerouting.library.Padstack curr_obstacle_padstack = ((net.freerouting.board.Via) curr_obstacle_item).get_padstack(); - if (!this.ctrl.via_rule.contains_padstack(curr_obstacle_padstack) || curr_obstacle_item.clearance_class_no() != this.ctrl.via_clearance_class) - { + if (!this.ctrl.via_rule.contains_padstack(curr_obstacle_padstack) || curr_obstacle_item.clearance_class_no() != this.ctrl.via_clearance_class) { return; } via_lower_bound = curr_obstacle_padstack.from_layer(); via_upper_bound = curr_obstacle_padstack.to_layer(); room_ripped = true; - } - else - { + } else { int[] net_no_arr = new int[1]; net_no_arr[0] = ctrl.net_no; @@ -752,117 +731,90 @@ private void expand_to_other_layers(MazeListElement p_list_element) int via_upper_limit = Math.min(curr_drill.last_layer, ctrl.via_upper_bound); // Calculate the lower bound of possible vias. int curr_layer = from_layer; - for (;;) - { + for (; ; ) { TileShape curr_room_shape = curr_drill.room_arr[curr_layer - curr_drill.first_layer].get_shape(); net.freerouting.board.ForcedPadAlgo.CheckDrillResult drill_result = ForcedViaAlgo.check_layer(ctrl.via_radius_arr[curr_layer], ctrl.via_clearance_class, - ctrl.attach_smd_allowed, curr_room_shape, curr_drill.location, curr_layer, net_no_arr, - ctrl.max_shove_trace_recursion_depth, 0, autoroute_engine.board); - if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) - { + ctrl.attach_smd_allowed, curr_room_shape, curr_drill.location, curr_layer, net_no_arr, + ctrl.max_shove_trace_recursion_depth, 0, autoroute_engine.board); + if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) { via_lower_bound = curr_layer + 1; break; - } - else if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.DRILLABLE_WITH_ATTACH_SMD) - { - if (curr_layer == 0) - { + } else if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.DRILLABLE_WITH_ATTACH_SMD) { + if (curr_layer == 0) { smd_attached_on_component_side = true; - } - else if (curr_layer == ctrl.layer_count - 1) - { + } else if (curr_layer == ctrl.layer_count - 1) { smd_attached_on_solder_side = true; } } - if (curr_layer <= via_lower_limit) - { + if (curr_layer <= via_lower_limit) { via_lower_bound = via_lower_limit; break; } --curr_layer; } - if (via_lower_bound > curr_drill.first_layer) - { + if (via_lower_bound > curr_drill.first_layer) { return; } curr_layer = from_layer + 1; - for (;;) - { - if (curr_layer > via_upper_limit) - { + for (; ; ) { + if (curr_layer > via_upper_limit) { via_upper_bound = via_upper_limit; break; } TileShape curr_room_shape = curr_drill.room_arr[curr_layer - curr_drill.first_layer].get_shape(); net.freerouting.board.ForcedPadAlgo.CheckDrillResult drill_result = ForcedViaAlgo.check_layer(ctrl.via_radius_arr[curr_layer], ctrl.via_clearance_class, ctrl.attach_smd_allowed, - curr_room_shape, curr_drill.location, curr_layer, net_no_arr, - ctrl.max_shove_trace_recursion_depth, 0, autoroute_engine.board); - if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) - { + curr_room_shape, curr_drill.location, curr_layer, net_no_arr, + ctrl.max_shove_trace_recursion_depth, 0, autoroute_engine.board); + if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) { via_upper_bound = curr_layer - 1; break; - } - else if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.DRILLABLE_WITH_ATTACH_SMD) - { - if (curr_layer == ctrl.layer_count - 1) - { + } else if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.DRILLABLE_WITH_ATTACH_SMD) { + if (curr_layer == ctrl.layer_count - 1) { smd_attached_on_solder_side = true; } } ++curr_layer; } - if (via_upper_bound < curr_drill.last_layer) - { + if (via_upper_bound < curr_drill.last_layer) { return; } } - for (int to_layer = via_lower_bound; to_layer <= via_upper_bound; ++to_layer) - { - if (to_layer == from_layer) - { + for (int to_layer = via_lower_bound; to_layer <= via_upper_bound; ++to_layer) { + if (to_layer == from_layer) { continue; } // check, there there is a fitting via mask. int curr_first_layer; int curr_last_layer; - if (to_layer < from_layer) - { + if (to_layer < from_layer) { curr_first_layer = to_layer; curr_last_layer = from_layer; - } - else - { + } else { curr_first_layer = from_layer; curr_last_layer = to_layer; } boolean mask_found = false; - for (int i = 0; i < ctrl.via_info_arr.length; ++i) - { + for (int i = 0; i < ctrl.via_info_arr.length; ++i) { AutorouteControl.ViaMask curr_via_info = ctrl.via_info_arr[i]; - if (curr_first_layer >= curr_via_info.from_layer && curr_last_layer <= curr_via_info.to_layer && curr_via_info.from_layer >= via_lower_bound && curr_via_info.to_layer <= via_upper_bound) - { + if (curr_first_layer >= curr_via_info.from_layer && curr_last_layer <= curr_via_info.to_layer && curr_via_info.from_layer >= via_lower_bound && curr_via_info.to_layer <= via_upper_bound) { boolean mask_ok = true; - if (curr_via_info.from_layer == 0 && smd_attached_on_component_side || curr_via_info.to_layer == ctrl.layer_count - 1 && smd_attached_on_solder_side) - { + if (curr_via_info.from_layer == 0 && smd_attached_on_component_side || curr_via_info.to_layer == ctrl.layer_count - 1 && smd_attached_on_solder_side) { mask_ok = curr_via_info.attach_smd_allowed; } - if (mask_ok) - { + if (mask_ok) { mask_found = true; break; } } } - if (!mask_found) - { + if (!mask_found) { continue; } MazeSearchElement curr_drill_layer_info = curr_drill.get_maze_search_element(to_layer - curr_drill.first_layer); - if (curr_drill_layer_info.is_occupied) - { + if (curr_drill_layer_info.is_occupied) { continue; } double expansion_value = p_list_element.expansion_value + ctrl.add_via_costs[from_layer].to_layer[to_layer]; @@ -871,8 +823,8 @@ else if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.DR int curr_room_index = to_layer - curr_drill.first_layer; MazeListElement new_element = new MazeListElement(curr_drill, curr_room_index, curr_drill, p_list_element.section_no_of_door, - expansion_value, sorting_value, curr_drill.room_arr[curr_room_index], p_list_element.shape_entry, - room_ripped, MazeSearchElement.Adjustment.NONE, false); + expansion_value, sorting_value, curr_drill.room_arr[curr_room_index], p_list_element.shape_entry, + room_ripped, MazeSearchElement.Adjustment.NONE, false); this.maze_expansion_list.add(new_element); } } @@ -881,34 +833,28 @@ else if (drill_result == net.freerouting.board.ForcedPadAlgo.CheckDrillResult.DR * Initializes the maze search algorithm. * Returns false if the initialisation failed. */ - private boolean init(Set p_start_items, Set p_destination_items) - { + private boolean init(Set p_start_items, Set p_destination_items) { reduce_trace_shapes_at_tie_pins(p_start_items, this.ctrl.net_no, this.search_tree); reduce_trace_shapes_at_tie_pins(p_destination_items, this.ctrl.net_no, this.search_tree); // process the destination items boolean destination_ok = false; Iterator it = p_destination_items.iterator(); - while (it.hasNext()) - { - if (this.autoroute_engine.is_stop_requested()) - { + while (it.hasNext()) { + if (this.autoroute_engine.is_stop_requested()) { return false; } Item curr_item = it.next(); ItemAutorouteInfo curr_info = curr_item.get_autoroute_info(); curr_info.set_start_info(false); - for (int i = 0; i < curr_item.tree_shape_count(this.search_tree); ++i) - { + for (int i = 0; i < curr_item.tree_shape_count(this.search_tree); ++i) { TileShape curr_tree_shape = curr_item.get_tree_shape(this.search_tree, i); - if (curr_tree_shape != null) - { + if (curr_tree_shape != null) { destination_distance.join(curr_tree_shape.bounding_box(), curr_item.shape_layer(i)); } } destination_ok = true; } - if (!destination_ok && this.ctrl.is_fanout) - { + if (!destination_ok && this.ctrl.is_fanout) { // detination set is not needed for fanout IntBox board_bounding_box = this.autoroute_engine.board.bounding_box; destination_distance.join(board_bounding_box, 0); @@ -916,26 +862,21 @@ private boolean init(Set p_start_items, Set p_destination_items) destination_ok = true; } - if (!destination_ok) - { + if (!destination_ok) { return false; } // process the start items Collection start_rooms = new LinkedList(); it = p_start_items.iterator(); - while (it.hasNext()) - { - if (this.autoroute_engine.is_stop_requested()) - { + while (it.hasNext()) { + if (this.autoroute_engine.is_stop_requested()) { return false; } Item curr_item = it.next(); ItemAutorouteInfo curr_info = curr_item.get_autoroute_info(); curr_info.set_start_info(true); - if (curr_item instanceof Connectable) - { - for (int i = 0; i < curr_item.tree_shape_count(search_tree); ++i) - { + if (curr_item instanceof Connectable) { + for (int i = 0; i < curr_item.tree_shape_count(search_tree); ++i) { TileShape contained_shape = ((Connectable) curr_item).get_trace_connection_shape(search_tree, i); IncompleteFreeSpaceExpansionRoom new_start_room = autoroute_engine.add_incomplete_expansion_room(null, curr_item.shape_layer(i), contained_shape); @@ -948,16 +889,13 @@ private boolean init(Set p_start_items, Set p_destination_items) Collection completed_start_rooms = new LinkedList(); - if (this.autoroute_engine.maintain_database) - { + if (this.autoroute_engine.maintain_database) { // add the completed start rooms carried over from the last autoroute to the start rooms. completed_start_rooms.addAll(this.autoroute_engine.get_rooms_with_target_items(p_start_items)); } - for (IncompleteFreeSpaceExpansionRoom curr_room : start_rooms) - { - if (this.autoroute_engine.is_stop_requested()) - { + for (IncompleteFreeSpaceExpansionRoom curr_room : start_rooms) { + if (this.autoroute_engine.is_stop_requested()) { return false; } Collection curr_completed_rooms = @@ -968,18 +906,14 @@ private boolean init(Set p_start_items, Set p_destination_items) // Put the ItemExpansionDoors of the completed start rooms into // the maze_expansion_list. boolean start_ok = false; - for (CompleteFreeSpaceExpansionRoom curr_room : completed_start_rooms) - { + for (CompleteFreeSpaceExpansionRoom curr_room : completed_start_rooms) { Iterator it2 = curr_room.get_target_doors().iterator(); - while (it2.hasNext()) - { - if (this.autoroute_engine.is_stop_requested()) - { + while (it2.hasNext()) { + if (this.autoroute_engine.is_stop_requested()) { return false; } TargetItemExpansionDoor curr_door = it2.next(); - if (curr_door.is_destination_door()) - { + if (curr_door.is_destination_door()) { continue; } TileShape connection_shape = ((Connectable) curr_door.item).get_trace_connection_shape(search_tree, curr_door.tree_entry_no); @@ -989,7 +923,7 @@ private boolean init(Set p_start_items, Set p_destination_items) double sorting_value = this.destination_distance.calculate(curr_center, curr_room.get_layer()); MazeListElement new_list_element = new MazeListElement(curr_door, 0, null, 0, 0, sorting_value, curr_room, shape_entry, false, - MazeSearchElement.Adjustment.NONE, false); + MazeSearchElement.Adjustment.NONE, false); maze_expansion_list.add(new_list_element); start_ok = true; } @@ -997,72 +931,39 @@ private boolean init(Set p_start_items, Set p_destination_items) return start_ok; } - /** - * Looks for pins with more than 1 nets and reduces shapes of thraces of foreign nets, - * which are already connected to such a pin, so that the pin center is not blocked for connection. - */ - private static void reduce_trace_shapes_at_tie_pins(Collection p_item_list, int p_own_net_no, ShapeSearchTree p_autoroute_tree) - { - for (Item curr_item : p_item_list) - { - if ((curr_item instanceof net.freerouting.board.Pin) && curr_item.net_count() > 1) - { - Collection pin_contacts = curr_item.get_normal_contacts(); - net.freerouting.board.Pin curr_tie_pin = (net.freerouting.board.Pin) curr_item; - for (Item curr_contact : pin_contacts) - { - if (!(curr_contact instanceof net.freerouting.board.PolylineTrace) || curr_contact.contains_net(p_own_net_no)) - { - continue; - } - p_autoroute_tree.reduce_trace_shape_at_tie_pin(curr_tie_pin, (net.freerouting.board.PolylineTrace) curr_contact); - } - } - } - } - - private boolean room_shape_is_thick(ObstacleExpansionRoom p_obstacle_room) - { + private boolean room_shape_is_thick(ObstacleExpansionRoom p_obstacle_room) { Item obstacle_item = p_obstacle_room.get_item(); int layer = p_obstacle_room.get_layer(); double obstacle_half_width; - if (obstacle_item instanceof net.freerouting.board.Trace) - { + if (obstacle_item instanceof net.freerouting.board.Trace) { obstacle_half_width = ((net.freerouting.board.Trace) obstacle_item).get_half_width() + this.search_tree.clearance_compensation_value(obstacle_item.clearance_class_no(), layer); - } - else if (obstacle_item instanceof net.freerouting.board.Via) - { + } else if (obstacle_item instanceof net.freerouting.board.Via) { TileShape via_shape = ((net.freerouting.board.Via) obstacle_item).get_tree_shape_on_layer(this.search_tree, layer); obstacle_half_width = 0.5 * via_shape.max_width(); - } - else - { + } else { System.out.println("MazeSearchAlgo. room_shape_is_thick: unexpected obstacle item"); obstacle_half_width = 0; } return obstacle_half_width >= this.ctrl.compensated_trace_half_width[layer]; } - /** Checks, if the room can be ripped and returns the rip up costs, + /** + * Checks, if the room can be ripped and returns the rip up costs, * which are > 0, if the room is ripped and -1, if no ripup was possible. * If the previous room was also ripped and contained the same item * or an item of the same connection, the result will be * equal to ALREADY_RIPPED_COSTS */ - private int check_ripup(MazeListElement p_list_element, Item p_obstacle_item, boolean p_door_is_small) - { - if (!p_obstacle_item.is_route()) - { + private int check_ripup(MazeListElement p_list_element, Item p_obstacle_item, boolean p_door_is_small) { + if (!p_obstacle_item.is_route()) { return -1; } - if (p_door_is_small) - { + if (p_door_is_small) { // allow entering a via or trace, if its corresponding border segment is smaller than the current trace width - if (!enter_through_small_door(p_list_element, p_obstacle_item)) - { + if (!enter_through_small_door(p_list_element, p_obstacle_item)) { return -1; } @@ -1070,61 +971,47 @@ private int check_ripup(MazeListElement p_list_element, Item p_obstacle_item, bo CompleteExpansionRoom previous_room = p_list_element.door.other_room(p_list_element.next_room); boolean room_was_shoved = p_list_element.adjustment != MazeSearchElement.Adjustment.NONE; Item previous_item = null; - if (previous_room != null && previous_room instanceof ObstacleExpansionRoom) - { + if (previous_room != null && previous_room instanceof ObstacleExpansionRoom) { previous_item = ((ObstacleExpansionRoom) previous_room).get_item(); } - if (room_was_shoved) - { - if (previous_item != null && previous_item != p_obstacle_item && previous_item.shares_net(p_obstacle_item)) - { + if (room_was_shoved) { + if (previous_item != null && previous_item != p_obstacle_item && previous_item.shares_net(p_obstacle_item)) { // The ripped trace may start at a fork. return -1; } - } - else if (previous_item == p_obstacle_item) - { + } else if (previous_item == p_obstacle_item) { return ALREADY_RIPPED_COSTS; } double fanout_via_cost_factor = 1.0; double cost_factor = 1; - if (p_obstacle_item instanceof net.freerouting.board.Trace) - { + if (p_obstacle_item instanceof net.freerouting.board.Trace) { net.freerouting.board.Trace obstacle_trace = (net.freerouting.board.Trace) p_obstacle_item; cost_factor = obstacle_trace.get_half_width(); - if (!this.ctrl.remove_unconnected_vias) - { + if (!this.ctrl.remove_unconnected_vias) { // protect traces between SMD-pins and fanout vias fanout_via_cost_factor = calc_fanout_via_ripup_cost_factor(obstacle_trace); } - } - else if (p_obstacle_item instanceof net.freerouting.board.Via) - { + } else if (p_obstacle_item instanceof net.freerouting.board.Via) { boolean look_if_fanout_via = !this.ctrl.remove_unconnected_vias; Collection contact_list = p_obstacle_item.get_normal_contacts(); int contact_count = 0; - for (Item curr_contact : contact_list) - { - if (!(curr_contact instanceof net.freerouting.board.Trace) || curr_contact.is_user_fixed()) - { + for (Item curr_contact : contact_list) { + if (!(curr_contact instanceof net.freerouting.board.Trace) || curr_contact.is_user_fixed()) { return -1; } ++contact_count; net.freerouting.board.Trace obstacle_trace = (net.freerouting.board.Trace) curr_contact; cost_factor = Math.max(cost_factor, obstacle_trace.get_half_width()); - if (look_if_fanout_via) - { + if (look_if_fanout_via) { double curr_fanout_via_cost_factor = calc_fanout_via_ripup_cost_factor(obstacle_trace); - if (curr_fanout_via_cost_factor > 1) - { + if (curr_fanout_via_cost_factor > 1) { fanout_via_cost_factor = curr_fanout_via_cost_factor; look_if_fanout_via = false; } } } - if (fanout_via_cost_factor <= 1) - { + if (fanout_via_cost_factor <= 1) { // not a fanout via cost_factor *= 0.5 * Math.max(contact_count - 1, 0); } @@ -1135,14 +1022,12 @@ else if (p_obstacle_item instanceof net.freerouting.board.Via) if (fanout_via_cost_factor <= 1) // p_obstacle_item does not belong to a fanout { Connection obstacle_connection = Connection.get(p_obstacle_item); - if (obstacle_connection != null) - { + if (obstacle_connection != null) { detour = obstacle_connection.get_detour(); } } boolean randomize = this.ctrl.ripup_pass_no >= 4 && this.ctrl.ripup_pass_no % 3 != 0; - if (randomize) - { + if (randomize) { // shuffle the result to avoid repetitive loops double random_number = this.random_generator.nextDouble(); double random_factor = 0.5 + random_number * random_number; @@ -1156,91 +1041,32 @@ else if (p_obstacle_item instanceof net.freerouting.board.Via) return Math.min(result, MAX_RIPUP_COSTS); } - /** - * Return the addditional cost factor for ripping the trace, if it is connected to a fanout via - * or 1, if no fanout via was found. - */ - private static double calc_fanout_via_ripup_cost_factor(net.freerouting.board.Trace p_trace) - { - final double FANOUT_COST_CONST = 20000; - Collection curr_end_contacts; - for (int i = 0; i < 2; ++i) - { - if (i == 0) - { - curr_end_contacts = p_trace.get_start_contacts(); - } - else - { - curr_end_contacts = p_trace.get_end_contacts(); - } - if (curr_end_contacts.size() != 1) - { - continue; - } - Item curr_trace_contact = curr_end_contacts.iterator().next(); - boolean protect_fanout_via = false; - if (curr_trace_contact instanceof net.freerouting.board.Pin && curr_trace_contact.first_layer() == curr_trace_contact.last_layer()) - { - protect_fanout_via = true; - } - else if (curr_trace_contact instanceof PolylineTrace && curr_trace_contact.get_fixed_state() == net.freerouting.board.FixedState.SHOVE_FIXED) - { - // look for shove fixed exit traces of SMD-pins - PolylineTrace contact_trace = (PolylineTrace) curr_trace_contact; - if (contact_trace.corner_count() == 2) - { - protect_fanout_via = true; - } - } - - - if (protect_fanout_via) - { - double fanout_via_cost_factor = p_trace.get_half_width() / p_trace.get_length(); - fanout_via_cost_factor *= fanout_via_cost_factor; - fanout_via_cost_factor *= FANOUT_COST_CONST; - fanout_via_cost_factor = Math.max(fanout_via_cost_factor, 1); - return fanout_via_cost_factor; - } - } - return 1; - } - /** * Shoves a trace room and expands the corresponding doors. * Return false, if no door was expanded. In this case occupation of the door_section by ripup can be delayed * to allow shoving the room fromm a different door section */ - private boolean shove_trace_room(MazeListElement p_list_element, ObstacleExpansionRoom p_obstacle_room) - { + private boolean shove_trace_room(MazeListElement p_list_element, ObstacleExpansionRoom p_obstacle_room) { if (p_list_element.section_no_of_door != 0 - && p_list_element.section_no_of_door != p_list_element.door.maze_search_element_count() - 1) - { + && p_list_element.section_no_of_door != p_list_element.door.maze_search_element_count() - 1) { // No delay of occupation necessesary because inner sections of a door are currently not shoved. return true; } boolean result = false; - if (p_list_element.adjustment != MazeSearchElement.Adjustment.RIGHT) - { + if (p_list_element.adjustment != MazeSearchElement.Adjustment.RIGHT) { Collection left_to_door_section_list = new java.util.LinkedList(); if (MazeShoveTraceAlgo.check_shove_trace_line(p_list_element, p_obstacle_room, - this.autoroute_engine.board, this.ctrl, false, left_to_door_section_list)) - { + this.autoroute_engine.board, this.ctrl, false, left_to_door_section_list)) { result = true; } - for (MazeShoveTraceAlgo.DoorSection curr_left_door_section : left_to_door_section_list) - { + for (MazeShoveTraceAlgo.DoorSection curr_left_door_section : left_to_door_section_list) { MazeSearchElement.Adjustment curr_adjustment; - if (curr_left_door_section.door.dimension == 2) - { + if (curr_left_door_section.door.dimension == 2) { // the door is the link door to the next room curr_adjustment = MazeSearchElement.Adjustment.LEFT; - } - else - { + } else { curr_adjustment = MazeSearchElement.Adjustment.NONE; } @@ -1250,25 +1076,19 @@ private boolean shove_trace_room(MazeListElement p_list_element, ObstacleExpansi } } - if (p_list_element.adjustment != MazeSearchElement.Adjustment.LEFT) - { + if (p_list_element.adjustment != MazeSearchElement.Adjustment.LEFT) { Collection right_to_door_section_list = new java.util.LinkedList(); if (MazeShoveTraceAlgo.check_shove_trace_line(p_list_element, p_obstacle_room, - this.autoroute_engine.board, this.ctrl, true, right_to_door_section_list)) - { + this.autoroute_engine.board, this.ctrl, true, right_to_door_section_list)) { result = true; } - for (MazeShoveTraceAlgo.DoorSection curr_right_door_section : right_to_door_section_list) - { + for (MazeShoveTraceAlgo.DoorSection curr_right_door_section : right_to_door_section_list) { MazeSearchElement.Adjustment curr_adjustment; - if (curr_right_door_section.door.dimension == 2) - { + if (curr_right_door_section.door.dimension == 2) { // the door is the link door to the next room curr_adjustment = MazeSearchElement.Adjustment.RIGHT; - } - else - { + } else { curr_adjustment = MazeSearchElement.Adjustment.NONE; } expand_to_door_section(curr_right_door_section.door, curr_right_door_section.section_no, @@ -1283,79 +1103,23 @@ private boolean shove_trace_room(MazeListElement p_list_element, ObstacleExpansi * Checks, if the next roomm contains a destination pin, where evtl. neckdown is necessary. * Return the neck down width in this case, or 0, if no such pin waas found, */ - private double check_neck_down_at_dest_pin(CompleteExpansionRoom p_room) - { + private double check_neck_down_at_dest_pin(CompleteExpansionRoom p_room) { Collection target_doors = p_room.get_target_doors(); - for (TargetItemExpansionDoor curr_target_door : target_doors) - { - if (curr_target_door.item instanceof net.freerouting.board.Pin) - { + for (TargetItemExpansionDoor curr_target_door : target_doors) { + if (curr_target_door.item instanceof net.freerouting.board.Pin) { return ((net.freerouting.board.Pin) curr_target_door.item).get_trace_neckdown_halfwidth(p_room.get_layer()); } } return 0; } - /** - * Returns the perpendicular projection of p_from_segment onto p_to_segment. - * Returns null, if the projection is empty. - */ - private static FloatLine segment_projection(FloatLine p_from_segment, FloatLine p_to_segment) - { - FloatLine check_segment = p_from_segment.adjust_direction(p_to_segment); - FloatLine first_projection = p_to_segment.segment_projection(check_segment); - FloatLine second_projection = p_to_segment.segment_projection_2(check_segment); - FloatLine result; - if (first_projection != null && second_projection != null) - { - FloatPoint result_a; - if (first_projection.a == p_to_segment.a || second_projection.a == p_to_segment.a) - { - result_a = p_to_segment.a; - } - else if (first_projection.a.distance_square(p_to_segment.a) <= second_projection.a.distance_square(p_to_segment.a)) - { - result_a = first_projection.a; - } - else - { - result_a = second_projection.a; - } - FloatPoint result_b; - if (first_projection.b == p_to_segment.b || second_projection.b == p_to_segment.b) - { - result_b = p_to_segment.b; - } - else if (first_projection.b.distance_square(p_to_segment.b) <= second_projection.b.distance_square(p_to_segment.b)) - { - result_b = first_projection.b; - } - else - { - result_b = second_projection.b; - } - result = new FloatLine(result_a, result_b); - } - else if (first_projection != null) - { - result = first_projection; - } - else - { - result = second_projection; - } - return result; - } - /** * Checks, if the next room can be entered if the door of p_list_element is small. * If p_ignore_item != null, p_ignore_item and all other items directly connected to p_ignore_item * are ignored in the check. */ - private boolean enter_through_small_door(MazeListElement p_list_element, Item p_ignore_item) - { - if (p_list_element.door.get_dimension() != 1) - { + private boolean enter_through_small_door(MazeListElement p_list_element, Item p_ignore_item) { + if (p_list_element.door.get_dimension() != 1) { return false; } TileShape door_shape = p_list_element.door.get_shape(); @@ -1364,19 +1128,16 @@ private boolean enter_through_small_door(MazeListElement p_list_element, Item p_ Line door_line = null; FloatPoint prev_corner = door_shape.corner_approx(0); int corner_count = door_shape.border_line_count(); - for (int i = 1; i < corner_count; ++i) - { + for (int i = 1; i < corner_count; ++i) { // skip lines of lenghth 0 FloatPoint next_corner = door_shape.corner_approx(i); - if (next_corner.distance_square(prev_corner) > 1) - { + if (next_corner.distance_square(prev_corner) > 1) { door_line = door_shape.border_line(i - 1); break; } prev_corner = next_corner; } - if (door_line == null) - { + if (door_line == null) { return false; } @@ -1398,105 +1159,78 @@ private boolean enter_through_small_door(MazeListElement p_list_element, Item p_ this.autoroute_engine.autoroute_search_tree.overlapping_objects(check_shape, curr_layer, ignore_net_nos, overlapping_objects); - for (SearchTreeObject curr_object : overlapping_objects) - { - if (!(curr_object instanceof Item) || curr_object == p_ignore_item) - { + for (SearchTreeObject curr_object : overlapping_objects) { + if (!(curr_object instanceof Item) || curr_object == p_ignore_item) { continue; } Item curr_item = (Item) curr_object; - if (!curr_item.shares_net(p_ignore_item)) - { + if (!curr_item.shares_net(p_ignore_item)) { return false; } Set curr_contacts = curr_item.get_normal_contacts(); - if (!curr_contacts.contains(p_ignore_item)) - { + if (!curr_contacts.contains(p_ignore_item)) { return false; } } return true; } - /** Checks entering a thick room from a via or trace through a small door (after ripup) */ - private boolean check_leaving_ripped_item(MazeListElement p_list_element) - { - if (!(p_list_element.door instanceof ExpansionDoor)) - { + /** + * Checks entering a thick room from a via or trace through a small door (after ripup) + */ + private boolean check_leaving_ripped_item(MazeListElement p_list_element) { + if (!(p_list_element.door instanceof ExpansionDoor)) { return false; } ExpansionDoor curr_door = (ExpansionDoor) p_list_element.door; CompleteExpansionRoom from_room = curr_door.other_room(p_list_element.next_room); - if (!(from_room instanceof ObstacleExpansionRoom)) - { + if (!(from_room instanceof ObstacleExpansionRoom)) { return false; } Item curr_item = ((ObstacleExpansionRoom) from_room).get_item(); - if (!curr_item.is_route()) - { + if (!curr_item.is_route()) { return false; } return enter_through_small_door(p_list_element, curr_item); } - /** - * The autoroute engine of this expansion algorithm. - */ - public final AutorouteEngine autoroute_engine; - final AutorouteControl ctrl; - /** - * The seach tree for expanding. It is the tree compensated for the current net. - */ - private final ShapeSearchTree search_tree; - /** - * The queue of of expanded elements used in this search algorithm. - */ - final java.util.SortedSet maze_expansion_list; - /** - * Used for calculating of a good lower bound for the distance between a new MazeExpansionElement - * and the destination set of the expansion. - */ - final DestinationDistance destination_distance; - /** - * The destination door found by the expanding algorithm. - */ - private ExpandableObject destination_door = null; - private int section_no_of_destination_door = 0; - private final java.util.Random random_generator = new java.util.Random(); - private static final int ALREADY_RIPPED_COSTS = 1; /** - * The result type of MazeSearchAlgo.find_connection + * The result type of MazeSearchAlgo.find_connection */ - public static class Result - { + public static class Result { - Result(ExpandableObject p_destination_door, int p_section_no_of_door) - { + public final ExpandableObject destination_door; + public final int section_no_of_door; + Result(ExpandableObject p_destination_door, int p_section_no_of_door) { destination_door = p_destination_door; section_no_of_door = p_section_no_of_door; } - public final ExpandableObject destination_door; - public final int section_no_of_door; } /** * Used for the result of MazeShoveViaAlgo.check_shove_via and MazeShoveThinRoomAlgo.check_shove_thin_room. */ - static class ShoveResult - { + static class ShoveResult { - /** The opposite door to be expanded */ + /** + * The opposite door to be expanded + */ final ExpansionDoor opposite_door; - /** The doors at the adjusted edge of the room shape to be expanded. */ + /** + * The doors at the adjusted edge of the room shape to be expanded. + */ final Collection side_doors; - /** The passing point of a trace through the from_door after adjustment. */ + /** + * The passing point of a trace through the from_door after adjustment. + */ final FloatPoint from_door_passing_point; - /** The passing point of a trace through the opposite door after adjustment. */ + /** + * The passing point of a trace through the opposite door after adjustment. + */ final FloatPoint opposite_door_passing_point; ShoveResult(ExpansionDoor p_opposite_door, Collection p_side_doors, - FloatPoint p_from_door_passing_point, FloatPoint p_opposite_door_passing_point) - { + FloatPoint p_from_door_passing_point, FloatPoint p_opposite_door_passing_point) { opposite_door = p_opposite_door; side_doors = p_side_doors; from_door_passing_point = p_from_door_passing_point; diff --git a/src/main/java/net/freerouting/autoroute/MazeSearchElement.java b/src/main/java/net/freerouting/autoroute/MazeSearchElement.java index 08a81c3b..897751d9 100644 --- a/src/main/java/net/freerouting/autoroute/MazeSearchElement.java +++ b/src/main/java/net/freerouting/autoroute/MazeSearchElement.java @@ -23,35 +23,32 @@ /** * Describes the structure of a section of an ExpandebleObject. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class MazeSearchElement -{ +public class MazeSearchElement { + /** + * true, if this door is already occupied by the maze expanding algorithm + */ + public boolean is_occupied = false; + /** + * Used for backtracking in the maze expanding algorithm + */ + public ExpandableObject backtrack_door = null; + public int section_no_of_backtrack_door = 0; + public boolean room_ripped = false; + public Adjustment adjustment = Adjustment.NONE; + /** * Resets this MazeSearchElement for autorouting the next connection. */ - public void reset() - { + public void reset() { is_occupied = false; backtrack_door = null; section_no_of_backtrack_door = 0; room_ripped = false; adjustment = Adjustment.NONE; } - - /** true, if this door is already occupied by the maze expanding algorithm */ - public boolean is_occupied = false; - - /** Used for backtracking in the maze expanding algorithm */ - public ExpandableObject backtrack_door = null; - - public int section_no_of_backtrack_door = 0; - - public boolean room_ripped = false; - - public Adjustment adjustment = Adjustment.NONE; - - public enum Adjustment - { NONE, RIGHT, LEFT} + + public enum Adjustment {NONE, RIGHT, LEFT} } diff --git a/src/main/java/net/freerouting/autoroute/MazeShoveTraceAlgo.java b/src/main/java/net/freerouting/autoroute/MazeShoveTraceAlgo.java index 75dd8a85..02bd44dc 100644 --- a/src/main/java/net/freerouting/autoroute/MazeShoveTraceAlgo.java +++ b/src/main/java/net/freerouting/autoroute/MazeShoveTraceAlgo.java @@ -21,67 +21,51 @@ package net.freerouting.autoroute; -import java.util.Collection; - -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.FloatLine; -import net.freerouting.geometry.planar.Side; -import net.freerouting.geometry.planar.Direction; -import net.freerouting.geometry.planar.LineSegment; - import net.freerouting.board.Item; import net.freerouting.board.RoutingBoard; import net.freerouting.board.ShoveTraceAlgo; +import net.freerouting.geometry.planar.*; + +import java.util.Collection; /** * Auxiliary functions used in MazeSearchAlgo. * * @author Alfons Wirtz */ -public class MazeShoveTraceAlgo -{ - +public class MazeShoveTraceAlgo { + /** * Returns false, if the algorithm did not succeed and trying to shove from another door section * may be more successful. */ public static boolean check_shove_trace_line(MazeListElement p_list_element, - ObstacleExpansionRoom p_obstacle_room, RoutingBoard p_board, AutorouteControl p_ctrl, - boolean p_shove_to_the_left, Collection p_to_door_list) - { - if (!(p_list_element.door instanceof ExpansionDoor)) - { + ObstacleExpansionRoom p_obstacle_room, RoutingBoard p_board, AutorouteControl p_ctrl, + boolean p_shove_to_the_left, Collection p_to_door_list) { + if (!(p_list_element.door instanceof ExpansionDoor)) { return true; } ExpansionDoor from_door = (ExpansionDoor) p_list_element.door; - if (!(p_obstacle_room.get_item() instanceof net.freerouting.board.PolylineTrace)) - { + if (!(p_obstacle_room.get_item() instanceof net.freerouting.board.PolylineTrace)) { return true; } - net.freerouting.board.PolylineTrace obstacle_trace = (net.freerouting.board.PolylineTrace)p_obstacle_room.get_item(); + net.freerouting.board.PolylineTrace obstacle_trace = (net.freerouting.board.PolylineTrace) p_obstacle_room.get_item(); int trace_layer = p_obstacle_room.get_layer(); // only traces with the same halfwidth and the same clearance class can be shoved. if (obstacle_trace.get_half_width() != p_ctrl.trace_half_width[trace_layer] - || obstacle_trace.clearance_class_no() != p_ctrl.trace_clearance_class_no) - { + || obstacle_trace.clearance_class_no() != p_ctrl.trace_clearance_class_no) { return true; } double compensated_trace_half_width = p_ctrl.compensated_trace_half_width[trace_layer]; TileShape from_door_shape = from_door.get_shape(); - if (from_door_shape.max_width() < 2 * compensated_trace_half_width) - { + if (from_door_shape.max_width() < 2 * compensated_trace_half_width) { return true; } int trace_corner_no = p_obstacle_room.get_index_in_item(); - + Polyline trace_polyline = obstacle_trace.polyline(); - - if (trace_corner_no >= trace_polyline.arr.length - 1) - { + + if (trace_corner_no >= trace_polyline.arr.length - 1) { System.out.println("MazeShoveTraceAlgo.check_shove_trace_line: trace_corner_no to big"); return false; } @@ -89,265 +73,212 @@ public static boolean check_shove_trace_line(MazeListElement p_list_element, // The side of the trace line seen from the doors to expand. // Used to determine, if a door is on the right side to put it into the p_door_list. LineSegment shove_line_segment; - if (from_door.dimension == 2) - { + if (from_door.dimension == 2) { // shove from a link door into the direction of the other link door. CompleteExpansionRoom other_room = from_door.other_room(p_obstacle_room); - if (!(other_room instanceof ObstacleExpansionRoom)) - { + if (!(other_room instanceof ObstacleExpansionRoom)) { return false; } - if (!end_points_matching(obstacle_trace, ((ObstacleExpansionRoom)other_room).get_item())) - { + if (!end_points_matching(obstacle_trace, ((ObstacleExpansionRoom) other_room).get_item())) { return false; } FloatPoint door_center = from_door_shape.centre_of_gravity(); FloatPoint corner_1 = trace_polyline.corner_approx(trace_corner_no); FloatPoint corner_2 = trace_polyline.corner_approx(trace_corner_no + 1); - if (corner_1.distance_square(corner_2) < 1) - { + if (corner_1.distance_square(corner_2) < 1) { // shove_line_segment may be reduced to a point return false; } boolean shove_into_direction_of_trace_start = door_center.distance_square(corner_2) < door_center.distance_square(corner_1); shove_line_segment = new LineSegment(trace_polyline, trace_corner_no + 1); - if (shove_into_direction_of_trace_start) - { - + if (shove_into_direction_of_trace_start) { + // shove from the endpoint to the start point of the line segment shove_line_segment = shove_line_segment.opposite(); } - } - else - { + } else { CompleteExpansionRoom from_room = from_door.other_room(p_obstacle_room); FloatPoint from_point = from_room.get_shape().centre_of_gravity(); Line shove_trace_line = trace_polyline.arr[trace_corner_no + 1]; FloatLine door_line_segment = from_door_shape.diagonal_corner_segment(); Side side_of_trace_line = shove_trace_line.side_of(door_line_segment.a, 0); - + FloatLine polar_line_segment = from_door_shape.polar_line_segment(from_point); - + boolean door_line_swapped = polar_line_segment.b.distance_square(door_line_segment.a) < - polar_line_segment.a.distance_square(door_line_segment.a); - + polar_line_segment.a.distance_square(door_line_segment.a); + boolean section_ok; // shove only from the right most section to the right or from the left most section to the left. - - double shape_entry_check_distance = compensated_trace_half_width + 5; + + double shape_entry_check_distance = compensated_trace_half_width + 5; double check_dist_square = shape_entry_check_distance * shape_entry_check_distance; - - if (p_shove_to_the_left && !door_line_swapped || !p_shove_to_the_left && door_line_swapped) - { + + if (p_shove_to_the_left && !door_line_swapped || !p_shove_to_the_left && door_line_swapped) { section_ok = p_list_element.section_no_of_door == p_list_element.door.maze_search_element_count() - 1 - && (p_list_element.shape_entry.a.distance_square(door_line_segment.b) <= check_dist_square - || p_list_element.shape_entry.b.distance_square(door_line_segment.b) <= check_dist_square); - } - else - { + && (p_list_element.shape_entry.a.distance_square(door_line_segment.b) <= check_dist_square + || p_list_element.shape_entry.b.distance_square(door_line_segment.b) <= check_dist_square); + } else { section_ok = p_list_element.section_no_of_door == 0 - && (p_list_element.shape_entry.a.distance_square(door_line_segment.a) <= check_dist_square - || p_list_element.shape_entry.b.distance_square(door_line_segment.a) <= check_dist_square); + && (p_list_element.shape_entry.a.distance_square(door_line_segment.a) <= check_dist_square + || p_list_element.shape_entry.b.distance_square(door_line_segment.a) <= check_dist_square); } - if (!section_ok) - { + if (!section_ok) { return false; } - - + + // create the line segment for shoving - + FloatLine shrinked_line_segment = polar_line_segment.shrink_segment(compensated_trace_half_width); Direction perpendicular_direction = shove_trace_line.direction().turn_45_degree(2); - if (side_of_trace_line == Side.ON_THE_LEFT) - { - if (p_shove_to_the_left) - { + if (side_of_trace_line == Side.ON_THE_LEFT) { + if (p_shove_to_the_left) { Line start_closing_line = new Line(shrinked_line_segment.b.round(), perpendicular_direction); shove_line_segment = new LineSegment(start_closing_line, trace_polyline.arr[trace_corner_no + 1], - trace_polyline.arr[trace_corner_no + 2]); - } - else - { + trace_polyline.arr[trace_corner_no + 2]); + } else { Line start_closing_line = new Line(shrinked_line_segment.a.round(), perpendicular_direction); shove_line_segment = new LineSegment(start_closing_line, trace_polyline.arr[trace_corner_no + 1].opposite(), - trace_polyline.arr[trace_corner_no].opposite()); + trace_polyline.arr[trace_corner_no].opposite()); } - } - else - { - if (p_shove_to_the_left) - { + } else { + if (p_shove_to_the_left) { Line start_closing_line = new Line(shrinked_line_segment.b.round(), perpendicular_direction); shove_line_segment = new LineSegment(start_closing_line, trace_polyline.arr[trace_corner_no + 1].opposite(), - trace_polyline.arr[trace_corner_no].opposite()); - } - else - { + trace_polyline.arr[trace_corner_no].opposite()); + } else { Line start_closing_line = new Line(shrinked_line_segment.a.round(), perpendicular_direction); shove_line_segment = new LineSegment(start_closing_line, trace_polyline.arr[trace_corner_no + 1], - trace_polyline.arr[trace_corner_no + 2]); + trace_polyline.arr[trace_corner_no + 2]); } } } int trace_half_width = p_ctrl.trace_half_width[trace_layer]; - int [] net_no_arr = new int[1]; + int[] net_no_arr = new int[1]; net_no_arr[0] = p_ctrl.net_no; - + double shove_width = p_board.check_trace_segment(shove_line_segment, trace_layer, net_no_arr, trace_half_width, - p_ctrl.trace_clearance_class_no, true); + p_ctrl.trace_clearance_class_no, true); boolean segment_shortened = false; - if (shove_width < Integer.MAX_VALUE) - { + if (shove_width < Integer.MAX_VALUE) { // shorten shove_line_segment shove_width = shove_width - 1; - if (shove_width <= 0) - { + if (shove_width <= 0) { return true; } shove_line_segment = shove_line_segment.change_length_approx(shove_width); segment_shortened = true; } - + FloatPoint from_corner = shove_line_segment.start_point_approx(); FloatPoint to_corner = shove_line_segment.end_point_approx(); boolean segment_ist_point = from_corner.distance_square(to_corner) < 0.1; - - if (!segment_ist_point) - { + + if (!segment_ist_point) { shove_width = ShoveTraceAlgo.check(p_board, shove_line_segment, p_shove_to_the_left, trace_layer, net_no_arr, trace_half_width, p_ctrl.trace_clearance_class_no, p_ctrl.max_shove_trace_recursion_depth, p_ctrl.max_shove_via_recursion_depth); - - if (shove_width <= 0) - { + + if (shove_width <= 0) { return true; } } - + // Put the doors on this side of the room into p_to_door_list with - if (segment_shortened) - { + if (segment_shortened) { shove_width = Math.min(shove_width, from_corner.distance(to_corner)); } - + Line shove_line = shove_line_segment.get_line(); - + // From_door_compare_distance is used to check, that a door is between from_door and the end point // of the shove line. double from_door_compare_distance; - if (from_door.dimension == 2 || segment_ist_point) - { + if (from_door.dimension == 2 || segment_ist_point) { from_door_compare_distance = Double.MAX_VALUE; - } - else - { + } else { from_door_compare_distance = to_corner.distance_square(from_door_shape.corner_approx(0)); } - - for (ExpansionDoor curr_door : room_doors) - { - if (curr_door == from_door) - { + + for (ExpansionDoor curr_door : room_doors) { + if (curr_door == from_door) { continue; } if (curr_door.first_room instanceof ObstacleExpansionRoom && - curr_door.second_room instanceof ObstacleExpansionRoom) - { - Item first_room_item = ((ObstacleExpansionRoom)curr_door.first_room).get_item(); - Item second_room_item = ((ObstacleExpansionRoom)curr_door.second_room).get_item(); - if (first_room_item != second_room_item) - { + curr_door.second_room instanceof ObstacleExpansionRoom) { + Item first_room_item = ((ObstacleExpansionRoom) curr_door.first_room).get_item(); + Item second_room_item = ((ObstacleExpansionRoom) curr_door.second_room).get_item(); + if (first_room_item != second_room_item) { // there may be topological problems at a trace fork continue; } } TileShape curr_door_shape = curr_door.get_shape(); - if (curr_door.dimension == 2 && shove_width >= Integer.MAX_VALUE) - { + if (curr_door.dimension == 2 && shove_width >= Integer.MAX_VALUE) { boolean add_link_door = curr_door_shape.contains(to_corner); - - - if (add_link_door) - { + + + if (add_link_door) { FloatLine[] line_sections = curr_door.get_section_segments(compensated_trace_half_width); p_to_door_list.add(new DoorSection(curr_door, 0, line_sections[0])); } continue; - } - else if (!segment_ist_point) - { + } else if (!segment_ist_point) { // now curr_door is 1-dimensional - + // check, that curr_door is on the same border_line as p_from_door. FloatLine curr_door_segment = curr_door_shape.diagonal_corner_segment(); - if (curr_door_segment == null) - { - if (p_board.get_test_level() == net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT) - { + if (curr_door_segment == null) { + if (p_board.get_test_level() == net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT) { System.out.println("MazeShoveTraceAlgo.check_shove_trace_line: door shape is empty"); } continue; } Side start_corner_side_of_trace_line = shove_line.side_of(curr_door_segment.a, 0); Side end_corner_side_of_trace_line = shove_line.side_of(curr_door_segment.b, 0); - if (p_shove_to_the_left) - { - if (start_corner_side_of_trace_line != Side.ON_THE_LEFT || end_corner_side_of_trace_line != Side.ON_THE_LEFT) - { + if (p_shove_to_the_left) { + if (start_corner_side_of_trace_line != Side.ON_THE_LEFT || end_corner_side_of_trace_line != Side.ON_THE_LEFT) { continue; } - } - else - { - if (start_corner_side_of_trace_line != Side.ON_THE_RIGHT || end_corner_side_of_trace_line != Side.ON_THE_RIGHT) - { + } else { + if (start_corner_side_of_trace_line != Side.ON_THE_RIGHT || end_corner_side_of_trace_line != Side.ON_THE_RIGHT) { continue; } } FloatLine curr_door_line = curr_door_shape.polar_line_segment(from_corner); FloatPoint curr_door_nearest_corner; - if (curr_door_line.a.distance_square(from_corner) <= curr_door_line.b.distance_square(from_corner)) - { + if (curr_door_line.a.distance_square(from_corner) <= curr_door_line.b.distance_square(from_corner)) { curr_door_nearest_corner = curr_door_line.a; - } - else - { + } else { curr_door_nearest_corner = curr_door_line.b; } - if (to_corner.distance_square(curr_door_nearest_corner) >= from_door_compare_distance) - { + if (to_corner.distance_square(curr_door_nearest_corner) >= from_door_compare_distance) { // curr_door is not located into the direction of to_corner. continue; } FloatPoint curr_door_projection = curr_door_nearest_corner.projection_approx(shove_line); - - if (curr_door_projection.distance(from_corner) + compensated_trace_half_width <= shove_width) - { + + if (curr_door_projection.distance(from_corner) + compensated_trace_half_width <= shove_width) { FloatLine[] line_sections = curr_door.get_section_segments(compensated_trace_half_width); - for (int i = 0; i < line_sections.length; ++i) - { + for (int i = 0; i < line_sections.length; ++i) { FloatLine curr_line_section = line_sections[i]; FloatPoint curr_section_nearest_corner; - if (curr_line_section.a.distance_square(from_corner) <= curr_line_section.b.distance_square(from_corner)) - { + if (curr_line_section.a.distance_square(from_corner) <= curr_line_section.b.distance_square(from_corner)) { curr_section_nearest_corner = curr_line_section.a; - } - else - { + } else { curr_section_nearest_corner = curr_line_section.b; } FloatPoint curr_section_projection = curr_section_nearest_corner.projection_approx(shove_line); - if (curr_section_projection.distance(from_corner) <= shove_width) - { + if (curr_section_projection.distance(from_corner) <= shove_width) { p_to_door_list.add(new DoorSection(curr_door, i, curr_line_section)); } } @@ -356,53 +287,43 @@ else if (!segment_ist_point) } return true; } - + /** * Check if the endpoints of p_trace and p_from_item are maching, so that the * shove can continue through a link door. */ - private static boolean end_points_matching(net.freerouting.board.PolylineTrace p_trace, Item p_from_item) - { - if (p_from_item == p_trace) - { + private static boolean end_points_matching(net.freerouting.board.PolylineTrace p_trace, Item p_from_item) { + if (p_from_item == p_trace) { return true; } - if (!p_trace.shares_net(p_from_item)) - { + if (!p_trace.shares_net(p_from_item)) { return false; } boolean points_matching; - if (p_from_item instanceof net.freerouting.board.DrillItem) - { + if (p_from_item instanceof net.freerouting.board.DrillItem) { Point from_center = ((net.freerouting.board.DrillItem) p_from_item).get_center(); - points_matching = from_center.equals(p_trace.first_corner()) || from_center.equals(p_trace.last_corner()); - } - else if (p_from_item instanceof net.freerouting.board.PolylineTrace) - { + points_matching = from_center.equals(p_trace.first_corner()) || from_center.equals(p_trace.last_corner()); + } else if (p_from_item instanceof net.freerouting.board.PolylineTrace) { net.freerouting.board.PolylineTrace from_trace = (net.freerouting.board.PolylineTrace) p_from_item; points_matching = p_trace.first_corner().equals(from_trace.first_corner()) || p_trace.first_corner().equals(from_trace.last_corner()) || p_trace.last_corner().equals(from_trace.first_corner()) || p_trace.last_corner().equals(from_trace.last_corner()); - } - else - { + } else { points_matching = false; } return points_matching; } - - public static class DoorSection - { - DoorSection(ExpansionDoor p_door, int p_section_no, FloatLine p_section_line) - { + + public static class DoorSection { + final ExpansionDoor door; + final int section_no; + final FloatLine section_line; + DoorSection(ExpansionDoor p_door, int p_section_no, FloatLine p_section_line) { door = p_door; section_no = p_section_no; section_line = p_section_line; - + } - final ExpansionDoor door; - final int section_no; - final FloatLine section_line; } } diff --git a/src/main/java/net/freerouting/autoroute/ObstacleExpansionRoom.java b/src/main/java/net/freerouting/autoroute/ObstacleExpansionRoom.java index 512148a4..a6502561 100644 --- a/src/main/java/net/freerouting/autoroute/ObstacleExpansionRoom.java +++ b/src/main/java/net/freerouting/autoroute/ObstacleExpansionRoom.java @@ -21,103 +21,95 @@ package net.freerouting.autoroute; -import java.util.List; -import java.util.Collection; - -import net.freerouting.board.ShapeSearchTree; -import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.Item; import net.freerouting.board.PolylineTrace; - +import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.ShapeSearchTree; import net.freerouting.geometry.planar.TileShape; -import net.freerouting.board.Item; +import java.util.Collection; +import java.util.List; /** * Expansion Room used for pushing and ripping obstacles in the autoroute algorithm. * * @author Alfons Wirtz */ -public class ObstacleExpansionRoom implements CompleteExpansionRoom -{ - - /** Creates a new instance of ObstacleExpansionRoom */ - ObstacleExpansionRoom(Item p_item, int p_index_in_item, ShapeSearchTree p_shape_tree) - { +public class ObstacleExpansionRoom implements CompleteExpansionRoom { + + private final Item item; + private final int index_in_item; + private final TileShape shape; + /** + * The list of doors to neighbour expansion rooms + */ + private List doors; + private boolean doors_calculated = false; + + /** + * Creates a new instance of ObstacleExpansionRoom + */ + ObstacleExpansionRoom(Item p_item, int p_index_in_item, ShapeSearchTree p_shape_tree) { this.item = p_item; this.index_in_item = p_index_in_item; this.shape = p_item.get_tree_shape(p_shape_tree, p_index_in_item); this.doors = new java.util.LinkedList(); } - - public int get_index_in_item() - { + + public int get_index_in_item() { return this.index_in_item; } - - public int get_layer() - { + + public int get_layer() { return this.item.shape_layer(this.index_in_item); } - - public TileShape get_shape() - { + + public TileShape get_shape() { return this.shape; } - + /** * Checks, if this room has already a 1-dimensional door to p_other */ - public boolean door_exists(ExpansionRoom p_other) - { - if (doors != null) - { - for (ExpansionDoor curr_door : this.doors) - { - if (curr_door.first_room == p_other || curr_door.second_room == p_other) - { + public boolean door_exists(ExpansionRoom p_other) { + if (doors != null) { + for (ExpansionDoor curr_door : this.doors) { + if (curr_door.first_room == p_other || curr_door.second_room == p_other) { return true; } } } return false; } - + /** * Adds a door to the door list of this room. */ - public void add_door(ExpansionDoor p_door) - { + public void add_door(ExpansionDoor p_door) { this.doors.add(p_door); } - + /** * Creates a 2-dim door with the other obstacle room, if that is useful for the autoroute algorithm. * It is assumed that this room and p_other have a 2-dimensional overlap. * Returns false, if no door was created. */ - public boolean create_overlap_door(ObstacleExpansionRoom p_other) - { - if (this.door_exists(p_other)) - { + public boolean create_overlap_door(ObstacleExpansionRoom p_other) { + if (this.door_exists(p_other)) { return false; } - if (!(this.item.is_route() && p_other.item.is_route())) - { + if (!(this.item.is_route() && p_other.item.is_route())) { return false; } - if (!this.item.shares_net(p_other.item)) - { + if (!this.item.shares_net(p_other.item)) { return false; } - if (this.item == p_other.item) - { - if (!(this.item instanceof PolylineTrace)) - { + if (this.item == p_other.item) { + if (!(this.item instanceof PolylineTrace)) { return false; } // create only doors between consecutive trace segments - if (this.index_in_item != p_other.index_in_item + 1 && this.index_in_item != p_other.index_in_item - 1) - { + if (this.index_in_item != p_other.index_in_item + 1 && this.index_in_item != p_other.index_in_item - 1) { return false; } } @@ -126,82 +118,61 @@ public boolean create_overlap_door(ObstacleExpansionRoom p_other) p_other.add_door(new_door); return true; } - + /** * Returns the list of doors of this room to neighbour expansion rooms */ - public List get_doors() - { + public List get_doors() { return this.doors; } - + /** * Removes all doors from this room. */ - public void clear_doors() - { + public void clear_doors() { this.doors = new java.util.LinkedList(); } - - public void reset_doors() - { - for (ExpandableObject curr_door : this.doors) - { + + public void reset_doors() { + for (ExpandableObject curr_door : this.doors) { curr_door.reset(); } } - - public Collection get_target_doors() - { + + public Collection get_target_doors() { return new java.util.LinkedList(); } - - public Item get_item() - { + + public Item get_item() { return this.item; } - - public SearchTreeObject get_object() - { + + public SearchTreeObject get_object() { return this.item; } - - public boolean remove_door(ExpandableObject p_door) - { + + public boolean remove_door(ExpandableObject p_door) { return this.doors.remove(p_door); } - + /** * Returns, if all doors to the neighbour rooms are calculated. */ - boolean all_doors_calculated() - { + boolean all_doors_calculated() { return this.doors_calculated; } - - void set_doors_calculated(boolean p_value) - { + + void set_doors_calculated(boolean p_value) { this.doors_calculated = p_value; } - - + /** * Draws the shape of this room. */ - public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) - { + public void draw(java.awt.Graphics p_graphics, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, double p_intensity) { java.awt.Color draw_color = java.awt.Color.WHITE; double layer_visibility = p_graphics_context.get_layer_visibility(this.get_layer()); p_graphics_context.fill_area(this.get_shape(), p_graphics, draw_color, p_intensity * layer_visibility); p_graphics_context.draw_boundary(this.get_shape(), 0, draw_color, p_graphics, layer_visibility); } - - private final Item item; - private final int index_in_item; - private final TileShape shape; - - /** The list of doors to neighbour expansion rooms */ - private List doors; - - private boolean doors_calculated = false; } diff --git a/src/main/java/net/freerouting/autoroute/Sorted45DegreeRoomNeighbours.java b/src/main/java/net/freerouting/autoroute/Sorted45DegreeRoomNeighbours.java index d697eb6b..0ac2e571 100644 --- a/src/main/java/net/freerouting/autoroute/Sorted45DegreeRoomNeighbours.java +++ b/src/main/java/net/freerouting/autoroute/Sorted45DegreeRoomNeighbours.java @@ -21,87 +21,83 @@ package net.freerouting.autoroute; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.SortedSet; -import java.util.TreeSet; - +import net.freerouting.board.Item; +import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.ShapeSearchTree; import net.freerouting.datastructures.ShapeTree; +import net.freerouting.geometry.planar.*; -import net.freerouting.geometry.planar.Limits; -import net.freerouting.geometry.planar.IntOctagon; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.FloatPoint; - -import net.freerouting.board.ShapeSearchTree; -import net.freerouting.board.SearchTreeObject; -import net.freerouting.board.Item; +import java.util.*; /** - * * @author Alfons Wirtz */ -public class Sorted45DegreeRoomNeighbours -{ - - public static CompleteExpansionRoom calculate(ExpansionRoom p_room, AutorouteEngine p_autoroute_engine) - { +public class Sorted45DegreeRoomNeighbours { + + public final CompleteExpansionRoom completed_room; + public final SortedSet sorted_neighbours; + private final ExpansionRoom from_room; + private final IntOctagon room_shape; + private final boolean[] edge_interiour_touches_obstacle; + + /** + * Creates a new instance of Sorted45DegreeRoomNeighbours + */ + private Sorted45DegreeRoomNeighbours(ExpansionRoom p_from_room, CompleteExpansionRoom p_completed_room) { + from_room = p_from_room; + completed_room = p_completed_room; + room_shape = p_completed_room.get_shape().bounding_octagon(); + sorted_neighbours = new TreeSet(); + + edge_interiour_touches_obstacle = new boolean[8]; + for (int i = 0; i < 8; ++i) { + edge_interiour_touches_obstacle[i] = false; + } + } + + public static CompleteExpansionRoom calculate(ExpansionRoom p_room, AutorouteEngine p_autoroute_engine) { int net_no = p_autoroute_engine.get_net_no(); - Sorted45DegreeRoomNeighbours room_neighbours = Sorted45DegreeRoomNeighbours.calculate_neighbours(p_room, net_no, + Sorted45DegreeRoomNeighbours room_neighbours = Sorted45DegreeRoomNeighbours.calculate_neighbours(p_room, net_no, p_autoroute_engine.autoroute_search_tree, p_autoroute_engine.generate_room_id_no()); - if (room_neighbours == null) - { + if (room_neighbours == null) { return null; } - + // Check, that each side of the romm shape has at least one touching neighbour. // Otherwise improve the room shape by enlarging. boolean edge_removed = room_neighbours.try_remove_edge_line(net_no, p_autoroute_engine.autoroute_search_tree); CompleteExpansionRoom result = room_neighbours.completed_room; - if (edge_removed) - { + if (edge_removed) { p_autoroute_engine.remove_all_doors(result); return calculate(p_room, p_autoroute_engine); } - + // Now calculate the new incomplete rooms together with the doors // between this room and the sorted neighbours. - - if (room_neighbours.sorted_neighbours.isEmpty()) - { - if (result instanceof ObstacleExpansionRoom) - { + + if (room_neighbours.sorted_neighbours.isEmpty()) { + if (result instanceof ObstacleExpansionRoom) { room_neighbours.calculate_edge_incomplete_rooms_of_obstacle_expansion_room(0, 7, p_autoroute_engine); } - } - else - { + } else { room_neighbours.calculate_new_incomplete_rooms(p_autoroute_engine); } return result; } - + /** * Calculates all touching neighbours of p_room and sorts them in * counterclock sense around the boundary of the room shape. */ private static Sorted45DegreeRoomNeighbours calculate_neighbours(ExpansionRoom p_room, int p_net_no, - ShapeSearchTree p_autoroute_search_tree, int p_room_id_no) - { - TileShape room_shape = p_room.get_shape(); + ShapeSearchTree p_autoroute_search_tree, int p_room_id_no) { + TileShape room_shape = p_room.get_shape(); CompleteExpansionRoom completed_room; - if (p_room instanceof IncompleteFreeSpaceExpansionRoom) - { + if (p_room instanceof IncompleteFreeSpaceExpansionRoom) { completed_room = new CompleteFreeSpaceExpansionRoom(room_shape, p_room.get_layer(), p_room_id_no); - } - else if (p_room instanceof ObstacleExpansionRoom) - { - completed_room = (ObstacleExpansionRoom)p_room; - } - else - { + } else if (p_room instanceof ObstacleExpansionRoom) { + completed_room = (ObstacleExpansionRoom) p_room; + } else { System.out.println("Sorted45DegreeRoomNeighbours.calculate_neighbours: unexpected expansion room type"); return null; } @@ -111,15 +107,12 @@ else if (p_room instanceof ObstacleExpansionRoom) p_autoroute_search_tree.overlapping_tree_entries(room_shape, p_room.get_layer(), overlapping_objects); // Calculate the touching neigbour objects and sort them in counterclock sence // around the border of the room shape. - for (ShapeTree.TreeEntry curr_entry : overlapping_objects) - { + for (ShapeTree.TreeEntry curr_entry : overlapping_objects) { SearchTreeObject curr_object = (SearchTreeObject) curr_entry.object; - if (curr_object == p_room) - { + if (curr_object == p_room) { continue; } - if ((completed_room instanceof CompleteFreeSpaceExpansionRoom) && !curr_object.is_trace_obstacle(p_net_no)) - { + if ((completed_room instanceof CompleteFreeSpaceExpansionRoom) && !curr_object.is_trace_obstacle(p_net_no)) { ((CompleteFreeSpaceExpansionRoom) completed_room).calculate_target_doors(curr_entry, p_net_no, p_autoroute_search_tree); continue; @@ -129,51 +122,40 @@ else if (p_room instanceof ObstacleExpansionRoom) IntOctagon curr_oct = curr_shape.bounding_octagon(); IntOctagon intersection = room_oct.intersection(curr_oct); int dimension = intersection.dimension(); - if (dimension > 1 && completed_room instanceof ObstacleExpansionRoom) - { - if (curr_object instanceof Item) - { + if (dimension > 1 && completed_room instanceof ObstacleExpansionRoom) { + if (curr_object instanceof Item) { // only Obstacle expansion roos may have a 2-dim overlap Item curr_item = (Item) curr_object; - if (curr_item.is_route()) - { + if (curr_item.is_route()) { ItemAutorouteInfo item_info = curr_item.get_autoroute_info(); - ObstacleExpansionRoom curr_overlap_room = + ObstacleExpansionRoom curr_overlap_room = item_info.get_expansion_room(curr_entry.shape_index_in_object, p_autoroute_search_tree); ((ObstacleExpansionRoom) completed_room).create_overlap_door(curr_overlap_room); } } continue; } - if (dimension < 0) - { + if (dimension < 0) { // may happen at a corner from 2 diagonal lines with non integer coordinates (--.5, ---.5). continue; } result.add_sorted_neighbour(curr_oct, intersection); - if (dimension > 0) - { + if (dimension > 0) { // make shure, that there is a door to the neighbour room. ExpansionRoom neighbour_room = null; - if (curr_object instanceof ExpansionRoom) - { + if (curr_object instanceof ExpansionRoom) { neighbour_room = (ExpansionRoom) curr_object; - } - else if (curr_object instanceof Item) - { + } else if (curr_object instanceof Item) { Item curr_item = (Item) curr_object; - if (curr_item.is_route()) - { + if (curr_item.is_route()) { // expand the item for ripup and pushing purposes ItemAutorouteInfo item_info = curr_item.get_autoroute_info(); - neighbour_room = + neighbour_room = item_info.get_expansion_room(curr_entry.shape_index_in_object, p_autoroute_search_tree); } } - if (neighbour_room != null) - { - if (SortedRoomNeighbours.insert_door_ok(completed_room, neighbour_room, intersection)) - { + if (neighbour_room != null) { + if (SortedRoomNeighbours.insert_door_ok(completed_room, neighbour_room, intersection)) { ExpansionDoor new_door = new ExpansionDoor(completed_room, neighbour_room); neighbour_room.add_door(new_door); completed_room.add_door(new_door); @@ -183,51 +165,92 @@ else if (curr_object instanceof Item) } return result; } - - - /** Creates a new instance of Sorted45DegreeRoomNeighbours */ - private Sorted45DegreeRoomNeighbours(ExpansionRoom p_from_room, CompleteExpansionRoom p_completed_room) - { - from_room = p_from_room; - completed_room = p_completed_room; - room_shape = p_completed_room.get_shape().bounding_octagon(); - sorted_neighbours = new TreeSet(); - - edge_interiour_touches_obstacle = new boolean[8]; - for (int i = 0; i < 8; ++i) - { - edge_interiour_touches_obstacle[i] = false; + + private static IntOctagon remove_not_touching_border_lines(IntOctagon p_room_oct, + boolean[] p_edge_interiour_touches_obstacle) { + int lx; + if (p_edge_interiour_touches_obstacle[6]) { + lx = p_room_oct.lx; + } else { + lx = -Limits.CRIT_INT; + } + + int ly; + if (p_edge_interiour_touches_obstacle[0]) { + ly = p_room_oct.ly; + } else { + ly = -Limits.CRIT_INT; + } + + int rx; + if (p_edge_interiour_touches_obstacle[2]) { + rx = p_room_oct.rx; + } else { + rx = Limits.CRIT_INT; + } + + + int uy; + if (p_edge_interiour_touches_obstacle[4]) { + uy = p_room_oct.uy; + } else { + uy = Limits.CRIT_INT; + } + + int ulx; + if (p_edge_interiour_touches_obstacle[5]) { + ulx = p_room_oct.ulx; + } else { + ulx = -Limits.CRIT_INT; + } + + int lrx; + if (p_edge_interiour_touches_obstacle[1]) { + lrx = p_room_oct.lrx; + } else { + lrx = Limits.CRIT_INT; + } + + int llx; + if (p_edge_interiour_touches_obstacle[7]) { + llx = p_room_oct.llx; + } else { + llx = -Limits.CRIT_INT; + } + + int urx; + if (p_edge_interiour_touches_obstacle[3]) { + urx = p_room_oct.urx; + } else { + urx = Limits.CRIT_INT; } + + IntOctagon result = new IntOctagon(lx, ly, rx, uy, ulx, lrx, llx, urx); + return result.normalize(); } - - private void add_sorted_neighbour(IntOctagon p_neighbour_shape, IntOctagon p_intersection) - { + + private void add_sorted_neighbour(IntOctagon p_neighbour_shape, IntOctagon p_intersection) { SortedRoomNeighbour new_neighbour = new SortedRoomNeighbour(p_neighbour_shape, p_intersection); - if (new_neighbour.last_touching_side >= 0) - { + if (new_neighbour.last_touching_side >= 0) { sorted_neighbours.add(new_neighbour); } } - + /** * Calculates an incomplete room for each edge side from p_from_side_no to p_to_side_no. */ - private void calculate_edge_incomplete_rooms_of_obstacle_expansion_room(int p_from_side_no, int p_to_side_no, AutorouteEngine p_autoroute_engine) - { - if (!(this.from_room instanceof ObstacleExpansionRoom)) - { + private void calculate_edge_incomplete_rooms_of_obstacle_expansion_room(int p_from_side_no, int p_to_side_no, AutorouteEngine p_autoroute_engine) { + if (!(this.from_room instanceof ObstacleExpansionRoom)) { System.out.println("Sorted45DegreeRoomNeighbours.calculate_side_incomplete_rooms_of_obstacle_expansion_room: ObstacleExpansionRoom expected for this.from_room"); return; } IntOctagon board_bounding_oct = p_autoroute_engine.board.get_bounding_box().bounding_octagon(); IntPoint curr_corner = this.room_shape.corner(p_from_side_no); int curr_side_no = p_from_side_no; - for (;;) - { + for (; ; ) { int next_side_no = (curr_side_no + 1) % 8; - IntPoint next_corner = this.room_shape.corner(next_side_no); - if (!curr_corner.equals(next_corner)) - { + IntPoint next_corner = this.room_shape.corner(next_side_no); + if (!curr_corner.equals(next_corner)) { int lx = board_bounding_oct.lx; int ly = board_bounding_oct.ly; int rx = board_bounding_oct.rx; @@ -236,200 +259,84 @@ private void calculate_edge_incomplete_rooms_of_obstacle_expansion_room(int p_fr int lrx = board_bounding_oct.lrx; int llx = board_bounding_oct.llx; int urx = board_bounding_oct.urx; - if (curr_side_no == 0) - { + if (curr_side_no == 0) { uy = this.room_shape.ly; - } - else if (curr_side_no == 1) - { + } else if (curr_side_no == 1) { ulx = this.room_shape.lrx; - } - else if (curr_side_no == 2) - { + } else if (curr_side_no == 2) { lx = this.room_shape.rx; - } - else if (curr_side_no == 3) - { + } else if (curr_side_no == 3) { llx = this.room_shape.urx; - } - else if (curr_side_no == 4) - { + } else if (curr_side_no == 4) { ly = this.room_shape.uy; - } - else if (curr_side_no == 5) - { + } else if (curr_side_no == 5) { lrx = this.room_shape.ulx; - } - else if (curr_side_no == 6) - { + } else if (curr_side_no == 6) { rx = this.room_shape.lx; - } - else if (curr_side_no == 7) - { + } else if (curr_side_no == 7) { urx = this.room_shape.llx; - } - else - { + } else { System.out.println("SortedOrthoganelRoomNeighbours.calculate_edge_incomplete_rooms_of_obstacle_expansion_room: curr_side_no illegal"); return; } insert_incomplete_room(p_autoroute_engine, lx, ly, rx, uy, ulx, lrx, llx, urx); } - if (curr_side_no == p_to_side_no) - { + if (curr_side_no == p_to_side_no) { break; } curr_side_no = next_side_no; } } - - private static IntOctagon remove_not_touching_border_lines( IntOctagon p_room_oct, - boolean[] p_edge_interiour_touches_obstacle) - { - int lx; - if (p_edge_interiour_touches_obstacle[6]) - { - lx = p_room_oct.lx; - } - else - { - lx = -Limits.CRIT_INT; - } - - int ly; - if (p_edge_interiour_touches_obstacle[0]) - { - ly = p_room_oct.ly; - } - else - { - ly = -Limits.CRIT_INT; - } - - int rx; - if (p_edge_interiour_touches_obstacle[2]) - { - rx = p_room_oct.rx; - } - else - { - rx = Limits.CRIT_INT; - } - - - int uy; - if (p_edge_interiour_touches_obstacle[4]) - { - uy = p_room_oct.uy; - } - else - { - uy = Limits.CRIT_INT; - } - - int ulx; - if (p_edge_interiour_touches_obstacle[5]) - { - ulx = p_room_oct.ulx; - } - else - { - ulx = -Limits.CRIT_INT; - } - - int lrx; - if (p_edge_interiour_touches_obstacle[1]) - { - lrx = p_room_oct.lrx; - } - else - { - lrx = Limits.CRIT_INT; - } - - int llx; - if (p_edge_interiour_touches_obstacle[7]) - { - llx = p_room_oct.llx; - } - else - { - llx = -Limits.CRIT_INT; - } - - int urx; - if (p_edge_interiour_touches_obstacle[3]) - { - urx = p_room_oct.urx; - } - else - { - urx = Limits.CRIT_INT; - } - - IntOctagon result = new IntOctagon( lx, ly, rx, uy, ulx, lrx, llx, urx); - return result.normalize(); - } + /** * Check, that each side of the romm shape has at least one touching neighbour. * Otherwise the room shape will be improved the by enlarging. * Returns true, if the room shape was changed. */ - private boolean try_remove_edge_line(int p_net_no, ShapeSearchTree p_autoroute_search_tree) - { - if (!(this.from_room instanceof IncompleteFreeSpaceExpansionRoom)) - { + private boolean try_remove_edge_line(int p_net_no, ShapeSearchTree p_autoroute_search_tree) { + if (!(this.from_room instanceof IncompleteFreeSpaceExpansionRoom)) { return false; } IncompleteFreeSpaceExpansionRoom curr_incomplete_room = (IncompleteFreeSpaceExpansionRoom) this.from_room; - if (!(curr_incomplete_room.get_shape() instanceof IntOctagon)) - { + if (!(curr_incomplete_room.get_shape() instanceof IntOctagon)) { System.out.println("Sorted45DegreeRoomNeighbours.try_remove_edge_line: IntOctagon expected for room_shape type"); return false; } - IntOctagon room_oct = (IntOctagon) curr_incomplete_room.get_shape(); + IntOctagon room_oct = (IntOctagon) curr_incomplete_room.get_shape(); double room_area = room_oct.area(); - + boolean try_remove_edge_lines = false; - for (int i = 0; i < 8; ++i) - { - if (!this.edge_interiour_touches_obstacle[i]) - { + for (int i = 0; i < 8; ++i) { + if (!this.edge_interiour_touches_obstacle[i]) { FloatPoint prev_corner = this.room_shape.corner_approx(i); FloatPoint next_corner = this.room_shape.corner_approx(this.room_shape.next_no(i)); - if(prev_corner.distance_square(next_corner) > 1) - { + if (prev_corner.distance_square(next_corner) > 1) { try_remove_edge_lines = true; break; } } } - - if (try_remove_edge_lines) - { + + if (try_remove_edge_lines) { // Touching neighbour missing at the edge side with index remove_edge_no // Remove the edge line and restart the algorithm. - - IntOctagon enlarged_oct = remove_not_touching_border_lines( room_oct, this.edge_interiour_touches_obstacle); - + + IntOctagon enlarged_oct = remove_not_touching_border_lines(room_oct, this.edge_interiour_touches_obstacle); + Collection door_list = this.completed_room.get_doors(); TileShape ignore_shape = null; SearchTreeObject ignore_object = null; double max_door_area = 0; - for (ExpansionDoor curr_door: door_list) - { + for (ExpansionDoor curr_door : door_list) { // insert the overlapping doors with CompleteFreeSpaceExpansionRooms // for the information in complete_shape about the objects to ignore. - if (curr_door.dimension == 2) - { + if (curr_door.dimension == 2) { CompleteExpansionRoom other_room = curr_door.other_room(this.completed_room); { - if (other_room instanceof CompleteFreeSpaceExpansionRoom) - { + if (other_room instanceof CompleteFreeSpaceExpansionRoom) { TileShape curr_door_shape = curr_door.get_shape(); double curr_door_area = curr_door_shape.area(); - if (curr_door_area > max_door_area) - { + if (curr_door_area > max_door_area) { max_door_area = curr_door_area; ignore_shape = curr_door_shape; ignore_object = (CompleteFreeSpaceExpansionRoom) other_room; @@ -440,15 +347,13 @@ private boolean try_remove_edge_line(int p_net_no, ShapeSearchTree p_autoroute_s } IncompleteFreeSpaceExpansionRoom enlarged_room = new IncompleteFreeSpaceExpansionRoom(enlarged_oct, curr_incomplete_room.get_layer(), - curr_incomplete_room.get_contained_shape()); - Collection new_rooms = + curr_incomplete_room.get_contained_shape()); + Collection new_rooms = p_autoroute_search_tree.complete_shape(enlarged_room, p_net_no, ignore_object, ignore_shape); - if (new_rooms.size() == 1) - { + if (new_rooms.size() == 1) { // Check, that the area increases to prevent endless loop. IncompleteFreeSpaceExpansionRoom new_room = new_rooms.iterator().next(); - if (new_room.get_shape().area() > room_area) - { + if (new_room.get_shape().area() > room_area) { curr_incomplete_room.set_shape(new_room.get_shape()); curr_incomplete_room.set_contained_shape(new_room.get_contained_shape()); return true; @@ -457,23 +362,19 @@ private boolean try_remove_edge_line(int p_net_no, ShapeSearchTree p_autoroute_s } return false; } - + /** * Inserts a new incomplete room with an octagon shape. */ private void insert_incomplete_room(AutorouteEngine p_autoroute_engine, int p_lx, int p_ly, int p_rx, int p_uy, - int p_ulx, int p_lrx, int p_llx, int p_urx) - { + int p_ulx, int p_lrx, int p_llx, int p_urx) { IntOctagon new_incomplete_room_shape = new IntOctagon(p_lx, p_ly, p_rx, p_uy, p_ulx, p_lrx, p_llx, p_urx); new_incomplete_room_shape = new_incomplete_room_shape.normalize(); - if (new_incomplete_room_shape.dimension() == 2) - { + if (new_incomplete_room_shape.dimension() == 2) { IntOctagon new_contained_shape = this.room_shape.intersection(new_incomplete_room_shape); - if (!new_contained_shape.is_empty()) - { + if (!new_contained_shape.is_empty()) { int door_dimension = new_contained_shape.dimension(); - if (door_dimension > 0) - { + if (door_dimension > 0) { FreeSpaceExpansionRoom new_room = p_autoroute_engine.add_incomplete_expansion_room(new_incomplete_room_shape, this.from_room.get_layer(), new_contained_shape); ExpansionDoor new_door = new ExpansionDoor(this.completed_room, new_room, door_dimension); @@ -483,21 +384,19 @@ private void insert_incomplete_room(AutorouteEngine p_autoroute_engine, int p_lx } } } - + private void calculate_new_incomplete_rooms_for_obstacle_expansion_room(SortedRoomNeighbour p_prev_neighbour, - SortedRoomNeighbour p_next_neighbour, AutorouteEngine p_autoroute_engine) - { + SortedRoomNeighbour p_next_neighbour, AutorouteEngine p_autoroute_engine) { int from_side_no = p_prev_neighbour.last_touching_side; int to_side_no = p_next_neighbour.first_touching_side; - if (from_side_no == to_side_no && p_prev_neighbour != p_next_neighbour) - { + if (from_side_no == to_side_no && p_prev_neighbour != p_next_neighbour) { // no return in case of only 1 neighbour. return; } - IntOctagon board_bounding_oct = p_autoroute_engine.board.bounding_box.bounding_octagon(); - + IntOctagon board_bounding_oct = p_autoroute_engine.board.bounding_box.bounding_octagon(); + // insert the new incomplete room from p_prev_neighbour to the next corner of the room shape. - + int lx = board_bounding_oct.lx; int ly = board_bounding_oct.ly; int rx = board_bounding_oct.rx; @@ -506,50 +405,35 @@ private void calculate_new_incomplete_rooms_for_obstacle_expansion_room(SortedRo int lrx = board_bounding_oct.lrx; int llx = board_bounding_oct.llx; int urx = board_bounding_oct.urx; - if (from_side_no == 0) - { + if (from_side_no == 0) { uy = this.room_shape.ly; ulx = p_prev_neighbour.intersection.lrx; - } - else if (from_side_no == 1) - { + } else if (from_side_no == 1) { ulx = this.room_shape.lrx; lx = p_prev_neighbour.intersection.rx; - } - else if (from_side_no == 2) - { + } else if (from_side_no == 2) { lx = this.room_shape.rx; llx = p_prev_neighbour.intersection.urx; - } - else if (from_side_no == 3) - { + } else if (from_side_no == 3) { llx = this.room_shape.urx; ly = p_prev_neighbour.intersection.uy; - } - else if (from_side_no == 4) - { + } else if (from_side_no == 4) { ly = this.room_shape.uy; lrx = p_prev_neighbour.intersection.ulx; - } - else if (from_side_no == 5) - { + } else if (from_side_no == 5) { lrx = this.room_shape.ulx; rx = p_prev_neighbour.intersection.lx; - } - else if (from_side_no == 6) - { + } else if (from_side_no == 6) { rx = this.room_shape.lx; urx = p_prev_neighbour.intersection.llx; - } - else if (from_side_no == 7) - { + } else if (from_side_no == 7) { urx = this.room_shape.llx; uy = p_prev_neighbour.intersection.ly; } insert_incomplete_room(p_autoroute_engine, lx, ly, rx, uy, ulx, lrx, llx, urx); - + // insert the new incomplete room from p_prev_neighbour to the next corner of the room shape. - + lx = board_bounding_oct.lx; ly = board_bounding_oct.ly; rx = board_bounding_oct.rx; @@ -558,128 +442,93 @@ else if (from_side_no == 7) lrx = board_bounding_oct.lrx; llx = board_bounding_oct.llx; urx = board_bounding_oct.urx; - - if (to_side_no == 0) - { + + if (to_side_no == 0) { uy = this.room_shape.ly; urx = p_next_neighbour.intersection.llx; - } - else if (to_side_no == 1) - { + } else if (to_side_no == 1) { ulx = this.room_shape.lrx; uy = p_next_neighbour.intersection.ly; - } - else if (to_side_no == 2) - { + } else if (to_side_no == 2) { lx = this.room_shape.rx; ulx = p_next_neighbour.intersection.lrx; - } - else if (to_side_no == 3) - { + } else if (to_side_no == 3) { llx = this.room_shape.urx; lx = p_next_neighbour.intersection.rx; - } - else if (to_side_no == 4) - { + } else if (to_side_no == 4) { ly = this.room_shape.uy; llx = p_next_neighbour.intersection.urx; - } - else if (to_side_no == 5) - { + } else if (to_side_no == 5) { lrx = this.room_shape.ulx; ly = p_next_neighbour.intersection.uy; - } - else if (to_side_no == 6) - { + } else if (to_side_no == 6) { rx = this.room_shape.lx; lrx = p_next_neighbour.intersection.ulx; - } - else if (to_side_no == 7) - { + } else if (to_side_no == 7) { urx = this.room_shape.llx; rx = p_next_neighbour.intersection.lx; } insert_incomplete_room(p_autoroute_engine, lx, ly, rx, uy, ulx, lrx, llx, urx); - + // Insert the new incomplete rooms on the intermediate free sides of the obstacle expansion room. int curr_from_side_no = (from_side_no + 1) % 8; - if (curr_from_side_no == to_side_no) - { + if (curr_from_side_no == to_side_no) { return; } int curr_to_side_no = (to_side_no + 7) % 8; this.calculate_edge_incomplete_rooms_of_obstacle_expansion_room(curr_from_side_no, curr_to_side_no, p_autoroute_engine); } - - private void calculate_new_incomplete_rooms(AutorouteEngine p_autoroute_engine) - { - IntOctagon board_bounding_oct = p_autoroute_engine.board.bounding_box.bounding_octagon(); + + private void calculate_new_incomplete_rooms(AutorouteEngine p_autoroute_engine) { + IntOctagon board_bounding_oct = p_autoroute_engine.board.bounding_box.bounding_octagon(); SortedRoomNeighbour prev_neighbour = this.sorted_neighbours.last(); - if (this.from_room instanceof ObstacleExpansionRoom && this.sorted_neighbours.size() == 1) - { + if (this.from_room instanceof ObstacleExpansionRoom && this.sorted_neighbours.size() == 1) { // ObstacleExpansionRoom has only only 1 neighbour calculate_new_incomplete_rooms_for_obstacle_expansion_room(prev_neighbour, prev_neighbour, p_autoroute_engine); return; } Iterator it = this.sorted_neighbours.iterator(); - - while (it.hasNext()) - { + + while (it.hasNext()) { SortedRoomNeighbour next_neighbour = it.next(); - + boolean insert_incomplete_room; - - if (this.completed_room instanceof ObstacleExpansionRoom && this.sorted_neighbours.size() == 2) - { + + if (this.completed_room instanceof ObstacleExpansionRoom && this.sorted_neighbours.size() == 2) { // check, if this site is touching or open. TileShape intersection = next_neighbour.intersection.intersection(prev_neighbour.intersection); - if (intersection.is_empty()) - { + if (intersection.is_empty()) { insert_incomplete_room = true; - } - else if (intersection.dimension() >= 1) - { + } else if (intersection.dimension() >= 1) { insert_incomplete_room = false; - } - else // dimension = 1 + } else // dimension = 1 { - if (prev_neighbour.last_touching_side == next_neighbour.first_touching_side) - { + if (prev_neighbour.last_touching_side == next_neighbour.first_touching_side) { // touch along the side of the room shape insert_incomplete_room = false; - } - else if(prev_neighbour.last_touching_side == (next_neighbour.first_touching_side + 1) % 8) - { + } else if (prev_neighbour.last_touching_side == (next_neighbour.first_touching_side + 1) % 8) { // touch at a corner of the room shape insert_incomplete_room = false; - } - else - { + } else { insert_incomplete_room = true; } } - } - else - { + } else { // the 2 neigbours do not touch - insert_incomplete_room = !next_neighbour.intersection.intersects(prev_neighbour.intersection); + insert_incomplete_room = !next_neighbour.intersection.intersects(prev_neighbour.intersection); } - - - if (insert_incomplete_room) - { + + + if (insert_incomplete_room) { // create a door to a new incomplete expansion room between // the last corner of the previous neighbour and the first corner of the // current neighbour - + if (this.from_room instanceof ObstacleExpansionRoom && - next_neighbour.first_touching_side != prev_neighbour.last_touching_side) - { + next_neighbour.first_touching_side != prev_neighbour.last_touching_side) { calculate_new_incomplete_rooms_for_obstacle_expansion_room(prev_neighbour, next_neighbour, p_autoroute_engine); - } - else - { + } else { int lx = board_bounding_oct.lx; int ly = board_bounding_oct.ly; int rx = board_bounding_oct.rx; @@ -688,177 +537,120 @@ else if(prev_neighbour.last_touching_side == (next_neighbour.first_touching_side int lrx = board_bounding_oct.lrx; int llx = board_bounding_oct.llx; int urx = board_bounding_oct.urx; - - if (next_neighbour.first_touching_side == 0) - { - if (prev_neighbour.intersection.llx < next_neighbour.intersection.llx) - { + + if (next_neighbour.first_touching_side == 0) { + if (prev_neighbour.intersection.llx < next_neighbour.intersection.llx) { urx = next_neighbour.intersection.llx; - uy = prev_neighbour.intersection.ly; - if (prev_neighbour.last_touching_side == 0) - { + uy = prev_neighbour.intersection.ly; + if (prev_neighbour.last_touching_side == 0) { ulx = prev_neighbour.intersection.lrx; } - } - else if (prev_neighbour.intersection.llx > next_neighbour.intersection.llx) - { - rx = next_neighbour.intersection.lx; + } else if (prev_neighbour.intersection.llx > next_neighbour.intersection.llx) { + rx = next_neighbour.intersection.lx; urx = prev_neighbour.intersection.llx; - } - else // prev_neighbour.intersection.llx == next_neighbour.intersection.llx + } else // prev_neighbour.intersection.llx == next_neighbour.intersection.llx { urx = next_neighbour.intersection.llx; } - } - else if (next_neighbour.first_touching_side == 1) - { - if (prev_neighbour.intersection.ly < next_neighbour.intersection.ly) - { + } else if (next_neighbour.first_touching_side == 1) { + if (prev_neighbour.intersection.ly < next_neighbour.intersection.ly) { uy = next_neighbour.intersection.ly; ulx = prev_neighbour.intersection.lrx; - if (prev_neighbour.last_touching_side == 1) - { + if (prev_neighbour.last_touching_side == 1) { lx = prev_neighbour.intersection.rx; } - } - else if (prev_neighbour.intersection.ly > next_neighbour.intersection.ly) - { + } else if (prev_neighbour.intersection.ly > next_neighbour.intersection.ly) { uy = prev_neighbour.intersection.ly; urx = next_neighbour.intersection.llx; - } - else // prev_neighbour.intersection.ly == next_neighbour.intersection.ly + } else // prev_neighbour.intersection.ly == next_neighbour.intersection.ly { uy = next_neighbour.intersection.ly; } - } - else if (next_neighbour.first_touching_side == 2) - { - if (prev_neighbour.intersection.lrx > next_neighbour.intersection.lrx) - { + } else if (next_neighbour.first_touching_side == 2) { + if (prev_neighbour.intersection.lrx > next_neighbour.intersection.lrx) { ulx = next_neighbour.intersection.lrx; - lx = prev_neighbour.intersection.rx; - if (prev_neighbour.last_touching_side == 2) - { + lx = prev_neighbour.intersection.rx; + if (prev_neighbour.last_touching_side == 2) { llx = prev_neighbour.intersection.urx; } - } - else if (prev_neighbour.intersection.lrx < next_neighbour.intersection.lrx) - { - uy = next_neighbour.intersection.ly; + } else if (prev_neighbour.intersection.lrx < next_neighbour.intersection.lrx) { + uy = next_neighbour.intersection.ly; ulx = prev_neighbour.intersection.lrx; - } - else // prev_neighbour.intersection.lrx == next_neighbour.intersection.lrx + } else // prev_neighbour.intersection.lrx == next_neighbour.intersection.lrx { ulx = next_neighbour.intersection.lrx; } - } - else if (next_neighbour.first_touching_side == 3) - { - if (prev_neighbour.intersection.rx > next_neighbour.intersection.rx) - { + } else if (next_neighbour.first_touching_side == 3) { + if (prev_neighbour.intersection.rx > next_neighbour.intersection.rx) { lx = next_neighbour.intersection.rx; llx = prev_neighbour.intersection.urx; - if (prev_neighbour.last_touching_side == 3) - { + if (prev_neighbour.last_touching_side == 3) { ly = prev_neighbour.intersection.uy; } - } - else if (prev_neighbour.intersection.rx < next_neighbour.intersection.rx) - { + } else if (prev_neighbour.intersection.rx < next_neighbour.intersection.rx) { lx = prev_neighbour.intersection.rx; ulx = next_neighbour.intersection.lrx; - } - else // prev_neighbour.intersection.ry == next_neighbour.intersection.ry + } else // prev_neighbour.intersection.ry == next_neighbour.intersection.ry { lx = next_neighbour.intersection.rx; } - } - else if (next_neighbour.first_touching_side == 4) - { - if (prev_neighbour.intersection.urx > next_neighbour.intersection.urx) - { + } else if (next_neighbour.first_touching_side == 4) { + if (prev_neighbour.intersection.urx > next_neighbour.intersection.urx) { llx = next_neighbour.intersection.urx; - ly = prev_neighbour.intersection.uy; - if (prev_neighbour.last_touching_side == 4) - { + ly = prev_neighbour.intersection.uy; + if (prev_neighbour.last_touching_side == 4) { lrx = prev_neighbour.intersection.ulx; } - } - else if (prev_neighbour.intersection.urx < next_neighbour.intersection.urx) - { - lx = next_neighbour.intersection.rx; + } else if (prev_neighbour.intersection.urx < next_neighbour.intersection.urx) { + lx = next_neighbour.intersection.rx; llx = prev_neighbour.intersection.urx; - } - else // prev_neighbour.intersection.urx == next_neighbour.intersection.urx + } else // prev_neighbour.intersection.urx == next_neighbour.intersection.urx { llx = next_neighbour.intersection.urx; } - } - else if (next_neighbour.first_touching_side == 5) - { - if (prev_neighbour.intersection.uy > next_neighbour.intersection.uy) - { + } else if (next_neighbour.first_touching_side == 5) { + if (prev_neighbour.intersection.uy > next_neighbour.intersection.uy) { ly = next_neighbour.intersection.uy; lrx = prev_neighbour.intersection.ulx; - if (prev_neighbour.last_touching_side == 5) - { + if (prev_neighbour.last_touching_side == 5) { rx = prev_neighbour.intersection.lx; } - } - else if (prev_neighbour.intersection.uy < next_neighbour.intersection.uy) - { + } else if (prev_neighbour.intersection.uy < next_neighbour.intersection.uy) { ly = prev_neighbour.intersection.uy; llx = next_neighbour.intersection.urx; - } - else // prev_neighbour.intersection.uy == next_neighbour.intersection.uy + } else // prev_neighbour.intersection.uy == next_neighbour.intersection.uy { ly = next_neighbour.intersection.uy; } - } - else if (next_neighbour.first_touching_side == 6) - { - if (prev_neighbour.intersection.ulx < next_neighbour.intersection.ulx) - { + } else if (next_neighbour.first_touching_side == 6) { + if (prev_neighbour.intersection.ulx < next_neighbour.intersection.ulx) { lrx = next_neighbour.intersection.ulx; - rx = prev_neighbour.intersection.lx; - if (prev_neighbour.last_touching_side == 6) - { + rx = prev_neighbour.intersection.lx; + if (prev_neighbour.last_touching_side == 6) { urx = prev_neighbour.intersection.llx; } - } - else if (prev_neighbour.intersection.ulx > next_neighbour.intersection.ulx) - { - ly = next_neighbour.intersection.uy; + } else if (prev_neighbour.intersection.ulx > next_neighbour.intersection.ulx) { + ly = next_neighbour.intersection.uy; lrx = prev_neighbour.intersection.ulx; - } - else // prev_neighbour.intersection.ulx == next_neighbour.intersection.ulx + } else // prev_neighbour.intersection.ulx == next_neighbour.intersection.ulx { lrx = next_neighbour.intersection.ulx; } - } - else if (next_neighbour.first_touching_side == 7) - { - if (prev_neighbour.intersection.lx < next_neighbour.intersection.lx) - { + } else if (next_neighbour.first_touching_side == 7) { + if (prev_neighbour.intersection.lx < next_neighbour.intersection.lx) { rx = next_neighbour.intersection.lx; urx = prev_neighbour.intersection.llx; - if (prev_neighbour.last_touching_side == 7) - { + if (prev_neighbour.last_touching_side == 7) { uy = prev_neighbour.intersection.ly; } - } - else if (prev_neighbour.intersection.lx > next_neighbour.intersection.lx) - { + } else if (prev_neighbour.intersection.lx > next_neighbour.intersection.lx) { rx = prev_neighbour.intersection.lx; lrx = next_neighbour.intersection.ulx; - } - else // prev_neighbour.intersection.lx == next_neighbour.intersection.lx + } else // prev_neighbour.intersection.lx == next_neighbour.intersection.lx { rx = next_neighbour.intersection.lx; } - } - else - { + } else { System.out.println("Sorted45DegreeRoomNeighbour.calculate_new_incomplete: illegal touching side"); } insert_incomplete_room(p_autoroute_engine, lx, ly, rx, uy, ulx, lrx, llx, urx); @@ -867,265 +659,182 @@ else if (prev_neighbour.intersection.lx > next_neighbour.intersection.lx) prev_neighbour = next_neighbour; } } - - public final CompleteExpansionRoom completed_room; - public final SortedSet sorted_neighbours; - private final ExpansionRoom from_room; - private final IntOctagon room_shape; - - private final boolean[] edge_interiour_touches_obstacle; - + /** * Helper class to sort the doors of an expansion room counterclockwise * arount the border of the room shape. */ - - private class SortedRoomNeighbour implements Comparable - { - + + private class SortedRoomNeighbour implements Comparable { + + /** + * The shape of the neighbour room + */ + public final IntOctagon shape; + /** + * The intersection of tnis ExpansionRoom shape with the neighbour_shape + */ + public final IntOctagon intersection; + /** + * The first side of the room shape, where the neighbour_shape touches + */ + public final int first_touching_side; + /** + * The last side of the room shape, where the neighbour_shape touches + */ + public final int last_touching_side; + /** * Creates a new instance of SortedRoomNeighbour and calculates the first and last * touching sides with the room shape. * this.last_touching_side will be -1, if sorting did not work because * the room_shape is contained in the neighbour shape. */ - public SortedRoomNeighbour(IntOctagon p_neighbour_shape, IntOctagon p_intersection) - { + public SortedRoomNeighbour(IntOctagon p_neighbour_shape, IntOctagon p_intersection) { shape = p_neighbour_shape; intersection = p_intersection; - - if (intersection.ly == room_shape.ly && intersection.llx > room_shape.llx) - { + + if (intersection.ly == room_shape.ly && intersection.llx > room_shape.llx) { this.first_touching_side = 0; - } - else if (intersection.lrx == room_shape.lrx && intersection.ly > room_shape.ly) - { + } else if (intersection.lrx == room_shape.lrx && intersection.ly > room_shape.ly) { this.first_touching_side = 1; - } - else if (intersection.rx == room_shape.rx && intersection.lrx < room_shape.lrx) - { + } else if (intersection.rx == room_shape.rx && intersection.lrx < room_shape.lrx) { this.first_touching_side = 2; - } - else if (intersection.urx == room_shape.urx && intersection.rx < room_shape.rx) - { + } else if (intersection.urx == room_shape.urx && intersection.rx < room_shape.rx) { this.first_touching_side = 3; - } - else if (intersection.uy == room_shape.uy && intersection.urx < room_shape.urx) - { + } else if (intersection.uy == room_shape.uy && intersection.urx < room_shape.urx) { this.first_touching_side = 4; - } - else if (intersection.ulx == room_shape.ulx && intersection.uy < room_shape.uy) - { + } else if (intersection.ulx == room_shape.ulx && intersection.uy < room_shape.uy) { this.first_touching_side = 5; - } - else if (intersection.lx == room_shape.lx && intersection.ulx > room_shape.ulx) - { + } else if (intersection.lx == room_shape.lx && intersection.ulx > room_shape.ulx) { this.first_touching_side = 6; - } - else if (intersection.llx == room_shape.llx && intersection.lx > room_shape.lx) - { + } else if (intersection.llx == room_shape.llx && intersection.lx > room_shape.lx) { this.first_touching_side = 7; - } - else - { + } else { // the room_shape may be contained in the neighbour_shape this.first_touching_side = -1; this.last_touching_side = -1; return; } - - if (intersection.llx == room_shape.llx && intersection.ly > room_shape.ly) - { + + if (intersection.llx == room_shape.llx && intersection.ly > room_shape.ly) { this.last_touching_side = 7; - } - else if (intersection.lx == room_shape.lx && intersection.llx > room_shape.llx) - { + } else if (intersection.lx == room_shape.lx && intersection.llx > room_shape.llx) { this.last_touching_side = 6; - } - else if (intersection.ulx == room_shape.ulx && intersection.lx > room_shape.lx) - { + } else if (intersection.ulx == room_shape.ulx && intersection.lx > room_shape.lx) { this.last_touching_side = 5; - } - else if (intersection.uy == room_shape.uy && intersection.ulx > room_shape.ulx) - { + } else if (intersection.uy == room_shape.uy && intersection.ulx > room_shape.ulx) { this.last_touching_side = 4; - } - else if (intersection.urx == room_shape.urx && intersection.uy < room_shape.uy) - { + } else if (intersection.urx == room_shape.urx && intersection.uy < room_shape.uy) { this.last_touching_side = 3; - } - else if (intersection.rx == room_shape.rx && intersection.urx < room_shape.urx) - { + } else if (intersection.rx == room_shape.rx && intersection.urx < room_shape.urx) { this.last_touching_side = 2; - } - else if (intersection.lrx == room_shape.lrx && intersection.rx < room_shape.rx) - { + } else if (intersection.lrx == room_shape.lrx && intersection.rx < room_shape.rx) { this.last_touching_side = 1; - } - else if (intersection.ly == room_shape.ly && intersection.lrx < room_shape.lrx) - { + } else if (intersection.ly == room_shape.ly && intersection.lrx < room_shape.lrx) { this.last_touching_side = 0; - } - else - { + } else { // the room_shape may be contained in the neighbour_shape this.last_touching_side = -1; return; } - + int next_side_no = this.first_touching_side; - for (;;) - { + for (; ; ) { int curr_side_no = next_side_no; next_side_no = (next_side_no + 1) % 8; - if (!edge_interiour_touches_obstacle[curr_side_no]) - { + if (!edge_interiour_touches_obstacle[curr_side_no]) { boolean touch_only_at_corner = false; - if (curr_side_no == this.first_touching_side) - { - if (intersection.corner(curr_side_no).equals(room_shape.corner(next_side_no))) - { + if (curr_side_no == this.first_touching_side) { + if (intersection.corner(curr_side_no).equals(room_shape.corner(next_side_no))) { touch_only_at_corner = true; } } - if (curr_side_no == this.last_touching_side) - { - if (intersection.corner(next_side_no).equals(room_shape.corner(curr_side_no))) - { + if (curr_side_no == this.last_touching_side) { + if (intersection.corner(next_side_no).equals(room_shape.corner(curr_side_no))) { touch_only_at_corner = true; } } - if (!touch_only_at_corner) - { + if (!touch_only_at_corner) { edge_interiour_touches_obstacle[curr_side_no] = true; } } - if (curr_side_no == this.last_touching_side) - { + if (curr_side_no == this.last_touching_side) { break; } - + } } - + /** * Compare function for or sorting the neighbours in counterclock sense * around the border of the room shape in ascending order. */ - public int compareTo(SortedRoomNeighbour p_other) - { - if (this.first_touching_side > p_other.first_touching_side) - { + public int compareTo(SortedRoomNeighbour p_other) { + if (this.first_touching_side > p_other.first_touching_side) { return 1; } - if (this.first_touching_side < p_other.first_touching_side) - { + if (this.first_touching_side < p_other.first_touching_side) { return -1; } - + // now the first touch of this and p_other is at the same side IntOctagon is1 = this.intersection; IntOctagon is2 = p_other.intersection; int cmp_value; - - if (first_touching_side == 0) - { + + if (first_touching_side == 0) { cmp_value = is1.corner(0).x - is2.corner(0).x; - } - else if (first_touching_side == 1) - { + } else if (first_touching_side == 1) { cmp_value = is1.corner(1).x - is2.corner(1).x; - } - else if (first_touching_side == 2) - { + } else if (first_touching_side == 2) { cmp_value = is1.corner(2).y - is2.corner(2).y; - } - else if (first_touching_side == 3) - { + } else if (first_touching_side == 3) { cmp_value = is1.corner(3).y - is2.corner(3).y; - } - else if (first_touching_side == 4) - { + } else if (first_touching_side == 4) { cmp_value = is2.corner(4).x - is1.corner(4).x; - } - else if (first_touching_side == 5) - { + } else if (first_touching_side == 5) { cmp_value = is2.corner(5).x - is1.corner(5).x; - } - else if (first_touching_side == 6) - { + } else if (first_touching_side == 6) { cmp_value = is2.corner(6).y - is1.corner(6).y; - } - else if (first_touching_side == 7) - { + } else if (first_touching_side == 7) { cmp_value = is2.corner(7).y - is1.corner(7).y; - } - else - { + } else { System.out.println("SortedRoomNeighbour.compareTo: first_touching_side out of range "); return 0; } - - if (cmp_value == 0) - { + + if (cmp_value == 0) { // The first touching points of this neighbour and p_other with the room shape are equal. // Compare the last touching points. - int this_touching_side_diff = (this.last_touching_side - this.first_touching_side + 8) % 8; - int other_touching_side_diff = (p_other.last_touching_side - p_other.first_touching_side + 8) % 8; - if (this_touching_side_diff > other_touching_side_diff) - { + int this_touching_side_diff = (this.last_touching_side - this.first_touching_side + 8) % 8; + int other_touching_side_diff = (p_other.last_touching_side - p_other.first_touching_side + 8) % 8; + if (this_touching_side_diff > other_touching_side_diff) { return 1; } - if (this_touching_side_diff < other_touching_side_diff) - { + if (this_touching_side_diff < other_touching_side_diff) { return -1; } // now the last touch of this and p_other is at the same side - if (last_touching_side == 0) - { + if (last_touching_side == 0) { cmp_value = is1.corner(1).x - is2.corner(1).x; - } - else if (last_touching_side == 1) - { + } else if (last_touching_side == 1) { cmp_value = is1.corner(2).x - is2.corner(2).x; - } - else if (last_touching_side == 2) - { + } else if (last_touching_side == 2) { cmp_value = is1.corner(3).y - is2.corner(3).y; - } - else if (last_touching_side == 3) - { + } else if (last_touching_side == 3) { cmp_value = is1.corner(4).y - is2.corner(4).y; - } - else if (last_touching_side == 4) - { + } else if (last_touching_side == 4) { cmp_value = is2.corner(5).x - is1.corner(5).x; - } - else if (last_touching_side == 5) - { + } else if (last_touching_side == 5) { cmp_value = is2.corner(6).x - is1.corner(6).x; - } - else if (last_touching_side == 6) - { + } else if (last_touching_side == 6) { cmp_value = is2.corner(7).y - is1.corner(7).y; - } - else if (last_touching_side == 7) - { + } else if (last_touching_side == 7) { cmp_value = is2.corner(0).y - is1.corner(0).y; } } return cmp_value; } - /** The shape of the neighbour room */ - public final IntOctagon shape; - - /** The intersection of tnis ExpansionRoom shape with the neighbour_shape */ - public final IntOctagon intersection; - - /** The first side of the room shape, where the neighbour_shape touches */ - public final int first_touching_side; - - /** The last side of the room shape, where the neighbour_shape touches */ - public final int last_touching_side; } } diff --git a/src/main/java/net/freerouting/autoroute/SortedOrthogonalRoomNeighbours.java b/src/main/java/net/freerouting/autoroute/SortedOrthogonalRoomNeighbours.java index 37fa6878..ac016a96 100644 --- a/src/main/java/net/freerouting/autoroute/SortedOrthogonalRoomNeighbours.java +++ b/src/main/java/net/freerouting/autoroute/SortedOrthogonalRoomNeighbours.java @@ -21,97 +21,92 @@ package net.freerouting.autoroute; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.SortedSet; -import java.util.TreeSet; - +import net.freerouting.board.Item; +import net.freerouting.board.SearchTreeObject; +import net.freerouting.board.ShapeSearchTree; import net.freerouting.datastructures.ShapeTree; - import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.TileShape; import net.freerouting.geometry.planar.Limits; +import net.freerouting.geometry.planar.TileShape; -import net.freerouting.board.SearchTreeObject; -import net.freerouting.board.ShapeSearchTree; -import net.freerouting.board.Item; +import java.util.*; /** - * * @author Alfons Wirtz */ -public class SortedOrthogonalRoomNeighbours -{ - - public static CompleteExpansionRoom calculate(ExpansionRoom p_room, AutorouteEngine p_autoroute_engine) - { +public class SortedOrthogonalRoomNeighbours { + + public final CompleteExpansionRoom completed_room; + public final SortedSet sorted_neighbours; + private final ExpansionRoom from_room; + private final boolean is_obstacle_expansion_room; + private final IntBox room_shape; + private final boolean[] edge_interiour_touches_obstacle; + + /** + * Creates a new instance of SortedOrthogonalRoomNeighbours + */ + private SortedOrthogonalRoomNeighbours(ExpansionRoom p_from_room, CompleteExpansionRoom p_completed_room) { + from_room = p_from_room; + completed_room = p_completed_room; + is_obstacle_expansion_room = p_from_room instanceof ObstacleExpansionRoom; + room_shape = (IntBox) p_completed_room.get_shape(); + sorted_neighbours = new TreeSet(); + edge_interiour_touches_obstacle = new boolean[4]; + for (int i = 0; i < 4; ++i) { + edge_interiour_touches_obstacle[i] = false; + } + } + + public static CompleteExpansionRoom calculate(ExpansionRoom p_room, AutorouteEngine p_autoroute_engine) { int net_no = p_autoroute_engine.get_net_no(); - SortedOrthogonalRoomNeighbours room_neighbours = SortedOrthogonalRoomNeighbours.calculate_neighbours(p_room, net_no, + SortedOrthogonalRoomNeighbours room_neighbours = SortedOrthogonalRoomNeighbours.calculate_neighbours(p_room, net_no, p_autoroute_engine.autoroute_search_tree, p_autoroute_engine.generate_room_id_no()); - if (room_neighbours == null) - { + if (room_neighbours == null) { return null; } - + // Check, that each side of the romm shape has at least one touching neighbour. // Otherwise improve the room shape by enlarging. boolean edge_removed = room_neighbours.try_remove_edge(net_no, p_autoroute_engine.autoroute_search_tree); CompleteExpansionRoom result = room_neighbours.completed_room; - if (edge_removed) - { + if (edge_removed) { p_autoroute_engine.remove_all_doors(result); return calculate(p_room, p_autoroute_engine); } - + // Now calculate the new incomplete rooms together with the doors // between this room and the sorted neighbours. - - if (room_neighbours.sorted_neighbours.isEmpty()) - { - if (result instanceof ObstacleExpansionRoom) - { + + if (room_neighbours.sorted_neighbours.isEmpty()) { + if (result instanceof ObstacleExpansionRoom) { calculate_incomplete_rooms_with_empty_neighbours((ObstacleExpansionRoom) p_room, p_autoroute_engine); } - } - else - { + } else { room_neighbours.calculate_new_incomplete_rooms(p_autoroute_engine); } return result; } - - private static void calculate_incomplete_rooms_with_empty_neighbours(ObstacleExpansionRoom p_room, AutorouteEngine p_autoroute_engine) - { + + private static void calculate_incomplete_rooms_with_empty_neighbours(ObstacleExpansionRoom p_room, AutorouteEngine p_autoroute_engine) { TileShape room_shape = p_room.get_shape(); - if (!(room_shape instanceof IntBox)) - { + if (!(room_shape instanceof IntBox)) { System.out.println("SortedOrthoganelRoomNeighbours.calculate_incomplete_rooms_with_empty_neighbours: IntBox expected for room_shape"); return; } IntBox room_box = (IntBox) room_shape; IntBox bounding_box = p_autoroute_engine.board.get_bounding_box(); - for (int i = 0; i < 4; ++i) - { + for (int i = 0; i < 4; ++i) { IntBox new_room_box; - if (i == 0) - { + if (i == 0) { new_room_box = new IntBox(bounding_box.ll.x, bounding_box.ll.y, bounding_box.ur.x, room_box.ll.y); - } - else if (i == 1) - { + } else if (i == 1) { new_room_box = new IntBox(room_box.ur.x, bounding_box.ll.y, bounding_box.ur.x, bounding_box.ur.y); - } - else if (i == 2) - { + } else if (i == 2) { new_room_box = new IntBox(bounding_box.ll.x, room_box.ur.y, bounding_box.ur.x, bounding_box.ur.y); - } - else if (i == 3) - { + } else if (i == 3) { new_room_box = new IntBox(bounding_box.ll.x, bounding_box.ll.y, room_box.ll.x, bounding_box.ur.y); - } - else - { + } else { System.out.println("SortedOrthoganelRoomNeighbours.calculate_incomplete_rooms_with_empty_neighbours: illegal index i"); return; } @@ -122,32 +117,25 @@ else if (i == 3) new_room.add_door(new_door); } } - + /** * Calculates all touching neighbours of p_room and sorts them in * counterclock sense around the boundary of the room shape. */ private static SortedOrthogonalRoomNeighbours calculate_neighbours(ExpansionRoom p_room, int p_net_no, - ShapeSearchTree p_autoroute_search_tree, int p_room_id_no) - { + ShapeSearchTree p_autoroute_search_tree, int p_room_id_no) { TileShape room_shape = p_room.get_shape(); - if (!(room_shape instanceof IntBox)) - { + if (!(room_shape instanceof IntBox)) { System.out.println("SortedOrthogonalRoomNeighbours.calculate: IntBox expected for room_shape"); return null; } IntBox room_box = (IntBox) room_shape; CompleteExpansionRoom completed_room; - if (p_room instanceof IncompleteFreeSpaceExpansionRoom) - { + if (p_room instanceof IncompleteFreeSpaceExpansionRoom) { completed_room = new CompleteFreeSpaceExpansionRoom(room_shape, p_room.get_layer(), p_room_id_no); - } - else if (p_room instanceof ObstacleExpansionRoom) - { - completed_room = (ObstacleExpansionRoom)p_room; - } - else - { + } else if (p_room instanceof ObstacleExpansionRoom) { + completed_room = (ObstacleExpansionRoom) p_room; + } else { System.out.println("SortedOrthogonalRoomNeighbours.calculate: unexpected expansion room type"); return null; } @@ -156,76 +144,61 @@ else if (p_room instanceof ObstacleExpansionRoom) p_autoroute_search_tree.overlapping_tree_entries(room_shape, p_room.get_layer(), overlapping_objects); // Calculate the touching neigbour objects and sort them in counterclock sence // around the border of the room shape. - for (ShapeTree.TreeEntry curr_entry : overlapping_objects) - { + for (ShapeTree.TreeEntry curr_entry : overlapping_objects) { SearchTreeObject curr_object = (SearchTreeObject) curr_entry.object; - if (curr_object == p_room) - { + if (curr_object == p_room) { continue; } - if ((completed_room instanceof CompleteFreeSpaceExpansionRoom) && !curr_object.is_trace_obstacle(p_net_no)) - { + if ((completed_room instanceof CompleteFreeSpaceExpansionRoom) && !curr_object.is_trace_obstacle(p_net_no)) { ((CompleteFreeSpaceExpansionRoom) completed_room).calculate_target_doors(curr_entry, p_net_no, p_autoroute_search_tree); continue; } TileShape curr_shape = curr_object.get_tree_shape(p_autoroute_search_tree, curr_entry.shape_index_in_object); - if (!(curr_shape instanceof IntBox)) - { + if (!(curr_shape instanceof IntBox)) { System.out.println("OrthogonalAutorouteEngine:calculate_sorted_neighbours: IntBox expected for curr_shape"); return null; } IntBox curr_box = (IntBox) curr_shape; IntBox intersection = room_box.intersection(curr_box); int dimension = intersection.dimension(); - if (dimension > 1 && completed_room instanceof ObstacleExpansionRoom) - { - if (curr_object instanceof Item) - { + if (dimension > 1 && completed_room instanceof ObstacleExpansionRoom) { + if (curr_object instanceof Item) { // only Obstacle expansion roos may have a 2-dim overlap Item curr_item = (Item) curr_object; - if (curr_item.is_route()) - { + if (curr_item.is_route()) { ItemAutorouteInfo item_info = curr_item.get_autoroute_info(); - ObstacleExpansionRoom curr_overlap_room = + ObstacleExpansionRoom curr_overlap_room = item_info.get_expansion_room(curr_entry.shape_index_in_object, p_autoroute_search_tree); ((ObstacleExpansionRoom) completed_room).create_overlap_door(curr_overlap_room); } - + } continue; } - if (dimension < 0) - { - + if (dimension < 0) { + System.out.println("AutorouteEngine.calculate_doors: dimension >= 0 expected"); continue; } result.add_sorted_neighbour(curr_box, intersection); - if (dimension > 0) - { + if (dimension > 0) { // make shure, that there is a door to the neighbour room. ExpansionRoom neighbour_room = null; - if (curr_object instanceof ExpansionRoom) - { + if (curr_object instanceof ExpansionRoom) { neighbour_room = (ExpansionRoom) curr_object; - } - else if (curr_object instanceof Item) - { + } else if (curr_object instanceof Item) { Item curr_item = (Item) curr_object; - if (curr_item.is_route()) - { + if (curr_item.is_route()) { // expand the item for ripup and pushing purposes ItemAutorouteInfo item_info = curr_item.get_autoroute_info(); - neighbour_room = + neighbour_room = item_info.get_expansion_room(curr_entry.shape_index_in_object, p_autoroute_search_tree); } } - if (neighbour_room != null) - { - if (SortedRoomNeighbours.insert_door_ok(completed_room, neighbour_room, intersection)) - { + if (neighbour_room != null) { + if (SortedRoomNeighbours.insert_door_ok(completed_room, neighbour_room, intersection)) { ExpansionDoor new_door = new ExpansionDoor(completed_room, neighbour_room); neighbour_room.add_door(new_door); completed_room.add_door(new_door); @@ -235,178 +208,143 @@ else if (curr_object instanceof Item) } return result; } - - private void calculate_new_incomplete_rooms(AutorouteEngine p_autoroute_engine) - { + + private static IntBox remove_border_line(IntBox p_room_box, int p_remove_edge_no) { + IntBox result; + if (p_remove_edge_no == 0) { + result = new IntBox(p_room_box.ll.x, -Limits.CRIT_INT, p_room_box.ur.x, p_room_box.ur.y); + } else if (p_remove_edge_no == 1) { + result = new IntBox(p_room_box.ll.x, p_room_box.ll.y, Limits.CRIT_INT, p_room_box.ur.y); + } else if (p_remove_edge_no == 2) { + result = new IntBox(p_room_box.ll.x, p_room_box.ll.y, p_room_box.ur.x, Limits.CRIT_INT); + } else if (p_remove_edge_no == 3) { + result = new IntBox(-Limits.CRIT_INT, p_room_box.ll.y, p_room_box.ur.x, p_room_box.ur.y); + } else { + System.out.println("SortedOrthogonalRoomNeighbours.remove_border_line: illegal p_remove_edge_no"); + result = null; + } + return result; + } + + private void calculate_new_incomplete_rooms(AutorouteEngine p_autoroute_engine) { IntBox board_bounds = p_autoroute_engine.board.bounding_box; SortedRoomNeighbour prev_neighbour = this.sorted_neighbours.last(); Iterator it = this.sorted_neighbours.iterator(); - - while (it.hasNext()) - { + + while (it.hasNext()) { SortedRoomNeighbour next_neighbour = it.next(); - - if (!next_neighbour.intersection.intersects(prev_neighbour.intersection)) - { + + if (!next_neighbour.intersection.intersects(prev_neighbour.intersection)) { // create a door to a new incomplete expansion room between // the last corner of the previous neighbour and the first corner of the // current neighbour. - if (next_neighbour.first_touching_side == 0) - { - if (prev_neighbour.last_touching_side == 0) - { - if (prev_neighbour.intersection.ur.x < next_neighbour.intersection.ll.x) - { + if (next_neighbour.first_touching_side == 0) { + if (prev_neighbour.last_touching_side == 0) { + if (prev_neighbour.intersection.ur.x < next_neighbour.intersection.ll.x) { insert_incomplete_room(p_autoroute_engine, prev_neighbour.intersection.ur.x, board_bounds.ll.y, next_neighbour.intersection.ll.x, this.room_shape.ll.y); } - } - else - { + } else { if (prev_neighbour.intersection.ll.y > this.room_shape.ll.y - || next_neighbour.intersection.ll.x > this.room_shape.ll.x) - { - if (is_obstacle_expansion_room) - { + || next_neighbour.intersection.ll.x > this.room_shape.ll.x) { + if (is_obstacle_expansion_room) { // no 2-dim doors between obstacle_expansion_rooms and free space rooms allowed. - if (prev_neighbour.last_touching_side == 3) - { + if (prev_neighbour.last_touching_side == 3) { insert_incomplete_room(p_autoroute_engine, board_bounds.ll.x, room_shape.ll.y, room_shape.ll.x, prev_neighbour.intersection.ll.y); } insert_incomplete_room(p_autoroute_engine, room_shape.ll.x, board_bounds.ll.y, next_neighbour.intersection.ll.x, room_shape.ll.y); - } - else - { + } else { insert_incomplete_room(p_autoroute_engine, board_bounds.ll.x, board_bounds.ll.y, next_neighbour.intersection.ll.x, prev_neighbour.intersection.ll.y); } } } - } - else if (next_neighbour.first_touching_side == 1) - { - if (prev_neighbour.last_touching_side == 1) - { - if (prev_neighbour.intersection.ur.y < next_neighbour.intersection.ll.y) - { + } else if (next_neighbour.first_touching_side == 1) { + if (prev_neighbour.last_touching_side == 1) { + if (prev_neighbour.intersection.ur.y < next_neighbour.intersection.ll.y) { insert_incomplete_room(p_autoroute_engine, this.room_shape.ur.x, prev_neighbour.intersection.ur.y, - board_bounds.ur.x, next_neighbour.intersection.ll.y ); + board_bounds.ur.x, next_neighbour.intersection.ll.y); } - } - else - { + } else { if (prev_neighbour.intersection.ur.x < this.room_shape.ur.x - || next_neighbour.intersection.ll.y > this.room_shape.ll.y) - { - if (is_obstacle_expansion_room) - { + || next_neighbour.intersection.ll.y > this.room_shape.ll.y) { + if (is_obstacle_expansion_room) { // no 2-dim doors between obstacle_expansion_rooms and free space rooms allowed. - if (prev_neighbour.last_touching_side == 0) - { + if (prev_neighbour.last_touching_side == 0) { insert_incomplete_room(p_autoroute_engine, prev_neighbour.intersection.ur.x, board_bounds.ll.y, room_shape.ur.x, room_shape.ll.y); } insert_incomplete_room(p_autoroute_engine, room_shape.ur.x, room_shape.ll.y, - room_shape.ur.x, next_neighbour.intersection.ll.y ); - } - else - { + room_shape.ur.x, next_neighbour.intersection.ll.y); + } else { insert_incomplete_room(p_autoroute_engine, prev_neighbour.intersection.ur.x, board_bounds.ll.y, board_bounds.ur.x, next_neighbour.intersection.ll.y); } } } - } - else if (next_neighbour.first_touching_side == 2) - { - if (prev_neighbour.last_touching_side == 2) - { - if (prev_neighbour.intersection.ll.x > next_neighbour.intersection.ur.x) - { + } else if (next_neighbour.first_touching_side == 2) { + if (prev_neighbour.last_touching_side == 2) { + if (prev_neighbour.intersection.ll.x > next_neighbour.intersection.ur.x) { insert_incomplete_room(p_autoroute_engine, next_neighbour.intersection.ur.x, this.room_shape.ur.y, prev_neighbour.intersection.ll.x, board_bounds.ur.y); } - } - else - { + } else { if (prev_neighbour.intersection.ur.y < this.room_shape.ur.y - || next_neighbour.intersection.ur.x < this.room_shape.ur.x) - { - if (is_obstacle_expansion_room) - { + || next_neighbour.intersection.ur.x < this.room_shape.ur.x) { + if (is_obstacle_expansion_room) { // no 2-dim doors between obstacle_expansion_rooms and free space rooms allowed. - if (prev_neighbour.last_touching_side == 1) - { + if (prev_neighbour.last_touching_side == 1) { insert_incomplete_room(p_autoroute_engine, room_shape.ur.x, prev_neighbour.intersection.ur.y, board_bounds.ur.x, room_shape.ur.y); } insert_incomplete_room(p_autoroute_engine, next_neighbour.intersection.ur.x, room_shape.ur.y, - room_shape.ur.x, board_bounds.ur.y ); - } - else - { + room_shape.ur.x, board_bounds.ur.y); + } else { insert_incomplete_room(p_autoroute_engine, next_neighbour.intersection.ur.x, prev_neighbour.intersection.ur.y, board_bounds.ur.x, board_bounds.ur.y); } } } - } - else if (next_neighbour.first_touching_side == 3) - { - if (prev_neighbour.last_touching_side == 3) - { - if (prev_neighbour.intersection.ll.y > next_neighbour.intersection.ur.y) - { + } else if (next_neighbour.first_touching_side == 3) { + if (prev_neighbour.last_touching_side == 3) { + if (prev_neighbour.intersection.ll.y > next_neighbour.intersection.ur.y) { insert_incomplete_room(p_autoroute_engine, board_bounds.ll.x, next_neighbour.intersection.ur.y, this.room_shape.ll.x, prev_neighbour.intersection.ll.y); } - } - else - { + } else { if (next_neighbour.intersection.ur.y < this.room_shape.ur.y - || prev_neighbour.intersection.ll.x > this.room_shape.ll.x) - { - if (is_obstacle_expansion_room) - { + || prev_neighbour.intersection.ll.x > this.room_shape.ll.x) { + if (is_obstacle_expansion_room) { // no 2-dim doors between obstacle_expansion_rooms and free space rooms allowed. - if (prev_neighbour.last_touching_side == 2) - { + if (prev_neighbour.last_touching_side == 2) { insert_incomplete_room(p_autoroute_engine, room_shape.ll.x, room_shape.ur.y, prev_neighbour.intersection.ll.x, board_bounds.ur.y); } insert_incomplete_room(p_autoroute_engine, board_bounds.ll.x, next_neighbour.intersection.ur.y, room_shape.ll.x, room_shape.ur.y); - } - else - { + } else { insert_incomplete_room(p_autoroute_engine, board_bounds.ll.x, next_neighbour.intersection.ur.y, prev_neighbour.intersection.ll.x, board_bounds.ur.y); } } } - } - else - { + } else { System.out.println("SortedOrthogonalRoomNeighbour.calculate_new_incomplete: illegal touching side"); } } prev_neighbour = next_neighbour; } } - - private void insert_incomplete_room(AutorouteEngine p_autoroute_engine, int p_ll_x, int p_ll_y, int p_ur_x, int p_ur_y) - { + + private void insert_incomplete_room(AutorouteEngine p_autoroute_engine, int p_ll_x, int p_ll_y, int p_ur_x, int p_ur_y) { IntBox new_incomplete_room_shape = new IntBox(p_ll_x, p_ll_y, p_ur_x, p_ur_y); - if (new_incomplete_room_shape.dimension() == 2) - { + if (new_incomplete_room_shape.dimension() == 2) { IntBox new_contained_shape = this.room_shape.intersection(new_incomplete_room_shape); - if (!new_contained_shape.is_empty()) - { + if (!new_contained_shape.is_empty()) { int door_dimension = new_incomplete_room_shape.intersection(this.room_shape).dimension(); - if (door_dimension > 0) - { + if (door_dimension > 0) { FreeSpaceExpansionRoom new_room = p_autoroute_engine.add_incomplete_expansion_room(new_incomplete_room_shape, this.from_room.get_layer(), new_contained_shape); ExpansionDoor new_door = new ExpansionDoor(this.completed_room, new_room, door_dimension); @@ -416,75 +354,50 @@ private void insert_incomplete_room(AutorouteEngine p_autoroute_engine, int p_ll } } } - - /** Creates a new instance of SortedOrthogonalRoomNeighbours */ - private SortedOrthogonalRoomNeighbours(ExpansionRoom p_from_room, CompleteExpansionRoom p_completed_room) - { - from_room = p_from_room; - completed_room = p_completed_room; - is_obstacle_expansion_room = p_from_room instanceof ObstacleExpansionRoom; - room_shape = (IntBox) p_completed_room.get_shape(); - sorted_neighbours = new TreeSet(); - edge_interiour_touches_obstacle = new boolean[4]; - for (int i = 0; i < 4; ++i) - { - edge_interiour_touches_obstacle[i] = false; - } - } - + /** * Check, that each side of the romm shape has at least one touching neighbour. * Otherwise the room shape will be improved the by enlarging. * Returns true, if the room shape was changed. */ - private boolean try_remove_edge(int p_net_no, ShapeSearchTree p_autoroute_search_tree) - { - if (!(this.from_room instanceof IncompleteFreeSpaceExpansionRoom)) - { + private boolean try_remove_edge(int p_net_no, ShapeSearchTree p_autoroute_search_tree) { + if (!(this.from_room instanceof IncompleteFreeSpaceExpansionRoom)) { return false; } IncompleteFreeSpaceExpansionRoom curr_incomplete_room = (IncompleteFreeSpaceExpansionRoom) this.from_room; - if (!(curr_incomplete_room.get_shape() instanceof IntBox)) - { + if (!(curr_incomplete_room.get_shape() instanceof IntBox)) { System.out.println("SortedOrthogonalRoomNeighbours.try_remove_edge: IntBox expected for room_shape type"); return false; } - IntBox room_box = (IntBox) curr_incomplete_room.get_shape(); + IntBox room_box = (IntBox) curr_incomplete_room.get_shape(); double room_area = room_box.area(); - + int remove_edge_no = -1; - for (int i = 0; i < 4; ++i) - { - if (!this.edge_interiour_touches_obstacle[i]) - { + for (int i = 0; i < 4; ++i) { + if (!this.edge_interiour_touches_obstacle[i]) { remove_edge_no = i; break; } } - - if (remove_edge_no >= 0) - { + + if (remove_edge_no >= 0) { // Touching neighbour missing at the edge side with index remove_edge_no // Remove the edge line and restart the algorithm. - IntBox enlarged_box = remove_border_line( room_box, remove_edge_no); + IntBox enlarged_box = remove_border_line(room_box, remove_edge_no); Collection door_list = this.completed_room.get_doors(); TileShape ignore_shape = null; SearchTreeObject ignore_object = null; double max_door_area = 0; - for (ExpansionDoor curr_door: door_list) - { + for (ExpansionDoor curr_door : door_list) { // insert the overlapping doors with CompleteFreeSpaceExpansionRooms // for the information in complete_shape about the objects to ignore. - if (curr_door.dimension == 2) - { + if (curr_door.dimension == 2) { CompleteExpansionRoom other_room = curr_door.other_room(this.completed_room); { - if (other_room instanceof CompleteFreeSpaceExpansionRoom) - { + if (other_room instanceof CompleteFreeSpaceExpansionRoom) { TileShape curr_door_shape = curr_door.get_shape(); double curr_door_area = curr_door_shape.area(); - if (curr_door_area > max_door_area) - { + if (curr_door_area > max_door_area) { max_door_area = curr_door_area; ignore_shape = curr_door_shape; ignore_object = (CompleteFreeSpaceExpansionRoom) other_room; @@ -495,15 +408,13 @@ private boolean try_remove_edge(int p_net_no, ShapeSearchTree p_autoroute_search } IncompleteFreeSpaceExpansionRoom enlarged_room = new IncompleteFreeSpaceExpansionRoom(enlarged_box, curr_incomplete_room.get_layer(), - curr_incomplete_room.get_contained_shape()); - Collection new_rooms = + curr_incomplete_room.get_contained_shape()); + Collection new_rooms = p_autoroute_search_tree.complete_shape(enlarged_room, p_net_no, ignore_object, ignore_shape); - if (new_rooms.size() == 1) - { + if (new_rooms.size() == 1) { // Check, that the area increases to prevent endless loop. IncompleteFreeSpaceExpansionRoom new_room = new_rooms.iterator().next(); - if (new_room.get_shape().area() > room_area) - { + if (new_room.get_shape().area() > room_area) { curr_incomplete_room.set_shape(new_room.get_shape()); curr_incomplete_room.set_contained_shape(new_room.get_contained_shape()); return true; @@ -512,218 +423,139 @@ private boolean try_remove_edge(int p_net_no, ShapeSearchTree p_autoroute_search } return false; } - - private static IntBox remove_border_line( IntBox p_room_box, int p_remove_edge_no) - { - IntBox result; - if (p_remove_edge_no == 0) - { - result = new IntBox(p_room_box.ll.x, -Limits.CRIT_INT, p_room_box.ur.x, p_room_box.ur.y); - } - else if (p_remove_edge_no == 1) - { - result = new IntBox(p_room_box.ll.x, p_room_box.ll.y, Limits.CRIT_INT, p_room_box.ur.y); - } - else if (p_remove_edge_no == 2) - { - result = new IntBox(p_room_box.ll.x, p_room_box.ll.y, p_room_box.ur.x, Limits.CRIT_INT); - } - else if (p_remove_edge_no == 3) - { - result = new IntBox(-Limits.CRIT_INT, p_room_box.ll.y, p_room_box.ur.x, p_room_box.ur.y); - } - else - { - System.out.println("SortedOrthogonalRoomNeighbours.remove_border_line: illegal p_remove_edge_no"); - result = null; - } - return result; - } - - private void add_sorted_neighbour(IntBox p_neighbour_shape, IntBox p_intersection) - { + + private void add_sorted_neighbour(IntBox p_neighbour_shape, IntBox p_intersection) { SortedRoomNeighbour new_neighbour = new SortedRoomNeighbour(p_neighbour_shape, p_intersection); sorted_neighbours.add(new_neighbour); } - - public final CompleteExpansionRoom completed_room; - public final SortedSet sorted_neighbours; - private final ExpansionRoom from_room; - private final boolean is_obstacle_expansion_room; - private final IntBox room_shape; - - private final boolean[] edge_interiour_touches_obstacle; - + /** * Helper class to sort the doors of an expansion room counterclockwise * arount the border of the room shape. */ - - private class SortedRoomNeighbour implements Comparable - { - public SortedRoomNeighbour(IntBox p_neighbour_shape, IntBox p_intersection) - { + + private class SortedRoomNeighbour implements Comparable { + /** + * The shape of the neighbour room + */ + public final IntBox shape; + /** + * The intersection of tnis ExpansionRoom shape with the neighbour_shape + */ + public final IntBox intersection; + /** + * The first side of the room shape, where the neighbour_shape touches + */ + public final int first_touching_side; + /** + * The last side of the room shape, where the neighbour_shape touches + */ + public final int last_touching_side; + + public SortedRoomNeighbour(IntBox p_neighbour_shape, IntBox p_intersection) { shape = p_neighbour_shape; intersection = p_intersection; - - if( p_intersection.ll.y == room_shape.ll.y - && p_intersection.ur.x > room_shape.ll.x && p_intersection.ll.x < room_shape.ur.x) - { + + if (p_intersection.ll.y == room_shape.ll.y + && p_intersection.ur.x > room_shape.ll.x && p_intersection.ll.x < room_shape.ur.x) { edge_interiour_touches_obstacle[0] = true; } - if( p_intersection.ur.x == room_shape.ur.x - && p_intersection.ur.y > room_shape.ll.y && p_intersection.ll.y < room_shape.ur.y) - { + if (p_intersection.ur.x == room_shape.ur.x + && p_intersection.ur.y > room_shape.ll.y && p_intersection.ll.y < room_shape.ur.y) { edge_interiour_touches_obstacle[1] = true; } - if( p_intersection.ur.y == room_shape.ur.y - && p_intersection.ur.x > room_shape.ll.x && p_intersection.ll.x < room_shape.ur.x) - { + if (p_intersection.ur.y == room_shape.ur.y + && p_intersection.ur.x > room_shape.ll.x && p_intersection.ll.x < room_shape.ur.x) { edge_interiour_touches_obstacle[2] = true; } - if( p_intersection.ll.x == room_shape.ll.x - && p_intersection.ur.y > room_shape.ll.y && p_intersection.ll.y < room_shape.ur.y) - { + if (p_intersection.ll.x == room_shape.ll.x + && p_intersection.ur.y > room_shape.ll.y && p_intersection.ll.y < room_shape.ur.y) { edge_interiour_touches_obstacle[3] = true; } - - if (p_intersection.ll.y == room_shape.ll.y && p_intersection.ll.x > room_shape.ll.x) - { + + if (p_intersection.ll.y == room_shape.ll.y && p_intersection.ll.x > room_shape.ll.x) { this.first_touching_side = 0; - } - else if (p_intersection.ur.x == room_shape.ur.x && p_intersection.ll.y > room_shape.ll.y) - { + } else if (p_intersection.ur.x == room_shape.ur.x && p_intersection.ll.y > room_shape.ll.y) { this.first_touching_side = 1; - } - else if (p_intersection.ur.y == room_shape.ur.y ) - { + } else if (p_intersection.ur.y == room_shape.ur.y) { this.first_touching_side = 2; - } - else if (p_intersection.ll.x == room_shape.ll.x) - { + } else if (p_intersection.ll.x == room_shape.ll.x) { this.first_touching_side = 3; - } - else - { + } else { System.out.println("SortedRoomNeighbour: case not expected"); this.first_touching_side = -1; } - - if (p_intersection.ll.x == room_shape.ll.x && p_intersection.ll.y > room_shape.ll.y) - { + + if (p_intersection.ll.x == room_shape.ll.x && p_intersection.ll.y > room_shape.ll.y) { this.last_touching_side = 3; - } - else if (p_intersection.ur.y == room_shape.ur.y && p_intersection.ll.x > room_shape.ll.x) - { + } else if (p_intersection.ur.y == room_shape.ur.y && p_intersection.ll.x > room_shape.ll.x) { this.last_touching_side = 2; - } - else if (p_intersection.ur.x == room_shape.ur.x) - { + } else if (p_intersection.ur.x == room_shape.ur.x) { this.last_touching_side = 1; - } - else if (p_intersection.ll.y == room_shape.ll.y) - { + } else if (p_intersection.ll.y == room_shape.ll.y) { this.last_touching_side = 0; - } - else - { + } else { System.out.println("SortedRoomNeighbour: case not expected"); this.last_touching_side = -1; } } - + /** * Compare function for or sorting the neighbours in counterclock sense * around the border of the room shape in ascending order. */ - public int compareTo(SortedRoomNeighbour p_other) - { - if (this.first_touching_side > p_other.first_touching_side) - { + public int compareTo(SortedRoomNeighbour p_other) { + if (this.first_touching_side > p_other.first_touching_side) { return 1; } - if (this.first_touching_side < p_other.first_touching_side) - { + if (this.first_touching_side < p_other.first_touching_side) { return -1; } - + // now the first touch of this and p_other is at the same side IntBox is1 = this.intersection; IntBox is2 = p_other.intersection; int cmp_value; - - if (first_touching_side == 0) - { + + if (first_touching_side == 0) { cmp_value = is1.ll.x - is2.ll.x; - } - else if (first_touching_side == 1) - { + } else if (first_touching_side == 1) { cmp_value = is1.ll.y - is2.ll.y; - } - else if (first_touching_side == 2) - { + } else if (first_touching_side == 2) { cmp_value = is2.ur.x - is1.ur.x; - } - else if (first_touching_side == 3) - { + } else if (first_touching_side == 3) { cmp_value = is2.ur.y - is1.ur.y; - } - else - { + } else { System.out.println("SortedRoomNeighbour.compareTo: first_touching_side out of range "); return 0; } - if (cmp_value == 0) - { + if (cmp_value == 0) { // The first touching points of this neighbour and p_other with the room shape are equal. // Compare the last touching points. - int this_touching_side_diff = (this.last_touching_side - this.first_touching_side + 4) % 4; - int other_touching_side_diff = (p_other.last_touching_side - p_other.first_touching_side + 4) % 4; - if (this_touching_side_diff > other_touching_side_diff) - { + int this_touching_side_diff = (this.last_touching_side - this.first_touching_side + 4) % 4; + int other_touching_side_diff = (p_other.last_touching_side - p_other.first_touching_side + 4) % 4; + if (this_touching_side_diff > other_touching_side_diff) { return 1; } - if (this_touching_side_diff < other_touching_side_diff) - { + if (this_touching_side_diff < other_touching_side_diff) { return -1; } - + // now the last touch of this and p_other is at the same side - if (last_touching_side == 0) - { + if (last_touching_side == 0) { cmp_value = is1.ur.x - is2.ur.x; - } - else if (last_touching_side == 1) - { + } else if (last_touching_side == 1) { cmp_value = is1.ur.y - is2.ur.y; - } - else if (last_touching_side == 2) - { + } else if (last_touching_side == 2) { cmp_value = is2.ll.x - is1.ll.x; - } - else if (last_touching_side == 3) - { + } else if (last_touching_side == 3) { cmp_value = is2.ll.y - is1.ll.y; - } - else - { + } else { System.out.println("SortedRoomNeighbour.compareTo: first_touching_side out of range "); return 0; } } return cmp_value; } - - /** The shape of the neighbour room */ - public final IntBox shape; - - /** The intersection of tnis ExpansionRoom shape with the neighbour_shape */ - public final IntBox intersection; - - /** The first side of the room shape, where the neighbour_shape touches */ - public final int first_touching_side; - - /** The last side of the room shape, where the neighbour_shape touches */ - public final int last_touching_side; } } diff --git a/src/main/java/net/freerouting/autoroute/SortedRoomNeighbours.java b/src/main/java/net/freerouting/autoroute/SortedRoomNeighbours.java index d11e99d7..5d686a5b 100644 --- a/src/main/java/net/freerouting/autoroute/SortedRoomNeighbours.java +++ b/src/main/java/net/freerouting/autoroute/SortedRoomNeighbours.java @@ -21,30 +21,12 @@ package net.freerouting.autoroute; -import java.util.Collection; -import java.util.LinkedList; -import java.util.TreeSet; -import java.util.SortedSet; -import java.util.Iterator; - -import net.freerouting.datastructures.Signum; +import net.freerouting.board.*; import net.freerouting.datastructures.ShapeTree; +import net.freerouting.datastructures.Signum; +import net.freerouting.geometry.planar.*; -import net.freerouting.geometry.planar.Side; -import net.freerouting.geometry.planar.Direction; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Simplex; - -import net.freerouting.board.ShapeSearchTree; -import net.freerouting.board.SearchTreeObject; -import net.freerouting.board.Connectable; -import net.freerouting.board.Item; -import net.freerouting.board.PolylineTrace; -import net.freerouting.board.TestLevel; +import java.util.*; /** * To calculate the neigbour rooms of an expansion room. @@ -53,66 +35,71 @@ * * @author Alfons Wirtz */ -public class SortedRoomNeighbours -{ +public class SortedRoomNeighbours { + private final ExpansionRoom from_room; + private final CompleteExpansionRoom completed_room; + private final TileShape room_shape; + private final SortedSet sorted_neighbours; + private final Collection own_net_objects; + + /** + * Creates a new instance of SortedRoomNeighbours + */ + private SortedRoomNeighbours(ExpansionRoom p_from_room, CompleteExpansionRoom p_completed_room) { + from_room = p_from_room; + completed_room = p_completed_room; + room_shape = p_completed_room.get_shape(); + sorted_neighbours = new TreeSet(); + own_net_objects = new LinkedList(); + } + /** * To calculate the neigbour rooms of an expansion room. * The neighbour rooms will be sorted in counterclock sense around the border of the shape of p_room. * Overlapping neighbours containing an item may be stored in an unordered list. */ - public static CompleteExpansionRoom calculate(ExpansionRoom p_room, AutorouteEngine p_autoroute_engine) - { + public static CompleteExpansionRoom calculate(ExpansionRoom p_room, AutorouteEngine p_autoroute_engine) { int net_no = p_autoroute_engine.get_net_no(); TestLevel test_level = p_autoroute_engine.board.get_test_level(); SortedRoomNeighbours room_neighbours = calculate_neighbours(p_room, net_no, p_autoroute_engine.autoroute_search_tree, p_autoroute_engine.generate_room_id_no(), test_level); - + // Check, that each side of the romm shape has at least one touching neighbour. // Otherwise improve the room shape by enlarging. - + boolean edge_removed = room_neighbours.try_remove_edge(net_no, p_autoroute_engine.autoroute_search_tree, test_level); CompleteExpansionRoom result = room_neighbours.completed_room; - if (edge_removed) - { + if (edge_removed) { p_autoroute_engine.remove_all_doors(result); return calculate(p_room, p_autoroute_engine); } - + // Now calculate the new incomplete rooms together with the doors // between this room and the sorted neighbours. - if (room_neighbours.sorted_neighbours.isEmpty()) - { - if (result instanceof ObstacleExpansionRoom) - { + if (room_neighbours.sorted_neighbours.isEmpty()) { + if (result instanceof ObstacleExpansionRoom) { calculate_incomplete_rooms_with_empty_neighbours((ObstacleExpansionRoom) p_room, p_autoroute_engine); } - } - else - { + } else { room_neighbours.calculate_new_incomplete_rooms(p_autoroute_engine); - if (test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal() && result.get_shape().dimension() < 2) - { + if (test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal() && result.get_shape().dimension() < 2) { System.out.println("AutorouteEngine.calculate_new_incomplete_rooms_with_mmore_than_1_neighbour: unexpected dimension for smoothened_shape"); } } - - if (result instanceof CompleteFreeSpaceExpansionRoom) - { + + if (result instanceof CompleteFreeSpaceExpansionRoom) { calculate_target_doors((CompleteFreeSpaceExpansionRoom) result, room_neighbours.own_net_objects, p_autoroute_engine); } return result; } - - private static void calculate_incomplete_rooms_with_empty_neighbours(ObstacleExpansionRoom p_room, AutorouteEngine p_autoroute_engine) - { + + private static void calculate_incomplete_rooms_with_empty_neighbours(ObstacleExpansionRoom p_room, AutorouteEngine p_autoroute_engine) { TileShape room_shape = p_room.get_shape(); - for (int i = 0; i < room_shape.border_line_count(); ++i) - { + for (int i = 0; i < room_shape.border_line_count(); ++i) { Line curr_line = room_shape.border_line(i); - if (SortedRoomNeighbours.insert_door_ok(p_room, curr_line)) - { + if (SortedRoomNeighbours.insert_door_ok(p_room, curr_line)) { Line[] shape_line = new Line[1]; shape_line[0] = curr_line.opposite(); TileShape new_room_shape = new Simplex(shape_line); @@ -124,52 +111,39 @@ private static void calculate_incomplete_rooms_with_empty_neighbours(ObstacleExp } } } - - + private static void calculate_target_doors(CompleteFreeSpaceExpansionRoom p_room, - Collection p_own_net_objects, AutorouteEngine p_autoroute_engine) - { - if (!p_own_net_objects.isEmpty()) - { + Collection p_own_net_objects, AutorouteEngine p_autoroute_engine) { + if (!p_own_net_objects.isEmpty()) { p_room.set_net_dependent(); } - for (ShapeTree.TreeEntry curr_entry : p_own_net_objects) - { - if (curr_entry.object instanceof Connectable) - { + for (ShapeTree.TreeEntry curr_entry : p_own_net_objects) { + if (curr_entry.object instanceof Connectable) { Connectable curr_object = (Connectable) curr_entry.object; - if (curr_object.contains_net(p_autoroute_engine.get_net_no())) - { + if (curr_object.contains_net(p_autoroute_engine.get_net_no())) { TileShape curr_connection_shape = curr_object.get_trace_connection_shape(p_autoroute_engine.autoroute_search_tree, curr_entry.shape_index_in_object); - if (curr_connection_shape != null && p_room.get_shape().intersects(curr_connection_shape)) - { + if (curr_connection_shape != null && p_room.get_shape().intersects(curr_connection_shape)) { Item curr_item = (Item) curr_object; TargetItemExpansionDoor new_target_door = new TargetItemExpansionDoor(curr_item, curr_entry.shape_index_in_object, p_room, - p_autoroute_engine.autoroute_search_tree); + p_autoroute_engine.autoroute_search_tree); p_room.add_target_door(new_target_door); } } } } } - + private static SortedRoomNeighbours calculate_neighbours(ExpansionRoom p_room, int p_net_no, - ShapeSearchTree p_autoroute_search_tree, int p_room_id_no, TestLevel p_test_level) - { + ShapeSearchTree p_autoroute_search_tree, int p_room_id_no, TestLevel p_test_level) { TileShape room_shape = p_room.get_shape(); CompleteExpansionRoom completed_room; - if (p_room instanceof IncompleteFreeSpaceExpansionRoom) - { + if (p_room instanceof IncompleteFreeSpaceExpansionRoom) { completed_room = new CompleteFreeSpaceExpansionRoom(room_shape, p_room.get_layer(), p_room_id_no); - } - else if (p_room instanceof ObstacleExpansionRoom) - { - completed_room = (ObstacleExpansionRoom)p_room; - } - else - { + } else if (p_room instanceof ObstacleExpansionRoom) { + completed_room = (ObstacleExpansionRoom) p_room; + } else { System.out.println("SortedRoomNeighbours.calculate: unexpected expansion room type"); return null; } @@ -178,15 +152,12 @@ else if (p_room instanceof ObstacleExpansionRoom) p_autoroute_search_tree.overlapping_tree_entries(room_shape, p_room.get_layer(), overlapping_objects); // Calculate the touching neigbour objects and sort them in counterclock sence // around the border of the room shape. - for (ShapeTree.TreeEntry curr_entry : overlapping_objects) - { + for (ShapeTree.TreeEntry curr_entry : overlapping_objects) { SearchTreeObject curr_object = (SearchTreeObject) curr_entry.object; - if (curr_object == p_room) - { + if (curr_object == p_room) { continue; } - if ((p_room instanceof IncompleteFreeSpaceExpansionRoom) && !curr_object.is_trace_obstacle(p_net_no)) - { + if ((p_room instanceof IncompleteFreeSpaceExpansionRoom) && !curr_object.is_trace_obstacle(p_net_no)) { // delay processing the target doors until the room shape will not change any more result.own_net_objects.add(curr_entry); continue; @@ -195,41 +166,31 @@ else if (p_room instanceof ObstacleExpansionRoom) curr_object.get_tree_shape(p_autoroute_search_tree, curr_entry.shape_index_in_object); TileShape intersection = room_shape.intersection(curr_shape); int dimension = intersection.dimension(); - if (dimension > 1) - { - if (completed_room instanceof ObstacleExpansionRoom && curr_object instanceof Item) - { + if (dimension > 1) { + if (completed_room instanceof ObstacleExpansionRoom && curr_object instanceof Item) { // only Obstacle expansion roos may have a 2-dim overlap Item curr_item = (Item) curr_object; - if (curr_item.is_route()) - { + if (curr_item.is_route()) { ItemAutorouteInfo item_info = curr_item.get_autoroute_info(); - ObstacleExpansionRoom curr_overlap_room = + ObstacleExpansionRoom curr_overlap_room = item_info.get_expansion_room(curr_entry.shape_index_in_object, p_autoroute_search_tree); ((ObstacleExpansionRoom) completed_room).create_overlap_door(curr_overlap_room); } - } - else if (p_test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + } else if (p_test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("SortedRoomNeighbours.calculate: unexpected area overlap of free space expansion room"); } continue; } - if (dimension < 0) - { - if (p_test_level.ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) - { + if (dimension < 0) { + if (p_test_level.ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("SortedRoomNeighbours.calculate: dimension >= 0 expected"); } continue; } - if (dimension == 1) - { + if (dimension == 1) { int[] touching_sides = room_shape.touching_sides(curr_shape); - if (touching_sides.length != 2) - { - if (p_test_level.ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) - { + if (touching_sides.length != 2) { + if (p_test_level.ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("SortedRoomNeighbours.calculate: touching_sides length 2 expected"); } continue; @@ -238,108 +199,144 @@ else if (p_test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) touching_sides[1], false, false); // make shure, that there is a door to the neighbour room. ExpansionRoom neighbour_room = null; - if (curr_object instanceof ExpansionRoom) - { + if (curr_object instanceof ExpansionRoom) { neighbour_room = (ExpansionRoom) curr_object; - } - else if (curr_object instanceof Item) - { + } else if (curr_object instanceof Item) { Item curr_item = (Item) curr_object; - if (curr_item.is_route()) - { + if (curr_item.is_route()) { // expand the item for ripup and pushing purposes ItemAutorouteInfo item_info = curr_item.get_autoroute_info(); - neighbour_room = + neighbour_room = item_info.get_expansion_room(curr_entry.shape_index_in_object, p_autoroute_search_tree); } } - if (neighbour_room != null) - { - if (SortedRoomNeighbours.insert_door_ok(completed_room, neighbour_room, intersection)) - { + if (neighbour_room != null) { + if (SortedRoomNeighbours.insert_door_ok(completed_room, neighbour_room, intersection)) { ExpansionDoor new_door = new ExpansionDoor(completed_room, neighbour_room, 1); neighbour_room.add_door(new_door); completed_room.add_door(new_door); } } - } - else // dimensin = 0 + } else // dimensin = 0 { Point touching_point = intersection.corner(0); int room_corner_no = room_shape.equals_corner(touching_point); boolean room_touch_is_corner; int touching_side_no_of_room; - if (room_corner_no >= 0) - { + if (room_corner_no >= 0) { room_touch_is_corner = true; touching_side_no_of_room = room_corner_no; - } - else - { + } else { room_touch_is_corner = false; touching_side_no_of_room = room_shape.contains_on_border_line_no(touching_point); - if (touching_side_no_of_room < 0 && p_test_level.ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) - { + if (touching_side_no_of_room < 0 && p_test_level.ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("SortedRoomNeighbours.calculate: touching_side_no_of_room >= 0 expected"); } } int neighbour_room_corner_no = curr_shape.equals_corner(touching_point); boolean neighbour_room_touch_is_corner; int touching_side_no_of_neighbour_room; - if (neighbour_room_corner_no >= 0) - { + if (neighbour_room_corner_no >= 0) { neighbour_room_touch_is_corner = true; // The previous border line is preferred to make the shape of the incomplete room as big as possible touching_side_no_of_neighbour_room = curr_shape.prev_no(neighbour_room_corner_no); - } - else - { + } else { neighbour_room_touch_is_corner = false; touching_side_no_of_neighbour_room = curr_shape.contains_on_border_line_no(touching_point); - if (touching_side_no_of_neighbour_room < 0 && p_test_level.ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) - { + if (touching_side_no_of_neighbour_room < 0 && p_test_level.ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("AutorouteEngine.SortedRoomNeighbours.calculate: touching_side_no_of_neighbour_room >= 0 expected"); } } result.add_sorted_neighbour(curr_shape, intersection, - touching_side_no_of_room , touching_side_no_of_neighbour_room, - room_touch_is_corner , neighbour_room_touch_is_corner); + touching_side_no_of_room, touching_side_no_of_neighbour_room, + room_touch_is_corner, neighbour_room_touch_is_corner); } } return result; } - - - - /** Creates a new instance of SortedRoomNeighbours */ - private SortedRoomNeighbours(ExpansionRoom p_from_room, CompleteExpansionRoom p_completed_room) - { - from_room = p_from_room; - completed_room = p_completed_room; - room_shape = p_completed_room.get_shape(); - sorted_neighbours = new TreeSet(); - own_net_objects = new LinkedList(); + + /** + * p_door_shape is expected to bave dimension 1. + */ + static boolean insert_door_ok(ExpansionRoom p_room_1, ExpansionRoom p_room_2, TileShape p_door_shape) { + if (p_room_1.door_exists(p_room_2)) { + return false; + } + if (p_room_1 instanceof ObstacleExpansionRoom && p_room_2 instanceof ObstacleExpansionRoom) { + Item first_item = ((ObstacleExpansionRoom) p_room_1).get_item(); + Item second_item = ((ObstacleExpansionRoom) p_room_2).get_item(); + // insert only overlap_doors between items of the same net for performance reasons. + return (first_item.shares_net(second_item)); + } + if (!(p_room_1 instanceof ObstacleExpansionRoom) && !(p_room_2 instanceof ObstacleExpansionRoom)) { + return true; + } + // Insert 1 dimensional doors of trace rooms only, if they are parallel to the trace line. + // Otherwise there may be check ripup problems with entering at the wrong side at a fork. + Line door_line = null; + Point prev_corner = p_door_shape.corner(0); + int corner_count = p_door_shape.border_line_count(); + for (int i = 1; i < corner_count; ++i) { + Point curr_corner = p_door_shape.corner(i); + if (!curr_corner.equals(prev_corner)) { + door_line = p_door_shape.border_line(i - 1); + break; + } + prev_corner = curr_corner; + } + if (p_room_1 instanceof ObstacleExpansionRoom) { + if (!insert_door_ok((ObstacleExpansionRoom) p_room_1, door_line)) { + return false; + } + } + if (p_room_2 instanceof ObstacleExpansionRoom) { + if (!insert_door_ok((ObstacleExpansionRoom) p_room_2, door_line)) { + return false; + } + } + return true; } - + + /** + * Insert 1 dimensional doors for the first and the last room of a trace rooms only, + * if they are parallel to the trace line. + * Otherwise there may be check ripup problems with entering at the wrong side at a fork. + */ + private static boolean insert_door_ok(ObstacleExpansionRoom p_room, Line p_door_line) { + if (p_door_line == null) { + System.out.println("SortedRoomNeighbours.insert_door_ok: p_door_line is null"); + return false; + } + Item curr_item = p_room.get_item(); + if (curr_item instanceof PolylineTrace) { + int room_index = p_room.get_index_in_item(); + PolylineTrace curr_trace = (PolylineTrace) curr_item; + if (room_index == 0 || room_index == curr_trace.tile_shape_count() - 1) { + Line curr_trace_line = curr_trace.polyline().arr[room_index + 1]; + if (!curr_trace_line.is_parallel(p_door_line)) { + return false; + } + } + } + return true; + } + private void add_sorted_neighbour(TileShape p_neighbour_shape, TileShape p_intersection, - int p_touching_side_no_of_room, int p_touching_side_no_of_neighbour_room, - boolean p_room_touch_is_corner, boolean p_neighbour_room_touch_is_corner) - { + int p_touching_side_no_of_room, int p_touching_side_no_of_neighbour_room, + boolean p_room_touch_is_corner, boolean p_neighbour_room_touch_is_corner) { SortedRoomNeighbour new_neighbour = new SortedRoomNeighbour(p_neighbour_shape, p_intersection, p_touching_side_no_of_room, p_touching_side_no_of_neighbour_room, p_room_touch_is_corner, p_neighbour_room_touch_is_corner); sorted_neighbours.add(new_neighbour); } - + /** * Check, that each side of the romm shape has at least one touching neighbour. * Otherwise the room shape will be improved the by enlarging. * Returns true, if the room shape was changed. */ - private boolean try_remove_edge(int p_net_no, ShapeSearchTree p_autoroute_search_tree, TestLevel p_test_level) - { - if (!(this.from_room instanceof IncompleteFreeSpaceExpansionRoom)) - { + private boolean try_remove_edge(int p_net_no, ShapeSearchTree p_autoroute_search_tree, TestLevel p_test_level) { + if (!(this.from_room instanceof IncompleteFreeSpaceExpansionRoom)) { return false; } IncompleteFreeSpaceExpansionRoom curr_incomplete_room = (IncompleteFreeSpaceExpansionRoom) this.from_room; @@ -347,68 +344,55 @@ private boolean try_remove_edge(int p_net_no, ShapeSearchTree p_autoroute_search int remove_edge_no = -1; Simplex room_simplex = curr_incomplete_room.get_shape().to_Simplex(); double room_shape_area = room_simplex.area(); - + int prev_edge_no = -1; int curr_edge_no = 0; - while (it.hasNext()) - { + while (it.hasNext()) { SortedRoomNeighbour next_neighbour = it.next(); - if (next_neighbour.touching_side_no_of_room == prev_edge_no) - { + if (next_neighbour.touching_side_no_of_room == prev_edge_no) { continue; } - if (next_neighbour.touching_side_no_of_room == curr_edge_no) - { + if (next_neighbour.touching_side_no_of_room == curr_edge_no) { prev_edge_no = curr_edge_no; ++curr_edge_no; - } - else - { + } else { // On the edge side with index curr_edge_no is no touching // neighbour. remove_edge_no = curr_edge_no; break; } } - - if (remove_edge_no < 0 && curr_edge_no < room_simplex.border_line_count()) - { + + if (remove_edge_no < 0 && curr_edge_no < room_simplex.border_line_count()) { // missing touching neighbour at the last edge side. remove_edge_no = curr_edge_no; } - - - - if (remove_edge_no >= 0) - { + + + if (remove_edge_no >= 0) { // Touching neighbour missing at the edge side with index remove_edge_no // Remove the edge line and restart the algorithm. Simplex enlarged_shape = room_simplex.remove_border_line(remove_edge_no); IncompleteFreeSpaceExpansionRoom enlarged_room = new IncompleteFreeSpaceExpansionRoom(enlarged_shape, curr_incomplete_room.get_layer(), - curr_incomplete_room.get_contained_shape()); - Collection new_rooms = + curr_incomplete_room.get_contained_shape()); + Collection new_rooms = p_autoroute_search_tree.complete_shape(enlarged_room, p_net_no, null, null); - if (new_rooms.size() != 1) - { - if (p_test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (new_rooms.size() != 1) { + if (p_test_level.ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("AutorouteEngine.calculate_doors: 1 completed shape expected"); } return false; } boolean remove_edge = false; - if (new_rooms.size() == 1) - { + if (new_rooms.size() == 1) { // Check, that the area increases to prevent endless loop. IncompleteFreeSpaceExpansionRoom new_shape = new_rooms.iterator().next(); - if (new_shape.get_shape().area() > room_shape_area) - { + if (new_shape.get_shape().area() > room_shape_area) { remove_edge = true; } } - if (remove_edge) - { + if (remove_edge) { Iterator it2 = new_rooms.iterator(); IncompleteFreeSpaceExpansionRoom new_room = it2.next(); curr_incomplete_room.set_shape(new_room.get_shape()); @@ -418,63 +402,55 @@ private boolean try_remove_edge(int p_net_no, ShapeSearchTree p_autoroute_search } return false; } - + /** * Called from calculate_doors(). * The shape of the room p_result may change inside this function. */ - public void calculate_new_incomplete_rooms(AutorouteEngine p_autoroute_engine) - { + public void calculate_new_incomplete_rooms(AutorouteEngine p_autoroute_engine) { SortedRoomNeighbour prev_neighbour = this.sorted_neighbours.last(); Iterator it = this.sorted_neighbours.iterator(); Simplex room_simplex = this.from_room.get_shape().to_Simplex(); - while (it.hasNext()) - { + while (it.hasNext()) { SortedRoomNeighbour next_neighbour = it.next(); int first_touching_side_no = prev_neighbour.touching_side_no_of_room; int last_touching_side_no = next_neighbour.touching_side_no_of_room; - + int curr_next_no = room_simplex.next_no(first_touching_side_no); boolean intersection_with_prev_neighbour_ends_at_corner = (first_touching_side_no != last_touching_side_no || prev_neighbour == this.sorted_neighbours.last()) - && prev_neighbour.last_corner().equals(room_simplex.corner(curr_next_no)); + && prev_neighbour.last_corner().equals(room_simplex.corner(curr_next_no)); boolean intersection_with_next_neighbour_starts_at_corner = (first_touching_side_no != last_touching_side_no || prev_neighbour == this.sorted_neighbours.last()) - && next_neighbour.first_corner().equals(room_simplex.corner(last_touching_side_no)); - - if (intersection_with_prev_neighbour_ends_at_corner) - { + && next_neighbour.first_corner().equals(room_simplex.corner(last_touching_side_no)); + + if (intersection_with_prev_neighbour_ends_at_corner) { first_touching_side_no = curr_next_no; } - - if(intersection_with_next_neighbour_starts_at_corner) - { + + if (intersection_with_next_neighbour_starts_at_corner) { last_touching_side_no = room_simplex.prev_no(last_touching_side_no); } boolean neighbours_touch = false; - - if (this.sorted_neighbours.size() > 1) - { + + if (this.sorted_neighbours.size() > 1) { neighbours_touch = prev_neighbour.last_corner().equals(next_neighbour.first_corner()); } - - if (!neighbours_touch) - { + + if (!neighbours_touch) { // create a door to a new incomplete expansion room between // the last corner of the previous neighbour and the first corner of the // current neighbour. int last_bounding_line_no = prev_neighbour.touching_side_no_of_neighbour_room; if (!(intersection_with_prev_neighbour_ends_at_corner - || prev_neighbour.room_touch_is_corner)) - { + || prev_neighbour.room_touch_is_corner)) { last_bounding_line_no = prev_neighbour.neighbour_shape.prev_no(last_bounding_line_no); } - - + + int first_bounding_line_no = next_neighbour.touching_side_no_of_neighbour_room; if (!(intersection_with_next_neighbour_starts_at_corner - || next_neighbour.neighbour_room_touch_is_corner)) - { + || next_neighbour.neighbour_room_touch_is_corner)) { first_bounding_line_no = next_neighbour.neighbour_shape.next_no(first_bounding_line_no); } Line start_edge_line = next_neighbour.neighbour_shape.border_line(first_bounding_line_no).opposite(); @@ -483,15 +459,12 @@ public void calculate_new_incomplete_rooms(AutorouteEngine p_autoroute_engine) int curr_touching_side_no = last_touching_side_no; boolean first_time = true; // The loop goes backwards fromm the edge line of next_neigbour to the edge line of prev_neigbour. - for (;;) - { + for (; ; ) { boolean corner_cut_off = false; - if (this.from_room instanceof IncompleteFreeSpaceExpansionRoom) - { + if (this.from_room instanceof IncompleteFreeSpaceExpansionRoom) { IncompleteFreeSpaceExpansionRoom incomplete_room = (IncompleteFreeSpaceExpansionRoom) this.from_room; if (curr_touching_side_no == last_touching_side_no - && first_touching_side_no != last_touching_side_no) - { + && first_touching_side_no != last_touching_side_no) { // Create a new line approximately from the last corner of the previous // neighbour to the first corner of the next neighbour to cut off // the outstanding corners of the room shape in the empty space. @@ -500,87 +473,73 @@ public void calculate_new_incomplete_rooms(AutorouteEngine p_autoroute_engine) IntPoint cut_line_end = next_neighbour.first_corner().to_float().round(); Line cut_line = new Line(cut_line_start, cut_line_end); TileShape cut_half_plane = TileShape.get_instance(cut_line); - ((CompleteFreeSpaceExpansionRoom)this.completed_room).set_shape(this.completed_room.get_shape().intersection(cut_half_plane)); + ((CompleteFreeSpaceExpansionRoom) this.completed_room).set_shape(this.completed_room.get_shape().intersection(cut_half_plane)); corner_cut_off = true; - if (incomplete_room.get_contained_shape().side_of(cut_line) != Side.ON_THE_LEFT) - { + if (incomplete_room.get_contained_shape().side_of(cut_line) != Side.ON_THE_LEFT) { // Otherwise p_room.contained_shape would no longer be contained // in the shape after cutting of the corner. corner_cut_off = false; } - if (corner_cut_off) - { + if (corner_cut_off) { middle_edge_line = cut_line.opposite(); } } } int next_touching_side_no = room_simplex.prev_no(curr_touching_side_no); - - if (!corner_cut_off) - { + + if (!corner_cut_off) { middle_edge_line = room_simplex.border_line(curr_touching_side_no).opposite(); } - + Direction middle_line_dir = middle_edge_line.direction(); - + boolean last_time = curr_touching_side_no == first_touching_side_no - && !(prev_neighbour == this.sorted_neighbours.last() && first_time) - // The expression above handles the case, when all neigbours are on 1 edge line. - || corner_cut_off; - + && !(prev_neighbour == this.sorted_neighbours.last() && first_time) + // The expression above handles the case, when all neigbours are on 1 edge line. + || corner_cut_off; + Line end_edge_line; // end_edge_line is only used for the last new incomplete room. - if (last_time) - { + if (last_time) { end_edge_line = prev_neighbour.neighbour_shape.border_line(last_bounding_line_no).opposite(); - if (end_edge_line.direction().side_of(middle_line_dir) != Side.ON_THE_LEFT) - { + if (end_edge_line.direction().side_of(middle_line_dir) != Side.ON_THE_LEFT) { // Concave corner between the middle and the last line. // May be there is a 1 point touch. end_edge_line = null; } - } - else - { + } else { end_edge_line = null; } - - if (start_edge_line != null && middle_line_dir.side_of(start_edge_line.direction()) != Side.ON_THE_LEFT) - { + + if (start_edge_line != null && middle_line_dir.side_of(start_edge_line.direction()) != Side.ON_THE_LEFT) { // concave corner between the first and the middle line // May be there is a 1 point touch. start_edge_line = null; } int new_edge_line_count = 1; - if (start_edge_line != null) - { + if (start_edge_line != null) { ++new_edge_line_count; } - if (end_edge_line != null) - { + if (end_edge_line != null) { ++new_edge_line_count; } - Line [] new_edge_lines = new Line[new_edge_line_count]; + Line[] new_edge_lines = new Line[new_edge_line_count]; int curr_index = 0; - if (start_edge_line != null) - { + if (start_edge_line != null) { new_edge_lines[curr_index] = start_edge_line; ++curr_index; } new_edge_lines[curr_index] = middle_edge_line; - if (end_edge_line != null) - { + if (end_edge_line != null) { ++curr_index; new_edge_lines[curr_index] = end_edge_line; } Simplex new_room_shape = Simplex.get_instance(new_edge_lines); - if (!new_room_shape.is_empty()) - { - + if (!new_room_shape.is_empty()) { + TileShape new_contained_shape = this.completed_room.get_shape().intersection(new_room_shape); - if (!new_contained_shape.is_empty()) - { + if (!new_contained_shape.is_empty()) { FreeSpaceExpansionRoom new_room = p_autoroute_engine.add_incomplete_expansion_room(new_room_shape, this.from_room.get_layer(), new_contained_shape); ExpansionDoor new_door = new ExpansionDoor(this.completed_room, new_room, 1); @@ -588,8 +547,7 @@ public void calculate_new_incomplete_rooms(AutorouteEngine p_autoroute_engine) new_room.add_door(new_door); } } - if (last_time) - { + if (last_time) { break; } curr_touching_side_no = next_touching_side_no; @@ -600,106 +558,48 @@ public void calculate_new_incomplete_rooms(AutorouteEngine p_autoroute_engine) prev_neighbour = next_neighbour; } } - - /** - * p_door_shape is expected to bave dimension 1. - */ - static boolean insert_door_ok(ExpansionRoom p_room_1, ExpansionRoom p_room_2, TileShape p_door_shape) - { - if (p_room_1.door_exists(p_room_2)) - { - return false; - } - if (p_room_1 instanceof ObstacleExpansionRoom && p_room_2 instanceof ObstacleExpansionRoom) - { - Item first_item = ((ObstacleExpansionRoom) p_room_1).get_item(); - Item second_item = ((ObstacleExpansionRoom) p_room_2).get_item(); - // insert only overlap_doors between items of the same net for performance reasons. - return (first_item.shares_net(second_item)); - } - if (!(p_room_1 instanceof ObstacleExpansionRoom) && !(p_room_2 instanceof ObstacleExpansionRoom)) - { - return true; - } - // Insert 1 dimensional doors of trace rooms only, if they are parallel to the trace line. - // Otherwise there may be check ripup problems with entering at the wrong side at a fork. - Line door_line = null; - Point prev_corner = p_door_shape.corner(0); - int corner_count = p_door_shape.border_line_count(); - for (int i = 1; i < corner_count; ++i) - { - Point curr_corner = p_door_shape.corner(i); - if (!curr_corner.equals(prev_corner)) - { - door_line = p_door_shape.border_line(i - 1); - break; - } - prev_corner = curr_corner; - } - if (p_room_1 instanceof ObstacleExpansionRoom) - { - if (!insert_door_ok((ObstacleExpansionRoom) p_room_1, door_line)) - { - return false; - } - } - if (p_room_2 instanceof ObstacleExpansionRoom) - { - if (!insert_door_ok((ObstacleExpansionRoom) p_room_2, door_line)) - { - return false; - } - } - return true; - } - /** - * Insert 1 dimensional doors for the first and the last room of a trace rooms only, - * if they are parallel to the trace line. - * Otherwise there may be check ripup problems with entering at the wrong side at a fork. - */ - private static boolean insert_door_ok(ObstacleExpansionRoom p_room, Line p_door_line) - { - if (p_door_line == null) - { - System.out.println("SortedRoomNeighbours.insert_door_ok: p_door_line is null"); - return false; - } - Item curr_item = p_room.get_item(); - if (curr_item instanceof PolylineTrace) - { - int room_index = p_room.get_index_in_item(); - PolylineTrace curr_trace = (PolylineTrace) curr_item; - if (room_index == 0 || room_index == curr_trace.tile_shape_count() - 1) - { - Line curr_trace_line = curr_trace.polyline().arr[room_index + 1]; - if (!curr_trace_line.is_parallel(p_door_line)) - { - return false; - } - } - } - return true; - } - - private final ExpansionRoom from_room; - private final CompleteExpansionRoom completed_room; - private final TileShape room_shape; - private final SortedSet sorted_neighbours; - private final Collection own_net_objects; - + /** * Helper class to sort the doors of an expansion room counterclockwise * arount the border of the room shape. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ - - private class SortedRoomNeighbour implements Comparable - { + + private class SortedRoomNeighbour implements Comparable { + static private final double c_dist_tolerance = 1; + /** + * The shape of the neighbour room + */ + public final TileShape neighbour_shape; + /** + * The intersection of tnis ExpansionRoom shape with the neighbour_shape + */ + public final TileShape intersection; + /** + * The side number of this room, where it touches the neighbour + */ + public final int touching_side_no_of_room; + /** + * The side number of the neighbour room, where it touches this room + */ + public final int touching_side_no_of_neighbour_room; + /** + * True, if the intersection of this room and the neighbour is + * equal to a corner of this room + */ + public final boolean room_touch_is_corner; + /** + * True, if the intersection of this room and the neighbour is + * equal to a corner of the neighbour room + */ + public final boolean neighbour_room_touch_is_corner; + private Point precalculated_first_corner = null; + private Point precalculated_last_corner = null; + public SortedRoomNeighbour(TileShape p_neighbour_shape, TileShape p_intersection, - int p_touching_side_no_of_room, int p_touching_side_no_of_neighbour_room, - boolean p_room_touch_is_corner, boolean p_neighbour_room_touch_is_corner) - { + int p_touching_side_no_of_room, int p_touching_side_no_of_neighbour_room, + boolean p_room_touch_is_corner, boolean p_neighbour_room_touch_is_corner) { neighbour_shape = p_neighbour_shape; intersection = p_intersection; touching_side_no_of_room = p_touching_side_no_of_room; @@ -707,41 +607,35 @@ public SortedRoomNeighbour(TileShape p_neighbour_shape, TileShape p_intersection room_touch_is_corner = p_room_touch_is_corner; neighbour_room_touch_is_corner = p_neighbour_room_touch_is_corner; } - + /** * Compare function for or sorting the neighbours in counterclock sense * around the border of the room shape in ascending order. */ - public int compareTo(SortedRoomNeighbour p_other) - { + public int compareTo(SortedRoomNeighbour p_other) { int compare_value = this.touching_side_no_of_room - p_other.touching_side_no_of_room; - if (compare_value != 0) - { + if (compare_value != 0) { return compare_value; } FloatPoint compare_corner = room_shape.corner_approx(touching_side_no_of_room); double this_distance = this.first_corner().to_float().distance(compare_corner); double other_distance = p_other.first_corner().to_float().distance(compare_corner); double delta_distance = this_distance - other_distance; - if (Math.abs(delta_distance) <= c_dist_tolerance) - { + if (Math.abs(delta_distance) <= c_dist_tolerance) { // check corners for equality - if (this.first_corner().equals(p_other.first_corner())) - { + if (this.first_corner().equals(p_other.first_corner())) { // in this case compare the last corners double this_distance2 = this.last_corner().to_float().distance(compare_corner); double other_distance2 = p_other.last_corner().to_float().distance(compare_corner); delta_distance = this_distance2 - other_distance2; - if (Math.abs(delta_distance) <= c_dist_tolerance) - { + if (Math.abs(delta_distance) <= c_dist_tolerance) { if (this.neighbour_room_touch_is_corner && p_other.neighbour_room_touch_is_corner) - // Otherwise there may be a short 1 dim. touch at a link between 2 trace lines. - // In this case equality is ok, because the 2 intersection pieces with - // the expansion room are identical, so that only 1 obstacle is needed. + // Otherwise there may be a short 1 dim. touch at a link between 2 trace lines. + // In this case equality is ok, because the 2 intersection pieces with + // the expansion room are identical, so that only 1 obstacle is needed. { int compare_line_no = touching_side_no_of_room; - if (room_touch_is_corner) - { + if (room_touch_is_corner) { compare_line_no = room_shape.prev_no(compare_line_no); } Direction compare_dir = room_shape.border_line(compare_line_no).direction().opposite(); @@ -755,31 +649,22 @@ public int compareTo(SortedRoomNeighbour p_other) int result = Signum.as_int(delta_distance); return result; } - + /** * Returns the first corner of the intersection shape with the neighbour. */ - public Point first_corner() - { - if (precalculated_first_corner == null) - { - if (room_touch_is_corner) - { + public Point first_corner() { + if (precalculated_first_corner == null) { + if (room_touch_is_corner) { precalculated_first_corner = room_shape.corner(touching_side_no_of_room); - } - else if (neighbour_room_touch_is_corner) - { + } else if (neighbour_room_touch_is_corner) { precalculated_first_corner = neighbour_shape.corner(touching_side_no_of_neighbour_room); - } - else - { + } else { Point curr_first_corner = neighbour_shape.corner(neighbour_shape.next_no(touching_side_no_of_neighbour_room)); Line prev_line = room_shape.border_line(room_shape.prev_no(touching_side_no_of_room)); - if (prev_line.side_of(curr_first_corner) == Side.ON_THE_RIGHT) - { + if (prev_line.side_of(curr_first_corner) == Side.ON_THE_RIGHT) { precalculated_first_corner = curr_first_corner; - } - else // curr_first_corner is outside the door shape + } else // curr_first_corner is outside the door shape { precalculated_first_corner = room_shape.corner(touching_side_no_of_room); } @@ -787,31 +672,22 @@ else if (neighbour_room_touch_is_corner) } return precalculated_first_corner; } - + /** * Returns the last corner of the intersection shape with the neighbour. */ - public Point last_corner() - { - if (precalculated_last_corner == null) - { - if (room_touch_is_corner) - { + public Point last_corner() { + if (precalculated_last_corner == null) { + if (room_touch_is_corner) { precalculated_last_corner = room_shape.corner(touching_side_no_of_room); - } - else if (neighbour_room_touch_is_corner) - { + } else if (neighbour_room_touch_is_corner) { precalculated_last_corner = neighbour_shape.corner(touching_side_no_of_neighbour_room); - } - else - { + } else { Point curr_last_corner = neighbour_shape.corner(touching_side_no_of_neighbour_room); Line next_line = room_shape.border_line(room_shape.next_no(touching_side_no_of_room)); - if (next_line.side_of(curr_last_corner) == Side.ON_THE_RIGHT) - { + if (next_line.side_of(curr_last_corner) == Side.ON_THE_RIGHT) { precalculated_last_corner = curr_last_corner; - } - else // curr_last_corner is outside the door shape + } else // curr_last_corner is outside the door shape { precalculated_last_corner = room_shape.corner(room_shape.next_no(touching_side_no_of_room)); } @@ -819,30 +695,5 @@ else if (neighbour_room_touch_is_corner) } return precalculated_last_corner; } - - /** The shape of the neighbour room */ - public final TileShape neighbour_shape; - - /** The intersection of tnis ExpansionRoom shape with the neighbour_shape */ - public final TileShape intersection; - - /** The side number of this room, where it touches the neighbour */ - public final int touching_side_no_of_room ; - - /** The side number of the neighbour room, where it touches this room */ - public final int touching_side_no_of_neighbour_room ; - - /** True, if the intersection of this room and the neighbour is - * equal to a corner of this room */ - public final boolean room_touch_is_corner; - - /** True, if the intersection of this room and the neighbour is - * equal to a corner of the neighbour room */ - public final boolean neighbour_room_touch_is_corner; - - private Point precalculated_first_corner = null; - private Point precalculated_last_corner = null; - - static private final double c_dist_tolerance = 1; } } diff --git a/src/main/java/net/freerouting/autoroute/TargetItemExpansionDoor.java b/src/main/java/net/freerouting/autoroute/TargetItemExpansionDoor.java index 6c82c160..d6544984 100644 --- a/src/main/java/net/freerouting/autoroute/TargetItemExpansionDoor.java +++ b/src/main/java/net/freerouting/autoroute/TargetItemExpansionDoor.java @@ -19,76 +19,66 @@ */ package net.freerouting.autoroute; -import net.freerouting.geometry.planar.Simplex; -import net.freerouting.geometry.planar.TileShape; import net.freerouting.board.Item; import net.freerouting.board.ShapeSearchTree; +import net.freerouting.geometry.planar.Simplex; +import net.freerouting.geometry.planar.TileShape; /** * An expansion door leading to a start or destination item of the autoroute algorithm. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class TargetItemExpansionDoor implements ExpandableObject -{ +public class TargetItemExpansionDoor implements ExpandableObject { + + public final Item item; + public final int tree_entry_no; + public final CompleteExpansionRoom room; + private final TileShape shape; + private final MazeSearchElement maze_search_info; - /** Creates a new instance of ItemExpansionInfo */ - public TargetItemExpansionDoor(Item p_item, int p_tree_entry_no, CompleteExpansionRoom p_room, ShapeSearchTree p_search_tree) - { + /** + * Creates a new instance of ItemExpansionInfo + */ + public TargetItemExpansionDoor(Item p_item, int p_tree_entry_no, CompleteExpansionRoom p_room, ShapeSearchTree p_search_tree) { item = p_item; tree_entry_no = p_tree_entry_no; room = p_room; - if (room == null) - { + if (room == null) { this.shape = Simplex.EMPTY; - } - else - { + } else { TileShape item_shape = item.get_tree_shape(p_search_tree, tree_entry_no); this.shape = item_shape.intersection(room.get_shape()); } maze_search_info = new MazeSearchElement(); } - public TileShape get_shape() - { + public TileShape get_shape() { return this.shape; } - public int get_dimension() - { + public int get_dimension() { return 2; } - public boolean is_destination_door() - { + public boolean is_destination_door() { ItemAutorouteInfo item_info = this.item.get_autoroute_info(); return !item_info.is_start_info(); } - public CompleteExpansionRoom other_room(CompleteExpansionRoom p_room) - { + public CompleteExpansionRoom other_room(CompleteExpansionRoom p_room) { return null; } - public MazeSearchElement get_maze_search_element(int p_no) - { + public MazeSearchElement get_maze_search_element(int p_no) { return maze_search_info; } - public int maze_search_element_count() - { + public int maze_search_element_count() { return 1; } - public void reset() - { + public void reset() { maze_search_info.reset(); } - - public final Item item; - public final int tree_entry_no; - public final CompleteExpansionRoom room; - private final TileShape shape; - private final MazeSearchElement maze_search_info; } diff --git a/src/main/java/net/freerouting/autoroute/package.html b/src/main/java/net/freerouting/autoroute/package.html index 2e56d1f7..5fd52206 100644 --- a/src/main/java/net/freerouting/autoroute/package.html +++ b/src/main/java/net/freerouting/autoroute/package.html @@ -1,5 +1,6 @@ -java.text package -Contains functionality of the autoroute algorithm. \ No newline at end of file +Contains functionality of the autoroute algorithm. + \ No newline at end of file diff --git a/src/main/java/net/freerouting/board/AngleRestriction.java b/src/main/java/net/freerouting/board/AngleRestriction.java index 4e62c16b..e9da4976 100644 --- a/src/main/java/net/freerouting/board/AngleRestriction.java +++ b/src/main/java/net/freerouting/board/AngleRestriction.java @@ -25,39 +25,37 @@ * * @author Alfons Wirtz */ -public class AngleRestriction -{ +public class AngleRestriction { public static final AngleRestriction NONE = new AngleRestriction("none", 0); public static final AngleRestriction FORTYFIVE_DEGREE = new AngleRestriction("45 degree", 1); public static final AngleRestriction NINETY_DEGREE = new AngleRestriction("90 degree", 2); - + public static final AngleRestriction[] arr = - { - NONE, FORTYFIVE_DEGREE, NINETY_DEGREE - }; - + { + NONE, FORTYFIVE_DEGREE, NINETY_DEGREE + }; + private final String name; + private final int no; + + /** + * Creates a new instance of SnapAngle + */ + private AngleRestriction(String p_name, int p_no) { + name = p_name; + no = p_no; + } + /** * Returns the string of this instance */ - public String to_string() - { + public String to_string() { return name; } - + /** * Returns the number of this instance */ - public int get_no() - { + public int get_no() { return no; } - /** Creates a new instance of SnapAngle */ - private AngleRestriction(String p_name, int p_no) - { - name = p_name; - no = p_no; - } - - private final String name; - private final int no; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/board/BasicBoard.java b/src/main/java/net/freerouting/board/BasicBoard.java index ec967736..8b2c2337 100644 --- a/src/main/java/net/freerouting/board/BasicBoard.java +++ b/src/main/java/net/freerouting/board/BasicBoard.java @@ -15,36 +15,21 @@ */ package net.freerouting.board; -import net.freerouting.geometry.planar.Area; -import net.freerouting.geometry.planar.ConvexShape; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.IntOctagon; +import net.freerouting.boardgraphics.Drawable; +import net.freerouting.boardgraphics.GraphicsContext; +import net.freerouting.datastructures.ShapeTree.TreeEntry; +import net.freerouting.datastructures.UndoableObjects; +import net.freerouting.geometry.planar.*; import net.freerouting.geometry.planar.Point; import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.PolylineShape; -import net.freerouting.geometry.planar.TileShape; - -import java.awt.Graphics; - -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import net.freerouting.datastructures.ShapeTree.TreeEntry; - import net.freerouting.library.BoardLibrary; import net.freerouting.library.Padstack; import net.freerouting.rules.BoardRules; -import net.freerouting.boardgraphics.GraphicsContext; -import net.freerouting.boardgraphics.Drawable; -import net.freerouting.datastructures.UndoableObjects; + +import java.awt.*; +import java.util.*; /** - * * Provides basic functionality of a board with geometric items. * Contains functions such as inserting, deleting, modifying * and picking items and elementary checking functions. @@ -52,8 +37,59 @@ * * @author Alfons Wirtz */ -public class BasicBoard implements java.io.Serializable -{ +public class BasicBoard implements java.io.Serializable { + + /** + * List of items inserted into this board + */ + public final UndoableObjects item_list; + /** + * List of placed components on the board. + */ + public final Components components; + /** + * Class defining the rules for items to be inserted into this board. + * Contains for example the clearance matrix. + */ + public final BoardRules rules; + /** + * The library containing pastack masks, packagages and other + * templates used on the board. + */ + public final BoardLibrary library; + /** + * The layer structure of this board. + */ + public final LayerStructure layer_structure; + /** + * For communication with a host system or host design file formats. + */ + public final Communication communication; + /** + * bounding orthogonal rectangle of this board + */ + public final IntBox bounding_box; + /** + * Handels the search trees pointing into the items of this board + */ + public transient SearchTreeManager search_tree_manager; + /** + * If test_level != RELEASE_VERSION, some features may be used, which are still in experimental state. + * Also warnings for debugging may be printed depending on the size of test_level. + */ + transient private TestLevel test_level; + /** + * the rectangle, where the graphics may be not uptodate + */ + transient private IntBox update_box = IntBox.EMPTY; + /** + * the biggest half width of all traces on the board + */ + private int max_trace_half_width = 1000; + /** + * the smallest half width of all traces on the board + */ + private int min_trace_half_width = 10000; /** * Creates a new instance of a routing Board with surrrounding box @@ -66,8 +102,7 @@ public class BasicBoard implements java.io.Serializable * Also warnings for debugging may be printed depending on the size of p_test_level. */ public BasicBoard(IntBox p_bounding_box, LayerStructure p_layer_structure, PolylineShape[] p_outline_shapes, - int p_outline_cl_class_no, BoardRules p_rules, Communication p_communication, TestLevel p_test_level) - { + int p_outline_cl_class_no, BoardRules p_rules, Communication p_communication, TestLevel p_test_level) { layer_structure = p_layer_structure; rules = p_rules; library = new BoardLibrary(); @@ -89,24 +124,19 @@ public BasicBoard(IntBox p_bounding_box, LayerStructure p_layer_structure, Polyl * item can be returned. */ public PolylineTrace insert_trace_without_cleaning(Polyline p_polyline, int p_layer, - int p_half_width, int[] p_net_no_arr, int p_clearance_class, FixedState p_fixed_state) - { - if (p_polyline.corner_count() < 2) - { + int p_half_width, int[] p_net_no_arr, int p_clearance_class, FixedState p_fixed_state) { + if (p_polyline.corner_count() < 2) { return null; } PolylineTrace new_trace = new PolylineTrace(p_polyline, p_layer, p_half_width, p_net_no_arr, p_clearance_class, 0, 0, p_fixed_state, this); - if (new_trace.first_corner().equals(new_trace.last_corner())) - { - if (p_fixed_state.ordinal() < FixedState.USER_FIXED.ordinal()) - { + if (new_trace.first_corner().equals(new_trace.last_corner())) { + if (p_fixed_state.ordinal() < FixedState.USER_FIXED.ordinal()) { return null; } } insert_item(new_trace); - if (new_trace.nets_normal()) - { + if (new_trace.nets_normal()) { max_trace_half_width = Math.max(max_trace_half_width, p_half_width); min_trace_half_width = Math.min(min_trace_half_width, p_half_width); } @@ -119,21 +149,17 @@ public PolylineTrace insert_trace_without_cleaning(Polyline p_polyline, int p_la * which describes the required clearance restrictions to other items. */ public void insert_trace(Polyline p_polyline, int p_layer, - int p_half_width, int[] p_net_no_arr, int p_clearance_class, FixedState p_fixed_state) - { + int p_half_width, int[] p_net_no_arr, int p_clearance_class, FixedState p_fixed_state) { PolylineTrace new_trace = insert_trace_without_cleaning(p_polyline, p_layer, p_half_width, - p_net_no_arr, p_clearance_class, p_fixed_state); - if (new_trace == null) - { + p_net_no_arr, p_clearance_class, p_fixed_state); + if (new_trace == null) { return; } IntOctagon clip_shape = null; - if (this instanceof RoutingBoard) - { + if (this instanceof RoutingBoard) { ChangedArea changed_area = ((RoutingBoard) this).changed_area; - if (changed_area != null) - { + if (changed_area != null) { clip_shape = changed_area.get_area(p_layer); } } @@ -145,12 +171,9 @@ public void insert_trace(Polyline p_polyline, int p_layer, * an array of points, and cleans up the net. */ public void insert_trace(Point[] p_points, int p_layer, - int p_half_width, int[] p_net_no_arr, int p_clearance_class, FixedState p_fixed_state) - { - for (int i = 0; i < p_points.length; ++i) - { - if (!this.bounding_box.contains(p_points[i])) - { + int p_half_width, int[] p_net_no_arr, int p_clearance_class, FixedState p_fixed_state) { + for (int i = 0; i < p_points.length; ++i) { + if (!this.bounding_box.contains(p_points[i])) { System.out.println("LayeredBoard.insert_trace: input point out of range"); } } @@ -163,17 +186,14 @@ public void insert_trace(Point[] p_points, int p_layer, * of the same net. */ public Via insert_via(Padstack p_padstack, Point p_center, int[] p_net_no_arr, int p_clearance_class, - FixedState p_fixed_state, boolean p_attach_allowed) - { + FixedState p_fixed_state, boolean p_attach_allowed) { Via new_via = new Via(p_padstack, p_center, p_net_no_arr, p_clearance_class, 0, 0, p_fixed_state, p_attach_allowed, this); insert_item(new_via); int from_layer = p_padstack.from_layer(); int to_layer = p_padstack.to_layer(); - for (int i = from_layer; i < to_layer; ++i) - { - for (int curr_net_no : p_net_no_arr) - { + for (int i = from_layer; i < to_layer; ++i) { + for (int curr_net_no : p_net_no_arr) { split_traces(p_center, i, curr_net_no); } } @@ -182,10 +202,9 @@ public Via insert_via(Padstack p_padstack, Point p_center, int[] p_net_no_arr, i /** * Inserts a pin into the board. - * p_pin_no is the number of this pin in the library package of its component (starting with 0). + * p_pin_no is the number of this pin in the library package of its component (starting with 0). */ - public Pin insert_pin(int p_component_no, int p_pin_no, int[] p_net_no_arr, int p_clearance_class, FixedState p_fixed_state) - { + public Pin insert_pin(int p_component_no, int p_pin_no, int[] p_net_no_arr, int p_clearance_class, FixedState p_fixed_state) { Pin new_pin = new Pin(p_component_no, p_pin_no, p_net_no_arr, p_clearance_class, 0, p_fixed_state, this); insert_item(new_pin); return new_pin; @@ -196,10 +215,8 @@ public Pin insert_pin(int p_component_no, int p_pin_no, int[] p_net_no_arr, int * by a polygonyal shape, which may have holes. * If p_component_no != 0, the obstacle belongs to a component. */ - public ObstacleArea insert_obstacle(Area p_area, int p_layer, int p_clearance_class, FixedState p_fixed_state) - { - if (p_area == null) - { + public ObstacleArea insert_obstacle(Area p_area, int p_layer, int p_clearance_class, FixedState p_fixed_state) { + if (p_area == null) { System.out.println("BasicBoard.insert_obstacle: p_area is null"); return null; } @@ -213,10 +230,8 @@ public ObstacleArea insert_obstacle(Area p_area, int p_layer, int p_clearance_cl * p_name is to identify the corresponding ObstacstacleArea in the component package. */ public ObstacleArea insert_obstacle(Area p_area, int p_layer, Vector p_translation, double p_rotation_in_degree, - boolean p_side_changed, int p_clearance_class, int p_component_no, String p_name, FixedState p_fixed_state) - { - if (p_area == null) - { + boolean p_side_changed, int p_clearance_class, int p_component_no, String p_name, FixedState p_fixed_state) { + if (p_area == null) { System.out.println("BasicBoard.insert_obstacle: p_area is null"); return null; } @@ -231,10 +246,8 @@ public ObstacleArea insert_obstacle(Area p_area, int p_layer, Vector p_translati * by a polygonyal shape, which may have holes. */ public ViaObstacleArea insert_via_obstacle(Area p_area, int p_layer, int p_clearance_class, - FixedState p_fixed_state) - { - if (p_area == null) - { + FixedState p_fixed_state) { + if (p_area == null) { System.out.println("BasicBoard.insert_via_obstacle: p_area is null"); return null; } @@ -250,10 +263,8 @@ public ViaObstacleArea insert_via_obstacle(Area p_area, int p_layer, int p_clear */ public ViaObstacleArea insert_via_obstacle(Area p_area, int p_layer, Vector p_translation, double p_rotation_in_degree, boolean p_side_changed, int p_clearance_class, int p_component_no, String p_name, - FixedState p_fixed_state) - { - if (p_area == null) - { + FixedState p_fixed_state) { + if (p_area == null) { System.out.println("BasicBoard.insert_via_obstacle: p_area is null"); return null; } @@ -268,10 +279,8 @@ public ViaObstacleArea insert_via_obstacle(Area p_area, int p_layer, Vector p_tr * by a polygonyal shape, which may have holes. */ public ComponentObstacleArea insert_component_obstacle(Area p_area, int p_layer, - int p_clearance_class, FixedState p_fixed_state) - { - if (p_area == null) - { + int p_clearance_class, FixedState p_fixed_state) { + if (p_area == null) { System.out.println("BasicBoard.insert_component_obstacle: p_area is null"); return null; } @@ -286,10 +295,8 @@ public ComponentObstacleArea insert_component_obstacle(Area p_area, int p_layer, * p_name is to identify the corresponding ObstacstacleArea in the component package. */ public ComponentObstacleArea insert_component_obstacle(Area p_area, int p_layer, Vector p_translation, double p_rotation_in_degree, - boolean p_side_changed, int p_clearance_class, int p_component_no, String p_name, FixedState p_fixed_state) - { - if (p_area == null) - { + boolean p_side_changed, int p_clearance_class, int p_component_no, String p_name, FixedState p_fixed_state) { + if (p_area == null) { System.out.println("BasicBoard.insert_component_obstacle: p_area is null"); return null; } @@ -303,15 +310,12 @@ public ComponentObstacleArea insert_component_obstacle(Area p_area, int p_layer, * Inserts a component ouline into the board. */ public ComponentOutline insert_component_outline(Area p_area, boolean p_is_front, Vector p_translation, double p_rotation_in_degree, - int p_component_no, FixedState p_fixed_state) - { - if (p_area == null) - { + int p_component_no, FixedState p_fixed_state) { + if (p_area == null) { System.out.println("BasicBoard.insert_component_outline: p_area is null"); return null; } - if (!p_area.is_bounded()) - { + if (!p_area.is_bounded()) { System.out.println("BasicBoard.insert_component_outline: p_area is not bounded"); return null; } @@ -328,10 +332,8 @@ public ComponentOutline insert_component_outline(Area p_area, boolean p_is_front * with traces and vias of foreign nets. */ public ConductionArea insert_conduction_area(Area p_area, int p_layer, - int[] p_net_no_arr, int p_clearance_class, boolean p_is_obstacle, FixedState p_fixed_state) - { - if (p_area == null) - { + int[] p_net_no_arr, int p_clearance_class, boolean p_is_obstacle, FixedState p_fixed_state) { + if (p_area == null) { System.out.println("BasicBoard.insert_conduction_area: p_area is null"); return null; } @@ -344,8 +346,7 @@ public ConductionArea insert_conduction_area(Area p_area, int p_layer, /** * Inserts an Outline into the board. */ - public BoardOutline insert_outline(PolylineShape[] p_outline_shapes, int p_clearance_class_no) - { + public BoardOutline insert_outline(PolylineShape[] p_outline_shapes, int p_clearance_class_no) { BoardOutline result = new BoardOutline(p_outline_shapes, p_clearance_class_no, 0, this); insert_item(result); return result; @@ -354,18 +355,14 @@ public BoardOutline insert_outline(PolylineShape[] p_outline_shapes, int p_clear /** * Returns the outline of the board. */ - public BoardOutline get_outline() - { + public BoardOutline get_outline() { Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { UndoableObjects.Storable curr_item = item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof BoardOutline) - { + if (curr_item instanceof BoardOutline) { return (BoardOutline) curr_item; } } @@ -375,10 +372,8 @@ public BoardOutline get_outline() /** * Removes an item from the board */ - public void remove_item(Item p_item) - { - if (p_item == null) - { + public void remove_item(Item p_item) { + if (p_item == null) { return; } additional_update_after_change(p_item); // must be called before p_item is deleted. @@ -393,18 +388,14 @@ public void remove_item(Item p_item) * looks, if an item with id_no p_id_no is on the board. * Returns the found item or null, if no such item is found. */ - public Item get_item(int p_id_no) - { + public Item get_item(int p_id_no) { Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item.get_id_no() == p_id_no) - { + if (curr_item.get_id_no() == p_id_no) { return curr_item; } } @@ -414,15 +405,12 @@ public Item get_item(int p_id_no) /** * Returns the list of all items on the board */ - public Collection get_items() - { + public Collection get_items() { Collection result = new LinkedList(); Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } result.add(curr_item); @@ -433,19 +421,15 @@ public Collection get_items() /** * Returns all connectable items on the board containing p_net_no */ - public Collection get_connectable_items(int p_net_no) - { + public Collection get_connectable_items(int p_net_no) { Collection result = new LinkedList(); Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof Connectable && curr_item.contains_net(p_net_no)) - { + if (curr_item instanceof Connectable && curr_item.contains_net(p_net_no)) { result.add(curr_item); } } @@ -455,19 +439,15 @@ public Collection get_connectable_items(int p_net_no) /** * Returns the count of connectable items of the net with number p_net_no */ - public int connectable_item_count(int p_net_no) - { + public int connectable_item_count(int p_net_no) { int result = 0; Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof Connectable && curr_item.contains_net(p_net_no)) - { + if (curr_item instanceof Connectable && curr_item.contains_net(p_net_no)) { ++result; } } @@ -477,19 +457,15 @@ public int connectable_item_count(int p_net_no) /** * Returns all items with the input component number */ - public Collection get_component_items(int p_component_no) - { + public Collection get_component_items(int p_component_no) { Collection result = new LinkedList(); Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item.get_component_no() == p_component_no) - { + if (curr_item.get_component_no() == p_component_no) { result.add(curr_item); } } @@ -499,19 +475,15 @@ public Collection get_component_items(int p_component_no) /** * Returns all pins with the input component number */ - public Collection get_component_pins(int p_component_no) - { + public Collection get_component_pins(int p_component_no) { Collection result = new LinkedList(); Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item.get_component_no() == p_component_no && curr_item instanceof Pin) - { + if (curr_item.get_component_no() == p_component_no && curr_item instanceof Pin) { result.add((Pin) curr_item); } } @@ -521,21 +493,16 @@ public Collection get_component_pins(int p_component_no) /** * Returns the pin with the input component number and pin number, or null, if no such pinn exists. */ - public Pin get_pin(int p_component_no, int p_pin_no) - { + public Pin get_pin(int p_component_no, int p_pin_no) { Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item.get_component_no() == p_component_no && curr_item instanceof Pin) - { + if (curr_item.get_component_no() == p_component_no && curr_item instanceof Pin) { Pin curr_pin = (Pin) curr_item; - if (curr_pin.pin_no == p_pin_no) - { + if (curr_pin.pin_no == p_pin_no) { return curr_pin; } } @@ -547,19 +514,14 @@ public Pin get_pin(int p_component_no, int p_pin_no) * Removes the items in p_item_list. * Returns false, if some items could not be removed, bcause they are fixed. */ - public boolean remove_items(Collection p_item_list, boolean p_with_delete_fixed) - { + public boolean remove_items(Collection p_item_list, boolean p_with_delete_fixed) { boolean result = true; Iterator it = p_item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (!p_with_delete_fixed && curr_item.is_delete_fixed() || curr_item.is_user_fixed()) - { + if (!p_with_delete_fixed && curr_item.is_delete_fixed() || curr_item.is_user_fixed()) { result = false; - } - else - { + } else { remove_item(curr_item); } } @@ -569,19 +531,15 @@ public boolean remove_items(Collection p_item_list, boolean p_with_delete_ /** * Returns the list of all conduction areas on the board */ - public Collection get_conduction_areas() - { + public Collection get_conduction_areas() { Collection result = new LinkedList(); Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { UndoableObjects.Storable curr_item = item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof ConductionArea) - { + if (curr_item instanceof ConductionArea) { result.add((ConductionArea) curr_item); } } @@ -591,19 +549,15 @@ public Collection get_conduction_areas() /** * Returns the list of all pins on the board */ - public Collection get_pins() - { + public Collection get_pins() { Collection result = new LinkedList(); Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { UndoableObjects.Storable curr_item = item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof Pin) - { + if (curr_item instanceof Pin) { result.add((Pin) curr_item); } } @@ -613,22 +567,17 @@ public Collection get_pins() /** * Returns the list of all pins on the board with only 1 layer */ - public Collection get_smd_pins() - { + public Collection get_smd_pins() { Collection result = new LinkedList(); Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { UndoableObjects.Storable curr_item = item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof Pin) - { + if (curr_item instanceof Pin) { Pin curr_pin = (Pin) curr_item; - if (curr_pin.first_layer() == curr_pin.last_layer()) - { + if (curr_pin.first_layer() == curr_pin.last_layer()) { result.add(curr_pin); } } @@ -639,19 +588,15 @@ public Collection get_smd_pins() /** * Returns the list of all vias on the board */ - public Collection get_vias() - { + public Collection get_vias() { Collection result = new LinkedList(); Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { UndoableObjects.Storable curr_item = item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof Via) - { + if (curr_item instanceof Via) { result.add((Via) curr_item); } } @@ -661,19 +606,15 @@ public Collection get_vias() /** * Returns the list of all traces on the board */ - public Collection get_traces() - { + public Collection get_traces() { Collection result = new LinkedList(); Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { UndoableObjects.Storable curr_item = item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof Trace) - { + if (curr_item instanceof Trace) { result.add((Trace) curr_item); } } @@ -683,19 +624,15 @@ public Collection get_traces() /** * Returns the cumulative length of all traces on the board */ - public double cumulative_trace_length() - { + public double cumulative_trace_length() { double result = 0; Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { UndoableObjects.Storable curr_item = item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof Trace) - { + if (curr_item instanceof Trace) { result += ((Trace) curr_item).get_length(); } } @@ -707,25 +644,19 @@ public double cumulative_trace_length() * at the connection point. * if p_net_no < 0 traces of all nets are combined. */ - public boolean combine_traces(int p_net_no) - { + public boolean combine_traces(int p_net_no) { boolean result = false; boolean something_changed = true; - while (something_changed) - { + while (something_changed) { something_changed = false; Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if ((p_net_no < 0 || curr_item.contains_net(p_net_no)) && curr_item instanceof Trace && curr_item.is_on_the_board()) - { - if (((Trace) curr_item).combine()) - { + if ((p_net_no < 0 || curr_item.contains_net(p_net_no)) && curr_item instanceof Trace && curr_item.is_on_the_board()) { + if (((Trace) curr_item).combine()) { something_changed = true; result = true; break; @@ -739,40 +670,29 @@ public boolean combine_traces(int p_net_no) /** * Normalizes the traces of this net */ - public boolean normalize_traces(int p_net_no) - { + public boolean normalize_traces(int p_net_no) { boolean result = false; boolean something_changed = true; Item curr_item = null; - while (something_changed) - { + while (something_changed) { something_changed = false; Iterator it = item_list.start_read_object(); - for (;;) - { - try - { + for (; ; ) { + try { curr_item = (Item) item_list.read_object(it); - } - catch (java.util.ConcurrentModificationException e) - { + } catch (java.util.ConcurrentModificationException e) { something_changed = true; break; } - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item.contains_net(p_net_no) && curr_item instanceof PolylineTrace && curr_item.is_on_the_board()) - { + if (curr_item.contains_net(p_net_no) && curr_item instanceof PolylineTrace && curr_item.is_on_the_board()) { PolylineTrace curr_trace = (PolylineTrace) curr_item; - if (curr_trace.normalize(null)) - { + if (curr_trace.normalize(null)) { something_changed = true; result = true; - } - else if (!curr_trace.is_user_fixed() && this.remove_if_cycle(curr_trace)) - { + } else if (!curr_trace.is_user_fixed() && this.remove_if_cycle(curr_trace)) { something_changed = true; result = true; } @@ -786,20 +706,16 @@ else if (!curr_trace.is_user_fixed() && this.remove_if_cycle(curr_trace)) * Looks for traces of the input net on the input layer, so that p_location is on the trace polygon, * and splits these traces. Returns false, if no trace was split. */ - public boolean split_traces(Point p_location, int p_layer, int p_net_no) - { + public boolean split_traces(Point p_location, int p_layer, int p_net_no) { ItemSelectionFilter filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.TRACES); Collection picked_items = this.pick_items(p_location, p_layer, filter); IntOctagon location_shape = TileShape.get_instance(p_location).bounding_octagon(); boolean trace_split = false; - for (Item curr_item : picked_items) - { + for (Item curr_item : picked_items) { Trace curr_trace = (Trace) curr_item; - if (curr_trace.contains_net(p_net_no)) - { + if (curr_trace.contains_net(p_net_no)) { Collection split_pieces = curr_trace.split(location_shape); - if (split_pieces.size() != 1) - { + if (split_pieces.size() != 1) { trace_split = true; } } @@ -810,30 +726,24 @@ public boolean split_traces(Point p_location, int p_layer, int p_net_no) /** * Returs a Collection of Collections of items forming a connected set. */ - public Collection> get_connected_sets(int p_net_no) - { + public Collection> get_connected_sets(int p_net_no) { Collection> result = new LinkedList>(); - if (p_net_no <= 0) - { + if (p_net_no <= 0) { return result; } SortedSet items_to_handle = new TreeSet(); Iterator it = this.item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof Connectable && curr_item.contains_net(p_net_no)) - { + if (curr_item instanceof Connectable && curr_item.contains_net(p_net_no)) { items_to_handle.add(curr_item); } } Iterator it2 = items_to_handle.iterator(); - while (it2.hasNext()) - { + while (it2.hasNext()) { Item curr_item = it2.next(); Collection next_connected_set = curr_item.get_connected_set(p_net_no); result.add(next_connected_set); @@ -847,8 +757,7 @@ public Collection> get_connected_sets(int p_net_no) * Returns all SearchTreeObjects on layer p_layer, which overlap with p_shape. * If p_layer < 0, the layer is ignored */ - public Set overlapping_objects(ConvexShape p_shape, int p_layer) - { + public Set overlapping_objects(ConvexShape p_shape, int p_layer) { return this.search_tree_manager.get_default_tree().overlapping_objects(p_shape, p_layer); } @@ -862,8 +771,7 @@ public Set overlapping_objects(ConvexShape p_shape, int p_laye * If p_layer < 0, the layer is ignored. */ public Set overlapping_items_with_clearance(ConvexShape p_shape, int p_layer, int[] p_ignore_net_nos, - int p_clearance_class) - { + int p_clearance_class) { ShapeSearchTree default_tree = this.search_tree_manager.get_default_tree(); return default_tree.overlapping_items_with_clearance(p_shape, p_layer, p_ignore_net_nos, p_clearance_class); } @@ -872,17 +780,13 @@ public Set overlapping_items_with_clearance(ConvexShape p_shape, int p_lay * Returns all items on layer p_layer, which overlap with p_area. * If p_layer < 0, the layer is ignored */ - public Set overlapping_items(Area p_area, int p_layer) - { + public Set overlapping_items(Area p_area, int p_layer) { Set result = new TreeSet(); TileShape[] tile_shapes = p_area.split_to_convex(); - for (int i = 0; i < tile_shapes.length; ++i) - { + for (int i = 0; i < tile_shapes.length; ++i) { Set curr_overlaps = overlapping_objects(tile_shapes[i], p_layer); - for (SearchTreeObject curr_overlap : curr_overlaps) - { - if (curr_overlap instanceof Item) - { + for (SearchTreeObject curr_overlap : curr_overlaps) { + if (curr_overlap instanceof Item) { result.add((Item) curr_overlap); } } @@ -895,32 +799,25 @@ public Set overlapping_items(Area p_area, int p_layer) * and clearance class p_cl_class can be inserted on layer p_layer * without clearance violation. */ - public boolean check_shape(Area p_shape, int p_layer, int[] p_net_no_arr, int p_cl_class) - { + public boolean check_shape(Area p_shape, int p_layer, int[] p_net_no_arr, int p_cl_class) { TileShape[] tiles = p_shape.split_to_convex(); ShapeSearchTree default_tree = this.search_tree_manager.get_default_tree(); - for (int i = 0; i < tiles.length; ++i) - { + for (int i = 0; i < tiles.length; ++i) { TileShape curr_shape = tiles[i]; - if (!curr_shape.is_contained_in(bounding_box)) - { + if (!curr_shape.is_contained_in(bounding_box)) { return false; } Set obstacles = new TreeSet(); default_tree.overlapping_objects_with_clearance(curr_shape, p_layer, p_net_no_arr, p_cl_class, obstacles); - for (SearchTreeObject curr_ob : obstacles) - { + for (SearchTreeObject curr_ob : obstacles) { boolean is_obstacle = true; - for (int j = 0; j < p_net_no_arr.length; ++j) - { - if (!curr_ob.is_obstacle(p_net_no_arr[j])) - { + for (int j = 0; j < p_net_no_arr.length; ++j) { + if (!curr_ob.is_obstacle(p_net_no_arr[j])) { is_obstacle = false; } } - if (is_obstacle) - { + if (is_obstacle) { return false; } } @@ -936,76 +833,58 @@ public boolean check_shape(Area p_shape, int p_layer, int[] p_net_no_arr, int p_ * regarded as obstacles, even if they are of the own net. */ public boolean check_trace_shape(TileShape p_shape, int p_layer, int[] p_net_no_arr, - int p_cl_class, Set p_contact_pins) - { - if (!p_shape.is_contained_in(bounding_box)) - { + int p_cl_class, Set p_contact_pins) { + if (!p_shape.is_contained_in(bounding_box)) { return false; } ShapeSearchTree default_tree = this.search_tree_manager.get_default_tree(); Collection tree_entries = new LinkedList(); int[] ignore_net_nos = new int[0]; - if (default_tree.is_clearance_compensation_used()) - { + if (default_tree.is_clearance_compensation_used()) { default_tree.overlapping_tree_entries(p_shape, p_layer, ignore_net_nos, tree_entries); - } - else - { + } else { default_tree.overlapping_tree_entries_with_clearance(p_shape, p_layer, ignore_net_nos, p_cl_class, tree_entries); } - for (TreeEntry curr_tree_entry : tree_entries) - { - if (!(curr_tree_entry.object instanceof Item)) - { + for (TreeEntry curr_tree_entry : tree_entries) { + if (!(curr_tree_entry.object instanceof Item)) { continue; } Item curr_item = (Item) curr_tree_entry.object; - if (p_contact_pins != null) - { - if (p_contact_pins.contains(curr_item)) - { + if (p_contact_pins != null) { + if (p_contact_pins.contains(curr_item)) { continue; } - if (curr_item instanceof Pin) - { + if (curr_item instanceof Pin) { // The contact pins of the trace should be contained in p_ignore_items. // Other pins are handled as obstacles to avoid acid traps. return false; } } boolean is_obstacle = true; - for (int i = 0; i < p_net_no_arr.length; ++i) - { - if (!curr_item.is_trace_obstacle(p_net_no_arr[i])) - { + for (int i = 0; i < p_net_no_arr.length; ++i) { + if (!curr_item.is_trace_obstacle(p_net_no_arr[i])) { is_obstacle = false; } } - if (is_obstacle && (curr_item instanceof PolylineTrace) && p_contact_pins != null) - { + if (is_obstacle && (curr_item instanceof PolylineTrace) && p_contact_pins != null) { // check for traces of foreign nets at tie pins, which will be ignored inside the pin shape TileShape intersection = null; - for (Pin curr_contact_pin : p_contact_pins) - { - if (curr_contact_pin.net_count() <= 1 || !curr_contact_pin.shares_net(curr_item)) - { + for (Pin curr_contact_pin : p_contact_pins) { + if (curr_contact_pin.net_count() <= 1 || !curr_contact_pin.shares_net(curr_item)) { continue; } - if (intersection == null) - { + if (intersection == null) { TileShape obstacle_trace_shape = curr_item.get_tile_shape(curr_tree_entry.shape_index_in_object); intersection = p_shape.intersection(obstacle_trace_shape); } TileShape pin_shape = curr_contact_pin.get_tile_shape_on_layer(p_layer); - if (pin_shape.contains_approx(intersection)) - { + if (pin_shape.contains_approx(intersection)) { is_obstacle = false; break; } } } - if (is_obstacle) - { + if (is_obstacle) { return false; } } @@ -1017,16 +896,13 @@ public boolean check_trace_shape(TileShape p_shape, int p_layer, int[] p_net_no_ * without clearance violations */ public boolean check_polyline_trace(Polyline p_polyline, int p_layer, int p_pen_half_width, - int[] p_net_no_arr, int p_clearance_class) - { + int[] p_net_no_arr, int p_clearance_class) { Trace tmp_trace = new PolylineTrace(p_polyline, p_layer, p_pen_half_width, p_net_no_arr, p_clearance_class, 0, 0, FixedState.UNFIXED, this); Set contact_pins = tmp_trace.touching_pins_at_end_corners(); - for (int i = 0; i < tmp_trace.tile_shape_count(); ++i) - { + for (int i = 0; i < tmp_trace.tile_shape_count(); ++i) { if (!this.check_trace_shape(tmp_trace.get_tile_shape(i), p_layer, p_net_no_arr, - p_clearance_class, contact_pins)) - { + p_clearance_class, contact_pins)) { return false; } } @@ -1036,8 +912,7 @@ public boolean check_polyline_trace(Polyline p_polyline, int p_layer, int p_pen_ /** * Returns the layer count of this board. */ - public int get_layer_count() - { + public int get_layer_count() { return layer_structure.arr.length; } @@ -1046,33 +921,24 @@ public int get_layer_count() * paintComponent method of a class derived from JPanel. * The value of p_layer_visibility is expected between 0 and 1 for each layer. */ - public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) - { - if (p_graphics_context == null) - { + public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) { + if (p_graphics_context == null) { return; } // draw all items on the board - for (int curr_priority = Drawable.MIN_DRAW_PRIORITY; curr_priority <= Drawable.MIDDLE_DRAW_PRIORITY; ++curr_priority) - { + for (int curr_priority = Drawable.MIN_DRAW_PRIORITY; curr_priority <= Drawable.MIDDLE_DRAW_PRIORITY; ++curr_priority) { Iterator it = item_list.start_read_object(); - for (;;) - { - try - { + for (; ; ) { + try { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item.get_draw_priority() == curr_priority) - { + if (curr_item.get_draw_priority() == curr_priority) { curr_item.draw(p_graphics, p_graphics_context); } - } - catch (java.util.ConcurrentModificationException e) - { + } catch (java.util.ConcurrentModificationException e) { // may happen when window are changed interactively while running a logfile return; } @@ -1085,20 +951,16 @@ public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) * If p_layer < 0, the layer is ignored. * If p_item_selection_filter != null, only items of types selected by the filter are picked. */ - public Set pick_items(Point p_location, int p_layer, ItemSelectionFilter p_filter) - { + public Set pick_items(Point p_location, int p_layer, ItemSelectionFilter p_filter) { TileShape point_shape = TileShape.get_instance(p_location); Collection overlaps = overlapping_objects(point_shape, p_layer); Set result = new TreeSet(); - for (SearchTreeObject curr_object : overlaps) - { - if (curr_object instanceof Item) - { + for (SearchTreeObject curr_object : overlaps) { + if (curr_object instanceof Item) { result.add((Item) curr_object); } } - if (p_filter != null) - { + if (p_filter != null) { result = p_filter.filter(result); } return result; @@ -1107,8 +969,7 @@ public Set pick_items(Point p_location, int p_layer, ItemSelectionFilter p /** * checks, if p_point is contained in the bounding box of this board. */ - public boolean contains(Point p_point) - { + public boolean contains(Point p_point) { return p_point.is_contained_in(bounding_box); } @@ -1117,10 +978,8 @@ public boolean contains(Point p_point) * clearance class p_class_1 and p_class_2. * p_class_1 and p_class_2 are indices in the clearance matrix. */ - public int clearance_value(int p_class_1, int p_class_2, int p_layer) - { - if (rules == null || rules.clearance_matrix == null) - { + public int clearance_value(int p_class_1, int p_class_2, int p_layer) { + if (rules == null || rules.clearance_matrix == null) { return 0; } return rules.clearance_matrix.value(p_class_1, p_class_2, p_layer); @@ -1129,35 +988,30 @@ public int clearance_value(int p_class_1, int p_class_2, int p_layer) /** * returns the biggest half width of all traces on the board. */ - public int get_max_trace_half_width() - { + public int get_max_trace_half_width() { return max_trace_half_width; } /** * returns the smallest half width of all traces on the board. */ - public int get_min_trace_half_width() - { + public int get_min_trace_half_width() { return min_trace_half_width; } /** * Returns a surrounding box of the geometry of this board */ - public IntBox get_bounding_box() - { + public IntBox get_bounding_box() { return bounding_box; } /** * Returns a box containing all items in p_item_list. */ - public IntBox get_bounding_box(Collection p_item_list) - { + public IntBox get_bounding_box(Collection p_item_list) { IntBox result = IntBox.EMPTY; - for (Item curr_item : p_item_list) - { + for (Item curr_item : p_item_list) { result = result.union(curr_item.bounding_box()); } return result; @@ -1166,26 +1020,22 @@ public IntBox get_bounding_box(Collection p_item_list) /** * Resets the rectangle, where a graphics update is needed. */ - public void reset_graphics_update_box() - { + public void reset_graphics_update_box() { update_box = IntBox.EMPTY; } /** * Gets the rectancle, where a graphics update is needed on the screen. */ - public IntBox get_graphics_update_box() - { + public IntBox get_graphics_update_box() { return update_box; } /** * enlarges the graphics update box, so that it contains p_box */ - public void join_graphics_update_box(IntBox p_box) - { - if (update_box == null) - { + public void join_graphics_update_box(IntBox p_box) { + if (update_box == null) { reset_graphics_update_box(); } update_box = update_box.union(p_box); @@ -1194,10 +1044,8 @@ public void join_graphics_update_box(IntBox p_box) /** * starts notifying the observers of any change in the objects list */ - public void start_notify_observers() - { - if (this.communication.observers != null) - { + public void start_notify_observers() { + if (this.communication.observers != null) { communication.observers.activate(); } } @@ -1205,10 +1053,8 @@ public void start_notify_observers() /** * ends notifying the observers of changes in the objects list */ - public void end_notify_observers() - { - if (this.communication.observers != null) - { + public void end_notify_observers() { + if (this.communication.observers != null) { communication.observers.deactivate(); } } @@ -1216,15 +1062,11 @@ public void end_notify_observers() /** * Returns, if the observer of the board items is activated. */ - public boolean observers_active() - { + public boolean observers_active() { boolean result; - if (this.communication.observers != null) - { + if (this.communication.observers != null) { result = communication.observers.is_active(); - } - else - { + } else { result = false; } return result; @@ -1235,8 +1077,7 @@ public boolean observers_active() * If it is convex and has no holes, it is turned into a Pin, * alse into a conduction area. */ - public Connectable make_conductive(ObstacleArea p_area, int p_net_no) - { + public Connectable make_conductive(ObstacleArea p_area, int p_net_no) { Item new_item; Area curr_area = p_area.get_relative_area(); int layer = p_area.get_layer(); @@ -1256,16 +1097,13 @@ public Connectable make_conductive(ObstacleArea p_area, int p_net_no) /** * Inserts an item into the board data base */ - public void insert_item(Item p_item) - { - if (p_item == null) - { + public void insert_item(Item p_item) { + if (p_item == null) { return; } if (rules == null || rules.clearance_matrix == null || p_item.clearance_class_no() < 0 || - p_item.clearance_class_no() >= rules.clearance_matrix.get_class_count()) - { + p_item.clearance_class_no() >= rules.clearance_matrix.get_class_count()) { System.out.println("LayeredBoard.insert_item: clearance_class no out of range"); p_item.set_clearance_class_no(0); } @@ -1279,8 +1117,7 @@ public void insert_item(Item p_item) /** * Stub function overwritten in class RoutingBoard to maintain the autorouter database if necessesary. */ - public void additional_update_after_change(Item p_item) - { + public void additional_update_after_change(Item p_item) { } /** @@ -1288,42 +1125,35 @@ public void additional_update_after_change(Item p_item) * Returns false, if no more undo is possible. * Puts the numbers of the changed nets into the set p_changed_nets, if p_changed_nets != null */ - public boolean undo(Set p_changed_nets) - { + public boolean undo(Set p_changed_nets) { this.components.undo(this.communication.observers); Collection cancelled_objects = new LinkedList(); Collection restored_objects = new LinkedList(); boolean result = item_list.undo(cancelled_objects, restored_objects); // update the search trees Iterator it = cancelled_objects.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = (Item) it.next(); search_tree_manager.remove(curr_item); // let the observers syncronize the deletion communication.observers.notify_deleted(curr_item); - if (p_changed_nets != null) - { - for (int i = 0; i < curr_item.net_count(); ++i) - { + if (p_changed_nets != null) { + for (int i = 0; i < curr_item.net_count(); ++i) { p_changed_nets.add(new Integer(curr_item.get_net_no(i))); } } } it = restored_objects.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = (Item) it.next(); curr_item.board = this; search_tree_manager.insert(curr_item); curr_item.clear_autoroute_info(); // let the observers know the insertion communication.observers.notify_new(curr_item); - if (p_changed_nets != null) - { - for (int i = 0; i < curr_item.net_count(); ++i) - { + if (p_changed_nets != null) { + for (int i = 0; i < curr_item.net_count(); ++i) { p_changed_nets.add(new Integer(curr_item.get_net_no(i))); } } @@ -1336,41 +1166,34 @@ public boolean undo(Set p_changed_nets) * Returns false, if no more redo is possible. * Puts the numbers of the changed nets into the set p_changed_nets, if p_changed_nets != null */ - public boolean redo(Set p_changed_nets) - { + public boolean redo(Set p_changed_nets) { this.components.redo(this.communication.observers); Collection cancelled_objects = new LinkedList(); Collection restored_objects = new LinkedList(); boolean result = item_list.redo(cancelled_objects, restored_objects); // update the search trees Iterator it = cancelled_objects.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = (Item) it.next(); search_tree_manager.remove(curr_item); // let the observers syncronize the deletion communication.observers.notify_deleted(curr_item); - if (p_changed_nets != null) - { - for (int i = 0; i < curr_item.net_count(); ++i) - { + if (p_changed_nets != null) { + for (int i = 0; i < curr_item.net_count(); ++i) { p_changed_nets.add(curr_item.get_net_no(i)); } } } it = restored_objects.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = (Item) it.next(); curr_item.board = this; search_tree_manager.insert(curr_item); curr_item.clear_autoroute_info(); // let the observers know the insertion communication.observers.notify_new(curr_item); - if (p_changed_nets != null) - { - for (int i = 0; i < curr_item.net_count(); ++i) - { + if (p_changed_nets != null) { + for (int i = 0; i < curr_item.net_count(); ++i) { p_changed_nets.add(curr_item.get_net_no(i)); } } @@ -1381,19 +1204,17 @@ public boolean redo(Set p_changed_nets) /** * Makes the current board situation restorable by undo. */ - public void generate_snapshot() - { + public void generate_snapshot() { item_list.generate_snapshot(); components.generate_snapshot(); } /** - * Removes the top snapshot from the undo stack, so that its situation cannot be - * restored any more. - * Returns false, if no more snapshot could be popped. + * Removes the top snapshot from the undo stack, so that its situation cannot be + * restored any more. + * Returns false, if no more snapshot could be popped. */ - public boolean pop_snapshot() - { + public boolean pop_snapshot() { return item_list.pop_snapshot(); } @@ -1402,34 +1223,26 @@ public boolean pop_snapshot() * which has no normal contact at that position. * Returns null, if no tail is found. */ - public Trace get_trace_tail(Point p_location, int p_layer, int[] p_net_no_arr) - { + public Trace get_trace_tail(Point p_location, int p_layer, int[] p_net_no_arr) { TileShape point_shape = TileShape.get_instance(p_location); Collection found_items = overlapping_objects(point_shape, p_layer); Iterator it = found_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { SearchTreeObject curr_ob = it.next(); - if (curr_ob instanceof Trace) - { + if (curr_ob instanceof Trace) { Trace curr_trace = (Trace) curr_ob; - if (!curr_trace.nets_equal(p_net_no_arr)) - { + if (!curr_trace.nets_equal(p_net_no_arr)) { continue; } - if (curr_trace.first_corner().equals(p_location)) - { + if (curr_trace.first_corner().equals(p_location)) { Collection contacts = curr_trace.get_start_contacts(); - if (contacts.size() == 0) - { + if (contacts.size() == 0) { return curr_trace; } } - if (curr_trace.last_corner().equals(p_location)) - { + if (curr_trace.last_corner().equals(p_location)) { Collection contacts = curr_trace.get_end_contacts(); - if (contacts.size() == 0) - { + if (contacts.size() == 0) { return curr_trace; } } @@ -1442,14 +1255,11 @@ public Trace get_trace_tail(Point p_location, int p_layer, int[] p_net_no_arr) * Checks, if p_item item is part of a cycle and remuve it * together with its connection in this case. */ - public boolean remove_if_cycle(Trace p_trace) - { - if (!p_trace.is_on_the_board()) - { + public boolean remove_if_cycle(Trace p_trace) { + if (!p_trace.is_on_the_board()) { return false; } - if (!p_trace.is_cycle()) - { + if (!p_trace.is_cycle()) { return false; } // Remove tails at the endpoints after removing the cycle, @@ -1462,21 +1272,17 @@ public boolean remove_if_cycle(Trace p_trace) end_corners[0] = p_trace.first_corner(); end_corners[1] = p_trace.last_corner(); tail_at_endpoint_before = new boolean[2]; - for (int i = 0; i < 2; ++i) - { + for (int i = 0; i < 2; ++i) { Trace tail = get_trace_tail(end_corners[i], curr_layer, curr_net_no_arr); tail_at_endpoint_before[i] = (tail != null); } Set connection_items = p_trace.get_connection_items(); this.remove_items(connection_items, false); - for (int i = 0; i < 2; ++i) - { - if (!tail_at_endpoint_before[i]) - { + for (int i = 0; i < 2; ++i) { + if (!tail_at_endpoint_before[i]) { Trace tail = get_trace_tail(end_corners[i], curr_layer, curr_net_no_arr); - if (tail != null) - { + if (tail != null) { remove_items(tail.get_connection_items(), false); } } @@ -1488,80 +1294,29 @@ public boolean remove_if_cycle(Trace p_trace) * If != RELEASE_VERSION,, some features may be used, which are still in experimental state. * Also warnings for debugging may be printed depending on the test_level. */ - public TestLevel get_test_level() - { + public TestLevel get_test_level() { return this.test_level; } /** * Only to be used in BoardHandling.read_design. */ - public void set_test_level(TestLevel p_value) - { + public void set_test_level(TestLevel p_value) { this.test_level = p_value; } private void readObject(java.io.ObjectInputStream p_stream) - throws java.io.IOException, java.lang.ClassNotFoundException - { + throws java.io.IOException, java.lang.ClassNotFoundException { p_stream.defaultReadObject(); // insert the items on the board into the search trees search_tree_manager = new SearchTreeManager(this); Iterator it = this.get_items().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); curr_item.board = this; search_tree_manager.insert(curr_item); } } - /** - * List of items inserted into this board - */ - public final UndoableObjects item_list; - /** List of placed components on the board. */ - public final Components components; - /** - * Class defining the rules for items to be inserted into this board. - * Contains for example the clearance matrix. - */ - public final BoardRules rules; - /** - * The library containing pastack masks, packagages and other - * templates used on the board. - */ - public final BoardLibrary library; - /** - * The layer structure of this board. - */ - public final LayerStructure layer_structure; - /** - * Handels the search trees pointing into the items of this board - */ - public transient SearchTreeManager search_tree_manager; - /** - * For communication with a host system or host design file formats. - */ - public final Communication communication; - /** - * bounding orthogonal rectangle of this board - */ - public final IntBox bounding_box; - /** - * If test_level != RELEASE_VERSION, some features may be used, which are still in experimental state. - * Also warnings for debugging may be printed depending on the size of test_level. - */ - transient private TestLevel test_level; - /** the rectangle, where the graphics may be not uptodate */ - transient private IntBox update_box = IntBox.EMPTY; - /** - * the biggest half width of all traces on the board - */ - private int max_trace_half_width = 1000; - /** - * the smallest half width of all traces on the board - */ - private int min_trace_half_width = 10000; /** * Limits the maximum width of a shape in the search tree. */ diff --git a/src/main/java/net/freerouting/board/BoardObserverAdaptor.java b/src/main/java/net/freerouting/board/BoardObserverAdaptor.java index 93a503ce..a6ae87e0 100644 --- a/src/main/java/net/freerouting/board/BoardObserverAdaptor.java +++ b/src/main/java/net/freerouting/board/BoardObserverAdaptor.java @@ -26,64 +26,56 @@ * * @author Alfons Wirtz */ -public class BoardObserverAdaptor implements BoardObservers -{ +public class BoardObserverAdaptor implements BoardObservers { + private boolean active = false; + /** * Tell the observers the deletion p_object. */ - public void notify_deleted(Item p_item) - { - + public void notify_deleted(Item p_item) { + } - + /** * Notify the observers, that they can syncronize the changes on p_object. */ - public void notify_changed(Item p_item) - { - + public void notify_changed(Item p_item) { + } - + /** * Enable the observers to syncronize the new created item. */ - public void notify_new(Item p_item) - { - + public void notify_new(Item p_item) { + } - + /** * Enable the observers to syncronize the moved component. */ - public void notify_moved(Component p_component) - { - + public void notify_moved(Component p_component) { + } - + /** * activate the observers */ - public void activate() - { + public void activate() { active = true; } - + /** * Deactivate the observers. **/ - public void deactivate() - { + public void deactivate() { active = false; } - + /** * Returns, if the observer is activated. */ - public boolean is_active() - { + public boolean is_active() { return active; } - - private boolean active = false; - + } diff --git a/src/main/java/net/freerouting/board/BoardObservers.java b/src/main/java/net/freerouting/board/BoardObservers.java index 2c454da1..e2bc4b32 100644 --- a/src/main/java/net/freerouting/board/BoardObservers.java +++ b/src/main/java/net/freerouting/board/BoardObservers.java @@ -24,11 +24,9 @@ import net.freerouting.datastructures.Observers; /** - * * @author alfons */ -public interface BoardObservers extends Observers -{ +public interface BoardObservers extends Observers { /** * Enable the observers to syncronize the moved component. */ diff --git a/src/main/java/net/freerouting/board/BoardOutline.java b/src/main/java/net/freerouting/board/BoardOutline.java index a81d3703..382944ab 100644 --- a/src/main/java/net/freerouting/board/BoardOutline.java +++ b/src/main/java/net/freerouting/board/BoardOutline.java @@ -19,198 +19,167 @@ */ package net.freerouting.board; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.PolylineShape; -import net.freerouting.geometry.planar.PolylineArea; -import net.freerouting.geometry.planar.Area; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.FloatPoint; - import net.freerouting.boardgraphics.GraphicsContext; +import net.freerouting.geometry.planar.*; /** * Class describing a board outline. * - * @author alfons + * @author alfons */ -public class BoardOutline extends Item implements java.io.Serializable -{ +public class BoardOutline extends Item implements java.io.Serializable { + + private static final int HALF_WIDTH = 100; + /** + * The board shapes inside the outline curves. + */ + private PolylineShape[] shapes; + /** + * The board shape outside the outline curves, where a keepout will be generated + * The outline curves are holes of the keepout_area. + */ + private Area keepout_area = null; + /** + * Used instead of keepout_area if only the line shapes of the outlines are inserted as keepout. + */ + private TileShape[] keepout_lines = null; + private boolean keepout_outside_outline = false; - /** Creates a new instance of BoardOutline */ - public BoardOutline(PolylineShape[] p_shapes, int p_clearance_class_no, int p_id_no, BasicBoard p_board) - { + /** + * Creates a new instance of BoardOutline + */ + public BoardOutline(PolylineShape[] p_shapes, int p_clearance_class_no, int p_id_no, BasicBoard p_board) { super(new int[0], p_clearance_class_no, p_id_no, 0, FixedState.SYSTEM_FIXED, p_board); shapes = p_shapes; } - public int tile_shape_count() - { + public int tile_shape_count() { int result; - if (this.keepout_outside_outline) - { + if (this.keepout_outside_outline) { TileShape[] tile_shapes = this.get_keepout_area().split_to_convex(); - if (tile_shapes == null) - { + if (tile_shapes == null) { // an error accured while dividing the area result = 0; - } - else - { + } else { result = tile_shapes.length * this.board.layer_structure.arr.length; } - } - else - { + } else { result = this.line_count() * this.board.layer_structure.arr.length; } return result; } - public int shape_layer(int p_index) - { + public int shape_layer(int p_index) { int shape_count = this.tile_shape_count(); int result; - if (shape_count > 0) - { + if (shape_count > 0) { result = p_index * this.board.layer_structure.arr.length / shape_count; - } - else - { + } else { result = 0; } - if (result < 0 || result >= this.board.layer_structure.arr.length) - { + if (result < 0 || result >= this.board.layer_structure.arr.length) { System.out.println("BoardOutline.shape_layer: p_index out of range"); } return result; } - public boolean is_obstacle(Item p_other) - { + public boolean is_obstacle(Item p_other) { return !(p_other instanceof BoardOutline || p_other instanceof ObstacleArea); } - public IntBox bounding_box() - { + public IntBox bounding_box() { IntBox result = IntBox.EMPTY; - for (PolylineShape curr_shape : this.shapes) - { + for (PolylineShape curr_shape : this.shapes) { result = result.union(curr_shape.bounding_box()); } return result; } - public int first_layer() - { + public int first_layer() { return 0; } - public int last_layer() - { + public int last_layer() { return this.board.layer_structure.arr.length - 1; } - public boolean is_on_layer(int p_layer) - { + public boolean is_on_layer(int p_layer) { return true; } - public void translate_by(Vector p_vector) - { - for (PolylineShape curr_shape : this.shapes) - { + public void translate_by(Vector p_vector) { + for (PolylineShape curr_shape : this.shapes) { curr_shape = curr_shape.translate_by(p_vector); } - if (keepout_area != null) - { + if (keepout_area != null) { keepout_area = keepout_area.translate_by(p_vector); } keepout_lines = null; } - public void turn_90_degree(int p_factor, IntPoint p_pole) - { - for (PolylineShape curr_shape : this.shapes) - { + public void turn_90_degree(int p_factor, IntPoint p_pole) { + for (PolylineShape curr_shape : this.shapes) { curr_shape = curr_shape.turn_90_degree(p_factor, p_pole); } - if (keepout_area != null) - { + if (keepout_area != null) { keepout_area = keepout_area.turn_90_degree(p_factor, p_pole); } keepout_lines = null; } - public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) - { + public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) { double angle = Math.toRadians(p_angle_in_degree); - for (PolylineShape curr_shape : this.shapes) - { + for (PolylineShape curr_shape : this.shapes) { curr_shape = curr_shape.rotate_approx(angle, p_pole); } - if (keepout_area != null) - { + if (keepout_area != null) { keepout_area = keepout_area.rotate_approx(angle, p_pole); } keepout_lines = null; } - public void change_placement_side(IntPoint p_pole) - { - for (PolylineShape curr_shape : this.shapes) - { + public void change_placement_side(IntPoint p_pole) { + for (PolylineShape curr_shape : this.shapes) { curr_shape = curr_shape.mirror_vertical(p_pole); } - if (keepout_area != null) - { + if (keepout_area != null) { keepout_area = keepout_area.mirror_vertical(p_pole); } keepout_lines = null; } - public double get_draw_intensity(GraphicsContext p_graphics_context) - { + public double get_draw_intensity(GraphicsContext p_graphics_context) { return 1; } - public int get_draw_priority() - { + public int get_draw_priority() { return net.freerouting.boardgraphics.Drawable.MAX_DRAW_PRIORITY; } - public int shape_count() - { + public int shape_count() { return this.shapes.length; } - public PolylineShape get_shape(int p_index) - { - if (p_index < 0 || p_index >= this.shapes.length) - { + public PolylineShape get_shape(int p_index) { + if (p_index < 0 || p_index >= this.shapes.length) { System.out.println("BoardOutline.get_shape: p_index out of range"); return null; } return this.shapes[p_index]; } - public boolean is_selected_by_filter(ItemSelectionFilter p_filter) - { - if (!this.is_selected_by_fixed_filter(p_filter)) - { + public boolean is_selected_by_filter(ItemSelectionFilter p_filter) { + if (!this.is_selected_by_fixed_filter(p_filter)) { return false; } return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.BOARD_OUTLINE); } - public java.awt.Color[] get_draw_colors(GraphicsContext p_graphics_context) - { + public java.awt.Color[] get_draw_colors(GraphicsContext p_graphics_context) { java.awt.Color[] color_arr = new java.awt.Color[this.board.layer_structure.arr.length]; java.awt.Color draw_color = p_graphics_context.get_outline_color(); - for (int i = 0; i < color_arr.length; ++i) - { + for (int i = 0; i < color_arr.length; ++i) { color_arr[i] = draw_color; } return color_arr; @@ -220,13 +189,10 @@ public java.awt.Color[] get_draw_colors(GraphicsContext p_graphics_context) * The board shape outside the outline curves, where a keepout will be generated * The outline curves are holes of the keepout_area. */ - Area get_keepout_area() - { - if (this.keepout_area == null) - { + Area get_keepout_area() { + if (this.keepout_area == null) { PolylineShape[] hole_arr = new PolylineShape[this.shapes.length]; - for (int i = 0; i < hole_arr.length; ++i) - { + for (int i = 0; i < hole_arr.length; ++i) { hole_arr[i] = this.shapes[i]; } keepout_area = new PolylineArea(this.board.bounding_box, hole_arr); @@ -234,23 +200,18 @@ Area get_keepout_area() return this.keepout_area; } - TileShape[] get_keepout_lines() - { - if (this.keepout_lines == null) - { + TileShape[] get_keepout_lines() { + if (this.keepout_lines == null) { this.keepout_lines = new TileShape[0]; } return this.keepout_lines; } - public void draw(java.awt.Graphics p_g, GraphicsContext p_graphics_context, java.awt.Color[] p_color_arr, double p_intensity) - { - if (p_graphics_context == null || p_intensity <= 0) - { + public void draw(java.awt.Graphics p_g, GraphicsContext p_graphics_context, java.awt.Color[] p_color_arr, double p_intensity) { + if (p_graphics_context == null || p_intensity <= 0) { return; } - for (PolylineShape curr_shape : this.shapes) - { + for (PolylineShape curr_shape : this.shapes) { FloatPoint[] draw_corners = curr_shape.corner_approx_arr(); FloatPoint[] closed_draw_corners = new FloatPoint[draw_corners.length + 1]; System.arraycopy(draw_corners, 0, closed_draw_corners, 0, draw_corners.length); @@ -259,13 +220,11 @@ public void draw(java.awt.Graphics p_g, GraphicsContext p_graphics_context, java } } - public Item copy(int p_id_no) - { + public Item copy(int p_id_no) { return new BoardOutline(this.shapes, this.clearance_class_no(), p_id_no, this.board); } - public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { + public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("board_outline")); @@ -273,40 +232,33 @@ public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) p_window.newline(); } - public boolean write(java.io.ObjectOutputStream p_stream) - { - try - { + public boolean write(java.io.ObjectOutputStream p_stream) { + try { p_stream.writeObject(this); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { return false; } return true; } /** - * Returns, if keepout is generated outside the board outline. - * Otherwise only the line shapes of the outlines are inserted as keepout. + * Returns, if keepout is generated outside the board outline. + * Otherwise only the line shapes of the outlines are inserted as keepout. */ - public boolean keepout_outside_outline_generated() - { + public boolean keepout_outside_outline_generated() { return keepout_outside_outline; } /** - * Makes the area outside this Outline to Keepout, if p_valus = true. - * Reinserts this Outline into the search trees, if the value changes. + * Makes the area outside this Outline to Keepout, if p_valus = true. + * Reinserts this Outline into the search trees, if the value changes. */ - public void generate_keepout_outside(boolean p_value) - { - if (p_value == keepout_outside_outline) - { + public void generate_keepout_outside(boolean p_value) { + if (p_value == keepout_outside_outline) { return; } keepout_outside_outline = p_value; - if (this.board == null || this.board.search_tree_manager == null) - { + if (this.board == null || this.board.search_tree_manager == null) { return; } this.board.search_tree_manager.remove(this); @@ -317,39 +269,22 @@ public void generate_keepout_outside(boolean p_value) /** * Returns the sum of the lines of all outline poligons. */ - public int line_count() - { + public int line_count() { int result = 0; - for (PolylineShape curr_shape : this.shapes) - { + for (PolylineShape curr_shape : this.shapes) { result += curr_shape.border_line_count(); } return result; } /** - * Returns the half width of the lines of this outline. + * Returns the half width of the lines of this outline. */ - public int get_half_width() - { + public int get_half_width() { return HALF_WIDTH; } - protected TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) - { + protected TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) { return p_search_tree.calculate_tree_shapes(this); } - /** The board shapes inside the outline curves. */ - private PolylineShape[] shapes; - /** - * The board shape outside the outline curves, where a keepout will be generated - * The outline curves are holes of the keepout_area. - */ - private Area keepout_area = null; - /** - * Used instead of keepout_area if only the line shapes of the outlines are inserted as keepout. - */ - private TileShape[] keepout_lines = null; - private boolean keepout_outside_outline = false; - private static final int HALF_WIDTH = 100; } diff --git a/src/main/java/net/freerouting/board/CalcFromSide.java b/src/main/java/net/freerouting/board/CalcFromSide.java index a60f7e78..72b3f480 100644 --- a/src/main/java/net/freerouting/board/CalcFromSide.java +++ b/src/main/java/net/freerouting/board/CalcFromSide.java @@ -20,47 +20,37 @@ package net.freerouting.board; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.LineSegment; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Side; +import net.freerouting.geometry.planar.*; /** - * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class CalcFromSide -{ +public class CalcFromSide { public static final CalcFromSide NOT_CALCULATED = new CalcFromSide(-1, null); - + final int no; + final FloatPoint border_intersection; + /** * calculates the number of the edge line of p_shape where p_polyline * enters. Used in the push trace algorithm to determine the shove direction. * p_no is expected between 1 and p_polyline.line_count - 2 inclusive. */ - CalcFromSide(Polyline p_polyline, int p_no, TileShape p_shape ) - { + CalcFromSide(Polyline p_polyline, int p_no, TileShape p_shape) { int fromside_no = -1; FloatPoint intersection = null; boolean border_intersection_found = false; // calculate the edge_no of p_shape, where p_polyline enters - for (int curr_no = p_no; curr_no > 0; --curr_no) - { + for (int curr_no = p_no; curr_no > 0; --curr_no) { LineSegment curr_seg = new LineSegment(p_polyline, curr_no); - int [] intersections = curr_seg.border_intersections(p_shape); - if (intersections.length > 0) - { + int[] intersections = curr_seg.border_intersections(p_shape); + if (intersections.length > 0) { fromside_no = intersections[0]; intersection = curr_seg.get_line().intersection_approx(p_shape.border_line(fromside_no)); border_intersection_found = true; break; } } - if (!border_intersection_found) - { + if (!border_intersection_found) { // The first corner of p_polyline is inside p_shape. // Calculate the nearest intersection point of p_polyline.arr[1] // with the border of p_shape to the first corner of p_polyline @@ -68,14 +58,12 @@ public class CalcFromSide Line check_line = p_polyline.arr[1]; double min_dist = Double.MAX_VALUE; int edge_count = p_shape.border_line_count(); - for (int i = 0; i < edge_count; ++i) - { + for (int i = 0; i < edge_count; ++i) { Line curr_line = p_shape.border_line(i); FloatPoint curr_intersection = check_line.intersection_approx(curr_line); double curr_dist = Math.abs(curr_intersection.distance(from_point)); - if (curr_dist < min_dist) - { + if (curr_dist < min_dist) { fromside_no = i; intersection = curr_intersection; min_dist = curr_dist; @@ -85,28 +73,26 @@ public class CalcFromSide this.no = fromside_no; this.border_intersection = intersection; } - + + /** * Calculates the nearest border side of p_shape to p_from_point. * Used in the shove_drill_item algorithm to determine the shove direction. */ - CalcFromSide(Point p_from_point, TileShape p_shape) - { + CalcFromSide(Point p_from_point, TileShape p_shape) { Point border_projection = p_shape.nearest_border_point(p_from_point); this.no = p_shape.contains_on_border_line_no(border_projection); - if (this.no < 0) - { + if (this.no < 0) { System.out.println("CalcFromSide: this.no >= 0 expected"); } this.border_intersection = border_projection.to_float(); } - + /** * Calculates the Side of p_shape at the start of p_line_segment. * If p_shove_to_the_left, the from_side_no is decremented by 2, else it is increased by 2. */ - CalcFromSide(LineSegment p_line_segment, TileShape p_shape, boolean p_shove_to_the_left) - { + CalcFromSide(LineSegment p_line_segment, TileShape p_shape, boolean p_shove_to_the_left) { FloatPoint start_corner = p_line_segment.start_point_approx(); FloatPoint end_corner = p_line_segment.end_point_approx(); int border_line_count = p_shape.border_line_count(); @@ -114,62 +100,45 @@ public class CalcFromSide FloatPoint first_corner = p_shape.corner_approx(0); Side prev_side = check_line.side_of(first_corner); int front_side_no = -1; - - for (int i = 1; i <= border_line_count; ++i) - { + + for (int i = 1; i <= border_line_count; ++i) { FloatPoint next_corner; - if (i == border_line_count) - { + if (i == border_line_count) { next_corner = first_corner; - } - else - { + } else { next_corner = p_shape.corner_approx(i); } Side next_side = check_line.side_of(next_corner); - if (prev_side != next_side) - { + if (prev_side != next_side) { FloatPoint curr_intersection = p_shape.border_line(i - 1).intersection_approx(check_line); - if (curr_intersection.distance_square(start_corner) < curr_intersection.distance_square(end_corner)) - { + if (curr_intersection.distance_square(start_corner) < curr_intersection.distance_square(end_corner)) { front_side_no = i - 1; break; } } prev_side = next_side; } - if (front_side_no < 0) - { + if (front_side_no < 0) { System.out.println("CalcFromSide: start corner not found"); no = -1; border_intersection = null; return; } - if (p_shove_to_the_left) - { + if (p_shove_to_the_left) { this.no = (front_side_no + 2) % border_line_count; - - } - else - { + + } else { this.no = (front_side_no + border_line_count - 2) % border_line_count; } FloatPoint prev_corner = p_shape.corner_approx(this.no); FloatPoint next_corner = p_shape.corner_approx((this.no + 1) % border_line_count); this.border_intersection = prev_corner.middle_point(next_corner); } - - - /** * Values already calculated. Just create an instance from them. */ - CalcFromSide(int p_no, FloatPoint p_border_intersection) - { + CalcFromSide(int p_no, FloatPoint p_border_intersection) { no = p_no; border_intersection = p_border_intersection; } - - final int no; - final FloatPoint border_intersection; } diff --git a/src/main/java/net/freerouting/board/CalcShapeAndFromSide.java b/src/main/java/net/freerouting/board/CalcShapeAndFromSide.java index 37a8e92c..e9a3b711 100644 --- a/src/main/java/net/freerouting/board/CalcShapeAndFromSide.java +++ b/src/main/java/net/freerouting/board/CalcShapeAndFromSide.java @@ -18,143 +18,115 @@ package net.freerouting.board; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.Side; -import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.*; /** * Used in the shove algorithm to calculate the fromside for pushing and * to cut off dog ears of the trace shape. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -class CalcShapeAndFromSide -{ +class CalcShapeAndFromSide { + final TileShape shape; + final CalcFromSide from_side; + /** * Used in the shove algorithm to calculate the fromside for pushing and * to cut off dog ears of the trace shape. * In the check shove functions, p_in_shove_check is expected to be true. * In the actual shove functions p_in_shove_check is expected to be false. */ - CalcShapeAndFromSide(PolylineTrace p_trace, int p_index, boolean p_orthogonal, boolean p_in_shove_check) - { + CalcShapeAndFromSide(PolylineTrace p_trace, int p_index, boolean p_orthogonal, boolean p_in_shove_check) { ShapeSearchTree search_tree = p_trace.board.search_tree_manager.get_default_tree(); TileShape curr_shape = p_trace.get_tree_shape(search_tree, p_index); CalcFromSide curr_from_side = null; boolean cut_off_at_start = false; boolean cut_off_at_end = false; - if (p_orthogonal) - { + if (p_orthogonal) { curr_shape = curr_shape.bounding_box(); - } - else - { + } else { // prevent dog ears at the start and the end of the substitute trace curr_shape = curr_shape.to_Simplex(); Line end_cutline = calc_cutline_at_end(p_index, p_trace); - if (end_cutline != null) - { + if (end_cutline != null) { TileShape cut_plane = TileShape.get_instance(end_cutline); TileShape tmp_shape = curr_shape.intersection(cut_plane); - if (tmp_shape != curr_shape && !tmp_shape.is_empty()) - { + if (tmp_shape != curr_shape && !tmp_shape.is_empty()) { curr_shape = tmp_shape.to_Simplex(); cut_off_at_end = true; } } Line start_cutline = calc_cutline_at_start(p_index, p_trace); - if (start_cutline != null) - { + if (start_cutline != null) { TileShape cut_plane = TileShape.get_instance(start_cutline); TileShape tmp_shape = curr_shape.intersection(cut_plane); - if (tmp_shape != curr_shape && !tmp_shape.is_empty()) - { + if (tmp_shape != curr_shape && !tmp_shape.is_empty()) { curr_shape = tmp_shape.to_Simplex(); cut_off_at_start = true; - + } } int from_side_no = -1; Line curr_cut_line = null; - if (cut_off_at_start == true) - { + if (cut_off_at_start == true) { curr_cut_line = start_cutline; from_side_no = curr_shape.border_line_index(curr_cut_line); } - if (from_side_no < 0 && cut_off_at_end == true) - { + if (from_side_no < 0 && cut_off_at_end == true) { curr_cut_line = end_cutline; from_side_no = curr_shape.border_line_index(curr_cut_line); } - if (from_side_no >= 0) - { + if (from_side_no >= 0) { FloatPoint border_intersection = curr_cut_line.intersection_approx(curr_shape.border_line(from_side_no)); - curr_from_side = new CalcFromSide(from_side_no, border_intersection); + curr_from_side = new CalcFromSide(from_side_no, border_intersection); } } - if (curr_from_side == null && !p_in_shove_check ) - { - // In p_in_shove_check, using this calculation may produce an undesired stack_level > 1 in ShapeTraceEntries. - curr_from_side = new CalcFromSide(p_trace.polyline(), p_index, curr_shape); + if (curr_from_side == null && !p_in_shove_check) { + // In p_in_shove_check, using this calculation may produce an undesired stack_level > 1 in ShapeTraceEntries. + curr_from_side = new CalcFromSide(p_trace.polyline(), p_index, curr_shape); } this.shape = curr_shape; this.from_side = curr_from_side; } - - private static Line calc_cutline_at_end(int p_index, PolylineTrace p_trace) - { + + private static Line calc_cutline_at_end(int p_index, PolylineTrace p_trace) { Polyline trace_lines = p_trace.polyline(); ShapeSearchTree search_tree = p_trace.board.search_tree_manager.get_default_tree(); if (p_index == trace_lines.arr.length - 3 || trace_lines.corner_approx(trace_lines.arr.length - 2).distance(trace_lines.corner_approx(p_index + 1)) - < p_trace.get_compensated_half_width(search_tree)) - { - + < p_trace.get_compensated_half_width(search_tree)) { + Line curr_line = trace_lines.arr[trace_lines.arr.length - 1]; FloatPoint is = trace_lines.corner_approx(trace_lines.arr.length - 3); Line cut_line; - if (curr_line.side_of(is) == Side.ON_THE_LEFT) - { + if (curr_line.side_of(is) == Side.ON_THE_LEFT) { cut_line = curr_line.opposite(); - } - else - { + } else { cut_line = curr_line; } return cut_line; } return null; } - - private static Line calc_cutline_at_start(int p_index, PolylineTrace p_trace) - { + + private static Line calc_cutline_at_start(int p_index, PolylineTrace p_trace) { Polyline trace_lines = p_trace.polyline(); ShapeSearchTree search_tree = p_trace.board.search_tree_manager.get_default_tree(); if (p_index == 0 || trace_lines.corner_approx(0).distance(trace_lines.corner_approx(p_index)) - < p_trace.get_compensated_half_width(search_tree)) - { + < p_trace.get_compensated_half_width(search_tree)) { Line curr_line = trace_lines.arr[0]; FloatPoint is = trace_lines.corner_approx(1); Line cut_line; - if (curr_line.side_of(is) == Side.ON_THE_LEFT) - { + if (curr_line.side_of(is) == Side.ON_THE_LEFT) { cut_line = curr_line.opposite(); - } - else - { + } else { cut_line = curr_line; } return cut_line; } return null; } - - - final TileShape shape; - final CalcFromSide from_side; } diff --git a/src/main/java/net/freerouting/board/ChangedArea.java b/src/main/java/net/freerouting/board/ChangedArea.java index 57d7c6b6..a73ff7a4 100644 --- a/src/main/java/net/freerouting/board/ChangedArea.java +++ b/src/main/java/net/freerouting/board/ChangedArea.java @@ -15,29 +15,28 @@ */ package net.freerouting.board; + import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntBox; import net.freerouting.geometry.planar.IntOctagon; /** - * * Used internally for marking changed areas on the board * after shoving and optimizing items. * - * @author Alfons Wirtz */ -class ChangedArea -{ +class ChangedArea { - public ChangedArea(int p_layer_count) - { + final int layer_count; + MutableOctagon[] arr; + + public ChangedArea(int p_layer_count) { layer_count = p_layer_count; - arr = new MutableOctagon [layer_count]; + arr = new MutableOctagon[layer_count]; // initialise all octagons to empty - for (int i = 0; i < layer_count; ++i) - { + for (int i = 0; i < layer_count; ++i) { arr[i] = new MutableOctagon(); arr[i].set_empty(); } @@ -46,8 +45,7 @@ public ChangedArea(int p_layer_count) /** * enlarges the octagon on p_layer, so that it contains p_point */ - public void join (FloatPoint p_point, int p_layer) - { + public void join(FloatPoint p_point, int p_layer) { MutableOctagon curr = arr[p_layer]; curr.lx = Math.min(p_point.x, curr.lx); curr.ly = Math.min(p_point.y, curr.ly); @@ -62,19 +60,16 @@ public void join (FloatPoint p_point, int p_layer) curr.llx = Math.min(curr.llx, tmp); curr.urx = Math.max(curr.urx, tmp); } - - /** + + /** * enlarges the octagon on p_layer, so that it contains p_shape */ - public void join (net.freerouting.geometry.planar.TileShape p_shape, int p_layer) - { - if (p_shape == null) - { + public void join(net.freerouting.geometry.planar.TileShape p_shape, int p_layer) { + if (p_shape == null) { return; } int corner_count = p_shape.border_line_count(); - for (int i = 0; i < corner_count; ++i) - { + for (int i = 0; i < corner_count; ++i) { join(p_shape.corner_approx(i), p_layer); } } @@ -82,28 +77,24 @@ public void join (net.freerouting.geometry.planar.TileShape p_shape, int p_layer /** * get the marking octagon on layer p_layer */ - public IntOctagon get_area (int p_layer) - { + public IntOctagon get_area(int p_layer) { return arr[p_layer].to_int(); } - public IntBox surrounding_box() - { + public IntBox surrounding_box() { int llx = Integer.MAX_VALUE; int lly = Integer.MAX_VALUE; int urx = Integer.MIN_VALUE; int ury = Integer.MIN_VALUE; - for (int i = 0; i < layer_count; ++i) - { + for (int i = 0; i < layer_count; ++i) { MutableOctagon curr = arr[i]; - llx = Math.min (llx, (int)Math.floor(curr.lx)); - lly = Math.min (lly, (int)Math.floor(curr.ly)); - urx = Math.max (urx, (int)Math.ceil(curr.rx)); - ury = Math.max (ury, (int)Math.ceil(curr.uy)); + llx = Math.min(llx, (int) Math.floor(curr.lx)); + lly = Math.min(lly, (int) Math.floor(curr.ly)); + urx = Math.max(urx, (int) Math.ceil(curr.rx)); + ury = Math.max(ury, (int) Math.ceil(curr.uy)); } - if (llx > urx || lly > ury) - { + if (llx > urx || lly > ury) { return IntBox.EMPTY; } return new IntBox(llx, lly, urx, ury); @@ -112,19 +103,14 @@ public IntBox surrounding_box() /** * inizialises the marking octagon on p_layer to empty */ - void set_empty(int p_layer) - { + void set_empty(int p_layer) { arr[p_layer].set_empty(); } - final int layer_count; - MutableOctagon [] arr; - /** * mutable octagon with double coordinates (see geometry.planar.IntOctagon) */ - private static class MutableOctagon - { + private static class MutableOctagon { double lx; double ly; double rx; @@ -133,9 +119,8 @@ private static class MutableOctagon double lrx; double llx; double urx; - - void set_empty() - { + + void set_empty() { lx = Integer.MAX_VALUE; ly = Integer.MAX_VALUE; rx = Integer.MIN_VALUE; @@ -143,21 +128,20 @@ void set_empty() ulx = Integer.MAX_VALUE; lrx = Integer.MIN_VALUE; llx = Integer.MAX_VALUE; - urx = Integer.MIN_VALUE; + urx = Integer.MIN_VALUE; } + /** * calculates the smallest IntOctagon containing this octagon. */ - IntOctagon to_int() - { - if (rx < lx || uy < ly || lrx < ulx || urx < llx) - { + IntOctagon to_int() { + if (rx < lx || uy < ly || lrx < ulx || urx < llx) { return IntOctagon.EMPTY; } - return new IntOctagon ((int)Math.floor(lx), (int)Math.floor(ly), - (int)Math.ceil(rx), (int)Math.ceil(uy), - (int)Math.floor(ulx), (int)Math.ceil(lrx), - (int)Math.floor(llx), (int)Math.ceil(urx)); + return new IntOctagon((int) Math.floor(lx), (int) Math.floor(ly), + (int) Math.ceil(rx), (int) Math.ceil(uy), + (int) Math.floor(ulx), (int) Math.ceil(lrx), + (int) Math.floor(llx), (int) Math.ceil(urx)); } } } \ No newline at end of file diff --git a/src/main/java/net/freerouting/board/ClearanceViolation.java b/src/main/java/net/freerouting/board/ClearanceViolation.java index 5bf92bc3..b31561fd 100644 --- a/src/main/java/net/freerouting/board/ClearanceViolation.java +++ b/src/main/java/net/freerouting/board/ClearanceViolation.java @@ -26,23 +26,38 @@ /** * Information of a clearance violation between 2 items. * - * @author alfons + * @author alfons */ -public class ClearanceViolation implements ObjectInfoPanel.Printable -{ - - /** Creates a new instance of ClearanceViolation */ - public ClearanceViolation(Item p_first_item, Item p_second_item, ConvexShape p_shape, int p_layer) - { +public class ClearanceViolation implements ObjectInfoPanel.Printable { + + /** + * The first item of the clearance violation + */ + public final Item first_item; + /** + * The second item of the clearance violation + */ + public final Item second_item; + /** + * The shape of the clearance violation + */ + public final ConvexShape shape; + /** + * The layer of the clearance violation + */ + public final int layer; + /** + * Creates a new instance of ClearanceViolation + */ + public ClearanceViolation(Item p_first_item, Item p_second_item, ConvexShape p_shape, int p_layer) { first_item = p_first_item; second_item = p_second_item; shape = p_shape; layer = p_layer; } - - public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("clearance_violation_2")); p_window.append(" " + resources.getString("at") + " "); @@ -51,20 +66,11 @@ public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) p_window.append(2 * this.shape.smallest_radius()); p_window.append(", " + resources.getString("layer") + " "); p_window.append(first_item.board.layer_structure.arr[this.layer].name); - p_window.append(", "+ resources.getString("between")); + p_window.append(", " + resources.getString("between")); p_window.newline(); p_window.indent(); first_item.print_info(p_window, p_locale); p_window.indent(); second_item.print_info(p_window, p_locale); } - - /** The first item of the clearance violation */ - public final Item first_item; - /** The second item of the clearance violation */ - public final Item second_item; - /** The shape of the clearance violation */ - public final ConvexShape shape; - /** The layer of the clearance violation */ - public final int layer; } diff --git a/src/main/java/net/freerouting/board/Communication.java b/src/main/java/net/freerouting/board/Communication.java index 1263b873..d30d4dc8 100644 --- a/src/main/java/net/freerouting/board/Communication.java +++ b/src/main/java/net/freerouting/board/Communication.java @@ -26,16 +26,34 @@ /** * Communication information to host systems or host design formats. * - * @author alfons + * @author alfons */ -public class Communication implements java.io.Serializable -{ - - /** Creates a new instance of BoardCommunication */ +public class Communication implements java.io.Serializable { + + /** + * For coordinate tramsforms to a Specctra dsn file for example. + */ + public final CoordinateTransform coordinate_transform; + /** + * mil, inch or mm + */ + public final Unit unit; + /** + * The resolution (1 / unit_factor) of the coordinate system, + * which is imported from the host system. + */ + public final int resolution; + public final SpecctraParserInfo specctra_parser_info; + public final IdNoGenerator id_no_generator; + transient public BoardObservers observers; + + + /** + * Creates a new instance of BoardCommunication + */ public Communication(Unit p_unit, int p_resolution, - SpecctraParserInfo p_specctra_parser_info, CoordinateTransform p_coordinate_transform, - IdNoGenerator p_id_no_generator, BoardObservers p_observers) - { + SpecctraParserInfo p_specctra_parser_info, CoordinateTransform p_coordinate_transform, + IdNoGenerator p_id_no_generator, BoardObservers p_observers) { coordinate_transform = p_coordinate_transform; unit = p_unit; resolution = p_resolution; @@ -43,71 +61,56 @@ public Communication(Unit p_unit, int p_resolution, id_no_generator = p_id_no_generator; observers = p_observers; } - - /** Creates a new instance of BoardCommunication */ - public Communication() - { - this(Unit.MIL, 1, new SpecctraParserInfo("\"", null, null, null, null, false), + + /** + * Creates a new instance of BoardCommunication + */ + public Communication() { + this(Unit.MIL, 1, new SpecctraParserInfo("\"", null, null, null, null, false), new CoordinateTransform(1, 0, 0), new net.freerouting.board.ItemIdNoGenerator(), new BoardObserverAdaptor()); } - - public boolean host_cad_is_eagle() - { - return specctra_parser_info != null && specctra_parser_info.host_cad != null + + public boolean host_cad_is_eagle() { + return specctra_parser_info != null && specctra_parser_info.host_cad != null && specctra_parser_info.host_cad.equalsIgnoreCase("CadSoft"); } - - public boolean host_cad_exists() - { + + public boolean host_cad_exists() { return specctra_parser_info != null && specctra_parser_info.host_cad != null; } - - + /** - * Returns the resolution scaled to the input unit + * Returns the resolution scaled to the input unit */ - public double get_resolution (Unit p_unit) - { + public double get_resolution(Unit p_unit) { return Unit.scale(this.resolution, p_unit, this.unit); } - + private void readObject(java.io.ObjectInputStream p_stream) - throws java.io.IOException, java.lang.ClassNotFoundException - { + throws java.io.IOException, java.lang.ClassNotFoundException { p_stream.defaultReadObject(); observers = new BoardObserverAdaptor(); } - - /** For coordinate tramsforms to a Specctra dsn file for example. */ - public final CoordinateTransform coordinate_transform; - - /** mil, inch or mm */ - public final Unit unit; - - /** - * The resolution (1 / unit_factor) of the coordinate system, - * which is imported from the host system. - */ - public final int resolution; - - public final SpecctraParserInfo specctra_parser_info; - - public final IdNoGenerator id_no_generator; - - transient public BoardObservers observers; - /** * Information from the parser scope in a Specctra-dsn-file. * The fields are optional and may be null. */ - public static class SpecctraParserInfo implements java.io.Serializable - { + public static class SpecctraParserInfo implements java.io.Serializable { + /** + * Character for quoting strings in a dsn-File. + */ + public final String string_quote; + public final String host_cad; + public final String host_version; + public final java.util.Collection constants; + public final WriteResolution write_resolution; + public final boolean dsn_file_generated_by_host; + public SpecctraParserInfo(String p_string_quote, String p_host_cad, - String p_host_version, java.util.Collection p_constants, - WriteResolution p_write_resolution, - boolean p_dsn_file_generated_by_host) - { + String p_host_version, java.util.Collection p_constants, + WriteResolution p_write_resolution, + boolean p_dsn_file_generated_by_host) { string_quote = p_string_quote; host_cad = p_host_cad; host_version = p_host_version; @@ -115,30 +118,14 @@ public SpecctraParserInfo(String p_string_quote, String p_host_cad, write_resolution = p_write_resolution; dsn_file_generated_by_host = p_dsn_file_generated_by_host; } - - /** Character for quoting strings in a dsn-File. */ - public final String string_quote; - - public final String host_cad; - - public final String host_version; - - public final java.util.Collection constants; - - public final WriteResolution write_resolution; - - public final boolean dsn_file_generated_by_host; - - - public static class WriteResolution implements java.io.Serializable - { - public WriteResolution(String p_char_name, int p_positive_int) - { + + public static class WriteResolution implements java.io.Serializable { + public final String char_name; + public final int positive_int; + public WriteResolution(String p_char_name, int p_positive_int) { char_name = p_char_name; positive_int = p_positive_int; } - public final String char_name; - public final int positive_int; } } } diff --git a/src/main/java/net/freerouting/board/Component.java b/src/main/java/net/freerouting/board/Component.java index 0fbd2687..9aea8dfa 100644 --- a/src/main/java/net/freerouting/board/Component.java +++ b/src/main/java/net/freerouting/board/Component.java @@ -22,11 +22,9 @@ import net.freerouting.datastructures.UndoableObjects; - -import net.freerouting.geometry.planar.Point; import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Point; import net.freerouting.geometry.planar.Vector; - import net.freerouting.library.Package; @@ -34,26 +32,59 @@ * Describes board components consisting of an array of pins * und other stuff like component keepouts. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Component implements UndoableObjects.Storable, ObjectInfoPanel.Printable, java.io.Serializable -{ +public class Component implements UndoableObjects.Storable, ObjectInfoPanel.Printable, java.io.Serializable { + /** + * The name of the component. + */ + public final String name; + /** + * Internal generated unique identification number. + */ + public final int no; + /** + * If true, the component cannot be moved. + */ + public final boolean position_fixed; + /** + * The library package of the component if it is placed on the component side. + */ + private final Package lib_package_front; + /** + * The library package of the component if it is placed on the solder side. + */ + private final Package lib_package_back; + /** + * The location of the component. + */ + private Point location; + /** + * The rotation of the library package of the component in degree + */ + private double rotation_in_degree; + /** + * Contains information for gate swapping and pin swapping, if != null + */ + private net.freerouting.library.LogicalPart logical_part = null; + /** + * If false, the component will be placed on the back side of the board. + */ + private boolean on_front; + /** * Creates a new instance of Component with the input parameters. * If p_on_front is false, the component will be placed on the back side. */ Component(String p_name, Point p_location, double p_rotation_in_degree, boolean p_on_front, - Package p_package_front, Package p_package_back, int p_no, boolean p_position_fixed) - { + Package p_package_front, Package p_package_back, int p_no, boolean p_position_fixed) { name = p_name; location = p_location; rotation_in_degree = p_rotation_in_degree; - while (this.rotation_in_degree >= 360) - { + while (this.rotation_in_degree >= 360) { this.rotation_in_degree -= 360; } - while (this.rotation_in_degree < 0) - { + while (this.rotation_in_degree < 0) { this.rotation_in_degree += 360; } on_front = p_on_front; @@ -62,236 +93,174 @@ public class Component implements UndoableObjects.Storable, ObjectInfoPanel.Prin no = p_no; position_fixed = p_position_fixed; } - + /** * Returns the location of this component. */ - public Point get_location() - { + public Point get_location() { return location; } - + /** * Returns the rotation of this component in degree. */ - public double get_rotation_in_degree() - { + public double get_rotation_in_degree() { return rotation_in_degree; } - - public boolean is_placed() - { + + public boolean is_placed() { return location != null; } - + /** * If false, the component will be placed on the back side of the board. */ - public boolean placed_on_front() - { + public boolean placed_on_front() { return this.on_front; } - + /** * Translates the location of this Component by p_p_vector. * The Pins in the board must be moved seperately. */ - public void translate_by(Vector p_vector) - { - if (location != null) - { + public void translate_by(Vector p_vector) { + if (location != null) { location = location.translate_by(p_vector); } } - + /** * Turns this component by p_factor times 90 degree around p_pole. */ - public void turn_90_degree(int p_factor, IntPoint p_pole) - { - if (p_factor == 0) - { + public void turn_90_degree(int p_factor, IntPoint p_pole) { + if (p_factor == 0) { return; } - this.rotation_in_degree = this.rotation_in_degree + p_factor * 90; - while (this.rotation_in_degree >= 360) - { + this.rotation_in_degree = this.rotation_in_degree + p_factor * 90; + while (this.rotation_in_degree >= 360) { this.rotation_in_degree -= 360; } - while (this.rotation_in_degree < 0) - { + while (this.rotation_in_degree < 0) { this.rotation_in_degree += 360; } - if (location != null) - { + if (location != null) { this.location = this.location.turn_90_degree(p_factor, p_pole); } } + /** * Rotates this component by p_angle_in_degree around p_pole. */ - public void rotate(double p_angle_in_degree, IntPoint p_pole, boolean p_flip_style_rotate_first) - { - if (p_angle_in_degree == 0) - { + public void rotate(double p_angle_in_degree, IntPoint p_pole, boolean p_flip_style_rotate_first) { + if (p_angle_in_degree == 0) { return; } double turn_angle = p_angle_in_degree; - if (p_flip_style_rotate_first && !this.placed_on_front()) - { + if (p_flip_style_rotate_first && !this.placed_on_front()) { // take care of the order of mirroring and rotating on the back side of the board turn_angle = 360 - p_angle_in_degree; } - this.rotation_in_degree = this.rotation_in_degree + turn_angle; - while (this.rotation_in_degree >= 360) - { + this.rotation_in_degree = this.rotation_in_degree + turn_angle; + while (this.rotation_in_degree >= 360) { this.rotation_in_degree -= 360; } - while (this.rotation_in_degree < 0) - { + while (this.rotation_in_degree < 0) { this.rotation_in_degree += 360; } - if (location != null) - { + if (location != null) { this.location = this.location.to_float().rotate(Math.toRadians(p_angle_in_degree), p_pole.to_float()).round(); } } - + /** * Changes the placement side of this component and mirrors it at the * vertical line through p_pole. */ - public void change_side(IntPoint p_pole) - { + public void change_side(IntPoint p_pole) { this.on_front = !this.on_front; this.location = this.location.mirror_vertical(p_pole); } - + /** * Compares 2 components by name. * Useful for example to display components in alphabetic order. */ - public int compareTo(Object p_other) - { - if (p_other instanceof Component) - { - return this.name.compareToIgnoreCase(((Component)p_other).name); + public int compareTo(Object p_other) { + if (p_other instanceof Component) { + return this.name.compareToIgnoreCase(((Component) p_other).name); } return 1; } - + /** * Creates a copy of this component. */ - public Component clone() - { + public Component clone() { Component result = new Component(name, location, rotation_in_degree, on_front, lib_package_front, lib_package_back, no, position_fixed); result.logical_part = this.logical_part; return result; } - - public String toString() - { + + public String toString() { return this.name; } - + /** * Returns information for pin swap and gate swap, if != null. */ - public net.freerouting.library.LogicalPart get_logical_part() - { + public net.freerouting.library.LogicalPart get_logical_part() { return this.logical_part; } - + /** * Sets the infomation for pin swap and gate swap. */ - public void set_logical_part(net.freerouting.library.LogicalPart p_logical_part) - { + public void set_logical_part(net.freerouting.library.LogicalPart p_logical_part) { this.logical_part = p_logical_part; } - - public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("component") + " "); p_window.append_bold(this.name); - if (this.location != null) - { + if (this.location != null) { p_window.append(" " + resources.getString("at") + " "); p_window.append(this.location.to_float()); - + p_window.append(", " + resources.getString("rotation") + " "); p_window.append_without_transforming(rotation_in_degree); - - if (this.on_front) - { + + if (this.on_front) { p_window.append(", " + resources.getString("front")); - } - else - { + } else { p_window.append(", " + resources.getString("back")); } - } - else - { + } else { p_window.append(" " + resources.getString("not_yet_placed")); } p_window.append(", " + resources.getString("package")); Package lib_package = this.get_package(); p_window.append(lib_package.name, resources.getString("package_info"), lib_package); - if (this.logical_part != null) - { + if (this.logical_part != null) { p_window.append(", " + resources.getString("logical_part") + " "); p_window.append(this.logical_part.name, resources.getString("logical_part_info"), this.logical_part); } p_window.newline(); } - + /** * Returns the library package of this component. */ - public Package get_package() - { + public Package get_package() { Package result; - if (this.on_front) - { + if (this.on_front) { result = lib_package_front; - } - else - { + } else { result = lib_package_back; } return result; - } - - /** The name of the component. */ - public final String name; - - /** The location of the component. */ - private Point location; - - /** The rotation of the library package of the component in degree */ - private double rotation_in_degree; - - /** Contains information for gate swapping and pin swapping, if != null */ - private net.freerouting.library.LogicalPart logical_part = null; - - /** If false, the component will be placed on the back side of the board. */ - private boolean on_front; - - /** The library package of the component if it is placed on the component side. */ - private final Package lib_package_front; - - /** The library package of the component if it is placed on the solder side. */ - private final Package lib_package_back; - - /** Internal generated unique identification number. */ - public final int no; - - /** If true, the component cannot be moved. */ - public final boolean position_fixed; - + } + } diff --git a/src/main/java/net/freerouting/board/ComponentObstacleArea.java b/src/main/java/net/freerouting/board/ComponentObstacleArea.java index 56c879b2..bbf4a5df 100644 --- a/src/main/java/net/freerouting/board/ComponentObstacleArea.java +++ b/src/main/java/net/freerouting/board/ComponentObstacleArea.java @@ -29,70 +29,58 @@ * * @author alfons */ -public class ComponentObstacleArea extends ObstacleArea -{ +public class ComponentObstacleArea extends ObstacleArea { /** * Creates a new instance of ComponentObstacleArea * If p_is_obstacle ist false, the new instance is not regarded as obstacle and used only for displaying on the screen. */ ComponentObstacleArea(Area p_area, int p_layer, Vector p_translation, double p_rotation_in_degree, - boolean p_side_changed, int p_clearance_type, int p_id_no, int p_component_no, - String p_name, FixedState p_fixed_state, BasicBoard p_board) - { + boolean p_side_changed, int p_clearance_type, int p_id_no, int p_component_no, + String p_name, FixedState p_fixed_state, BasicBoard p_board) { super(p_area, p_layer, p_translation, p_rotation_in_degree, p_side_changed, new int[0], p_clearance_type, p_id_no, p_component_no, p_name, p_fixed_state, p_board); } - - public Item copy(int p_id_no) - { + + public Item copy(int p_id_no) { return new ComponentObstacleArea(get_relative_area(), get_layer(), get_translation(), get_rotation_in_degree(), get_side_changed(), clearance_class_no(), p_id_no, get_component_no(), this.name, get_fixed_state(), board); } - - public boolean is_obstacle(Item p_other) - { + + public boolean is_obstacle(Item p_other) { return p_other != this && p_other instanceof ComponentObstacleArea && p_other.get_component_no() != this.get_component_no(); } - - public boolean is_trace_obstacle(int p_net_no) - { + + public boolean is_trace_obstacle(int p_net_no) { return false; } - - public boolean is_selected_by_filter(ItemSelectionFilter p_filter) - { - if (!this.is_selected_by_fixed_filter(p_filter)) - { + + public boolean is_selected_by_filter(ItemSelectionFilter p_filter) { + if (!this.is_selected_by_fixed_filter(p_filter)) { return false; } return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.COMPONENT_KEEPOUT); } - - - public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { - return p_graphics_context.get_place_obstacle_colors(); + + + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { + return p_graphics_context.get_place_obstacle_colors(); } - - public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { + + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_place_obstacle_color_intensity(); } - - public boolean is_selectrd_by_filter(ItemSelectionFilter p_filter) - { - if (!this.is_selected_by_fixed_filter(p_filter)) - { + + public boolean is_selectrd_by_filter(ItemSelectionFilter p_filter) { + if (!this.is_selected_by_fixed_filter(p_filter)) { return false; } return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.COMPONENT_KEEPOUT); } - - public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("component_keepout")); this.print_shape_info(p_window, p_locale); diff --git a/src/main/java/net/freerouting/board/ComponentOutline.java b/src/main/java/net/freerouting/board/ComponentOutline.java index e113ac13..5c59c892 100644 --- a/src/main/java/net/freerouting/board/ComponentOutline.java +++ b/src/main/java/net/freerouting/board/ComponentOutline.java @@ -20,27 +20,28 @@ */ package net.freerouting.board; -import java.awt.Color; - -import net.freerouting.geometry.planar.Area; -import net.freerouting.geometry.planar.Vector; +import net.freerouting.boardgraphics.GraphicsContext; +import net.freerouting.geometry.planar.*; import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.boardgraphics.GraphicsContext; +import java.awt.*; /** - * * @author Alfons Wirtz */ -public class ComponentOutline extends Item implements java.io.Serializable -{ +public class ComponentOutline extends Item implements java.io.Serializable { - /** Creates a new instance of ComponentOutline */ + private Area relative_area; + private transient Area precalculated_absolute_area = null; + private Vector translation; + private double rotation_in_degree; + private boolean is_front; + + /** + * Creates a new instance of ComponentOutline + */ public ComponentOutline(Area p_area, boolean p_is_front, Vector p_translation, double p_rotation_in_degree, - int p_component_no, FixedState p_fixed_state, BasicBoard p_board) - { + int p_component_no, FixedState p_fixed_state, BasicBoard p_board) { super(new int[0], 0, 0, p_component_no, p_fixed_state, p_board); this.relative_area = p_area; this.is_front = p_is_front; @@ -48,137 +49,110 @@ public ComponentOutline(Area p_area, boolean p_is_front, Vector p_translation, d this.rotation_in_degree = p_rotation_in_degree; } - public Item copy(int p_id_no) - { + public Item copy(int p_id_no) { return new ComponentOutline(this.relative_area, this.is_front, this.translation, this.rotation_in_degree, this.get_component_no(), this.get_fixed_state(), this.board); } - public boolean is_selected_by_filter(ItemSelectionFilter p_filter) - { + public boolean is_selected_by_filter(ItemSelectionFilter p_filter) { return false; } - public int get_layer() - { + public int get_layer() { int result; - if (this.is_front) - { + if (this.is_front) { result = 0; - } - else - { + } else { result = this.board.get_layer_count() - 1; } return result; } - public int first_layer() - { + public int first_layer() { return get_layer(); } - public int last_layer() - { + public int last_layer() { return get_layer(); } - public boolean is_on_layer(int p_layer) - { + public boolean is_on_layer(int p_layer) { return get_layer() == p_layer; } - public boolean is_obstacle(Item p_item) - { + public boolean is_obstacle(Item p_item) { return false; } - public int shape_layer(int p_index) - { + public int shape_layer(int p_index) { return get_layer(); } - public int tile_shape_count() - { + public int tile_shape_count() { return 0; } - protected net.freerouting.geometry.planar.TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) - { + protected net.freerouting.geometry.planar.TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) { return new net.freerouting.geometry.planar.TileShape[0]; } - public double get_draw_intensity(GraphicsContext p_graphics_context) - { + public double get_draw_intensity(GraphicsContext p_graphics_context) { return p_graphics_context.get_component_outline_color_intensity(); } - public Color[] get_draw_colors(GraphicsContext p_graphics_context) - { + public Color[] get_draw_colors(GraphicsContext p_graphics_context) { Color[] color_arr = new java.awt.Color[this.board.layer_structure.arr.length]; Color front_draw_color = p_graphics_context.get_component_color(true); - for (int i = 0; i < color_arr.length - 1; ++i) - { + for (int i = 0; i < color_arr.length - 1; ++i) { color_arr[i] = front_draw_color; } - if (color_arr.length > 1) - { + if (color_arr.length > 1) { color_arr[color_arr.length - 1] = p_graphics_context.get_component_color(false); } return color_arr; } - public int get_draw_priority() - { + public int get_draw_priority() { return net.freerouting.boardgraphics.Drawable.MIDDLE_DRAW_PRIORITY; } - public void draw(java.awt.Graphics p_g, GraphicsContext p_graphics_context, Color[] p_color_arr, double p_intensity) - { - if (p_graphics_context == null || p_intensity <= 0) - { + public void draw(java.awt.Graphics p_g, GraphicsContext p_graphics_context, Color[] p_color_arr, double p_intensity) { + if (p_graphics_context == null || p_intensity <= 0) { return; } Color color = p_color_arr[this.get_layer()]; double intensity = p_graphics_context.get_layer_visibility(this.get_layer()) * p_intensity; - double draw_width = Math.min (this.board.communication.get_resolution(Unit.MIL), 100); // problem with low resolution on Kicad + double draw_width = Math.min(this.board.communication.get_resolution(Unit.MIL), 100); // problem with low resolution on Kicad p_graphics_context.draw_boundary(this.get_area(), draw_width, color, p_g, intensity); } - public net.freerouting.geometry.planar.IntBox bounding_box() - { + public net.freerouting.geometry.planar.IntBox bounding_box() { return get_area().bounding_box(); } - public void translate_by(Vector p_vector) - { + public void translate_by(Vector p_vector) { this.translation = this.translation.add(p_vector); clear_derived_data(); } - public void change_placement_side(IntPoint p_pole) - { + public void change_placement_side(IntPoint p_pole) { this.is_front = !this.is_front; Point rel_location = Point.ZERO.translate_by(this.translation); this.translation = rel_location.mirror_vertical(p_pole).difference_by(Point.ZERO); clear_derived_data(); } - public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) - { + public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) { double turn_angle = p_angle_in_degree; - if (!this.is_front && this.board.components.get_flip_style_rotate_first()) - { + if (!this.is_front && this.board.components.get_flip_style_rotate_first()) { turn_angle = 360 - p_angle_in_degree; } this.rotation_in_degree += turn_angle; - while (this.rotation_in_degree >= 360) - { + while (this.rotation_in_degree >= 360) { this.rotation_in_degree -= 360; } - while (this.rotation_in_degree < 0) - { + while (this.rotation_in_degree < 0) { this.rotation_in_degree += 360; } FloatPoint new_translation = this.translation.to_float().rotate(Math.toRadians(p_angle_in_degree), p_pole); @@ -186,15 +160,12 @@ public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) clear_derived_data(); } - public void turn_90_degree(int p_factor, IntPoint p_pole) - { + public void turn_90_degree(int p_factor, IntPoint p_pole) { this.rotation_in_degree += p_factor * 90; - while (this.rotation_in_degree >= 360) - { + while (this.rotation_in_degree >= 360) { this.rotation_in_degree -= 360; } - while (this.rotation_in_degree < 0) - { + while (this.rotation_in_degree < 0) { this.rotation_in_degree += 360; } Point rel_location = Point.ZERO.translate_by(this.translation); @@ -202,35 +173,26 @@ public void turn_90_degree(int p_factor, IntPoint p_pole) clear_derived_data(); } - public Area get_area() - { - if (this.precalculated_absolute_area == null) - { - if (this.relative_area == null) - { + public Area get_area() { + if (this.precalculated_absolute_area == null) { + if (this.relative_area == null) { System.out.println("ObstacleArea.get_area: area is null"); return null; } Area turned_area = this.relative_area; - if (!this.is_front && !this.board.components.get_flip_style_rotate_first()) - { + if (!this.is_front && !this.board.components.get_flip_style_rotate_first()) { turned_area = turned_area.mirror_vertical(Point.ZERO); } - if (this.rotation_in_degree != 0) - { + if (this.rotation_in_degree != 0) { double rotation = this.rotation_in_degree; - if (rotation % 90 == 0) - { + if (rotation % 90 == 0) { turned_area = turned_area.turn_90_degree(((int) rotation) / 90, Point.ZERO); - } - else - { + } else { turned_area = turned_area.rotate_approx(Math.toRadians(rotation), FloatPoint.ZERO); } } - if (!this.is_front && this.board.components.get_flip_style_rotate_first()) - { + if (!this.is_front && this.board.components.get_flip_style_rotate_first()) { turned_area = turned_area.mirror_vertical(Point.ZERO); } this.precalculated_absolute_area = turned_area.translate_by(this.translation); @@ -238,29 +200,19 @@ public Area get_area() return this.precalculated_absolute_area; } - public void clear_derived_data() - { + public void clear_derived_data() { precalculated_absolute_area = null; } - public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { + public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { } - public boolean write(java.io.ObjectOutputStream p_stream) - { - try - { + public boolean write(java.io.ObjectOutputStream p_stream) { + try { p_stream.writeObject(this); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { return false; } return true; } - private Area relative_area; - private transient Area precalculated_absolute_area = null; - private Vector translation; - private double rotation_in_degree; - private boolean is_front; } diff --git a/src/main/java/net/freerouting/board/Components.java b/src/main/java/net/freerouting/board/Components.java index f27d895c..c235b423 100644 --- a/src/main/java/net/freerouting/board/Components.java +++ b/src/main/java/net/freerouting/board/Components.java @@ -22,23 +22,28 @@ package net.freerouting.board; -import java.util.Iterator; -import java.util.Vector; - import net.freerouting.datastructures.UndoableObjects; - -import net.freerouting.geometry.planar.Point; import net.freerouting.geometry.planar.IntPoint; - +import net.freerouting.geometry.planar.Point; import net.freerouting.library.Package; +import java.util.Iterator; +import java.util.Vector; + /** * Contains the lists of components on the board. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Components implements java.io.Serializable -{ +public class Components implements java.io.Serializable { + private final UndoableObjects undo_list = new UndoableObjects(); + private Vector component_arr = new Vector(); + /** + * If true, components on the back side are rotated before mirroring, + * else they are mirrored before rotating. + */ + private boolean flip_style_rotate_first = false; + /** * Inserts a component into the list. * The items of the component have to be inserted seperately into the board. @@ -46,194 +51,162 @@ public class Components implements java.io.Serializable * and p_package_back is used instead of p_package_front. */ public Component add(String p_name, Point p_location, double p_rotation_in_degree, - boolean p_on_front, Package p_package_front, Package p_package_back, boolean p_position_fixed) - { - + boolean p_on_front, Package p_package_front, Package p_package_back, boolean p_position_fixed) { + Component new_component = new Component(p_name, p_location, p_rotation_in_degree, p_on_front, p_package_front, - p_package_back, component_arr.size() + 1, p_position_fixed); + p_package_back, component_arr.size() + 1, p_position_fixed); component_arr.add(new_component); undo_list.insert(new_component); return new_component; } - + /** * Adds a component to this object. * The items of the component have to be inserted seperately into the board. * If p_on_front is false, the component will be placed on the back side. * The component name is generated internally. */ - public Component add(Point p_location, double p_rotation, boolean p_on_front, Package p_package) - { + public Component add(Point p_location, double p_rotation, boolean p_on_front, Package p_package) { String component_name = "Component#" + (new Integer(component_arr.size() + 1)).toString(); return add(component_name, p_location, p_rotation, p_on_front, p_package, p_package, false); } - + /** * Returns the component with the input name or null, * if no such component exists. */ - public Component get(String p_name) - { + public Component get(String p_name) { Iterator it = component_arr.iterator(); - while(it.hasNext()) - { + while (it.hasNext()) { Component curr = it.next(); - if (curr.name.equals(p_name)) - { + if (curr.name.equals(p_name)) { return curr; } } return null; } - + /** * Returns the component with the input component number or null, * if no such component exists. * Component numbers are from 1 to component count */ - public Component get(int p_component_no) - { - Component result = component_arr.elementAt(p_component_no - 1); - if (result != null && result.no != p_component_no) - { + public Component get(int p_component_no) { + Component result = component_arr.elementAt(p_component_no - 1); + if (result != null && result.no != p_component_no) { System.out.println("Components.get: inconsistent component number"); } return result; } - + /** * Returns the number of components on the board. */ - public int count() - { + public int count() { return component_arr.size(); } - + /** * Generates a snapshot for the undo algorithm. */ - public void generate_snapshot() - { + public void generate_snapshot() { this.undo_list.generate_snapshot(); } - + /** * Restores the sitiation at the previous snapshot. * Returns false, if no more undo is possible. */ - public boolean undo(BoardObservers p_observers) - { - if (!this.undo_list.undo(null, null)) - { + public boolean undo(BoardObservers p_observers) { + if (!this.undo_list.undo(null, null)) { return false; } restore_component_arr_from_undo_list(p_observers); return true; } - + /** * Restores the sitiation before the last undo. * Returns false, if no more redo is possible. */ - public boolean redo(BoardObservers p_observers) - { - if (!this.undo_list.redo(null, null)) - { + public boolean redo(BoardObservers p_observers) { + if (!this.undo_list.redo(null, null)) { return false; } restore_component_arr_from_undo_list(p_observers); return true; } - + /* * Restore the components in component_arr from the undo list. */ - private void restore_component_arr_from_undo_list(BoardObservers p_observers) - { - Iterator it = this.undo_list.start_read_object(); - for (;;) - { + private void restore_component_arr_from_undo_list(BoardObservers p_observers) { + Iterator it = this.undo_list.start_read_object(); + for (; ; ) { Component curr_component = (Component) this.undo_list.read_object(it); - if (curr_component == null) - { + if (curr_component == null) { break; } this.component_arr.setElementAt(curr_component, curr_component.no - 1); p_observers.notify_moved(curr_component); } } - + /** * Moves the component with number p_component_no. * Works contrary to Component.translate_by with the undo algorithm of the board. */ - public void move(int p_component_no, net.freerouting.geometry.planar.Vector p_vector ) - { + public void move(int p_component_no, net.freerouting.geometry.planar.Vector p_vector) { Component curr_component = this.get(p_component_no); this.undo_list.save_for_undo(curr_component); curr_component.translate_by(p_vector); } - + /** * Turns the component with number p_component_no by p_factor times 90 degree around p_pole. * Works contrary to Component.turn_90_degree with the undo algorithm of the board. */ - public void turn_90_degree(int p_component_no, int p_factor, IntPoint p_pole) - { + public void turn_90_degree(int p_component_no, int p_factor, IntPoint p_pole) { Component curr_component = this.get(p_component_no); this.undo_list.save_for_undo(curr_component); curr_component.turn_90_degree(p_factor, p_pole); } - - /** + + /** * Rotates the component with number p_component_no by p_rotation_in_degree around p_pole. * Works contrary to Component.rotate with the undo algorithm of the board. */ - public void rotate (int p_component_no, double p_rotation_in_degree, IntPoint p_pole) - { + public void rotate(int p_component_no, double p_rotation_in_degree, IntPoint p_pole) { Component curr_component = this.get(p_component_no); this.undo_list.save_for_undo(curr_component); curr_component.rotate(p_rotation_in_degree, p_pole, flip_style_rotate_first); } - + /** * Changes the placement side of the component the component with numberp_component_no and * mirrors it at the vertical line through p_pole. * Works contrary to Component.change_side the undo algorithm of the board. */ - public void change_side(int p_component_no, IntPoint p_pole) - { + public void change_side(int p_component_no, IntPoint p_pole) { Component curr_component = this.get(p_component_no); this.undo_list.save_for_undo(curr_component); curr_component.change_side(p_pole); } - - /** - * If true, components on the back side are rotated before mirroring, - * else they are mirrored before rotating. - */ - public void set_flip_style_rotate_first(boolean p_value) - { - flip_style_rotate_first = p_value; - } - + /** * If true, components on the back side are rotated before mirroring, * else they are mirrored before rotating. */ - public boolean get_flip_style_rotate_first() - { + public boolean get_flip_style_rotate_first() { return flip_style_rotate_first; } - - private final UndoableObjects undo_list = new UndoableObjects(); - - private Vector component_arr = new Vector(); - + /** * If true, components on the back side are rotated before mirroring, * else they are mirrored before rotating. */ - private boolean flip_style_rotate_first = false; + public void set_flip_style_rotate_first(boolean p_value) { + flip_style_rotate_first = p_value; + } } diff --git a/src/main/java/net/freerouting/board/ConductionArea.java b/src/main/java/net/freerouting/board/ConductionArea.java index 5f726cac..b9b1e068 100644 --- a/src/main/java/net/freerouting/board/ConductionArea.java +++ b/src/main/java/net/freerouting/board/ConductionArea.java @@ -20,79 +20,64 @@ package net.freerouting.board; -import java.util.Iterator; - -import net.freerouting.geometry.planar.Area; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.*; +import java.util.Iterator; import java.util.Set; import java.util.TreeSet; /** - * A ObstacleArea, which can be electrically conected to other items. + * A ObstacleArea, which can be electrically conected to other items. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class ConductionArea extends ObstacleArea implements Connectable -{ - - /** Creates a new instance of ConductionArea */ +public class ConductionArea extends ObstacleArea implements Connectable { + + private boolean is_obstacle; + + /** + * Creates a new instance of ConductionArea + */ ConductionArea(Area p_area, int p_layer, Vector p_translation, double p_rotation_in_degree, boolean p_side_changed, - int[] p_net_no_arr, int p_clearance_class, int p_id_no, int p_group_no, String p_name, boolean p_is_obstacle, - FixedState p_fixed_state, BasicBoard p_board) - { - super(p_area, p_layer, p_translation, p_rotation_in_degree, p_side_changed, p_net_no_arr, p_clearance_class, p_id_no, + int[] p_net_no_arr, int p_clearance_class, int p_id_no, int p_group_no, String p_name, boolean p_is_obstacle, + FixedState p_fixed_state, BasicBoard p_board) { + super(p_area, p_layer, p_translation, p_rotation_in_degree, p_side_changed, p_net_no_arr, p_clearance_class, p_id_no, p_group_no, p_name, p_fixed_state, p_board); is_obstacle = p_is_obstacle; } - - public Item copy(int p_id_no) - { - if (this.net_count() != 1) - { + + public Item copy(int p_id_no) { + if (this.net_count() != 1) { System.out.println("ConductionArea.copy not yet implemented for areas with more than 1 net"); return null; } return new ConductionArea(get_relative_area(), get_layer(), get_translation(), get_rotation_in_degree(), - get_side_changed(), net_no_arr, clearance_class_no(), p_id_no, get_component_no(), + get_side_changed(), net_no_arr, clearance_class_no(), p_id_no, get_component_no(), this.name, is_obstacle, get_fixed_state(), board); } - - public Set get_normal_contacts() - { + + public Set get_normal_contacts() { Set result = new TreeSet(); - for (int i = 0; i < tile_shape_count(); ++i) - { + for (int i = 0; i < tile_shape_count(); ++i) { TileShape curr_shape = get_tile_shape(i); Set overlaps = board.overlapping_objects(curr_shape, get_layer()); Iterator it = overlaps.iterator(); - while(it.hasNext()) - { + while (it.hasNext()) { SearchTreeObject curr_ob = it.next(); - if (!(curr_ob instanceof Item)) - { + if (!(curr_ob instanceof Item)) { continue; } Item curr_item = (Item) curr_ob; - if (curr_item != this && curr_item.shares_net(this) && curr_item.shares_layer(this)) - { - if (curr_item instanceof Trace) - { + if (curr_item != this && curr_item.shares_net(this) && curr_item.shares_layer(this)) { + if (curr_item instanceof Trace) { Trace curr_trace = (Trace) curr_item; - if(curr_shape.contains(curr_trace.first_corner()) - || curr_shape.contains(curr_trace.last_corner())) - { + if (curr_shape.contains(curr_trace.first_corner()) + || curr_shape.contains(curr_trace.last_corner())) { result.add(curr_item); } - } - else if (curr_item instanceof DrillItem) - { + } else if (curr_item instanceof DrillItem) { DrillItem curr_drill_item = (DrillItem) curr_item; - if (curr_shape.contains(curr_drill_item.get_center())) - { + if (curr_shape.contains(curr_drill_item.get_center())) { result.add(curr_item); } } @@ -101,94 +86,76 @@ else if (curr_item instanceof DrillItem) } return result; } - - public TileShape get_trace_connection_shape(ShapeSearchTree p_search_tree, int p_index) - { - if (p_index < 0 || p_index >= this.tree_shape_count(p_search_tree)) - { + + public TileShape get_trace_connection_shape(ShapeSearchTree p_search_tree, int p_index) { + if (p_index < 0 || p_index >= this.tree_shape_count(p_search_tree)) { System.out.println("ConductionArea.get_trace_connection_shape p_index out of range"); return null; } return this.get_tree_shape(p_search_tree, p_index); } - - public Point[] get_ratsnest_corners() - { - Point [] result; + + public Point[] get_ratsnest_corners() { + Point[] result; FloatPoint[] corners = this.get_area().corner_approx_arr(); result = new Point[corners.length]; - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { result[i] = corners[i].round(); } - + return result; } - - public boolean is_obstacle(Item p_other) - { - if (this.is_obstacle) - { + + public boolean is_obstacle(Item p_other) { + if (this.is_obstacle) { return super.is_obstacle(p_other); } return false; } - + /** * Returns if this conduction area is regarded as obstacle to traces of foreign nets. */ - public boolean get_is_obstacle() - { + public boolean get_is_obstacle() { return this.is_obstacle; } - - + /** * Sets, if this conduction area is regarded as obstacle to traces and vias of foreign nets. */ - public void set_is_obstacle(boolean p_value) - { + public void set_is_obstacle(boolean p_value) { this.is_obstacle = p_value; } - - public boolean is_trace_obstacle(int p_net_no) - { + + public boolean is_trace_obstacle(int p_net_no) { return this.is_obstacle && !this.contains_net(p_net_no); } - - public boolean is_drillable(int p_net_no) - { + + public boolean is_drillable(int p_net_no) { return !this.is_obstacle || this.contains_net(p_net_no); } - - public boolean is_selected_by_filter(ItemSelectionFilter p_filter) - { - if (!this.is_selected_by_fixed_filter(p_filter)) - { + + public boolean is_selected_by_filter(ItemSelectionFilter p_filter) { + if (!this.is_selected_by_fixed_filter(p_filter)) { return false; } return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.CONDUCTION); } - - public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { + + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_conduction_colors(); } - - public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { + + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_conduction_color_intensity(); } - - public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("conduction_area")); this.print_shape_info(p_window, p_locale); this.print_connectable_item_info(p_window, p_locale); p_window.newline(); } - - private boolean is_obstacle; } diff --git a/src/main/java/net/freerouting/board/Connectable.java b/src/main/java/net/freerouting/board/Connectable.java index 95524e9c..3151e820 100644 --- a/src/main/java/net/freerouting/board/Connectable.java +++ b/src/main/java/net/freerouting/board/Connectable.java @@ -21,38 +21,36 @@ import java.util.Set; /** - * * Functionality required for items, which can be * electrical connected to other items. * * @author Alfons Wirtz */ -public interface Connectable -{ +public interface Connectable { /** * Returns true if this item belongs to the net with number p_net_no. */ public boolean contains_net(int p_net_no); - + /** - * Returns true if the net number array of this and p_net_no_arr have a common - * number. + * Returns true if the net number array of this and p_net_no_arr have a common + * number. */ - public boolean shares_net_no(int [] p_net_no_arr); - + public boolean shares_net_no(int[] p_net_no_arr); + /** * Returns a list of all connectable items overlapping * and sharing a net with this item. */ Set get_all_contacts(); - + /** * Returns a list of all connectable items overlapping with * this item on the input layer and sharing a net with this item. */ - Set get_all_contacts(int p_layer ); - + Set get_all_contacts(int p_layer); + /** * Returns the list of all contacts of a connectable item * located at defined connection points. @@ -61,14 +59,14 @@ public interface Connectable * points of conduction areas are points on there border. */ Set get_normal_contacts(); - + /** * Returns all connectable items of the net with number p_net_no, which can be reached recursively * from this item via normal contacts. * if (p_net_no <= 0, the net number is ignored. */ Set get_connected_set(int p_net_no); - + /** * Returns for each convex shape of a connectable item * the subshape of points, where traces can be connected to that item. diff --git a/src/main/java/net/freerouting/board/CoordinateTransform.java b/src/main/java/net/freerouting/board/CoordinateTransform.java index 39f1590a..5a7eaabd 100644 --- a/src/main/java/net/freerouting/board/CoordinateTransform.java +++ b/src/main/java/net/freerouting/board/CoordinateTransform.java @@ -27,115 +27,103 @@ * * @author Alfons Wirtz */ -public class CoordinateTransform implements java.io.Serializable -{ - - /** Creates a new instance of CoordinateTransform */ +public class CoordinateTransform implements java.io.Serializable { + + /** + * The unit used for user coordinates + */ + public final Unit user_unit; + /** + * The factor of the user unit + */ + public final double user_unit_factor; + /** + * The unit used for board coordinates + */ + public final Unit board_unit; + /** + * The factor of the board unit + */ + public final double board_unit_factor; + /** + * The factor used for transforming coordinates between user coordinate space and board coordinate space + */ + private final double scale_factor; + + /** + * Creates a new instance of CoordinateTransform + */ public CoordinateTransform(double p_user_unit_factor, Unit p_user_unit, - double p_board_unit_factor, Unit p_board_unit) - { - user_unit = p_user_unit; - board_unit = p_board_unit; + double p_board_unit_factor, Unit p_board_unit) { + user_unit = p_user_unit; + board_unit = p_board_unit; user_unit_factor = p_user_unit_factor; board_unit_factor = p_board_unit_factor; scale_factor = board_unit_factor / user_unit_factor; } - + /** * Scale a value from the board to the user coordinate system. */ - public double board_to_user(double p_value) - { + public double board_to_user(double p_value) { return Unit.scale(p_value * scale_factor, board_unit, user_unit); } - + /** * Scale a value from the user to the board coordinate system. */ - public double user_to_board(double p_value) - { - return Unit.scale(p_value / scale_factor, user_unit, board_unit) ; + public double user_to_board(double p_value) { + return Unit.scale(p_value / scale_factor, user_unit, board_unit); } - - + /** * Transforms a geometry.planar.FloatPoint from the board coordinate space * to the user coordinate space. */ - public FloatPoint board_to_user(FloatPoint p_point) - { - return new FloatPoint(board_to_user(p_point.x), board_to_user(p_point.y)); + public FloatPoint board_to_user(FloatPoint p_point) { + return new FloatPoint(board_to_user(p_point.x), board_to_user(p_point.y)); } - + /** * Transforms a geometry.planar.FloatPoint from the user coordinate space. * to the board coordinate space. */ - public FloatPoint user_to_board(FloatPoint p_point) - { - return new FloatPoint(user_to_board(p_point.x), user_to_board(p_point.y)); + public FloatPoint user_to_board(FloatPoint p_point) { + return new FloatPoint(user_to_board(p_point.x), user_to_board(p_point.y)); } - - public PrintableShape board_to_user(net.freerouting.geometry.planar.Shape p_shape, java.util.Locale p_locale) - { + + public PrintableShape board_to_user(net.freerouting.geometry.planar.Shape p_shape, java.util.Locale p_locale) { PrintableShape result; - if (p_shape instanceof net.freerouting.geometry.planar.Circle) - { + if (p_shape instanceof net.freerouting.geometry.planar.Circle) { result = board_to_user((net.freerouting.geometry.planar.Circle) p_shape, p_locale); - } - else if (p_shape instanceof net.freerouting.geometry.planar.IntBox) - { + } else if (p_shape instanceof net.freerouting.geometry.planar.IntBox) { result = board_to_user((net.freerouting.geometry.planar.IntBox) p_shape, p_locale); - } - else if (p_shape instanceof net.freerouting.geometry.planar.PolylineShape) - { - result = board_to_user((net.freerouting.geometry.planar.PolylineShape) p_shape, p_locale); - } - else - { + } else if (p_shape instanceof net.freerouting.geometry.planar.PolylineShape) { + result = board_to_user((net.freerouting.geometry.planar.PolylineShape) p_shape, p_locale); + } else { System.out.println("CoordinateTransform.board_to_user not yet implemented for p_shape"); result = null; } return result; } - - public PrintableShape.Circle board_to_user(net.freerouting.geometry.planar.Circle p_circle, java.util.Locale p_locale) - { + + public PrintableShape.Circle board_to_user(net.freerouting.geometry.planar.Circle p_circle, java.util.Locale p_locale) { return new PrintableShape.Circle(board_to_user(p_circle.center.to_float()), board_to_user(p_circle.radius), p_locale); } - - public PrintableShape.Rectangle board_to_user(net.freerouting.geometry.planar.IntBox p_box, java.util.Locale p_locale) - { + + public PrintableShape.Rectangle board_to_user(net.freerouting.geometry.planar.IntBox p_box, java.util.Locale p_locale) { return new PrintableShape.Rectangle(board_to_user(p_box.ll.to_float()), board_to_user(p_box.ur.to_float()), p_locale); } - - public PrintableShape.Polygon board_to_user(net.freerouting.geometry.planar.PolylineShape p_shape, java.util.Locale p_locale) - { + + public PrintableShape.Polygon board_to_user(net.freerouting.geometry.planar.PolylineShape p_shape, java.util.Locale p_locale) { FloatPoint[] corners = p_shape.corner_approx_arr(); FloatPoint[] transformed_corners = new FloatPoint[corners.length]; - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { transformed_corners[i] = board_to_user(corners[i]); } return new PrintableShape.Polygon(transformed_corners, p_locale); } - - /** The unit used for user coordinates */ - public final Unit user_unit; - - - /** The factor of the user unit */ - public final double user_unit_factor; - - /** The unit used for board coordinates */ - public final Unit board_unit; - - /** The factor of the board unit */ - public final double board_unit_factor; - - /** The factor used for transforming coordinates between user coordinate space and board coordinate space */ - private final double scale_factor; - + } diff --git a/src/main/java/net/freerouting/board/DrillItem.java b/src/main/java/net/freerouting/board/DrillItem.java index 0e9b809f..8bd2cdba 100644 --- a/src/main/java/net/freerouting/board/DrillItem.java +++ b/src/main/java/net/freerouting/board/DrillItem.java @@ -21,89 +21,88 @@ package net.freerouting.board; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Shape; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.*; +import net.freerouting.library.Padstack; import java.util.Collection; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; -import net.freerouting.library.Padstack; - /** * Common superclass for Pins and Vias * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public abstract class DrillItem extends Item implements Connectable, java.io.Serializable -{ - - public DrillItem( Point p_center, int[] p_net_no_arr, int p_clearance_type, int p_id_no, - int p_group_no, FixedState p_fixed_state, BasicBoard p_board) - { +public abstract class DrillItem extends Item implements Connectable, java.io.Serializable { + + /** + * The center point of the drillitem + */ + private Point center; + /** + * Contains the precalculated mininal width of the shapes of this DrillItem on all layers. + * If < 0, the value is not yet calculated + */ + private double precalculated_min_width = -1; + /** + * Contains the precalculated first layer, where this DrillItem contains a pad shape. + * If < 0, the value is not yet calculated + */ + private int precalculated_first_layer = -1; + /** + * Contains the precalculated last layer, where this DrillItem contains a pad shape. + * If < 0, the value is not yet calculated + */ + private int precalculated_last_layer = -1; + + public DrillItem(Point p_center, int[] p_net_no_arr, int p_clearance_type, int p_id_no, + int p_group_no, FixedState p_fixed_state, BasicBoard p_board) { super(p_net_no_arr, p_clearance_type, p_id_no, p_group_no, p_fixed_state, p_board); this.center = p_center; } - + /** * Works only for symmettric DrillItems */ - public void translate_by(Vector p_vector) - { - if (center != null) - { - center = center.translate_by(p_vector); + public void translate_by(Vector p_vector) { + if (center != null) { + center = center.translate_by(p_vector); } this.clear_derived_data(); } - - - public void turn_90_degree(int p_factor, IntPoint p_pole) - { - if (center != null) - { - center = center.turn_90_degree(p_factor, p_pole); + + public void turn_90_degree(int p_factor, IntPoint p_pole) { + if (center != null) { + center = center.turn_90_degree(p_factor, p_pole); } this.clear_derived_data(); } - - public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) - { - if (center != null) - { - FloatPoint new_center = center.to_float().rotate(Math.toRadians(p_angle_in_degree), p_pole); + + public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) { + if (center != null) { + FloatPoint new_center = center.to_float().rotate(Math.toRadians(p_angle_in_degree), p_pole); this.center = new_center.round(); } this.clear_derived_data(); } - - public void change_placement_side(IntPoint p_pole) - { - if (center != null) - { - center = center.mirror_vertical(p_pole); + + public void change_placement_side(IntPoint p_pole) { + if (center != null) { + center = center.mirror_vertical(p_pole); } this.clear_derived_data(); } - - public void move_by(Vector p_vector) - { + + public void move_by(Vector p_vector) { Point old_center = this.get_center(); // remember the contact situation of this drillitem to traces on each layer Set contact_trace_info = new TreeSet(); Collection contacts = this.get_normal_contacts(); Iterator it = contacts.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_contact = it.next(); - if (curr_contact instanceof Trace) - { + if (curr_contact instanceof Trace) { Trace curr_trace = (Trace) curr_contact; TraceInfo curr_trace_info = new TraceInfo(curr_trace.get_layer(), curr_trace.get_half_width(), curr_trace.clearance_class_no()); @@ -111,234 +110,187 @@ public void move_by(Vector p_vector) } } super.move_by(p_vector); - + // Insert a Trace from the old center to the new center, on all layers, where // this DrillItem was connected to a Trace. Collection connect_point_list = new java.util.LinkedList(); connect_point_list.add(old_center); Point new_center = this.get_center(); IntPoint add_corner = null; - if (old_center instanceof IntPoint && new_center instanceof IntPoint) - { + if (old_center instanceof IntPoint && new_center instanceof IntPoint) { // Make shure, that the traces will remain 90- or 45-degree. - if (board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { - add_corner = ((IntPoint)old_center).ninety_degree_corner((IntPoint)new_center, true); - } - else if (board.rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) - { - add_corner = ((IntPoint)old_center).fortyfive_degree_corner((IntPoint)new_center, true); + if (board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { + add_corner = ((IntPoint) old_center).ninety_degree_corner((IntPoint) new_center, true); + } else if (board.rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) { + add_corner = ((IntPoint) old_center).fortyfive_degree_corner((IntPoint) new_center, true); } } - if (add_corner != null) - { + if (add_corner != null) { connect_point_list.add(add_corner); } connect_point_list.add(new_center); Point[] connect_points = new Point[connect_point_list.size()]; Iterator it3 = connect_point_list.iterator(); - for (int i = 0 ; i < connect_points.length; ++i) - { + for (int i = 0; i < connect_points.length; ++i) { connect_points[i] = it3.next(); } Iterator it2 = contact_trace_info.iterator(); - while (it2.hasNext()) - { + while (it2.hasNext()) { TraceInfo curr_trace_info = it2.next(); board.insert_trace(connect_points, curr_trace_info.layer, curr_trace_info.half_width, this.net_no_arr, curr_trace_info.clearance_type, FixedState.UNFIXED); } } - - public int shape_layer(int p_index) - { - int index = Math.max( p_index, 0); + + public int shape_layer(int p_index) { + int index = Math.max(p_index, 0); int from_layer = first_layer(); int to_layer = last_layer(); index = Math.min(index, to_layer - from_layer); return from_layer + index; } - - public boolean is_on_layer(int p_layer) - { - return p_layer >= first_layer() && p_layer <= last_layer(); + + public boolean is_on_layer(int p_layer) { + return p_layer >= first_layer() && p_layer <= last_layer(); } - - - public int first_layer() - { - if (this.precalculated_first_layer < 0) - { + + public int first_layer() { + if (this.precalculated_first_layer < 0) { Padstack padstack = get_padstack(); - if (this.is_placed_on_front() || padstack.placed_absolute) - { - this.precalculated_first_layer = padstack.from_layer(); - } - else - { + if (this.is_placed_on_front() || padstack.placed_absolute) { + this.precalculated_first_layer = padstack.from_layer(); + } else { this.precalculated_first_layer = padstack.board_layer_count() - padstack.to_layer() - 1; } } return this.precalculated_first_layer; } - - public int last_layer() - { - if (this.precalculated_last_layer < 0) - { + + public int last_layer() { + if (this.precalculated_last_layer < 0) { Padstack padstack = get_padstack(); - if (this.is_placed_on_front()|| padstack.placed_absolute) - { - this.precalculated_last_layer = padstack.to_layer(); - } - else - { + if (this.is_placed_on_front() || padstack.placed_absolute) { + this.precalculated_last_layer = padstack.to_layer(); + } else { this.precalculated_last_layer = padstack.board_layer_count() - padstack.from_layer() - 1; } } return this.precalculated_last_layer; } - + public abstract Shape get_shape(int p_index); - - public IntBox bounding_box() - { + + public IntBox bounding_box() { IntBox result = IntBox.EMPTY; - for (int i = 0; i < tile_shape_count(); ++i) - { + for (int i = 0; i < tile_shape_count(); ++i) { Shape curr_shape = this.get_shape(i); - if (curr_shape != null) - { + if (curr_shape != null) { result = result.union(curr_shape.bounding_box()); } } return result; } - - public int tile_shape_count() - { + + public int tile_shape_count() { Padstack padstack = get_padstack(); int from_layer = padstack.from_layer(); int to_layer = padstack.to_layer(); return to_layer - from_layer + 1; } - - protected TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) - { + + protected TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) { return p_search_tree.calculate_tree_shapes(this); } - + /** * Returns the smallest distance from the center to the border of * the shape on any layer. */ - public double smallest_radius() - { + public double smallest_radius() { double result = Double.MAX_VALUE; FloatPoint c = get_center().to_float(); - for (int i = 0; i < tile_shape_count(); ++i) - { + for (int i = 0; i < tile_shape_count(); ++i) { Shape curr_shape = get_shape(i); - if (curr_shape != null) - { + if (curr_shape != null) { result = Math.min(result, curr_shape.border_distance(c)); } } return result; } - - - /** Returns the center point of this DrillItem. */ - public Point get_center() - { + + /** + * Returns the center point of this DrillItem. + */ + public Point get_center() { return center; } - - protected void set_center(Point p_center) - { + + protected void set_center(Point p_center) { center = p_center; } - + /** * Returns the padstack of this drillitem. */ public abstract Padstack get_padstack(); - - public TileShape get_tree_shape_on_layer(ShapeSearchTree p_tree, int p_layer) - { + + public TileShape get_tree_shape_on_layer(ShapeSearchTree p_tree, int p_layer) { int from_layer = first_layer(); int to_layer = last_layer(); - if (p_layer < from_layer || p_layer > to_layer) - { + if (p_layer < from_layer || p_layer > to_layer) { System.out.println("DrillItem.get_tree_shape_on_layer: p_layer out of range"); return null; } return get_tree_shape(p_tree, p_layer - from_layer); } - - public TileShape get_tile_shape_on_layer(int p_layer) - { + + public TileShape get_tile_shape_on_layer(int p_layer) { int from_layer = first_layer(); int to_layer = last_layer(); - if (p_layer < from_layer || p_layer > to_layer) - { + if (p_layer < from_layer || p_layer > to_layer) { System.out.println("DrillItem.get_tile_shape_on_layer: p_layer out of range"); return null; } return get_tile_shape(p_layer - from_layer); } - - public Shape get_shape_on_layer(int p_layer) - { + + public Shape get_shape_on_layer(int p_layer) { int from_layer = first_layer(); int to_layer = last_layer(); - if (p_layer < from_layer || p_layer > to_layer) - { + if (p_layer < from_layer || p_layer > to_layer) { System.out.println("DrillItem.get_shape_on_layer: p_layer out of range"); return null; } return get_shape(p_layer - from_layer); } - - public Set get_normal_contacts() - { + + public Set get_normal_contacts() { Point drill_center = this.get_center(); TileShape search_shape = TileShape.get_instance(drill_center); Set overlaps = board.overlapping_objects(search_shape, -1); Iterator it = overlaps.iterator(); Set result = new TreeSet(); - while(it.hasNext()) - { + while (it.hasNext()) { SearchTreeObject curr_ob = it.next(); - if (!(curr_ob instanceof Item)) - { + if (!(curr_ob instanceof Item)) { continue; } Item curr_item = (Item) curr_ob; - if (curr_item != this && curr_item.shares_net(this) && curr_item.shares_layer(this)) - { - if (curr_item instanceof Trace) - { + if (curr_item != this && curr_item.shares_net(this) && curr_item.shares_layer(this)) { + if (curr_item instanceof Trace) { Trace curr_trace = (Trace) curr_item; - if(drill_center.equals(curr_trace.first_corner()) - || drill_center.equals(curr_trace.last_corner())) - { + if (drill_center.equals(curr_trace.first_corner()) + || drill_center.equals(curr_trace.last_corner())) { result.add(curr_item); } - } - else if (curr_item instanceof DrillItem) - { + } else if (curr_item instanceof DrillItem) { DrillItem curr_drill_item = (DrillItem) curr_item; - if (drill_center.equals(curr_drill_item.get_center())) - { + if (drill_center.equals(curr_drill_item.get_center())) { result.add(curr_item); } - } - else if (curr_item instanceof ConductionArea) - { + } else if (curr_item instanceof ConductionArea) { ConductionArea curr_area = (ConductionArea) curr_item; - if (curr_area.get_area().contains(drill_center)) - { + if (curr_area.get_area().contains(drill_center)) { result.add(curr_item); } } @@ -346,72 +298,60 @@ else if (curr_item instanceof ConductionArea) } return result; } - - public Point normal_contact_point(Item p_other) - { + + public Point normal_contact_point(Item p_other) { return p_other.normal_contact_point(this); } - - Point normal_contact_point(DrillItem p_other) - { - if (this.shares_layer(p_other) && this.get_center().equals(p_other.get_center())) - { + + Point normal_contact_point(DrillItem p_other) { + if (this.shares_layer(p_other) && this.get_center().equals(p_other.get_center())) { return this.get_center(); } return null; } - - Point normal_contact_point(Trace p_trace) - { - if (!this.shares_layer(p_trace)) - { + + Point normal_contact_point(Trace p_trace) { + if (!this.shares_layer(p_trace)) { return null; } Point drill_center = this.get_center(); - if (drill_center.equals(p_trace.first_corner()) || drill_center.equals(p_trace.last_corner())) - { + if (drill_center.equals(p_trace.first_corner()) || drill_center.equals(p_trace.last_corner())) { return drill_center; } return null; } - - public Point[] get_ratsnest_corners() - { + + public Point[] get_ratsnest_corners() { Point[] result = new Point[1]; result[0] = this.get_center(); return result; } - - public TileShape get_trace_connection_shape(ShapeSearchTree p_search_tree, int p_index) - { + + public TileShape get_trace_connection_shape(ShapeSearchTree p_search_tree, int p_index) { return TileShape.get_instance(this.get_center()); } - - /** False, if this drillitem is places on the back side of the board */ - public boolean is_placed_on_front() - { + + /** + * False, if this drillitem is places on the back side of the board + */ + public boolean is_placed_on_front() { return true; } - + /** * Return the mininal width of the shapes of this DrillItem on all signal layers. */ - public double min_width() - { - if (this.precalculated_min_width < 0) - { + public double min_width() { + if (this.precalculated_min_width < 0) { double min_width = Integer.MAX_VALUE; int begin_layer = this.first_layer(); int end_layer = this.last_layer(); - for (int curr_layer = begin_layer; curr_layer <= end_layer; ++curr_layer ) - { - if(this.board != null && !this.board.layer_structure.arr[curr_layer].is_signal) - { + for (int curr_layer = begin_layer; curr_layer <= end_layer; ++curr_layer) { + if (this.board != null && !this.board.layer_structure.arr[curr_layer].is_signal) { continue; } Shape curr_shape = this.get_shape_on_layer(curr_layer); - if (curr_shape != null) - { + if (curr_shape != null) { IntBox curr_bounding_box = curr_shape.bounding_box(); min_width = Math.min(min_width, curr_bounding_box.width()); min_width = Math.min(min_width, curr_bounding_box.height()); @@ -421,45 +361,37 @@ public double min_width() } return this.precalculated_min_width; } - - public void clear_derived_data() - { - super.clear_derived_data(); - this.precalculated_first_layer = -1; - this.precalculated_last_layer = -1; + + public void clear_derived_data() { + super.clear_derived_data(); + this.precalculated_first_layer = -1; + this.precalculated_last_layer = -1; } - - public int get_draw_priority() - { + + public int get_draw_priority() { return net.freerouting.boardgraphics.Drawable.MIDDLE_DRAW_PRIORITY; } - + public void draw(java.awt.Graphics p_g, net.freerouting.boardgraphics.GraphicsContext p_graphics_context, - java.awt.Color[] p_color_arr, double p_intensity) - { - if (p_graphics_context == null|| p_intensity <= 0) - { + java.awt.Color[] p_color_arr, double p_intensity) { + if (p_graphics_context == null || p_intensity <= 0) { return; } int from_layer = first_layer(); int to_layer = last_layer(); // Decrease the drawing intensity for items with many layers. double visibility_factor = 0; - for (int i = from_layer; i <= to_layer; ++i) - { + for (int i = from_layer; i <= to_layer; ++i) { visibility_factor += p_graphics_context.get_layer_visibility(i); } - - if (visibility_factor < 0.001) - { + + if (visibility_factor < 0.001) { return; } double intensity = p_intensity / Math.max(visibility_factor, 1); - for (int i = 0; i <= to_layer - from_layer; ++i) - { + for (int i = 0; i <= to_layer - from_layer; ++i) { Shape curr_shape = this.get_shape(i); - if (curr_shape == null) - { + if (curr_shape == null) { continue; } java.awt.Color color = p_color_arr[from_layer + i]; @@ -467,50 +399,25 @@ public void draw(java.awt.Graphics p_g, net.freerouting.boardgraphics.GraphicsCo p_graphics_context.fill_area(curr_shape, p_g, color, layer_intensity); } } - - /** The center point of the drillitem */ - private Point center; - - /** - * Contains the precalculated mininal width of the shapes of this DrillItem on all layers. - * If < 0, the value is not yet calculated - */ - private double precalculated_min_width = -1; - - /** - * Contains the precalculated first layer, where this DrillItem contains a pad shape. - * If < 0, the value is not yet calculated - */ - private int precalculated_first_layer = -1; - - /** - * Contains the precalculated last layer, where this DrillItem contains a pad shape. - * If < 0, the value is not yet calculated - */ - private int precalculated_last_layer = -1; - + /** * Auxiliary class used in the method move_by */ - private static class TraceInfo implements Comparable - { - TraceInfo(int p_layer, int p_half_width, int p_clearance_type) - { + private static class TraceInfo implements Comparable { + int layer; + int half_width; + int clearance_type; + TraceInfo(int p_layer, int p_half_width, int p_clearance_type) { layer = p_layer; half_width = p_half_width; clearance_type = p_clearance_type; } - + /** * Implements the comparable interface. */ - public int compareTo(TraceInfo p_other) - { + public int compareTo(TraceInfo p_other) { return p_other.layer - this.layer; } - - int layer; - int half_width; - int clearance_type; } } diff --git a/src/main/java/net/freerouting/board/FixedState.java b/src/main/java/net/freerouting/board/FixedState.java index b7d3b8fb..722135da 100644 --- a/src/main/java/net/freerouting/board/FixedState.java +++ b/src/main/java/net/freerouting/board/FixedState.java @@ -25,7 +25,6 @@ * * @author alfons */ -public enum FixedState -{ +public enum FixedState { UNFIXED, SHOVE_FIXED, USER_FIXED, SYSTEM_FIXED } diff --git a/src/main/java/net/freerouting/board/ForcedPadAlgo.java b/src/main/java/net/freerouting/board/ForcedPadAlgo.java index a9c9e816..1680f9ea 100644 --- a/src/main/java/net/freerouting/board/ForcedPadAlgo.java +++ b/src/main/java/net/freerouting/board/ForcedPadAlgo.java @@ -21,17 +21,7 @@ package net.freerouting.board; import net.freerouting.datastructures.TimeLimit; - -import net.freerouting.geometry.planar.Direction; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.IntOctagon; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.*; import java.util.Collection; @@ -39,17 +29,180 @@ * Class with functions for checking and inserting pads with eventually * shoving aside obstacle traces. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class ForcedPadAlgo -{ - - /** Creates a new instance of ForcedPadAlgo */ - public ForcedPadAlgo(RoutingBoard p_board) - { +public class ForcedPadAlgo { + + private final RoutingBoard board; + + /** + * Creates a new instance of ForcedPadAlgo + */ + public ForcedPadAlgo(RoutingBoard p_board) { board = p_board; } - + + private static TileShape calc_check_chape_for_from_side(TileShape p_shape, + Point p_shape_center, Line p_border_line) { + FloatPoint shape_center = p_shape_center.to_float(); + FloatPoint offset_projection = shape_center.projection_approx(p_border_line); + // Make shure, that direction restrictions are retained. + Line[] line_arr = new Line[3]; + Direction curr_dir = p_border_line.direction(); + line_arr[0] = new Line(p_shape_center, curr_dir); + line_arr[1] = new Line(p_shape_center, curr_dir.turn_45_degree(2)); + line_arr[2] = new Line(offset_projection.round(), curr_dir); + Polyline check_line = new Polyline(line_arr); + return check_line.offset_shape(1, 0); + } + + /** + * Checks, if p_line is in frone of p_pad_shape when shoving from p_from_side + */ + private static boolean in_front_of_pad(Line p_line, TileShape p_pad_shape, int p_from_side, + int p_width, boolean p_with_sides) { + if (!p_pad_shape.is_IntOctagon()) { + // only implemented for octagons + return true; + } + IntOctagon pad_octagon = p_pad_shape.bounding_octagon(); + if (!(p_line.a instanceof IntPoint && p_line.b instanceof IntPoint)) { + // not implemented + return true; + } + IntPoint line_a = (IntPoint) p_line.a; + IntPoint line_b = (IntPoint) p_line.b; + + double diag_width = p_width * Math.sqrt(2); + + boolean result; + switch (p_from_side) { + case 0: + result = Math.min(line_a.y, line_b.y) >= pad_octagon.uy + p_width || + Math.max(line_a.x - line_a.y, line_b.x - line_b.y) + <= pad_octagon.ulx - diag_width || + Math.min(line_a.x + line_a.y, line_b.x + line_b.x) + >= pad_octagon.urx + diag_width; + if (p_with_sides && !result) { + result = Math.max(line_a.x, line_b.x) <= pad_octagon.lx - p_width + && Math.min(line_a.x - line_a.y, line_b.x - line_b.y) + <= pad_octagon.ulx - diag_width || + Math.min(line_a.x, line_b.x) >= pad_octagon.rx + p_width && + Math.min(line_a.x + line_a.y, line_b.x + line_b.y) + >= pad_octagon.urx + diag_width; + } + break; + case 1: + result = Math.min(line_a.y, line_b.y) >= pad_octagon.uy + p_width || + Math.max(line_a.x - line_a.y, line_b.x - line_b.y) + <= pad_octagon.ulx - diag_width || + Math.max(line_a.x, line_b.x) <= pad_octagon.lx - p_width; + if (p_with_sides && !result) { + result = Math.min(line_a.x, line_b.x) <= pad_octagon.lx - p_width + && Math.max(line_a.x + line_a.y, line_b.x + line_b.y) + <= pad_octagon.llx - diag_width || + Math.max(line_a.y, line_b.y) >= pad_octagon.uy + p_width && + Math.min(line_a.x + line_a.y, line_b.x + line_b.y) + >= pad_octagon.urx + diag_width; + } + break; + case 2: + result = Math.max(line_a.x, line_b.x) <= pad_octagon.lx - p_width || + Math.max(line_a.x - line_a.y, line_b.x - line_b.y) + <= pad_octagon.ulx - diag_width || + Math.max(line_a.x + line_a.y, line_b.x + line_b.y) + <= pad_octagon.llx - diag_width; + if (p_with_sides && !result) { + result = Math.max(line_a.y, line_b.y) <= pad_octagon.ly - p_width + && Math.min(line_a.x + line_a.y, line_b.x + line_b.y) + <= pad_octagon.llx - diag_width || + Math.min(line_a.y, line_b.y) >= pad_octagon.uy + p_width && + Math.min(line_a.x - line_a.y, line_b.x - line_b.y) + <= pad_octagon.ulx - diag_width; + + } + break; + case 3: + result = Math.max(line_a.x, line_b.x) <= pad_octagon.lx - p_width || + Math.max(line_a.y, line_b.y) <= pad_octagon.ly - p_width || + Math.max(line_a.x + line_a.y, line_b.x + line_b.y) + <= pad_octagon.llx - diag_width; + if (p_with_sides && !result) { + result = Math.min(line_a.y, line_b.y) <= pad_octagon.ly - p_width + && Math.min(line_a.x - line_a.y, line_b.x - line_b.y) + >= pad_octagon.lrx + diag_width || + Math.min(line_a.x, line_b.x) <= pad_octagon.lx - p_width + && Math.max(line_a.x - line_a.y, line_b.x - line_b.y) + <= pad_octagon.ulx - diag_width; + } + break; + case 4: + result = Math.max(line_a.y, line_b.y) <= pad_octagon.ly - p_width || + Math.max(line_a.x + line_a.y, line_b.x + line_b.y) + <= pad_octagon.llx - diag_width || + Math.min(line_a.x - line_a.y, line_b.x - line_b.y) + >= pad_octagon.lrx + diag_width; + if (p_with_sides && !result) { + result = Math.min(line_a.x, line_b.x) >= pad_octagon.rx + p_width + && Math.max(line_a.x - line_a.y, line_b.x - line_b.y) + >= pad_octagon.lrx + diag_width || + Math.max(line_a.x, line_b.x) <= pad_octagon.lx - p_width && + Math.min(line_a.x + line_a.y, line_b.x + line_b.y) + <= pad_octagon.llx - diag_width; + } + break; + case 5: + result = Math.max(line_a.y, line_b.y) <= pad_octagon.ly - p_width || + Math.min(line_a.x, line_b.x) >= pad_octagon.rx + p_width || + Math.min(line_a.x - line_a.y, line_b.x - line_b.y) + >= pad_octagon.lrx + diag_width; + if (p_with_sides && !result) { + result = Math.max(line_a.x, line_b.x) >= pad_octagon.rx + p_width + && Math.min(line_a.x + line_a.y, line_b.x + line_b.y) + >= pad_octagon.urx + diag_width || + Math.min(line_a.y, line_b.y) <= pad_octagon.ly - p_width && + Math.max(line_a.x + line_a.y, line_b.x + line_b.y) + <= pad_octagon.llx - diag_width; + } + break; + case 6: + result = Math.min(line_a.x, line_b.x) >= pad_octagon.rx + p_width || + Math.min(line_a.x + line_a.y, line_b.x + line_b.y) + >= pad_octagon.urx + diag_width || + Math.min(line_a.x - line_a.y, line_b.x - line_b.y) + >= pad_octagon.lrx + diag_width; + if (p_with_sides && !result) { + result = Math.max(line_a.y, line_b.y) <= pad_octagon.ly - p_width + && Math.max(line_a.x - line_a.y, line_b.x - line_b.y) + >= pad_octagon.lrx + diag_width || + Math.min(line_a.y, line_b.y) >= pad_octagon.uy + p_width + && Math.max(line_a.x + line_a.y, line_b.x + line_b.y) + >= pad_octagon.urx + diag_width; + } + break; + case 7: + result = Math.min(line_a.y, line_b.y) >= pad_octagon.uy + p_width || + Math.min(line_a.x + line_a.y, line_b.x + line_b.y) + >= pad_octagon.urx + diag_width || + Math.min(line_a.x, line_b.x) >= pad_octagon.rx + p_width; + if (p_with_sides && !result) { + result = Math.max(line_a.y, line_b.y) >= pad_octagon.uy + p_width + && Math.max(line_a.x - line_a.y, line_b.x - line_b.y) + <= pad_octagon.ulx - diag_width || + Math.max(line_a.x, line_b.x) >= pad_octagon.rx + p_width + && Math.min(line_a.x - line_a.y, line_b.x - line_b.y) + >= pad_octagon.lrx + diag_width; + } + break; + default: { + System.out.println("ForcedPadAlgo.in_front_of_pad: p_from_side out of range"); + result = true; + } + } + + return result; + } + /** * Checks, if possible obstacle traces can be shoved aside, so that a * pad with the input parameters can be inserted without clearance violations. @@ -59,11 +212,9 @@ public ForcedPadAlgo(RoutingBoard p_board) * for performance reasons. This is the cave when moving drill_items */ public CheckDrillResult check_forced_pad(TileShape p_pad_shape, CalcFromSide p_from_side, int p_layer, int[] p_net_no_arr, - int p_cl_type, boolean p_copper_sharing_allowed, Collection p_ignore_items, int p_max_recursion_depth, int p_max_via_recursion_depth, - boolean p_check_only_front, TimeLimit p_time_limit) - { - if (!p_pad_shape.is_contained_in(board.get_bounding_box())) - { + int p_cl_type, boolean p_copper_sharing_allowed, Collection p_ignore_items, int p_max_recursion_depth, int p_max_via_recursion_depth, + boolean p_check_only_front, TimeLimit p_time_limit) { + if (!p_pad_shape.is_contained_in(board.get_bounding_box())) { this.board.set_shove_failing_obstacle(board.get_outline()); return CheckDrillResult.NOT_DRILLABLE; } @@ -71,32 +222,27 @@ public CheckDrillResult check_forced_pad(TileShape p_pad_shape, CalcFromSide p_f ShapeTraceEntries shape_entries = new ShapeTraceEntries(p_pad_shape, p_layer, p_net_no_arr, p_cl_type, p_from_side, board); Collection obstacles = search_tree.overlapping_items_with_clearance(p_pad_shape, p_layer, new int[0], p_cl_type); - - if (p_ignore_items != null) - { + + if (p_ignore_items != null) { obstacles.removeAll(p_ignore_items); } boolean obstacles_shovable = shape_entries.store_items(obstacles, true, p_copper_sharing_allowed); - if (!obstacles_shovable) - { + if (!obstacles_shovable) { this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); return CheckDrillResult.NOT_DRILLABLE; } - + // check, if the obstacle vias can be shoved - - for (Via curr_shove_via : shape_entries.shove_via_list) - { - if (p_max_via_recursion_depth <= 0) - { + + for (Via curr_shove_via : shape_entries.shove_via_list) { + if (p_max_via_recursion_depth <= 0) { this.board.set_shove_failing_obstacle(curr_shove_via); return CheckDrillResult.NOT_DRILLABLE; } - IntPoint [] new_via_center = + IntPoint[] new_via_center = MoveDrillItemAlgo.try_shove_via_points(p_pad_shape, p_layer, curr_shove_via, p_cl_type, false, board); - - if (new_via_center.length <= 0) - { + + if (new_via_center.length <= 0) { this.board.set_shove_failing_obstacle(curr_shove_via); return CheckDrillResult.NOT_DRILLABLE; } @@ -104,69 +250,54 @@ public CheckDrillResult check_forced_pad(TileShape p_pad_shape, CalcFromSide p_f Collection ignore_items = new java.util.LinkedList(); if (!MoveDrillItemAlgo.check(curr_shove_via, delta, p_max_recursion_depth, p_max_via_recursion_depth - 1, ignore_items, - this.board, p_time_limit)) - { + this.board, p_time_limit)) { return CheckDrillResult.NOT_DRILLABLE; } } CheckDrillResult result = CheckDrillResult.DRILLABLE; - if (p_copper_sharing_allowed) - { - for (Item curr_obstacle : obstacles) - { - if (curr_obstacle instanceof Pin) - { + if (p_copper_sharing_allowed) { + for (Item curr_obstacle : obstacles) { + if (curr_obstacle instanceof Pin) { result = CheckDrillResult.DRILLABLE_WITH_ATTACH_SMD; break; } } } int trace_piece_count = shape_entries.substitute_trace_count(); - if (trace_piece_count == 0) - { + if (trace_piece_count == 0) { return result; } - if (p_max_recursion_depth <= 0) - { + if (p_max_recursion_depth <= 0) { this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); return CheckDrillResult.NOT_DRILLABLE; } - if (shape_entries.stack_depth() > 1) - { + if (shape_entries.stack_depth() > 1) { this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); return CheckDrillResult.NOT_DRILLABLE; } ShoveTraceAlgo shove_trace_algo = new ShoveTraceAlgo(board); boolean is_orthogonal_mode = p_pad_shape instanceof IntBox; - for (;;) - { + for (; ; ) { PolylineTrace curr_substitute_trace = shape_entries.next_substitute_trace_piece(); - if (curr_substitute_trace == null) - { + if (curr_substitute_trace == null) { break; } - for (int i = 0; i < curr_substitute_trace.tile_shape_count(); ++i) - { + for (int i = 0; i < curr_substitute_trace.tile_shape_count(); ++i) { Line curr_line = curr_substitute_trace.polyline().arr[i + 1]; Direction curr_dir = curr_line.direction(); boolean is_in_front; - if (p_check_only_front) - { + if (p_check_only_front) { is_in_front = in_front_of_pad(curr_line, p_pad_shape, p_from_side.no, curr_substitute_trace.get_half_width(), true); - } - else - { + } else { is_in_front = true; } - if (is_in_front) - { + if (is_in_front) { CalcShapeAndFromSide curr = new CalcShapeAndFromSide(curr_substitute_trace, i, is_orthogonal_mode, true); if (!shove_trace_algo.check(curr.shape, curr.from_side, curr_dir, p_layer, curr_substitute_trace.net_no_arr, curr_substitute_trace.clearance_class_no(), - p_max_recursion_depth - 1, p_max_via_recursion_depth, 0, p_time_limit)) - { + p_max_recursion_depth - 1, p_max_via_recursion_depth, 0, p_time_limit)) { return CheckDrillResult.NOT_DRILLABLE; } } @@ -174,7 +305,7 @@ public CheckDrillResult check_forced_pad(TileShape p_pad_shape, CalcFromSide p_f } return result; } - + /** * Shoves aside traces, so that a pad with the input parameters can be * inserted without clearance violations. Returns false, if the shove @@ -182,46 +313,38 @@ public CheckDrillResult check_forced_pad(TileShape p_pad_shape, CalcFromSide p_f * becomes necessesary. */ boolean forced_pad(TileShape p_pad_shape, CalcFromSide p_from_side, - int p_layer, int[] p_net_no_arr, int p_cl_type, boolean p_copper_sharing_allowed, Collection p_ignore_items, int p_max_recursion_depth, int p_max_via_recursion_depth) - { - if (p_pad_shape.is_empty()) - { + int p_layer, int[] p_net_no_arr, int p_cl_type, boolean p_copper_sharing_allowed, Collection p_ignore_items, int p_max_recursion_depth, int p_max_via_recursion_depth) { + if (p_pad_shape.is_empty()) { System.out.println("ShoveTraceAux.forced_pad: p_pad_shape is empty"); return true; } - if (!p_pad_shape.is_contained_in(board.get_bounding_box())) - { + if (!p_pad_shape.is_contained_in(board.get_bounding_box())) { this.board.set_shove_failing_obstacle(board.get_outline()); return false; } if (!MoveDrillItemAlgo.shove_vias(p_pad_shape, p_from_side, p_layer, p_net_no_arr, p_cl_type, - p_ignore_items, p_max_recursion_depth, p_max_via_recursion_depth, false, this.board)) - { + p_ignore_items, p_max_recursion_depth, p_max_via_recursion_depth, false, this.board)) { return false; } ShapeSearchTree search_tree = this.board.search_tree_manager.get_default_tree(); ShapeTraceEntries shape_entries = new ShapeTraceEntries(p_pad_shape, p_layer, p_net_no_arr, p_cl_type, p_from_side, board); Collection obstacles = search_tree.overlapping_items_with_clearance(p_pad_shape, p_layer, new int[0], p_cl_type); - if (p_ignore_items != null) - { + if (p_ignore_items != null) { obstacles.removeAll(p_ignore_items); } boolean obstacles_shovable = shape_entries.store_items(obstacles, true, p_copper_sharing_allowed) - && shape_entries.shove_via_list.isEmpty(); - if (!obstacles_shovable) - { + && shape_entries.shove_via_list.isEmpty(); + if (!obstacles_shovable) { this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); return false; } int trace_piece_count = shape_entries.substitute_trace_count(); - if (trace_piece_count == 0) - { + if (trace_piece_count == 0) { return true; } - if (p_max_recursion_depth <= 0) - { + if (p_max_recursion_depth <= 0) { this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); return false; } @@ -229,63 +352,49 @@ boolean forced_pad(TileShape p_pad_shape, CalcFromSide p_from_side, shape_entries.cutout_traces(obstacles); boolean is_orthogonal_mode = p_pad_shape instanceof IntBox; ShoveTraceAlgo shove_trace_algo = new ShoveTraceAlgo(this.board); - for (;;) - { + for (; ; ) { PolylineTrace curr_substitute_trace = shape_entries.next_substitute_trace_piece(); - if (curr_substitute_trace == null) - { + if (curr_substitute_trace == null) { break; } - if (curr_substitute_trace.first_corner().equals(curr_substitute_trace.last_corner())) - { + if (curr_substitute_trace.first_corner().equals(curr_substitute_trace.last_corner())) { continue; } int[] curr_net_no_arr = curr_substitute_trace.net_no_arr; - for (int i = 0; i < curr_substitute_trace.tile_shape_count(); ++i) - { + for (int i = 0; i < curr_substitute_trace.tile_shape_count(); ++i) { CalcShapeAndFromSide curr = new CalcShapeAndFromSide(curr_substitute_trace, i, is_orthogonal_mode, false); if (!shove_trace_algo.insert(curr.shape, curr.from_side, p_layer, curr_net_no_arr, curr_substitute_trace.clearance_class_no(), - p_ignore_items, p_max_recursion_depth - 1, p_max_via_recursion_depth, 0)) - { + p_ignore_items, p_max_recursion_depth - 1, p_max_via_recursion_depth, 0)) { return false; } } - for (int i = 0; i < curr_substitute_trace.corner_count(); ++i) - { + for (int i = 0; i < curr_substitute_trace.corner_count(); ++i) { board.join_changed_area( curr_substitute_trace.polyline().corner_approx(i), p_layer); } - Point [] end_corners = null; - if (!tails_exist_before) - { + Point[] end_corners = null; + if (!tails_exist_before) { end_corners = new Point[2]; end_corners[0] = curr_substitute_trace.first_corner(); end_corners[1] = curr_substitute_trace.last_corner(); } board.insert_item(curr_substitute_trace); IntOctagon opt_area; - if (board.changed_area != null) - { + if (board.changed_area != null) { opt_area = board.changed_area.get_area(p_layer); - } - else - { + } else { opt_area = null; } curr_substitute_trace.normalize(opt_area); - if (!tails_exist_before) - { - for (int i = 0; i < 2; ++i) - { + if (!tails_exist_before) { + for (int i = 0; i < 2; ++i) { Trace tail = board.get_trace_tail(end_corners[i], p_layer, curr_net_no_arr); - if (tail != null) - { + if (tail != null) { board.remove_items(tail.get_connection_items(Item.StopConnectionOption.VIA), false); - for (int curr_net_no : curr_net_no_arr ) - { + for (int curr_net_no : curr_net_no_arr) { board.combine_traces(curr_net_no); } } @@ -294,218 +403,34 @@ boolean forced_pad(TileShape p_pad_shape, CalcFromSide p_from_side, } return true; } - - + /** * Looks for a side of p_shape, so that a trace line from the shape center * to the nearest point on this side does not conflict with any obstacles. */ - CalcFromSide calc_from_side(TileShape p_shape, Point p_shape_center, int p_layer, int p_offset, int p_cl_class) - { - int [] empty_arr = new int [0]; + CalcFromSide calc_from_side(TileShape p_shape, Point p_shape_center, int p_layer, int p_offset, int p_cl_class) { + int[] empty_arr = new int[0]; TileShape offset_shape = (TileShape) p_shape.offset(p_offset); - for (int i = 0; i < offset_shape.border_line_count(); ++i) - { + for (int i = 0; i < offset_shape.border_line_count(); ++i) { TileShape check_shape = calc_check_chape_for_from_side(p_shape, p_shape_center, offset_shape.border_line(i)); - - if(board.check_trace_shape(check_shape, p_layer, empty_arr, p_cl_class, null)) - { + + if (board.check_trace_shape(check_shape, p_layer, empty_arr, p_cl_class, null)) { return new CalcFromSide(i, null); } } // try second check without clearance - for (int i = 0; i < offset_shape.border_line_count(); ++i) - { + for (int i = 0; i < offset_shape.border_line_count(); ++i) { TileShape check_shape = calc_check_chape_for_from_side(p_shape, p_shape_center, offset_shape.border_line(i)); - if(board.check_trace_shape(check_shape, p_layer, empty_arr, 0, null)) - { + if (board.check_trace_shape(check_shape, p_layer, empty_arr, 0, null)) { return new CalcFromSide(i, null); } } return CalcFromSide.NOT_CALCULATED; } - - private static TileShape calc_check_chape_for_from_side(TileShape p_shape, - Point p_shape_center, Line p_border_line) - { - FloatPoint shape_center = p_shape_center.to_float(); - FloatPoint offset_projection = shape_center.projection_approx(p_border_line); - // Make shure, that direction restrictions are retained. - Line [] line_arr = new Line[3]; - Direction curr_dir = p_border_line.direction(); - line_arr[0] = new Line(p_shape_center, curr_dir); - line_arr[1] = new Line(p_shape_center, curr_dir.turn_45_degree(2)); - line_arr[2] = new Line(offset_projection.round(), curr_dir); - Polyline check_line = new Polyline(line_arr); - return check_line.offset_shape(1, 0); - } - - /** - * Checks, if p_line is in frone of p_pad_shape when shoving from p_from_side - */ - private static boolean in_front_of_pad(Line p_line, TileShape p_pad_shape, int p_from_side, - int p_width, boolean p_with_sides) - { - if (!p_pad_shape.is_IntOctagon()) - { - // only implemented for octagons - return true; - } - IntOctagon pad_octagon = p_pad_shape.bounding_octagon(); - if (!(p_line.a instanceof IntPoint && p_line.b instanceof IntPoint)) - { - // not implemented - return true; - } - IntPoint line_a = (IntPoint) p_line.a; - IntPoint line_b = (IntPoint) p_line.b; - - double diag_width = p_width * Math.sqrt(2); - - boolean result; - switch (p_from_side) - { - case 0: - result = Math.min(line_a.y, line_b.y) >= pad_octagon.uy + p_width || - Math.max(line_a.x - line_a.y, line_b.x - line_b.y) - <= pad_octagon.ulx - diag_width || - Math.min(line_a.x + line_a.y, line_b.x + line_b.x) - >= pad_octagon.urx + diag_width; - if (p_with_sides && !result) - { - result = Math.max(line_a.x, line_b.x) <= pad_octagon.lx - p_width - && Math.min(line_a.x - line_a.y, line_b.x - line_b.y) - <= pad_octagon.ulx - diag_width || - Math.min(line_a.x, line_b.x) >= pad_octagon.rx + p_width && - Math.min(line_a.x + line_a.y, line_b.x + line_b.y) - >= pad_octagon.urx + diag_width; - } - break; - case 1: - result = Math.min(line_a.y, line_b.y) >= pad_octagon.uy + p_width || - Math.max(line_a.x - line_a.y, line_b.x - line_b.y) - <= pad_octagon.ulx - diag_width || - Math.max(line_a.x, line_b.x) <= pad_octagon.lx - p_width; - if (p_with_sides && !result) - { - result = Math.min(line_a.x, line_b.x) <= pad_octagon.lx - p_width - && Math.max(line_a.x + line_a.y, line_b.x + line_b.y) - <= pad_octagon.llx - diag_width || - Math.max(line_a.y, line_b.y) >= pad_octagon.uy + p_width && - Math.min(line_a.x + line_a.y, line_b.x + line_b.y) - >= pad_octagon.urx + diag_width; - } - break; - case 2: - result = Math.max(line_a.x, line_b.x) <= pad_octagon.lx - p_width || - Math.max(line_a.x - line_a.y, line_b.x - line_b.y) - <= pad_octagon.ulx - diag_width || - Math.max(line_a.x + line_a.y, line_b.x + line_b.y) - <= pad_octagon.llx - diag_width; - if (p_with_sides && !result) - { - result = Math.max(line_a.y, line_b.y) <= pad_octagon.ly - p_width - && Math.min(line_a.x + line_a.y, line_b.x + line_b.y) - <= pad_octagon.llx - diag_width || - Math.min(line_a.y, line_b.y) >= pad_octagon.uy + p_width && - Math.min(line_a.x - line_a.y, line_b.x - line_b.y) - <= pad_octagon.ulx - diag_width; - - } - break; - case 3: - result = Math.max(line_a.x, line_b.x) <= pad_octagon.lx - p_width || - Math.max(line_a.y, line_b.y) <= pad_octagon.ly - p_width || - Math.max(line_a.x + line_a.y, line_b.x + line_b.y) - <= pad_octagon.llx - diag_width; - if (p_with_sides && !result) - { - result = Math.min(line_a.y, line_b.y) <= pad_octagon.ly - p_width - && Math.min(line_a.x - line_a.y, line_b.x - line_b.y) - >= pad_octagon.lrx + diag_width || - Math.min(line_a.x, line_b.x) <= pad_octagon.lx - p_width - && Math.max(line_a.x - line_a.y, line_b.x - line_b.y) - <= pad_octagon.ulx - diag_width; - } - break; - case 4: - result = Math.max(line_a.y, line_b.y) <= pad_octagon.ly - p_width || - Math.max(line_a.x + line_a.y, line_b.x + line_b.y) - <= pad_octagon.llx - diag_width || - Math.min(line_a.x - line_a.y, line_b.x - line_b.y) - >= pad_octagon.lrx + diag_width; - if (p_with_sides && !result) - { - result = Math.min(line_a.x, line_b.x) >= pad_octagon.rx + p_width - && Math.max(line_a.x - line_a.y, line_b.x - line_b.y) - >= pad_octagon.lrx + diag_width || - Math.max(line_a.x, line_b.x) <= pad_octagon.lx - p_width && - Math.min(line_a.x + line_a.y, line_b.x + line_b.y) - <= pad_octagon.llx - diag_width; - } - break; - case 5: - result = Math.max(line_a.y, line_b.y) <= pad_octagon.ly - p_width || - Math.min(line_a.x, line_b.x) >= pad_octagon.rx + p_width || - Math.min(line_a.x - line_a.y, line_b.x - line_b.y) - >= pad_octagon.lrx + diag_width; - if (p_with_sides && !result) - { - result = Math.max(line_a.x, line_b.x) >= pad_octagon.rx + p_width - && Math.min(line_a.x + line_a.y, line_b.x + line_b.y) - >= pad_octagon.urx + diag_width || - Math.min(line_a.y, line_b.y) <= pad_octagon.ly - p_width && - Math.max(line_a.x + line_a.y, line_b.x + line_b.y) - <= pad_octagon.llx - diag_width; - } - break; - case 6: - result = Math.min(line_a.x, line_b.x) >= pad_octagon.rx + p_width || - Math.min(line_a.x + line_a.y, line_b.x + line_b.y) - >= pad_octagon.urx + diag_width || - Math.min(line_a.x - line_a.y, line_b.x - line_b.y) - >= pad_octagon.lrx + diag_width; - if (p_with_sides && !result) - { - result = Math.max(line_a.y, line_b.y) <= pad_octagon.ly - p_width - && Math.max(line_a.x - line_a.y, line_b.x - line_b.y) - >= pad_octagon.lrx + diag_width || - Math.min(line_a.y, line_b.y) >= pad_octagon.uy + p_width - && Math.max(line_a.x + line_a.y, line_b.x + line_b.y) - >= pad_octagon.urx + diag_width; - } - break; - case 7: - result = Math.min(line_a.y, line_b.y) >= pad_octagon.uy + p_width || - Math.min(line_a.x + line_a.y, line_b.x + line_b.y) - >= pad_octagon.urx + diag_width || - Math.min(line_a.x, line_b.x) >= pad_octagon.rx + p_width; - if (p_with_sides && !result) - { - result = Math.max(line_a.y, line_b.y) >= pad_octagon.uy + p_width - && Math.max(line_a.x - line_a.y, line_b.x - line_b.y) - <= pad_octagon.ulx - diag_width || - Math.max(line_a.x, line_b.x) >= pad_octagon.rx + p_width - && Math.min(line_a.x - line_a.y, line_b.x - line_b.y) - >= pad_octagon.lrx + diag_width; - } - break; - default: - { - System.out.println("ForcedPadAlgo.in_front_of_pad: p_from_side out of range"); - result = true; - } - } - - return result; - } - - private final RoutingBoard board; - - public enum CheckDrillResult - { + + public enum CheckDrillResult { DRILLABLE, DRILLABLE_WITH_ATTACH_SMD, NOT_DRILLABLE } } diff --git a/src/main/java/net/freerouting/board/ForcedViaAlgo.java b/src/main/java/net/freerouting/board/ForcedViaAlgo.java index e9bbc53a..c24857fc 100644 --- a/src/main/java/net/freerouting/board/ForcedViaAlgo.java +++ b/src/main/java/net/freerouting/board/ForcedViaAlgo.java @@ -20,116 +20,91 @@ package net.freerouting.board; -import net.freerouting.geometry.planar.ConvexShape; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Shape; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Simplex; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.Circle; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.Limits; -import net.freerouting.rules.ViaInfo; +import net.freerouting.geometry.planar.*; import net.freerouting.library.Padstack; +import net.freerouting.rules.ViaInfo; /** * Class with static functions for checking and inserting forced vias. * - * @author alfons + * @author alfons */ -public class ForcedViaAlgo -{ +public class ForcedViaAlgo { /** * Checks, if a Via is possible at the input layer after evtl. shoving aside obstacle traces. * p_room_shape is used for calculating the from_side. */ public static ForcedPadAlgo.CheckDrillResult check_layer(double p_via_radius, int p_cl_class, boolean p_attach_smd_allowed, - TileShape p_room_shape, Point p_location, int p_layer, - int[] p_net_no_arr, int p_max_recursion_depth, - int p_max_via_recursion_depth, RoutingBoard p_board) - { - if (p_via_radius <= 0) - { + TileShape p_room_shape, Point p_location, int p_layer, + int[] p_net_no_arr, int p_max_recursion_depth, + int p_max_via_recursion_depth, RoutingBoard p_board) { + if (p_via_radius <= 0) { return ForcedPadAlgo.CheckDrillResult.DRILLABLE; } ForcedPadAlgo forced_pad_algo = new ForcedPadAlgo(p_board); - if (!(p_location instanceof IntPoint)) - { + if (!(p_location instanceof IntPoint)) { return ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE; } - ConvexShape via_shape = new Circle((IntPoint) p_location, (int) Math.ceil(p_via_radius)); - + ConvexShape via_shape = new Circle((IntPoint) p_location, (int) Math.ceil(p_via_radius)); + double check_radius = p_via_radius + 0.5 * p_board.clearance_value(p_cl_class, p_cl_class, p_layer) - + p_board.get_min_trace_half_width(); - + + p_board.get_min_trace_half_width(); + TileShape tile_shape; boolean is_90_degree; - if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { tile_shape = via_shape.bounding_box(); is_90_degree = true; - } - else - { + } else { tile_shape = via_shape.bounding_octagon(); is_90_degree = false; } - + CalcFromSide from_side = calculate_from_side(p_location.to_float(), tile_shape, p_room_shape.to_Simplex(), check_radius, is_90_degree); - if (from_side == null) - { + if (from_side == null) { return ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE; } - + ForcedPadAlgo.CheckDrillResult result = forced_pad_algo.check_forced_pad(tile_shape, from_side, p_layer, p_net_no_arr, p_cl_class, p_attach_smd_allowed, null, p_max_recursion_depth, p_max_via_recursion_depth, false, null); return result; } - + /** * Checks, if a Via is possible with the input parameter after evtl. shoving aside obstacle traces. */ public static boolean check(ViaInfo p_via_info, Point p_location, int[] p_net_no_arr, int p_max_recursion_depth, - int p_max_via_recursion_depth, RoutingBoard p_board) - { + int p_max_via_recursion_depth, RoutingBoard p_board) { Vector translate_vector = p_location.difference_by(Point.ZERO); int calc_from_side_offset = p_board.get_min_trace_half_width(); ForcedPadAlgo forced_pad_algo = new ForcedPadAlgo(p_board); Padstack via_padstack = p_via_info.get_padstack(); - for (int i = via_padstack.from_layer(); i <= via_padstack.to_layer(); ++i) - { + for (int i = via_padstack.from_layer(); i <= via_padstack.to_layer(); ++i) { Shape curr_pad_shape = via_padstack.get_shape(i); - if (curr_pad_shape == null) - { + if (curr_pad_shape == null) { continue; } curr_pad_shape = (Shape) curr_pad_shape.translate_by(translate_vector); TileShape tile_shape; - if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { tile_shape = curr_pad_shape.bounding_box(); - } - else - { + } else { tile_shape = curr_pad_shape.bounding_octagon(); } CalcFromSide from_side - = forced_pad_algo.calc_from_side(tile_shape, p_location, i, calc_from_side_offset,p_via_info.get_clearance_class()); + = forced_pad_algo.calc_from_side(tile_shape, p_location, i, calc_from_side_offset, p_via_info.get_clearance_class()); if (forced_pad_algo.check_forced_pad(tile_shape, from_side, i, p_net_no_arr, p_via_info.get_clearance_class(), p_via_info.attach_smd_allowed(), null, p_max_recursion_depth, p_max_via_recursion_depth, false, null) - == ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) - { + == ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) { p_board.set_shove_failing_layer(i); return false; } } return true; } - + /** * Shoves aside traces, so that a via with the input parameters can be * inserted without clearance violations. If the shove failed, the database may be damaged, so that an undo @@ -138,63 +113,49 @@ public static boolean check(ViaInfo p_via_info, Point p_location, int[] p_net_no * in case the trace width is bigger than the via shape. * Returns false, if the forced via failed. */ - public static boolean insert( ViaInfo p_via_info, Point p_location, int[] p_net_no_arr, - int p_trace_clearance_class_no, int [] p_trace_pen_halfwidth_arr, int p_max_recursion_depth, - int p_max_via_recursion_depth, RoutingBoard p_board) - { + public static boolean insert(ViaInfo p_via_info, Point p_location, int[] p_net_no_arr, + int p_trace_clearance_class_no, int[] p_trace_pen_halfwidth_arr, int p_max_recursion_depth, + int p_max_via_recursion_depth, RoutingBoard p_board) { Vector translate_vector = p_location.difference_by(Point.ZERO); int calc_from_side_offset = p_board.get_min_trace_half_width(); ForcedPadAlgo forced_pad_algo = new ForcedPadAlgo(p_board); Padstack via_padstack = p_via_info.get_padstack(); - for (int i = via_padstack.from_layer(); i <= via_padstack.to_layer(); ++i) - { + for (int i = via_padstack.from_layer(); i <= via_padstack.to_layer(); ++i) { Shape curr_pad_shape = via_padstack.get_shape(i); - if (curr_pad_shape == null) - { + if (curr_pad_shape == null) { continue; } curr_pad_shape = (Shape) curr_pad_shape.translate_by(translate_vector); TileShape tile_shape; Circle start_trace_circle; - if (p_trace_pen_halfwidth_arr[i] > 0 && p_location instanceof IntPoint) - { + if (p_trace_pen_halfwidth_arr[i] > 0 && p_location instanceof IntPoint) { start_trace_circle = new Circle((IntPoint) p_location, p_trace_pen_halfwidth_arr[i]); - } - else - { + } else { start_trace_circle = null; } TileShape start_trace_shape = null; - if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { tile_shape = curr_pad_shape.bounding_box(); - if (start_trace_circle != null) - { + if (start_trace_circle != null) { start_trace_shape = start_trace_circle.bounding_box(); } - } - else - { + } else { tile_shape = curr_pad_shape.bounding_octagon(); - if (start_trace_circle != null) - { + if (start_trace_circle != null) { start_trace_shape = start_trace_circle.bounding_octagon(); } } CalcFromSide from_side - = forced_pad_algo.calc_from_side(tile_shape, p_location, i, calc_from_side_offset,p_via_info.get_clearance_class()); + = forced_pad_algo.calc_from_side(tile_shape, p_location, i, calc_from_side_offset, p_via_info.get_clearance_class()); if (!forced_pad_algo.forced_pad(tile_shape, from_side, i, p_net_no_arr, p_via_info.get_clearance_class(), - p_via_info.attach_smd_allowed(), null, p_max_recursion_depth, p_max_via_recursion_depth)) - { + p_via_info.attach_smd_allowed(), null, p_max_recursion_depth, p_max_via_recursion_depth)) { p_board.set_shove_failing_layer(i); return false; } - if (start_trace_shape != null) - { + if (start_trace_shape != null) { // necessesary in case strart_trace_shape is bigger than tile_shape if (!forced_pad_algo.forced_pad(start_trace_shape, from_side, i, p_net_no_arr, p_trace_clearance_class_no, - true, null, p_max_recursion_depth, p_max_via_recursion_depth)) - { + true, null, p_max_recursion_depth, p_max_via_recursion_depth)) { p_board.set_shove_failing_layer(i); return false; } @@ -204,93 +165,72 @@ public static boolean insert( ViaInfo p_via_info, Point p_location, int[] p_net_ FixedState.UNFIXED, p_via_info.attach_smd_allowed()); return true; } - - static private CalcFromSide calculate_from_side(FloatPoint p_via_location, TileShape p_via_shape, Simplex p_room_shape, double p_dist, boolean is_90_degree) - { + + static private CalcFromSide calculate_from_side(FloatPoint p_via_location, TileShape p_via_shape, Simplex p_room_shape, double p_dist, boolean is_90_degree) { IntBox via_box = p_via_shape.bounding_box(); - for (int i = 0; i < 4; ++i) - { + for (int i = 0; i < 4; ++i) { FloatPoint check_point; double border_x; double border_y; - if (i == 0) - { + if (i == 0) { check_point = new FloatPoint(p_via_location.x, p_via_location.y - p_dist); border_x = p_via_location.x; - border_y = via_box.ll.y; - } - else if (i == 1) - { + border_y = via_box.ll.y; + } else if (i == 1) { check_point = new FloatPoint(p_via_location.x + p_dist, p_via_location.y); border_x = via_box.ur.x; border_y = p_via_location.y; - } - else if (i == 2) - { + } else if (i == 2) { check_point = new FloatPoint(p_via_location.x, p_via_location.y + p_dist); border_x = p_via_location.x; - border_y = via_box.ur.y; - } - else // i == 3 + border_y = via_box.ur.y; + } else // i == 3 { check_point = new FloatPoint(p_via_location.x - p_dist, p_via_location.y); border_x = via_box.ll.x; - border_y = p_via_location.y; + border_y = p_via_location.y; } - if (p_room_shape.contains(check_point)) - { + if (p_room_shape.contains(check_point)) { int from_side_no; - if (is_90_degree) - { + if (is_90_degree) { from_side_no = i; - } - else - { + } else { from_side_no = 2 * i; } FloatPoint curr_border_point = new FloatPoint(border_x, border_y); return new CalcFromSide(from_side_no, curr_border_point); } } - if (is_90_degree) - { + if (is_90_degree) { return null; } // try the diagonal drections - double dist = p_dist / Limits.sqrt2; + double dist = p_dist / Limits.sqrt2; double border_dist = via_box.max_width() / (2 * Limits.sqrt2); - for (int i = 0; i < 4; ++i) - { + for (int i = 0; i < 4; ++i) { FloatPoint check_point; double border_x; double border_y; - if (i == 0) - { + if (i == 0) { check_point = new FloatPoint(p_via_location.x + dist, p_via_location.y - dist); border_x = p_via_location.x + border_dist; border_y = p_via_location.y - border_dist; - } - else if (i == 1) - { + } else if (i == 1) { check_point = new FloatPoint(p_via_location.x + dist, p_via_location.y + dist); border_x = p_via_location.x + border_dist; border_y = p_via_location.y + border_dist; - } - else if (i == 2) - { + } else if (i == 2) { check_point = new FloatPoint(p_via_location.x - dist, p_via_location.y + dist); border_x = p_via_location.x - border_dist; border_y = p_via_location.y + border_dist; - } - else // i == 3 + } else // i == 3 { check_point = new FloatPoint(p_via_location.x - dist, p_via_location.y - dist); border_x = p_via_location.x - border_dist; border_y = p_via_location.y - border_dist; } - if (p_room_shape.contains(check_point)) - { - + if (p_room_shape.contains(check_point)) { + int from_side_no = 2 * i + 1; FloatPoint curr_border_point = new FloatPoint(border_x, border_y); return new CalcFromSide(from_side_no, curr_border_point); diff --git a/src/main/java/net/freerouting/board/Item.java b/src/main/java/net/freerouting/board/Item.java index 75ef9604..4fa007ab 100644 --- a/src/main/java/net/freerouting/board/Item.java +++ b/src/main/java/net/freerouting/board/Item.java @@ -15,51 +15,87 @@ */ package net.freerouting.board; -import java.util.Collection; -import java.util.LinkedList; - -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.IntBox; - -import java.awt.Color; -import java.awt.Graphics; -import java.io.Serializable; -import java.util.Iterator; -import java.util.Set; -import java.util.TreeSet; - -import net.freerouting.rules.Nets; import net.freerouting.boardgraphics.Drawable; import net.freerouting.boardgraphics.GraphicsContext; - -import net.freerouting.datastructures.UndoableObjects; import net.freerouting.datastructures.ShapeTree; import net.freerouting.datastructures.ShapeTree.TreeEntry; +import net.freerouting.datastructures.UndoableObjects; +import net.freerouting.geometry.planar.*; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Vector; +import net.freerouting.rules.Nets; + +import java.awt.*; +import java.io.Serializable; +import java.util.*; /** * Basic class of the items on a board. * * @author Alfons Wirtz */ -public abstract class Item implements Drawable, SearchTreeObject, ObjectInfoPanel.Printable, UndoableObjects.Storable, Serializable -{ +public abstract class Item implements Drawable, SearchTreeObject, ObjectInfoPanel.Printable, UndoableObjects.Storable, Serializable { + + private static double PROTECT_FANOUT_LENGTH = 400; + private final int id_no; + /** + * The board this Itewm is on + */ + transient public BasicBoard board; + /** + * The nets, to which this item belongs + */ + int[] net_no_arr; + /** + * the index in the clearance matrix describing the required spacing + * to other items + */ + private int clearance_class; + /** + * points to the entries of this item in the ShapeSearchTrees + */ + transient private ItemSearchTreesInfo search_trees_info = null; + private FixedState fixed_state; + /** + * not 0, if this item belongs to a component + */ + private int component_no = 0; + /** + * Folse, if the item is deleted or not inserted into the board + */ + private boolean on_the_board = false; + /** + * Temporary data used in the autoroute algorithm. + */ + transient private net.freerouting.autoroute.ItemAutorouteInfo autoroute_info = null; + + Item(int[] p_net_no_arr, int p_clearance_type, int p_id_no, + int p_component_no, FixedState p_fixed_state, BasicBoard p_board) { + if (p_net_no_arr == null) { + net_no_arr = new int[0]; + } else { + net_no_arr = new int[p_net_no_arr.length]; + System.arraycopy(p_net_no_arr, 0, net_no_arr, 0, p_net_no_arr.length); + } + clearance_class = p_clearance_type; + component_no = p_component_no; + fixed_state = p_fixed_state; + board = p_board; + if (p_id_no <= 0) { + id_no = board.communication.id_no_generator.new_no(); + } else { + id_no = p_id_no; + } + } /** * Implements the comparable interface. */ - public int compareTo(Object p_other) - { + public int compareTo(Object p_other) { int result; - if (p_other instanceof Item) - { + if (p_other instanceof Item) { result = ((Item) p_other).id_no - id_no; - } - else - { + } else { result = 1; } return result; @@ -68,37 +104,30 @@ public int compareTo(Object p_other) /** * returns the unique idcentification number of this item */ - public int get_id_no() - { + public int get_id_no() { return id_no; } /** * Returns true if the net number array of this item contains p_net_no. */ - public boolean contains_net(int p_net_no) - { - if (p_net_no <= 0) - { + public boolean contains_net(int p_net_no) { + if (p_net_no <= 0) { return false; } - for (int i = 0; i < net_no_arr.length; ++i) - { - if (net_no_arr[i] == p_net_no) - { + for (int i = 0; i < net_no_arr.length; ++i) { + if (net_no_arr[i] == p_net_no) { return true; } } return false; } - public boolean is_obstacle(int p_net_no) - { + public boolean is_obstacle(int p_net_no) { return !contains_net(p_net_no); } - public boolean is_trace_obstacle(int p_net_no) - { + public boolean is_trace_obstacle(int p_net_no) { return !contains_net(p_net_no); } @@ -108,26 +137,21 @@ public boolean is_trace_obstacle(int p_net_no) public abstract boolean is_obstacle(Item p_other); /** - * Returns true if the net number arrays of this and p_other have a common - * number. + * Returns true if the net number arrays of this and p_other have a common + * number. */ - public boolean shares_net(Item p_other) - { + public boolean shares_net(Item p_other) { return this.shares_net_no(p_other.net_no_arr); } /** - * Returns true if the net number array of this and p_net_no_arr have a common - * number. + * Returns true if the net number array of this and p_net_no_arr have a common + * number. */ - public boolean shares_net_no(int[] p_net_no_arr) - { - for (int i = 0; i < net_no_arr.length; ++i) - { - for (int j = 0; j < p_net_no_arr.length; ++j) - { - if (net_no_arr[i] == p_net_no_arr[j]) - { + public boolean shares_net_no(int[] p_net_no_arr) { + for (int i = 0; i < net_no_arr.length; ++i) { + for (int j = 0; j < p_net_no_arr.length; ++j) { + if (net_no_arr[i] == p_net_no_arr[j]) { return true; } } @@ -143,45 +167,36 @@ public boolean shares_net_no(int[] p_net_no_arr) /** * Returns the p_index-throws shape of this item after decomposition into convex polygonal shapes */ - public TileShape get_tile_shape(int p_index) - { - if (this.board == null) - { + public TileShape get_tile_shape(int p_index) { + if (this.board == null) { System.out.println("Item.get_tile_shape: board is null"); return null; } return get_tree_shape(this.board.search_tree_manager.get_default_tree(), p_index); } - public int tree_shape_count(ShapeTree p_tree) - { - if (this.board == null) - { + public int tree_shape_count(ShapeTree p_tree) { + if (this.board == null) { return 0; } TileShape[] precalculated_tree_shapes = this.get_precalculated_tree_shapes(p_tree); return precalculated_tree_shapes.length; } - public TileShape get_tree_shape(ShapeTree p_tree, int p_index) - { - if (this.board == null) - { + public TileShape get_tree_shape(ShapeTree p_tree, int p_index) { + if (this.board == null) { return null; } TileShape[] precalculated_tree_shapes = this.get_precalculated_tree_shapes(p_tree); return precalculated_tree_shapes[p_index]; } - private TileShape[] get_precalculated_tree_shapes(ShapeTree p_tree) - { - if (this.search_trees_info == null) - { + private TileShape[] get_precalculated_tree_shapes(ShapeTree p_tree) { + if (this.search_trees_info == null) { this.search_trees_info = new ItemSearchTreesInfo(); } TileShape[] precalculated_tree_shapes = this.search_trees_info.get_precalculated_tree_shapes(p_tree); - if (precalculated_tree_shapes == null) - { + if (precalculated_tree_shapes == null) { precalculated_tree_shapes = this.calculate_tree_shapes((ShapeSearchTree) p_tree); this.search_trees_info.set_precalculated_tree_shapes(precalculated_tree_shapes, p_tree); } @@ -197,13 +212,11 @@ private TileShape[] get_precalculated_tree_shapes(ShapeTree p_tree) * Returns false, if this item is deleted oor not inserted into * the board. */ - public boolean is_on_the_board() - { + public boolean is_on_the_board() { return this.on_the_board; } - void set_on_the_board(boolean p_value) - { + void set_on_the_board(boolean p_value) { this.on_the_board = p_value; } @@ -213,8 +226,7 @@ void set_on_the_board(boolean p_value) */ public abstract Item copy(int p_id_no); - public Object clone() - { + public Object clone() { return copy(this.get_id_no()); } @@ -268,10 +280,9 @@ public Object clone() public abstract IntBox bounding_box(); /** - * Translates this item by p_vector in the board. + * Translates this item by p_vector in the board. */ - public void move_by(Vector p_vector) - { + public void move_by(Vector p_vector) { board.item_list.save_for_undo(this); board.search_tree_manager.remove(this); this.translate_by(p_vector); @@ -284,8 +295,7 @@ public void move_by(Vector p_vector) * Returns true, if some shapes of this item and p_other are * on the same layer. */ - public boolean shares_layer(Item p_other) - { + public boolean shares_layer(Item p_other) { int max_first_layer = Math.max(this.first_layer(), p_other.first_layer()); int min_last_layer = Math.min(this.last_layer(), p_other.last_layer()); return max_first_layer <= min_last_layer; @@ -295,12 +305,10 @@ public boolean shares_layer(Item p_other) * Returns the first layer, where both this item and p_other have a shape. * Returns -1, if such a layer does not exisr. */ - public int first_common_layer(Item p_other) - { + public int first_common_layer(Item p_other) { int max_first_layer = Math.max(this.first_layer(), p_other.first_layer()); int min_last_layer = Math.min(this.last_layer(), p_other.last_layer()); - if (max_first_layer > min_last_layer) - { + if (max_first_layer > min_last_layer) { return -1; } return max_first_layer; @@ -310,12 +318,10 @@ public int first_common_layer(Item p_other) * Returns the last layer, where both this item and p_other have a shape. * Returns -1, if such a layer does not exisr. */ - public int last_common_layer(Item p_other) - { + public int last_common_layer(Item p_other) { int max_first_layer = Math.max(this.first_layer(), p_other.first_layer()); int min_last_layer = Math.min(this.last_layer(), p_other.last_layer()); - if (max_first_layer > min_last_layer) - { + if (max_first_layer > min_last_layer) { return -1; } return min_last_layer; @@ -324,10 +330,8 @@ public int last_common_layer(Item p_other) /** * Return the name of the component of this item or null, if this item does not belong to a component. */ - public String component_name() - { - if (component_no <= 0) - { + public String component_name() { + if (component_no <= 0) { return null; } return board.components.get(component_no).name; @@ -337,8 +341,7 @@ public String component_name() * Returns the count of clearance violations of this item with * other items. */ - public int clearance_violation_count() - { + public int clearance_violation_count() { Collection violations = this.clearance_violations(); return violations.size(); } @@ -348,31 +351,25 @@ public int clearance_violation_count() * The objects in the list are of type ClearanceViolations. * The first_item in such an object is always this item. */ - public Collection clearance_violations() - { + public Collection clearance_violations() { Collection result = new LinkedList(); - if (this.board == null) - { + if (this.board == null) { return result; } ShapeSearchTree default_tree = board.search_tree_manager.get_default_tree(); - for (int i = 0; i < tile_shape_count(); ++i) - { + for (int i = 0; i < tile_shape_count(); ++i) { TileShape curr_tile_shape = get_tile_shape(i); Collection curr_overlapping_items = default_tree.overlapping_tree_entries_with_clearance(curr_tile_shape, shape_layer(i), new int[0], clearance_class); Iterator it = curr_overlapping_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { TreeEntry curr_entry = it.next(); - if (!(curr_entry.object instanceof Item) || curr_entry.object == this) - { + if (!(curr_entry.object instanceof Item) || curr_entry.object == this) { continue; } Item curr_item = (Item) curr_entry.object; boolean is_obstacle = curr_item.is_obstacle(this); - if (is_obstacle && this instanceof Trace && curr_item instanceof Trace) - { + if (is_obstacle && this instanceof Trace && curr_item instanceof Trace) { // Look, if both traces are connected to the same tie pin. // In this case they are allowed to overlap without sharing a net. Trace this_trace = (Trace) this; @@ -380,30 +377,23 @@ public Collection clearance_violations() boolean contact_found = false; Collection curr_contacts = this_trace.get_normal_contacts(contact_point, true); { - if (curr_contacts.contains(curr_item)) - { + if (curr_contacts.contains(curr_item)) { contact_found = true; } } - if (!contact_found) - { + if (!contact_found) { contact_point = this_trace.last_corner(); curr_contacts = this_trace.get_normal_contacts(contact_point, true); { - if (curr_contacts.contains(curr_item)) - { + if (curr_contacts.contains(curr_item)) { contact_found = true; } } } - if (contact_found) - { - for (Item curr_contact : curr_contacts) - { - if (curr_contact instanceof Pin) - { - if (curr_contact.shares_net(this) && curr_contact.shares_net(curr_item)) - { + if (contact_found) { + for (Item curr_contact : curr_contacts) { + if (curr_contact instanceof Pin) { + if (curr_contact.shares_net(this) && curr_contact.shares_net(curr_item)) { is_obstacle = false; break; } @@ -412,17 +402,14 @@ public Collection clearance_violations() } } - if (is_obstacle) - { + if (is_obstacle) { TileShape shape_1 = curr_tile_shape; TileShape shape_2 = curr_item.get_tree_shape(default_tree, curr_entry.shape_index_in_object); - if (shape_1 == null || shape_2 == null) - { + if (shape_1 == null || shape_2 == null) { System.out.println("Item.clearance_violations: unexpected null shape"); continue; } - if (!this.board.search_tree_manager.is_clearance_compensation_used()) - { + if (!this.board.search_tree_manager.is_clearance_compensation_used()) { double cl_offset = 0.5 * board.rules.clearance_matrix.value(curr_item.clearance_class, this.clearance_class, shape_layer(i)); shape_1 = (TileShape) shape_1.enlarge(cl_offset); @@ -430,8 +417,7 @@ public Collection clearance_violations() } TileShape intersection = shape_1.intersection(shape_2); - if (intersection.dimension() == 2) - { + if (intersection.dimension() == 2) { ClearanceViolation curr_violation = new ClearanceViolation(this, curr_item, intersection, shape_layer(i)); result.add(curr_violation); @@ -446,27 +432,21 @@ public Collection clearance_violations() * Returns all connectable Items with a direct contacts to this item. * The result will be empty, if this item is not connectable. */ - public Set get_all_contacts() - { + public Set get_all_contacts() { Set result = new TreeSet(); - if (!(this instanceof Connectable)) - { + if (!(this instanceof Connectable)) { return result; } - for (int i = 0; i < this.tile_shape_count(); ++i) - { + for (int i = 0; i < this.tile_shape_count(); ++i) { Collection overlapping_items = board.overlapping_objects(get_tile_shape(i), shape_layer(i)); Iterator it = overlapping_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { SearchTreeObject curr_ob = it.next(); - if (!(curr_ob instanceof Item)) - { + if (!(curr_ob instanceof Item)) { continue; } Item curr_item = (Item) curr_ob; - if (curr_item != this && curr_item instanceof Connectable && curr_item.shares_net(this)) - { + if (curr_item != this && curr_item instanceof Connectable && curr_item.shares_net(this)) { result.add(curr_item); } } @@ -478,31 +458,24 @@ public Set get_all_contacts() * Returns all connectable Items with a direct contacts to this item on the input layer. * The result will be empty, if this item is not connectable. */ - public Set get_all_contacts(int p_layer) - { + public Set get_all_contacts(int p_layer) { Set result = new TreeSet(); - if (!(this instanceof Connectable)) - { + if (!(this instanceof Connectable)) { return result; } - for (int i = 0; i < this.tile_shape_count(); ++i) - { - if (this.shape_layer(i) != p_layer) - { + for (int i = 0; i < this.tile_shape_count(); ++i) { + if (this.shape_layer(i) != p_layer) { continue; } Collection overlapping_items = board.overlapping_objects(get_tile_shape(i), p_layer); Iterator it = overlapping_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { SearchTreeObject curr_ob = it.next(); - if (!(curr_ob instanceof Item)) - { + if (!(curr_ob instanceof Item)) { continue; } Item curr_item = (Item) curr_ob; - if (curr_item != this && curr_item instanceof Connectable && curr_item.shares_net(this)) - { + if (curr_item != this && curr_item instanceof Connectable && curr_item.shares_net(this)) { result.add(curr_item); } } @@ -514,8 +487,7 @@ public Set get_all_contacts(int p_layer) * Checks, if this item is electrically connected to another connectable * item. Returns false for items, which are not connectable. */ - public boolean is_connected() - { + public boolean is_connected() { Collection contacts = this.get_all_contacts(); return (contacts.size() > 0); } @@ -524,8 +496,7 @@ public boolean is_connected() * Checks, if this item is electrically connected to another connectable * item on the input layer. Returns false for items, which are not connectable. */ - public boolean is_connected_on_layer(int p_layer) - { + public boolean is_connected_on_layer(int p_layer) { Collection contacts_on_layer = this.get_all_contacts(p_layer); return (contacts_on_layer.size() > 0); } @@ -533,8 +504,7 @@ public boolean is_connected_on_layer(int p_layer) /** * default implementation to be overwritten in the Connectable subclasses */ - public Set get_normal_contacts() - { + public Set get_normal_contacts() { return new TreeSet(); } @@ -543,24 +513,21 @@ public Set get_normal_contacts() * and have a unique normal contact. * Returns null otherwise */ - public Point normal_contact_point(Item p_other) - { + public Point normal_contact_point(Item p_other) { return null; } /** * auxiliary function */ - Point normal_contact_point(Trace p_other) - { + Point normal_contact_point(Trace p_other) { return null; } /** * auxiliary function */ - Point normal_contact_point(DrillItem p_other) - { + Point normal_contact_point(DrillItem p_other) { return null; } @@ -569,8 +536,7 @@ Point normal_contact_point(DrillItem p_other) * via normal contacts from this item. * If p_net_no <= 0, the net number is ignored. */ - public Set get_connected_set(int p_net_no) - { + public Set get_connected_set(int p_net_no) { return get_connected_set(p_net_no, false); } @@ -581,11 +547,9 @@ public Set get_connected_set(int p_net_no) * If p_stop_at_plane, the recursive algorithm stops, when a conduction area is reached, * which does not belong to a component. */ - public Set get_connected_set(int p_net_no, boolean p_stop_at_plane) - { + public Set get_connected_set(int p_net_no, boolean p_stop_at_plane) { Set result = new TreeSet(); - if (p_net_no > 0 && !this.contains_net(p_net_no)) - { + if (p_net_no > 0 && !this.contains_net(p_net_no)) { return result; } result.add(this); @@ -596,25 +560,19 @@ public Set get_connected_set(int p_net_no, boolean p_stop_at_plane) /** * recursive part of get_connected_set */ - private void get_connected_set_recu(Set p_result, int p_net_no, boolean p_stop_at_plane) - { + private void get_connected_set_recu(Set p_result, int p_net_no, boolean p_stop_at_plane) { Collection contact_list = get_normal_contacts(); - if (contact_list == null) - { + if (contact_list == null) { return; } - for (Item curr_contact : contact_list) - { - if (p_stop_at_plane && curr_contact instanceof ConductionArea && curr_contact.get_component_no() <= 0) - { + for (Item curr_contact : contact_list) { + if (p_stop_at_plane && curr_contact instanceof ConductionArea && curr_contact.get_component_no() <= 0) { continue; } - if (p_net_no > 0 && !curr_contact.contains_net(p_net_no)) - { + if (p_net_no > 0 && !curr_contact.contains_net(p_net_no)) { continue; } - if (p_result.add(curr_contact)) - { + if (p_result.add(curr_contact)) { curr_contact.get_connected_set_recu(p_result, p_net_no, p_stop_at_plane); } } @@ -623,8 +581,7 @@ private void get_connected_set_recu(Set p_result, int p_net_no, boolean p_ /** * Returns true, if this item contains some overlap to be cleaned. */ - public boolean is_overlap() - { + public boolean is_overlap() { return false; } @@ -633,33 +590,25 @@ public boolean is_overlap() * If p_ignore_areas is true, cycles where conduction areas are involved are ignored. */ boolean is_cycle_recu(Set p_visited_items, Item p_search_item, Item p_come_from_item, - boolean p_ignore_areas) - { - if (p_ignore_areas && this instanceof ConductionArea) - { + boolean p_ignore_areas) { + if (p_ignore_areas && this instanceof ConductionArea) { return false; } Collection contact_list = get_normal_contacts(); - if (contact_list == null) - { + if (contact_list == null) { return false; } Iterator it = contact_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_contact = it.next(); - if (curr_contact == p_come_from_item) - { + if (curr_contact == p_come_from_item) { continue; } - if (curr_contact == p_search_item) - { + if (curr_contact == p_search_item) { return true; } - if (p_visited_items.add(curr_contact)) - { - if (curr_contact.is_cycle_recu(p_visited_items, p_search_item, this, p_ignore_areas)) - { + if (p_visited_items.add(curr_contact)) { + if (curr_contact.is_cycle_recu(p_visited_items, p_search_item, this, p_ignore_areas)) { return true; } } @@ -672,21 +621,15 @@ boolean is_cycle_recu(Set p_visited_items, Item p_search_item, Item p_come * which are not in the connected set of this item. * If p_net_no <= 0, the net numbers contained in this items are used instead of p_net_no. */ - public Set get_unconnected_set(int p_net_no) - { + public Set get_unconnected_set(int p_net_no) { Set result = new TreeSet(); - if (p_net_no > 0 && !this.contains_net(p_net_no)) - { + if (p_net_no > 0 && !this.contains_net(p_net_no)) { return result; } - if (p_net_no > 0) - { + if (p_net_no > 0) { result.addAll(board.get_connectable_items(p_net_no)); - } - else - { - for (int curr_net_no : this.net_no_arr) - { + } else { + for (int curr_net_no : this.net_no_arr) { result.addAll(board.get_connectable_items(curr_net_no)); } } @@ -695,68 +638,55 @@ public Set get_unconnected_set(int p_net_no) } /** - * Returns all traces and vias from this item until the next fork or terminal item. + * Returns all traces and vias from this item until the next fork or terminal item. */ - public Set get_connection_items() - { + public Set get_connection_items() { return get_connection_items(StopConnectionOption.NONE); } /** - * Returns all traces and vias from this item until the next fork or terminal item. + * Returns all traces and vias from this item until the next fork or terminal item. * If p_stop_option == StopConnectionOption.FANOUT_VIA, the algorithm will stop at the next fanout via, * If p_stop_option == StopConnectionOption.VIA, the algorithm will stop at any via. */ - public Set get_connection_items(StopConnectionOption p_stop_option) - { + public Set get_connection_items(StopConnectionOption p_stop_option) { Set contacts = this.get_normal_contacts(); Set result = new TreeSet(); - if (this.is_route()) - { + if (this.is_route()) { result.add(this); } Iterator it = contacts.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); Point prev_contact_point = this.normal_contact_point(curr_item); - if (prev_contact_point == null) - { + if (prev_contact_point == null) { // no unique contact point continue; } int prev_contact_layer = this.first_common_layer(curr_item); - if (this instanceof Trace) - { + if (this instanceof Trace) { // Check, that there is only 1 contact at this location. // Only for pins and vias items of more than 1 connection // are collected Trace start_trace = (Trace) this; Collection check_contacts = start_trace.get_normal_contacts(prev_contact_point, false); - if (check_contacts.size() != 1) - { + if (check_contacts.size() != 1) { continue; } } // Search from curr_item along the contacts // until the next fork or nonroute item. - for (;;) - { - if (!curr_item.is_route()) - { + for (; ; ) { + if (!curr_item.is_route()) { // connection ends break; } - if (curr_item instanceof Via) - { - if (p_stop_option == StopConnectionOption.VIA) - { + if (curr_item instanceof Via) { + if (p_stop_option == StopConnectionOption.VIA) { break; } - if (p_stop_option == StopConnectionOption.FANOUT_VIA) - { - if (curr_item.is_fanout_via(result)) - { + if (p_stop_option == StopConnectionOption.FANOUT_VIA) { + if (curr_item.is_fanout_via(result)) { break; } } @@ -772,24 +702,19 @@ public Set get_connection_items(StopConnectionOption p_stop_option) Item next_contact = null; boolean fork_found = false; Iterator curr_it = curr_ob_contacts.iterator(); - while (curr_it.hasNext()) - { + while (curr_it.hasNext()) { Item tmp_contact = curr_it.next(); int tmp_contact_layer = curr_item.first_common_layer(tmp_contact); - if (tmp_contact_layer >= 0) - { + if (tmp_contact_layer >= 0) { Point tmp_contact_point = curr_item.normal_contact_point(tmp_contact); - if (tmp_contact_point == null) - { + if (tmp_contact_point == null) { // no unique contact point fork_found = true; break; } if (prev_contact_layer != tmp_contact_layer || - !prev_contact_point.equals(tmp_contact_point)) - { - if (next_contact != null) - { + !prev_contact_point.equals(tmp_contact_point)) { + if (next_contact != null) { // second new contact found fork_found = true; break; @@ -800,8 +725,7 @@ public Set get_connection_items(StopConnectionOption p_stop_option) } } } - if (next_contact == null || fork_found) - { + if (next_contact == null || fork_found) { break; } curr_item = next_contact; @@ -815,8 +739,7 @@ public Set get_connection_items(StopConnectionOption p_stop_option) /** * Function o be overwritten by classes Trace ans Via */ - public boolean is_tail() - { + public boolean is_tail() { return false; } @@ -824,16 +747,13 @@ public boolean is_tail() * Returns all corners of this item, which are used for displaying the ratsnest. * To be overwritten in derived classes implementing the Connectable interface. */ - public Point[] get_ratsnest_corners() - { + public Point[] get_ratsnest_corners() { return new Point[0]; } - public void draw(Graphics p_g, GraphicsContext p_graphics_context, Color p_color, double p_intensity) - { + public void draw(Graphics p_g, GraphicsContext p_graphics_context, Color p_color, double p_intensity) { Color[] color_arr = new Color[board.get_layer_count()]; - for (int i = 0; i < color_arr.length; ++i) - { + for (int i = 0; i < color_arr.length; ++i) { color_arr[i] = p_color; } draw(p_g, p_graphics_context, color_arr, p_intensity); @@ -843,8 +763,7 @@ public void draw(Graphics p_g, GraphicsContext p_graphics_context, Color p_color * Draws this item whith its draw colors from p_graphics_context. * p_layer_visibility[i] is expected between 0 and 1 for each layer i. */ - public void draw(Graphics p_g, GraphicsContext p_graphics_context) - { + public void draw(Graphics p_g, GraphicsContext p_graphics_context) { Color[] layer_colors = get_draw_colors(p_graphics_context); draw(p_g, p_graphics_context, layer_colors, get_draw_intensity(p_graphics_context)); } @@ -852,18 +771,14 @@ public void draw(Graphics p_g, GraphicsContext p_graphics_context) /** * Test function checking the item for inconsitencies. */ - public boolean validate() - { + public boolean validate() { boolean result = true; - if (!board.search_tree_manager.validate_entries(this)) - { + if (!board.search_tree_manager.validate_entries(this)) { result = false; } - for (int i = 0; i < this.tile_shape_count(); ++i) - { + for (int i = 0; i < this.tile_shape_count(); ++i) { TileShape curr_shape = this.get_tile_shape(i); - if (curr_shape.is_empty()) - { + if (curr_shape.is_empty()) { System.out.println("Item.validate: shape is empty"); result = false; } @@ -877,55 +792,24 @@ public boolean validate() */ public abstract int shape_layer(int p_index); - Item(int[] p_net_no_arr, int p_clearance_type, int p_id_no, - int p_component_no, FixedState p_fixed_state, BasicBoard p_board) - { - if (p_net_no_arr == null) - { - net_no_arr = new int[0]; - } - else - { - net_no_arr = new int[p_net_no_arr.length]; - System.arraycopy(p_net_no_arr, 0, net_no_arr, 0, p_net_no_arr.length); - } - clearance_class = p_clearance_type; - component_no = p_component_no; - fixed_state = p_fixed_state; - board = p_board; - if (p_id_no <= 0) - { - id_no = board.communication.id_no_generator.new_no(); - } - else - { - id_no = p_id_no; - } - } - /** * Returns true, if it is not allowed to change this item except evtl. shoving the item */ - public boolean is_user_fixed() - { + public boolean is_user_fixed() { return (fixed_state.ordinal() >= FixedState.USER_FIXED.ordinal()); } /** * Returns true, if it is not allowed to delete this item. */ - boolean is_delete_fixed() - { + boolean is_delete_fixed() { // Items belonging to a component are delete_fixed. - if (this.component_no > 0 || is_user_fixed()) - { + if (this.component_no > 0 || is_user_fixed()) { return true; } // Also power planes are delete_fixed. - if (this instanceof ConductionArea) - { - if (!this.board.layer_structure.arr[((ConductionArea) this).get_layer()].is_signal) - { + if (this instanceof ConductionArea) { + if (!this.board.layer_structure.arr[((ConductionArea) this).get_layer()].is_signal) { return true; } } @@ -935,42 +819,36 @@ boolean is_delete_fixed() /** * Returns true, if it is not allowed to change the location of this item by the push algorithm. */ - public boolean is_shove_fixed() - { + public boolean is_shove_fixed() { return (this.fixed_state.ordinal() >= FixedState.SHOVE_FIXED.ordinal()); } /** * Returns the fixed state of this Item. */ - public FixedState get_fixed_state() - { + public FixedState get_fixed_state() { return this.fixed_state; } /** - * Returns false, if this item is an obstacle for vias with the input net number. + * Fixes the item. */ - public boolean is_drillable(int p_net_no) - { - return false; + public void set_fixed_state(FixedState p_fixed_state) { + fixed_state = p_fixed_state; } /** - * Fixes the item. + * Returns false, if this item is an obstacle for vias with the input net number. */ - public void set_fixed_state(FixedState p_fixed_state) - { - fixed_state = p_fixed_state; + public boolean is_drillable(int p_net_no) { + return false; } /** * Unfixes the item, if it is not fixed by the system. */ - public void unfix() - { - if (fixed_state != FixedState.SYSTEM_FIXED) - { + public void unfix() { + if (fixed_state != FixedState.SYSTEM_FIXED) { fixed_state = FixedState.UNFIXED; } @@ -979,40 +857,35 @@ public void unfix() /** * returns true, if this item is an unfixed trace or via */ - public boolean is_route() - { + public boolean is_route() { return false; } /** * Returns, if this item can be routed to. */ - public boolean is_connectable() - { + public boolean is_connectable() { return ((this instanceof Connectable) && this.net_count() > 0); } /** * Returns the count of nets this item belongs to. */ - public int net_count() - { + public int net_count() { return net_no_arr.length; } /** * gets the p_no-th net number of this item for 0 <= p_no < this.net_count(). */ - public int get_net_no(int p_no) - { + public int get_net_no(int p_no) { return net_no_arr[p_no]; } /** * Return the component number of this item or 0, if it does not belong to a component. */ - public int get_component_no() - { + public int get_component_no() { return component_no; } @@ -1020,27 +893,21 @@ public int get_component_no() * Removes p_net_no from the net number array. * Returns false, if p_net_no was not contained in this array. */ - public boolean remove_from_net(int p_net_no) - { + public boolean remove_from_net(int p_net_no) { int found_index = -1; - for (int i = 0; i < this.net_no_arr.length; ++i) - { - if (this.net_no_arr[i] == p_net_no) - { + for (int i = 0; i < this.net_no_arr.length; ++i) { + if (this.net_no_arr[i] == p_net_no) { found_index = i; } } - if (found_index < 0) - { + if (found_index < 0) { return false; } int[] new_net_no_arr = new int[this.net_no_arr.length - 1]; - for (int i = 0; i < found_index; ++i) - { + for (int i = 0; i < found_index; ++i) { new_net_no_arr[i] = this.net_no_arr[i]; } - for (int i = found_index; i < new_net_no_arr.length; ++i) - { + for (int i = found_index; i < new_net_no_arr.length; ++i) { new_net_no_arr[i] = this.net_no_arr[i + 1]; } this.net_no_arr = new_net_no_arr; @@ -1051,8 +918,7 @@ public boolean remove_from_net(int p_net_no) * Returns the index in the clearance matrix describing the required spacing * of this item to other items */ - public int clearance_class_no() - { + public int clearance_class_no() { return clearance_class; } @@ -1060,10 +926,8 @@ public int clearance_class_no() * Sets the index in the clearance matrix describing the required spacing * of this item to other items. */ - public void set_clearance_class_no(int p_index) - { - if (p_index < 0 || p_index >= this.board.rules.clearance_matrix.get_class_count()) - { + public void set_clearance_class_no(int p_index) { + if (p_index < 0 || p_index >= this.board.rules.clearance_matrix.get_class_count()) { System.out.println("Item.set_clearance_class_no: p_index out of range"); return; } @@ -1073,17 +937,14 @@ public void set_clearance_class_no(int p_index) /** * Changes the clearance class of this item and updates the search tree. */ - public void change_clearance_class(int p_index) - { - if (p_index < 0 || p_index >= this.board.rules.clearance_matrix.get_class_count()) - { + public void change_clearance_class(int p_index) { + if (p_index < 0 || p_index >= this.board.rules.clearance_matrix.get_class_count()) { System.out.println("Item.set_clearance_class_no: p_index out of range"); return; } clearance_class = p_index; this.clear_derived_data(); - if (this.board != null && this.board.search_tree_manager.is_clearance_compensation_used()) - { + if (this.board != null && this.board.search_tree_manager.is_clearance_compensation_used()) { // reinsert the item into the search tree, because the compensated shape has changed. this.board.search_tree_manager.remove(this); this.board.search_tree_manager.insert(this); @@ -1093,8 +954,7 @@ public void change_clearance_class(int p_index) /** * Assigns this item to the component with the input component number. */ - public void assign_component_no(int p_no) - { + public void assign_component_no(int p_no) { component_no = p_no; } @@ -1102,30 +962,21 @@ public void assign_component_no(int p_no) * Makes this item connectable and assigns it to the input net. * If p_net_no < 0, the net items net number will be removed and the item will no longer be connectable. */ - public void assign_net_no(int p_net_no) - { - if (!Nets.is_normal_net_no(p_net_no)) - { + public void assign_net_no(int p_net_no) { + if (!Nets.is_normal_net_no(p_net_no)) { return; } - if (p_net_no > board.rules.nets.max_net_no()) - { + if (p_net_no > board.rules.nets.max_net_no()) { System.out.println("Item.assign_net_no: p_net_no to big"); return; } board.item_list.save_for_undo(this); - if (p_net_no <= 0) - { + if (p_net_no <= 0) { net_no_arr = new int[0]; - } - else - { - if (net_no_arr.length == 0) - { + } else { + if (net_no_arr.length == 0) { net_no_arr = new int[1]; - } - else if (net_no_arr.length > 1) - { + } else if (net_no_arr.length > 1) { System.out.println("Item.assign_net_no: unexpected net_count > 1"); } net_no_arr[0] = p_net_no; @@ -1140,15 +991,11 @@ else if (net_no_arr.length > 1) /** * Internally used for implementing the function is_selectrd_by_filter */ - protected boolean is_selected_by_fixed_filter(ItemSelectionFilter p_filter) - { + protected boolean is_selected_by_fixed_filter(ItemSelectionFilter p_filter) { boolean result; - if (this.is_user_fixed()) - { + if (this.is_user_fixed()) { result = p_filter.is_selected(ItemSelectionFilter.SelectableChoices.FIXED); - } - else - { + } else { result = p_filter.is_selected(ItemSelectionFilter.SelectableChoices.UNFIXED); } return result; @@ -1157,14 +1004,11 @@ protected boolean is_selected_by_fixed_filter(ItemSelectionFilter p_filter) /** * Sets the item tree entries for the tree with identification number p_tree_no. */ - public void set_search_tree_entries(ShapeTree.Leaf[] p_tree_entries, ShapeTree p_tree) - { - if (this.board == null) - { + public void set_search_tree_entries(ShapeTree.Leaf[] p_tree_entries, ShapeTree p_tree) { + if (this.board == null) { return; } - if (this.search_trees_info == null) - { + if (this.search_trees_info == null) { this.search_trees_info = new ItemSearchTreesInfo(); } this.search_trees_info.set_tree_entries(p_tree_entries, p_tree); @@ -1174,10 +1018,8 @@ public void set_search_tree_entries(ShapeTree.Leaf[] p_tree_entries, ShapeTree p * Returns the tree entries for the tree with identification number p_tree_no, * or null, if for this tree no entries of this item are inserted. */ - public ShapeTree.Leaf[] get_search_tree_entries(ShapeSearchTree p_tree) - { - if (this.search_trees_info == null) - { + public ShapeTree.Leaf[] get_search_tree_entries(ShapeSearchTree p_tree) { + if (this.search_trees_info == null) { return null; } return this.search_trees_info.get_tree_entries(p_tree); @@ -1186,14 +1028,11 @@ public ShapeTree.Leaf[] get_search_tree_entries(ShapeSearchTree p_tree) /** * Sets the precalculated tree shapes tree entries for the tree with identification number p_tree_no. */ - protected void set_precalculated_tree_shapes(TileShape[] p_shapes, ShapeSearchTree p_tree) - { - if (this.board == null) - { + protected void set_precalculated_tree_shapes(TileShape[] p_shapes, ShapeSearchTree p_tree) { + if (this.board == null) { return; } - if (this.search_trees_info == null) - { + if (this.search_trees_info == null) { System.out.println("Item.set_precalculated_tree_shapes search_trees_info not allocated"); return; } @@ -1203,8 +1042,7 @@ protected void set_precalculated_tree_shapes(TileShape[] p_shapes, ShapeSearchTr /** * Sets the searh tree entries of this item to null. */ - public void clear_search_tree_entries() - { + public void clear_search_tree_entries() { this.search_trees_info = null; } @@ -1212,10 +1050,8 @@ public void clear_search_tree_entries() * Gets the information for the autoroute algorithm. * Creates it, if it does not yet exist. */ - public net.freerouting.autoroute.ItemAutorouteInfo get_autoroute_info() - { - if (autoroute_info == null) - { + public net.freerouting.autoroute.ItemAutorouteInfo get_autoroute_info() { + if (autoroute_info == null) { autoroute_info = new net.freerouting.autoroute.ItemAutorouteInfo(this); } return autoroute_info; @@ -1224,16 +1060,14 @@ public net.freerouting.autoroute.ItemAutorouteInfo get_autoroute_info() /** * Gets the information for the autoroute algorithm. */ - public net.freerouting.autoroute.ItemAutorouteInfo get_autoroute_info_pur() - { + public net.freerouting.autoroute.ItemAutorouteInfo get_autoroute_info_pur() { return autoroute_info; } /** * Clears the data allocated for the autoroute algorithm. */ - public void clear_autoroute_info() - { + public void clear_autoroute_info() { autoroute_info = null; } @@ -1241,10 +1075,8 @@ public void clear_autoroute_info() * Clear all cached or derived data. so that they have to be recalculated, * when they are used next time. */ - public void clear_derived_data() - { - if (this.search_trees_info != null) - { + public void clear_derived_data() { + if (this.search_trees_info != null) { this.search_trees_info.clear_precalculated_tree_shapes(); } autoroute_info = null; @@ -1253,12 +1085,10 @@ public void clear_derived_data() /** * Internal funktion used in the implementation of print_info */ - protected void print_net_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { + protected void print_net_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); - for (int i = 0; i < this.net_count(); ++i) - { + for (int i = 0; i < this.net_count(); ++i) { p_window.append(", " + resources.getString("net") + " "); net.freerouting.rules.Net curr_net = board.rules.nets.get(this.get_net_no(i)); p_window.append(curr_net.name, resources.getString("net_info"), curr_net); @@ -1268,10 +1098,8 @@ protected void print_net_info(ObjectInfoPanel p_window, java.util.Locale p_local /** * Internal funktion used in the implementation of print_info */ - protected void print_clearance_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { - if (this.clearance_class > 0) - { + protected void print_clearance_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { + if (this.clearance_class > 0) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append(", " + resources.getString("clearance_class") + " "); @@ -1283,10 +1111,8 @@ protected void print_clearance_info(ObjectInfoPanel p_window, java.util.Locale p /** * Internal funktion used in the implementation of print_info */ - protected void print_fixed_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { - if (this.fixed_state != FixedState.UNFIXED) - { + protected void print_fixed_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { + if (this.fixed_state != FixedState.UNFIXED) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.FixedState", p_locale); p_window.append(", "); @@ -1297,11 +1123,9 @@ protected void print_fixed_info(ObjectInfoPanel p_window, java.util.Locale p_loc /** * Internal funktion used in the implementation of print_info */ - protected void print_contact_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { + protected void print_contact_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { Collection contacts = this.get_normal_contacts(); - if (!contacts.isEmpty()) - { + if (!contacts.isEmpty()) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append(", " + resources.getString("contacts") + " "); @@ -1313,11 +1137,9 @@ protected void print_contact_info(ObjectInfoPanel p_window, java.util.Locale p_l /** * Internal funktion used in the implementation of print_info */ - protected void print_clearance_violation_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { + protected void print_clearance_violation_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { Collection clearance_violations = this.clearance_violations(); - if (!clearance_violations.isEmpty()) - { + if (!clearance_violations.isEmpty()) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append(", "); @@ -1325,12 +1147,9 @@ protected void print_clearance_violation_info(ObjectInfoPanel p_window, java.uti Collection violations = new java.util.LinkedList(); violations.addAll(clearance_violations); p_window.append_objects(violation_count.toString(), resources.getString("violation_info"), violations); - if (violation_count == 1) - { + if (violation_count == 1) { p_window.append(" " + resources.getString("clearance_violation")); - } - else - { + } else { p_window.append(" " + resources.getString("clearance_violations")); } } @@ -1339,8 +1158,7 @@ protected void print_clearance_violation_info(ObjectInfoPanel p_window, java.uti /** * Internal funktion used in the implementation of print_info */ - protected void print_connectable_item_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { + protected void print_connectable_item_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { this.print_clearance_info(p_window, p_locale); this.print_fixed_info(p_window, p_locale); this.print_net_info(p_window, p_locale); @@ -1351,8 +1169,7 @@ protected void print_connectable_item_info(ObjectInfoPanel p_window, java.util.L /** * Internal funktion used in the implementation of print_info */ - protected void print_item_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { + protected void print_item_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { this.print_clearance_info(p_window, p_locale); this.print_fixed_info(p_window, p_locale); this.print_clearance_violation_info(p_window, p_locale); @@ -1361,12 +1178,9 @@ protected void print_item_info(ObjectInfoPanel p_window, java.util.Locale p_loca /** * Checks, if all nets of this items are normal. */ - public boolean nets_normal() - { - for (int i = 0; i < this.net_no_arr.length; ++i) - { - if (!Nets.is_normal_net_no(this.net_no_arr[i])) - { + public boolean nets_normal() { + for (int i = 0; i < this.net_no_arr.length; ++i) { + if (!Nets.is_normal_net_no(this.net_no_arr[i])) { return false; } } @@ -1376,24 +1190,19 @@ public boolean nets_normal() /** * Checks, if this item and p_other contain exactly the same net numbers. */ - public boolean nets_equal(Item p_other) - { + public boolean nets_equal(Item p_other) { return nets_equal(p_other.net_no_arr); } /** * Checks, if this item contains exacly the nets in p_net_no_arr */ - public boolean nets_equal(int[] p_net_no_arr) - { - if (this.net_no_arr.length != p_net_no_arr.length) - { + public boolean nets_equal(int[] p_net_no_arr) { + if (this.net_no_arr.length != p_net_no_arr.length) { return false; } - for (int curr_net_no : p_net_no_arr) - { - if (!this.contains_net(curr_net_no)) - { + for (int curr_net_no : p_net_no_arr) { + if (!this.contains_net(curr_net_no)) { return false; } } @@ -1401,42 +1210,32 @@ public boolean nets_equal(int[] p_net_no_arr) } /** - * Returns true, if the via is directly ob by a trace connected to a nearby SMD-pin. + * Returns true, if the via is directly ob by a trace connected to a nearby SMD-pin. * If p_ignore_items != null, contact traces in P-ignore_items are ignored. */ - boolean is_fanout_via(Set p_ignore_items) - { + boolean is_fanout_via(Set p_ignore_items) { Collection contact_list = this.get_normal_contacts(); - for (Item curr_contact : contact_list) - { - if (curr_contact instanceof Pin && curr_contact.first_layer() == curr_contact.last_layer() && curr_contact.get_normal_contacts().size() <= 1) - { + for (Item curr_contact : contact_list) { + if (curr_contact instanceof Pin && curr_contact.first_layer() == curr_contact.last_layer() && curr_contact.get_normal_contacts().size() <= 1) { return true; } - if (curr_contact instanceof Trace) - { - if (p_ignore_items != null && p_ignore_items.contains(curr_contact)) - { + if (curr_contact instanceof Trace) { + if (p_ignore_items != null && p_ignore_items.contains(curr_contact)) { continue; } Trace curr_trace = (Trace) curr_contact; - if (curr_trace.get_length() >= PROTECT_FANOUT_LENGTH * curr_trace.get_half_width()) - { + if (curr_trace.get_length() >= PROTECT_FANOUT_LENGTH * curr_trace.get_half_width()) { continue; } Collection trace_contact_list = curr_trace.get_normal_contacts(); - for (Item tmp_contact : trace_contact_list) - { - if (tmp_contact instanceof Pin && curr_contact.first_layer() == curr_contact.last_layer() && tmp_contact.get_normal_contacts().size() <= 1) - { + for (Item tmp_contact : trace_contact_list) { + if (tmp_contact instanceof Pin && curr_contact.first_layer() == curr_contact.last_layer() && tmp_contact.get_normal_contacts().size() <= 1) { return true; } - if (tmp_contact instanceof PolylineTrace && tmp_contact.get_fixed_state() == FixedState.SHOVE_FIXED) - { + if (tmp_contact instanceof PolylineTrace && tmp_contact.get_fixed_state() == FixedState.SHOVE_FIXED) { // look for shove fixed exit traces of SMD-pins PolylineTrace contact_trace = (PolylineTrace) tmp_contact; - if (contact_trace.corner_count() == 2) - { + if (contact_trace.corner_count() == 2) { return true; } } @@ -1445,35 +1244,12 @@ boolean is_fanout_via(Set p_ignore_items) } return false; } - /** - * the index in the clearance matrix describing the required spacing - * to other items - */ - private int clearance_class; - /** The board this Itewm is on */ - transient public BasicBoard board; - /** The nets, to which this item belongs */ - int[] net_no_arr; - /** points to the entries of this item in the ShapeSearchTrees */ - transient private ItemSearchTreesInfo search_trees_info = null; - private FixedState fixed_state; - /** not 0, if this item belongs to a component */ - private int component_no = 0; - private final int id_no; - /** - * Folse, if the item is deleted or not inserted into the board - */ - private boolean on_the_board = false; - /** Temporary data used in the autoroute algorithm. */ - transient private net.freerouting.autoroute.ItemAutorouteInfo autoroute_info = null; - private static double PROTECT_FANOUT_LENGTH = 400; /** - * Used as parameter of get_connection to control, that the connection - * stops at the next fanout via or at any via. + * Used as parameter of get_connection to control, that the connection + * stops at the next fanout via or at any via. */ - public enum StopConnectionOption - { + public enum StopConnectionOption { NONE, FANOUT_VIA, VIA } diff --git a/src/main/java/net/freerouting/board/ItemIdNoGenerator.java b/src/main/java/net/freerouting/board/ItemIdNoGenerator.java index fa72cf69..71312eb0 100644 --- a/src/main/java/net/freerouting/board/ItemIdNoGenerator.java +++ b/src/main/java/net/freerouting/board/ItemIdNoGenerator.java @@ -23,41 +23,36 @@ /** * Creates unique Item identication nunbers. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class ItemIdNoGenerator implements net.freerouting.datastructures.IdNoGenerator, java.io.Serializable -{ - +public class ItemIdNoGenerator implements net.freerouting.datastructures.IdNoGenerator, java.io.Serializable { + + static final private int c_max_id_no = Integer.MAX_VALUE / 2; + private int last_generated_id_no = 0; + /** * Creates a new ItemIdNoGenerator */ - public ItemIdNoGenerator() - { + public ItemIdNoGenerator() { } - + /** * Create a new unique identification number. * Use eventually the id_no generater from the host system * for syncronisation */ - public int new_no() - { - if (last_generated_id_no >= c_max_id_no) - { + public int new_no() { + if (last_generated_id_no >= c_max_id_no) { System.out.println("IdNoGenerator: danger of overflow, please regenerate id numbers from scratch!"); } ++last_generated_id_no; return last_generated_id_no; } - + /** * Return the maximum generated id number so far. */ - public int max_generated_no() - { + public int max_generated_no() { return last_generated_id_no; } - - private int last_generated_id_no = 0; - static final private int c_max_id_no = Integer.MAX_VALUE / 2; } diff --git a/src/main/java/net/freerouting/board/ItemSearchTreesInfo.java b/src/main/java/net/freerouting/board/ItemSearchTreesInfo.java index b8131d44..5362a2f7 100644 --- a/src/main/java/net/freerouting/board/ItemSearchTreesInfo.java +++ b/src/main/java/net/freerouting/board/ItemSearchTreesInfo.java @@ -21,53 +21,48 @@ package net.freerouting.board; +import net.freerouting.datastructures.ShapeTree; +import net.freerouting.geometry.planar.TileShape; + import java.util.Collection; import java.util.LinkedList; -import net.freerouting.datastructures.ShapeTree; - -import net.freerouting.geometry.planar.TileShape; - /** * Stores information about the search trees of the board items, * which is precalculated for performance reasons. * * @author Alfons Wirtz */ -class ItemSearchTreesInfo -{ - - /** Creates a new instance of ItemSearchTreeEntries */ - public ItemSearchTreesInfo() - { +class ItemSearchTreesInfo { + + private final Collection tree_list; + + /** + * Creates a new instance of ItemSearchTreeEntries + */ + public ItemSearchTreesInfo() { this.tree_list = new LinkedList(); } - + /** * Returns the tree entries for the tree with identification number p_tree_no, * or null, if for this tree no entries of this item are inserted. */ - public ShapeTree.Leaf[] get_tree_entries(ShapeTree p_tree) - { - for (SearchTreeInfo curr_tree_info : this.tree_list) - { - if (curr_tree_info.tree == p_tree) - { + public ShapeTree.Leaf[] get_tree_entries(ShapeTree p_tree) { + for (SearchTreeInfo curr_tree_info : this.tree_list) { + if (curr_tree_info.tree == p_tree) { return curr_tree_info.entry_arr; } } return null; } - + /** * Sets the item tree entries for the tree with identification number p_tree_no. */ - public void set_tree_entries(ShapeTree.Leaf[] p_tree_entries, ShapeTree p_tree) - { - for (SearchTreeInfo curr_tree_info : this.tree_list) - { - if (curr_tree_info.tree == p_tree) - { + public void set_tree_entries(ShapeTree.Leaf[] p_tree_entries, ShapeTree p_tree) { + for (SearchTreeInfo curr_tree_info : this.tree_list) { + if (curr_tree_info.tree == p_tree) { curr_tree_info.entry_arr = p_tree_entries; return; } @@ -76,32 +71,26 @@ public void set_tree_entries(ShapeTree.Leaf[] p_tree_entries, ShapeTree p_tree) new_tree_info.entry_arr = p_tree_entries; this.tree_list.add(new_tree_info); } - + /** * Returns the precalculated tiles hapes for the tree with identification number p_tree_no, * or null, if the tile shapes of this tree are nnot yet precalculated. */ - public TileShape[] get_precalculated_tree_shapes(ShapeTree p_tree) - { - for (SearchTreeInfo curr_tree_info : this.tree_list) - { - if (curr_tree_info.tree == p_tree) - { + public TileShape[] get_precalculated_tree_shapes(ShapeTree p_tree) { + for (SearchTreeInfo curr_tree_info : this.tree_list) { + if (curr_tree_info.tree == p_tree) { return curr_tree_info.precalculated_tree_shapes; } } return null; } - + /** * Sets the item tree entries for the tree with identification number p_tree_no. */ - public void set_precalculated_tree_shapes(TileShape[] p_tile_shapes, ShapeTree p_tree) - { - for (SearchTreeInfo curr_tree_info : this.tree_list) - { - if (curr_tree_info.tree == p_tree) - { + public void set_precalculated_tree_shapes(TileShape[] p_tile_shapes, ShapeTree p_tree) { + for (SearchTreeInfo curr_tree_info : this.tree_list) { + if (curr_tree_info.tree == p_tree) { curr_tree_info.precalculated_tree_shapes = p_tile_shapes; return; } @@ -110,33 +99,25 @@ public void set_precalculated_tree_shapes(TileShape[] p_tile_shapes, ShapeTree p new_tree_info.precalculated_tree_shapes = p_tile_shapes; this.tree_list.add(new_tree_info); } - + /** * clears the stored information about the precalculated tree shapes for all search trees. */ - public void clear_precalculated_tree_shapes() - { - for (SearchTreeInfo curr_tree_info : this.tree_list) - { - + public void clear_precalculated_tree_shapes() { + for (SearchTreeInfo curr_tree_info : this.tree_list) { + curr_tree_info.precalculated_tree_shapes = null; } } - - - private final Collection tree_list; - - private static class SearchTreeInfo - { - SearchTreeInfo(ShapeTree p_tree) - { + + private static class SearchTreeInfo { + final ShapeTree tree; + ShapeTree.Leaf[] entry_arr; + TileShape[] precalculated_tree_shapes; + SearchTreeInfo(ShapeTree p_tree) { tree = p_tree; entry_arr = null; precalculated_tree_shapes = null; } - - final ShapeTree tree; - ShapeTree.Leaf [] entry_arr; - TileShape [] precalculated_tree_shapes; } } diff --git a/src/main/java/net/freerouting/board/ItemSelectionFilter.java b/src/main/java/net/freerouting/board/ItemSelectionFilter.java index 51fcb8a1..a6c10993 100644 --- a/src/main/java/net/freerouting/board/ItemSelectionFilter.java +++ b/src/main/java/net/freerouting/board/ItemSelectionFilter.java @@ -28,21 +28,16 @@ * * @author Alfons Wirtz */ -public class ItemSelectionFilter implements java.io.Serializable -{ +public class ItemSelectionFilter implements java.io.Serializable { /** - * The possible choices in the filter. + * the filter array of the item types */ - public enum SelectableChoices - { - TRACES, VIAS, PINS, CONDUCTION, KEEPOUT, VIA_KEEPOUT, COMPONENT_KEEPOUT, BOARD_OUTLINE, FIXED, UNFIXED - } - + private final boolean[] values; + /** * Creates a new filter with all item types selected. */ - public ItemSelectionFilter() - { + public ItemSelectionFilter() { this.values = new boolean[SelectableChoices.values().length]; java.util.Arrays.fill(this.values, true); this.values[SelectableChoices.KEEPOUT.ordinal()] = false; @@ -51,94 +46,86 @@ public ItemSelectionFilter() this.values[SelectableChoices.CONDUCTION.ordinal()] = false; this.values[SelectableChoices.BOARD_OUTLINE.ordinal()] = false; } - + /** * Creates a new filter with only p_item_type selected. */ - public ItemSelectionFilter(SelectableChoices p_item_type) - { + public ItemSelectionFilter(SelectableChoices p_item_type) { this.values = new boolean[SelectableChoices.values().length]; java.util.Arrays.fill(this.values, false); values[p_item_type.ordinal()] = true; values[SelectableChoices.FIXED.ordinal()] = true; values[SelectableChoices.UNFIXED.ordinal()] = true; } - + /** * Creates a new filter with only p_item_types selected. */ - public ItemSelectionFilter(SelectableChoices[] p_item_types) - { + public ItemSelectionFilter(SelectableChoices[] p_item_types) { this.values = new boolean[SelectableChoices.values().length]; java.util.Arrays.fill(this.values, false); - for (int i = 0; i < p_item_types.length; ++i) - { + for (int i = 0; i < p_item_types.length; ++i) { values[p_item_types[i].ordinal()] = true; } values[SelectableChoices.FIXED.ordinal()] = true; values[SelectableChoices.UNFIXED.ordinal()] = true; } - + /** * Copy constructor */ - public ItemSelectionFilter(ItemSelectionFilter p_item_selection_filter) - { + public ItemSelectionFilter(ItemSelectionFilter p_item_selection_filter) { this.values = new boolean[SelectableChoices.values().length]; - for (int i = 0; i < this.values.length; ++i) - { + for (int i = 0; i < this.values.length; ++i) { this.values[i] = p_item_selection_filter.values[i]; } } - + /** * Selects or deselects an item type */ - public void set_selected(SelectableChoices p_choice, boolean p_value) - { + public void set_selected(SelectableChoices p_choice, boolean p_value) { values[p_choice.ordinal()] = p_value; } - + /** * Selects all item types. */ - public void select_all() - { + public void select_all() { java.util.Arrays.fill(values, true); } - + /** * Deselects all item types. */ - public void deselect_all() - { + public void deselect_all() { java.util.Arrays.fill(values, false); } - + /** * Filters a collection of items with this filter. */ - public Set filter(java.util.Set p_items) - { + public Set filter(java.util.Set p_items) { Set result = new TreeSet(); - for (net.freerouting.board.Item curr_item : p_items) - { - if (curr_item.is_selected_by_filter(this)) - { + for (net.freerouting.board.Item curr_item : p_items) { + if (curr_item.is_selected_by_filter(this)) { result.add(curr_item); } } return result; } - + /** * Looks, if the input item type is selected. */ - public boolean is_selected(SelectableChoices p_choice) - { + public boolean is_selected(SelectableChoices p_choice) { return values[p_choice.ordinal()]; } - - /** the filter array of the item types */ - private final boolean[] values; + + /** + * The possible choices in the filter. + */ + public enum SelectableChoices { + TRACES, VIAS, PINS, CONDUCTION, KEEPOUT, VIA_KEEPOUT, COMPONENT_KEEPOUT, BOARD_OUTLINE, FIXED, UNFIXED + } } diff --git a/src/main/java/net/freerouting/board/Layer.java b/src/main/java/net/freerouting/board/Layer.java index c6ce8763..d4abbf02 100644 --- a/src/main/java/net/freerouting/board/Layer.java +++ b/src/main/java/net/freerouting/board/Layer.java @@ -23,29 +23,29 @@ /** * Describes the structure of a board layer. * - * @author alfons + * @author alfons */ -public class Layer implements java.io.Serializable -{ - - /** Creates a new instance of Layer */ - public Layer(String p_name, boolean p_is_signal) - { - name = p_name; - is_signal = p_is_signal; - } - - public String toString() - { - return name; - } - - /** The name of the layer. */ +public class Layer implements java.io.Serializable { + + /** + * The name of the layer. + */ public final String name; - - /** + /** * True, if this is a signal layer, which can be used for routing. * Otherwise it may be for example a power ground layer. */ public final boolean is_signal; + + /** + * Creates a new instance of Layer + */ + public Layer(String p_name, boolean p_is_signal) { + name = p_name; + is_signal = p_is_signal; + } + + public String toString() { + return name; + } } diff --git a/src/main/java/net/freerouting/board/LayerStructure.java b/src/main/java/net/freerouting/board/LayerStructure.java index 3dbaa072..f8840592 100644 --- a/src/main/java/net/freerouting/board/LayerStructure.java +++ b/src/main/java/net/freerouting/board/LayerStructure.java @@ -23,77 +23,66 @@ /** * Describes the layer structure of the board. * - * @author alfons + * @author alfons */ -public class LayerStructure implements java.io.Serializable -{ - - /** Creates a new instance of LayerStructure */ - public LayerStructure(Layer [] p_layer_arr) - { +public class LayerStructure implements java.io.Serializable { + + public final Layer[] arr; + + /** + * Creates a new instance of LayerStructure + */ + public LayerStructure(Layer[] p_layer_arr) { arr = p_layer_arr; } - + /** * Returns the index of the layer with the name p_name in the array arr, * -1, if arr contains no layer with name p_name. */ - public int get_no(String p_name) - { - for (int i = 0; i < arr.length; ++i) - { - if (p_name.equals(arr[i].name)) - { + public int get_no(String p_name) { + for (int i = 0; i < arr.length; ++i) { + if (p_name.equals(arr[i].name)) { return i; } } return -1; } - + /** * Returns the index of p_layer in the array arr, * or -1, if arr does not contain p_layer. */ - public int get_no(Layer p_layer) - { - for (int i = 0; i < arr.length; ++i) - { - if (p_layer == arr[i]) - { + public int get_no(Layer p_layer) { + for (int i = 0; i < arr.length; ++i) { + if (p_layer == arr[i]) { return i; } } return -1; } - + /** * Returns the count of signal layers of this layer_structure. */ - public int signal_layer_count() - { + public int signal_layer_count() { int found_signal_layers = 0; - for (int i = 0; i < arr.length; ++i) - { - if (arr[i].is_signal) - { + for (int i = 0; i < arr.length; ++i) { + if (arr[i].is_signal) { ++found_signal_layers; } } return found_signal_layers; } - + /** * Gets the p_no-th signal layer of this layer structure. */ - public Layer get_signal_layer(int p_no) - { + public Layer get_signal_layer(int p_no) { int found_signal_layers = 0; - for (int i = 0; i < arr.length; ++i) - { - if (arr[i].is_signal) - { - if (p_no == found_signal_layers) - { + for (int i = 0; i < arr.length; ++i) { + if (arr[i].is_signal) { + if (p_no == found_signal_layers) { return arr[i]; } ++found_signal_layers; @@ -101,35 +90,28 @@ public Layer get_signal_layer(int p_no) } return arr[arr.length - 1]; } - + /** * Returns the count of signal layers with a smaller number than p_layer */ - public int get_signal_layer_no(Layer p_layer) - { + public int get_signal_layer_no(Layer p_layer) { int found_signal_layers = 0; - for (int i = 0; i < arr.length; ++i) - { - if (arr[i] == p_layer) - { + for (int i = 0; i < arr.length; ++i) { + if (arr[i] == p_layer) { return found_signal_layers; } - if (arr[i].is_signal) - { + if (arr[i].is_signal) { ++found_signal_layers; } } return -1; } - + /** * Gets the layer number of the p_signal_layer_no-th signal layer in this layer structure */ - public int get_layer_no (int p_signal_layer_no) - { - Layer curr_signal_layer = get_signal_layer(p_signal_layer_no); - return get_no(curr_signal_layer); + public int get_layer_no(int p_signal_layer_no) { + Layer curr_signal_layer = get_signal_layer(p_signal_layer_no); + return get_no(curr_signal_layer); } - - public final Layer [] arr; } diff --git a/src/main/java/net/freerouting/board/MoveComponent.java b/src/main/java/net/freerouting/board/MoveComponent.java index 9939cc01..e8c81235 100644 --- a/src/main/java/net/freerouting/board/MoveComponent.java +++ b/src/main/java/net/freerouting/board/MoveComponent.java @@ -19,8 +19,8 @@ */ package net.freerouting.board; +import net.freerouting.datastructures.Signum; import net.freerouting.datastructures.TimeLimit; - import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntPoint; import net.freerouting.geometry.planar.Point; @@ -30,63 +30,61 @@ import java.util.Iterator; import java.util.LinkedList; -import net.freerouting.datastructures.Signum; - /** * Class for moving a group of items on the board - * @author Alfons Wirtz + * + * @author Alfons Wirtz */ -public class MoveComponent -{ +public class MoveComponent { - /** Creates a new instance of MoveItemGroup */ - public MoveComponent(Item p_item, Vector p_translate_vector, int p_max_recursion_depth, int p_max_via_recursion_depth) - { + private static int PULL_TIGHT_TIME_LIMIT = 1000; + private static int CHECK_TIME_LIMIT = 3000; + private final Vector translate_vector; + private final int max_recursion_depth; + private final int max_via_recursion_depth; + private final RoutingBoard board; + private boolean all_items_movable = true; + private SortedItem[] item_group_arr; + private Component component = null; + /** + * Creates a new instance of MoveItemGroup + */ + public MoveComponent(Item p_item, Vector p_translate_vector, int p_max_recursion_depth, int p_max_via_recursion_depth) { translate_vector = p_translate_vector; max_recursion_depth = p_max_recursion_depth; max_via_recursion_depth = p_max_via_recursion_depth; - if (p_item.board instanceof RoutingBoard) - { + if (p_item.board instanceof RoutingBoard) { board = (RoutingBoard) p_item.board; - } - else - { + } else { board = null; all_items_movable = false; } Collection item_group_list; int component_no = p_item.get_component_no(); - if (component_no > 0) - { + if (component_no > 0) { item_group_list = board.get_component_items(component_no); this.component = board.components.get(component_no); - } - else - { + } else { item_group_list = new LinkedList(); item_group_list.add(p_item); } Collection item_centers = new LinkedList(); - for (Item curr_item : item_group_list) - { + for (Item curr_item : item_group_list) { boolean curr_item_movable = !curr_item.is_user_fixed() && ((curr_item instanceof DrillItem) || (curr_item instanceof ObstacleArea) || (curr_item instanceof ComponentOutline)); - if (!curr_item_movable) - { + if (!curr_item_movable) { // MoveItemGroup currently only implemented for DrillItems all_items_movable = false; return; } - if (curr_item instanceof DrillItem) - { + if (curr_item instanceof DrillItem) { item_centers.add(((DrillItem) curr_item).get_center().to_float()); } } // calculate the gravity point of all item centers double gravity_x = 0; double gravity_y = 0; - for (FloatPoint curr_center : item_centers) - { + for (FloatPoint curr_center : item_centers) { gravity_x += curr_center.x; gravity_y += curr_center.y; } @@ -95,16 +93,12 @@ public MoveComponent(Item p_item, Vector p_translate_vector, int p_max_recursion Point gravity_point = new IntPoint((int) Math.round(gravity_x), (int) Math.round(gravity_y)); item_group_arr = new SortedItem[item_group_list.size()]; Iterator it = item_group_list.iterator(); - for (int i = 0; i < item_group_arr.length; ++i) - { + for (int i = 0; i < item_group_arr.length; ++i) { Item curr_item = it.next(); Point item_center; - if (curr_item instanceof DrillItem) - { + if (curr_item instanceof DrillItem) { item_center = ((DrillItem) curr_item).get_center(); - } - else - { + } else { item_center = curr_item.bounding_box().centre_of_gravity().round(); } Vector compare_vector = gravity_point.difference_by(item_center); @@ -120,38 +114,28 @@ public MoveComponent(Item p_item, Vector p_translate_vector, int p_max_recursion * Checks, if all items in the group can be moved by shoving obstacle trace aside * without creating clearance violations. */ - public boolean check() - { - if (!all_items_movable) - { + public boolean check() { + if (!all_items_movable) { return false; } TimeLimit time_limit = new TimeLimit(CHECK_TIME_LIMIT); Collection ignore_items = new LinkedList(); - for (int i = 0; i < item_group_arr.length; ++i) - { + for (int i = 0; i < item_group_arr.length; ++i) { boolean move_ok; - if (item_group_arr[i].item instanceof DrillItem) - { + if (item_group_arr[i].item instanceof DrillItem) { DrillItem curr_drill_item = (DrillItem) item_group_arr[i].item; - if (this.translate_vector.length_approx() >= curr_drill_item.min_width()) - { + if (this.translate_vector.length_approx() >= curr_drill_item.min_width()) { // a clearance violation with a connecting trace may occur move_ok = false; - } - else - { + } else { move_ok = MoveDrillItemAlgo.check(curr_drill_item, this.translate_vector, this.max_recursion_depth, this.max_via_recursion_depth, ignore_items, board, time_limit); } - } - else - { + } else { move_ok = board.check_move_item(item_group_arr[i].item, this.translate_vector, ignore_items); } - if (!move_ok) - { + if (!move_ok) { return false; } } @@ -163,72 +147,52 @@ public boolean check() * obstacle traces. Returns false, if that was not possible without * creating clearance violations. In this case an undo may be necessary. */ - public boolean insert(int p_tidy_width, int p_pull_tight_accuracy) - { - if (!all_items_movable) - { + public boolean insert(int p_tidy_width, int p_pull_tight_accuracy) { + if (!all_items_movable) { return false; } - if (this.component != null) - { + if (this.component != null) { // component must be moved first, so that the new pin shapes are calculeted correctly board.components.move(this.component.no, translate_vector); // let the observers syncronize the moving board.communication.observers.notify_moved(this.component); } - for (int i = 0; i < item_group_arr.length; ++i) - { - if (item_group_arr[i].item instanceof DrillItem) - { + for (int i = 0; i < item_group_arr.length; ++i) { + if (item_group_arr[i].item instanceof DrillItem) { DrillItem curr_drill_item = (DrillItem) item_group_arr[i].item; boolean move_ok = board.move_drill_item(curr_drill_item, this.translate_vector, this.max_recursion_depth, this.max_via_recursion_depth, p_tidy_width, p_pull_tight_accuracy, PULL_TIGHT_TIME_LIMIT); - if (!move_ok) - { - if (this.component != null) - { + if (!move_ok) { + if (this.component != null) { this.component.translate_by(translate_vector.negate()); // Otherwise the component outline is not restored correctly by the undo algorithm. } return false; } - } - else - { + } else { item_group_arr[i].item.move_by(this.translate_vector); } } return true; } - private final Vector translate_vector; - private final int max_recursion_depth; - private final int max_via_recursion_depth; - private final RoutingBoard board; - private boolean all_items_movable = true; - private SortedItem[] item_group_arr; - private Component component = null; - private static int PULL_TIGHT_TIME_LIMIT = 1000; - private static int CHECK_TIME_LIMIT = 3000; /** * used to sort the group items in the direction of translate_vector, * so that the front items can be moved first. */ - private static class SortedItem implements Comparable - { + private static class SortedItem implements Comparable { - SortedItem(Item p_item, double p_projection) - { + final Item item; + final double projection; + + SortedItem(Item p_item, double p_projection) { item = p_item; projection = p_projection; } - public int compareTo(SortedItem p_other) - { + public int compareTo(SortedItem p_other) { return Signum.as_int(this.projection - p_other.projection); } - final Item item; - final double projection; } } diff --git a/src/main/java/net/freerouting/board/MoveDrillItemAlgo.java b/src/main/java/net/freerouting/board/MoveDrillItemAlgo.java index 5320e9ef..20bbed36 100644 --- a/src/main/java/net/freerouting/board/MoveDrillItemAlgo.java +++ b/src/main/java/net/freerouting/board/MoveDrillItemAlgo.java @@ -21,204 +21,161 @@ package net.freerouting.board; -import java.util.Collection; - import net.freerouting.datastructures.TimeLimit; +import net.freerouting.geometry.planar.*; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.ConvexShape; -import net.freerouting.geometry.planar.IntOctagon; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.FloatPoint; +import java.util.Collection; /** - * * Contains internal auxiliary functions of class RoutingBoard * for shoving vias and pins * * @author Alfons Wirtz */ -public class MoveDrillItemAlgo -{ - +public class MoveDrillItemAlgo { + /** * checks, if p_drill_item can be translated by p_vector by shoving obstacle * traces and vias aside, so that no clearance violations occur. */ public static boolean check(DrillItem p_drill_item, Vector p_vector, int p_max_recursion_depth, - int p_max_via_recursion_depth, Collection p_ignore_items, - RoutingBoard p_board, TimeLimit p_time_limit) - { - - if (p_time_limit != null && p_time_limit.limit_exceeded()) - { + int p_max_via_recursion_depth, Collection p_ignore_items, + RoutingBoard p_board, TimeLimit p_time_limit) { + + if (p_time_limit != null && p_time_limit.limit_exceeded()) { return false; } - if (p_drill_item.is_shove_fixed()) - { + if (p_drill_item.is_shove_fixed()) { return false; } - + // Check, that p_drillitem is only connected to traces. Collection contact_list = p_drill_item.get_normal_contacts(); - for (Item curr_contact : contact_list) - { - if (!(curr_contact instanceof Trace || curr_contact instanceof ConductionArea)) - { + for (Item curr_contact : contact_list) { + if (!(curr_contact instanceof Trace || curr_contact instanceof ConductionArea)) { return false; } } Collection ignore_items; - if (p_ignore_items == null) - { + if (p_ignore_items == null) { ignore_items = new java.util.LinkedList(); - } - else - { + } else { ignore_items = p_ignore_items; } ignore_items.add(p_drill_item); ForcedPadAlgo forced_pad_algo = new ForcedPadAlgo(p_board); boolean attach_allowed = false; - if (p_drill_item instanceof Via) - { - attach_allowed = ((Via)p_drill_item).attach_allowed; + if (p_drill_item instanceof Via) { + attach_allowed = ((Via) p_drill_item).attach_allowed; } ShapeSearchTree search_tree = p_board.search_tree_manager.get_default_tree(); - for (int curr_layer = p_drill_item.first_layer(); curr_layer <= p_drill_item.last_layer(); ++curr_layer) - { + for (int curr_layer = p_drill_item.first_layer(); curr_layer <= p_drill_item.last_layer(); ++curr_layer) { int curr_ind = curr_layer - p_drill_item.first_layer(); TileShape curr_shape = p_drill_item.get_tree_shape(search_tree, curr_ind); - if (curr_shape == null) - { + if (curr_shape == null) { continue; } ConvexShape new_shape = (ConvexShape) curr_shape.translate_by(p_vector); TileShape curr_tile_shape; - if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { curr_tile_shape = new_shape.bounding_box(); - } - else - { + } else { curr_tile_shape = new_shape.bounding_octagon(); } CalcFromSide from_side = new CalcFromSide(p_drill_item.get_center(), curr_tile_shape); if (forced_pad_algo.check_forced_pad(curr_tile_shape, from_side, curr_layer, p_drill_item.net_no_arr, p_drill_item.clearance_class_no(), attach_allowed, ignore_items, p_max_recursion_depth, p_max_via_recursion_depth, true, p_time_limit) - == ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) - { + == ForcedPadAlgo.CheckDrillResult.NOT_DRILLABLE) { return false; } } return true; } - + /** * Translates p_drill_item by p_vector by shoving obstacle * traces and vias aside, so that no clearance violations occur. * If p_tidy_region != null, it will be joined by the bounding octagons of the translated shapes. */ static boolean insert(DrillItem p_drill_item, Vector p_vector, - int p_max_recursion_depth, int p_max_via_recursion_depth, IntOctagon p_tidy_region, - RoutingBoard p_board) - { - if (p_drill_item.is_shove_fixed()) - { + int p_max_recursion_depth, int p_max_via_recursion_depth, IntOctagon p_tidy_region, + RoutingBoard p_board) { + if (p_drill_item.is_shove_fixed()) { return false; } boolean attach_allowed = false; - if (p_drill_item instanceof Via) - { - attach_allowed = ((Via)p_drill_item).attach_allowed; + if (p_drill_item instanceof Via) { + attach_allowed = ((Via) p_drill_item).attach_allowed; } ForcedPadAlgo forced_pad_algo = new ForcedPadAlgo(p_board); Collection ignore_items = new java.util.LinkedList(); ignore_items.add(p_drill_item); ShapeSearchTree search_tree = p_board.search_tree_manager.get_default_tree(); - for (int curr_layer = p_drill_item.first_layer(); curr_layer <= p_drill_item.last_layer(); ++curr_layer) - { + for (int curr_layer = p_drill_item.first_layer(); curr_layer <= p_drill_item.last_layer(); ++curr_layer) { int curr_ind = curr_layer - p_drill_item.first_layer(); TileShape curr_shape = p_drill_item.get_tree_shape(search_tree, curr_ind); - if (curr_shape == null) - { + if (curr_shape == null) { continue; } ConvexShape new_shape = (ConvexShape) curr_shape.translate_by(p_vector); TileShape curr_tile_shape; - if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { curr_tile_shape = new_shape.bounding_box(); - } - else - { + } else { curr_tile_shape = new_shape.bounding_octagon(); } - if (p_tidy_region != null) - { + if (p_tidy_region != null) { p_tidy_region = p_tidy_region.union(curr_tile_shape.bounding_octagon()); } CalcFromSide from_side = new CalcFromSide(p_drill_item.get_center(), curr_tile_shape); if (!forced_pad_algo.forced_pad(curr_tile_shape, from_side, curr_layer, p_drill_item.net_no_arr, p_drill_item.clearance_class_no(), attach_allowed, - ignore_items, p_max_recursion_depth, p_max_via_recursion_depth)) - { + ignore_items, p_max_recursion_depth, p_max_via_recursion_depth)) { return false; } IntBox curr_bounding_box = curr_shape.bounding_box(); - for (int j = 0; j < 4; ++j) - { - p_board.join_changed_area( curr_bounding_box.corner_approx(j), curr_layer); + for (int j = 0; j < 4; ++j) { + p_board.join_changed_area(curr_bounding_box.corner_approx(j), curr_layer); } } p_drill_item.move_by(p_vector); return true; } - + /** * Shoves vias out of p_obstacle_shape. Returns false, if the database is damaged, so that an undo is necessary afterwards. */ static boolean shove_vias(TileShape p_obstacle_shape, CalcFromSide p_from_side, int p_layer, int[] p_net_no_arr, - int p_cl_type, Collection p_ignore_items, int p_max_recursion_depth, - int p_max_via_recursion_depth, boolean p_copper_sharing_allowed, - RoutingBoard p_board) - { + int p_cl_type, Collection p_ignore_items, int p_max_recursion_depth, + int p_max_via_recursion_depth, boolean p_copper_sharing_allowed, + RoutingBoard p_board) { ShapeSearchTree search_tree = p_board.search_tree_manager.get_default_tree(); ShapeTraceEntries shape_entries = new ShapeTraceEntries(p_obstacle_shape, p_layer, p_net_no_arr, p_cl_type, p_from_side, p_board); Collection obstacles = search_tree.overlapping_items_with_clearance(p_obstacle_shape, p_layer, new int[0], p_cl_type); - - if (!shape_entries.store_items(obstacles, false, p_copper_sharing_allowed)) - { + + if (!shape_entries.store_items(obstacles, false, p_copper_sharing_allowed)) { return true; } - if (p_ignore_items != null) - { + if (p_ignore_items != null) { shape_entries.shove_via_list.removeAll(p_ignore_items); } - if (shape_entries.shove_via_list.isEmpty()) - { + if (shape_entries.shove_via_list.isEmpty()) { return true; } double shape_radius = 0.5 * p_obstacle_shape.bounding_box().min_width(); - for (Via curr_via : shape_entries.shove_via_list) - { - if (curr_via.shares_net_no(p_net_no_arr)) - { + for (Via curr_via : shape_entries.shove_via_list) { + if (curr_via.shares_net_no(p_net_no_arr)) { continue; } - if (p_max_via_recursion_depth <= 0) - { + if (p_max_via_recursion_depth <= 0) { return true; } - IntPoint [] try_via_centers = + IntPoint[] try_via_centers = try_shove_via_points(p_obstacle_shape, p_layer, curr_via, p_cl_type, true, p_board); IntPoint new_via_center = null; double max_dist = 0.5 * curr_via.get_shape_on_layer(p_layer).bounding_box().max_width() + shape_radius; @@ -226,115 +183,92 @@ static boolean shove_vias(TileShape p_obstacle_shape, CalcFromSide p_from_side, IntPoint curr_via_center = (IntPoint) curr_via.get_center(); FloatPoint check_via_center = curr_via_center.to_float(); Vector rel_coor = null; - for (int i = 0; i < try_via_centers.length; ++i) - { - if (i == 0 || check_via_center.distance_square(try_via_centers[i].to_float()) <= max_dist_square) - { + for (int i = 0; i < try_via_centers.length; ++i) { + if (i == 0 || check_via_center.distance_square(try_via_centers[i].to_float()) <= max_dist_square) { Collection ignore_items = new java.util.LinkedList(); - if (p_ignore_items != null) - { + if (p_ignore_items != null) { ignore_items.addAll(p_ignore_items); } rel_coor = try_via_centers[i].difference_by(curr_via_center); // No time limit here because the item database is already changed. - boolean shove_ok = check(curr_via, rel_coor, p_max_recursion_depth, + boolean shove_ok = check(curr_via, rel_coor, p_max_recursion_depth, p_max_via_recursion_depth - 1, ignore_items, p_board, null); - if (shove_ok) - { + if (shove_ok) { new_via_center = try_via_centers[i]; break; } } } - if (new_via_center == null) - { + if (new_via_center == null) { continue; } - if (!insert(curr_via, rel_coor, p_max_recursion_depth, p_max_via_recursion_depth - 1, null, p_board)) - { + if (!insert(curr_via, rel_coor, p_max_recursion_depth, p_max_via_recursion_depth - 1, null, p_board)) { return false; } } return true; } - + /** * Calculates possible new location for a via to shove outside p_obstacle_shape. * if p_extended_check is true, more than 1 possible new locations are calculated. * The function isused here and in ShoveTraceAlgo.check. */ - static IntPoint[] try_shove_via_points(TileShape p_obstacle_shape, int p_layer, Via p_via, int p_cl_class_no, - boolean p_extended_check, RoutingBoard p_board) - { + static IntPoint[] try_shove_via_points(TileShape p_obstacle_shape, int p_layer, Via p_via, int p_cl_class_no, + boolean p_extended_check, RoutingBoard p_board) { ShapeSearchTree search_tree = p_board.search_tree_manager.get_default_tree(); TileShape curr_via_shape = p_via.get_tree_shape_on_layer(search_tree, p_layer); - if (curr_via_shape == null) - { - return new IntPoint [0]; + if (curr_via_shape == null) { + return new IntPoint[0]; } boolean is_int_octagon = p_obstacle_shape.is_IntOctagon(); double clearance_value = p_board.clearance_value(p_cl_class_no, p_via.clearance_class_no(), p_layer); double shove_distance; - if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE ||is_int_octagon ) - { - shove_distance = 0.5 * curr_via_shape.bounding_box().max_width(); - if (!search_tree.is_clearance_compensation_used()) - { + if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE || is_int_octagon) { + shove_distance = 0.5 * curr_via_shape.bounding_box().max_width(); + if (!search_tree.is_clearance_compensation_used()) { shove_distance += clearance_value; } - } - else - { + } else { // a different algorithm is used for calculating the new via centers shove_distance = 0; - if (!search_tree.is_clearance_compensation_used()) - { + if (!search_tree.is_clearance_compensation_used()) { // enlarge p_obstacle_shape and curr_via_shape by half of the clearance value to syncronize // with the check algorithm in ShapeSearchTree.overlapping_tree_entries_with_clearance shove_distance += 0.5 * clearance_value; } } - + // The additional constant 2 is an empirical value for the tolerance in case of diagonal shoving. - shove_distance += 2; - + shove_distance += 2; + IntPoint curr_via_center = (IntPoint) p_via.get_center(); - IntPoint [] try_via_centers; + IntPoint[] try_via_centers; int try_count = 1; - if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { IntBox curr_offset_box = p_obstacle_shape.bounding_box().offset(shove_distance); - if (p_extended_check) - { + if (p_extended_check) { try_count = 2; } try_via_centers = curr_offset_box.nearest_border_projections(curr_via_center, try_count); - } - else if (is_int_octagon) - { + } else if (is_int_octagon) { IntOctagon curr_offset_octagon = p_obstacle_shape.bounding_octagon().enlarge(shove_distance); - if (p_extended_check) - { + if (p_extended_check) { try_count = 4; } - + try_via_centers = curr_offset_octagon.nearest_border_projections(curr_via_center, try_count); - } - else - { + } else { TileShape curr_offset_shape = (TileShape) p_obstacle_shape.enlarge(shove_distance); - if (!search_tree.is_clearance_compensation_used()) - { + if (!search_tree.is_clearance_compensation_used()) { curr_via_shape = (TileShape) curr_via_shape.enlarge(0.5 * clearance_value); } - if (p_extended_check) - { + if (p_extended_check) { try_count = 4; } - FloatPoint[] shove_deltas = curr_offset_shape.nearest_relative_outside_locations(curr_via_shape, try_count); + FloatPoint[] shove_deltas = curr_offset_shape.nearest_relative_outside_locations(curr_via_shape, try_count); try_via_centers = new IntPoint[shove_deltas.length]; - for (int i = 0; i < try_via_centers.length; ++i) - { + for (int i = 0; i < try_via_centers.length; ++i) { Vector curr_delta = shove_deltas[i].round().difference_by(Point.ZERO); try_via_centers[i] = (IntPoint) curr_via_center.translate_by(curr_delta); } diff --git a/src/main/java/net/freerouting/board/ObjectInfoPanel.java b/src/main/java/net/freerouting/board/ObjectInfoPanel.java index 85f98102..642bff7f 100644 --- a/src/main/java/net/freerouting/board/ObjectInfoPanel.java +++ b/src/main/java/net/freerouting/board/ObjectInfoPanel.java @@ -25,83 +25,81 @@ * * @author Alfons Wirtz */ -public interface ObjectInfoPanel -{ +public interface ObjectInfoPanel { /** * Appends p_string to the window. * Returns false, if that was not possible. */ boolean append(String p_string); - + /** * Appends p_string in bold styleto the window. * Returns false, if that was not possible. */ boolean append_bold(String p_string); - + /** * Appends p_value to the window after * transforming it to the user coordinate sytem. * Returns false, if that was not possible. */ boolean append(double p_value); - + /** * Appends p_value to the window without * transforming it to the user coordinate sytem. * Returns false, if that was not possible. */ boolean append_without_transforming(double p_value); - + /** * Appends p_point to the window * after transforming to the user coordinate sytem. * Returns false, if that was not possible. */ boolean append(net.freerouting.geometry.planar.FloatPoint p_point); - + /** * Appends p_shape to the window * after transforming to the user coordinate sytem. * Returns false, if that was not possible. */ boolean append(net.freerouting.geometry.planar.Shape p_shape, java.util.Locale p_locale); - + /** * Begins a new line in the window. */ boolean newline(); - + /** * Appends a fixed number of spaces to the window. */ boolean indent(); - + /** * Appends a link for creating a new PrintInfoWindow with the information * of p_object to the window. Returns false, if that was not possible. */ - boolean append( String p_link_name, String p_window_title, ObjectInfoPanel.Printable p_object); - - + boolean append(String p_link_name, String p_window_title, ObjectInfoPanel.Printable p_object); + + /** * Appends a link for creating a new PrintInfoWindow with the information * of p_items to the window. Returns false, if that was not possible. */ - boolean append_items( String p_link_name, String p_window_title, java.util.Collection p_items); - + boolean append_items(String p_link_name, String p_window_title, java.util.Collection p_items); + /** * Appends a link for creating a new PrintInfoWindow with the information * of p_objects to the window. Returns false, if that was not possible. */ - boolean append_objects( String p_button_name, String p_window_title, - java.util.Collection p_objects); - + boolean append_objects(String p_button_name, String p_window_title, + java.util.Collection p_objects); + /** * Funktionality needed for objects to print information into an ObjectInfoWindow */ - public interface Printable - { + public interface Printable { /** * Prints information about an ObjectInfoWindow.Printable object into the input window. */ diff --git a/src/main/java/net/freerouting/board/ObstacleArea.java b/src/main/java/net/freerouting/board/ObstacleArea.java index 7c3bf73e..99bba97a 100644 --- a/src/main/java/net/freerouting/board/ObstacleArea.java +++ b/src/main/java/net/freerouting/board/ObstacleArea.java @@ -16,36 +16,43 @@ package net.freerouting.board; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Area; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Vector; +import net.freerouting.boardgraphics.GraphicsContext; +import net.freerouting.geometry.planar.*; import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.FloatPoint; - -import java.awt.Color; -import net.freerouting.boardgraphics.GraphicsContext; +import java.awt.*; /** - * * An item on the board with an relative_area shape, for example keepout, conduction relative_area * - * - * * @author Alfons Wirtz */ -public class ObstacleArea extends Item implements java.io.Serializable -{ +public class ObstacleArea extends Item implements java.io.Serializable { + /** + * For debugging the division into tree shapes + */ + private static final boolean display_tree_shapes = false; + /** + * The name of this ObstacleArea, which is null, if the ObstacleArea doos not belong to a component. + */ + public final String name; + /** + * the layer of this relative_area + */ + private int layer; + private Area relative_area; + private transient Area precalculated_absolute_area = null; + private Vector translation; + private double rotation_in_degree; + private boolean side_changed; + /** * Creates a new relative_area item which may belong to several nets. * p_name is null, if the ObstacleArea does not belong to a component. */ ObstacleArea(Area p_area, int p_layer, Vector p_translation, double p_rotation_in_degree, boolean p_side_changed, - int[] p_net_no_arr, int p_clearance_type, int p_id_no, int p_cmp_no, String p_name, FixedState p_fixed_state, BasicBoard p_board) - { + int[] p_net_no_arr, int p_clearance_type, int p_id_no, int p_cmp_no, String p_name, FixedState p_fixed_state, BasicBoard p_board) { super(p_net_no_arr, p_clearance_type, p_id_no, p_cmp_no, p_fixed_state, p_board); this.relative_area = p_area; this.layer = p_layer; @@ -54,252 +61,203 @@ public class ObstacleArea extends Item implements java.io.Serializable this.side_changed = p_side_changed; this.name = p_name; } - + /** * Creates a new relative_area item without net. * p_name is null, if the ObstacleArea does not belong to a component. */ ObstacleArea(Area p_area, int p_layer, Vector p_translation, double p_rotation_in_degree, boolean p_side_changed, - int p_clearance_type, int p_id_no, int p_group_no, String p_name, FixedState p_fixed_state, BasicBoard p_board) - { + int p_clearance_type, int p_id_no, int p_group_no, String p_name, FixedState p_fixed_state, BasicBoard p_board) { this(p_area, p_layer, p_translation, p_rotation_in_degree, p_side_changed, new int[0], p_clearance_type, p_id_no, p_group_no, p_name, p_fixed_state, p_board); } - - public Item copy(int p_id_no) - { - int [] copied_net_nos = new int[net_no_arr.length]; + + public Item copy(int p_id_no) { + int[] copied_net_nos = new int[net_no_arr.length]; System.arraycopy(net_no_arr, 0, copied_net_nos, 0, net_no_arr.length); return new ObstacleArea(relative_area, layer, translation, rotation_in_degree, side_changed, copied_net_nos, clearance_class_no(), p_id_no, get_component_no(), name, get_fixed_state(), board); } - - public Area get_area() - { - if (this.precalculated_absolute_area == null) - { - if (this.relative_area == null) - { + + public Area get_area() { + if (this.precalculated_absolute_area == null) { + if (this.relative_area == null) { System.out.println("ObstacleArea.get_area: area is null"); return null; } Area turned_area = this.relative_area; - if (this.side_changed && !this.board.components.get_flip_style_rotate_first()) - { - turned_area = turned_area.mirror_vertical(Point.ZERO); + if (this.side_changed && !this.board.components.get_flip_style_rotate_first()) { + turned_area = turned_area.mirror_vertical(Point.ZERO); } - if (this.rotation_in_degree != 0) - { + if (this.rotation_in_degree != 0) { double rotation = this.rotation_in_degree; - if (rotation % 90 == 0) - { - turned_area = turned_area.turn_90_degree(((int) rotation )/ 90, Point.ZERO); - } - else - { + if (rotation % 90 == 0) { + turned_area = turned_area.turn_90_degree(((int) rotation) / 90, Point.ZERO); + } else { turned_area = turned_area.rotate_approx(Math.toRadians(rotation), FloatPoint.ZERO); } - + } - if (this.side_changed && this.board.components.get_flip_style_rotate_first()) - { - turned_area = turned_area.mirror_vertical(Point.ZERO); + if (this.side_changed && this.board.components.get_flip_style_rotate_first()) { + turned_area = turned_area.mirror_vertical(Point.ZERO); } - this.precalculated_absolute_area = turned_area.translate_by(this.translation); + this.precalculated_absolute_area = turned_area.translate_by(this.translation); } return this.precalculated_absolute_area; } - - protected Area get_relative_area() - { + + protected Area get_relative_area() { return this.relative_area; } - - public boolean is_on_layer(int p_layer) - { + + public boolean is_on_layer(int p_layer) { return layer == p_layer; } - - public int first_layer() - { + + public int first_layer() { return this.layer; } - - public int last_layer() - { + + public int last_layer() { return this.layer; } - - public int get_layer() - { + + public int get_layer() { return this.layer; } - - public IntBox bounding_box() - { + + public IntBox bounding_box() { return this.get_area().bounding_box(); } - - public boolean is_obstacle(Item p_other) - { - if (p_other.shares_net(this)) - { + + public boolean is_obstacle(Item p_other) { + if (p_other.shares_net(this)) { return false; } return p_other instanceof Trace || p_other instanceof Via; } - - protected TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) - { + + protected TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) { return p_search_tree.calculate_tree_shapes(this); } - - public int tile_shape_count() - { + + public int tile_shape_count() { TileShape[] tile_shapes = this.split_to_convex(); - if (tile_shapes == null) - { + if (tile_shapes == null) { // an error accured while dividing the relative_area return 0; } return tile_shapes.length; } - - public TileShape get_tile_shape(int p_no) - { + + public TileShape get_tile_shape(int p_no) { TileShape[] tile_shapes = this.split_to_convex(); - if (tile_shapes == null || p_no < 0 || p_no >= tile_shapes.length) - { + if (tile_shapes == null || p_no < 0 || p_no >= tile_shapes.length) { System.out.println("ConvexObstacle.get_tile_shape: p_no out of range"); return null; } return tile_shapes[p_no]; } - - public void translate_by(Vector p_vector) - { + + public void translate_by(Vector p_vector) { this.translation = this.translation.add(p_vector); this.clear_derived_data(); } - - public void turn_90_degree(int p_factor, IntPoint p_pole) - { + + public void turn_90_degree(int p_factor, IntPoint p_pole) { this.rotation_in_degree += p_factor * 90; - while(this.rotation_in_degree >= 360) - { + while (this.rotation_in_degree >= 360) { this.rotation_in_degree -= 360; } - while(this.rotation_in_degree < 0) - { + while (this.rotation_in_degree < 0) { this.rotation_in_degree += 360; } Point rel_location = Point.ZERO.translate_by(this.translation); this.translation = rel_location.turn_90_degree(p_factor, p_pole).difference_by(Point.ZERO); this.clear_derived_data(); } - - public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) - { + + public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) { double turn_angle = p_angle_in_degree; - if (this.side_changed && this.board.components.get_flip_style_rotate_first()) - { + if (this.side_changed && this.board.components.get_flip_style_rotate_first()) { turn_angle = 360 - p_angle_in_degree; } this.rotation_in_degree += turn_angle; - while(this.rotation_in_degree >= 360) - { + while (this.rotation_in_degree >= 360) { this.rotation_in_degree -= 360; } - while(this.rotation_in_degree < 0) - { + while (this.rotation_in_degree < 0) { this.rotation_in_degree += 360; } FloatPoint new_translation = this.translation.to_float().rotate(Math.toRadians(p_angle_in_degree), p_pole); this.translation = new_translation.round().difference_by(Point.ZERO); this.clear_derived_data(); } - - public void change_placement_side(IntPoint p_pole) - { + + public void change_placement_side(IntPoint p_pole) { this.side_changed = !this.side_changed; - if (this.board != null) - { + if (this.board != null) { this.layer = board.get_layer_count() - this.layer - 1; } Point rel_location = Point.ZERO.translate_by(this.translation); this.translation = rel_location.mirror_vertical(p_pole).difference_by(Point.ZERO); this.clear_derived_data(); } - - public boolean is_selected_by_filter(ItemSelectionFilter p_filter) - { - if (!this.is_selected_by_fixed_filter(p_filter)) - { + + public boolean is_selected_by_filter(ItemSelectionFilter p_filter) { + if (!this.is_selected_by_fixed_filter(p_filter)) { return false; } return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.KEEPOUT); } - - public Color[] get_draw_colors(GraphicsContext p_graphics_context) - { + + public Color[] get_draw_colors(GraphicsContext p_graphics_context) { return p_graphics_context.get_obstacle_colors(); } - - public double get_draw_intensity(GraphicsContext p_graphics_context) - { + + public double get_draw_intensity(GraphicsContext p_graphics_context) { return p_graphics_context.get_obstacle_color_intensity(); } - - public int get_draw_priority() - { + + public int get_draw_priority() { return net.freerouting.boardgraphics.Drawable.MIN_DRAW_PRIORITY; } - - public void draw(java.awt.Graphics p_g, GraphicsContext p_graphics_context, Color[] p_color_arr, double p_intensity) - { - if (p_graphics_context == null || p_intensity <= 0) - { + + public void draw(java.awt.Graphics p_g, GraphicsContext p_graphics_context, Color[] p_color_arr, double p_intensity) { + if (p_graphics_context == null || p_intensity <= 0) { return; } Color color = p_color_arr[this.layer]; double intensity = p_graphics_context.get_layer_visibility(this.layer) * p_intensity; p_graphics_context.fill_area(this.get_area(), p_g, color, intensity); - if (intensity > 0 && display_tree_shapes) - { + if (intensity > 0 && display_tree_shapes) { ShapeSearchTree default_tree = this.board.search_tree_manager.get_default_tree(); - for (int i = 0; i < this.tree_shape_count(default_tree); ++i) - { + for (int i = 0; i < this.tree_shape_count(default_tree); ++i) { p_graphics_context.draw_boundary(this.get_tree_shape(default_tree, i), 1, Color.white, p_g, 1); } } } - - public int shape_layer(int p_index) - { + + public int shape_layer(int p_index) { return layer; } - - protected Vector get_translation() - { + + protected Vector get_translation() { return translation; } - - protected double get_rotation_in_degree() - { + + protected double get_rotation_in_degree() { return rotation_in_degree; } - - protected boolean get_side_changed() - { + + protected boolean get_side_changed() { return side_changed; } - - public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { + + public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("keepout")); int cmp_no = this.get_component_no(); - if (cmp_no > 0) - { + if (cmp_no > 0) { p_window.append(" " + resources.getString("of_component") + " "); Component component = board.components.get(cmp_no); p_window.append(component.name, resources.getString("component_info"), component); @@ -308,86 +266,50 @@ public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) this.print_item_info(p_window, p_locale); p_window.newline(); } - + /** * Used in the implementation of print_info for this class and derived classes. */ - protected final void print_shape_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { + protected final void print_shape_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append(" " + resources.getString("at") + " "); net.freerouting.geometry.planar.FloatPoint center = this.get_area().get_border().centre_of_gravity(); p_window.append(center); Integer hole_count = this.relative_area.get_holes().length; - if(hole_count > 0) - { + if (hole_count > 0) { p_window.append(" " + resources.getString("with") + " "); - java.text.NumberFormat nf = java.text.NumberFormat.getInstance(p_locale); + java.text.NumberFormat nf = java.text.NumberFormat.getInstance(p_locale); p_window.append(nf.format(hole_count)); - if (hole_count == 1) - { + if (hole_count == 1) { p_window.append(" " + resources.getString("hole")); - } - else - { + } else { p_window.append(" " + resources.getString("holes")); } } p_window.append(" " + resources.getString("on_layer") + " "); p_window.append(this.board.layer_structure.arr[this.get_layer()].name); } - - TileShape[] split_to_convex() - { - if (this.relative_area == null) - { + + TileShape[] split_to_convex() { + if (this.relative_area == null) { System.out.println("ObstacleArea.split_to_convex: area is null"); return null; } return this.get_area().split_to_convex(); } - - public void clear_derived_data() - { + + public void clear_derived_data() { super.clear_derived_data(); this.precalculated_absolute_area = null; } - - - public boolean write(java.io.ObjectOutputStream p_stream) - { - try - { + + public boolean write(java.io.ObjectOutputStream p_stream) { + try { p_stream.writeObject(this); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { return false; } return true; } - - /** - * The name of this ObstacleArea, which is null, if the ObstacleArea doos not belong to a component. - */ - public final String name; - - /** - * the layer of this relative_area - */ - private int layer; - - private Area relative_area; - - private transient Area precalculated_absolute_area = null; - - private Vector translation; - - private double rotation_in_degree; - - private boolean side_changed; - - /** For debugging the division into tree shapes */ - private static final boolean display_tree_shapes = false; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/board/OptViaAlgo.java b/src/main/java/net/freerouting/board/OptViaAlgo.java index 216f5119..2698a6ea 100644 --- a/src/main/java/net/freerouting/board/OptViaAlgo.java +++ b/src/main/java/net/freerouting/board/OptViaAlgo.java @@ -21,27 +21,19 @@ package net.freerouting.board; +import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; +import net.freerouting.geometry.planar.*; + import java.util.Collection; import java.util.Iterator; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.FloatLine; -import net.freerouting.geometry.planar.Side; - -import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; - /** * Contains functions for optimizing and improving via locations. * * @author Alfons Wirtz */ -public class OptViaAlgo -{ - +public class OptViaAlgo { + /** * Optimizes the location of a via connected to at most 2 traces * according to the trace costs on the layers of the connected traces @@ -49,17 +41,13 @@ public class OptViaAlgo * Returns false, if the via was not changed. */ public static boolean opt_via_location(RoutingBoard p_board, Via p_via, - ExpansionCostFactor[] p_trace_cost_arr, int p_trace_pull_tight_accuracy, int p_max_recursion_depth) - { - if (p_via.is_shove_fixed()) - { + ExpansionCostFactor[] p_trace_cost_arr, int p_trace_pull_tight_accuracy, int p_max_recursion_depth) { + if (p_via.is_shove_fixed()) { return false; } - if (p_max_recursion_depth <= 0) - { - if (p_board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) - { - System.out.println("OptViaAlgo.opt_via_location: probably endless loop") ; + if (p_max_recursion_depth <= 0) { + if (p_board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) { + System.out.println("OptViaAlgo.opt_via_location: probably endless loop"); } return false; } @@ -67,48 +55,33 @@ public static boolean opt_via_location(RoutingBoard p_board, Via p_via, boolean is_plane_or_fanout_via = (contacts.size() == 1); PolylineTrace first_trace = null; PolylineTrace second_trace = null; - if (!is_plane_or_fanout_via) - { - if (contacts.size() != 2) - { + if (!is_plane_or_fanout_via) { + if (contacts.size() != 2) { return false; } Iterator it = contacts.iterator(); Item curr_item = it.next(); - if (curr_item.is_shove_fixed() || !(curr_item instanceof PolylineTrace)) - { - if (curr_item instanceof ConductionArea) - { + if (curr_item.is_shove_fixed() || !(curr_item instanceof PolylineTrace)) { + if (curr_item instanceof ConductionArea) { is_plane_or_fanout_via = true; - } - else - { + } else { return false; } - } - else - { + } else { first_trace = (PolylineTrace) curr_item; } curr_item = it.next(); - if (curr_item.is_shove_fixed() || !(curr_item instanceof PolylineTrace)) - { - if (curr_item instanceof ConductionArea) - { + if (curr_item.is_shove_fixed() || !(curr_item instanceof PolylineTrace)) { + if (curr_item instanceof ConductionArea) { is_plane_or_fanout_via = true; - } - else - { + } else { return false; } - } - else - { + } else { second_trace = (PolylineTrace) curr_item; } } - if (is_plane_or_fanout_via) - { + if (is_plane_or_fanout_via) { return opt_plane_or_fanout_via(p_board, p_via, p_trace_pull_tight_accuracy, p_max_recursion_depth); } Point via_center = p_via.get_center(); @@ -116,161 +89,122 @@ public static boolean opt_via_location(RoutingBoard p_board, Via p_via, int second_layer = second_trace.get_layer(); Point first_trace_from_corner; Point second_trace_from_corner; - + // calculate first_trace_from_corner and second_trace_from_corner - - if (first_trace.first_corner().equals(via_center)) - { + + if (first_trace.first_corner().equals(via_center)) { first_trace_from_corner = first_trace.polyline().corner(1); - } - else if (first_trace.last_corner().equals(via_center)) - { + } else if (first_trace.last_corner().equals(via_center)) { first_trace_from_corner = first_trace.polyline().corner(first_trace.polyline().corner_count() - 2); - } - else - { + } else { System.out.println("OptViaAlgo.opt_via_location: incorrect first contact"); return false; } - - if (second_trace.first_corner().equals(via_center)) - { + + if (second_trace.first_corner().equals(via_center)) { second_trace_from_corner = second_trace.polyline().corner(1); - } - else if (second_trace.last_corner().equals(via_center)) - { + } else if (second_trace.last_corner().equals(via_center)) { second_trace_from_corner = second_trace.polyline().corner(second_trace.polyline().corner_count() - 2); - } - else - { + } else { System.out.println("OptViaAlgo.opt_via_location: incorrect second contact"); return false; } - + ExpansionCostFactor first_layer_trace_costs; ExpansionCostFactor second_layer_trace_costs; - if (p_trace_cost_arr != null) - { + if (p_trace_cost_arr != null) { first_layer_trace_costs = p_trace_cost_arr[first_layer]; second_layer_trace_costs = p_trace_cost_arr[second_layer]; - } - else - { + } else { first_layer_trace_costs = new ExpansionCostFactor(1, 1); second_layer_trace_costs = first_layer_trace_costs; } - + Point new_location = reposition_via(p_board, p_via, - first_trace.get_half_width(), first_trace.clearance_class_no(), first_trace.get_layer(), - first_layer_trace_costs, first_trace_from_corner, - second_trace.get_half_width(), second_trace.clearance_class_no(), second_trace.get_layer(), - second_layer_trace_costs, second_trace_from_corner); - if (new_location == null || new_location.equals(via_center)) - { + first_trace.get_half_width(), first_trace.clearance_class_no(), first_trace.get_layer(), + first_layer_trace_costs, first_trace_from_corner, + second_trace.get_half_width(), second_trace.clearance_class_no(), second_trace.get_layer(), + second_layer_trace_costs, second_trace_from_corner); + if (new_location == null || new_location.equals(via_center)) { return false; } Vector delta = new_location.difference_by(via_center); - if (!MoveDrillItemAlgo.insert(p_via, delta, 9, 9, null, p_board)) - { + if (!MoveDrillItemAlgo.insert(p_via, delta, 9, 9, null, p_board)) { System.out.println("OptViaAlgo.opt_via_location: move via failed"); return false; } ItemSelectionFilter filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.TRACES); Collection picked_items = p_board.pick_items(new_location, first_trace.get_layer(), filter); - for (Item curr_item : picked_items) - { + for (Item curr_item : picked_items) { ((PolylineTrace) curr_item).pull_tight(true, p_trace_pull_tight_accuracy, null); } picked_items = p_board.pick_items(new_location, second_trace.get_layer(), filter); - for (Item curr_item : picked_items) - { + for (Item curr_item : picked_items) { ((PolylineTrace) curr_item).pull_tight(true, p_trace_pull_tight_accuracy, null); } filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.VIAS); picked_items = p_board.pick_items(new_location, first_trace.get_layer(), filter); - for (Item curr_item : picked_items) - { + for (Item curr_item : picked_items) { opt_via_location(p_board, (Via) curr_item, p_trace_cost_arr, p_trace_pull_tight_accuracy, p_max_recursion_depth - 1); break; } return true; } - + /** * Optimisations for vias with only 1 connected Trace (Plane or Fanout Vias). */ private static boolean opt_plane_or_fanout_via(RoutingBoard p_board, Via p_via, - int p_trace_pull_tight_accuracy, int p_max_recursion_depth) - { - if (p_max_recursion_depth <= 0) - { - if (p_board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) - { - System.out.println("OptViaAlgo.opt_plane_or_fanout_via: probably endless loop") ; + int p_trace_pull_tight_accuracy, int p_max_recursion_depth) { + if (p_max_recursion_depth <= 0) { + if (p_board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) { + System.out.println("OptViaAlgo.opt_plane_or_fanout_via: probably endless loop"); } return false; } Collection contact_list = p_via.get_normal_contacts(); - if (contact_list.isEmpty()) - { + if (contact_list.isEmpty()) { return false; } ConductionArea contact_plane = null; PolylineTrace contact_trace = null; - for (Item curr_contact : contact_list) - { - if (curr_contact instanceof ConductionArea) - { - if (contact_plane != null) - { + for (Item curr_contact : contact_list) { + if (curr_contact instanceof ConductionArea) { + if (contact_plane != null) { return false; } contact_plane = (ConductionArea) curr_contact; - } - else if (curr_contact instanceof PolylineTrace) - { - if (curr_contact.is_shove_fixed() || contact_trace != null) - { + } else if (curr_contact instanceof PolylineTrace) { + if (curr_contact.is_shove_fixed() || contact_trace != null) { return false; } contact_trace = (PolylineTrace) curr_contact; - } - else - { + } else { return false; } } - if (contact_trace == null) - { + if (contact_trace == null) { return false; } Point via_center = p_via.get_center(); boolean at_first_corner; - if (contact_trace.first_corner().equals(via_center)) - { + if (contact_trace.first_corner().equals(via_center)) { at_first_corner = true; - } - else if (contact_trace.last_corner().equals(via_center)) - { + } else if (contact_trace.last_corner().equals(via_center)) { at_first_corner = false; - } - else - { + } else { System.out.println("OptViaAlgo.opt_plane_or_fanout_via: unconsistant contact"); return false; } Polyline trace_polyline = contact_trace.polyline(); Point check_corner; - if (at_first_corner) - { + if (at_first_corner) { check_corner = trace_polyline.corner(1); - } - else - { + } else { check_corner = trace_polyline.corner(trace_polyline.corner_count() - 2); } IntPoint rounded_check_corner = check_corner.to_float().round(); @@ -278,27 +212,22 @@ else if (contact_trace.last_corner().equals(via_center)) int trace_layer = contact_trace.get_layer(); int trace_cl_class_no = contact_trace.clearance_class_no(); Point new_via_location = - reposition_via(p_board, p_via, rounded_check_corner, trace_half_width , - trace_layer, trace_cl_class_no); - if (new_via_location == null && trace_polyline.corner_count() >= 3) - { - + reposition_via(p_board, p_via, rounded_check_corner, trace_half_width, + trace_layer, trace_cl_class_no); + if (new_via_location == null && trace_polyline.corner_count() >= 3) { + // try to project the via to the previous line - Point prev_corner; - - if (at_first_corner) - { + Point prev_corner; + + if (at_first_corner) { prev_corner = trace_polyline.corner(2); - } - else - { + } else { prev_corner = trace_polyline.corner(trace_polyline.corner_count() - 3); } FloatPoint float_check_corner = check_corner.to_float(); FloatPoint float_via_center = via_center.to_float(); FloatPoint float_prev_corner = prev_corner.to_float(); - if (float_check_corner.scalar_product(float_via_center, float_prev_corner) != 0) - { + if (float_check_corner.scalar_product(float_via_center, float_prev_corner) != 0) { FloatLine curr_line = new FloatLine(float_check_corner, float_prev_corner); Point projection = curr_line.perpendicular_projection(float_via_center).round(); Vector diff_vector = projection.difference_by(via_center); @@ -306,126 +235,106 @@ else if (contact_trace.last_corner().equals(via_center)) AngleRestriction angle_restriction = p_board.rules.get_trace_angle_restriction(); if (projection.equals(via_center) || angle_restriction == AngleRestriction.NINETY_DEGREE && !diff_vector.is_orthogonal() || - angle_restriction == AngleRestriction.FORTYFIVE_DEGREE && !diff_vector.is_multiple_of_45_degree()) - { + angle_restriction == AngleRestriction.FORTYFIVE_DEGREE && !diff_vector.is_multiple_of_45_degree()) { projection_ok = false; } - if (projection_ok) - { - if(MoveDrillItemAlgo.check(p_via, diff_vector, 0, 0, null, p_board, null)) - { + if (projection_ok) { + if (MoveDrillItemAlgo.check(p_via, diff_vector, 0, 0, null, p_board, null)) { double ok_length = p_board.check_trace_segment(via_center, projection, trace_layer, p_via.net_no_arr, - trace_half_width, trace_cl_class_no, false); - if (ok_length >= Integer.MAX_VALUE) - { + trace_half_width, trace_cl_class_no, false); + if (ok_length >= Integer.MAX_VALUE) { new_via_location = projection; } } - + } } } - if (new_via_location == null) - { + if (new_via_location == null) { return false; } - if (contact_plane != null) - { + if (contact_plane != null) { // check, that the new location is inside the contact plane ItemSelectionFilter filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.CONDUCTION); Collection picked_items = p_board.pick_items(new_via_location, contact_plane.get_layer(), filter); boolean contact_ok = false; - for (Item curr_item : picked_items) - { - if (curr_item == contact_plane) - { + for (Item curr_item : picked_items) { + if (curr_item == contact_plane) { contact_ok = true; break; } } - if (!contact_ok) - { + if (!contact_ok) { return false; } } Vector diff_vector = new_via_location.difference_by(via_center); - if (!MoveDrillItemAlgo.insert(p_via, diff_vector, 9, 9, null, p_board)) - { + if (!MoveDrillItemAlgo.insert(p_via, diff_vector, 9, 9, null, p_board)) { System.out.println("OptViaAlgo.opt_plane_or_fanout_via: move via failed"); return false; } ItemSelectionFilter filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.TRACES); Collection picked_items = p_board.pick_items(new_via_location, contact_trace.get_layer(), filter); - for (Item curr_item : picked_items) - { + for (Item curr_item : picked_items) { ((PolylineTrace) curr_item).pull_tight(true, p_trace_pull_tight_accuracy, null); } - if (new_via_location.equals(check_corner)) - { + if (new_via_location.equals(check_corner)) { opt_plane_or_fanout_via(p_board, p_via, p_trace_pull_tight_accuracy, p_max_recursion_depth - 1); } return true; } - + /** * Tries to move the via into the direction of p_to_location as far as possible * Return the new location of the via, or null, if no move was possible. */ private static Point reposition_via(RoutingBoard p_board, Via p_via, - IntPoint p_to_location, int p_trace_half_width, int p_trace_layer, int p_trace_cl_class) - + IntPoint p_to_location, int p_trace_half_width, int p_trace_layer, int p_trace_cl_class) + { - Point from_location = p_via.get_center(); - - if (from_location.equals(p_to_location)) - { + Point from_location = p_via.get_center(); + + if (from_location.equals(p_to_location)) { return null; } - + double ok_length = p_board.check_trace_segment(from_location, p_to_location, p_trace_layer, p_via.net_no_arr, p_trace_half_width, p_trace_cl_class, false); - if (ok_length <= 0) - { + if (ok_length <= 0) { return null; } FloatPoint float_from_location = from_location.to_float(); FloatPoint float_to_location = p_to_location.to_float(); FloatPoint new_float_to_location; - if (ok_length >= Integer.MAX_VALUE) - { + if (ok_length >= Integer.MAX_VALUE) { new_float_to_location = float_to_location; - } - else - { + } else { new_float_to_location = float_from_location.change_length(float_to_location, ok_length); } Point new_to_location = new_float_to_location.round(); Vector delta = new_to_location.difference_by(from_location); boolean check_ok = MoveDrillItemAlgo.check(p_via, delta, 0, 0, null, p_board, null); - - if (check_ok) - { + + if (check_ok) { return new_to_location; } - + final double c_min_length = 0.3 * p_trace_half_width + 1; - + ok_length = Math.min(ok_length, float_from_location.distance(float_to_location)); - + double curr_length = ok_length / 2; - + ok_length = 0; Point result = null; - - while (curr_length >= c_min_length) - { + + while (curr_length >= c_min_length) { Point check_point = float_from_location.change_length(float_to_location, ok_length + curr_length).round(); - + delta = check_point.difference_by(from_location); - if (MoveDrillItemAlgo.check(p_via, delta, 0, 0, null, p_board, null)) - { + if (MoveDrillItemAlgo.check(p_via, delta, 0, 0, null, p_board, null)) { ok_length += curr_length; result = check_point; } @@ -433,73 +342,66 @@ private static Point reposition_via(RoutingBoard p_board, Via p_via, } return result; } - + private static boolean reposition_via(RoutingBoard p_board, Via p_via, - IntPoint p_to_location, int p_trace_half_width_1, int p_trace_layer_1, int p_trace_cl_class_1, - IntPoint p_connect_location, int p_trace_half_width_2, int p_trace_layer_2, int p_trace_cl_class_2) - + IntPoint p_to_location, int p_trace_half_width_1, int p_trace_layer_1, int p_trace_cl_class_1, + IntPoint p_connect_location, int p_trace_half_width_2, int p_trace_layer_2, int p_trace_cl_class_2) + { - Point from_location = p_via.get_center(); - - if (from_location.equals(p_to_location)) - { - if (p_board.get_test_level() == TestLevel.ALL_DEBUGGING_OUTPUT) - { + Point from_location = p_via.get_center(); + + if (from_location.equals(p_to_location)) { + if (p_board.get_test_level() == TestLevel.ALL_DEBUGGING_OUTPUT) { System.out.println("OptViaAlgo.reposition_via: from_location equal p_to_location"); } return false; } - + Vector delta = p_to_location.difference_by(from_location); - - if ( p_board.rules.get_trace_angle_restriction() == AngleRestriction.NONE && delta.length_approx() <= 1.5) - { + + if (p_board.rules.get_trace_angle_restriction() == AngleRestriction.NONE && delta.length_approx() <= 1.5) { // PullTightAlgoAnyAngle.reduce_corners mmay not be able to remove the new generated overlap // because of numerical stability problems // That would result in an endless loop with removing the generated acute angle in reposition_via. return false; } - + int[] net_no_arr = p_via.net_no_arr; - + double ok_length = p_board.check_trace_segment(from_location, p_to_location, p_trace_layer_1, net_no_arr, p_trace_half_width_1, p_trace_cl_class_1, false); - - if (ok_length < Integer.MAX_VALUE) - { + + if (ok_length < Integer.MAX_VALUE) { return false; } - + ok_length = p_board.check_trace_segment(p_to_location, p_connect_location, p_trace_layer_2, net_no_arr, p_trace_half_width_2, p_trace_cl_class_2, false); - - if (ok_length < Integer.MAX_VALUE) - { + + if (ok_length < Integer.MAX_VALUE) { return false; } - if (!MoveDrillItemAlgo.check(p_via, delta, 0, 0, null, p_board, null)) - { + if (!MoveDrillItemAlgo.check(p_via, delta, 0, 0, null, p_board, null)) { return false; } return true; } - + /** * Tries to reposition the via to a better location according to the * trace costs. Returns null, if no better location was found. */ private static Point reposition_via(RoutingBoard p_board, Via p_via, - int p_first_trace_half_width, int p_first_trace_cl_class, int p_first_trace_layer, - ExpansionCostFactor p_first_trace_costs, Point p_first_trace_from_corner, - int p_second_trace_half_width, int p_second_trace_cl_class, int p_second_trace_layer, - ExpansionCostFactor p_second_trace_costs, Point p_second_trace_from_corner) - { - Point via_location = p_via.get_center(); - + int p_first_trace_half_width, int p_first_trace_cl_class, int p_first_trace_layer, + ExpansionCostFactor p_first_trace_costs, Point p_first_trace_from_corner, + int p_second_trace_half_width, int p_second_trace_cl_class, int p_second_trace_layer, + ExpansionCostFactor p_second_trace_costs, Point p_second_trace_from_corner) { + Point via_location = p_via.get_center(); + Vector first_delta = p_first_trace_from_corner.difference_by(via_location); Vector second_delta = p_second_trace_from_corner.difference_by(via_location); double scalar_product = first_delta.scalar_product(second_delta); - + FloatPoint float_via_location = via_location.to_float(); FloatPoint float_first_trace_from_corner = p_first_trace_from_corner.to_float(); FloatPoint float_second_trace_from_corner = p_second_trace_from_corner.to_float(); @@ -507,14 +409,12 @@ private static Point reposition_via(RoutingBoard p_board, Via p_via, double second_trace_from_corner_distance = float_via_location.distance(float_second_trace_from_corner); IntPoint rounded_first_trace_from_corner = float_first_trace_from_corner.round(); IntPoint rounded_second_trace_from_corner = float_second_trace_from_corner.round(); - + // handle case of overlapping lines first - + if (via_location.side_of(p_first_trace_from_corner, p_second_trace_from_corner) == Side.COLLINEAR - && scalar_product > 0) - { - if (second_trace_from_corner_distance < first_trace_from_corner_distance) - { + && scalar_product > 0) { + if (second_trace_from_corner_distance < first_trace_from_corner_distance) { return reposition_via(p_board, p_via, rounded_second_trace_from_corner, p_first_trace_half_width, p_first_trace_layer, p_first_trace_cl_class); } @@ -522,199 +422,175 @@ private static Point reposition_via(RoutingBoard p_board, Via p_via, p_second_trace_half_width, p_second_trace_layer, p_second_trace_cl_class); } Point result = null; - + double curr_weighted_distance_1 = float_via_location.weighted_distance(float_first_trace_from_corner, p_first_trace_costs.horizontal, - p_first_trace_costs.vertical); + p_first_trace_costs.vertical); double curr_weighted_distance_2 = float_via_location.weighted_distance(float_first_trace_from_corner, p_second_trace_costs.horizontal, - p_second_trace_costs.vertical); - - if (curr_weighted_distance_1 > curr_weighted_distance_2) - { + p_second_trace_costs.vertical); + + if (curr_weighted_distance_1 > curr_weighted_distance_2) { // try to move the via in direction of p_first_trace_from_corner result = reposition_via(p_board, p_via, rounded_first_trace_from_corner, p_second_trace_half_width, p_second_trace_layer, p_second_trace_cl_class); - if (result != null) - { + if (result != null) { return result; } } - + curr_weighted_distance_1 = float_via_location.weighted_distance(float_second_trace_from_corner, p_second_trace_costs.horizontal, - p_second_trace_costs.vertical); + p_second_trace_costs.vertical); curr_weighted_distance_2 = float_via_location.weighted_distance(float_second_trace_from_corner, p_first_trace_costs.horizontal, - p_first_trace_costs.vertical); - - if (curr_weighted_distance_1 > curr_weighted_distance_2) - { + p_first_trace_costs.vertical); + + if (curr_weighted_distance_1 > curr_weighted_distance_2) { // try to move the via in direction of p_second_trace_from_corner result = reposition_via(p_board, p_via, rounded_second_trace_from_corner, p_first_trace_half_width, p_first_trace_layer, p_first_trace_cl_class); - if (result != null) - { + if (result != null) { return result; } } - if (scalar_product > 0 && p_board.rules.get_trace_angle_restriction() != AngleRestriction.NINETY_DEGREE) - { + if (scalar_product > 0 && p_board.rules.get_trace_angle_restriction() != AngleRestriction.NINETY_DEGREE) { // acute angle IntPoint to_point_1; IntPoint to_point_2; FloatPoint float_to_point_1; FloatPoint float_to_point_2; - if (first_trace_from_corner_distance < second_trace_from_corner_distance) - { + if (first_trace_from_corner_distance < second_trace_from_corner_distance) { to_point_1 = rounded_first_trace_from_corner; float_to_point_1 = float_first_trace_from_corner; float_to_point_2 = float_via_location.change_length(float_second_trace_from_corner, - first_trace_from_corner_distance); - to_point_2 = float_to_point_2.round(); - } - else - { + first_trace_from_corner_distance); + to_point_2 = float_to_point_2.round(); + } else { float_to_point_1 = float_via_location.change_length(float_first_trace_from_corner, - second_trace_from_corner_distance); + second_trace_from_corner_distance); to_point_1 = float_to_point_1.round(); to_point_2 = rounded_second_trace_from_corner; float_to_point_2 = float_second_trace_from_corner; } curr_weighted_distance_1 = float_to_point_1.weighted_distance(float_to_point_2, p_first_trace_costs.horizontal, - p_first_trace_costs.vertical); + p_first_trace_costs.vertical); curr_weighted_distance_2 = float_to_point_1.weighted_distance(float_to_point_2, p_second_trace_costs.horizontal, - p_second_trace_costs.vertical); - - if (curr_weighted_distance_1 > curr_weighted_distance_2) - { + p_second_trace_costs.vertical); + + if (curr_weighted_distance_1 > curr_weighted_distance_2) { // try moving the via first into the direction of to_point_1 - result = reposition_via(p_board, p_via, to_point_1, + result = reposition_via(p_board, p_via, to_point_1, p_second_trace_half_width, p_second_trace_layer, p_second_trace_cl_class); - if (result == null) - { - result = reposition_via(p_board, p_via, to_point_2, + if (result == null) { + result = reposition_via(p_board, p_via, to_point_2, p_first_trace_half_width, p_first_trace_layer, p_first_trace_cl_class); } - } - else - { + } else { // try moving the via first into the direction of to_point_2 - result = reposition_via(p_board, p_via, to_point_2, + result = reposition_via(p_board, p_via, to_point_2, p_first_trace_half_width, p_first_trace_layer, p_first_trace_cl_class); - if (result == null) - { - result = reposition_via(p_board, p_via, to_point_1, + if (result == null) { + result = reposition_via(p_board, p_via, to_point_1, p_second_trace_half_width, p_second_trace_layer, p_second_trace_cl_class); } } - if (result != null) - { + if (result != null) { return result; } } - + // try decomposition in axisparallel parts - - if (!first_delta.is_orthogonal()) - { + + if (!first_delta.is_orthogonal()) { FloatPoint float_check_location = new FloatPoint(float_via_location.x, float_first_trace_from_corner.y); - + curr_weighted_distance_1 = float_via_location.weighted_distance(float_first_trace_from_corner, p_first_trace_costs.horizontal, - p_first_trace_costs.vertical); + p_first_trace_costs.vertical); curr_weighted_distance_2 = float_via_location.weighted_distance(float_check_location, p_second_trace_costs.horizontal, - p_second_trace_costs.vertical); + p_second_trace_costs.vertical); double curr_weighted_distance_3 = float_check_location.weighted_distance(float_first_trace_from_corner, p_first_trace_costs.horizontal, - p_first_trace_costs.vertical); - - if (curr_weighted_distance_1 > curr_weighted_distance_2 + curr_weighted_distance_3) - { + p_first_trace_costs.vertical); + + if (curr_weighted_distance_1 > curr_weighted_distance_2 + curr_weighted_distance_3) { IntPoint check_location = float_check_location.round(); boolean check_ok = reposition_via(p_board, p_via, check_location, p_second_trace_half_width, - p_second_trace_layer, p_second_trace_cl_class, rounded_first_trace_from_corner, - p_first_trace_half_width, p_first_trace_layer, p_first_trace_cl_class); - if (check_ok) - { + p_second_trace_layer, p_second_trace_cl_class, rounded_first_trace_from_corner, + p_first_trace_half_width, p_first_trace_layer, p_first_trace_cl_class); + if (check_ok) { return check_location; } } - + float_check_location = new FloatPoint(float_first_trace_from_corner.x, float_via_location.y); - + curr_weighted_distance_2 = float_via_location.weighted_distance(float_check_location, p_second_trace_costs.horizontal, - p_second_trace_costs.vertical); + p_second_trace_costs.vertical); curr_weighted_distance_3 = float_check_location.weighted_distance(float_first_trace_from_corner, p_first_trace_costs.horizontal, - p_first_trace_costs.vertical); - - if (curr_weighted_distance_1 > curr_weighted_distance_2 + curr_weighted_distance_3) - { + p_first_trace_costs.vertical); + + if (curr_weighted_distance_1 > curr_weighted_distance_2 + curr_weighted_distance_3) { IntPoint check_location = float_check_location.round(); boolean check_ok = reposition_via(p_board, p_via, check_location, p_second_trace_half_width, - p_second_trace_layer, p_second_trace_cl_class, rounded_first_trace_from_corner, - p_first_trace_half_width, p_first_trace_layer, p_first_trace_cl_class); - if (check_ok) - { + p_second_trace_layer, p_second_trace_cl_class, rounded_first_trace_from_corner, + p_first_trace_half_width, p_first_trace_layer, p_first_trace_cl_class); + if (check_ok) { return check_location; } } } - - if (!second_delta.is_orthogonal()) - { + + if (!second_delta.is_orthogonal()) { FloatPoint float_check_location = new FloatPoint(float_via_location.x, float_second_trace_from_corner.y); - + curr_weighted_distance_1 = float_via_location.weighted_distance(float_second_trace_from_corner, p_second_trace_costs.horizontal, - p_second_trace_costs.vertical); + p_second_trace_costs.vertical); curr_weighted_distance_2 = float_via_location.weighted_distance(float_check_location, p_first_trace_costs.horizontal, - p_first_trace_costs.vertical); + p_first_trace_costs.vertical); double curr_weighted_distance_3 = float_check_location.weighted_distance(float_second_trace_from_corner, p_second_trace_costs.horizontal, - p_second_trace_costs.vertical); - - if (curr_weighted_distance_1 > curr_weighted_distance_2 + curr_weighted_distance_3) - { + p_second_trace_costs.vertical); + + if (curr_weighted_distance_1 > curr_weighted_distance_2 + curr_weighted_distance_3) { IntPoint check_location = float_check_location.round(); boolean check_ok = - reposition_via(p_board, p_via, check_location, p_first_trace_half_width, - p_first_trace_layer, p_first_trace_cl_class, rounded_second_trace_from_corner, - p_second_trace_half_width, p_second_trace_layer, p_second_trace_cl_class); - if (check_ok) - { + reposition_via(p_board, p_via, check_location, p_first_trace_half_width, + p_first_trace_layer, p_first_trace_cl_class, rounded_second_trace_from_corner, + p_second_trace_half_width, p_second_trace_layer, p_second_trace_cl_class); + if (check_ok) { return check_location; } } - + float_check_location = new FloatPoint(float_second_trace_from_corner.x, float_via_location.y); - + curr_weighted_distance_2 = float_via_location.weighted_distance(float_check_location, p_first_trace_costs.horizontal, - p_first_trace_costs.vertical); + p_first_trace_costs.vertical); curr_weighted_distance_3 = float_check_location.weighted_distance(float_second_trace_from_corner, p_second_trace_costs.horizontal, - p_second_trace_costs.vertical); - - if (curr_weighted_distance_1 > curr_weighted_distance_2 + curr_weighted_distance_3) - { + p_second_trace_costs.vertical); + + if (curr_weighted_distance_1 > curr_weighted_distance_2 + curr_weighted_distance_3) { IntPoint check_location = float_check_location.round(); boolean check_ok = reposition_via(p_board, p_via, check_location, p_first_trace_half_width, - p_first_trace_layer, p_first_trace_cl_class, rounded_second_trace_from_corner, - p_second_trace_half_width, p_second_trace_layer, p_second_trace_cl_class); - if (check_ok) - { + p_first_trace_layer, p_first_trace_cl_class, rounded_second_trace_from_corner, + p_second_trace_half_width, p_second_trace_layer, p_second_trace_cl_class); + if (check_ok) { return check_location; } } diff --git a/src/main/java/net/freerouting/board/Pin.java b/src/main/java/net/freerouting/board/Pin.java index 67faf541..5badcb97 100644 --- a/src/main/java/net/freerouting/board/Pin.java +++ b/src/main/java/net/freerouting/board/Pin.java @@ -21,17 +21,7 @@ package net.freerouting.board; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Shape; -import net.freerouting.geometry.planar.ConvexShape; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.Direction; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.FloatPoint; - +import net.freerouting.geometry.planar.*; import net.freerouting.library.Package; import net.freerouting.library.Padstack; @@ -39,165 +29,147 @@ * Class describing the functionality of an electrical Item on the board * with a shape on 1 or several layers. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Pin extends DrillItem implements java.io.Serializable -{ - /** Creates a new instance of Pin with the input parameters. - * (p_to_layer - p_from_layer + 1) shapes must be provided. - * p_pin_no isthe number of the pin in its component (starting with 0). +public class Pin extends DrillItem implements java.io.Serializable { + /** + * The number of this pin in its component (starting with 0). + */ + public final int pin_no; + /** + * The pin, this pin was changed to by swapping or this pin, if no pin swap accured. + */ + private Pin changed_to = this; + private transient Shape[] precalculated_shapes = null; + + /** + * Creates a new instance of Pin with the input parameters. + * (p_to_layer - p_from_layer + 1) shapes must be provided. + * p_pin_no isthe number of the pin in its component (starting with 0). */ Pin(int p_component_no, int p_pin_no, int[] p_net_no_arr, int p_clearance_type, int p_id_no, - FixedState p_fixed_state, BasicBoard p_board) - { + FixedState p_fixed_state, BasicBoard p_board) { super(null, p_net_no_arr, p_clearance_type, p_id_no, p_component_no, p_fixed_state, p_board); - + this.pin_no = p_pin_no; } - + /** * Calculates the relative location of this pin to its component. */ - public Vector relative_location() - { + public Vector relative_location() { Component component = board.components.get(this.get_component_no()); - Package lib_package = component.get_package(); + Package lib_package = component.get_package(); Package.Pin package_pin = lib_package.get_pin(this.pin_no); Vector rel_location = package_pin.relative_location; double component_rotation = component.get_rotation_in_degree(); - if (!component.placed_on_front() && !board.components.get_flip_style_rotate_first()) - { + if (!component.placed_on_front() && !board.components.get_flip_style_rotate_first()) { rel_location = package_pin.relative_location.mirror_at_y_axis(); } - if (component_rotation % 90 == 0) - { - int component_ninety_degree_factor = ((int) component_rotation )/ 90; - if (component_ninety_degree_factor != 0) - { + if (component_rotation % 90 == 0) { + int component_ninety_degree_factor = ((int) component_rotation) / 90; + if (component_ninety_degree_factor != 0) { rel_location = rel_location.turn_90_degree(component_ninety_degree_factor); } - } - else - { + } else { // rotation may be not exact FloatPoint location_approx = rel_location.to_float(); location_approx = location_approx.rotate(Math.toRadians(component_rotation), FloatPoint.ZERO); rel_location = location_approx.round().difference_by(Point.ZERO); } - if (!component.placed_on_front() && board.components.get_flip_style_rotate_first()) - { + if (!component.placed_on_front() && board.components.get_flip_style_rotate_first()) { rel_location = rel_location.mirror_at_y_axis(); } return rel_location; } - - - public Point get_center() - { + + public Point get_center() { Point pin_center = super.get_center(); - if (pin_center == null) - { - + if (pin_center == null) { + // Calculate the pin center. Component component = board.components.get(this.get_component_no()); pin_center = component.get_location().translate_by(this.relative_location()); - + // check that the pin center is inside the pin shape and correct it eventually - + Padstack padstack = get_padstack(); int from_layer = padstack.from_layer(); int to_layer = padstack.to_layer(); Shape curr_shape = null; - for (int i = 0; i < to_layer - from_layer + 1; ++i) - { + for (int i = 0; i < to_layer - from_layer + 1; ++i) { curr_shape = this.get_shape(i); - if (curr_shape != null) - { + if (curr_shape != null) { break; } } - if (curr_shape == null) - { + if (curr_shape == null) { System.out.println("Pin: At least 1 shape != null expected"); - } - else if (!curr_shape.contains_inside(pin_center)) - { + } else if (!curr_shape.contains_inside(pin_center)) { pin_center = curr_shape.centre_of_gravity().round(); } this.set_center(pin_center); } return pin_center; } - - public Padstack get_padstack() - { + + public Padstack get_padstack() { Component component = board.components.get(get_component_no()); - if (component == null) - { + if (component == null) { System.out.println("Pin.get_padstack; component not found"); return null; } int padstack_no = component.get_package().get_pin(pin_no).padstack_no; return board.library.padstacks.get(padstack_no); } - - public Item copy(int p_id_no) - { - int [] curr_net_no_arr = new int [this.net_count()]; - for (int i = 0; i < curr_net_no_arr.length; ++i) - { + + public Item copy(int p_id_no) { + int[] curr_net_no_arr = new int[this.net_count()]; + for (int i = 0; i < curr_net_no_arr.length; ++i) { curr_net_no_arr[i] = get_net_no(i); } return new Pin(get_component_no(), this.pin_no, curr_net_no_arr, clearance_class_no(), - p_id_no, get_fixed_state(), board); + p_id_no, get_fixed_state(), board); } - + /** * Return the name of this pin in the package of this component. */ - public String name() - { + public String name() { Component component = board.components.get(this.get_component_no()); - if (component == null) - { + if (component == null) { System.out.println("Pin.name: component not found"); return null; } return component.get_package().get_pin(pin_no).name; } - + /** * Gets index of this pin in the library package of the pins component. */ - public int get_index_in_package() - { + public int get_index_in_package() { return pin_no; } - - public Shape get_shape(int p_index) - { + + public Shape get_shape(int p_index) { Padstack padstack = get_padstack(); - if (this.precalculated_shapes == null) - { + if (this.precalculated_shapes == null) { // all shapes have to be calculated at once, because otherwise calculation // of from_layer and to_layer may not be correct this.precalculated_shapes = new Shape[padstack.to_layer() - padstack.from_layer() + 1]; - + Component component = board.components.get(this.get_component_no()); - if (component == null) - { + if (component == null) { System.out.println("Pin.get_shape: component not found"); return null; } - Package lib_package = component.get_package(); - if (lib_package == null) - { + Package lib_package = component.get_package(); + if (lib_package == null) { System.out.println("Pin.get_shape: package not found"); return null; } Package.Pin package_pin = lib_package.get_pin(this.pin_no); - if (package_pin == null) - { + if (package_pin == null) { System.out.println("Pin.get_shape: pin_no out of range"); return null; } @@ -205,162 +177,132 @@ public Shape get_shape(int p_index) double component_rotation = component.get_rotation_in_degree(); boolean mirror_at_y_axis = !component.placed_on_front() && !board.components.get_flip_style_rotate_first(); - - if (mirror_at_y_axis) - { + + if (mirror_at_y_axis) { rel_location = package_pin.relative_location.mirror_at_y_axis(); } - + Vector component_translation = component.get_location().difference_by(Point.ZERO); - - for (int index = 0; index < this.precalculated_shapes.length; ++index) - { - + + for (int index = 0; index < this.precalculated_shapes.length; ++index) { + int padstack_layer = get_padstack_layer(index); - + ConvexShape curr_shape = padstack.get_shape(padstack_layer); - if (curr_shape == null) - { + if (curr_shape == null) { continue; } double pin_rotation = package_pin.rotation_in_degree; - if (pin_rotation % 90 == 0) - { - int pin_ninety_degree_factor = ((int) pin_rotation)/ 90; - if (pin_ninety_degree_factor!= 0) - { + if (pin_rotation % 90 == 0) { + int pin_ninety_degree_factor = ((int) pin_rotation) / 90; + if (pin_ninety_degree_factor != 0) { curr_shape = (ConvexShape) curr_shape.turn_90_degree(pin_ninety_degree_factor, Point.ZERO); } - } - else - { + } else { curr_shape = (ConvexShape) curr_shape.rotate_approx(Math.toRadians(pin_rotation), FloatPoint.ZERO); } - if (mirror_at_y_axis) - { + if (mirror_at_y_axis) { curr_shape = (ConvexShape) curr_shape.mirror_vertical(Point.ZERO); } - + // translate the shape first relative to the component ConvexShape translated_shape = (ConvexShape) curr_shape.translate_by(rel_location); - - if (component_rotation % 90 == 0) - { - int component_ninety_degree_factor = ((int) component_rotation )/ 90; - if (component_ninety_degree_factor != 0) - { + + if (component_rotation % 90 == 0) { + int component_ninety_degree_factor = ((int) component_rotation) / 90; + if (component_ninety_degree_factor != 0) { translated_shape = (ConvexShape) translated_shape.turn_90_degree(component_ninety_degree_factor, Point.ZERO); } - } - else - { + } else { translated_shape = (ConvexShape) translated_shape.rotate_approx(Math.toRadians(component_rotation), FloatPoint.ZERO); } - if (!component.placed_on_front() && board.components.get_flip_style_rotate_first()) - { + if (!component.placed_on_front() && board.components.get_flip_style_rotate_first()) { translated_shape = (ConvexShape) translated_shape.mirror_vertical(Point.ZERO); } this.precalculated_shapes[index] = (ConvexShape) translated_shape.translate_by(component_translation); } - + } return this.precalculated_shapes[p_index]; } - + /** * Returns the layer of the padstack shape corresponding to the shape with index p_index. */ - int get_padstack_layer(int p_index) - { + int get_padstack_layer(int p_index) { Padstack padstack = get_padstack(); Component component = board.components.get(this.get_component_no()); int padstack_layer; - if (component.placed_on_front() || padstack.placed_absolute) - { + if (component.placed_on_front() || padstack.placed_absolute) { padstack_layer = p_index + this.first_layer(); - } - else - { + } else { padstack_layer = padstack.board_layer_count() - p_index - this.first_layer() - 1; } return padstack_layer; } - + /** * Calculates the allowed trace exit directions of the shape of this padstack on layer p_layer * together with the minimal trace line lengths into thei directions. * Currently only implemented only for box shapes, where traces are allowed to exit * the pad only on the small sides. */ - public java.util.Collection get_trace_exit_restrictions(int p_layer) - { + public java.util.Collection get_trace_exit_restrictions(int p_layer) { java.util.Collection result = new java.util.LinkedList(); - int padstack_layer = this.get_padstack_layer(p_layer - this.first_layer()); + int padstack_layer = this.get_padstack_layer(p_layer - this.first_layer()); double pad_xy_factor = 1.5; - // setting 1.5 to a higher factor may hinder the shove algorithm of the autorouter between - // the pins of SMD components, because the channels can get blocked by the shove_fixed stubs. - - Component component = board.components.get(this.get_component_no()); - if (component != null) - { - if (component.get_package().pin_count() <= 3) - { - pad_xy_factor *= 2; // allow connection to the longer side also for shorter pads. - } - } - - java.util.Collection padstack_exit_directions = - this.get_padstack().get_trace_exit_directions(padstack_layer, pad_xy_factor ); - if (padstack_exit_directions.isEmpty()) - { + // setting 1.5 to a higher factor may hinder the shove algorithm of the autorouter between + // the pins of SMD components, because the channels can get blocked by the shove_fixed stubs. + + Component component = board.components.get(this.get_component_no()); + if (component != null) { + if (component.get_package().pin_count() <= 3) { + pad_xy_factor *= 2; // allow connection to the longer side also for shorter pads. + } + } + + java.util.Collection padstack_exit_directions = + this.get_padstack().get_trace_exit_directions(padstack_layer, pad_xy_factor); + if (padstack_exit_directions.isEmpty()) { return result; } - - if (component == null) - { + + if (component == null) { return result; } Shape curr_shape = this.get_shape(p_layer - this.first_layer()); - if (curr_shape == null || !(curr_shape instanceof TileShape)) - { + if (curr_shape == null || !(curr_shape instanceof TileShape)) { return result; } - TileShape pad_shape = (TileShape) curr_shape; + TileShape pad_shape = (TileShape) curr_shape; double component_rotation = component.get_rotation_in_degree(); Point pin_center = this.get_center(); FloatPoint center_approx = pin_center.to_float(); - - for (Direction curr_padstack_exit_direction : padstack_exit_directions) - { - - Package lib_package = component.get_package(); - if (lib_package == null) - { + + for (Direction curr_padstack_exit_direction : padstack_exit_directions) { + + Package lib_package = component.get_package(); + if (lib_package == null) { continue; } Package.Pin package_pin = lib_package.get_pin(this.pin_no); - if (package_pin == null) - { + if (package_pin == null) { continue; } double curr_rotation_in_degree = component_rotation + package_pin.rotation_in_degree; Direction curr_exit_direction; - if (curr_rotation_in_degree % 45 == 0) - { - int fortyfive_degree_factor = ((int) curr_rotation_in_degree)/ 45; + if (curr_rotation_in_degree % 45 == 0) { + int fortyfive_degree_factor = ((int) curr_rotation_in_degree) / 45; curr_exit_direction = curr_padstack_exit_direction.turn_45_degree(fortyfive_degree_factor); - } - else - { + } else { double curr_angle_in_radian = Math.toRadians(curr_rotation_in_degree) + curr_padstack_exit_direction.angle_approx(); curr_exit_direction = Direction.get_instance_approx(curr_angle_in_radian); } // calculate the minimum line length from the pin center into curr_exit_direction int intersecting_border_line_no = pad_shape.intersecting_border_line_no(pin_center, curr_exit_direction); - if (intersecting_border_line_no < 0) - { + if (intersecting_border_line_no < 0) { System.out.println("Pin.get_trace_exit_restrictions: border line not found"); continue; } @@ -372,183 +314,144 @@ public java.util.Collection get_trace_exit_restrictions(in } return result; } - + /** * Returns true, if this pin has exit restrictions on some kayer. */ - public boolean has_trace_exit_restrictions() - { - for (int i = this.first_layer(); i <= this.last_layer(); ++i) - { + public boolean has_trace_exit_restrictions() { + for (int i = this.first_layer(); i <= this.last_layer(); ++i) { java.util.Collection curr_exit_restrictions = get_trace_exit_restrictions(i); - if (curr_exit_restrictions.size() > 0) - { + if (curr_exit_restrictions.size() > 0) { return true; } } return false; } - + /** * Returns true, if vias throw the pads of this pins are allowed, false, otherwise. * Currently drills are allowed to SMD-pins. */ - public boolean drill_allowed() - { + public boolean drill_allowed() { return (this.first_layer() == this.last_layer()); } - - public boolean is_obstacle(Item p_other) - { - if (p_other == this || p_other instanceof ObstacleArea) - { + + public boolean is_obstacle(Item p_other) { + if (p_other == this || p_other instanceof ObstacleArea) { return false; } - if (!p_other.shares_net(this)) - { + if (!p_other.shares_net(this)) { return true; } - if (p_other instanceof Trace) - { + if (p_other instanceof Trace) { return false; } - if (this.drill_allowed() && p_other instanceof Via && ((Via) p_other).attach_allowed) - { + if (this.drill_allowed() && p_other instanceof Via && ((Via) p_other).attach_allowed) { return false; } return true; } - - public void turn_90_degree(int p_factor, IntPoint p_pole) - { + + public void turn_90_degree(int p_factor, IntPoint p_pole) { this.set_center(null); clear_derived_data(); } - - public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) - { + + public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) { this.set_center(null); this.clear_derived_data(); } - - public void change_placement_side(IntPoint p_pole) - { + + public void change_placement_side(IntPoint p_pole) { this.set_center(null); this.clear_derived_data(); } - - public void clear_derived_data() - { + + public void clear_derived_data() { super.clear_derived_data(); this.precalculated_shapes = null; } - + /** * Return all Pins, that can be swapped with this pin. */ - public java.util.Set get_swappable_pins() - { + public java.util.Set get_swappable_pins() { java.util.Set result = new java.util.TreeSet(); Component component = this.board.components.get(this.get_component_no()); - if (component == null) - { + if (component == null) { return result; } net.freerouting.library.LogicalPart logical_part = component.get_logical_part(); - if (logical_part == null) - { + if (logical_part == null) { return result; } net.freerouting.library.LogicalPart.PartPin this_part_pin = logical_part.get_pin(this.pin_no); - if (this_part_pin == null) - { + if (this_part_pin == null) { return result; } - if (this_part_pin.gate_pin_swap_code <= 0) - { + if (this_part_pin.gate_pin_swap_code <= 0) { return result; } // look up all part pins with the same gate_name and the same gate_pin_swap_code - for( int i = 0; i < logical_part.pin_count(); ++i) - { - if (i == this.pin_no) - { + for (int i = 0; i < logical_part.pin_count(); ++i) { + if (i == this.pin_no) { continue; } - net.freerouting.library.LogicalPart.PartPin curr_part_pin = logical_part.get_pin(i); + net.freerouting.library.LogicalPart.PartPin curr_part_pin = logical_part.get_pin(i); if (curr_part_pin != null && curr_part_pin.gate_pin_swap_code == this_part_pin.gate_pin_swap_code - && curr_part_pin.gate_name.equals(this_part_pin.gate_name)) - { + && curr_part_pin.gate_name.equals(this_part_pin.gate_name)) { Pin curr_swappeble_pin = this.board.get_pin(this.get_component_no(), curr_part_pin.pin_no); - if (curr_swappeble_pin != null) - { + if (curr_swappeble_pin != null) { result.add(curr_swappeble_pin); - } - else - { + } else { System.out.println("Pin.get_swappable_pins: swappable pin not found"); } } } return result; } - - public boolean is_selected_by_filter(ItemSelectionFilter p_filter) - { - if (!this.is_selected_by_fixed_filter(p_filter)) - { + + public boolean is_selected_by_filter(ItemSelectionFilter p_filter) { + if (!this.is_selected_by_fixed_filter(p_filter)) { return false; } return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.PINS); } - - public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { + + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { java.awt.Color[] result; - if (this.net_count() > 0) - { + if (this.net_count() > 0) { result = p_graphics_context.get_pin_colors(); - } - else - { + } else { // display unconnected pins as obstacles result = p_graphics_context.get_obstacle_colors(); } return result; } - - public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { + + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_pin_color_intensity(); } - + /** * Swaps the nets of this pin and p_other. * Returns false on error. */ - public boolean swap(Pin p_other) - { - if (this.net_count() > 1 || p_other.net_count() > 1) - { + public boolean swap(Pin p_other) { + if (this.net_count() > 1 || p_other.net_count() > 1) { System.out.println("Pin.swap not yet implemented for pins belonging to more than 1 net "); return false; } int this_net_no; - if (this.net_count() > 0) - { - this_net_no = this.get_net_no(0); - } - else - { + if (this.net_count() > 0) { + this_net_no = this.get_net_no(0); + } else { this_net_no = 0; } int other_net_no; - if (p_other.net_count() > 0) - { - other_net_no = p_other.get_net_no(0); - } - else - { + if (p_other.net_count() > 0) { + other_net_no = p_other.get_net_no(0); + } else { other_net_no = 0; } this.assign_net_no(other_net_no); @@ -558,97 +461,83 @@ public boolean swap(Pin p_other) p_other.changed_to = tmp; return true; } - + /** * Returns the pin, this pin was changed to by pin swapping, or this pin, if it was not swapped. */ - public Pin get_changed_to() - { + public Pin get_changed_to() { return changed_to; } - - public boolean write(java.io.ObjectOutputStream p_stream) - { - try - { + + public boolean write(java.io.ObjectOutputStream p_stream) { + try { p_stream.writeObject(this); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { return false; } return true; } - - - /** False, if this drillitem is places on the back side of the board */ - public boolean is_placed_on_front() - { + + /** + * False, if this drillitem is places on the back side of the board + */ + public boolean is_placed_on_front() { boolean result = true; Component component = board.components.get(this.get_component_no()); - if (component != null) - { + if (component != null) { result = component.placed_on_front(); } return result; } - + /** * Returns the smallest width of the pin shape on layer p_layer. */ - public double get_min_width(int p_layer) - { + public double get_min_width(int p_layer) { int padstack_layer = get_padstack_layer(p_layer - this.first_layer()); Shape padstack_shape = this.get_padstack().get_shape(padstack_layer); - if (padstack_shape == null) - { + if (padstack_shape == null) { System.out.println("Pin.get_min_width: padstack_shape is null"); return 0; } net.freerouting.geometry.planar.IntBox padstack_bounding_box = padstack_shape.bounding_box(); - if (padstack_bounding_box == null) - { + if (padstack_bounding_box == null) { System.out.println("Pin.get_min_width: padstack_bounding_box is null"); return 0; } return padstack_bounding_box.min_width(); } - + /** * Returns the neckdown half width for traces on p_layer. * The neckdown width is used, when the pin width is smmaller than the trace width * to enter or leave the pin with a trace. */ - public int get_trace_neckdown_halfwidth(int p_layer) - { - double result = Math.max (0.5 * this.get_min_width(p_layer) - 1, 1); + public int get_trace_neckdown_halfwidth(int p_layer) { + double result = Math.max(0.5 * this.get_min_width(p_layer) - 1, 1); return (int) result; } - + /** * Returns the largest width of the pin shape on layer p_layer. */ - public double get_max_width(int p_layer) - { + public double get_max_width(int p_layer) { int padstack_layer = get_padstack_layer(p_layer - this.first_layer()); Shape padstack_shape = this.get_padstack().get_shape(padstack_layer); - if (padstack_shape == null) - { + if (padstack_shape == null) { System.out.println("Pin.get_max_width: padstack_shape is null"); return 0; } net.freerouting.geometry.planar.IntBox padstack_bounding_box = padstack_shape.bounding_box(); - if (padstack_bounding_box == null) - { + if (padstack_bounding_box == null) { System.out.println("Pin.get_max_width: padstack_bounding_box is null"); return 0; } return padstack_bounding_box.max_width(); } - - public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("pin") + ": "); p_window.append(resources.getString("component_2") + " "); @@ -659,42 +548,37 @@ public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) p_window.append(", " + resources.getString("padstack") + " "); net.freerouting.library.Padstack padstack = this.get_padstack(); p_window.append(padstack.name, resources.getString("padstack_info"), padstack); - p_window.append(" " + resources.getString("at") + " "); + p_window.append(" " + resources.getString("at") + " "); p_window.append(this.get_center().to_float()); this.print_connectable_item_info(p_window, p_locale); p_window.newline(); } - + /** * Calculates the nearest exit restriction direction for changing p_trace_polyline. * p_trace_polyline is assumed to start at the pin center. * Returns null, if there is no matching exit restrictions. */ - Direction calc_nearest_exit_restriction_direction(Polyline p_trace_polyline, int p_trace_half_width, int p_layer) - { + Direction calc_nearest_exit_restriction_direction(Polyline p_trace_polyline, int p_trace_half_width, int p_layer) { java.util.Collection trace_exit_restrictions = this.get_trace_exit_restrictions(p_layer); - if (trace_exit_restrictions.isEmpty()) - { + if (trace_exit_restrictions.isEmpty()) { return null; } Shape pin_shape = this.get_shape(p_layer - this.first_layer()); Point pin_center = this.get_center(); - if (!(pin_shape instanceof TileShape)) - { + if (!(pin_shape instanceof TileShape)) { return null; } final double edge_to_turn_dist = this.board.rules.get_pin_edge_to_turn_dist(); - if (edge_to_turn_dist < 0) - { + if (edge_to_turn_dist < 0) { return null; } - TileShape offset_pin_shape = (TileShape)((TileShape)pin_shape).offset(edge_to_turn_dist + p_trace_half_width); - int [][] entries = offset_pin_shape.entrance_points(p_trace_polyline); - if (entries.length == 0) - { + TileShape offset_pin_shape = (TileShape) ((TileShape) pin_shape).offset(edge_to_turn_dist + p_trace_half_width); + int[][] entries = offset_pin_shape.entrance_points(p_trace_polyline); + if (entries.length == 0) { return null; } - int [] latest_entry_tuple = entries[entries.length - 1]; + int[] latest_entry_tuple = entries[entries.length - 1]; FloatPoint trace_entry_location_approx = p_trace_polyline.arr[latest_entry_tuple[0]].intersection_approx(offset_pin_shape.border_line(latest_entry_tuple[1])); // calculate the nearest legal pin exit point to trace_entry_location_approx @@ -702,38 +586,29 @@ Direction calc_nearest_exit_restriction_direction(Polyline p_trace_polyline, int FloatPoint nearest_exit_corner = null; Direction pin_exit_direction = null; final double TOLERANCE = 1; - for (Pin.TraceExitRestriction curr_exit_restriction : trace_exit_restrictions) - { + for (Pin.TraceExitRestriction curr_exit_restriction : trace_exit_restrictions) { int curr_intersecting_border_line_no = offset_pin_shape.intersecting_border_line_no(pin_center, curr_exit_restriction.direction); Line curr_pin_exit_ray = new Line(pin_center, curr_exit_restriction.direction); FloatPoint curr_exit_corner = curr_pin_exit_ray.intersection_approx(offset_pin_shape.border_line(curr_intersecting_border_line_no)); double curr_exit_corner_distance = curr_exit_corner.distance_square(trace_entry_location_approx); boolean new_nearest_corner_found = false; - if (curr_exit_corner_distance + TOLERANCE < min_exit_corner_distance) - { + if (curr_exit_corner_distance + TOLERANCE < min_exit_corner_distance) { new_nearest_corner_found = true; - } - else if (curr_exit_corner_distance < min_exit_corner_distance + TOLERANCE) - { + } else if (curr_exit_corner_distance < min_exit_corner_distance + TOLERANCE) { // the distances are near equal, compare to the previous corners of p_trace_polyline - for (int i = 1; i < p_trace_polyline.corner_count(); ++i ) - { + for (int i = 1; i < p_trace_polyline.corner_count(); ++i) { FloatPoint curr_trace_corner = p_trace_polyline.corner_approx(i); double curr_trace_corner_distance = curr_trace_corner.distance_square(curr_exit_corner); double old_trace_corner_distance = curr_trace_corner.distance_square(nearest_exit_corner); - if (curr_trace_corner_distance + TOLERANCE < old_trace_corner_distance) - { + if (curr_trace_corner_distance + TOLERANCE < old_trace_corner_distance) { new_nearest_corner_found = true; break; - } - else if (curr_trace_corner_distance > old_trace_corner_distance + TOLERANCE) - { + } else if (curr_trace_corner_distance > old_trace_corner_distance + TOLERANCE) { break; } } } - if (new_nearest_corner_found) - { + if (new_nearest_corner_found) { min_exit_corner_distance = curr_exit_corner_distance; pin_exit_direction = curr_exit_restriction.direction; nearest_exit_corner = curr_exit_corner; @@ -741,73 +616,56 @@ else if (curr_trace_corner_distance > old_trace_corner_distance + TOLERANCE) } return pin_exit_direction; } - - /** - * Calculates the nearest trace exit point of the pin on p_layer. - * Returns null, if the pin has no trace exit restrictions. - */ - public FloatPoint nearest_trace_exit_corner(FloatPoint p_from_point, int p_trace_half_width, int p_layer) - { + + /** + * Calculates the nearest trace exit point of the pin on p_layer. + * Returns null, if the pin has no trace exit restrictions. + */ + public FloatPoint nearest_trace_exit_corner(FloatPoint p_from_point, int p_trace_half_width, int p_layer) { java.util.Collection trace_exit_restrictions = this.get_trace_exit_restrictions(p_layer); - if (trace_exit_restrictions.isEmpty()) - { + if (trace_exit_restrictions.isEmpty()) { return null; } Shape pin_shape = this.get_shape(p_layer - this.first_layer()); Point pin_center = this.get_center(); - if (!(pin_shape instanceof TileShape)) - { + if (!(pin_shape instanceof TileShape)) { return null; } final double edge_to_turn_dist = this.board.rules.get_pin_edge_to_turn_dist(); - if (edge_to_turn_dist < 0) - { + if (edge_to_turn_dist < 0) { return null; } - TileShape offset_pin_shape = (TileShape)((TileShape)pin_shape).offset(edge_to_turn_dist + p_trace_half_width); + TileShape offset_pin_shape = (TileShape) ((TileShape) pin_shape).offset(edge_to_turn_dist + p_trace_half_width); // calculate the nearest legal pin exit point to trace_entry_location_approx double min_exit_corner_distance = Double.MAX_VALUE; FloatPoint nearest_exit_corner = null; - for (Pin.TraceExitRestriction curr_exit_restriction : trace_exit_restrictions) - { + for (Pin.TraceExitRestriction curr_exit_restriction : trace_exit_restrictions) { int curr_intersecting_border_line_no = offset_pin_shape.intersecting_border_line_no(pin_center, curr_exit_restriction.direction); Line curr_pin_exit_ray = new Line(pin_center, curr_exit_restriction.direction); FloatPoint curr_exit_corner = curr_pin_exit_ray.intersection_approx(offset_pin_shape.border_line(curr_intersecting_border_line_no)); double curr_exit_corner_distance = curr_exit_corner.distance_square(p_from_point); - if (curr_exit_corner_distance < min_exit_corner_distance) - { + if (curr_exit_corner_distance < min_exit_corner_distance) { min_exit_corner_distance = curr_exit_corner_distance; nearest_exit_corner = curr_exit_corner; } } return nearest_exit_corner; - } - - /** The number of this pin in its component (starting with 0). */ - public final int pin_no; - - /** - * The pin, this pin was changed to by swapping or this pin, if no pin swap accured. - */ - private Pin changed_to = this; - - private transient Shape[] precalculated_shapes = null; - + } + /** * Describes an exit restriction from a trace from a pin pad. */ - public static class TraceExitRestriction - { - - /** Creates a new instance of TraceExitRestriction */ - public TraceExitRestriction(Direction p_direction, double p_min_length) - { - direction = p_direction; - min_length = p_min_length; - } - + public static class TraceExitRestriction { + public final Direction direction; public final double min_length; + /** + * Creates a new instance of TraceExitRestriction + */ + public TraceExitRestriction(Direction p_direction, double p_min_length) { + direction = p_direction; + min_length = p_min_length; + } } } diff --git a/src/main/java/net/freerouting/board/PolylineTrace.java b/src/main/java/net/freerouting/board/PolylineTrace.java index 554aa972..cc295a04 100644 --- a/src/main/java/net/freerouting/board/PolylineTrace.java +++ b/src/main/java/net/freerouting/board/PolylineTrace.java @@ -15,61 +15,45 @@ */ package net.freerouting.board; +import net.freerouting.boardgraphics.GraphicsContext; import net.freerouting.datastructures.Signum; import net.freerouting.datastructures.Stoppable; - -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.IntOctagon; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.LineSegment; +import net.freerouting.geometry.planar.*; import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Polyline; import net.freerouting.geometry.planar.Shape; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Direction; -import net.freerouting.geometry.planar.Vector; -import java.awt.Color; -import java.awt.Graphics; +import java.awt.*; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import net.freerouting.boardgraphics.GraphicsContext; - /** - * * Objects of class Trace, whose geometry is described by a Polyline * - * * @author Alfons Wirtz */ -public class PolylineTrace extends Trace implements java.io.Serializable -{ +public class PolylineTrace extends Trace implements java.io.Serializable { + + // primary data + private Polyline lines; /** * creates a new instance of a PolylineTrace with the input data */ public PolylineTrace(Polyline p_polyline, int p_layer, int p_half_width, - int[] p_net_no_arr, int p_clearance_type, int p_id_no, - int p_group_no, FixedState p_fixed_state, BasicBoard p_board) - { + int[] p_net_no_arr, int p_clearance_type, int p_id_no, + int p_group_no, FixedState p_fixed_state, BasicBoard p_board) { super(p_layer, p_half_width, p_net_no_arr, p_clearance_type, p_id_no, p_group_no, p_fixed_state, p_board); - if (p_polyline.arr.length < 3) - { + if (p_polyline.arr.length < 3) { System.out.println("PolylineTrace: p_polyline.arr.length >= 3 expected"); } lines = p_polyline; } - public Item copy(int p_id_no) - { + public Item copy(int p_id_no) { int[] curr_net_no_arr = new int[this.net_count()]; - for (int i = 0; i < curr_net_no_arr.length; ++i) - { + for (int i = 0; i < curr_net_no_arr.length; ++i) { curr_net_no_arr[i] = get_net_no(i); } return new PolylineTrace(lines, get_layer(), get_half_width(), curr_net_no_arr, clearance_class_no(), @@ -79,8 +63,7 @@ public Item copy(int p_id_no) /** * checks, if this trace is on layer p_layer */ - public boolean is_on_layer(int p_layer) - { + public boolean is_on_layer(int p_layer) { return get_layer() == p_layer; } @@ -88,8 +71,7 @@ public boolean is_on_layer(int p_layer) * returns the first corner of this trace, which is the intersection * of the first and second lines of its polyline */ - public Point first_corner() - { + public Point first_corner() { return lines.corner(0); } @@ -97,8 +79,7 @@ public Point first_corner() * returns the last corner of this trace, which is the intersection * of the last two lines of its polyline */ - public Point last_corner() - { + public Point last_corner() { return lines.corner(lines.arr.length - 2); } @@ -106,26 +87,21 @@ public Point last_corner() * returns the number of corners of this trace, which is the * number of lines of its polyline minus one */ - public int corner_count() - { + public int corner_count() { return lines.arr.length - 1; } - public double get_length() - { + public double get_length() { return lines.length_approx(); } - public IntBox bounding_box() - { + public IntBox bounding_box() { IntBox result = this.lines.bounding_box(); return result.offset(this.get_half_width()); } - public void draw(Graphics p_g, GraphicsContext p_graphics_context, Color[] p_color_arr, double p_intensity) - { - if (p_graphics_context == null) - { + public void draw(Graphics p_g, GraphicsContext p_graphics_context, Color[] p_color_arr, double p_intensity) { + if (p_graphics_context == null) { return; } int layer = this.get_layer(); @@ -138,47 +114,39 @@ public void draw(Graphics p_g, GraphicsContext p_graphics_context, Color[] p_col /** * Returns the polyline of this trace. */ - public Polyline polyline() - { + public Polyline polyline() { return lines; } - protected TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) - { + protected TileShape[] calculate_tree_shapes(ShapeSearchTree p_search_tree) { return p_search_tree.calculate_tree_shapes(this); } /** * returns the count of tile shapes of this polyline */ - public int tile_shape_count() - { + public int tile_shape_count() { return Math.max(lines.arr.length - 2, 0); } - public void translate_by(Vector p_vector) - { + public void translate_by(Vector p_vector) { lines = lines.translate_by(p_vector); this.clear_derived_data(); } - public void turn_90_degree(int p_factor, IntPoint p_pole) - { + public void turn_90_degree(int p_factor, IntPoint p_pole) { lines = lines.turn_90_degree(p_factor, p_pole); this.clear_derived_data(); } - public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) - { + public void rotate_approx(double p_angle_in_degree, FloatPoint p_pole) { this.lines = this.lines.rotate_approx(Math.toRadians(p_angle_in_degree), p_pole); } - public void change_placement_side(IntPoint p_pole) - { + public void change_placement_side(IntPoint p_pole) { lines = lines.mirror_vertical(p_pole); - if (this.board != null) - { + if (this.board != null) { this.set_layer(board.get_layer_count() - this.get_layer() - 1); } this.clear_derived_data(); @@ -189,29 +157,21 @@ public void change_placement_side(IntPoint p_pole) * Returns true, if somthing has been combined. * This trace will be the combined trace, so that only other traces may be deleted. */ - public boolean combine() - { - if (!this.is_on_the_board()) - { + public boolean combine() { + if (!this.is_on_the_board()) { return false; } boolean something_changed; - if (this.combine_at_start(true)) - { + if (this.combine_at_start(true)) { something_changed = true; this.combine(); - } - else if (this.combine_at_end(true)) - { + } else if (this.combine_at_end(true)) { something_changed = true; this.combine(); - } - else - { + } else { something_changed = false; } - if (something_changed) - { + if (something_changed) { // let the observers syncronize the changes board.communication.observers.notify_changed(this); board.additional_update_after_change(this); @@ -226,45 +186,34 @@ else if (this.combine_at_end(true)) * In case of combine the other trace will be deleted and this trace will * remain. */ - private boolean combine_at_start(boolean p_ignore_areas) - { + private boolean combine_at_start(boolean p_ignore_areas) { Point start_corner = first_corner(); Collection contacts = get_normal_contacts(start_corner, false); - if (p_ignore_areas) - { + if (p_ignore_areas) { // remove conduction areas from the list Iterator it = contacts.iterator(); - while (it.hasNext()) - { - if (it.next() instanceof ConductionArea) - { + while (it.hasNext()) { + if (it.next() instanceof ConductionArea) { it.remove(); } } } - if (contacts.size() != 1) - { + if (contacts.size() != 1) { return false; } PolylineTrace other_trace = null; boolean trace_found = false; boolean reverse_order = false; Iterator it = contacts.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if (curr_ob instanceof PolylineTrace) - { + if (curr_ob instanceof PolylineTrace) { other_trace = (PolylineTrace) curr_ob; - if (other_trace.get_layer() == get_layer() && other_trace.nets_equal(this) && other_trace.get_half_width() == get_half_width() && other_trace.get_fixed_state() == this.get_fixed_state()) - { - if (start_corner.equals(other_trace.last_corner())) - { + if (other_trace.get_layer() == get_layer() && other_trace.nets_equal(this) && other_trace.get_half_width() == get_half_width() && other_trace.get_fixed_state() == this.get_fixed_state()) { + if (start_corner.equals(other_trace.last_corner())) { trace_found = true; break; - } - else if (start_corner.equals(other_trace.first_corner())) - { + } else if (start_corner.equals(other_trace.first_corner())) { reverse_order = true; trace_found = true; break; @@ -272,8 +221,7 @@ else if (start_corner.equals(other_trace.first_corner())) } } } - if (!trace_found) - { + if (!trace_found) { return false; } @@ -281,50 +229,40 @@ else if (start_corner.equals(other_trace.first_corner())) // create the lines of the joined polyline Line[] this_lines = lines.arr; Line[] other_lines; - if (reverse_order) - { + if (reverse_order) { other_lines = new Line[other_trace.lines.arr.length]; - for (int i = 0; i < other_lines.length; ++i) - { + for (int i = 0; i < other_lines.length; ++i) { other_lines[i] = other_trace.lines.arr[other_lines.length - 1 - i].opposite(); } - } - else - { + } else { other_lines = other_trace.lines.arr; } boolean skip_line = other_lines[other_lines.length - 2].is_equal_or_opposite(this_lines[1]); int new_line_count = this_lines.length + other_lines.length - 2; - if (skip_line) - { + if (skip_line) { --new_line_count; } Line[] new_lines = new Line[new_line_count]; System.arraycopy(other_lines, 0, new_lines, 0, other_lines.length - 1); int join_pos = other_lines.length - 1; - if (skip_line) - { + if (skip_line) { --join_pos; } System.arraycopy(this_lines, 1, new_lines, join_pos, this_lines.length - 1); Polyline joined_polyline = new Polyline(new_lines); - if (joined_polyline.arr.length != new_line_count) - { + if (joined_polyline.arr.length != new_line_count) { // consecutive parallel lines where skipped at the join location // combine without performance optimation board.search_tree_manager.remove(this); this.lines = joined_polyline; this.clear_derived_data(); board.search_tree_manager.insert(this); - } - else - { + } else { // reuse the tree entries for better performance // create the changed line shape at the join location int to_no = other_lines.length; - if (skip_line) - { + if (skip_line) { --to_no; } board.search_tree_manager.merge_entries_in_front(other_trace, this, joined_polyline, @@ -332,13 +270,11 @@ else if (start_corner.equals(other_trace.first_corner())) other_trace.clear_search_tree_entries(); this.lines = joined_polyline; } - if (this.lines.arr.length < 3) - { + if (this.lines.arr.length < 3) { board.remove_item(this); } board.remove_item(other_trace); - if (board instanceof RoutingBoard) - { + if (board instanceof RoutingBoard) { ((RoutingBoard) board).join_changed_area(start_corner.to_float(), get_layer()); } return true; @@ -351,45 +287,34 @@ else if (start_corner.equals(other_trace.first_corner())) * In case of combine the other trace will be deleted and this trace will * remain. */ - private boolean combine_at_end(boolean p_ignore_areas) - { + private boolean combine_at_end(boolean p_ignore_areas) { Point end_corner = last_corner(); Collection contacts = get_normal_contacts(end_corner, false); - if (p_ignore_areas) - { + if (p_ignore_areas) { // remove conduction areas from the list Iterator it = contacts.iterator(); - while (it.hasNext()) - { - if (it.next() instanceof ConductionArea) - { + while (it.hasNext()) { + if (it.next() instanceof ConductionArea) { it.remove(); } } } - if (contacts.size() != 1) - { + if (contacts.size() != 1) { return false; } PolylineTrace other_trace = null; boolean trace_found = false; boolean reverse_order = false; Iterator it = contacts.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if (curr_ob instanceof PolylineTrace) - { + if (curr_ob instanceof PolylineTrace) { other_trace = (PolylineTrace) curr_ob; - if (other_trace.get_layer() == get_layer() && other_trace.nets_equal(this) && other_trace.get_half_width() == get_half_width() && other_trace.get_fixed_state() == this.get_fixed_state()) - { - if (end_corner.equals(other_trace.first_corner())) - { + if (other_trace.get_layer() == get_layer() && other_trace.nets_equal(this) && other_trace.get_half_width() == get_half_width() && other_trace.get_fixed_state() == this.get_fixed_state()) { + if (end_corner.equals(other_trace.first_corner())) { trace_found = true; break; - } - else if (end_corner.equals(other_trace.last_corner())) - { + } else if (end_corner.equals(other_trace.last_corner())) { reverse_order = true; trace_found = true; break; @@ -397,8 +322,7 @@ else if (end_corner.equals(other_trace.last_corner())) } } } - if (!trace_found) - { + if (!trace_found) { return false; } @@ -406,36 +330,29 @@ else if (end_corner.equals(other_trace.last_corner())) // create the lines of the joined polyline Line[] this_lines = lines.arr; Line[] other_lines; - if (reverse_order) - { + if (reverse_order) { other_lines = new Line[other_trace.lines.arr.length]; - for (int i = 0; i < other_lines.length; ++i) - { + for (int i = 0; i < other_lines.length; ++i) { other_lines[i] = other_trace.lines.arr[other_lines.length - 1 - i].opposite(); } - } - else - { + } else { other_lines = other_trace.lines.arr; } boolean skip_line = this_lines[this_lines.length - 2].is_equal_or_opposite(other_lines[1]); int new_line_count = this_lines.length + other_lines.length - 2; - if (skip_line) - { + if (skip_line) { --new_line_count; } Line[] new_lines = new Line[new_line_count]; System.arraycopy(this_lines, 0, new_lines, 0, this_lines.length - 1); int join_pos = this_lines.length - 1; - if (skip_line) - { + if (skip_line) { --join_pos; } System.arraycopy(other_lines, 1, new_lines, join_pos, other_lines.length - 1); Polyline joined_polyline = new Polyline(new_lines); - if (joined_polyline.arr.length != new_line_count) - { + if (joined_polyline.arr.length != new_line_count) { // consecutive parallel lines where skipped at the join location // combine without performance optimation board.search_tree_manager.remove(this); @@ -443,27 +360,22 @@ else if (end_corner.equals(other_trace.last_corner())) this.lines = joined_polyline; this.clear_derived_data(); board.search_tree_manager.insert(this); - } - else - { + } else { // reuse tree entries for better performance // create the changed line shape at the join location int to_no = this_lines.length; - if (skip_line) - { + if (skip_line) { --to_no; } board.search_tree_manager.merge_entries_at_end(other_trace, this, joined_polyline, this_lines.length - 3, to_no); other_trace.clear_search_tree_entries(); this.lines = joined_polyline; } - if (this.lines.arr.length < 3) - { + if (this.lines.arr.length < 3) { board.remove_item(this); } board.remove_item(other_trace); - if (board instanceof RoutingBoard) - { + if (board instanceof RoutingBoard) { ((RoutingBoard) board).join_changed_area(end_corner.to_float(), get_layer()); } return true; @@ -477,24 +389,19 @@ else if (end_corner.equals(other_trace.last_corner())) * If nothing is split, the result will contain just this Trace. * If p_clip_shape != null, the split may be resticted to p_clip_shape. */ - public Collection split(IntOctagon p_clip_shape) - { + public Collection split(IntOctagon p_clip_shape) { Collection result = new LinkedList(); - if (!this.nets_normal()) - { + if (!this.nets_normal()) { // only normal nets are split result.add(this); return result; } boolean own_trace_split = false; ShapeSearchTree default_tree = board.search_tree_manager.get_default_tree(); - for (int i = 0; i < this.lines.arr.length - 2; ++i) - { - if (p_clip_shape != null) - { + for (int i = 0; i < this.lines.arr.length - 2; ++i) { + if (p_clip_shape != null) { LineSegment curr_segment = new LineSegment(this.lines, i + 1); - if (!p_clip_shape.intersects(curr_segment.bounding_box())) - { + if (!p_clip_shape.intersects(curr_segment.bounding_box())) { continue; } } @@ -504,49 +411,37 @@ public Collection split(IntOctagon p_clip_shape) // look for intersecting traces with the i-th line segment default_tree.overlapping_tree_entries(curr_shape, get_layer(), overlapping_tree_entries); Iterator it = overlapping_tree_entries.iterator(); - while (it.hasNext()) - { - if (!this.is_on_the_board()) - { + while (it.hasNext()) { + if (!this.is_on_the_board()) { // this trace has been deleted in a cleanup operation return result; } ShapeSearchTree.TreeEntry found_entry = it.next(); - if (!(found_entry.object instanceof Item)) - { + if (!(found_entry.object instanceof Item)) { continue; } Item found_item = (Item) found_entry.object; - if (found_item == this) - { + if (found_item == this) { - if (found_entry.shape_index_in_object >= i - 1 && found_entry.shape_index_in_object <= i + 1) - { + if (found_entry.shape_index_in_object >= i - 1 && found_entry.shape_index_in_object <= i + 1) { // don't split own trace at this line or at neighbour lines continue; } // try to handle intermediate segments of length 0 by comparing end corners - if (i < found_entry.shape_index_in_object) - { - if (lines.corner(i + 1).equals(lines.corner(found_entry.shape_index_in_object))) - { + if (i < found_entry.shape_index_in_object) { + if (lines.corner(i + 1).equals(lines.corner(found_entry.shape_index_in_object))) { continue; } - } - else if (found_entry.shape_index_in_object < i) - { - if (lines.corner(found_entry.shape_index_in_object + 1).equals(lines.corner(i))) - { + } else if (found_entry.shape_index_in_object < i) { + if (lines.corner(found_entry.shape_index_in_object + 1).equals(lines.corner(i))) { continue; } } } - if (!found_item.shares_net(this)) - { + if (!found_item.shares_net(this)) { continue; } - if (found_item instanceof PolylineTrace) - { + if (found_item instanceof PolylineTrace) { PolylineTrace found_trace = (PolylineTrace) found_item; LineSegment found_line_segment = new LineSegment(found_trace.lines, found_entry.shape_index_in_object + 1); @@ -556,26 +451,20 @@ else if (found_entry.shape_index_in_object < i) // try splitting the found trace first boolean found_trace_split = false; - if (found_trace != this) - { - for (int j = 0; j < intersecting_lines.length; ++j) - { + if (found_trace != this) { + for (int j = 0; j < intersecting_lines.length; ++j) { int line_no = found_entry.shape_index_in_object + 1; PolylineTrace[] curr_split_pieces = found_trace.split(line_no, intersecting_lines[j]); - if (curr_split_pieces != null) - { + if (curr_split_pieces != null) { - for (int k = 0; k < 2; ++k) - { - if (curr_split_pieces[k] != null) - { + for (int k = 0; k < 2; ++k) { + if (curr_split_pieces[k] != null) { found_trace_split = true; split_pieces.add(curr_split_pieces[k]); } } - if (found_trace_split) - { + if (found_trace_split) { // reread the overlapping tree entries and reset the iterator, // because the board has changed default_tree.overlapping_tree_entries(curr_shape, get_layer(), overlapping_tree_entries); @@ -584,41 +473,33 @@ else if (found_entry.shape_index_in_object < i) } } } - if (!found_trace_split) - { + if (!found_trace_split) { split_pieces.add(found_trace); } } // now try splitting the own trace intersecting_lines = curr_line_segment.intersection(found_line_segment); - for (int j = 0; j < intersecting_lines.length; ++j) - { + for (int j = 0; j < intersecting_lines.length; ++j) { PolylineTrace[] curr_split_pieces = split(i + 1, intersecting_lines[j]); - if (curr_split_pieces != null) - { + if (curr_split_pieces != null) { own_trace_split = true; // this trace was split itself into 2. - if (curr_split_pieces[0] != null) - { + if (curr_split_pieces[0] != null) { result.addAll(curr_split_pieces[0].split(p_clip_shape)); } - if (curr_split_pieces[1] != null) - { + if (curr_split_pieces[1] != null) { result.addAll(curr_split_pieces[1].split(p_clip_shape)); } break; } } - if (found_trace_split || own_trace_split) - { + if (found_trace_split || own_trace_split) { // something was split, // remove cycles containing a split piece Iterator it2 = split_pieces.iterator(); - for (int j = 0; j < 2; ++j) - { - while (it2.hasNext()) - { + for (int j = 0; j < 2; ++j) { + while (it2.hasNext()) { PolylineTrace curr_piece = it2.next(); board.remove_if_cycle(curr_piece); } @@ -628,55 +509,42 @@ else if (found_entry.shape_index_in_object < i) it2 = result.iterator(); } } - if (own_trace_split) - { + if (own_trace_split) { break; } - } - else if (found_item instanceof DrillItem) - { + } else if (found_item instanceof DrillItem) { DrillItem curr_drill_item = (DrillItem) found_item; Point split_point = curr_drill_item.get_center(); - if (curr_line_segment.contains(split_point)) - { + if (curr_line_segment.contains(split_point)) { Direction split_line_direction = curr_line_segment.get_line().direction().turn_45_degree(2); Line split_line = new Line(split_point, split_line_direction); split(i + 1, split_line); } - } - else if (!this.is_user_fixed() && (found_item instanceof ConductionArea)) - { + } else if (!this.is_user_fixed() && (found_item instanceof ConductionArea)) { boolean ignore_areas = false; - if (this.net_no_arr.length > 0) - { + if (this.net_no_arr.length > 0) { net.freerouting.rules.Net curr_net = this.board.rules.nets.get(this.net_no_arr[0]); - if (curr_net != null && curr_net.get_class() != null) - { + if (curr_net != null && curr_net.get_class() != null) { ignore_areas = curr_net.get_class().get_ignore_cycles_with_areas(); } } if (!ignore_areas && this.get_start_contacts().contains(found_item) && - this.get_end_contacts().contains(found_item)) - { + this.get_end_contacts().contains(found_item)) { // this trace can be removed because of cycle with conduction area board.remove_item(this); return result; } } } - if (own_trace_split) - { + if (own_trace_split) { break; } } - if (!own_trace_split) - { + if (!own_trace_split) { result.add(this); } - if (result.size() > 1) - { - for (Item curr_item : result) - { + if (result.size() > 1) { + for (Item curr_item : result) { board.additional_update_after_change(curr_item); } } @@ -689,35 +557,26 @@ else if (!this.is_user_fixed() && (found_item instanceof ConductionArea)) * is at the center of the pin. * Extending the function to vias leaded to broken connection problems wenn the autorouter connected to a trace. */ - private boolean split_inside_drill_pad_prohibited(int p_line_no, Line p_line) - { - if (this.board == null) - { + private boolean split_inside_drill_pad_prohibited(int p_line_no, Line p_line) { + if (this.board == null) { return false; } Point intersection = this.lines.arr[p_line_no].intersection(p_line); java.util.Collection overlap_items = this.board.pick_items(intersection, this.get_layer(), null); boolean pad_found = false; - for (Item curr_item : overlap_items) - { - if (!curr_item.shares_net(this)) - { + for (Item curr_item : overlap_items) { + if (!curr_item.shares_net(this)) { continue; } - if (curr_item instanceof Pin) - { + if (curr_item instanceof Pin) { DrillItem curr_drill_item = (DrillItem) curr_item; - if (curr_drill_item.get_center().equals(intersection)) - { + if (curr_drill_item.get_center().equals(intersection)) { return false; // split always at the center of a drill item. } pad_found = true; - } - else if (curr_item instanceof Trace) - { + } else if (curr_item instanceof Trace) { Trace curr_trace = (Trace) curr_item; - if (curr_trace != this && curr_trace.first_corner().equals(intersection) || curr_trace.last_corner().equals(intersection)) - { + if (curr_trace != this && curr_trace.first_corner().equals(intersection) || curr_trace.last_corner().equals(intersection)) { return false; } } @@ -727,21 +586,17 @@ else if (curr_item instanceof Trace) /** * Splits this trace into two at p_point. - * Returns the 2 pieces of the splitted trace, or null if nothing was splitted because for example + * Returns the 2 pieces of the splitted trace, or null if nothing was splitted because for example * p_point is not located on a line segment of the p_polyline of this trace. */ - public Trace[] split(Point p_point) - { - for (int i = 0; i < this.lines.arr.length - 2; ++i) - { + public Trace[] split(Point p_point) { + for (int i = 0; i < this.lines.arr.length - 2; ++i) { LineSegment curr_line_segment = new LineSegment(this.lines, i + 1); - if (curr_line_segment.contains(p_point)) - { + if (curr_line_segment.contains(p_point)) { Direction split_line_direction = curr_line_segment.get_line().direction().turn_45_degree(2); Line split_line = new Line(p_point, split_line_direction); Trace[] result = split(i + 1, split_line); - if (result != null) - { + if (result != null) { return result; } } @@ -755,24 +610,19 @@ public Trace[] split(Point p_point) * and as the start line of the second split piece. * Returns the 2 pieces of the splitted trace, or null, if nothing was splitted. */ - private PolylineTrace[] split(int p_line_no, Line p_new_end_line) - { - if (!this.is_on_the_board()) - { + private PolylineTrace[] split(int p_line_no, Line p_new_end_line) { + if (!this.is_on_the_board()) { return null; } Polyline[] split_polylines = lines.split(p_line_no, p_new_end_line); - if (split_polylines == null) - { + if (split_polylines == null) { return null; } - if (split_polylines.length != 2) - { + if (split_polylines.length != 2) { System.out.println("PolylineTrace.split: array of length 2 expected for split_polylines"); return null; } - if (split_inside_drill_pad_prohibited(p_line_no, p_new_end_line)) - { + if (split_inside_drill_pad_prohibited(p_line_no, p_new_end_line)) { return null; } board.remove_item(this); @@ -789,43 +639,34 @@ private PolylineTrace[] split(int p_line_no, Line p_new_end_line) * Returns true, if something was changed. * If p_clip_shape != null, splitting is restricted to p_clip_shape. */ - public boolean normalize(IntOctagon p_clip_shape) - { + public boolean normalize(IntOctagon p_clip_shape) { boolean observers_activated = false; BasicBoard routing_board = this.board; - if (this.board != null) - { + if (this.board != null) { // Let the observers know the trace changes. observers_activated = !routing_board.observers_active(); - if (observers_activated) - { + if (observers_activated) { routing_board.start_notify_observers(); } } Collection split_pieces = this.split(p_clip_shape); boolean result = (split_pieces.size() != 1); Iterator it = split_pieces.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { PolylineTrace curr_split_trace = it.next(); - if (curr_split_trace.is_on_the_board()) - { + if (curr_split_trace.is_on_the_board()) { boolean trace_combined = curr_split_trace.combine(); - if (curr_split_trace.corner_count() == 2 && curr_split_trace.first_corner().equals(curr_split_trace.last_corner())) - { + if (curr_split_trace.corner_count() == 2 && curr_split_trace.first_corner().equals(curr_split_trace.last_corner())) { // remove trace with only 1 corner board.remove_item(curr_split_trace); result = true; - } - else if (trace_combined) - { + } else if (trace_combined) { curr_split_trace.normalize(p_clip_shape); result = true; } } } - if (observers_activated) - { + if (observers_activated) { routing_board.end_notify_observers(); } return result; @@ -835,61 +676,48 @@ else if (trace_combined) * Tries to shorten this trace without creating clearance violations * Returns true, if the trace was changed. */ - public boolean pull_tight(PullTightAlgo p_pull_tight_algo) - { - if (!this.is_on_the_board()) - { + public boolean pull_tight(PullTightAlgo p_pull_tight_algo) { + if (!this.is_on_the_board()) { // This trace may have been deleted in a trace split for example return false; } - if (this.is_shove_fixed()) - { + if (this.is_shove_fixed()) { return false; } - if (!this.nets_normal()) - { + if (!this.nets_normal()) { return false; } - if (p_pull_tight_algo.only_net_no_arr.length > 0 && !this.nets_equal(p_pull_tight_algo.only_net_no_arr)) - { + if (p_pull_tight_algo.only_net_no_arr.length > 0 && !this.nets_equal(p_pull_tight_algo.only_net_no_arr)) { return false; } - if (this.net_no_arr.length > 0) - { - if (!this.board.rules.nets.get(this.net_no_arr[0]).get_class().get_pull_tight()) - { + if (this.net_no_arr.length > 0) { + if (!this.board.rules.nets.get(this.net_no_arr[0]).get_class().get_pull_tight()) { return false; } } Polyline new_lines = p_pull_tight_algo.pull_tight(lines, get_layer(), get_half_width(), net_no_arr, clearance_class_no(), - this.touching_pins_at_end_corners()); - if (new_lines != lines) - { + this.touching_pins_at_end_corners()); + if (new_lines != lines) { change(new_lines); return true; } AngleRestriction angle_restriction = this.board.rules.get_trace_angle_restriction(); - if (angle_restriction != AngleRestriction.NINETY_DEGREE && this.board.rules.get_pin_edge_to_turn_dist() > 0) - { - if (this.swap_connection_to_pin(true)) - { + if (angle_restriction != AngleRestriction.NINETY_DEGREE && this.board.rules.get_pin_edge_to_turn_dist() > 0) { + if (this.swap_connection_to_pin(true)) { pull_tight(p_pull_tight_algo); return true; } - if (this.swap_connection_to_pin(false)) - { + if (this.swap_connection_to_pin(false)) { pull_tight(p_pull_tight_algo); return true; } // optimize algorithm could not improve the trace, try to remove acid traps - if (this.correct_connection_to_pin(true, angle_restriction)) - { + if (this.correct_connection_to_pin(true, angle_restriction)) { pull_tight(p_pull_tight_algo); return true; } - if (this.correct_connection_to_pin(false, angle_restriction)) - { + if (this.correct_connection_to_pin(false, angle_restriction)) { pull_tight(p_pull_tight_algo); return true; } @@ -901,55 +729,43 @@ public boolean pull_tight(PullTightAlgo p_pull_tight_algo) * Tries to pull this trace tight without creating clearance violations * Returns true, if the trace was changed. */ - public boolean pull_tight(boolean p_own_net_only, int p_pull_tight_accuracy, Stoppable p_stoppable_thread) - { - if (!(this.board instanceof RoutingBoard)) - { + public boolean pull_tight(boolean p_own_net_only, int p_pull_tight_accuracy, Stoppable p_stoppable_thread) { + if (!(this.board instanceof RoutingBoard)) { return false; } int[] opt_net_no_arr; - if (p_own_net_only) - { + if (p_own_net_only) { opt_net_no_arr = this.net_no_arr; - } - else - { + } else { opt_net_no_arr = new int[0]; } PullTightAlgo pull_tight_algo = PullTightAlgo.get_instance((RoutingBoard) this.board, opt_net_no_arr, - null, p_pull_tight_accuracy, p_stoppable_thread, -1, null, -1); + null, p_pull_tight_accuracy, p_stoppable_thread, -1, null, -1); return pull_tight(pull_tight_algo); } /** * Tries to smoothen the end corners of this trace, which are at a fork with other traces. */ - public boolean smoothen_end_corners_fork(boolean p_own_net_only, int p_pull_tight_accuracy, Stoppable p_stoppable_thread) - { - if (!(this.board instanceof RoutingBoard)) - { + public boolean smoothen_end_corners_fork(boolean p_own_net_only, int p_pull_tight_accuracy, Stoppable p_stoppable_thread) { + if (!(this.board instanceof RoutingBoard)) { return false; } int[] opt_net_no_arr; - if (p_own_net_only) - { + if (p_own_net_only) { opt_net_no_arr = this.net_no_arr; - } - else - { + } else { opt_net_no_arr = new int[0]; } PullTightAlgo pull_tight_algo = PullTightAlgo.get_instance((RoutingBoard) this.board, opt_net_no_arr, - null, p_pull_tight_accuracy, p_stoppable_thread, -1, null, -1); + null, p_pull_tight_accuracy, p_stoppable_thread, -1, null, -1); return pull_tight_algo.smoothen_end_corners_at_trace(this); } - public TileShape get_trace_connection_shape(ShapeSearchTree p_search_tree, int p_index) - { - if (p_index < 0 || p_index >= this.tile_shape_count()) - { + public TileShape get_trace_connection_shape(ShapeSearchTree p_search_tree, int p_index) { + if (p_index < 0 || p_index >= this.tile_shape_count()) { System.out.println("PolylineTrace.get_trace_connection_shape p_index out of range"); return null; } @@ -958,13 +774,10 @@ public TileShape get_trace_connection_shape(ShapeSearchTree p_search_tree, int p return result; } - public boolean write(java.io.ObjectOutputStream p_stream) - { - try - { + public boolean write(java.io.ObjectOutputStream p_stream) { + try { p_stream.writeObject(this); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { return false; } return true; @@ -973,10 +786,8 @@ public boolean write(java.io.ObjectOutputStream p_stream) /** * changes the geometry of this trace to p_new_polyline */ - void change(Polyline p_new_polyline) - { - if (!this.is_on_the_board()) - { + void change(Polyline p_new_polyline) { + if (!this.is_on_the_board()) { // Just change the polyline of this trace. lines = p_new_polyline; return; @@ -996,32 +807,26 @@ void change(Polyline p_new_polyline) // the lines of the existung trace int last_index = Math.min(p_new_polyline.arr.length, lines.arr.length); int index_of_first_different_line = last_index; - for (int i = 0; i < last_index; ++i) - { - if (p_new_polyline.arr[i] != lines.arr[i]) - { + for (int i = 0; i < last_index; ++i) { + if (p_new_polyline.arr[i] != lines.arr[i]) { index_of_first_different_line = i; break; } } - if (index_of_first_different_line == last_index) - { + if (index_of_first_different_line == last_index) { return; // both polylines are equal, no change nessesary } // look for the last line in p_new_polyline different from // the lines of the existung trace int index_of_last_different_line = -1; - for (int i = 1; i <= last_index; ++i) - { + for (int i = 1; i <= last_index; ++i) { if (p_new_polyline.arr[p_new_polyline.arr.length - i] != - lines.arr[lines.arr.length - i]) - { + lines.arr[lines.arr.length - i]) { index_of_last_different_line = p_new_polyline.arr.length - i; break; } } - if (index_of_last_different_line < 0) - { + if (index_of_last_different_line < 0) { return; // both polylines are equal, no change nessesary } int keep_at_start_count = Math.max(index_of_first_different_line - 2, 0); @@ -1033,11 +838,9 @@ void change(Polyline p_new_polyline) board.communication.observers.notify_changed(this); IntOctagon clip_shape = null; - if (board instanceof RoutingBoard) - { + if (board instanceof RoutingBoard) { ChangedArea changed_area = ((RoutingBoard) board).changed_area; - if (changed_area != null) - { + if (changed_area != null) { clip_shape = changed_area.get_area(this.get_layer()); } } @@ -1050,84 +853,65 @@ void change(Polyline p_new_polyline) * else the end. Returns false, if a pin is at that end, where * the connection is checked and the connection is not ok. */ - public boolean check_connection_to_pin(boolean p_at_start) - { - if (this.board == null) - { + public boolean check_connection_to_pin(boolean p_at_start) { + if (this.board == null) { return true; } - if (this.corner_count() < 2) - { + if (this.corner_count() < 2) { return true; } Collection contact_list; - if (p_at_start) - { + if (p_at_start) { contact_list = this.get_start_contacts(); - } - else - { + } else { contact_list = this.get_end_contacts(); } Pin contact_pin = null; - for (Item curr_contact : contact_list) - { - if (curr_contact instanceof Pin) - { + for (Item curr_contact : contact_list) { + if (curr_contact instanceof Pin) { contact_pin = (Pin) curr_contact; break; } } - if (contact_pin == null) - { + if (contact_pin == null) { return true; } Collection trace_exit_restrictions = contact_pin.get_trace_exit_restrictions(this.get_layer()); - if (trace_exit_restrictions.isEmpty()) - { + if (trace_exit_restrictions.isEmpty()) { return true; } Point end_corner; Point prev_end_corner; - if (p_at_start) - { + if (p_at_start) { end_corner = this.first_corner(); prev_end_corner = this.lines.corner(1); - } - else - { + } else { end_corner = this.last_corner(); prev_end_corner = this.lines.corner(this.lines.corner_count() - 2); } Direction trace_end_direction = Direction.get_instance(end_corner, prev_end_corner); - if (trace_end_direction == null) - { + if (trace_end_direction == null) { return true; } Pin.TraceExitRestriction matching_exit_restriction = null; - for (Pin.TraceExitRestriction curr_exit_restriction : trace_exit_restrictions) - { - if (curr_exit_restriction.direction.equals(trace_end_direction)) - { + for (Pin.TraceExitRestriction curr_exit_restriction : trace_exit_restrictions) { + if (curr_exit_restriction.direction.equals(trace_end_direction)) { matching_exit_restriction = curr_exit_restriction; break; } } - if (matching_exit_restriction == null) - { + if (matching_exit_restriction == null) { return false; } final double edge_to_turn_dist = this.board.rules.get_pin_edge_to_turn_dist(); - if (edge_to_turn_dist < 0) - { + if (edge_to_turn_dist < 0) { return false; } double end_line_length = end_corner.to_float().distance(prev_end_corner.to_float()); double curr_clearance = board.clearance_value(this.clearance_class_no(), contact_pin.clearance_class_no(), this.get_layer()); double add_width = Math.max(edge_to_turn_dist, curr_clearance + 1); double preserve_length = matching_exit_restriction.min_length + this.get_half_width() + add_width; - if (preserve_length > end_line_length) - { + if (preserve_length > end_line_length) { return false; } return true; @@ -1136,71 +920,56 @@ public boolean check_connection_to_pin(boolean p_at_start) /** * Tries to correct a connection restriction of this trace. * If p_at_start, the start of the trace polygon is corrected, else the end. - *Returns true, if this trace was changed. + * Returns true, if this trace was changed. */ - public boolean correct_connection_to_pin(boolean p_at_start, AngleRestriction p_angle_restriction) - { - if (this.check_connection_to_pin(p_at_start)) - { + public boolean correct_connection_to_pin(boolean p_at_start, AngleRestriction p_angle_restriction) { + if (this.check_connection_to_pin(p_at_start)) { return false; } Polyline trace_polyline; Collection contact_list; - if (p_at_start) - { + if (p_at_start) { trace_polyline = this.polyline(); contact_list = this.get_start_contacts(); - } - else - { + } else { trace_polyline = this.polyline().reverse(); contact_list = this.get_end_contacts(); } Pin contact_pin = null; - for (Item curr_contact : contact_list) - { - if (curr_contact instanceof Pin) - { + for (Item curr_contact : contact_list) { + if (curr_contact instanceof Pin) { contact_pin = (Pin) curr_contact; break; } } - if (contact_pin == null) - { + if (contact_pin == null) { return false; } Collection trace_exit_restrictions = contact_pin.get_trace_exit_restrictions(this.get_layer()); - if (trace_exit_restrictions.isEmpty()) - { + if (trace_exit_restrictions.isEmpty()) { return false; } Shape pin_shape = contact_pin.get_shape(this.get_layer() - contact_pin.first_layer()); - if (!(pin_shape instanceof TileShape)) - { + if (!(pin_shape instanceof TileShape)) { return false; } Point pin_center = contact_pin.get_center(); final double edge_to_turn_dist = this.board.rules.get_pin_edge_to_turn_dist(); - if (edge_to_turn_dist < 0) - { + if (edge_to_turn_dist < 0) { return false; } double curr_clearance = board.clearance_value(this.clearance_class_no(), contact_pin.clearance_class_no(), this.get_layer()); double add_width = Math.max(edge_to_turn_dist, curr_clearance + 1); TileShape offset_pin_shape = (TileShape) ((TileShape) pin_shape).offset(this.get_half_width() + add_width); - if (p_angle_restriction == AngleRestriction.NINETY_DEGREE || offset_pin_shape.is_IntBox()) - { + if (p_angle_restriction == AngleRestriction.NINETY_DEGREE || offset_pin_shape.is_IntBox()) { offset_pin_shape = offset_pin_shape.bounding_box(); - } - else if (p_angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (p_angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) { offset_pin_shape = offset_pin_shape.bounding_octagon(); } int[][] entries = offset_pin_shape.entrance_points(trace_polyline); - if (entries.length == 0) - { + if (entries.length == 0) { return false; } int[] latest_entry_tuple = entries[entries.length - 1]; @@ -1213,38 +982,29 @@ else if (p_angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) Direction pin_exit_direction = null; FloatPoint nearest_exit_corner = null; final double TOLERANCE = 1; - for (Pin.TraceExitRestriction curr_exit_restriction : trace_exit_restrictions) - { + for (Pin.TraceExitRestriction curr_exit_restriction : trace_exit_restrictions) { int curr_intersecting_border_line_no = offset_pin_shape.intersecting_border_line_no(pin_center, curr_exit_restriction.direction); Line curr_pin_exit_ray = new Line(pin_center, curr_exit_restriction.direction); FloatPoint curr_exit_corner = curr_pin_exit_ray.intersection_approx(offset_pin_shape.border_line(curr_intersecting_border_line_no)); double curr_exit_corner_distance = curr_exit_corner.distance_square(trace_entry_location_approx); boolean new_nearest_corner_found = false; - if (curr_exit_corner_distance + TOLERANCE < min_exit_corner_distance) - { + if (curr_exit_corner_distance + TOLERANCE < min_exit_corner_distance) { new_nearest_corner_found = true; - } - else if (curr_exit_corner_distance < min_exit_corner_distance + TOLERANCE) - { + } else if (curr_exit_corner_distance < min_exit_corner_distance + TOLERANCE) { // the distances are near equal, compare to the previous corners of p_trace_polyline - for (int i = 1; i < trace_polyline.corner_count(); ++i) - { + for (int i = 1; i < trace_polyline.corner_count(); ++i) { FloatPoint curr_trace_corner = trace_polyline.corner_approx(i); double curr_trace_corner_distance = curr_trace_corner.distance_square(curr_exit_corner); double old_trace_corner_distance = curr_trace_corner.distance_square(nearest_exit_corner); - if (curr_trace_corner_distance + TOLERANCE < old_trace_corner_distance) - { + if (curr_trace_corner_distance + TOLERANCE < old_trace_corner_distance) { new_nearest_corner_found = true; break; - } - else if (curr_trace_corner_distance > old_trace_corner_distance + TOLERANCE) - { + } else if (curr_trace_corner_distance > old_trace_corner_distance + TOLERANCE) { break; } } } - if (new_nearest_corner_found) - { + if (new_nearest_corner_found) { min_exit_corner_distance = curr_exit_corner_distance; nearest_pin_exit_ray = curr_pin_exit_ray; nearest_border_line_no = curr_intersecting_border_line_no; @@ -1263,20 +1023,15 @@ else if (curr_trace_corner_distance > old_trace_corner_distance + TOLERANCE) int counter_clock_wise_side_diff = (latest_entry_tuple[1] - nearest_border_line_no + corner_count) % corner_count; int curr_border_line_no = nearest_border_line_no; - if (counter_clock_wise_side_diff <= clock_wise_side_diff) - { + if (counter_clock_wise_side_diff <= clock_wise_side_diff) { curr_lines = new Line[counter_clock_wise_side_diff + 3]; - for (int i = 0; i <= counter_clock_wise_side_diff; ++i) - { + for (int i = 0; i <= counter_clock_wise_side_diff; ++i) { curr_lines[i + 1] = offset_pin_shape.border_line(curr_border_line_no); curr_border_line_no = (curr_border_line_no + 1) % corner_count; } - } - else - { + } else { curr_lines = new Line[clock_wise_side_diff + 3]; - for (int i = 0; i <= clock_wise_side_diff; ++i) - { + for (int i = 0; i <= clock_wise_side_diff; ++i) { curr_lines[i + 1] = offset_pin_shape.border_line(curr_border_line_no); curr_border_line_no = (curr_border_line_no - 1 + corner_count) % corner_count; } @@ -1286,30 +1041,24 @@ else if (curr_trace_corner_distance > old_trace_corner_distance + TOLERANCE) Polyline border_polyline = new Polyline(curr_lines); if (!this.board.check_polyline_trace(border_polyline, this.get_layer(), - this.get_half_width(), this.net_no_arr, this.clearance_class_no())) - { + this.get_half_width(), this.net_no_arr, this.clearance_class_no())) { return false; } Line[] cut_lines = new Line[trace_polyline.arr.length - latest_entry_tuple[0] + 1]; cut_lines[0] = curr_lines[curr_lines.length - 2]; - for (int i = 1; i < cut_lines.length; ++i) - { + for (int i = 1; i < cut_lines.length; ++i) { cut_lines[i] = trace_polyline.arr[latest_entry_tuple[0] + i - 1]; } Polyline cut_polyline = new Polyline(cut_lines); Polyline changed_polyline; - if (cut_polyline.first_corner().equals(cut_polyline.last_corner())) - { + if (cut_polyline.first_corner().equals(cut_polyline.last_corner())) { changed_polyline = border_polyline; - } - else - { + } else { changed_polyline = border_polyline.combine(cut_polyline); } - if (!p_at_start) - { + if (!p_at_start) { changed_polyline = changed_polyline.reverse(); } this.change(changed_polyline); @@ -1332,27 +1081,21 @@ else if (curr_trace_corner_distance > old_trace_corner_distance + TOLERANCE) * If p_at_start, the start of the trace polygon is changed, else the end. * Returns true, if this trace was changed. */ - public boolean swap_connection_to_pin(boolean p_at_start) - { + public boolean swap_connection_to_pin(boolean p_at_start) { Polyline trace_polyline; Collection contact_list; - if (p_at_start) - { + if (p_at_start) { trace_polyline = this.polyline(); contact_list = this.get_start_contacts(); - } - else - { + } else { trace_polyline = this.polyline().reverse(); contact_list = this.get_end_contacts(); } - if (contact_list.size() != 1) - { + if (contact_list.size() != 1) { return false; } Item curr_contact = contact_list.iterator().next(); - if (!(curr_contact.get_fixed_state() == FixedState.SHOVE_FIXED && (curr_contact instanceof PolylineTrace))) - { + if (!(curr_contact.get_fixed_state() == FixedState.SHOVE_FIXED && (curr_contact instanceof PolylineTrace))) { return false; } PolylineTrace contact_trace = (PolylineTrace) curr_contact; @@ -1362,46 +1105,37 @@ public boolean swap_connection_to_pin(boolean p_at_start) Line first_line = trace_polyline.arr[1]; // check for sharp angle boolean check_swap = contact_last_line.direction().projection(first_line.direction()) == Signum.NEGATIVE; - if (!check_swap) - { + if (!check_swap) { double half_width = this.get_half_width(); if (trace_polyline.arr.length > 3 && - trace_polyline.corner_approx(0).distance_square(trace_polyline.corner_approx(1)) <= half_width * half_width) - { + trace_polyline.corner_approx(0).distance_square(trace_polyline.corner_approx(1)) <= half_width * half_width) { // check also for sharp angle with the second line check_swap = (contact_last_line.direction().projection(trace_polyline.arr[2].direction()) == Signum.NEGATIVE); } } - if (!check_swap) - { + if (!check_swap) { return false; } Pin contact_pin = null; Collection curr_contacts = contact_trace.get_start_contacts(); - for (Item tmp_contact : curr_contacts) - { - if (tmp_contact instanceof Pin) - { + for (Item tmp_contact : curr_contacts) { + if (tmp_contact instanceof Pin) { contact_pin = (Pin) tmp_contact; break; } } - if (contact_pin == null) - { + if (contact_pin == null) { return false; } Polyline combined_polyline = contact_polyline.combine(trace_polyline); Direction nearest_pin_exit_direction = contact_pin.calc_nearest_exit_restriction_direction(combined_polyline, this.get_half_width(), this.get_layer()); - if (nearest_pin_exit_direction == null || nearest_pin_exit_direction.equals(contact_polyline.arr[1].direction())) - { + if (nearest_pin_exit_direction == null || nearest_pin_exit_direction.equals(contact_polyline.arr[1].direction())) { return false; // direction would not be changed } contact_trace.set_fixed_state(this.get_fixed_state()); this.combine(); return true; } - // primary data - private Polyline lines; } diff --git a/src/main/java/net/freerouting/board/PrintableShape.java b/src/main/java/net/freerouting/board/PrintableShape.java index 65acb679..c63b08b6 100644 --- a/src/main/java/net/freerouting/board/PrintableShape.java +++ b/src/main/java/net/freerouting/board/PrintableShape.java @@ -27,104 +27,90 @@ * * @author Alfons Wirtz */ -public abstract class PrintableShape -{ - protected PrintableShape(java.util.Locale p_locale) - { +public abstract class PrintableShape { + protected final java.util.Locale locale; + + protected PrintableShape(java.util.Locale p_locale) { this.locale = p_locale; } - + /** * Returns text information about the PrintableShape. */ public abstract String toString(); - - protected final java.util.Locale locale; - - static class Circle extends PrintableShape - { + + static class Circle extends PrintableShape { + public final FloatPoint center; + public final double radius; + /** * Creates a Circle from the input coordinates. */ - public Circle(FloatPoint p_center, double p_radius, java.util.Locale p_locale) - { + public Circle(FloatPoint p_center, double p_radius, java.util.Locale p_locale) { super(p_locale); center = p_center; radius = p_radius; } - - public String toString() - { - java.util.ResourceBundle resources = + + public String toString() { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", this.locale); String result = resources.getString("circle") + ": "; - if (center.x != 0 || center.y != 0) - { + if (center.x != 0 || center.y != 0) { String center_string = resources.getString("center") + " =" + center.to_string(this.locale); result += center_string; } - java.text.NumberFormat nf = java.text.NumberFormat.getInstance(this.locale); + java.text.NumberFormat nf = java.text.NumberFormat.getInstance(this.locale); nf.setMaximumFractionDigits(4); - String radius_string = resources.getString("radius") + " = " + nf.format((float)radius); + String radius_string = resources.getString("radius") + " = " + nf.format((float) radius); result += radius_string; return result; } - - public final FloatPoint center; - public final double radius; } - + /** * Creates a Polygon from the input coordinates. */ - static class Rectangle extends PrintableShape - { - public Rectangle(FloatPoint p_lower_left, FloatPoint p_upper_right, java.util.Locale p_locale) - { + static class Rectangle extends PrintableShape { + public final FloatPoint lower_left; + public final FloatPoint upper_right; + + public Rectangle(FloatPoint p_lower_left, FloatPoint p_upper_right, java.util.Locale p_locale) { super(p_locale); lower_left = p_lower_left; upper_right = p_upper_right; } - - public String toString() - { - java.util.ResourceBundle resources = + + public String toString() { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", this.locale); String result = resources.getString("rectangle") + ": " + resources.getString("lower_left") + " = " + lower_left.to_string(this.locale) + ", " + resources.getString("upper_right") + " = " - + upper_right.to_string(this.locale) ; + + upper_right.to_string(this.locale); return result; } - - public final FloatPoint lower_left; - public final FloatPoint upper_right; } - - - static class Polygon extends PrintableShape - { - public Polygon(FloatPoint[] p_corners, java.util.Locale p_locale) - { + + + static class Polygon extends PrintableShape { + public final FloatPoint[] corner_arr; + + public Polygon(FloatPoint[] p_corners, java.util.Locale p_locale) { super(p_locale); corner_arr = p_corners; } - - public String toString() - { - java.util.ResourceBundle resources = + + public String toString() { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", this.locale); String result = resources.getString("polygon") + ": "; - for (int i = 0; i < corner_arr.length; ++i) - { - if (i > 0) - { + for (int i = 0; i < corner_arr.length; ++i) { + if (i > 0) { result += ", "; } result += corner_arr[i].to_string(this.locale); } return result; } - - public final FloatPoint[] corner_arr; } } diff --git a/src/main/java/net/freerouting/board/PullTightAlgo.java b/src/main/java/net/freerouting/board/PullTightAlgo.java index 8cf20553..a84aa1d9 100644 --- a/src/main/java/net/freerouting/board/PullTightAlgo.java +++ b/src/main/java/net/freerouting/board/PullTightAlgo.java @@ -19,32 +19,67 @@ */ package net.freerouting.board; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntOctagon; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.Side; -import net.freerouting.geometry.planar.TileShape; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Set; - +import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; import net.freerouting.datastructures.Signum; import net.freerouting.datastructures.Stoppable; import net.freerouting.datastructures.TimeLimit; +import net.freerouting.geometry.planar.*; -import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; /** * Class with functionality for optimising traces and vias. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public abstract class PullTightAlgo -{ +public abstract class PullTightAlgo { + + protected static final double c_max_cos_angle = 0.999; + // with angles to close to 180 degree the algorithm becomes numerically + // unstable + protected static final double c_min_corner_dist_square = 0.9; + protected final RoutingBoard board; + /** + * If only_net_no > 0, only nets with this net numbers are optimized. + */ + protected final int[] only_net_no_arr; + /** + * If stoppable_thread != null, the agorithm can be requested to be stopped. + */ + private final Stoppable stoppable_thread; + private final TimeLimit time_limit; + /** + * If keep_point != null, traces containing the keep_point must also + * contain the keep_point after optimizing. + */ + private final Point keep_point; + private final int keep_point_layer; + protected int curr_layer; + protected int curr_half_width; + protected int[] curr_net_no_arr; + protected int curr_cl_type; + protected IntOctagon curr_clip_shape; + protected Set contact_pins; + protected int min_translate_dist; + + /** + * Creates a new instance of PullTightAlgo + */ + PullTightAlgo(RoutingBoard p_board, int[] p_only_net_no_arr, Stoppable p_stoppable_thread, int p_time_limit, + Point p_keep_point, int p_keep_point_layer) { + board = p_board; + only_net_no_arr = p_only_net_no_arr; + stoppable_thread = p_stoppable_thread; + if (p_time_limit > 0) { + this.time_limit = new TimeLimit(p_time_limit); + } else { + this.time_limit = null; + } + this.keep_point = p_keep_point; + this.keep_point_layer = p_keep_point_layer; + } /** * Returns a new instance of PullTightAlgo. @@ -53,23 +88,17 @@ public abstract class PullTightAlgo * If p_time_limit > 0; the algorithm will be stopped after p_time_limit Milliseconds. */ static PullTightAlgo get_instance(RoutingBoard p_board, - int[] p_only_net_no_arr, IntOctagon p_clip_shape, int p_min_translate_dist, - Stoppable p_stoppable_thread, int p_time_limit, Point p_keep_point, int p_keep_point_layer) - { + int[] p_only_net_no_arr, IntOctagon p_clip_shape, int p_min_translate_dist, + Stoppable p_stoppable_thread, int p_time_limit, Point p_keep_point, int p_keep_point_layer) { PullTightAlgo result; AngleRestriction angle_restriction = p_board.rules.get_trace_angle_restriction(); - if (angle_restriction == AngleRestriction.NINETY_DEGREE) - { + if (angle_restriction == AngleRestriction.NINETY_DEGREE) { result = new PullTightAlgo90(p_board, p_only_net_no_arr, p_stoppable_thread, p_time_limit, p_keep_point, p_keep_point_layer); - } - else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) { result = new PullTightAlgo45(p_board, p_only_net_no_arr, p_stoppable_thread, p_time_limit, p_keep_point, p_keep_point_layer); - } - else - { + } else { result = new PullTightAlgoAnyAngle(p_board, p_only_net_no_arr, p_stoppable_thread, p_time_limit, p_keep_point, p_keep_point_layer); } @@ -78,48 +107,24 @@ else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) return result; } - /** Creates a new instance of PullTightAlgo */ - PullTightAlgo(RoutingBoard p_board, int[] p_only_net_no_arr, Stoppable p_stoppable_thread, int p_time_limit, - Point p_keep_point, int p_keep_point_layer) - { - board = p_board; - only_net_no_arr = p_only_net_no_arr; - stoppable_thread = p_stoppable_thread; - if (p_time_limit > 0) - { - this.time_limit = new TimeLimit(p_time_limit); - } - else - { - this.time_limit = null; - } - this.keep_point = p_keep_point; - this.keep_point_layer = p_keep_point_layer; - } - /** * Function for optimizing the route in an internal marked area. * If p_clip_shape != null, the optimizing area is restricted to p_clip_shape. - * p_trace_cost_arr is used for optimizing vias and may be null. + * p_trace_cost_arr is used for optimizing vias and may be null. */ - void opt_changed_area(ExpansionCostFactor[] p_trace_cost_arr) - { - if (board.changed_area == null) - { + void opt_changed_area(ExpansionCostFactor[] p_trace_cost_arr) { + if (board.changed_area == null) { return; } boolean something_changed = true; // starting with curr_min_translate_dist big is a try to // avoid fine approximation at the beginning to avoid // problems with dog ears - while (something_changed) - { + while (something_changed) { something_changed = false; - for (int i = 0; i < board.get_layer_count(); ++i) - { + for (int i = 0; i < board.get_layer_count(); ++i) { IntOctagon changed_region = board.changed_area.get_area(i); - if (changed_region.is_empty()) - { + if (changed_region.is_empty()) { continue; } board.changed_area.set_empty(i); @@ -131,35 +136,25 @@ void opt_changed_area(ExpansionCostFactor[] p_trace_cost_arr) // with clip_shape on layer i Collection items = board.overlapping_objects(changed_region, i); Iterator it = items.iterator(); - while (it.hasNext()) - { - if (this.is_stop_requested()) - { + while (it.hasNext()) { + if (this.is_stop_requested()) { return; } SearchTreeObject curr_ob = it.next(); - if (curr_ob instanceof PolylineTrace) - { + if (curr_ob instanceof PolylineTrace) { PolylineTrace curr_trace = (PolylineTrace) curr_ob; - if (curr_trace.pull_tight(this)) - { + if (curr_trace.pull_tight(this)) { something_changed = true; - if (this.split_traces_at_keep_point()) - { + if (this.split_traces_at_keep_point()) { break; } - } - else if (smoothen_end_corners_at_trace_1(curr_trace)) - { + } else if (smoothen_end_corners_at_trace_1(curr_trace)) { something_changed = true; break; // because items may be removed } - } - else if (curr_ob instanceof Via && p_trace_cost_arr != null) - { + } else if (curr_ob instanceof Via && p_trace_cost_arr != null) { if (OptViaAlgo.opt_via_location(this.board, (Via) curr_ob, - p_trace_cost_arr, this.min_translate_dist, 10)) - { + p_trace_cost_arr, this.min_translate_dist, 10)) { something_changed = true; } } @@ -174,8 +169,7 @@ else if (curr_ob instanceof Via && p_trace_cost_arr != null) * Other pins are regarded as obstacles, even if they are of the own net. */ Polyline pull_tight(Polyline p_polyline, int p_layer, int p_half_width, - int[] p_net_no_arr, int p_cl_type, Set p_contact_pins) - { + int[] p_net_no_arr, int p_cl_type, Set p_contact_pins) { curr_layer = p_layer; ShapeSearchTree search_tree = this.board.search_tree_manager.get_default_tree(); curr_half_width = p_half_width + search_tree.clearance_compensation_value(p_cl_type, p_layer); @@ -188,19 +182,15 @@ Polyline pull_tight(Polyline p_polyline, int p_layer, int p_half_width, /** * Termitates the pull tight algorithm, if the user has made a stop request. */ - protected boolean is_stop_requested() - { - if (this.stoppable_thread != null && this.stoppable_thread.is_stop_requested()) - { + protected boolean is_stop_requested() { + if (this.stoppable_thread != null && this.stoppable_thread.is_stop_requested()) { return true; } - if (this.time_limit == null) - { + if (this.time_limit == null) { return false; } boolean time_limit_exceeded = this.time_limit.limit_exceeded(); - if (time_limit_exceeded && this.board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) - { + if (time_limit_exceeded && this.board.get_test_level().ordinal() >= TestLevel.CRITICAL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("PullTightAlgo.is_stop_requested: time limit exceeded"); } return time_limit_exceeded; @@ -209,17 +199,13 @@ protected boolean is_stop_requested() /** * tries to shorten p_polyline by relocating its lines */ - Polyline reposition_lines(Polyline p_polyline) - { - if (p_polyline.arr.length < 5) - { + Polyline reposition_lines(Polyline p_polyline) { + if (p_polyline.arr.length < 5) { return p_polyline; } - for (int i = 2; i < p_polyline.arr.length - 2; ++i) - { + for (int i = 2; i < p_polyline.arr.length - 2; ++i) { Line new_line = reposition_line(p_polyline.arr, i); - if (new_line != null) - { + if (new_line != null) { Line[] line_arr = new Line[p_polyline.arr.length]; System.arraycopy(p_polyline.arr, 0, line_arr, 0, line_arr.length); line_arr[i] = new_line; @@ -234,22 +220,18 @@ Polyline reposition_lines(Polyline p_polyline) * Tries to reposition the line with index p_no to make the polyline consisting * of p_line_arr shorter. */ - protected Line reposition_line(Line[] p_line_arr, int p_no) - { - if (p_line_arr.length - p_no < 3) - { + protected Line reposition_line(Line[] p_line_arr, int p_no) { + if (p_line_arr.length - p_no < 3) { return null; } if (curr_clip_shape != null) // check, that the corners of the line to translate are inside // the clip shape { - for (int i = -1; i < 1; ++i) - { + for (int i = -1; i < 1; ++i) { Point curr_corner = p_line_arr[p_no + i].intersection(p_line_arr[p_no + i + 1]); - if (curr_clip_shape.is_outside(curr_corner)) - { + if (curr_clip_shape.is_outside(curr_corner)) { return null; } } @@ -261,20 +243,16 @@ protected Line reposition_line(Line[] p_line_arr, int p_no) p_line_arr[p_no + 1].intersection(p_line_arr[p_no + 2]); double prev_dist = translate_line.signed_distance(prev_corner.to_float()); double next_dist = translate_line.signed_distance(next_corner.to_float()); - if (Signum.of(prev_dist) != Signum.of(next_dist)) - { + if (Signum.of(prev_dist) != Signum.of(next_dist)) { // the 2 corners are at different sides of translate_line return null; } Point nearest_point; double max_translate_dist; - if (Math.abs(prev_dist) < Math.abs(next_dist)) - { + if (Math.abs(prev_dist) < Math.abs(next_dist)) { nearest_point = prev_corner; max_translate_dist = prev_dist; - } - else - { + } else { nearest_point = next_corner; max_translate_dist = next_dist; } @@ -287,26 +265,20 @@ protected Line reposition_line(Line[] p_line_arr, int p_no) check_lines[0] = p_line_arr[p_no - 1]; check_lines[2] = p_line_arr[p_no + 1]; boolean first_time = true; - while (first_time || Math.abs(delta_dist) > min_translate_dist) - { + while (first_time || Math.abs(delta_dist) > min_translate_dist) { boolean check_ok = false; - if (first_time && nearest_point instanceof IntPoint) - { + if (first_time && nearest_point instanceof IntPoint) { check_lines[1] = Line.get_instance(nearest_point, translate_line.direction()); - } - else - { + } else { check_lines[1] = translate_line.translate(-translate_dist); } - if (check_lines[1].equals(translate_line)) - { + if (check_lines[1].equals(translate_line)) { // may happen at first time if nearest_point is not an IntPoint return null; } Side new_line_side_of_nearest_point = check_lines[1].side_of(nearest_point); - if (new_line_side_of_nearest_point != side_of_nearest_point && new_line_side_of_nearest_point != Side.COLLINEAR) - { + if (new_line_side_of_nearest_point != side_of_nearest_point && new_line_side_of_nearest_point != Side.COLLINEAR) { // moved a little bit to far at the first time // because of numerical inaccuracy; // may happen if nearest_point is not an IntPoint @@ -318,8 +290,7 @@ protected Line reposition_line(Line[] p_line_arr, int p_no) } Polyline tmp = new Polyline(check_lines); - if (tmp.arr.length == 3) - { + if (tmp.arr.length == 3) { TileShape shape_to_check = tmp.offset_shape(curr_half_width, 0); check_ok = board.check_trace_shape(shape_to_check, @@ -327,24 +298,19 @@ protected Line reposition_line(Line[] p_line_arr, int p_no) } delta_dist /= 2; - if (check_ok) - { + if (check_ok) { new_line = check_lines[1]; - if (first_time) - { + if (first_time) { // biggest possible change break; } translate_dist += delta_dist; - } - else - { + } else { translate_dist -= delta_dist; } first_time = false; } - if (new_line != null && board.changed_area != null) - { + if (new_line != null && board.changed_area != null) { // mark the changed area board.changed_area.join(check_lines[0].intersection_approx(new_line), curr_layer); board.changed_area.join(check_lines[2].intersection_approx(new_line), curr_layer); @@ -360,12 +326,10 @@ protected Line reposition_line(Line[] p_line_arr, int p_no) * A check is nessesary before skipping because new dog ears * may occur. */ - Polyline skip_segments_of_length_0(Polyline p_polyline) - { + Polyline skip_segments_of_length_0(Polyline p_polyline) { boolean polyline_changed = false; Polyline curr_polyline = p_polyline; - for (int i = 1; i < curr_polyline.arr.length - 1; ++i) - { + for (int i = 1; i < curr_polyline.arr.length - 1; ++i) { boolean try_skip; if (i == 1 || i == curr_polyline.arr.length - 2) // the position of the first corner and the last corner @@ -374,17 +338,14 @@ Polyline skip_segments_of_length_0(Polyline p_polyline) Point prev_corner = curr_polyline.corner(i - 1); Point curr_corner = curr_polyline.corner(i); try_skip = curr_corner.equals(prev_corner); - } - else - { + } else { FloatPoint prev_corner = curr_polyline.corner_approx(i - 1); FloatPoint curr_corner = curr_polyline.corner_approx(i); try_skip = curr_corner.distance_square(prev_corner) < c_min_corner_dist_square; } - if (try_skip) - { + if (try_skip) { // check, if skipping the line of length 0 does not // result in a clearance violation Line[] curr_lines = new Line[curr_polyline.arr.length - 1]; @@ -393,35 +354,30 @@ Polyline skip_segments_of_length_0(Polyline p_polyline) i, curr_lines.length - i); Polyline tmp = new Polyline(curr_lines); boolean check_ok = (tmp.arr.length == curr_lines.length); - if (check_ok && !curr_polyline.arr[i].is_multiple_of_45_degree()) - { + if (check_ok && !curr_polyline.arr[i].is_multiple_of_45_degree()) { // no check necessary for skipping 45 degree lines, because the check is // performance critical and the line shapes // are intersected with the bounding octagon anyway. - if (i > 1) - { + if (i > 1) { TileShape shape_to_check = tmp.offset_shape(curr_half_width, i - 2); check_ok = board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins); } - if (check_ok && (i < curr_polyline.arr.length - 2)) - { + if (check_ok && (i < curr_polyline.arr.length - 2)) { TileShape shape_to_check = tmp.offset_shape(curr_half_width, i - 1); check_ok = board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins); } } - if (check_ok) - { + if (check_ok) { polyline_changed = true; curr_polyline = tmp; --i; } } } - if (!polyline_changed) - { + if (!polyline_changed) { return p_polyline; } return curr_polyline; @@ -431,8 +387,7 @@ Polyline skip_segments_of_length_0(Polyline p_polyline) * Smoothens acute angles with contact traces. * Returns true, if something was changed. */ - boolean smoothen_end_corners_at_trace(PolylineTrace p_trace) - { + boolean smoothen_end_corners_at_trace(PolylineTrace p_trace) { curr_layer = p_trace.get_layer(); curr_half_width = p_trace.get_half_width(); curr_net_no_arr = p_trace.net_no_arr; @@ -444,11 +399,9 @@ boolean smoothen_end_corners_at_trace(PolylineTrace p_trace) * Smoothens acute angles with contact traces. * Returns true, if something was changed. */ - private boolean smoothen_end_corners_at_trace_1(PolylineTrace p_trace) - { + private boolean smoothen_end_corners_at_trace_1(PolylineTrace p_trace) { // try to improve the connection to other traces - if (p_trace.is_shove_fixed()) - { + if (p_trace.is_shove_fixed()) { return false; } Set saved_contact_pins = this.contact_pins; @@ -457,12 +410,10 @@ private boolean smoothen_end_corners_at_trace_1(PolylineTrace p_trace) boolean result = false; boolean connection_to_trace_improved = true; PolylineTrace curr_trace = p_trace; - while (connection_to_trace_improved) - { + while (connection_to_trace_improved) { connection_to_trace_improved = false; Polyline adjusted_polyline = smoothen_end_corners_at_trace_2(curr_trace); - if (adjusted_polyline != null) - { + if (adjusted_polyline != null) { result = true; connection_to_trace_improved = true; int trace_layer = curr_trace.get_layer(); @@ -471,14 +422,12 @@ private boolean smoothen_end_corners_at_trace_1(PolylineTrace p_trace) board.remove_item(curr_trace); curr_trace = board.insert_trace_without_cleaning(adjusted_polyline, trace_layer, curr_half_width, curr_trace.net_no_arr, curr_cl_class, curr_fixed_state); - for (int curr_net_no : curr_trace.net_no_arr) - { + for (int curr_net_no : curr_trace.net_no_arr) { board.split_traces(adjusted_polyline.first_corner(), trace_layer, curr_net_no); board.split_traces(adjusted_polyline.last_corner(), trace_layer, curr_net_no); board.normalize_traces(curr_net_no); - if (split_traces_at_keep_point()) - { + if (split_traces_at_keep_point()) { return true; } } @@ -489,22 +438,18 @@ private boolean smoothen_end_corners_at_trace_1(PolylineTrace p_trace) } /** - * Splits the traces containing this.keep_point if this.keep_point != null. - * Returns true, if something was split. + * Splits the traces containing this.keep_point if this.keep_point != null. + * Returns true, if something was split. */ - boolean split_traces_at_keep_point() - { - if (this.keep_point == null) - { + boolean split_traces_at_keep_point() { + if (this.keep_point == null) { return false; } ItemSelectionFilter filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.TRACES); Collection picked_items = this.board.pick_items(this.keep_point, this.keep_point_layer, filter); - for (Item curr_item : picked_items) - { + for (Item curr_item : picked_items) { Trace[] split_pieces = ((Trace) curr_item).split(this.keep_point); - if (split_pieces != null) - { + if (split_pieces != null) { return true; } } @@ -515,29 +460,22 @@ boolean split_traces_at_keep_point() * Smoothens acute angles with contact traces. * Returns null, if something was changed. */ - private Polyline smoothen_end_corners_at_trace_2(PolylineTrace p_trace) - { - if (p_trace == null || !p_trace.is_on_the_board()) - { + private Polyline smoothen_end_corners_at_trace_2(PolylineTrace p_trace) { + if (p_trace == null || !p_trace.is_on_the_board()) { return null; } Polyline result = smoothen_start_corner_at_trace(p_trace); - if (result == null) - { + if (result == null) { result = smoothen_end_corner_at_trace(p_trace); - if (result != null && board.changed_area != null) - { + if (result != null && board.changed_area != null) { // mark the changed area board.changed_area.join(result.corner_approx(result.corner_count() - 1), curr_layer); } - } - else if (board.changed_area != null) - { + } else if (board.changed_area != null) { // mark the changed area board.changed_area.join(result.corner_approx(0), curr_layer); } - if (result != null) - { + if (result != null) { this.contact_pins = p_trace.touching_pins_at_end_corners(); result = skip_segments_of_length_0(result); } @@ -547,21 +485,17 @@ else if (board.changed_area != null) /** * Wraps around pins of the own net to avoid acid traps. */ - protected Polyline avoid_acid_traps(Polyline p_polyline) - { - if (true) - { + protected Polyline avoid_acid_traps(Polyline p_polyline) { + if (true) { return p_polyline; } Polyline result = p_polyline; ShoveTraceAlgo shove_trace_algo = new ShoveTraceAlgo(this.board); Polyline new_polyline = shove_trace_algo.spring_over_obstacles(p_polyline, curr_half_width, curr_layer, curr_net_no_arr, curr_cl_type, contact_pins); - if (new_polyline != null && new_polyline != p_polyline) - { + if (new_polyline != null && new_polyline != p_polyline) { if (this.board.check_polyline_trace(new_polyline, curr_layer, curr_half_width, - curr_net_no_arr, curr_cl_type)) - { + curr_net_no_arr, curr_cl_type)) { result = new_polyline; } } @@ -573,29 +507,4 @@ protected Polyline avoid_acid_traps(Polyline p_polyline) abstract Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace); abstract Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace); - protected final RoutingBoard board; - /** If only_net_no > 0, only nets with this net numbers are optimized. */ - protected final int[] only_net_no_arr; - protected int curr_layer; - protected int curr_half_width; - protected int[] curr_net_no_arr; - protected int curr_cl_type; - protected IntOctagon curr_clip_shape; - protected Set contact_pins; - protected int min_translate_dist; - protected static final double c_max_cos_angle = 0.999; - // with angles to close to 180 degree the algorithm becomes numerically - // unstable - protected static final double c_min_corner_dist_square = 0.9; - /** - * If stoppable_thread != null, the agorithm can be requested to be stopped. - */ - private final Stoppable stoppable_thread; - private final TimeLimit time_limit; - /** - * If keep_point != null, traces containing the keep_point must also - * contain the keep_point after optimizing. - */ - private final Point keep_point; - private final int keep_point_layer; } diff --git a/src/main/java/net/freerouting/board/PullTightAlgo45.java b/src/main/java/net/freerouting/board/PullTightAlgo45.java index 64eb69b6..71515d59 100644 --- a/src/main/java/net/freerouting/board/PullTightAlgo45.java +++ b/src/main/java/net/freerouting/board/PullTightAlgo45.java @@ -19,42 +19,28 @@ */ package net.freerouting.board; -import net.freerouting.datastructures.Stoppable; - -import net.freerouting.geometry.planar.Direction; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Limits; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.Side; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Vector; import net.freerouting.datastructures.Signum; +import net.freerouting.datastructures.Stoppable; +import net.freerouting.geometry.planar.*; /** - * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -class PullTightAlgo45 extends PullTightAlgo -{ +class PullTightAlgo45 extends PullTightAlgo { - /** Creates a new instance of PullTight90 */ + /** + * Creates a new instance of PullTight90 + */ public PullTightAlgo45(RoutingBoard p_board, int[] p_only_net_no_arr, Stoppable p_stoppable_thread, int p_time_limit, - Point p_keep_point, int p_keep_point_layer) - { + Point p_keep_point, int p_keep_point_layer) { super(p_board, p_only_net_no_arr, p_stoppable_thread, p_time_limit, p_keep_point, p_keep_point_layer); } - Polyline pull_tight(Polyline p_polyline) - { + Polyline pull_tight(Polyline p_polyline) { Polyline new_result = avoid_acid_traps(p_polyline); Polyline prev_result = null; - while (new_result != prev_result) - { - if (this.is_stop_requested()) - { + while (new_result != prev_result) { + if (this.is_stop_requested()) { break; } prev_result = new_result; @@ -65,8 +51,7 @@ Polyline pull_tight(Polyline p_polyline) return new_result; } - AngleRestriction get_angle_restriction() - { + AngleRestriction get_angle_restriction() { return AngleRestriction.FORTYFIVE_DEGREE; } @@ -74,32 +59,24 @@ AngleRestriction get_angle_restriction() * Tries to reduce the amount of corners of p_polyline. * Return p_polyline, if nothing was changed. */ - private Polyline reduce_corners(Polyline p_polyline) - { - if (p_polyline.arr.length <= 4) - { + private Polyline reduce_corners(Polyline p_polyline) { + if (p_polyline.arr.length <= 4) { return p_polyline; } int new_corner_count = 1; Point[] curr_corner = new Point[4]; - for (int i = 0; i < 4; ++i) - { + for (int i = 0; i < 4; ++i) { curr_corner[i] = p_polyline.corner(i); - if (!(curr_corner[i] instanceof IntPoint)) - { + if (!(curr_corner[i] instanceof IntPoint)) { return p_polyline; } } boolean[] curr_corner_in_clip_shape = new boolean[4]; - for (int i = 0; i < 4; ++i) - { - if (curr_clip_shape == null) - { + for (int i = 0; i < 4; ++i) { + if (curr_clip_shape == null) { curr_corner_in_clip_shape[i] = true; - } - else - { + } else { curr_corner_in_clip_shape[i] = !curr_clip_shape.is_outside(curr_corner[i]); } } @@ -110,138 +87,104 @@ private Polyline reduce_corners(Polyline p_polyline) Point[] curr_check_points = new Point[2]; Point new_corner = null; int corner_no = 3; - while (corner_no < p_polyline.arr.length - 1) - { + while (corner_no < p_polyline.arr.length - 1) { boolean corner_removed = false; curr_corner[3] = p_polyline.corner(corner_no); - if (!(curr_corner[3] instanceof IntPoint)) - { + if (!(curr_corner[3] instanceof IntPoint)) { return p_polyline; } if (curr_corner[1].equals(curr_corner[2]) || corner_no < p_polyline.arr.length - 2 && - curr_corner[3].side_of(curr_corner[1], curr_corner[2]) == Side.COLLINEAR) - { + curr_corner[3].side_of(curr_corner[1], curr_corner[2]) == Side.COLLINEAR) { // corners in the middle af a line can be skipped ++corner_no; curr_corner[2] = curr_corner[3]; curr_corner_in_clip_shape[2] = curr_corner_in_clip_shape[3]; - if (corner_no < p_polyline.arr.length - 1) - { + if (corner_no < p_polyline.arr.length - 1) { curr_corner[3] = p_polyline.corner(corner_no); - if (!(curr_corner[3] instanceof IntPoint)) - { + if (!(curr_corner[3] instanceof IntPoint)) { return p_polyline; } } polyline_changed = true; } curr_corner_in_clip_shape[3] = curr_clip_shape == null || !curr_clip_shape.is_outside(curr_corner[3]); - if (curr_corner_in_clip_shape[1] && curr_corner_in_clip_shape[2] && curr_corner_in_clip_shape[3]) - { + if (curr_corner_in_clip_shape[1] && curr_corner_in_clip_shape[2] && curr_corner_in_clip_shape[3]) { // translate the line from curr_corner[2] to curr_corner[1] to curr_corner[3] Vector delta = curr_corner[3].difference_by(curr_corner[2]); new_corner = curr_corner[1].translate_by(delta); - if (curr_corner[3].equals(curr_corner[2])) - { + if (curr_corner[3].equals(curr_corner[2])) { // just remove multiple corner corner_removed = true; - } - else if (new_corner.side_of(curr_corner[0], curr_corner[1]) == Side.COLLINEAR) - { + } else if (new_corner.side_of(curr_corner[0], curr_corner[1]) == Side.COLLINEAR) { curr_check_points[0] = new_corner; curr_check_points[1] = curr_corner[1]; Polyline check_polyline = new Polyline(curr_check_points); - if (check_polyline.arr.length == 3) - { + if (check_polyline.arr.length == 3) { TileShape shape_to_check = check_polyline.offset_shape(curr_half_width, 0); if (board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, - curr_cl_type, this.contact_pins)) - { + curr_cl_type, this.contact_pins)) { curr_check_points[1] = curr_corner[3]; - if (curr_check_points[0].equals(curr_check_points[1])) - { + if (curr_check_points[0].equals(curr_check_points[1])) { corner_removed = true; - } - else - { + } else { check_polyline = new Polyline(curr_check_points); - if (check_polyline.arr.length == 3) - { + if (check_polyline.arr.length == 3) { shape_to_check = check_polyline.offset_shape(curr_half_width, 0); corner_removed = board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins); - } - else - { + } else { corner_removed = true; } } } - } - else - { + } else { corner_removed = true; } } } - if (!corner_removed && curr_corner_in_clip_shape[0] && curr_corner_in_clip_shape[1] && curr_corner_in_clip_shape[2]) - { + if (!corner_removed && curr_corner_in_clip_shape[0] && curr_corner_in_clip_shape[1] && curr_corner_in_clip_shape[2]) { // the first try has failed. Try to translate the line from // corner_2 to corner_1 to corner_0 Vector delta = curr_corner[0].difference_by(curr_corner[1]); new_corner = curr_corner[2].translate_by(delta); - if (curr_corner[0].equals(curr_corner[1])) - { + if (curr_corner[0].equals(curr_corner[1])) { // just remove multiple corner corner_removed = true; - } - else if (new_corner.side_of(curr_corner[2], curr_corner[3]) == Side.COLLINEAR) - { + } else if (new_corner.side_of(curr_corner[2], curr_corner[3]) == Side.COLLINEAR) { curr_check_points[0] = new_corner; curr_check_points[1] = curr_corner[0]; Polyline check_polyline = new Polyline(curr_check_points); - if (check_polyline.arr.length == 3) - { + if (check_polyline.arr.length == 3) { TileShape shape_to_check = check_polyline.offset_shape(curr_half_width, 0); if (board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, - curr_cl_type, this.contact_pins)) - { + curr_cl_type, this.contact_pins)) { curr_check_points[1] = curr_corner[2]; check_polyline = new Polyline(curr_check_points); - if (check_polyline.arr.length == 3) - { + if (check_polyline.arr.length == 3) { shape_to_check = check_polyline.offset_shape(curr_half_width, 0); corner_removed = board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins); - } - else - { + } else { corner_removed = true; } } - } - else - { + } else { corner_removed = true; } } } - if (corner_removed) - { + if (corner_removed) { polyline_changed = true; curr_corner[1] = new_corner; curr_corner_in_clip_shape[1] = curr_clip_shape == null || !curr_clip_shape.is_outside(curr_corner[1]); - if (board.changed_area != null) - { + if (board.changed_area != null) { board.changed_area.join(new_corner.to_float(), curr_layer); board.changed_area.join(curr_corner[1].to_float(), curr_layer); board.changed_area.join(curr_corner[2].to_float(), curr_layer); } - } - else - { + } else { new_corners[new_corner_count] = curr_corner[1]; ++new_corner_count; curr_corner[0] = curr_corner[1]; @@ -253,13 +196,11 @@ else if (new_corner.side_of(curr_corner[2], curr_corner[3]) == Side.COLLINEAR) curr_corner_in_clip_shape[2] = curr_corner_in_clip_shape[3]; ++corner_no; } - if (!polyline_changed) - { + if (!polyline_changed) { return p_polyline; } Point adjusted_corners[] = new Point[new_corner_count + 2]; - for (int i = 0; i < new_corner_count; ++i) - { + for (int i = 0; i < new_corner_count; ++i) { adjusted_corners[i] = new_corners[i]; } adjusted_corners[new_corner_count] = curr_corner[1]; @@ -273,35 +214,28 @@ else if (new_corner.side_of(curr_corner[2], curr_corner[3]) == Side.COLLINEAR) * by cutting of the 90 degree corner. The cutting of is so small, * that no check is needed */ - private Polyline smoothen_corners(Polyline p_polyline) - { + private Polyline smoothen_corners(Polyline p_polyline) { Polyline result = p_polyline; boolean polyline_changed = true; - while (polyline_changed) - { - if (result.arr.length < 4) - { + while (polyline_changed) { + if (result.arr.length < 4) { return result; } polyline_changed = false; Line[] line_arr = new Line[result.arr.length]; System.arraycopy(result.arr, 0, line_arr, 0, line_arr.length); - for (int i = 1; i < line_arr.length - 2; ++i) - { + for (int i = 1; i < line_arr.length - 2; ++i) { Direction d1 = line_arr[i].direction(); Direction d2 = line_arr[i + 1].direction(); - if (d1.is_multiple_of_45_degree() && d2.is_multiple_of_45_degree() && d1.projection(d2) != Signum.POSITIVE) - { + if (d1.is_multiple_of_45_degree() && d2.is_multiple_of_45_degree() && d1.projection(d2) != Signum.POSITIVE) { // there is a 90 degree or sharper angle Line new_line = smoothen_corner(line_arr, i); - if (new_line == null) - { + if (new_line == null) { //the greedy smoothening couldn't change the polyline new_line = smoothen_sharp_corner(line_arr, i); } - if (new_line != null) - { + if (new_line != null) { polyline_changed = true; // add the new line into the line array Line[] tmp_lines = new Line[line_arr.length + 1]; @@ -314,8 +248,7 @@ private Polyline smoothen_corners(Polyline p_polyline) } } } - if (polyline_changed) - { + if (polyline_changed) { result = new Polyline(line_arr); } } @@ -328,16 +261,13 @@ private Polyline smoothen_corners(Polyline p_polyline) * The distance of the new line to the corner will be so small * that no clearance check is necessary. */ - private Line smoothen_sharp_corner(Line[] p_line_arr, int p_no) - { + private Line smoothen_sharp_corner(Line[] p_line_arr, int p_no) { FloatPoint curr_corner = p_line_arr[p_no].intersection_approx(p_line_arr[p_no + 1]); - if (curr_corner.x != (int) curr_corner.x) - { + if (curr_corner.x != (int) curr_corner.x) { // intersection of 2 diagonal lines is not integer Line result = smoothen_non_integer_corner(p_line_arr, p_no); { - if (result != null) - { + if (result != null) { return result; } } @@ -354,38 +284,32 @@ private Line smoothen_sharp_corner(Line[] p_line_arr, int p_no) double next_dist = Math.abs(translate_line.signed_distance(next_corner)); translate_dist = Math.min(translate_dist, prev_dist); translate_dist = Math.min(translate_dist, next_dist); - if (translate_dist < 0.99) - { + if (translate_dist < 0.99) { return null; } translate_dist = Math.max(translate_dist - 1, 1); - if (translate_line.side_of(next_corner) == Side.ON_THE_LEFT) - { + if (translate_line.side_of(next_corner) == Side.ON_THE_LEFT) { translate_dist = -translate_dist; } Line result = translate_line.translate(translate_dist); - if (board.changed_area != null) - { + if (board.changed_area != null) { board.changed_area.join(curr_corner, curr_layer); } return result; } /** - * Smoothens with a short axis parrallel line to remove a non integer corner - * of two intersecting diagonal lines. - * Returns null, if that is not possible. + * Smoothens with a short axis parrallel line to remove a non integer corner + * of two intersecting diagonal lines. + * Returns null, if that is not possible. */ - private Line smoothen_non_integer_corner(Line[] p_line_arr, int p_no) - { + private Line smoothen_non_integer_corner(Line[] p_line_arr, int p_no) { Line prev_line = p_line_arr[p_no]; Line next_line = p_line_arr[p_no + 1]; - if (prev_line.is_equal_or_opposite(next_line)) - { + if (prev_line.is_equal_or_opposite(next_line)) { return null; } - if (!(prev_line.is_diagonal() && next_line.is_diagonal())) - { + if (!(prev_line.is_diagonal() && next_line.is_diagonal())) { return null; } FloatPoint curr_corner = prev_line.intersection_approx(next_line); @@ -396,58 +320,40 @@ private Line smoothen_non_integer_corner(Line[] p_line_arr, int p_no) int new_y = 0; boolean new_line_is_vertical = false; boolean new_line_is_horizontal = false; - if (prev_corner.x > curr_corner.x && next_corner.x > curr_corner.x) - { + if (prev_corner.x > curr_corner.x && next_corner.x > curr_corner.x) { new_x = (int) Math.ceil(curr_corner.x); new_y = (int) Math.ceil(curr_corner.y); new_line_is_vertical = true; - } - else if (prev_corner.x < curr_corner.x && next_corner.x < curr_corner.x) - { + } else if (prev_corner.x < curr_corner.x && next_corner.x < curr_corner.x) { new_x = (int) Math.floor(curr_corner.x); new_y = (int) Math.floor(curr_corner.y); new_line_is_vertical = true; - } - else if (prev_corner.y > curr_corner.y && next_corner.y > curr_corner.y) - { + } else if (prev_corner.y > curr_corner.y && next_corner.y > curr_corner.y) { new_x = (int) Math.ceil(curr_corner.x); new_y = (int) Math.ceil(curr_corner.y); new_line_is_horizontal = true; - } - else if (prev_corner.y < curr_corner.y && next_corner.y < curr_corner.y) - { + } else if (prev_corner.y < curr_corner.y && next_corner.y < curr_corner.y) { new_x = (int) Math.floor(curr_corner.x); new_y = (int) Math.floor(curr_corner.y); new_line_is_horizontal = true; } Direction new_line_dir = null; - if (new_line_is_vertical) - { - if (prev_corner.y < next_corner.y) - { + if (new_line_is_vertical) { + if (prev_corner.y < next_corner.y) { new_line_dir = Direction.UP; - } - else - { + } else { new_line_dir = Direction.DOWN; } - } - else if (new_line_is_horizontal) - { - if (prev_corner.x < next_corner.x) - { + } else if (new_line_is_horizontal) { + if (prev_corner.x < next_corner.x) { new_line_dir = Direction.RIGHT; - } - else - { + } else { new_line_dir = Direction.LEFT; } - } - else - { + } else { return null; } - + Point line_a = new IntPoint(new_x, new_y); result = new Line(line_a, new_line_dir); return result; @@ -459,8 +365,7 @@ else if (new_line_is_horizontal) * The distance of the new line to the corner will be so big * that a clearance check is necessary. */ - private Line smoothen_corner(Line[] p_line_arr, int p_no) - { + private Line smoothen_corner(Line[] p_line_arr, int p_no) { FloatPoint prev_corner = p_line_arr[p_no].intersection_approx(p_line_arr[p_no - 1]); FloatPoint curr_corner = p_line_arr[p_no].intersection_approx(p_line_arr[p_no + 1]); FloatPoint next_corner = p_line_arr[p_no + 1].intersection_approx(p_line_arr[p_no + 2]); @@ -471,29 +376,23 @@ private Line smoothen_corner(Line[] p_line_arr, int p_no) Line translate_line = Line.get_instance(curr_corner.round(), new_line_dir); double prev_dist = Math.abs(translate_line.signed_distance(prev_corner)); double next_dist = Math.abs(translate_line.signed_distance(next_corner)); - if (prev_dist == 0 || next_dist == 0) - { + if (prev_dist == 0 || next_dist == 0) { return null; } double max_translate_dist; FloatPoint nearest_corner; - if (prev_dist <= next_dist) - { + if (prev_dist <= next_dist) { max_translate_dist = prev_dist; nearest_corner = prev_corner; - } - else - { + } else { max_translate_dist = next_dist; nearest_corner = next_corner; } - if (max_translate_dist < 1) - { + if (max_translate_dist < 1) { return null; } max_translate_dist = Math.max(max_translate_dist - 1, 1); - if (translate_line.side_of(next_corner) == Side.ON_THE_LEFT) - { + if (translate_line.side_of(next_corner) == Side.ON_THE_LEFT) { max_translate_dist = -max_translate_dist; } Line[] check_lines = new Line[3]; @@ -504,18 +403,15 @@ private Line smoothen_corner(Line[] p_line_arr, int p_no) Side side_of_nearest_corner = translate_line.side_of(nearest_corner); int sign = Signum.as_int(max_translate_dist); Line result = null; - while (Math.abs(delta_dist) > this.min_translate_dist) - { + while (Math.abs(delta_dist) > this.min_translate_dist) { boolean check_ok = false; Line new_line = translate_line.translate(translate_dist); Side new_line_side_of_nearest_corner = new_line.side_of(nearest_corner); - if (new_line_side_of_nearest_corner == side_of_nearest_corner || new_line_side_of_nearest_corner == Side.COLLINEAR) - { + if (new_line_side_of_nearest_corner == side_of_nearest_corner || new_line_side_of_nearest_corner == Side.COLLINEAR) { check_lines[1] = new_line; Polyline tmp = new Polyline(check_lines); - if (tmp.arr.length == 3) - { + if (tmp.arr.length == 3) { TileShape shape_to_check = tmp.offset_shape(curr_half_width, 0); check_ok = board.check_trace_shape(shape_to_check, @@ -523,22 +419,17 @@ private Line smoothen_corner(Line[] p_line_arr, int p_no) } delta_dist /= 2; - if (check_ok) - { + if (check_ok) { result = check_lines[1]; - if (translate_dist == max_translate_dist) - { + if (translate_dist == max_translate_dist) { // biggest possible change break; } translate_dist += delta_dist; - } - else - { + } else { translate_dist -= delta_dist; } - } - else + } else // moved a little bit to far at the first time // because of numerical inaccuracy { @@ -548,8 +439,7 @@ private Line smoothen_corner(Line[] p_line_arr, int p_no) delta_dist -= shorten_value; } } - if (result != null && board.changed_area != null) - { + if (result != null && board.changed_area != null) { FloatPoint new_prev_corner = check_lines[0].intersection_approx(result); FloatPoint new_next_corner = @@ -561,8 +451,7 @@ private Line smoothen_corner(Line[] p_line_arr, int p_no) return result; } - Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) - { + Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) { boolean acute_angle = false; boolean bend = false; FloatPoint other_trace_corner_approx = null; @@ -571,8 +460,7 @@ Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) Polyline trace_polyline = p_trace.polyline(); Point curr_end_corner = trace_polyline.corner(0); - if (this.curr_clip_shape != null && this.curr_clip_shape.is_outside(curr_end_corner)) - { + if (this.curr_clip_shape != null && this.curr_clip_shape.is_outside(curr_end_corner)) { return null; } @@ -582,22 +470,17 @@ Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) Direction prev_line_direction = trace_polyline.arr[2].direction(); java.util.Collection contact_list = p_trace.get_start_contacts(); - for (Item curr_contact : contact_list) - { - if (curr_contact instanceof PolylineTrace && !curr_contact.is_shove_fixed()) - { + for (Item curr_contact : contact_list) { + if (curr_contact instanceof PolylineTrace && !curr_contact.is_shove_fixed()) { Polyline contact_trace_polyline = ((PolylineTrace) curr_contact).polyline(); FloatPoint curr_other_trace_corner_approx; Line curr_other_trace_line; Line curr_other_prev_trace_line; - if (contact_trace_polyline.first_corner().equals(curr_end_corner)) - { + if (contact_trace_polyline.first_corner().equals(curr_end_corner)) { curr_other_trace_corner_approx = contact_trace_polyline.corner_approx(1); curr_other_trace_line = contact_trace_polyline.arr[1]; curr_other_prev_trace_line = contact_trace_polyline.arr[2]; - } - else - { + } else { int curr_corner_no = contact_trace_polyline.corner_count() - 2; curr_other_trace_corner_approx = contact_trace_polyline.corner_approx(curr_corner_no); curr_other_trace_line = contact_trace_polyline.arr[curr_corner_no + 1].opposite(); @@ -606,45 +489,33 @@ Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) Side curr_prev_corner_side = curr_prev_end_corner.side_of(curr_other_trace_line); Signum curr_projection = line_direction.projection(curr_other_trace_line.direction()); boolean other_trace_found = false; - if (curr_projection == Signum.POSITIVE && curr_prev_corner_side != Side.COLLINEAR) - { - if (curr_other_trace_line.direction().is_orthogonal()) - { + if (curr_projection == Signum.POSITIVE && curr_prev_corner_side != Side.COLLINEAR) { + if (curr_other_trace_line.direction().is_orthogonal()) { acute_angle = true; other_trace_found = true; } - } - else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) - { - if (prev_line_direction.projection(curr_other_trace_line.direction()) == Signum.POSITIVE) - { + } else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) { + if (prev_line_direction.projection(curr_other_trace_line.direction()) == Signum.POSITIVE) { bend = true; other_trace_found = true; } } - if (other_trace_found) - { + if (other_trace_found) { other_trace_corner_approx = curr_other_trace_corner_approx; other_trace_line = curr_other_trace_line; prev_corner_side = curr_prev_corner_side; other_prev_trace_line = curr_other_prev_trace_line; } - } - else - { + } else { return null; } } - if (acute_angle) - { + if (acute_angle) { Direction new_line_dir; - if (prev_corner_side == Side.ON_THE_LEFT) - { + if (prev_corner_side == Side.ON_THE_LEFT) { new_line_dir = other_trace_line.direction().turn_45_degree(2); - } - else - { + } else { new_line_dir = other_trace_line.direction().turn_45_degree(6); } Line translate_line = Line.get_instance(curr_end_corner.to_float().round(), new_line_dir); @@ -653,12 +524,10 @@ else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) double other_dist = Math.abs(translate_line.signed_distance(other_trace_corner_approx)); translate_dist = Math.min(translate_dist, prev_corner_dist); translate_dist = Math.min(translate_dist, other_dist); - if (translate_dist >= 0.99) - { + if (translate_dist >= 0.99) { translate_dist = Math.max(translate_dist - 1, 1); - if (translate_line.side_of(curr_prev_end_corner) == Side.ON_THE_LEFT) - { + if (translate_line.side_of(curr_prev_end_corner) == Side.ON_THE_LEFT) { translate_dist = -translate_dist; } Line add_line = translate_line.translate(translate_dist); @@ -666,30 +535,24 @@ else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) Line[] new_lines = new Line[trace_polyline.arr.length + 1]; new_lines[0] = other_trace_line; new_lines[1] = add_line; - for (int i = 2; i < new_lines.length; ++i) - { + for (int i = 2; i < new_lines.length; ++i) { new_lines[i] = trace_polyline.arr[i - 1]; } return new Polyline(new_lines); } - } - else if (bend) - { + } else if (bend) { Line[] check_line_arr = new Line[trace_polyline.arr.length + 1]; check_line_arr[0] = other_prev_trace_line; check_line_arr[1] = other_trace_line; - for (int i = 2; i < check_line_arr.length; ++i) - { + for (int i = 2; i < check_line_arr.length; ++i) { check_line_arr[i] = trace_polyline.arr[i - 1]; } Line new_line = reposition_line(check_line_arr, 2); - if (new_line != null) - { + if (new_line != null) { Line[] new_lines = new Line[trace_polyline.arr.length]; new_lines[0] = other_trace_line; new_lines[1] = new_line; - for (int i = 2; i < new_lines.length; ++i) - { + for (int i = 2; i < new_lines.length; ++i) { new_lines[i] = trace_polyline.arr[i]; } return new Polyline(new_lines); @@ -698,8 +561,7 @@ else if (bend) return null; } - Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) - { + Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) { boolean acute_angle = false; boolean bend = false; FloatPoint other_trace_corner_approx = null; @@ -708,8 +570,7 @@ Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) Polyline trace_polyline = p_trace.polyline(); Point curr_end_corner = trace_polyline.last_corner(); - if (this.curr_clip_shape != null && this.curr_clip_shape.is_outside(curr_end_corner)) - { + if (this.curr_clip_shape != null && this.curr_clip_shape.is_outside(curr_end_corner)) { return null; } @@ -719,22 +580,17 @@ Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) Direction prev_line_direction = trace_polyline.arr[trace_polyline.arr.length - 3].direction().opposite(); java.util.Collection contact_list = p_trace.get_end_contacts(); - for (Item curr_contact : contact_list) - { - if (curr_contact instanceof PolylineTrace && !curr_contact.is_shove_fixed()) - { + for (Item curr_contact : contact_list) { + if (curr_contact instanceof PolylineTrace && !curr_contact.is_shove_fixed()) { Polyline contact_trace_polyline = ((PolylineTrace) curr_contact).polyline(); FloatPoint curr_other_trace_corner_approx; Line curr_other_trace_line; Line curr_other_prev_trace_line; - if (contact_trace_polyline.first_corner().equals(curr_end_corner)) - { + if (contact_trace_polyline.first_corner().equals(curr_end_corner)) { curr_other_trace_corner_approx = contact_trace_polyline.corner_approx(1); curr_other_trace_line = contact_trace_polyline.arr[1]; curr_other_prev_trace_line = contact_trace_polyline.arr[2]; - } - else - { + } else { int curr_corner_no = contact_trace_polyline.corner_count() - 2; curr_other_trace_corner_approx = contact_trace_polyline.corner_approx(curr_corner_no); curr_other_trace_line = contact_trace_polyline.arr[curr_corner_no + 1].opposite(); @@ -743,45 +599,33 @@ Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) Side curr_prev_corner_side = curr_prev_end_corner.side_of(curr_other_trace_line); Signum curr_projection = line_direction.projection(curr_other_trace_line.direction()); boolean other_trace_found = false; - if (curr_projection == Signum.POSITIVE && curr_prev_corner_side != Side.COLLINEAR) - { - if (curr_other_trace_line.direction().is_orthogonal()) - { + if (curr_projection == Signum.POSITIVE && curr_prev_corner_side != Side.COLLINEAR) { + if (curr_other_trace_line.direction().is_orthogonal()) { acute_angle = true; other_trace_found = true; } - } - else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) - { - if (prev_line_direction.projection(curr_other_trace_line.direction()) == Signum.POSITIVE) - { + } else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) { + if (prev_line_direction.projection(curr_other_trace_line.direction()) == Signum.POSITIVE) { bend = true; other_trace_found = true; } } - if (other_trace_found) - { + if (other_trace_found) { other_trace_corner_approx = curr_other_trace_corner_approx; other_trace_line = curr_other_trace_line; prev_corner_side = curr_prev_corner_side; other_prev_trace_line = curr_other_prev_trace_line; } - } - else - { + } else { return null; } } - if (acute_angle) - { + if (acute_angle) { Direction new_line_dir; - if (prev_corner_side == Side.ON_THE_LEFT) - { + if (prev_corner_side == Side.ON_THE_LEFT) { new_line_dir = other_trace_line.direction().turn_45_degree(6); - } - else - { + } else { new_line_dir = other_trace_line.direction().turn_45_degree(2); } Line translate_line = Line.get_instance(curr_end_corner.to_float().round(), new_line_dir); @@ -790,41 +634,33 @@ else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) double other_dist = Math.abs(translate_line.signed_distance(other_trace_corner_approx)); translate_dist = Math.min(translate_dist, prev_corner_dist); translate_dist = Math.min(translate_dist, other_dist); - if (translate_dist >= 0.99) - { + if (translate_dist >= 0.99) { translate_dist = Math.max(translate_dist - 1, 1); - if (translate_line.side_of(curr_prev_end_corner) == Side.ON_THE_LEFT) - { + if (translate_line.side_of(curr_prev_end_corner) == Side.ON_THE_LEFT) { translate_dist = -translate_dist; } Line add_line = translate_line.translate(translate_dist); // constract the new trace polyline. Line[] new_lines = new Line[trace_polyline.arr.length + 1]; - for (int i = 0; i < trace_polyline.arr.length - 1; ++i) - { + for (int i = 0; i < trace_polyline.arr.length - 1; ++i) { new_lines[i] = trace_polyline.arr[i]; } new_lines[new_lines.length - 2] = add_line; new_lines[new_lines.length - 1] = other_trace_line; return new Polyline(new_lines); } - } - else if (bend) - { + } else if (bend) { Line[] check_line_arr = new Line[trace_polyline.arr.length + 1]; - for (int i = 0; i < trace_polyline.arr.length - 1; ++i) - { + for (int i = 0; i < trace_polyline.arr.length - 1; ++i) { check_line_arr[i] = trace_polyline.arr[i]; } check_line_arr[check_line_arr.length - 2] = other_trace_line; check_line_arr[check_line_arr.length - 1] = other_prev_trace_line; Line new_line = reposition_line(check_line_arr, trace_polyline.arr.length - 2); - if (new_line != null) - { + if (new_line != null) { Line[] new_lines = new Line[trace_polyline.arr.length]; - for (int i = 0; i < new_lines.length - 2; ++i) - { + for (int i = 0; i < new_lines.length - 2; ++i) { new_lines[i] = trace_polyline.arr[i]; } new_lines[new_lines.length - 2] = new_line; diff --git a/src/main/java/net/freerouting/board/PullTightAlgo90.java b/src/main/java/net/freerouting/board/PullTightAlgo90.java index 89dd2afa..066615ba 100644 --- a/src/main/java/net/freerouting/board/PullTightAlgo90.java +++ b/src/main/java/net/freerouting/board/PullTightAlgo90.java @@ -21,35 +21,26 @@ package net.freerouting.board; import net.freerouting.datastructures.Stoppable; - -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.*; /** - * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -class PullTightAlgo90 extends PullTightAlgo -{ - - /** Creates a new instance of PullTight90 */ +class PullTightAlgo90 extends PullTightAlgo { + + /** + * Creates a new instance of PullTight90 + */ public PullTightAlgo90(RoutingBoard p_board, int[] p_only_net_no_arr, Stoppable p_stoppable_thread, int p_time_limit, - Point p_keep_point, int p_keep_point_layer) - { + Point p_keep_point, int p_keep_point_layer) { super(p_board, p_only_net_no_arr, p_stoppable_thread, p_time_limit, p_keep_point, p_keep_point_layer); } - - Polyline pull_tight(Polyline p_polyline) - { + + Polyline pull_tight(Polyline p_polyline) { Polyline new_result = avoid_acid_traps(p_polyline); Polyline prev_result = null; - while (new_result != prev_result) - { - if (this.is_stop_requested()) - { + while (new_result != prev_result) { + if (this.is_stop_requested()) { break; } prev_result = new_result; @@ -59,15 +50,13 @@ Polyline pull_tight(Polyline p_polyline) } return new_result; } - + /** * Tries to skip the second corner of p_polyline. * Return p_polyline, if nothing was changed. */ - private Polyline try_skip_second_corner(Polyline p_polyline) - { - if (p_polyline.arr.length < 5) - { + private Polyline try_skip_second_corner(Polyline p_polyline) { + if (p_polyline.arr.length < 5) { return p_polyline; } Line[] check_lines = new Line[4]; @@ -78,88 +67,73 @@ private Polyline try_skip_second_corner(Polyline p_polyline) Polyline check_polyline = new Polyline(check_lines); if (check_polyline.arr.length != 4 || curr_clip_shape != null && - !curr_clip_shape.contains(check_polyline.corner_approx(1))) - { + !curr_clip_shape.contains(check_polyline.corner_approx(1))) { return p_polyline; } - for (int i = 0; i < 2; ++i) - { + for (int i = 0; i < 2; ++i) { TileShape shape_to_check = check_polyline.offset_shape(curr_half_width, i); if (!board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, - curr_cl_type, this.contact_pins)) - { + curr_cl_type, this.contact_pins)) { return p_polyline; } } // now the second corner can be skipped. - Line [] new_lines = new Line [p_polyline.arr.length - 1]; + Line[] new_lines = new Line[p_polyline.arr.length - 1]; new_lines[0] = p_polyline.arr[1]; new_lines[1] = p_polyline.arr[0]; - for (int i = 2; i < new_lines.length; ++i) - { + for (int i = 2; i < new_lines.length; ++i) { new_lines[i] = p_polyline.arr[i + 1]; } - return new Polyline(new_lines); + return new Polyline(new_lines); } - + /** * Tries to reduce the amount of corners of p_polyline. * Return p_polyline, if nothing was changed. */ - private Polyline try_skip_corners(Polyline p_polyline) - { - Line [] new_lines = new Line [p_polyline.arr.length]; + private Polyline try_skip_corners(Polyline p_polyline) { + Line[] new_lines = new Line[p_polyline.arr.length]; new_lines[0] = p_polyline.arr[0]; new_lines[1] = p_polyline.arr[1]; int new_line_index = 1; boolean polyline_changed = false; Line[] check_lines = new Line[4]; boolean second_last_corner_skipped = false; - for (int i = 5; i <= p_polyline.arr.length; ++i) - { + for (int i = 5; i <= p_polyline.arr.length; ++i) { boolean skip_lines = false; boolean in_clip_shape = curr_clip_shape == null || curr_clip_shape.contains(p_polyline.corner_approx(i - 3)); - if (in_clip_shape) - { + if (in_clip_shape) { check_lines[0] = new_lines[new_line_index - 1]; check_lines[1] = new_lines[new_line_index]; check_lines[2] = p_polyline.arr[i - 1]; - if (i < p_polyline.arr.length) - { + if (i < p_polyline.arr.length) { check_lines[3] = p_polyline.arr[i]; - } - else - { + } else { // use as concluding line the second last line check_lines[3] = p_polyline.arr[i - 2]; } Polyline check_polyline = new Polyline(check_lines); skip_lines = check_polyline.arr.length == 4 && (curr_clip_shape == null || - curr_clip_shape.contains(check_polyline.corner_approx(1))); - if (skip_lines) - { + curr_clip_shape.contains(check_polyline.corner_approx(1))); + if (skip_lines) { TileShape shape_to_check = check_polyline.offset_shape(curr_half_width, 0); skip_lines = board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins); } - if (skip_lines) - { + if (skip_lines) { TileShape shape_to_check = check_polyline.offset_shape(curr_half_width, 1); skip_lines = board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins); } } - if (skip_lines) - { - if (i == p_polyline.arr.length) - { + if (skip_lines) { + if (i == p_polyline.arr.length) { second_last_corner_skipped = true; } - if (board.changed_area != null) - { - FloatPoint new_corner = check_lines[1].intersection_approx(check_lines[2]); + if (board.changed_area != null) { + FloatPoint new_corner = check_lines[1].intersection_approx(check_lines[2]); board.changed_area.join(new_corner, curr_layer); FloatPoint skipped_corner = p_polyline.arr[i - 2].intersection_approx(p_polyline.arr[i - 3]); @@ -167,47 +141,38 @@ private Polyline try_skip_corners(Polyline p_polyline) } polyline_changed = true; ++i; - } - else - { + } else { ++new_line_index; - new_lines [new_line_index ] = p_polyline.arr[i - 3]; + new_lines[new_line_index] = p_polyline.arr[i - 3]; } } - if (!polyline_changed) - { + if (!polyline_changed) { return p_polyline; } - if (second_last_corner_skipped) - { + if (second_last_corner_skipped) { // The second last corner of p_polyline was skipped ++new_line_index; - new_lines [new_line_index] = p_polyline.arr[ p_polyline.arr.length -1]; + new_lines[new_line_index] = p_polyline.arr[p_polyline.arr.length - 1]; ++new_line_index; - new_lines [new_line_index] = p_polyline.arr[ p_polyline.arr.length -2]; - } - else - { - for (int i = 3; i > 0; --i) - { + new_lines[new_line_index] = p_polyline.arr[p_polyline.arr.length - 2]; + } else { + for (int i = 3; i > 0; --i) { ++new_line_index; - new_lines [new_line_index ] = p_polyline.arr[ p_polyline.arr.length - i]; + new_lines[new_line_index] = p_polyline.arr[p_polyline.arr.length - i]; } } - - Line [] cleaned_new_lines = new Line [new_line_index + 1]; + + Line[] cleaned_new_lines = new Line[new_line_index + 1]; System.arraycopy(new_lines, 0, cleaned_new_lines, 0, cleaned_new_lines.length); Polyline result = new Polyline(cleaned_new_lines); return result; } - - Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) - { + + Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) { return null; } - - Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) - { + + Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) { return null; } } diff --git a/src/main/java/net/freerouting/board/PullTightAlgoAnyAngle.java b/src/main/java/net/freerouting/board/PullTightAlgoAnyAngle.java index 7751eb9a..9bfc9ce6 100644 --- a/src/main/java/net/freerouting/board/PullTightAlgoAnyAngle.java +++ b/src/main/java/net/freerouting/board/PullTightAlgoAnyAngle.java @@ -16,194 +16,153 @@ package net.freerouting.board; -import net.freerouting.datastructures.Stoppable; -import net.freerouting.geometry.planar.Limits; import net.freerouting.datastructures.Signum; - -import net.freerouting.geometry.planar.Direction; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.Side; -import net.freerouting.geometry.planar.TileShape; +import net.freerouting.datastructures.Stoppable; +import net.freerouting.geometry.planar.*; /** - * * Auxiliary class containing internal functions for pulling any angle traces tight. * - * * @author Alfons Wirtz */ -class PullTightAlgoAnyAngle extends PullTightAlgo -{ - +class PullTightAlgoAnyAngle extends PullTightAlgo { + + private static double SKIP_LENGTH = 10.0; + PullTightAlgoAnyAngle(RoutingBoard p_board, int[] p_only_net_no_arr, Stoppable p_stoppable_thread, int p_time_limit, - Point p_keep_point, int p_keep_point_layer) - { + Point p_keep_point, int p_keep_point_layer) { super(p_board, p_only_net_no_arr, p_stoppable_thread, p_time_limit, p_keep_point, p_keep_point_layer); } - - Polyline pull_tight(Polyline p_polyline) - { + + Polyline pull_tight(Polyline p_polyline) { Polyline new_result = avoid_acid_traps(p_polyline); Polyline prev_result = null; - while (new_result != prev_result) - { - if (is_stop_requested()) - { + while (new_result != prev_result) { + if (is_stop_requested()) { break; } prev_result = new_result; Polyline tmp = skip_segments_of_length_0(prev_result); Polyline tmp0 = reduce_lines(tmp); Polyline tmp1 = skip_lines(tmp0); - + // I intended to replace reduce_corners by the previous 2 // functions, because with consecutive corners closer than // 1 grid point reduce_corners may loop with smoothen_corners // because of changing directions heavily. // Unlike reduce_corners, the above 2 functions do not // introduce new directions - + Polyline tmp2 = reduce_corners(tmp1); Polyline tmp3 = reposition_lines(tmp2); new_result = smoothen_corners(tmp3); } return new_result; } - - + // tries to reduce the corner count of p_polyline by replacing two consecutive // lines by a line through IntPoints near the previous corner and the next // corner, if that is possible without clearance violation. - private Polyline reduce_corners(Polyline p_polyline) - { - if (p_polyline.arr.length < 4) - { + private Polyline reduce_corners(Polyline p_polyline) { + if (p_polyline.arr.length < 4) { return p_polyline; } int last_index = p_polyline.arr.length - 4; - - Line [] new_lines = new Line [p_polyline.arr.length]; + + Line[] new_lines = new Line[p_polyline.arr.length]; new_lines[0] = p_polyline.arr[0]; new_lines[1] = p_polyline.arr[1]; - + int new_line_index = 1; - + boolean polyline_changed = false; - - Line [] curr_lines = new Line[3]; - - for (int i = 0; i <= last_index; ++i) - { + + Line[] curr_lines = new Line[3]; + + for (int i = 0; i <= last_index; ++i) { boolean skip_line = false; FloatPoint new_a = new_lines[new_line_index - 1].intersection_approx(new_lines[new_line_index]); FloatPoint new_b = p_polyline.corner_approx(i + 2); boolean in_clip_shape = curr_clip_shape == null || curr_clip_shape.contains(new_a) && curr_clip_shape.contains(new_b) - && curr_clip_shape.contains(p_polyline.corner_approx(new_line_index)); - - if (in_clip_shape) - { + && curr_clip_shape.contains(p_polyline.corner_approx(new_line_index)); + + if (in_clip_shape) { FloatPoint skip_corner = new_lines[new_line_index].intersection_approx(p_polyline.arr[i + 2]); - curr_lines [1] = new Line(new_a.round(), new_b.round()); + curr_lines[1] = new Line(new_a.round(), new_b.round()); boolean ok = true; - if (new_line_index == 1) - { - if (!(p_polyline.first_corner() instanceof IntPoint)) - { + if (new_line_index == 1) { + if (!(p_polyline.first_corner() instanceof IntPoint)) { // first corner must not be changed ok = false; - } - else - { + } else { Direction dir = curr_lines[1].direction(); curr_lines[0] = Line.get_instance(p_polyline.first_corner(), dir.turn_45_degree(2)); } - } - else - { + } else { curr_lines[0] = new_lines[new_line_index - 1]; } - if (i == last_index) - { - if (!(p_polyline.last_corner() instanceof IntPoint)) - { + if (i == last_index) { + if (!(p_polyline.last_corner() instanceof IntPoint)) { // last corner must not be changed ok = false; - } - else - { + } else { Direction dir = curr_lines[1].direction(); curr_lines[2] = Line.get_instance(p_polyline.last_corner(), dir.turn_45_degree(2)); } - } - else - { + } else { curr_lines[2] = p_polyline.arr[i + 3]; } - - + + // check, if the intersection of curr_lines[0] and curr_lines[1] // is near new_a and the intersection of curr_lines[0] and // curr_lines[1] and curr_lines[2] is near new_b. // There may be numerical stability proplems with // near parallel lines. - + final double check_dist = 100; - if (ok) - { - FloatPoint check_is = curr_lines[0].intersection_approx(curr_lines[1]); + if (ok) { + FloatPoint check_is = curr_lines[0].intersection_approx(curr_lines[1]); double dist = check_is.distance_square(new_a); - - if (dist > check_dist) - { + + if (dist > check_dist) { ok = false; } } - if (ok) - { - FloatPoint check_is = curr_lines[1].intersection_approx(curr_lines[2]); + if (ok) { + FloatPoint check_is = curr_lines[1].intersection_approx(curr_lines[2]); double dist = check_is.distance_square(new_b); - if (dist > check_dist) - { + if (dist > check_dist) { ok = false; } } - if (ok && i == 1 && !(p_polyline.first_corner() instanceof IntPoint)) - { + if (ok && i == 1 && !(p_polyline.first_corner() instanceof IntPoint)) { // There may be a connection to a trace. // make shure that the second corner of the new polyline // is on the same side of the trace as the third corner. (There may be splitting problems) - Point new_corner = curr_lines[0].intersection(curr_lines[1]); - if (new_corner.side_of(new_lines[0]) != p_polyline.corner(1).side_of(new_lines[0])) - { + Point new_corner = curr_lines[0].intersection(curr_lines[1]); + if (new_corner.side_of(new_lines[0]) != p_polyline.corner(1).side_of(new_lines[0])) { ok = false; } } - if (ok && i == last_index - 1 && !(p_polyline.last_corner() instanceof IntPoint)) - { + if (ok && i == last_index - 1 && !(p_polyline.last_corner() instanceof IntPoint)) { // There may be a connection to a trace. // make shure that the second last corner of the new polyline // is on the same side of the trace as the third last corner (There may be splitting problems) - Point new_corner = curr_lines[1].intersection(curr_lines[2]); - if (new_corner.side_of(new_lines[0]) != - p_polyline.corner(p_polyline.corner_count() - 2).side_of(new_lines[0])) - { + Point new_corner = curr_lines[1].intersection(curr_lines[2]); + if (new_corner.side_of(new_lines[0]) != + p_polyline.corner(p_polyline.corner_count() - 2).side_of(new_lines[0])) { ok = false; } } Polyline curr_polyline = null; - if (ok) - { + if (ok) { curr_polyline = new Polyline(curr_lines); - if ( curr_polyline.arr.length != 3) - { + if (curr_polyline.arr.length != 3) { ok = false; } double length_before = skip_corner.distance(new_a) + @@ -211,184 +170,155 @@ private Polyline reduce_corners(Polyline p_polyline) double length_after = curr_polyline.length_approx() + 1.5; // 1.5 added because of possible inacurracy SQRT_2 // by twice rounding. - if (length_after >= length_before) - // May happen from rounding to integer. - // Prevent infinite loop. + if (length_after >= length_before) + // May happen from rounding to integer. + // Prevent infinite loop. { ok = false; } } - - if (ok) - { + + if (ok) { TileShape shape_to_check = curr_polyline.offset_shape(curr_half_width, 0); skip_line = board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins); } } - if (skip_line) - { + if (skip_line) { polyline_changed = true; new_lines[new_line_index] = curr_lines[1]; - if (new_line_index == 1) - { + if (new_line_index == 1) { // make the first line perpendicular to the current line - new_lines[0] = curr_lines [0]; + new_lines[0] = curr_lines[0]; } - if (i == last_index) - { + if (i == last_index) { // make the last line perpendicular to the current line ++new_line_index; new_lines[new_line_index] = curr_lines[2]; } - if (board.changed_area != null) - { + if (board.changed_area != null) { board.changed_area.join(new_a, curr_layer); board.changed_area.join(new_b, curr_layer); } - } - else - { + } else { ++new_line_index; new_lines[new_line_index] = p_polyline.arr[i + 2]; - if (i == last_index) - { + if (i == last_index) { ++new_line_index; new_lines[new_line_index] = p_polyline.arr[i + 3]; } } - if (new_lines[new_line_index].is_parallel(new_lines[new_line_index - 1])) - { + if (new_lines[new_line_index].is_parallel(new_lines[new_line_index - 1])) { // skip line, if it is parallel to the previous one --new_line_index; } } - if (!polyline_changed) - { + if (!polyline_changed) { return p_polyline; } - Line [] cleaned_new_lines = new Line [new_line_index + 1]; + Line[] cleaned_new_lines = new Line[new_line_index + 1]; System.arraycopy(new_lines, 0, cleaned_new_lines, 0, cleaned_new_lines.length); Polyline result = new Polyline(cleaned_new_lines); return result; } - + /** * tries to smoothen p_polyline by cutting of corners, if possible */ - private Polyline smoothen_corners(Polyline p_polyline) - { - if (p_polyline.arr.length < 4) - { + private Polyline smoothen_corners(Polyline p_polyline) { + if (p_polyline.arr.length < 4) { return p_polyline; } boolean polyline_changed = false; Line[] line_arr = new Line[p_polyline.arr.length]; System.arraycopy(p_polyline.arr, 0, line_arr, 0, line_arr.length); - - for (int i = 0; i < line_arr.length - 3; ++i) - { + + for (int i = 0; i < line_arr.length - 3; ++i) { Line new_line = smoothen_corner(line_arr, i); - if (new_line != null) - { + if (new_line != null) { polyline_changed = true; // add the new line into the line array Line[] tmp_lines = new Line[line_arr.length + 1]; System.arraycopy(line_arr, 0, tmp_lines, 0, i + 2); - tmp_lines [i + 2] = new_line; + tmp_lines[i + 2] = new_line; System.arraycopy(line_arr, i + 2, tmp_lines, i + 3, tmp_lines.length - (i + 3)); line_arr = tmp_lines; ++i; } } - if (!polyline_changed) - { + if (!polyline_changed) { return p_polyline; } return new Polyline(line_arr); } - + /** * tries to shorten p_polyline by relocating its lines */ - Polyline reposition_lines(Polyline p_polyline) - { - if (p_polyline.arr.length < 5) - { + Polyline reposition_lines(Polyline p_polyline) { + if (p_polyline.arr.length < 5) { return p_polyline; } boolean polyline_changed = false; Line[] line_arr = new Line[p_polyline.arr.length]; System.arraycopy(p_polyline.arr, 0, line_arr, 0, line_arr.length); - for (int i = 0; i < line_arr.length - 4; ++i) - { + for (int i = 0; i < line_arr.length - 4; ++i) { Line new_line = reposition_line(line_arr, i); - if (new_line != null) - { + if (new_line != null) { polyline_changed = true; - line_arr [i + 2] = new_line; + line_arr[i + 2] = new_line; if (line_arr[i + 2].is_parallel(line_arr[i + 1]) || - line_arr[i + 2].is_parallel(line_arr[i + 3])) - { + line_arr[i + 2].is_parallel(line_arr[i + 3])) { // calculation of corners not possible before skipping // parallel lines break; } } } - if (!polyline_changed) - { + if (!polyline_changed) { return p_polyline; } return new Polyline(line_arr); } - + /** * tries to reduce te number of lines of p_polyline by moving * lines parallel beyond the intersection of the next or privious lines. */ - private Polyline reduce_lines(Polyline p_polyline) - { - if (p_polyline.arr.length < 6) - { + private Polyline reduce_lines(Polyline p_polyline) { + if (p_polyline.arr.length < 6) { return p_polyline; } boolean polyline_changed = false; Line[] line_arr = p_polyline.arr; - for (int i = 2; i < line_arr.length - 2; ++i) - { + for (int i = 2; i < line_arr.length - 2; ++i) { FloatPoint prev_corner = - line_arr[i - 2].intersection_approx( line_arr[i - 1]); + line_arr[i - 2].intersection_approx(line_arr[i - 1]); FloatPoint next_corner = - line_arr[i +1 ].intersection_approx( line_arr[i + 2]); + line_arr[i + 1].intersection_approx(line_arr[i + 2]); boolean in_clip_shape = curr_clip_shape == null || curr_clip_shape.contains(prev_corner) && - curr_clip_shape.contains(next_corner); - if (!in_clip_shape) - { + curr_clip_shape.contains(next_corner); + if (!in_clip_shape) { continue; } - Line translate_line = line_arr [i]; + Line translate_line = line_arr[i]; double prev_dist = translate_line.signed_distance(prev_corner); double next_dist = translate_line.signed_distance(next_corner); - if (Signum.of(prev_dist)!= Signum.of(next_dist)) - // the 2 corners are on different sides of the translate_line + if (Signum.of(prev_dist) != Signum.of(next_dist)) + // the 2 corners are on different sides of the translate_line { continue; } double translate_dist; - if (Math.abs(prev_dist) < Math.abs(next_dist)) - { - + if (Math.abs(prev_dist) < Math.abs(next_dist)) { + translate_dist = prev_dist; - } - else - { + } else { translate_dist = next_dist; } - if (translate_dist == 0) - { + if (translate_dist == 0) { //line segment may have length 0 continue; } @@ -399,8 +329,7 @@ private Polyline reduce_lines(Polyline p_polyline) Side new_line_side_of_prev_corner = new_line.side_of(prev_corner); Side new_line_side_of_next_corner = new_line.side_of(next_corner); while (new_line_side_of_prev_corner == line_side && - new_line_side_of_next_corner == line_side) - { + new_line_side_of_next_corner == line_side) { translate_dist += sign * 0.5; new_line = translate_line.translate(-translate_dist); new_line_side_of_prev_corner = new_line.side_of(prev_corner); @@ -408,68 +337,56 @@ private Polyline reduce_lines(Polyline p_polyline) } int crossed_corners_before_count = 0; int crossed_corners_after_count = 0; - if (new_line_side_of_prev_corner != line_side) - { + if (new_line_side_of_prev_corner != line_side) { ++crossed_corners_before_count; } - if (new_line_side_of_next_corner != line_side) - { + if (new_line_side_of_next_corner != line_side) { ++crossed_corners_after_count; } // check, that we havent crossed both corners - if (crossed_corners_before_count > 1 || crossed_corners_after_count > 1) - { + if (crossed_corners_before_count > 1 || crossed_corners_after_count > 1) { continue; } // check, that next_nearest_corner and nearest_corner are on // different sides of new_line; - if (crossed_corners_before_count > 0) - { - if (i < 3) - { + if (crossed_corners_before_count > 0) { + if (i < 3) { continue; } FloatPoint prev_prev_corner = - line_arr[i - 3].intersection_approx( line_arr[i - 2]); - if (new_line.side_of(prev_prev_corner) != line_side) - { + line_arr[i - 3].intersection_approx(line_arr[i - 2]); + if (new_line.side_of(prev_prev_corner) != line_side) { continue; } } - if (crossed_corners_after_count > 0) - { - if (i >= line_arr.length - 3) - { + if (crossed_corners_after_count > 0) { + if (i >= line_arr.length - 3) { continue; } FloatPoint next_next_corner = - line_arr[i + 2 ].intersection_approx( line_arr[i + 3]); - if (new_line.side_of(next_next_corner) != line_side) - { + line_arr[i + 2].intersection_approx(line_arr[i + 3]); + if (new_line.side_of(next_next_corner) != line_side) { continue; } } - Line [] curr_lines = new Line[line_arr.length - + Line[] curr_lines = new Line[line_arr.length - crossed_corners_before_count - crossed_corners_after_count]; int keep_before_ind = i - crossed_corners_before_count; System.arraycopy(line_arr, 0, curr_lines, 0, keep_before_ind); - curr_lines [keep_before_ind] = new_line; + curr_lines[keep_before_ind] = new_line; System.arraycopy(line_arr, i + 1 + crossed_corners_after_count, curr_lines, - keep_before_ind + 1, curr_lines.length - ( keep_before_ind + 1)); - Polyline tmp = new Polyline( curr_lines); + keep_before_ind + 1, curr_lines.length - (keep_before_ind + 1)); + Polyline tmp = new Polyline(curr_lines); boolean check_ok = false; - if (tmp.arr.length == curr_lines.length) - { + if (tmp.arr.length == curr_lines.length) { TileShape shape_to_check = tmp.offset_shape(curr_half_width, keep_before_ind - 1); check_ok = board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins); - + } - if (check_ok) - { - if (board.changed_area != null) - { + if (check_ok) { + if (board.changed_area != null) { board.changed_area.join(prev_corner, curr_layer); board.changed_area.join(next_corner, curr_layer); } @@ -478,67 +395,58 @@ private Polyline reduce_lines(Polyline p_polyline) --i; } } - if (!polyline_changed) - { + if (!polyline_changed) { return p_polyline; } return new Polyline(line_arr); } - - - private Line smoothen_corner(Line[] p_line_arr, int p_start_no) - { - if ( p_line_arr.length - p_start_no < 4) - { + + private Line smoothen_corner(Line[] p_line_arr, int p_start_no) { + if (p_line_arr.length - p_start_no < 4) { return null; } FloatPoint curr_corner = p_line_arr[p_start_no + 1].intersection_approx(p_line_arr[p_start_no + 2]); if (curr_clip_shape != null && - !curr_clip_shape.contains(curr_corner)) - { + !curr_clip_shape.contains(curr_corner)) { return null; } double cosinus_angle = p_line_arr[p_start_no + 1].cos_angle(p_line_arr[p_start_no + 2]); if (cosinus_angle > c_max_cos_angle) - // lines are already nearly parallel, don't divide angle any further - // because of problems with numerical stability + // lines are already nearly parallel, don't divide angle any further + // because of problems with numerical stability { return null; } FloatPoint prev_corner = - p_line_arr[p_start_no].intersection_approx( p_line_arr[p_start_no + 1]); + p_line_arr[p_start_no].intersection_approx(p_line_arr[p_start_no + 1]); FloatPoint next_corner = p_line_arr[p_start_no + 2].intersection_approx(p_line_arr[p_start_no + 3]); - + // create a line approximately through curr_corner, whose // direction is about the middle of the directions of the // previous and the next line. // Translations of this line are used to cut off the corner. - Direction prev_dir = p_line_arr[p_start_no + 1].direction(); - Direction next_dir = p_line_arr[p_start_no + 2].direction(); + Direction prev_dir = p_line_arr[p_start_no + 1].direction(); + Direction next_dir = p_line_arr[p_start_no + 2].direction(); Direction middle_dir = prev_dir.middle_approx(next_dir); Line translate_line = Line.get_instance(curr_corner.round(), middle_dir); double prev_dist = translate_line.signed_distance(prev_corner); double next_dist = translate_line.signed_distance(next_corner); FloatPoint nearest_point; double max_translate_dist; - if (Math.abs(prev_dist) < Math.abs(next_dist)) - { + if (Math.abs(prev_dist) < Math.abs(next_dist)) { nearest_point = prev_corner; max_translate_dist = prev_dist; - } - else - { + } else { nearest_point = next_corner; max_translate_dist = next_dist; } - if (Math.abs(max_translate_dist) < 1) - { + if (Math.abs(max_translate_dist) < 1) { return null; } - Line [] curr_lines = new Line[p_line_arr.length + 1]; + Line[] curr_lines = new Line[p_line_arr.length + 1]; System.arraycopy(p_line_arr, 0, curr_lines, 0, p_start_no + 2); System.arraycopy(p_line_arr, p_start_no + 2, curr_lines, p_start_no + 3, curr_lines.length - p_start_no - 3); @@ -547,43 +455,35 @@ private Line smoothen_corner(Line[] p_line_arr, int p_start_no) Side side_of_nearest_point = translate_line.side_of(nearest_point); int sign = Signum.as_int(max_translate_dist); Line result = null; - while (Math.abs(delta_dist) > this.min_translate_dist) - { + while (Math.abs(delta_dist) > this.min_translate_dist) { boolean check_ok = false; Line new_line = translate_line.translate(-translate_dist); Side new_line_side_of_nearest_point = new_line.side_of(nearest_point); if (new_line_side_of_nearest_point == side_of_nearest_point - || new_line_side_of_nearest_point == Side.COLLINEAR) - { - curr_lines [p_start_no + 2] = new_line; - Polyline tmp = new Polyline( curr_lines); - - if (tmp.arr.length == curr_lines.length) - { + || new_line_side_of_nearest_point == Side.COLLINEAR) { + curr_lines[p_start_no + 2] = new_line; + Polyline tmp = new Polyline(curr_lines); + + if (tmp.arr.length == curr_lines.length) { TileShape shape_to_check = tmp.offset_shape(curr_half_width, p_start_no + 1); check_ok = board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins); } delta_dist /= 2; - if (check_ok) - { + if (check_ok) { result = curr_lines[p_start_no + 2]; - if (translate_dist == max_translate_dist) - { + if (translate_dist == max_translate_dist) { // biggest possible change break; } translate_dist += delta_dist; - } - else - { + } else { translate_dist -= delta_dist; } - } - else - // moved a little bit to far at the first time - // because of numerical inaccuracy + } else + // moved a little bit to far at the first time + // because of numerical inaccuracy { double shorten_value = sign * 0.5; max_translate_dist -= shorten_value; @@ -591,46 +491,40 @@ private Line smoothen_corner(Line[] p_line_arr, int p_start_no) delta_dist -= shorten_value; } } - if (result == null) - { + if (result == null) { return null; } - - if (board.changed_area != null) - { + + if (board.changed_area != null) { FloatPoint new_prev_corner = - curr_lines[p_start_no].intersection_approx( curr_lines[p_start_no + 1]); + curr_lines[p_start_no].intersection_approx(curr_lines[p_start_no + 1]); FloatPoint new_next_corner = - curr_lines[p_start_no + 3].intersection_approx( curr_lines[p_start_no + 4]); + curr_lines[p_start_no + 3].intersection_approx(curr_lines[p_start_no + 4]); board.changed_area.join(new_prev_corner, curr_layer); board.changed_area.join(new_next_corner, curr_layer); } return result; } - - protected Line reposition_line(Line[] p_line_arr, int p_start_no) - { - if ( p_line_arr.length - p_start_no < 5) - { + + protected Line reposition_line(Line[] p_line_arr, int p_start_no) { + if (p_line_arr.length - p_start_no < 5) { return null; } if (curr_clip_shape != null) - // check, that the corners of the line to translate are inside - // the clip shape + // check, that the corners of the line to translate are inside + // the clip shape { - for (int i = 1; i < 3; ++i) - { + for (int i = 1; i < 3; ++i) { FloatPoint curr_corner = p_line_arr[p_start_no + i].intersection_approx(p_line_arr[p_start_no + i + 1]); - if(!curr_clip_shape.contains(curr_corner)) - { + if (!curr_clip_shape.contains(curr_corner)) { return null; } } } Line translate_line = p_line_arr[p_start_no + 2]; FloatPoint prev_corner = - p_line_arr[p_start_no].intersection_approx( p_line_arr[p_start_no + 1]); + p_line_arr[p_start_no].intersection_approx(p_line_arr[p_start_no + 1]); FloatPoint next_corner = p_line_arr[p_start_no + 3].intersection_approx(p_line_arr[p_start_no + 4]); double prev_dist = translate_line.signed_distance(prev_corner); @@ -638,50 +532,47 @@ protected Line reposition_line(Line[] p_line_arr, int p_start_no) int corners_skipped_after = 0; final double c_epsilon = 0.001; while (Math.abs(prev_dist) < c_epsilon) - // move also all lines trough the start corner of the line to translate + // move also all lines trough the start corner of the line to translate { ++corners_skipped_before; int curr_no = p_start_no - corners_skipped_before; if (curr_no < 0) - // the first corner is on the line to translate + // the first corner is on the line to translate { return null; } - prev_corner = p_line_arr[curr_no].intersection_approx( p_line_arr[curr_no + 1]); + prev_corner = p_line_arr[curr_no].intersection_approx(p_line_arr[curr_no + 1]); prev_dist = translate_line.signed_distance(prev_corner); } double next_dist = translate_line.signed_distance(next_corner); while (Math.abs(next_dist) < c_epsilon) - // move also all lines trough the end corner of the line to translate + // move also all lines trough the end corner of the line to translate { ++corners_skipped_after; int curr_no = p_start_no + 3 + corners_skipped_after; if (curr_no >= p_line_arr.length - 2) - // the last corner is on the line to translate + // the last corner is on the line to translate { return null; } - next_corner = p_line_arr[curr_no].intersection_approx( p_line_arr[curr_no + 1]); + next_corner = p_line_arr[curr_no].intersection_approx(p_line_arr[curr_no + 1]); next_dist = translate_line.signed_distance(next_corner); } - if (Signum.of(prev_dist)!= Signum.of(next_dist)) - // the 2 corners are at different sides of translate_line + if (Signum.of(prev_dist) != Signum.of(next_dist)) + // the 2 corners are at different sides of translate_line { return null; } FloatPoint nearest_point; double max_translate_dist; - if (Math.abs(prev_dist) < Math.abs(next_dist)) - { + if (Math.abs(prev_dist) < Math.abs(next_dist)) { nearest_point = prev_corner; max_translate_dist = prev_dist; - } - else - { + } else { nearest_point = next_corner; max_translate_dist = next_dist; } - Line [] curr_lines = new Line[p_line_arr.length]; + Line[] curr_lines = new Line[p_line_arr.length]; System.arraycopy(p_line_arr, 0, curr_lines, 0, p_start_no + 2); System.arraycopy(p_line_arr, p_start_no + 3, curr_lines, p_start_no + 3, curr_lines.length - p_start_no - 3); @@ -691,35 +582,29 @@ protected Line reposition_line(Line[] p_line_arr, int p_start_no) int sign = Signum.as_int(max_translate_dist); Line result = null; boolean first_time = true; - while (first_time || Math.abs(delta_dist) > this.min_translate_dist) - { + while (first_time || Math.abs(delta_dist) > this.min_translate_dist) { boolean check_ok = false; Line new_line = translate_line.translate(-translate_dist); - if (first_time && Math.abs(translate_dist) < 1) - { - if (new_line.equals(translate_line)) - { + if (first_time && Math.abs(translate_dist) < 1) { + if (new_line.equals(translate_line)) { // try the parallel line through the nearest_point IntPoint rounded_nearest_point = nearest_point.round(); if (nearest_point.distance(rounded_nearest_point.to_float()) - < Math.abs(translate_dist)) - { + < Math.abs(translate_dist)) { new_line = Line.get_instance(rounded_nearest_point, translate_line.direction()); } first_time = false; } - if (new_line.equals(translate_line)) - { + if (new_line.equals(translate_line)) { return null; } } Side new_line_side_of_nearest_point = new_line.side_of(nearest_point); if (new_line_side_of_nearest_point == side_of_nearest_point - || new_line_side_of_nearest_point == Side.COLLINEAR) - { + || new_line_side_of_nearest_point == Side.COLLINEAR) { first_time = false; - curr_lines [p_start_no + 2] = new_line; + curr_lines[p_start_no + 2] = new_line; // corners_skipped_before > 0 or corners_skipped_after > 0 // happens very rarely. But this handling seems to be // important because there are situations which no other @@ -727,59 +612,53 @@ protected Line reposition_line(Line[] p_line_arr, int p_start_no) // consecutive corners are equal. Line prev_translated_line = new_line; for (int i = 0; i < corners_skipped_before; ++i) - // Translate the previous lines onto or past the - // intersection of new_line with the first untranslated line. + // Translate the previous lines onto or past the + // intersection of new_line with the first untranslated line. { int prev_line_no = p_start_no + 1 - corners_skipped_before; FloatPoint curr_prev_corner = prev_translated_line.intersection_approx(curr_lines[prev_line_no]); - Line curr_translate_line = p_line_arr [p_start_no + 1 - i]; + Line curr_translate_line = p_line_arr[p_start_no + 1 - i]; double curr_translate_dist = curr_translate_line.signed_distance(curr_prev_corner); prev_translated_line = curr_translate_line.translate(-curr_translate_dist); curr_lines[p_start_no + 1 - i] = prev_translated_line; } prev_translated_line = new_line; for (int i = 0; i < corners_skipped_after; ++i) - // Translate the next lines onto or past the - // intersection of new_line with the first untranslated line. + // Translate the next lines onto or past the + // intersection of new_line with the first untranslated line. { int next_line_no = p_start_no + 3 + corners_skipped_after; FloatPoint curr_next_corner = prev_translated_line.intersection_approx(curr_lines[next_line_no]); - Line curr_translate_line = p_line_arr [p_start_no + 3 + i]; + Line curr_translate_line = p_line_arr[p_start_no + 3 + i]; double curr_translate_dist = curr_translate_line.signed_distance(curr_next_corner); prev_translated_line = curr_translate_line.translate(-curr_translate_dist); curr_lines[p_start_no + 3 + i] = prev_translated_line; } - Polyline tmp = new Polyline( curr_lines); - - if (tmp.arr.length == curr_lines.length) - { + Polyline tmp = new Polyline(curr_lines); + + if (tmp.arr.length == curr_lines.length) { TileShape shape_to_check = tmp.offset_shape(curr_half_width, p_start_no + 1); check_ok = board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins); - + } delta_dist /= 2; - if (check_ok) - { + if (check_ok) { result = curr_lines[p_start_no + 2]; - if (translate_dist == max_translate_dist) - { + if (translate_dist == max_translate_dist) { // biggest possible change break; } translate_dist += delta_dist; - } - else - { + } else { translate_dist -= delta_dist; } - } - else - // moved a little bit to far at the first time - // because of numerical inaccuracy + } else + // moved a little bit to far at the first time + // because of numerical inaccuracy { double shorten_value = sign * 0.5; max_translate_dist -= shorten_value; @@ -787,30 +666,24 @@ protected Line reposition_line(Line[] p_line_arr, int p_start_no) delta_dist -= shorten_value; } } - if (result == null) - { + if (result == null) { return null; } - - if (board.changed_area != null) - { + + if (board.changed_area != null) { FloatPoint new_prev_corner = - curr_lines[p_start_no].intersection_approx( curr_lines[p_start_no + 1]); + curr_lines[p_start_no].intersection_approx(curr_lines[p_start_no + 1]); FloatPoint new_next_corner = - curr_lines[p_start_no + 3].intersection_approx( curr_lines[p_start_no + 4]); + curr_lines[p_start_no + 3].intersection_approx(curr_lines[p_start_no + 4]); board.changed_area.join(new_prev_corner, curr_layer); board.changed_area.join(new_next_corner, curr_layer); } return result; } - - - private Polyline skip_lines(Polyline p_polyline) - { - for (int i = 1; i < p_polyline.arr.length - 3; ++i) - { - for (int j = 0; j <= 1; ++j) - { + + private Polyline skip_lines(Polyline p_polyline) { + for (int i = 1; i < p_polyline.arr.length - 3; ++i) { + for (int j = 0; j <= 1; ++j) { FloatPoint corner1; FloatPoint corner2; Line curr_line; @@ -819,8 +692,7 @@ private Polyline skip_lines(Polyline p_polyline) curr_line = p_polyline.arr[i + 2]; corner1 = p_polyline.corner_approx(i); corner2 = p_polyline.corner_approx(i - 1); - } - else // try to skip the line after i-th line + } else // try to skip the line after i-th line { curr_line = p_polyline.arr[i]; corner1 = p_polyline.corner_approx(i + 1); @@ -828,32 +700,27 @@ private Polyline skip_lines(Polyline p_polyline) } boolean in_clip_shape = curr_clip_shape == null || curr_clip_shape.contains(corner1) && - curr_clip_shape.contains(corner2); - if (!in_clip_shape) - { + curr_clip_shape.contains(corner2); + if (!in_clip_shape) { continue; } - + Side side1 = curr_line.side_of(corner1); Side side2 = curr_line.side_of(corner2); if (side1 != side2) - // the two corners are on different sides of the line + // the two corners are on different sides of the line { Polyline reduced_polyline = p_polyline.skip_lines(i + 1, i + 1); - if (reduced_polyline.arr.length == p_polyline.arr.length - 1) - { + if (reduced_polyline.arr.length == p_polyline.arr.length - 1) { int shape_no = i - 1; - if (j == 0) - { + if (j == 0) { ++shape_no; } TileShape shape_to_check = reduced_polyline.offset_shape(curr_half_width, shape_no); if (board.check_trace_shape(shape_to_check, - curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins)) - { - if (board.changed_area != null) - { + curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins)) { + if (board.changed_area != null) { board.changed_area.join(corner1, curr_layer); board.changed_area.join(corner2, curr_layer); } @@ -862,53 +729,42 @@ private Polyline skip_lines(Polyline p_polyline) } } // now try skipping 2 lines - if (i >= p_polyline.arr.length - 4) - { + if (i >= p_polyline.arr.length - 4) { break; } FloatPoint corner3; - if (j == 1) - { + if (j == 1) { corner3 = p_polyline.corner_approx(i + 3); - } - else - { + } else { corner3 = p_polyline.corner_approx(i + 1); } - if (curr_clip_shape != null && !curr_clip_shape.contains(corner3)) - { + if (curr_clip_shape != null && !curr_clip_shape.contains(corner3)) { continue; } if (j == 0) - // curr_line is 1 line later than in the case skipping 1 line - // when coming from behind + // curr_line is 1 line later than in the case skipping 1 line + // when coming from behind { curr_line = p_polyline.arr[i + 3]; side1 = curr_line.side_of(corner1); side2 = curr_line.side_of(corner2); - } - else - { + } else { side1 = curr_line.side_of(corner3); } if (side1 != side2) - // the two corners are on different sides of the line + // the two corners are on different sides of the line { Polyline reduced_polyline = p_polyline.skip_lines(i + 1, i + 2); - if (reduced_polyline.arr.length == p_polyline.arr.length - 2) - { + if (reduced_polyline.arr.length == p_polyline.arr.length - 2) { int shape_no = i - 1; - if (j == 0) - { + if (j == 0) { ++shape_no; } TileShape shape_to_check = reduced_polyline.offset_shape(curr_half_width, shape_no); if (board.check_trace_shape(shape_to_check, - curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins)) - { - if (board.changed_area != null) - { + curr_layer, curr_net_no_arr, curr_cl_type, this.contact_pins)) { + if (board.changed_area != null) { board.changed_area.join(corner1, curr_layer); board.changed_area.join(corner2, curr_layer); board.changed_area.join(corner3, curr_layer); @@ -917,14 +773,13 @@ private Polyline skip_lines(Polyline p_polyline) } } } - + } } return p_polyline; } - - Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) - { + + Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) { boolean acute_angle = false; boolean bend = false; FloatPoint other_trace_corner_approx = null; @@ -932,20 +787,17 @@ Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) Line other_prev_trace_line = null; Polyline trace_polyline = p_trace.polyline(); Point curr_end_corner = trace_polyline.corner(0); - - if (this.curr_clip_shape != null && this.curr_clip_shape.is_outside(curr_end_corner)) - { + + if (this.curr_clip_shape != null && this.curr_clip_shape.is_outside(curr_end_corner)) { return null; } - + Point curr_prev_end_corner = trace_polyline.corner(1); boolean skip_short_segment = !(curr_end_corner instanceof IntPoint) && curr_end_corner.to_float().distance_square(curr_prev_end_corner.to_float()) < SKIP_LENGTH; int start_line_no = 1; - if (skip_short_segment) - { - if (trace_polyline.corner_count() < 3) - { + if (skip_short_segment) { + if (trace_polyline.corner_count() < 3) { return null; } curr_prev_end_corner = trace_polyline.corner(2); @@ -954,24 +806,19 @@ Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) Side prev_corner_side = null; Direction line_direction = trace_polyline.arr[start_line_no].direction(); Direction prev_line_direction = trace_polyline.arr[start_line_no + 1].direction(); - + java.util.Collection contact_list = p_trace.get_start_contacts(); - for (Item curr_contact : contact_list) - { - if (curr_contact instanceof PolylineTrace && !curr_contact.is_shove_fixed()) - { + for (Item curr_contact : contact_list) { + if (curr_contact instanceof PolylineTrace && !curr_contact.is_shove_fixed()) { Polyline contact_trace_polyline = ((PolylineTrace) curr_contact).polyline(); FloatPoint curr_other_trace_corner_approx; Line curr_other_trace_line; Line curr_other_prev_trace_line; - if (contact_trace_polyline.first_corner().equals(curr_end_corner)) - { + if (contact_trace_polyline.first_corner().equals(curr_end_corner)) { curr_other_trace_corner_approx = contact_trace_polyline.corner_approx(1); curr_other_trace_line = contact_trace_polyline.arr[1]; curr_other_prev_trace_line = contact_trace_polyline.arr[2]; - } - else - { + } else { int curr_corner_no = contact_trace_polyline.corner_count() - 2; curr_other_trace_corner_approx = contact_trace_polyline.corner_approx(curr_corner_no); curr_other_trace_line = contact_trace_polyline.arr[curr_corner_no + 1].opposite(); @@ -980,49 +827,37 @@ Polyline smoothen_start_corner_at_trace(PolylineTrace p_trace) Side curr_prev_corner_side = curr_prev_end_corner.side_of(curr_other_trace_line); Signum curr_projection = line_direction.projection(curr_other_trace_line.direction()); boolean other_trace_found = false; - if (curr_projection == Signum.POSITIVE && curr_prev_corner_side != Side.COLLINEAR) - { + if (curr_projection == Signum.POSITIVE && curr_prev_corner_side != Side.COLLINEAR) { acute_angle = true; other_trace_found = true; - - } - else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) - { - if (prev_line_direction.projection(curr_other_trace_line.direction()) == Signum.POSITIVE) - { + + } else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) { + if (prev_line_direction.projection(curr_other_trace_line.direction()) == Signum.POSITIVE) { bend = true; other_trace_found = true; } } - if (other_trace_found) - { + if (other_trace_found) { other_trace_corner_approx = curr_other_trace_corner_approx; other_trace_line = curr_other_trace_line; prev_corner_side = curr_prev_corner_side; other_prev_trace_line = curr_other_prev_trace_line; } - } - else - { + } else { return null; } } int new_line_count = trace_polyline.arr.length + 1; int diff = 1; - if (skip_short_segment) - { + if (skip_short_segment) { --new_line_count; --diff; } - if (acute_angle) - { + if (acute_angle) { Direction new_line_dir; - if (prev_corner_side == Side.ON_THE_LEFT) - { + if (prev_corner_side == Side.ON_THE_LEFT) { new_line_dir = other_trace_line.direction().turn_45_degree(2); - } - else - { + } else { new_line_dir = other_trace_line.direction().turn_45_degree(6); } Line translate_line = Line.get_instance(curr_end_corner.to_float().round(), new_line_dir); @@ -1031,12 +866,10 @@ else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) double other_dist = Math.abs(translate_line.signed_distance(other_trace_corner_approx)); translate_dist = Math.min(translate_dist, prev_corner_dist); translate_dist = Math.min(translate_dist, other_dist); - if (translate_dist >= 0.99) - { - + if (translate_dist >= 0.99) { + translate_dist = Math.max(translate_dist - 1, 1); - if (translate_line.side_of(curr_prev_end_corner) == Side.ON_THE_LEFT) - { + if (translate_line.side_of(curr_prev_end_corner) == Side.ON_THE_LEFT) { translate_dist = -translate_dist; } Line add_line = translate_line.translate(translate_dist); @@ -1044,40 +877,33 @@ else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) Line[] new_lines = new Line[new_line_count]; new_lines[0] = other_trace_line; new_lines[1] = add_line; - for (int i = 2; i < new_lines.length; ++i) - { + for (int i = 2; i < new_lines.length; ++i) { new_lines[i] = trace_polyline.arr[i - diff]; } return new Polyline(new_lines); } - } - else if (bend) - { + } else if (bend) { Line[] check_line_arr = new Line[new_line_count]; - check_line_arr [0] = other_prev_trace_line; - check_line_arr [1] = other_trace_line; - for (int i = 2; i < check_line_arr.length; ++i) - { - check_line_arr [i] = trace_polyline.arr[i - diff]; + check_line_arr[0] = other_prev_trace_line; + check_line_arr[1] = other_trace_line; + for (int i = 2; i < check_line_arr.length; ++i) { + check_line_arr[i] = trace_polyline.arr[i - diff]; } Line new_line = reposition_line(check_line_arr, 0); - if (new_line != null) - { - Line [] new_lines = new Line[trace_polyline.arr.length]; + if (new_line != null) { + Line[] new_lines = new Line[trace_polyline.arr.length]; new_lines[0] = other_trace_line; new_lines[1] = new_line; - for (int i = 2; i < new_lines.length; ++i) - { - new_lines [i] = trace_polyline.arr[i]; + for (int i = 2; i < new_lines.length; ++i) { + new_lines[i] = trace_polyline.arr[i]; } return new Polyline(new_lines); } } return null; } - - Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) - { + + Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) { boolean acute_angle = false; boolean bend = false; FloatPoint other_trace_corner_approx = null; @@ -1085,20 +911,17 @@ Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) Line other_prev_trace_line = null; Polyline trace_polyline = p_trace.polyline(); Point curr_end_corner = trace_polyline.last_corner(); - - if (this.curr_clip_shape != null && this.curr_clip_shape.is_outside(curr_end_corner)) - { + + if (this.curr_clip_shape != null && this.curr_clip_shape.is_outside(curr_end_corner)) { return null; } - + Point curr_prev_end_corner = trace_polyline.corner(trace_polyline.corner_count() - 2); boolean skip_short_segment = !(curr_end_corner instanceof IntPoint) && curr_end_corner.to_float().distance_square(curr_prev_end_corner.to_float()) < SKIP_LENGTH; int end_line_no = trace_polyline.arr.length - 2; - if (skip_short_segment) - { - if (trace_polyline.corner_count() < 3) - { + if (skip_short_segment) { + if (trace_polyline.corner_count() < 3) { return null; } curr_prev_end_corner = trace_polyline.corner(trace_polyline.corner_count() - 3); @@ -1107,26 +930,20 @@ Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) Side prev_corner_side = null; Direction line_direction = trace_polyline.arr[end_line_no].direction().opposite(); Direction prev_line_direction = trace_polyline.arr[end_line_no].direction().opposite(); - + java.util.Collection contact_list = p_trace.get_end_contacts(); - for (Item curr_contact : contact_list) - { - if (curr_contact instanceof PolylineTrace && !curr_contact.is_shove_fixed()) - { + for (Item curr_contact : contact_list) { + if (curr_contact instanceof PolylineTrace && !curr_contact.is_shove_fixed()) { Polyline contact_trace_polyline = ((PolylineTrace) curr_contact).polyline(); - if (contact_trace_polyline.corner_count() > 2) - { + if (contact_trace_polyline.corner_count() > 2) { FloatPoint curr_other_trace_corner_approx; Line curr_other_trace_line; Line curr_other_prev_trace_line; - if (contact_trace_polyline.first_corner().equals(curr_end_corner)) - { + if (contact_trace_polyline.first_corner().equals(curr_end_corner)) { curr_other_trace_corner_approx = contact_trace_polyline.corner_approx(1); curr_other_trace_line = contact_trace_polyline.arr[1]; curr_other_prev_trace_line = contact_trace_polyline.arr[2]; - } - else - { + } else { int curr_corner_no = contact_trace_polyline.corner_count() - 2; curr_other_trace_corner_approx = contact_trace_polyline.corner_approx(curr_corner_no); curr_other_trace_line = contact_trace_polyline.arr[curr_corner_no + 1].opposite(); @@ -1135,51 +952,39 @@ Polyline smoothen_end_corner_at_trace(PolylineTrace p_trace) Side curr_prev_corner_side = curr_prev_end_corner.side_of(curr_other_trace_line); Signum curr_projection = line_direction.projection(curr_other_trace_line.direction()); boolean other_trace_found = false; - if (curr_projection == Signum.POSITIVE && curr_prev_corner_side != Side.COLLINEAR) - { + if (curr_projection == Signum.POSITIVE && curr_prev_corner_side != Side.COLLINEAR) { acute_angle = true; other_trace_found = true; - } - else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) - { - if (prev_line_direction.projection(curr_other_trace_line.direction()) == Signum.POSITIVE) - { + } else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) { + if (prev_line_direction.projection(curr_other_trace_line.direction()) == Signum.POSITIVE) { bend = true; other_trace_found = true; } } - if (other_trace_found) - { + if (other_trace_found) { other_trace_corner_approx = curr_other_trace_corner_approx; other_trace_line = curr_other_trace_line; prev_corner_side = curr_prev_corner_side; other_prev_trace_line = curr_other_prev_trace_line; } } - } - else - { + } else { return null; } } - + int new_line_count = trace_polyline.arr.length + 1; int diff = 0; - if (skip_short_segment) - { + if (skip_short_segment) { --new_line_count; ++diff; } - - if (acute_angle) - { + + if (acute_angle) { Direction new_line_dir; - if (prev_corner_side == Side.ON_THE_LEFT) - { + if (prev_corner_side == Side.ON_THE_LEFT) { new_line_dir = other_trace_line.direction().turn_45_degree(6); - } - else - { + } else { new_line_dir = other_trace_line.direction().turn_45_degree(2); } Line translate_line = Line.get_instance(curr_end_corner.to_float().round(), new_line_dir); @@ -1188,41 +993,33 @@ else if (curr_projection == Signum.ZERO && trace_polyline.corner_count() > 2) double other_dist = Math.abs(translate_line.signed_distance(other_trace_corner_approx)); translate_dist = Math.min(translate_dist, prev_corner_dist); translate_dist = Math.min(translate_dist, other_dist); - if (translate_dist >= 0.99) - { - + if (translate_dist >= 0.99) { + translate_dist = Math.max(translate_dist - 1, 1); - if (translate_line.side_of(curr_prev_end_corner) == Side.ON_THE_LEFT) - { + if (translate_line.side_of(curr_prev_end_corner) == Side.ON_THE_LEFT) { translate_dist = -translate_dist; } Line add_line = translate_line.translate(translate_dist); // constract the new trace polyline. Line[] new_lines = new Line[new_line_count]; - for (int i = 0; i < trace_polyline.arr.length - 1; ++i) - { + for (int i = 0; i < trace_polyline.arr.length - 1; ++i) { new_lines[i] = trace_polyline.arr[i]; } new_lines[new_lines.length - 2] = add_line; new_lines[new_lines.length - 1] = other_trace_line; return new Polyline(new_lines); } - } - else if (bend) - { + } else if (bend) { Line[] check_line_arr = new Line[new_line_count]; - for (int i = 0; i < check_line_arr.length - 2; ++i) - { + for (int i = 0; i < check_line_arr.length - 2; ++i) { check_line_arr[i] = trace_polyline.arr[i + diff]; } check_line_arr[check_line_arr.length - 2] = other_trace_line; check_line_arr[check_line_arr.length - 1] = other_prev_trace_line; Line new_line = reposition_line(check_line_arr, check_line_arr.length - 5); - if (new_line != null) - { - Line [] new_lines = new Line[trace_polyline.arr.length]; - for (int i = 0; i < new_lines.length - 2; ++i) - { + if (new_line != null) { + Line[] new_lines = new Line[trace_polyline.arr.length]; + for (int i = 0; i < new_lines.length - 2; ++i) { new_lines[i] = trace_polyline.arr[i]; } new_lines[new_lines.length - 2] = new_line; @@ -1232,7 +1029,4 @@ else if (bend) } return null; } - - - private static double SKIP_LENGTH = 10.0; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/board/RoutingBoard.java b/src/main/java/net/freerouting/board/RoutingBoard.java index e583e487..085e3221 100644 --- a/src/main/java/net/freerouting/board/RoutingBoard.java +++ b/src/main/java/net/freerouting/board/RoutingBoard.java @@ -15,44 +15,42 @@ */ package net.freerouting.board; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.IntOctagon; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.LineSegment; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.PolylineShape; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Vector; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import net.freerouting.datastructures.UndoableObjects; +import net.freerouting.autoroute.AutorouteControl; +import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; +import net.freerouting.autoroute.AutorouteEngine; +import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; +import net.freerouting.datastructures.ShapeTree.TreeEntry; import net.freerouting.datastructures.Stoppable; import net.freerouting.datastructures.TimeLimit; -import net.freerouting.datastructures.ShapeTree.TreeEntry; - -import net.freerouting.rules.ViaInfo; +import net.freerouting.datastructures.UndoableObjects; +import net.freerouting.geometry.planar.*; +import net.freerouting.geometry.planar.Vector; import net.freerouting.rules.BoardRules; +import net.freerouting.rules.ViaInfo; -import net.freerouting.autoroute.AutorouteControl; -import net.freerouting.autoroute.AutorouteEngine; -import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; -import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; +import java.util.*; /** - * * Contains higher level functions of a board * * @author Alfons Wirtz */ -public class RoutingBoard extends BasicBoard implements java.io.Serializable -{ +public class RoutingBoard extends BasicBoard implements java.io.Serializable { + + /** + * The time limit in milliseconds for the pull tight algorithm + */ + private static final int PULL_TIGHT_TIME_LIMIT = 2000; + /** + * the area marked for optimizing the route + */ + transient ChangedArea changed_area; + /** + * Contains the database for the autorouzte algorithm. + */ + private transient AutorouteEngine autoroute_engine = null; + private transient Item shove_failing_obstacle = null; + private transient int shove_failing_layer = -1; /** * Creates a new instance of a routing Board with surrrounding box @@ -61,8 +59,7 @@ public class RoutingBoard extends BasicBoard implements java.io.Serializable * Among other things it may contain a clearance matrix. */ public RoutingBoard(IntBox p_bounding_box, LayerStructure p_layer_structure, PolylineShape[] p_outline_shapes, - int p_outline_cl_class_no, BoardRules p_rules, Communication p_board_communication, TestLevel p_test_level) - { + int p_outline_cl_class_no, BoardRules p_rules, Communication p_board_communication, TestLevel p_test_level) { super(p_bounding_box, p_layer_structure, p_outline_shapes, p_outline_cl_class_no, p_rules, p_board_communication, p_test_level); } @@ -70,29 +67,23 @@ public RoutingBoard(IntBox p_bounding_box, LayerStructure p_layer_structure, Pol /** * Maintains the autorouter database after p_item is inserted, changed, or deleted. */ - public void additional_update_after_change(Item p_item) - { - if (p_item == null) - { + public void additional_update_after_change(Item p_item) { + if (p_item == null) { return; } - if (this.autoroute_engine == null || !this.autoroute_engine.maintain_database) - { + if (this.autoroute_engine == null || !this.autoroute_engine.maintain_database) { return; } // Invalidate the free space expansion rooms touching a shape of p_item. int shape_count = p_item.tree_shape_count(this.autoroute_engine.autoroute_search_tree); - for (int i = 0; i < shape_count; ++i) - { + for (int i = 0; i < shape_count; ++i) { TileShape curr_shape = p_item.get_tree_shape(this.autoroute_engine.autoroute_search_tree, i); this.autoroute_engine.invalidate_drill_pages(curr_shape); int curr_layer = p_item.shape_layer(i); Collection overlaps = this.autoroute_engine.autoroute_search_tree.overlapping_objects(curr_shape, curr_layer); - for (SearchTreeObject curr_object : overlaps) - { - if (curr_object instanceof CompleteFreeSpaceExpansionRoom) - { + for (SearchTreeObject curr_object : overlaps) { + if (curr_object instanceof CompleteFreeSpaceExpansionRoom) { this.autoroute_engine.remove_complete_expansion_room((CompleteFreeSpaceExpansionRoom) curr_object); } } @@ -105,55 +96,42 @@ public void additional_update_after_change(Item p_item) * Returns false, if some items could not be removed, because they were fixed. */ public boolean remove_items_and_pull_tight(Collection p_item_list, int p_tidy_width, - int p_pull_tight_accuracy, boolean p_with_delete_fixed) - { + int p_pull_tight_accuracy, boolean p_with_delete_fixed) { boolean result = true; IntOctagon tidy_region; boolean calculate_tidy_region; - if (p_tidy_width < Integer.MAX_VALUE) - { + if (p_tidy_width < Integer.MAX_VALUE) { tidy_region = IntOctagon.EMPTY; calculate_tidy_region = (p_tidy_width > 0); - } - else - { + } else { tidy_region = null; calculate_tidy_region = false; } start_marking_changed_area(); Set changed_nets = new TreeSet(); Iterator it = p_item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (!p_with_delete_fixed && curr_item.is_delete_fixed() || curr_item.is_user_fixed()) - { + if (!p_with_delete_fixed && curr_item.is_delete_fixed() || curr_item.is_user_fixed()) { result = false; - } - else - { - for (int i = 0; i < curr_item.tile_shape_count(); ++i) - { + } else { + for (int i = 0; i < curr_item.tile_shape_count(); ++i) { TileShape curr_shape = curr_item.get_tile_shape(i); changed_area.join(curr_shape, curr_item.shape_layer(i)); - if (calculate_tidy_region) - { + if (calculate_tidy_region) { tidy_region = tidy_region.union(curr_shape.bounding_octagon()); } } remove_item(curr_item); - for (int i = 0; i < curr_item.net_count(); ++i) - { + for (int i = 0; i < curr_item.net_count(); ++i) { changed_nets.add(curr_item.get_net_no(i)); } } } - for (Integer curr_net_no : changed_nets) - { + for (Integer curr_net_no : changed_nets) { this.combine_traces(curr_net_no); } - if (calculate_tidy_region) - { + if (calculate_tidy_region) { tidy_region = tidy_region.enlarge(p_tidy_width); } opt_changed_area(new int[0], tidy_region, p_pull_tight_accuracy, null, null, PULL_TIGHT_TIME_LIMIT); @@ -163,10 +141,8 @@ public boolean remove_items_and_pull_tight(Collection p_item_list, int p_t /** * starts marking the changed areas for optimizing traces */ - public void start_marking_changed_area() - { - if (changed_area == null) - { + public void start_marking_changed_area() { + if (changed_area == null) { changed_area = new ChangedArea(get_layer_count()); } } @@ -174,10 +150,8 @@ public void start_marking_changed_area() /** * enlarges the changed area on p_layer, so that it contains p_point */ - public void join_changed_area(FloatPoint p_point, int p_layer) - { - if (changed_area != null) - { + public void join_changed_area(FloatPoint p_point, int p_layer) { + if (changed_area != null) { changed_area.join(p_point, p_layer); } } @@ -185,18 +159,15 @@ public void join_changed_area(FloatPoint p_point, int p_layer) /** * marks the whole board as changed */ - public void mark_all_changed_area() - { + public void mark_all_changed_area() { start_marking_changed_area(); FloatPoint[] board_corners = new FloatPoint[4]; board_corners[0] = bounding_box.ll.to_float(); board_corners[1] = new FloatPoint(bounding_box.ur.x, bounding_box.ll.y); board_corners[2] = bounding_box.ur.to_float(); board_corners[3] = new FloatPoint(bounding_box.ll.x, bounding_box.ur.y); - for (int i = 0; i < get_layer_count(); ++i) - { - for (int j = 0; j < 4; ++j) - { + for (int i = 0; i < get_layer_count(); ++i) { + for (int j = 0; j < 4; ++j) { join_changed_area(board_corners[j], i); } } @@ -211,8 +182,7 @@ public void mark_all_changed_area() * If p_time_limit > 0; the algorithm will be stopped after p_time_limit Milliseconds. */ public void opt_changed_area(int[] p_only_net_no_arr, IntOctagon p_clip_shape, int p_accuracy, ExpansionCostFactor[] p_trace_cost_arr, - Stoppable p_stoppable_thread, int p_time_limit) - { + Stoppable p_stoppable_thread, int p_time_limit) { opt_changed_area(p_only_net_no_arr, p_clip_shape, p_accuracy, p_trace_cost_arr, p_stoppable_thread, p_time_limit, null, 0); } @@ -225,20 +195,17 @@ public void opt_changed_area(int[] p_only_net_no_arr, IntOctagon p_clip_shape, i * If p_stoppable_thread != null, the agorithm can be requested to be stopped. * If p_time_limit > 0; the algorithm will be stopped after p_time_limit Milliseconds. * If p_keep_point != null, traces on layer p_keep_point_layer containing p_keep_point - * will also contain this point after optimizing. + * will also contain this point after optimizing. */ public void opt_changed_area(int[] p_only_net_no_arr, IntOctagon p_clip_shape, int p_accuracy, ExpansionCostFactor[] p_trace_cost_arr, - Stoppable p_stoppable_thread, int p_time_limit, Point p_keep_point, int p_keep_point_layer) - { - if (changed_area == null) - { + Stoppable p_stoppable_thread, int p_time_limit, Point p_keep_point, int p_keep_point_layer) { + if (changed_area == null) { return; } - if (p_clip_shape != IntOctagon.EMPTY) - { + if (p_clip_shape != IntOctagon.EMPTY) { PullTightAlgo pull_tight_algo = PullTightAlgo.get_instance(this, p_only_net_no_arr, p_clip_shape, - p_accuracy, p_stoppable_thread, p_time_limit, p_keep_point, p_keep_point_layer); + p_accuracy, p_stoppable_thread, p_time_limit, p_keep_point, p_keep_point_layer); pull_tight_algo.opt_changed_area(p_trace_cost_arr); } join_graphics_update_box(changed_area.surrounding_box()); @@ -249,14 +216,12 @@ public void opt_changed_area(int[] p_only_net_no_arr, IntOctagon p_clip_shape, i * Checks if a rectangular boxed trace line segment with the input parameters can * be inserted without conflict. If a conflict exists, * The result length is the maximal line length from p_line.a to p_line.b, - * which can be inserted without conflict (Integer.MAX_VALUE, if no conflict exists). + * which can be inserted without conflict (Integer.MAX_VALUE, if no conflict exists). * If p_only_not_shovable_obstacles, unfixed traces and vias are ignored. */ public double check_trace_segment(Point p_from_point, Point p_to_point, int p_layer, int[] p_net_no_arr, - int p_trace_half_width, int p_cl_class_no, boolean p_only_not_shovable_obstacles) - { - if (p_from_point.equals(p_to_point)) - { + int p_trace_half_width, int p_cl_class_no, boolean p_only_not_shovable_obstacles) { + if (p_from_point.equals(p_to_point)) { return 0; } Polyline curr_polyline = new Polyline(p_from_point, p_to_point); @@ -269,15 +234,13 @@ public double check_trace_segment(Point p_from_point, Point p_to_point, int p_la * Checks if a trace shape around the input parameters can * be inserted without conflict. If a conflict exists, * The result length is the maximal line length from p_line.a to p_line.b, - * which can be inserted without conflict (Integer.MAX_VALUE, if no conflict exists). + * which can be inserted without conflict (Integer.MAX_VALUE, if no conflict exists). * If p_only_not_shovable_obstacles, unfixed traces and vias are ignored. */ public double check_trace_segment(LineSegment p_line_segment, int p_layer, int[] p_net_no_arr, - int p_trace_half_width, int p_cl_class_no, boolean p_only_not_shovable_obstacles) - { + int p_trace_half_width, int p_cl_class_no, boolean p_only_not_shovable_obstacles) { Polyline check_polyline = p_line_segment.to_polyline(); - if (check_polyline.arr.length != 3) - { + if (check_polyline.arr.length != 3) { return 0; } TileShape shape_to_check = check_polyline.offset_shape(p_trace_half_width, 0); @@ -289,36 +252,29 @@ public double check_trace_segment(LineSegment p_line_segment, int p_layer, int[] Collection obstacle_entries = default_tree.overlapping_tree_entries_with_clearance(shape_to_check, p_layer, p_net_no_arr, p_cl_class_no); - for (TreeEntry curr_obstacle_entry : obstacle_entries) - { + for (TreeEntry curr_obstacle_entry : obstacle_entries) { - if (!(curr_obstacle_entry.object instanceof Item)) - { + if (!(curr_obstacle_entry.object instanceof Item)) { continue; } Item curr_obstacle = (Item) curr_obstacle_entry.object; - if (p_only_not_shovable_obstacles && curr_obstacle.is_route() && !curr_obstacle.is_shove_fixed()) - { + if (p_only_not_shovable_obstacles && curr_obstacle.is_route() && !curr_obstacle.is_shove_fixed()) { continue; } TileShape curr_obstacle_shape = curr_obstacle_entry.object.get_tree_shape(default_tree, curr_obstacle_entry.shape_index_in_object); TileShape curr_offset_shape; FloatPoint nearest_obstacle_point; double shorten_value; - if (default_tree.is_clearance_compensation_used()) - { + if (default_tree.is_clearance_compensation_used()) { curr_offset_shape = shape_to_check; shorten_value = p_trace_half_width + rules.clearance_matrix.clearance_compensation_value(curr_obstacle.clearance_class_no(), p_layer); - } - else - { + } else { int clearance_value = this.clearance_value(curr_obstacle.clearance_class_no(), p_cl_class_no, p_layer); curr_offset_shape = (TileShape) shape_to_check.offset(clearance_value); shorten_value = p_trace_half_width + clearance_value; } TileShape intersection = curr_obstacle_shape.intersection(curr_offset_shape); - if (intersection.is_empty()) - { + if (intersection.is_empty()) { continue; } nearest_obstacle_point = intersection.nearest_point_approx(from_point); @@ -327,11 +283,9 @@ public double check_trace_segment(LineSegment p_line_segment, int p_layer, int[] projection = Math.max(0.0, projection - shorten_value - 1); - if (projection < ok_length) - { + if (projection < ok_length) { ok_length = projection; - if (ok_length <= 0) - { + if (ok_length <= 0) { return 0; } } @@ -344,53 +298,39 @@ public double check_trace_segment(LineSegment p_line_segment, int p_layer, int[] * Checks, if p_item can be translated by p_vector without * producing overlaps or clearance violations. */ - public boolean check_move_item(Item p_item, Vector p_vector, Collection p_ignore_items) - { + public boolean check_move_item(Item p_item, Vector p_vector, Collection p_ignore_items) { int net_count = p_item.net_no_arr.length; - if (net_count > 1) - { + if (net_count > 1) { return false; //not yet implemented } int contact_count = 0; // the connected items must remain connected after moving - if (p_item instanceof Connectable) - { + if (p_item instanceof Connectable) { contact_count = p_item.get_all_contacts().size(); } - if (p_item instanceof Trace && contact_count > 0) - { + if (p_item instanceof Trace && contact_count > 0) { return false; } - if (p_ignore_items != null) - { + if (p_ignore_items != null) { p_ignore_items.add(p_item); } - for (int i = 0; i < p_item.tile_shape_count(); ++i) - { + for (int i = 0; i < p_item.tile_shape_count(); ++i) { TileShape moved_shape = (TileShape) p_item.get_tile_shape(i).translate_by(p_vector); - if (!moved_shape.is_contained_in(bounding_box)) - { + if (!moved_shape.is_contained_in(bounding_box)) { return false; } Set obstacles = this.overlapping_items_with_clearance(moved_shape, p_item.shape_layer(i), p_item.net_no_arr, - p_item.clearance_class_no()); - for (Item curr_item : obstacles) - { - if (p_ignore_items != null) - { - if (!p_ignore_items.contains(curr_item)) - { - if (curr_item.is_obstacle(p_item)) - { + p_item.clearance_class_no()); + for (Item curr_item : obstacles) { + if (p_ignore_items != null) { + if (!p_ignore_items.contains(curr_item)) { + if (curr_item.is_obstacle(p_item)) { return false; } } - } - else if (curr_item != p_item) - { - if (curr_item.is_obstacle(p_item)) - { + } else if (curr_item != p_item) { + if (curr_item.is_obstacle(p_item)) { return false; } } @@ -402,20 +342,16 @@ else if (curr_item != p_item) /** * Checks, if the net number of p_item can be changed without producing clearance violations. */ - public boolean check_change_net(Item p_item, int p_new_net_no) - { + public boolean check_change_net(Item p_item, int p_new_net_no) { int[] net_no_arr = new int[1]; net_no_arr[0] = p_new_net_no; - for (int i = 0; i < p_item.tile_shape_count(); ++i) - { + for (int i = 0; i < p_item.tile_shape_count(); ++i) { TileShape curr_shape = p_item.get_tile_shape(i); Set obstacles = this.overlapping_items_with_clearance(curr_shape, p_item.shape_layer(i), - net_no_arr, p_item.clearance_class_no()); - for (SearchTreeObject curr_ob : obstacles) - { - if (curr_ob != p_item && curr_ob instanceof Connectable && !((Connectable) curr_ob).contains_net(p_new_net_no)) - { + net_no_arr, p_item.clearance_class_no()); + for (SearchTreeObject curr_ob : obstacles) { + if (curr_ob != p_item && curr_ob instanceof Connectable && !((Connectable) curr_ob).contains_net(p_new_net_no)) { return false; } } @@ -430,52 +366,41 @@ public boolean check_change_net(Item p_item, int p_new_net_no) * becomes necessesary. */ public boolean move_drill_item(DrillItem p_drill_item, Vector p_vector, - int p_max_recursion_depth, int p_max_via_recursion_depth, - int p_tidy_width, int p_pull_tight_accuracy, int p_pull_tight_time_limit) - { + int p_max_recursion_depth, int p_max_via_recursion_depth, + int p_tidy_width, int p_pull_tight_accuracy, int p_pull_tight_time_limit) { clear_shove_failing_obstacle(); // unfix the connected shove fixed traces. Collection contact_list = p_drill_item.get_normal_contacts(); Iterator it = contact_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_contact = it.next(); - if (curr_contact.get_fixed_state() == FixedState.SHOVE_FIXED) - { + if (curr_contact.get_fixed_state() == FixedState.SHOVE_FIXED) { curr_contact.set_fixed_state(FixedState.UNFIXED); } } IntOctagon tidy_region; boolean calculate_tidy_region; - if (p_tidy_width < Integer.MAX_VALUE) - { + if (p_tidy_width < Integer.MAX_VALUE) { tidy_region = IntOctagon.EMPTY; calculate_tidy_region = (p_tidy_width > 0); - } - else - { + } else { tidy_region = null; calculate_tidy_region = false; } int[] net_no_arr = p_drill_item.net_no_arr; start_marking_changed_area(); if (!MoveDrillItemAlgo.insert(p_drill_item, p_vector, - p_max_recursion_depth, p_max_via_recursion_depth, tidy_region, this)) - { + p_max_recursion_depth, p_max_via_recursion_depth, tidy_region, this)) { return false; } - if (calculate_tidy_region) - { + if (calculate_tidy_region) { tidy_region = tidy_region.enlarge(p_tidy_width); } int[] opt_net_no_arr; - if (p_max_recursion_depth <= 0) - { + if (p_max_recursion_depth <= 0) { opt_net_no_arr = net_no_arr; - } - else - { + } else { opt_net_no_arr = new int[0]; } opt_changed_area(opt_net_no_arr, tidy_region, p_pull_tight_accuracy, null, null, p_pull_tight_time_limit); @@ -490,8 +415,7 @@ public boolean move_drill_item(DrillItem p_drill_item, Vector p_vector, * Returns null, if no item is found, * If p_layer < 0, the layer is ignored */ - public Item pick_nearest_routing_item(Point p_location, int p_layer, Item p_from_item) - { + public Item pick_nearest_routing_item(Point p_location, int p_layer, Item p_from_item) { TileShape point_shape = TileShape.get_instance(p_location); Collection found_items = overlapping_items(point_shape, p_layer); FloatPoint pick_location = p_location.to_float(); @@ -499,65 +423,48 @@ public Item pick_nearest_routing_item(Point p_location, int p_layer, Item p_from Item nearest_item = null; Set ignore_set = null; Iterator it = found_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (!curr_item.is_connectable()) - { + if (!curr_item.is_connectable()) { continue; } boolean candidate_found = false; double curr_dist = 0; - if (curr_item instanceof PolylineTrace) - { + if (curr_item instanceof PolylineTrace) { PolylineTrace curr_trace = (PolylineTrace) curr_item; - if (p_layer < 0 || curr_trace.get_layer() == p_layer) - { - if (nearest_item instanceof DrillItem) - { + if (p_layer < 0 || curr_trace.get_layer() == p_layer) { + if (nearest_item instanceof DrillItem) { continue; // prefer drill items } int trace_radius = curr_trace.get_half_width(); curr_dist = curr_trace.polyline().distance(pick_location); - if (curr_dist < min_dist && curr_dist <= trace_radius) - { + if (curr_dist < min_dist && curr_dist <= trace_radius) { candidate_found = true; } } - } - else if (curr_item instanceof DrillItem) - { + } else if (curr_item instanceof DrillItem) { DrillItem curr_drill_item = (DrillItem) curr_item; - if (p_layer < 0 || curr_drill_item.is_on_layer(p_layer)) - { + if (p_layer < 0 || curr_drill_item.is_on_layer(p_layer)) { FloatPoint drill_item_center = curr_drill_item.get_center().to_float(); curr_dist = drill_item_center.distance(pick_location); - if (curr_dist < min_dist || nearest_item instanceof Trace) - { + if (curr_dist < min_dist || nearest_item instanceof Trace) { candidate_found = true; } } - } - else if (curr_item instanceof ConductionArea) - { + } else if (curr_item instanceof ConductionArea) { ConductionArea curr_area = (ConductionArea) curr_item; - if ((p_layer < 0 || curr_area.get_layer() == p_layer) && nearest_item == null) - { + if ((p_layer < 0 || curr_area.get_layer() == p_layer) && nearest_item == null) { candidate_found = true; curr_dist = Integer.MAX_VALUE; } } - if (candidate_found) - { - if (p_from_item != null) - { - if (ignore_set == null) - { + if (candidate_found) { + if (p_from_item != null) { + if (ignore_set == null) { // calculated here to avoid unnessery calculations for performance reasoss. ignore_set = p_from_item.get_connected_set(-1); } - if (ignore_set.contains(curr_item)) - { + if (ignore_set.contains(curr_item)) { continue; } } @@ -574,33 +481,25 @@ else if (curr_item instanceof ConductionArea) * becomes necessesary. Returns false, if the forced via failed. */ public boolean forced_via(ViaInfo p_via_info, Point p_location, int[] p_net_no_arr, - int p_trace_clearance_class_no, int[] p_trace_pen_halfwidth_arr, - int p_max_recursion_depth, int p_max_via_recursion_depth, - int p_tidy_width, int p_pull_tight_accuracy, int p_pull_tight_time_limit) - { + int p_trace_clearance_class_no, int[] p_trace_pen_halfwidth_arr, + int p_max_recursion_depth, int p_max_via_recursion_depth, + int p_tidy_width, int p_pull_tight_accuracy, int p_pull_tight_time_limit) { clear_shove_failing_obstacle(); this.start_marking_changed_area(); boolean result = ForcedViaAlgo.insert(p_via_info, p_location, p_net_no_arr, p_trace_clearance_class_no, p_trace_pen_halfwidth_arr, p_max_recursion_depth, p_max_via_recursion_depth, this); - if (result) - { + if (result) { IntOctagon tidy_clip_shape; - if (p_tidy_width < Integer.MAX_VALUE) - { + if (p_tidy_width < Integer.MAX_VALUE) { tidy_clip_shape = p_location.surrounding_octagon().enlarge(p_tidy_width); - } - else - { + } else { tidy_clip_shape = null; } int[] opt_net_no_arr; - if (p_max_recursion_depth <= 0) - { + if (p_max_recursion_depth <= 0) { opt_net_no_arr = p_net_no_arr; - } - else - { + } else { opt_net_no_arr = new int[0]; } this.opt_changed_area(opt_net_no_arr, tidy_clip_shape, @@ -619,13 +518,11 @@ public boolean forced_via(ViaInfo p_via_info, Point p_location, int[] p_net_no_a * p_search_tree is the shape search tree used in the algorithm. */ public Point insert_forced_trace_segment(Point p_from_corner, - Point p_to_corner, int p_half_width, int p_layer, int[] p_net_no_arr, - int p_clearance_class_no, int p_max_recursion_depth, int p_max_via_recursion_depth, - int p_max_spring_over_recursion_depth, int p_tidy_width, - int p_pull_tight_accuracy, boolean p_with_check, TimeLimit p_time_limit) - { - if (p_from_corner.equals(p_to_corner)) - { + Point p_to_corner, int p_half_width, int p_layer, int[] p_net_no_arr, + int p_clearance_class_no, int p_max_recursion_depth, int p_max_via_recursion_depth, + int p_max_spring_over_recursion_depth, int p_tidy_width, + int p_pull_tight_accuracy, boolean p_with_check, TimeLimit p_time_limit) { + if (p_from_corner.equals(p_to_corner)) { return p_to_corner; } Polyline insert_polyline = new Polyline(p_from_corner, p_to_corner); @@ -634,16 +531,11 @@ public Point insert_forced_trace_segment(Point p_from_corner, p_max_spring_over_recursion_depth, p_tidy_width, p_pull_tight_accuracy, p_with_check, p_time_limit); Point result; - if (ok_point == insert_polyline.first_corner()) - { + if (ok_point == insert_polyline.first_corner()) { result = p_from_corner; - } - else if (ok_point == insert_polyline.last_corner()) - { + } else if (ok_point == insert_polyline.last_corner()) { result = p_to_corner; - } - else - { + } else { result = ok_point; } return result; @@ -654,20 +546,17 @@ else if (ok_point == insert_polyline.last_corner()) * while shoving aside obstacle traces and vias. */ public boolean check_forced_trace_polyline(Polyline p_polyline, int p_half_width, int p_layer, int[] p_net_no_arr, - int p_clearance_class_no, int p_max_recursion_depth, int p_max_via_recursion_depth, - int p_max_spring_over_recursion_depth) - { + int p_clearance_class_no, int p_max_recursion_depth, int p_max_via_recursion_depth, + int p_max_spring_over_recursion_depth) { ShapeSearchTree search_tree = search_tree_manager.get_default_tree(); int compensated_half_width = p_half_width + search_tree.clearance_compensation_value(p_clearance_class_no, p_layer); TileShape[] trace_shapes = p_polyline.offset_shapes(compensated_half_width, 0, p_polyline.arr.length - 1); boolean orthogonal_mode = (rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE); ShoveTraceAlgo shove_trace_algo = new ShoveTraceAlgo(this); - for (int i = 0; i < trace_shapes.length; ++i) - { + for (int i = 0; i < trace_shapes.length; ++i) { TileShape curr_trace_shape = trace_shapes[i]; - if (orthogonal_mode) - { + if (orthogonal_mode) { curr_trace_shape = curr_trace_shape.bounding_box(); } CalcFromSide from_side = new CalcFromSide(p_polyline, i + 1, curr_trace_shape); @@ -675,8 +564,7 @@ public boolean check_forced_trace_polyline(Polyline p_polyline, int p_half_width boolean check_shove_ok = shove_trace_algo.check(curr_trace_shape, from_side, null, p_layer, p_net_no_arr, p_clearance_class_no, p_max_recursion_depth, p_max_via_recursion_depth, p_max_spring_over_recursion_depth, null); - if (!check_shove_ok) - { + if (!check_shove_ok) { return false; } } @@ -691,19 +579,16 @@ public boolean check_forced_trace_polyline(Polyline p_polyline, int p_half_width * inserting, so that the database may be damaged and an undo necessary. */ public Point insert_forced_trace_polyline(Polyline p_polyline, int p_half_width, int p_layer, int[] p_net_no_arr, - int p_clearance_class_no, int p_max_recursion_depth, int p_max_via_recursion_depth, - int p_max_spring_over_recursion_depth, int p_tidy_width, - int p_pull_tight_accuracy, boolean p_with_check, TimeLimit p_time_limit) - { + int p_clearance_class_no, int p_max_recursion_depth, int p_max_via_recursion_depth, + int p_max_spring_over_recursion_depth, int p_tidy_width, + int p_pull_tight_accuracy, boolean p_with_check, TimeLimit p_time_limit) { clear_shove_failing_obstacle(); Point from_corner = p_polyline.first_corner(); Point to_corner = p_polyline.last_corner(); - if (from_corner.equals(to_corner)) - { + if (from_corner.equals(to_corner)) { return to_corner; } - if (!(from_corner instanceof IntPoint && to_corner instanceof IntPoint)) - { + if (!(from_corner instanceof IntPoint && to_corner instanceof IntPoint)) { System.out.println("RoutingBoard.insert_forced_trace_segment: only implemented for IntPoints"); return from_corner; } @@ -713,11 +598,9 @@ public Point insert_forced_trace_polyline(Polyline p_polyline, int p_half_width, Trace picked_trace = null; ItemSelectionFilter filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.TRACES); Set picked_items = this.pick_items(from_corner, p_layer, filter); - if (picked_items.size() == 1) - { + if (picked_items.size() == 1) { Trace curr_picked_trace = (Trace) picked_items.iterator().next(); - if (curr_picked_trace.nets_equal(p_net_no_arr) && curr_picked_trace.get_half_width() == p_half_width && curr_picked_trace.clearance_class_no() == p_clearance_class_no && (curr_picked_trace instanceof PolylineTrace)) - { + if (curr_picked_trace.nets_equal(p_net_no_arr) && curr_picked_trace.get_half_width() == p_half_width && curr_picked_trace.clearance_class_no() == p_clearance_class_no && (curr_picked_trace instanceof PolylineTrace)) { // can combine with the picked trace picked_trace = curr_picked_trace; } @@ -727,22 +610,17 @@ public Point insert_forced_trace_polyline(Polyline p_polyline, int p_half_width, ShoveTraceAlgo shove_trace_algo = new ShoveTraceAlgo(this); Polyline new_polyline = shove_trace_algo.spring_over_obstacles(p_polyline, compensated_half_width, p_layer, p_net_no_arr, p_clearance_class_no, null); - if (new_polyline == null) - { + if (new_polyline == null) { return from_corner; } Polyline combined_polyline; - if (picked_trace == null) - { + if (picked_trace == null) { combined_polyline = new_polyline; - } - else - { + } else { PolylineTrace combine_trace = (PolylineTrace) picked_trace; combined_polyline = new_polyline.combine(combine_trace.polyline()); } - if (combined_polyline.arr.length < 3) - { + if (combined_polyline.arr.length < 3) { return from_corner; } int start_shape_no = combined_polyline.arr.length - new_polyline.arr.length; @@ -751,22 +629,18 @@ public Point insert_forced_trace_polyline(Polyline p_polyline, int p_half_width, start_shape_no, combined_polyline.arr.length - 1); int last_shape_no = trace_shapes.length; boolean orthogonal_mode = (rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE); - for (int i = 0; i < trace_shapes.length; ++i) - { + for (int i = 0; i < trace_shapes.length; ++i) { TileShape curr_trace_shape = trace_shapes[i]; - if (orthogonal_mode) - { + if (orthogonal_mode) { curr_trace_shape = curr_trace_shape.bounding_box(); } CalcFromSide from_side = new CalcFromSide(combined_polyline, combined_polyline.corner_count() - trace_shapes.length - 1 + i, curr_trace_shape); - if (p_with_check) - { + if (p_with_check) { boolean check_shove_ok = shove_trace_algo.check(curr_trace_shape, from_side, null, p_layer, p_net_no_arr, p_clearance_class_no, p_max_recursion_depth, p_max_via_recursion_depth, p_max_spring_over_recursion_depth, p_time_limit); - if (!check_shove_ok) - { + if (!check_shove_ok) { last_shape_no = i; break; } @@ -774,59 +648,48 @@ public Point insert_forced_trace_polyline(Polyline p_polyline, int p_half_width, boolean insert_ok = shove_trace_algo.insert(curr_trace_shape, from_side, p_layer, p_net_no_arr, p_clearance_class_no, null, p_max_recursion_depth, p_max_via_recursion_depth, p_max_spring_over_recursion_depth); - if (!insert_ok) - { + if (!insert_ok) { return null; } } Point new_corner = to_corner; - if (last_shape_no < trace_shapes.length) - { + if (last_shape_no < trace_shapes.length) { // the shove with index last_shape_no failed. // Sample the shove line to a shorter shove distance and try again. TileShape last_trace_shape = trace_shapes[last_shape_no]; - if (orthogonal_mode) - { + if (orthogonal_mode) { last_trace_shape = last_trace_shape.bounding_box(); } int sample_width = 2 * this.get_min_trace_half_width(); FloatPoint last_corner = new_polyline.corner_approx(last_shape_no + 1); FloatPoint prev_last_corner = new_polyline.corner_approx(last_shape_no); double last_segment_length = last_corner.distance(prev_last_corner); - if (last_segment_length > 100 * sample_width) - { + if (last_segment_length > 100 * sample_width) { // to many cycles to sample return from_corner; } int shape_index = combined_polyline.corner_count() - trace_shapes.length - 1 + last_shape_no; - if (last_segment_length > sample_width) - { + if (last_segment_length > sample_width) { new_polyline = new_polyline.shorten(new_polyline.arr.length - (trace_shapes.length - last_shape_no - 1), sample_width); Point curr_last_corner = new_polyline.last_corner(); - if (!(curr_last_corner instanceof IntPoint)) - { + if (!(curr_last_corner instanceof IntPoint)) { System.out.println("insert_forced_trace_segment: IntPoint expected"); return from_corner; } new_corner = curr_last_corner; - if (picked_trace == null) - { + if (picked_trace == null) { combined_polyline = new_polyline; - } - else - { + } else { PolylineTrace combine_trace = (PolylineTrace) picked_trace; combined_polyline = new_polyline.combine(combine_trace.polyline()); } - if (combined_polyline.arr.length < 3) - { + if (combined_polyline.arr.length < 3) { return new_corner; } shape_index = combined_polyline.arr.length - 3; last_trace_shape = combined_polyline.offset_shape(compensated_half_width, shape_index); - if (orthogonal_mode) - { + if (orthogonal_mode) { last_trace_shape = last_trace_shape.bounding_box(); } } @@ -834,59 +697,49 @@ public Point insert_forced_trace_polyline(Polyline p_polyline, int p_half_width, boolean check_shove_ok = shove_trace_algo.check(last_trace_shape, from_side, null, p_layer, p_net_no_arr, p_clearance_class_no, p_max_recursion_depth, p_max_via_recursion_depth, p_max_spring_over_recursion_depth, p_time_limit); - if (!check_shove_ok) - { + if (!check_shove_ok) { return from_corner; } boolean insert_ok = shove_trace_algo.insert(last_trace_shape, from_side, p_layer, p_net_no_arr, p_clearance_class_no, null, p_max_recursion_depth, p_max_via_recursion_depth, p_max_spring_over_recursion_depth); - if (!insert_ok) - { + if (!insert_ok) { System.out.println("shove trace failed"); return null; } } // insert the new trace segment - for (int i = 0; i < new_polyline.corner_count(); ++i) - { + for (int i = 0; i < new_polyline.corner_count(); ++i) { join_changed_area(new_polyline.corner_approx(i), p_layer); } PolylineTrace new_trace = insert_trace_without_cleaning(new_polyline, p_layer, p_half_width, p_net_no_arr, p_clearance_class_no, FixedState.UNFIXED); new_trace.combine(); IntOctagon tidy_region = null; - if (p_tidy_width < Integer.MAX_VALUE) - { + if (p_tidy_width < Integer.MAX_VALUE) { tidy_region = new_corner.surrounding_octagon().enlarge(p_tidy_width); } int[] opt_net_no_arr; - if (p_max_recursion_depth <= 0) - { + if (p_max_recursion_depth <= 0) { opt_net_no_arr = p_net_no_arr; - } - else - { + } else { opt_net_no_arr = new int[0]; } PullTightAlgo pull_tight_algo = PullTightAlgo.get_instance(this, opt_net_no_arr, tidy_region, - p_pull_tight_accuracy, null, -1, new_corner, p_layer); + p_pull_tight_accuracy, null, -1, new_corner, p_layer); // Remove evtl. generated cycles because otherwise pull_tight may not work correctly. - if (new_trace.normalize(changed_area.get_area(p_layer))) - { + if (new_trace.normalize(changed_area.get_area(p_layer))) { pull_tight_algo.split_traces_at_keep_point(); // otherwise the new corner may no more be contained in the new trace after optimizing ItemSelectionFilter item_filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.TRACES); Set curr_picked_items = this.pick_items(new_corner, p_layer, item_filter); new_trace = null; - if (!curr_picked_items.isEmpty()) - { + if (!curr_picked_items.isEmpty()) { Item found_trace = curr_picked_items.iterator().next(); - if (found_trace instanceof PolylineTrace) - { + if (found_trace instanceof PolylineTrace) { new_trace = (PolylineTrace) found_trace; } } @@ -894,8 +747,7 @@ public Point insert_forced_trace_polyline(Polyline p_polyline, int p_half_width, // To avoid, that a separate handling for moving backwards in the own trace line // becomes necessesary, pull tight is called here. - if (p_tidy_width > 0 && new_trace != null) - { + if (p_tidy_width > 0 && new_trace != null) { new_trace.pull_tight(pull_tight_algo); } return new_corner; @@ -907,10 +759,8 @@ public Point insert_forced_trace_polyline(Polyline p_polyline, int p_half_width, * the algorithm for performance reasons. */ public AutorouteEngine init_autoroute(int p_net_no, int p_trace_clearance_class_no, - Stoppable p_stoppable_thread, TimeLimit p_time_limit, boolean p_retain_autoroute_database) - { - if (this.autoroute_engine == null || !p_retain_autoroute_database || this.autoroute_engine.autoroute_search_tree.compensated_clearance_class_no != p_trace_clearance_class_no) - { + Stoppable p_stoppable_thread, TimeLimit p_time_limit, boolean p_retain_autoroute_database) { + if (this.autoroute_engine == null || !p_retain_autoroute_database || this.autoroute_engine.autoroute_search_tree.compensated_clearance_class_no != p_trace_clearance_class_no) { this.autoroute_engine = new AutorouteEngine(this, p_trace_clearance_class_no, p_retain_autoroute_database); } this.autoroute_engine.init_connection(p_net_no, p_stoppable_thread, p_time_limit); @@ -920,10 +770,8 @@ public AutorouteEngine init_autoroute(int p_net_no, int p_trace_clearance_class_ /** * Clears the autoroute database in case it was retained. */ - public void finish_autoroute() - { - if (this.autoroute_engine != null) - { + public void finish_autoroute() { + if (this.autoroute_engine != null) { this.autoroute_engine.clear(); } this.autoroute_engine = null; @@ -934,14 +782,11 @@ public void finish_autoroute() * is not yet electrically connected. * Returns an enum of type AutorouteEngine.AutorouteResult */ - public AutorouteEngine.AutorouteResult autoroute(Item p_item, net.freerouting.interactive.Settings p_settings, int p_via_costs, Stoppable p_stoppable_thread, TimeLimit p_time_limit) - { - if (!(p_item instanceof Connectable) || p_item.net_count() == 0) - { + public AutorouteEngine.AutorouteResult autoroute(Item p_item, net.freerouting.interactive.Settings p_settings, int p_via_costs, Stoppable p_stoppable_thread, TimeLimit p_time_limit) { + if (!(p_item instanceof Connectable) || p_item.net_count() == 0) { return AutorouteEngine.AutorouteResult.ALREADY_CONNECTED; } - if (p_item.net_count() > 1) - { + if (p_item.net_count() > 1) { System.out.println("RoutingBoard.autoroute: net_count > 1 not yet implemented"); } int route_net_no = p_item.get_net_no(0); @@ -949,19 +794,15 @@ public AutorouteEngine.AutorouteResult autoroute(Item p_item, net.freerouting.in ctrl_settings.remove_unconnected_vias = false; Set route_start_set = p_item.get_connected_set(route_net_no); net.freerouting.rules.Net route_net = rules.nets.get(route_net_no); - if (route_net != null && route_net.contains_plane()) - { - for (Item curr_item : route_start_set) - { - if (curr_item instanceof net.freerouting.board.ConductionArea) - { + if (route_net != null && route_net.contains_plane()) { + for (Item curr_item : route_start_set) { + if (curr_item instanceof net.freerouting.board.ConductionArea) { return AutorouteEngine.AutorouteResult.ALREADY_CONNECTED; // already connected to plane } } } Set route_dest_set = p_item.get_unconnected_set(route_net_no); - if (route_dest_set.size() == 0) - { + if (route_dest_set.size() == 0) { return AutorouteEngine.AutorouteResult.ALREADY_CONNECTED; // p_item is already routed. } SortedSet ripped_item_list = new TreeSet(); @@ -969,8 +810,7 @@ public AutorouteEngine.AutorouteResult autoroute(Item p_item, net.freerouting.in ctrl_settings.trace_clearance_class_no, p_stoppable_thread, p_time_limit, false); AutorouteEngine.AutorouteResult result = curr_autoroute_engine.autoroute_connection(route_start_set, route_dest_set, ctrl_settings, ripped_item_list); - if (result == AutorouteEngine.AutorouteResult.ROUTED) - { + if (result == AutorouteEngine.AutorouteResult.ROUTED) { final int time_limit_to_prevent_endless_loop = 1000; opt_changed_area(new int[0], null, p_settings.get_trace_pull_tight_accuracy(), ctrl_settings.trace_costs, p_stoppable_thread, time_limit_to_prevent_endless_loop); } @@ -978,37 +818,31 @@ public AutorouteEngine.AutorouteResult autoroute(Item p_item, net.freerouting.in } /** - * Autoroutes from the input pin until the first via, in case the pin and its connected set - * has only 1 layer. Ripup is allowed if p_ripup_costs is >= 0. - * Returns an enum of type AutorouteEngine.AutorouteResult + * Autoroutes from the input pin until the first via, in case the pin and its connected set + * has only 1 layer. Ripup is allowed if p_ripup_costs is >= 0. + * Returns an enum of type AutorouteEngine.AutorouteResult */ public AutorouteEngine.AutorouteResult fanout(Pin p_pin, net.freerouting.interactive.Settings p_settings, int p_ripup_costs, - Stoppable p_stoppable_thread, TimeLimit p_time_limit) - { - if (p_pin.first_layer() != p_pin.last_layer() || p_pin.net_count() != 1) - { + Stoppable p_stoppable_thread, TimeLimit p_time_limit) { + if (p_pin.first_layer() != p_pin.last_layer() || p_pin.net_count() != 1) { return AutorouteEngine.AutorouteResult.ALREADY_CONNECTED; } int pin_net_no = p_pin.get_net_no(0); int pin_layer = p_pin.first_layer(); Set pin_connected_set = p_pin.get_connected_set(pin_net_no); - for (Item curr_item : pin_connected_set) - { - if (curr_item.first_layer() != pin_layer || curr_item.last_layer() != pin_layer) - { + for (Item curr_item : pin_connected_set) { + if (curr_item.first_layer() != pin_layer || curr_item.last_layer() != pin_layer) { return AutorouteEngine.AutorouteResult.ALREADY_CONNECTED; } } Set unconnected_set = p_pin.get_unconnected_set(pin_net_no); - if (unconnected_set.isEmpty()) - { + if (unconnected_set.isEmpty()) { return AutorouteEngine.AutorouteResult.ALREADY_CONNECTED; } AutorouteControl ctrl_settings = new AutorouteControl(this, pin_net_no, p_settings); ctrl_settings.is_fanout = true; ctrl_settings.remove_unconnected_vias = false; - if (p_ripup_costs >= 0) - { + if (p_ripup_costs >= 0) { ctrl_settings.ripup_allowed = true; ctrl_settings.ripup_costs = p_ripup_costs; } @@ -1017,9 +851,8 @@ public AutorouteEngine.AutorouteResult fanout(Pin p_pin, net.freerouting.interac ctrl_settings.trace_clearance_class_no, p_stoppable_thread, p_time_limit, false); AutorouteEngine.AutorouteResult result = curr_autoroute_engine.autoroute_connection(pin_connected_set, - unconnected_set, ctrl_settings, ripped_item_list); - if (result == AutorouteEngine.AutorouteResult.ROUTED) - { + unconnected_set, ctrl_settings, ripped_item_list); + if (result == AutorouteEngine.AutorouteResult.ROUTED) { final int time_limit_to_prevent_endless_loop = 1000; opt_changed_area(new int[0], null, p_settings.get_trace_pull_tight_accuracy(), ctrl_settings.trace_costs, p_stoppable_thread, time_limit_to_prevent_endless_loop); } @@ -1031,8 +864,7 @@ public AutorouteEngine.AutorouteResult fanout(Pin p_pin, net.freerouting.interac * Returns false, if that is not possible without clearance violation. */ public boolean connect_to_trace(IntPoint p_from_point, Trace p_to_trace, - int p_pen_half_width, int p_cl_type) - { + int p_pen_half_width, int p_cl_type) { Point first_corner = p_to_trace.first_corner(); @@ -1040,54 +872,43 @@ public boolean connect_to_trace(IntPoint p_from_point, Trace p_to_trace, int[] net_no_arr = p_to_trace.net_no_arr; - if (!(p_to_trace instanceof PolylineTrace)) - { + if (!(p_to_trace instanceof PolylineTrace)) { return false; // not yet implemented } PolylineTrace to_trace = (PolylineTrace) p_to_trace; - if (to_trace.polyline().contains(p_from_point)) - { + if (to_trace.polyline().contains(p_from_point)) { // no connection line necessary return true; } LineSegment projection_line = to_trace.polyline().projection_line(p_from_point); - if (projection_line == null) - { + if (projection_line == null) { return false; } Polyline connection_line = projection_line.to_polyline(); - if (connection_line == null || connection_line.arr.length != 3) - { + if (connection_line == null || connection_line.arr.length != 3) { return false; } int trace_layer = p_to_trace.get_layer(); if (!this.check_polyline_trace(connection_line, trace_layer, p_pen_half_width, - p_to_trace.net_no_arr, p_cl_type)) - { + p_to_trace.net_no_arr, p_cl_type)) { return false; } - if (this.changed_area != null) - { - for (int i = 0; i < connection_line.corner_count(); ++i) - { + if (this.changed_area != null) { + for (int i = 0; i < connection_line.corner_count(); ++i) { this.changed_area.join(connection_line.corner_approx(i), trace_layer); } } this.insert_trace(connection_line, trace_layer, p_pen_half_width, net_no_arr, p_cl_type, FixedState.UNFIXED); - if (!p_from_point.equals(first_corner)) - { + if (!p_from_point.equals(first_corner)) { Trace tail = this.get_trace_tail(first_corner, trace_layer, net_no_arr); - if (tail != null && !tail.is_user_fixed()) - { + if (tail != null && !tail.is_user_fixed()) { this.remove_item(tail); } } - if (!p_from_point.equals(last_corner)) - { + if (!p_from_point.equals(last_corner)) { Trace tail = this.get_trace_tail(last_corner, trace_layer, net_no_arr); - if (tail != null && !tail.is_user_fixed()) - { + if (tail != null && !tail.is_user_fixed()) { this.remove_item(tail); } } @@ -1098,19 +919,14 @@ public boolean connect_to_trace(IntPoint p_from_point, Trace p_to_trace, * Checks, if the list p_items contains traces, which have no contact at their * start or end point. Trace with net number p_except_net_no are ignored. */ - public boolean contains_trace_tails(Collection p_items, int[] p_except_net_no_arr) - { + public boolean contains_trace_tails(Collection p_items, int[] p_except_net_no_arr) { Iterator it = p_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if (curr_ob instanceof Trace) - { + if (curr_ob instanceof Trace) { Trace curr_trace = (Trace) curr_ob; - if (!curr_trace.nets_equal(p_except_net_no_arr)) - { - if (curr_trace.is_tail()) - { + if (!curr_trace.nets_equal(p_except_net_no_arr)) { + if (curr_trace.is_tail()) { return true; } } @@ -1122,38 +938,28 @@ public boolean contains_trace_tails(Collection p_items, int[] p_except_net /** * Removes all trace tails of the input net. * If p_net_no <= 0, the tails of all nets are removed. - * Returns true, if something was removed. + * Returns true, if something was removed. */ - public boolean remove_trace_tails(int p_net_no, Item.StopConnectionOption p_stop_connection_option) - { + public boolean remove_trace_tails(int p_net_no, Item.StopConnectionOption p_stop_connection_option) { SortedSet stub_set = new TreeSet(); Collection board_items = this.get_items(); - for (Item curr_item : board_items) - { - if (!curr_item.is_route()) - { + for (Item curr_item : board_items) { + if (!curr_item.is_route()) { continue; } - if (curr_item.net_count() != 1) - { + if (curr_item.net_count() != 1) { continue; } - if (p_net_no > 0 && curr_item.get_net_no(0) != p_net_no) - { + if (p_net_no > 0 && curr_item.get_net_no(0) != p_net_no) { continue; } - if (curr_item.is_tail()) - { - if (curr_item instanceof Via) - { - if (p_stop_connection_option == Item.StopConnectionOption.VIA) - { + if (curr_item.is_tail()) { + if (curr_item instanceof Via) { + if (p_stop_connection_option == Item.StopConnectionOption.VIA) { continue; } - if (p_stop_connection_option == Item.StopConnectionOption.FANOUT_VIA) - { - if (curr_item.is_fanout_via(null)) - { + if (p_stop_connection_option == Item.StopConnectionOption.FANOUT_VIA) { + if (curr_item.is_fanout_via(null)) { continue; } } @@ -1162,22 +968,17 @@ public boolean remove_trace_tails(int p_net_no, Item.StopConnectionOption p_stop } } SortedSet stub_connections = new TreeSet(); - for (Item curr_item : stub_set) - { + for (Item curr_item : stub_set) { int item_contact_count = curr_item.get_normal_contacts().size(); - if (item_contact_count == 1) - { + if (item_contact_count == 1) { stub_connections.addAll(curr_item.get_connection_items(p_stop_connection_option)); - } - else - { + } else { // the connected items are no stubs for example if a via is only connected on 1 layer, // but to several traces. stub_connections.add(curr_item); } } - if (stub_connections.isEmpty()) - { + if (stub_connections.isEmpty()) { return false; } this.remove_items(stub_connections, false); @@ -1185,14 +986,11 @@ public boolean remove_trace_tails(int p_net_no, Item.StopConnectionOption p_stop return true; } - public void clear_all_item_temporary_autoroute_data() - { + public void clear_all_item_temporary_autoroute_data() { Iterator it = this.item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } curr_item.clear_autoroute_info(); @@ -1202,36 +1000,29 @@ public void clear_all_item_temporary_autoroute_data() /** * Sets, if all conduction areas on the board are obstacles for route of foreign nets. */ - public void change_conduction_is_obstacle(boolean p_value) - { - if (this.rules.get_ignore_conduction() != p_value) - { + public void change_conduction_is_obstacle(boolean p_value) { + if (this.rules.get_ignore_conduction() != p_value) { return; // no muultiply } boolean something_changed = false; // Change the is_obstacle property of all conduction areas of the board. Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof ConductionArea) - { + if (curr_item instanceof ConductionArea) { ConductionArea curr_conduction_area = (ConductionArea) curr_item; Layer curr_layer = layer_structure.arr[curr_conduction_area.get_layer()]; - if (curr_layer.is_signal && curr_conduction_area.get_is_obstacle() != p_value) - { + if (curr_layer.is_signal && curr_conduction_area.get_is_obstacle() != p_value) { curr_conduction_area.set_is_obstacle(p_value); something_changed = true; } } } this.rules.set_ignore_conduction(!p_value); - if (something_changed) - { + if (something_changed) { this.search_tree_manager.reinsert_tree_items(); } } @@ -1241,63 +1032,46 @@ public void change_conduction_is_obstacle(boolean p_value) * items. This is applied to traces and vias with more than 1 net connected to tie pins. * Returns true, if the nets of some items were reduced. */ - public boolean reduce_nets_of_route_items() - { + public boolean reduce_nets_of_route_items() { boolean result = false; boolean something_changed = true; - while (something_changed) - { + while (something_changed) { something_changed = false; Iterator it = item_list.start_read_object(); - for (;;) - { + for (; ; ) { UndoableObjects.Storable curr_ob = item_list.read_object(it); - if (curr_ob == null) - { + if (curr_ob == null) { break; } Item curr_item = (Item) curr_ob; - if (curr_item.net_no_arr.length <= 1 || curr_item.get_fixed_state() == FixedState.SYSTEM_FIXED) - { + if (curr_item.net_no_arr.length <= 1 || curr_item.get_fixed_state() == FixedState.SYSTEM_FIXED) { continue; } - if (curr_ob instanceof Via) - { + if (curr_ob instanceof Via) { Collection contacts = curr_item.get_normal_contacts(); - for (int curr_net_no : curr_item.net_no_arr) - { - for (Item curr_contact : contacts) - { - if (!curr_contact.contains_net(curr_net_no)) - { + for (int curr_net_no : curr_item.net_no_arr) { + for (Item curr_contact : contacts) { + if (!curr_contact.contains_net(curr_net_no)) { curr_item.remove_from_net(curr_net_no); something_changed = true; break; } } - if (something_changed) - { + if (something_changed) { break; } } - } - else if (curr_ob instanceof Trace) - { + } else if (curr_ob instanceof Trace) { Trace curr_trace = (Trace) curr_ob; Collection contacts = curr_trace.get_start_contacts(); - for (int i = 0; i < 2; ++i) - { - for (int curr_net_no : curr_item.net_no_arr) - { + for (int i = 0; i < 2; ++i) { + for (int curr_net_no : curr_item.net_no_arr) { boolean pin_found = false; - for (Item curr_contact : contacts) - { - if (curr_contact instanceof Pin) - { + for (Item curr_contact : contacts) { + if (curr_contact instanceof Pin) { pin_found = true; - if (!curr_contact.contains_net(curr_net_no)) - { + if (!curr_contact.contains_net(curr_net_no)) { curr_item.remove_from_net(curr_net_no); something_changed = true; break; @@ -1306,10 +1080,8 @@ else if (curr_ob instanceof Trace) } if (!pin_found) // at tie pins traces may have different nets { - for (Item curr_contact : contacts) - { - if (!(curr_contact instanceof Pin) && !curr_contact.contains_net(curr_net_no)) - { + for (Item curr_contact : contacts) { + if (!(curr_contact instanceof Pin) && !curr_contact.contains_net(curr_net_no)) { curr_item.remove_from_net(curr_net_no); something_changed = true; break; @@ -1317,19 +1089,16 @@ else if (curr_ob instanceof Trace) } } } - if (something_changed) - { + if (something_changed) { break; } contacts = curr_trace.get_end_contacts(); } - if (something_changed) - { + if (something_changed) { break; } } - if (something_changed) - { + if (something_changed) { break; } } @@ -1340,64 +1109,44 @@ else if (curr_ob instanceof Trace) /** * Returns the obstacle responsible for the last shove to fail. */ - public Item get_shove_failing_obstacle() - { + public Item get_shove_failing_obstacle() { return shove_failing_obstacle; } - void set_shove_failing_obstacle(Item p_item) - { + void set_shove_failing_obstacle(Item p_item) { shove_failing_obstacle = p_item; } - public int get_shove_failing_layer() - { + public int get_shove_failing_layer() { return shove_failing_layer; } - void set_shove_failing_layer(int p_layer) - { + void set_shove_failing_layer(int p_layer) { shove_failing_layer = p_layer; } - private void clear_shove_failing_obstacle() - { + private void clear_shove_failing_obstacle() { shove_failing_obstacle = null; shove_failing_layer = -1; } /** - * Sets, if the autoroute database has to be maintained outside the outoroute algorithm + * Returns, if the autoroute database is maintained outside the outoroute algorithm * while changing items on rhe board. */ - void set_maintaining_autoroute_database(boolean p_value) - { - if (p_value) - { - - } - else - { - this.autoroute_engine = null; - } + boolean is_maintaining_autoroute_database() { + return this.autoroute_engine != null; } /** - * Returns, if the autoroute database is maintained outside the outoroute algorithm + * Sets, if the autoroute database has to be maintained outside the outoroute algorithm * while changing items on rhe board. */ - boolean is_maintaining_autoroute_database() - { - return this.autoroute_engine != null; + void set_maintaining_autoroute_database(boolean p_value) { + if (p_value) { + + } else { + this.autoroute_engine = null; + } } - /** - * Contains the database for the autorouzte algorithm. - */ - private transient AutorouteEngine autoroute_engine = null; - /** the area marked for optimizing the route */ - transient ChangedArea changed_area; - private transient Item shove_failing_obstacle = null; - private transient int shove_failing_layer = -1; - /** The time limit in milliseconds for the pull tight algorithm */ - private static final int PULL_TIGHT_TIME_LIMIT = 2000; } diff --git a/src/main/java/net/freerouting/board/SearchTreeManager.java b/src/main/java/net/freerouting/board/SearchTreeManager.java index 4bdc3b04..00bc847d 100644 --- a/src/main/java/net/freerouting/board/SearchTreeManager.java +++ b/src/main/java/net/freerouting/board/SearchTreeManager.java @@ -21,61 +21,58 @@ package net.freerouting.board; -import java.util.Collection; -import java.util.LinkedList; -import java.util.Iterator; - -import net.freerouting.datastructures.UndoableObjects; import net.freerouting.datastructures.ShapeTree; - +import net.freerouting.datastructures.UndoableObjects; import net.freerouting.geometry.planar.FortyfiveDegreeBoundingDirections; import net.freerouting.geometry.planar.Polyline; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; + /** - * * @author Alfons Wirtz */ -public class SearchTreeManager -{ - - /** Creates a new instance of SearchTreeManager */ - public SearchTreeManager(BasicBoard p_board) - { +public class SearchTreeManager { + + private final Collection compensated_search_trees; + private final BasicBoard board; + private ShapeSearchTree default_tree; + private boolean clearance_compensation_used; + + /** + * Creates a new instance of SearchTreeManager + */ + public SearchTreeManager(BasicBoard p_board) { board = p_board; compensated_search_trees = new LinkedList(); - default_tree = new ShapeSearchTree(FortyfiveDegreeBoundingDirections.INSTANCE, p_board, 0); + default_tree = new ShapeSearchTree(FortyfiveDegreeBoundingDirections.INSTANCE, p_board, 0); compensated_search_trees.add(default_tree); this.clearance_compensation_used = false; } - + /** * Inserts the tree shapes of p_item into all active search trees. */ - public void insert(Item p_item) - { - for (ShapeSearchTree curr_tree : compensated_search_trees) - { + public void insert(Item p_item) { + for (ShapeSearchTree curr_tree : compensated_search_trees) { curr_tree.insert(p_item); } p_item.set_on_the_board(true); } - + /** * Removes all entries of an item from the search trees. */ - public void remove(Item p_item) - { - if (!p_item.is_on_the_board()) - { + public void remove(Item p_item) { + if (!p_item.is_on_the_board()) { return; } - for (ShapeSearchTree curr_tree : compensated_search_trees) - { - + for (ShapeSearchTree curr_tree : compensated_search_trees) { + ShapeTree.Leaf[] curr_tree_entries = p_item.get_search_tree_entries(curr_tree); { - if (curr_tree_entries != null) - { + if (curr_tree_entries != null) { curr_tree.remove(curr_tree_entries); } } @@ -83,278 +80,224 @@ public void remove(Item p_item) p_item.clear_search_tree_entries(); p_item.set_on_the_board(false); } - + /** * Returns the default tree used in interactive routing. */ - public ShapeSearchTree get_default_tree() - { + public ShapeSearchTree get_default_tree() { return default_tree; } - - boolean validate_entries(Item p_item) - { + + boolean validate_entries(Item p_item) { boolean result = true; - for (ShapeSearchTree curr_tree : compensated_search_trees) - { - - if (!curr_tree.validate_entries(p_item)) - { + for (ShapeSearchTree curr_tree : compensated_search_trees) { + + if (!curr_tree.validate_entries(p_item)) { result = false; } } return result; } - + /** * Returns, if clearance compensation is used for the default tree. * This is normally the case, if there exist only the clearance classes null and default * in the clearance matrix. */ - public boolean is_clearance_compensation_used() - { + public boolean is_clearance_compensation_used() { return this.clearance_compensation_used; } - + /** * Sets the usage of clearance compensation to true or false. */ - public void set_clearance_compensation_used(boolean p_value) - { - if (this.clearance_compensation_used == p_value) - { + public void set_clearance_compensation_used(boolean p_value) { + if (this.clearance_compensation_used == p_value) { return; } - + this.clearance_compensation_used = p_value; remove_all_board_items(); this.compensated_search_trees.clear(); int compensated_clearance_class_no; - if (p_value) - { + if (p_value) { compensated_clearance_class_no = 1; - } - else - { + } else { compensated_clearance_class_no = 0; } - default_tree = new ShapeSearchTree(FortyfiveDegreeBoundingDirections.INSTANCE, this.board, compensated_clearance_class_no); + default_tree = new ShapeSearchTree(FortyfiveDegreeBoundingDirections.INSTANCE, this.board, compensated_clearance_class_no); this.compensated_search_trees.add(default_tree); insert_all_board_items(); } - + /** * Actions to be done, when a value in the clearance matrix is changed interactively. */ - public void clearance_value_changed() - { + public void clearance_value_changed() { // delete all trees except the default tree Iterator it = this.compensated_search_trees.iterator(); - while(it.hasNext()) - { + while (it.hasNext()) { ShapeSearchTree curr_tree = it.next(); - if (curr_tree.compensated_clearance_class_no != default_tree.compensated_clearance_class_no) - { + if (curr_tree.compensated_clearance_class_no != default_tree.compensated_clearance_class_no) { it.remove(); } } - if (this.clearance_compensation_used) - { + if (this.clearance_compensation_used) { remove_all_board_items(); insert_all_board_items(); } } - + /** * Actions to be done, when a new clearance class is removed interactively. */ - public void clearance_class_removed(int p_no) - { + public void clearance_class_removed(int p_no) { Iterator it = this.compensated_search_trees.iterator(); - if (p_no == default_tree.compensated_clearance_class_no) - { + if (p_no == default_tree.compensated_clearance_class_no) { System.out.println("SearchtreeManager.clearance_class_removed: unable to remove default tree"); return; } - while(it.hasNext()) - { + while (it.hasNext()) { ShapeSearchTree curr_tree = it.next(); - if (curr_tree.compensated_clearance_class_no == p_no) - { + if (curr_tree.compensated_clearance_class_no == p_no) { it.remove(); } } } - + /** * Returns the tree compensated for the clearance class with number p_clearance_vlass_no. * Initialized the tree, if it is not yet allocated. */ - public ShapeSearchTree get_autoroute_tree(int p_clearance_class_no) - { - for (ShapeSearchTree curr_tree : compensated_search_trees) - { - if (curr_tree.compensated_clearance_class_no == p_clearance_class_no) - { + public ShapeSearchTree get_autoroute_tree(int p_clearance_class_no) { + for (ShapeSearchTree curr_tree : compensated_search_trees) { + if (curr_tree.compensated_clearance_class_no == p_clearance_class_no) { return curr_tree; } } // tree is not yet initialized ShapeSearchTree curr_autoroute_tree; boolean fast_algorithm = !this.board.rules.get_slow_autoroute_algorithm(); - if (fast_algorithm && this.board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (fast_algorithm && this.board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { curr_autoroute_tree = new ShapeSearchTree90Degree(this.board, p_clearance_class_no); - } - else if (fast_algorithm && this.board.rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (fast_algorithm && this.board.rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) { curr_autoroute_tree = new ShapeSearchTree45Degree(this.board, p_clearance_class_no); - } - else - { + } else { curr_autoroute_tree = new ShapeSearchTree(FortyfiveDegreeBoundingDirections.INSTANCE, this.board, p_clearance_class_no); } this.compensated_search_trees.add(curr_autoroute_tree); Iterator it = this.board.item_list.start_read_object(); - for(;;) - { + for (; ; ) { Item curr_item = (Item) this.board.item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } curr_autoroute_tree.insert(curr_item); } return curr_autoroute_tree; } - + + //******************************************************************************** + + // The following functions are used internally for perfomance improvement. + + //******************************************************************************** + /** * Clears all compensated trees used in the autoroute algorithm apart from the default tree. */ - public void reset_compensated_trees() - { + public void reset_compensated_trees() { Iterator it = this.compensated_search_trees.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { ShapeSearchTree curr_tree = it.next(); - if (curr_tree != default_tree) - { + if (curr_tree != default_tree) { it.remove(); } } } - - /** Reinsert all items into the search trees */ - void reinsert_tree_items() - { + + /** + * Reinsert all items into the search trees + */ + void reinsert_tree_items() { remove_all_board_items(); insert_all_board_items(); } - - private void remove_all_board_items() - { - if (this.board == null) - { + + private void remove_all_board_items() { + if (this.board == null) { System.out.println("SearchtreeManager.remove_all_board_items: board is null"); return; } Iterator it = this.board.item_list.start_read_object(); - for(;;) - { + for (; ; ) { Item curr_item = (Item) this.board.item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } this.remove(curr_item); } } - - private void insert_all_board_items() - { - if (this.board == null) - { + + private void insert_all_board_items() { + if (this.board == null) { System.out.println("SearchtreeManager.insert_all_board_items: board is null"); return; } Iterator it = this.board.item_list.start_read_object(); - for(;;) - { + for (; ; ) { Item curr_item = (Item) this.board.item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } curr_item.clear_derived_data(); this.insert(curr_item); } } - - //******************************************************************************** - - // The following functions are used internally for perfomance improvement. - - //******************************************************************************** - + /** * Merges the tree entries from p_from_trace in front of p_to_trace. * Special implementation for combine trace for performance reasons. */ - void merge_entries_in_front( PolylineTrace p_from_trace, PolylineTrace p_to_trace, - Polyline p_joined_polyline, int p_from_entry_no, int p_to_entry_no) - { - for (ShapeSearchTree curr_tree : compensated_search_trees) - { + void merge_entries_in_front(PolylineTrace p_from_trace, PolylineTrace p_to_trace, + Polyline p_joined_polyline, int p_from_entry_no, int p_to_entry_no) { + for (ShapeSearchTree curr_tree : compensated_search_trees) { curr_tree.merge_entries_in_front(p_from_trace, p_to_trace, p_joined_polyline, p_from_entry_no, p_to_entry_no); } } - + /** * Merges the tree entries from p_from_trace to the end of p_to_trace. * Special implementation for combine trace for performance reasons. */ - void merge_entries_at_end( PolylineTrace p_from_trace, PolylineTrace p_to_trace, - Polyline p_joined_polyline, int p_from_entry_no, int p_to_entry_no) - { - for (ShapeSearchTree curr_tree : compensated_search_trees) - { + void merge_entries_at_end(PolylineTrace p_from_trace, PolylineTrace p_to_trace, + Polyline p_joined_polyline, int p_from_entry_no, int p_to_entry_no) { + for (ShapeSearchTree curr_tree : compensated_search_trees) { curr_tree.merge_entries_at_end(p_from_trace, p_to_trace, p_joined_polyline, p_from_entry_no, p_to_entry_no); } } - + /** * Changes the tree entries from p_keep_at_start_count + 1 * to new_shape_count - 1 - keep_at_end_count to p_changed_entries. * Special implementation for change_trace for performance reasons */ - void change_entries( PolylineTrace p_obj, Polyline p_new_polyline, - int p_keep_at_start_count, int p_keep_at_end_count) - { - for (ShapeSearchTree curr_tree : compensated_search_trees) - { + void change_entries(PolylineTrace p_obj, Polyline p_new_polyline, + int p_keep_at_start_count, int p_keep_at_end_count) { + for (ShapeSearchTree curr_tree : compensated_search_trees) { curr_tree.change_entries(p_obj, p_new_polyline, p_keep_at_start_count, p_keep_at_end_count); } } - + /** * Trannsfers tree entries from p_from_trace to p_start and p_end_piece * after a moddle piece was cut out. * Special implementation for ShapeTraceEntries.fast_cutout_trace for performance reasoms. */ - void reuse_entries_after_cutout(PolylineTrace p_from_trace, PolylineTrace p_start_piece, PolylineTrace p_end_piece) - { - for (ShapeSearchTree curr_tree : compensated_search_trees) - { - + void reuse_entries_after_cutout(PolylineTrace p_from_trace, PolylineTrace p_start_piece, PolylineTrace p_end_piece) { + for (ShapeSearchTree curr_tree : compensated_search_trees) { + curr_tree.reuse_entries_after_cutout(p_from_trace, p_start_piece, p_end_piece); } } - - private final Collection compensated_search_trees; - - private ShapeSearchTree default_tree; - - private final BasicBoard board; - - private boolean clearance_compensation_used; } diff --git a/src/main/java/net/freerouting/board/SearchTreeObject.java b/src/main/java/net/freerouting/board/SearchTreeObject.java index d362d4cd..bd93a3e1 100644 --- a/src/main/java/net/freerouting/board/SearchTreeObject.java +++ b/src/main/java/net/freerouting/board/SearchTreeObject.java @@ -23,22 +23,21 @@ /** * Common ShapeSearchTree functionality for board.Items and autoroute.ExpansionRooms * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public interface SearchTreeObject extends net.freerouting.datastructures.ShapeTree.Storable -{ +public interface SearchTreeObject extends net.freerouting.datastructures.ShapeTree.Storable { /** * Returns true if this object is an obstacle to objects containing - * the net number p_net_no + * the net number p_net_no */ boolean is_obstacle(int p_net_no); - + /** * Returns true if this object is an obstacle to traces containing - * the net number p_net_no + * the net number p_net_no */ boolean is_trace_obstacle(int p_net_no); - + /** * returns for this object the layer of the shape with index p_index. */ diff --git a/src/main/java/net/freerouting/board/ShapeSearchTree.java b/src/main/java/net/freerouting/board/ShapeSearchTree.java index 8ba5d7d7..99677a8c 100644 --- a/src/main/java/net/freerouting/board/ShapeSearchTree.java +++ b/src/main/java/net/freerouting/board/ShapeSearchTree.java @@ -19,52 +19,39 @@ */ package net.freerouting.board; -import net.freerouting.geometry.planar.ConvexShape; -import net.freerouting.geometry.planar.ShapeBoundingDirections; -import net.freerouting.geometry.planar.IntOctagon; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.LineSegment; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.PolylineShape; -import net.freerouting.geometry.planar.RegularTileShape; -import net.freerouting.geometry.planar.Shape; -import net.freerouting.geometry.planar.Side; -import net.freerouting.geometry.planar.Simplex; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.FloatPoint; - -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Set; -import java.util.TreeSet; - -import net.freerouting.rules.ClearanceMatrix; - +import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.IncompleteFreeSpaceExpansionRoom; import net.freerouting.datastructures.Signum; +import net.freerouting.geometry.planar.*; +import net.freerouting.rules.ClearanceMatrix; -import net.freerouting.autoroute.IncompleteFreeSpaceExpansionRoom; -import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; +import java.util.*; /** - * * Elementary geometric search functions making direct use * of the MinAreaTree in the package datastructures. * - * * @author Alfons Wirtz */ -public class ShapeSearchTree extends net.freerouting.datastructures.MinAreaTree -{ +public class ShapeSearchTree extends net.freerouting.datastructures.MinAreaTree { /** - * Creates a new ShapeSearchTree. + * used in objects of class EntrySortedByClearance + */ + static private int last_generated_id_no = 0; + /** + * The clearance class number for which the shapes of this tree is compensated. + * If compensated_clearance_class_no = 0, the shapes are not compensated. + */ + public final int compensated_clearance_class_no; + protected final BasicBoard board; + + /** + * Creates a new ShapeSearchTree. * p_compensated_clearance_class_no is the clearance class number for which the shapes of this tree is compensated. * If p_compensated_clearance_class_no = 0, the shapes are not compensated. */ - ShapeSearchTree(ShapeBoundingDirections p_directions, BasicBoard p_board, int p_compensated_clearance_class_no) - { + ShapeSearchTree(ShapeBoundingDirections p_directions, BasicBoard p_board, int p_compensated_clearance_class_no) { super(p_directions); this.compensated_clearance_class_no = p_compensated_clearance_class_no; board = p_board; @@ -74,8 +61,7 @@ public class ShapeSearchTree extends net.freerouting.datastructures.MinAreaTree * Returns, if for the shapes stored in this tree * clearance compensatiion is used. */ - public boolean is_clearance_compensation_used() - { + public boolean is_clearance_compensation_used() { return this.compensated_clearance_class_no > 0; } @@ -84,10 +70,8 @@ public boolean is_clearance_compensation_used() * of this search tree with on layer p_layer. * Returns 0, if no clearance compensation is used for this tree. */ - public int clearance_compensation_value(int p_clearance_class_no, int p_layer) - { - if (p_clearance_class_no <= 0) - { + public int clearance_compensation_value(int p_clearance_class_no, int p_layer) { + if (p_clearance_class_no <= 0) { return 0; } int result = board.rules.clearance_matrix.value(p_clearance_class_no, this.compensated_clearance_class_no, p_layer) - board.rules.clearance_matrix.clearance_compensation_value(this.compensated_clearance_class_no, p_layer); @@ -100,31 +84,27 @@ public int clearance_compensation_value(int p_clearance_class_no, int p_layer) * Special implementation for change_trace for performance reasons */ void change_entries(PolylineTrace p_obj, Polyline p_new_polyline, - int p_keep_at_start_count, int p_keep_at_end_count) - { + int p_keep_at_start_count, int p_keep_at_end_count) { // calculate the shapes of p_new_polyline from keep_at_start_count to // new_shape_count - keep_at_end_count - 1; int compensated_half_width = p_obj.get_half_width() + this.clearance_compensation_value(p_obj.clearance_class_no(), p_obj.get_layer()); TileShape[] changed_shapes = this.offset_shapes(p_new_polyline, compensated_half_width, p_keep_at_start_count, - p_new_polyline.arr.length - 1 - p_keep_at_end_count); + p_new_polyline.arr.length - 1 - p_keep_at_end_count); int old_shape_count = p_obj.tree_shape_count(this); int new_shape_count = changed_shapes.length + p_keep_at_start_count + p_keep_at_end_count; Leaf[] new_leaf_arr = new Leaf[new_shape_count]; TileShape[] new_precalculated_tree_shapes = new TileShape[new_shape_count]; Leaf[] old_entries = p_obj.get_search_tree_entries(this); - for (int i = 0; i < p_keep_at_start_count; ++i) - { + for (int i = 0; i < p_keep_at_start_count; ++i) { new_leaf_arr[i] = old_entries[i]; new_precalculated_tree_shapes[i] = p_obj.get_tree_shape(this, i); } - for (int i = p_keep_at_start_count; i < old_shape_count - p_keep_at_end_count; ++i) - { + for (int i = p_keep_at_start_count; i < old_shape_count - p_keep_at_end_count; ++i) { remove_leaf(old_entries[i]); } - for (int i = 0; i < p_keep_at_end_count; ++i) - { + for (int i = 0; i < p_keep_at_end_count; ++i) { int new_index = new_shape_count - p_keep_at_end_count + i; int old_index = old_shape_count - p_keep_at_end_count + i; @@ -134,14 +114,12 @@ void change_entries(PolylineTrace p_obj, Polyline p_new_polyline, } // correct the precalculated tree shapes first, because it is used in this.insert - for (int i = p_keep_at_start_count; i < new_shape_count - p_keep_at_end_count; ++i) - { + for (int i = p_keep_at_start_count; i < new_shape_count - p_keep_at_end_count; ++i) { new_precalculated_tree_shapes[i] = changed_shapes[i - p_keep_at_start_count]; } p_obj.set_precalculated_tree_shapes(new_precalculated_tree_shapes, this); - for (int i = p_keep_at_start_count; i < new_shape_count - p_keep_at_end_count; ++i) - { + for (int i = p_keep_at_start_count; i < new_shape_count - p_keep_at_end_count; ++i) { new_leaf_arr[i] = insert(p_obj, i); } p_obj.set_search_tree_entries(new_leaf_arr, this); @@ -152,8 +130,7 @@ void change_entries(PolylineTrace p_obj, Polyline p_new_polyline, * Special implementation for combine trace for performance reasons. */ void merge_entries_in_front(PolylineTrace p_from_trace, PolylineTrace p_to_trace, - Polyline p_joined_polyline, int p_from_entry_no, int p_to_entry_no) - { + Polyline p_joined_polyline, int p_from_entry_no, int p_to_entry_no) { int compensated_half_width = p_to_trace.get_half_width() + this.clearance_compensation_value(p_to_trace.clearance_class_no(), p_to_trace.get_layer()); TileShape[] link_shapes = @@ -165,12 +142,9 @@ void merge_entries_in_front(PolylineTrace p_from_trace, PolylineTrace p_to_trace // the new link entries. int from_shape_count_minus_1 = p_from_trace.tile_shape_count() - 1; int remove_no; - if (change_order) - { + if (change_order) { remove_no = 0; - } - else - { + } else { remove_no = from_shape_count_minus_1; } Leaf[] from_trace_entries = p_from_trace.get_search_tree_entries(this); @@ -182,15 +156,11 @@ void merge_entries_in_front(PolylineTrace p_from_trace, PolylineTrace p_to_trace int old_to_shape_count = to_trace_entries.length; TileShape[] new_precalculated_tree_shapes = new TileShape[new_shape_count]; // transfer the tree entries except the last or first from p_from_trace to p_to_trace - for (int i = 0; i < from_shape_count_minus_1; ++i) - { + for (int i = 0; i < from_shape_count_minus_1; ++i) { int from_no; - if (change_order) - { + if (change_order) { from_no = from_shape_count_minus_1 - i; - } - else - { + } else { from_no = i; } new_precalculated_tree_shapes[i] = p_from_trace.get_tree_shape(this, from_no); @@ -198,8 +168,7 @@ void merge_entries_in_front(PolylineTrace p_from_trace, PolylineTrace p_to_trace new_leaf_arr[i].object = p_to_trace; new_leaf_arr[i].shape_index_in_object = i; } - for (int i = 1; i < old_to_shape_count; ++i) - { + for (int i = 1; i < old_to_shape_count; ++i) { int curr_ind = from_shape_count_minus_1 + link_shapes.length + i - 1; new_precalculated_tree_shapes[curr_ind] = p_to_trace.get_tree_shape(this, i); @@ -208,16 +177,14 @@ void merge_entries_in_front(PolylineTrace p_from_trace, PolylineTrace p_to_trace } // correct the precalculated tree shapes first, because it is used in this.insert - for (int i = 0; i < link_shapes.length; ++i) - { + for (int i = 0; i < link_shapes.length; ++i) { int curr_ind = from_shape_count_minus_1 + i; new_precalculated_tree_shapes[curr_ind] = link_shapes[i]; } p_to_trace.set_precalculated_tree_shapes(new_precalculated_tree_shapes, this); // create the new link entries - for (int i = 0; i < link_shapes.length; ++i) - { + for (int i = 0; i < link_shapes.length; ++i) { int curr_ind = from_shape_count_minus_1 + i; new_leaf_arr[curr_ind] = insert(p_to_trace, curr_ind); } @@ -230,8 +197,7 @@ void merge_entries_in_front(PolylineTrace p_from_trace, PolylineTrace p_to_trace * Special implementation for combine trace for performance reasons. */ void merge_entries_at_end(PolylineTrace p_from_trace, PolylineTrace p_to_trace, - Polyline p_joined_polyline, int p_from_entry_no, int p_to_entry_no) - { + Polyline p_joined_polyline, int p_from_entry_no, int p_to_entry_no) { int compensated_half_width = p_to_trace.get_half_width() + this.clearance_compensation_value(p_to_trace.clearance_class_no(), p_to_trace.get_layer()); TileShape[] link_shapes = @@ -246,12 +212,9 @@ void merge_entries_at_end(PolylineTrace p_from_trace, PolylineTrace p_to_trace, int to_shape_count_minus_1 = p_to_trace.tile_shape_count() - 1; remove_leaf(to_trace_entries[to_shape_count_minus_1]); int remove_no; - if (change_order) - { + if (change_order) { remove_no = p_from_trace.tile_shape_count() - 1; - } - else - { + } else { remove_no = 0; } remove_leaf(from_trace_entries[remove_no]); @@ -261,22 +224,17 @@ void merge_entries_at_end(PolylineTrace p_from_trace, PolylineTrace p_to_trace, TileShape[] new_precalculated_tree_shapes = new TileShape[new_shape_count]; // transfer the tree entries except the last from the old shapes // of p_to_trace to the new shapes of p_to_trace - for (int i = 0; i < to_shape_count_minus_1; ++i) - { + for (int i = 0; i < to_shape_count_minus_1; ++i) { new_precalculated_tree_shapes[i] = p_to_trace.get_tree_shape(this, i); new_leaf_arr[i] = to_trace_entries[i]; } - for (int i = 1; i < from_trace_entries.length; ++i) - { + for (int i = 1; i < from_trace_entries.length; ++i) { int curr_ind = to_shape_count_minus_1 + link_shapes.length + i - 1; int from_no; - if (change_order) - { + if (change_order) { from_no = from_trace_entries.length - i - 1; - } - else - { + } else { from_no = i; } new_precalculated_tree_shapes[curr_ind] = p_from_trace.get_tree_shape(this, from_no); @@ -286,16 +244,14 @@ void merge_entries_at_end(PolylineTrace p_from_trace, PolylineTrace p_to_trace, } // correct the precalculated tree shapes first, because it is used in this.insert - for (int i = 0; i < link_shapes.length; ++i) - { + for (int i = 0; i < link_shapes.length; ++i) { int curr_ind = to_shape_count_minus_1 + i; new_precalculated_tree_shapes[curr_ind] = link_shapes[i]; } p_to_trace.set_precalculated_tree_shapes(new_precalculated_tree_shapes, this); // create the new link entries - for (int i = 0; i < link_shapes.length; ++i) - { + for (int i = 0; i < link_shapes.length; ++i) { int curr_ind = to_shape_count_minus_1 + i; new_leaf_arr[curr_ind] = insert(p_to_trace, curr_ind); } @@ -307,13 +263,11 @@ void merge_entries_at_end(PolylineTrace p_from_trace, PolylineTrace p_to_trace, * after a moddle piece was cut out. * Special implementation for ShapeTraceEntries.fast_cutout_trace for performance reasoms. */ - void reuse_entries_after_cutout(PolylineTrace p_from_trace, PolylineTrace p_start_piece, PolylineTrace p_end_piece) - { + void reuse_entries_after_cutout(PolylineTrace p_from_trace, PolylineTrace p_start_piece, PolylineTrace p_end_piece) { Leaf[] start_piece_leaf_arr = new Leaf[p_start_piece.polyline().arr.length - 2]; Leaf[] from_trace_entries = p_from_trace.get_search_tree_entries(this); // transfer the entries at the start of p_from_trace to p_start_piece. - for (int i = 0; i < start_piece_leaf_arr.length - 1; ++i) - { + for (int i = 0; i < start_piece_leaf_arr.length - 1; ++i) { start_piece_leaf_arr[i] = from_trace_entries[i]; start_piece_leaf_arr[i].object = p_start_piece; start_piece_leaf_arr[i].shape_index_in_object = i; @@ -328,8 +282,7 @@ void reuse_entries_after_cutout(PolylineTrace p_from_trace, PolylineTrace p_star // create the first tree entry of the end piece. end_piece_leaf_arr[0] = insert(p_end_piece, 0); - for (int i = 1; i < end_piece_leaf_arr.length; ++i) - { + for (int i = 1; i < end_piece_leaf_arr.length; ++i) { int from_index = from_trace_entries.length - end_piece_leaf_arr.length + i; end_piece_leaf_arr[i] = from_trace_entries[from_index]; end_piece_leaf_arr[i].object = p_end_piece; @@ -347,15 +300,12 @@ void reuse_entries_after_cutout(PolylineTrace p_from_trace, PolylineTrace p_star * If p_layer < 0, the layer is ignored. */ public void overlapping_objects(ConvexShape p_shape, int p_layer, int[] p_ignore_net_nos, - Set p_obstacles) - { + Set p_obstacles) { Collection tree_entries = new LinkedList(); overlapping_tree_entries(p_shape, p_layer, p_ignore_net_nos, tree_entries); - if (p_obstacles != null) - { + if (p_obstacles != null) { Iterator it = tree_entries.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { TreeEntry curr_entry = it.next(); p_obstacles.add((SearchTreeObject) curr_entry.object); } @@ -366,8 +316,7 @@ public void overlapping_objects(ConvexShape p_shape, int p_layer, int[] p_ignore * Returns all SearchTreeObjects on layer p_layer, which overlap with p_shape. * If p_layer < 0, the layer is ignored */ - public Set overlapping_objects(ConvexShape p_shape, int p_layer) - { + public Set overlapping_objects(ConvexShape p_shape, int p_layer) { Set result = new TreeSet(); this.overlapping_objects(p_shape, p_layer, new int[0], result); return result; @@ -378,8 +327,7 @@ public Set overlapping_objects(ConvexShape p_shape, int p_laye * on layer p_layer into the list p_obstacles. * If p_layer < 0, the layer is ignored. */ - public void overlapping_tree_entries(ConvexShape p_shape, int p_layer, Collection p_tree_entries) - { + public void overlapping_tree_entries(ConvexShape p_shape, int p_layer, Collection p_tree_entries) { overlapping_tree_entries(p_shape, p_layer, new int[0], p_tree_entries); } @@ -390,20 +338,16 @@ public void overlapping_tree_entries(ConvexShape p_shape, int p_layer, Collectio * tree_entries with object containing a net number of p_ignore_net_nos are ignored. */ public void overlapping_tree_entries(ConvexShape p_shape, int p_layer, int[] p_ignore_net_nos, - Collection p_tree_entries) - { - if (p_shape == null) - { + Collection p_tree_entries) { + if (p_shape == null) { return; } - if (p_tree_entries == null) - { + if (p_tree_entries == null) { System.out.println("board.ShapeSearchTree.overlaps: p_obstacle_entries is null"); return; } RegularTileShape bounds = p_shape.bounding_shape(bounding_directions); - if (bounds == null) - { + if (bounds == null) { System.out.println("board.ShapeSearchTree.overlaps: p_shape not bounded"); return; } @@ -412,25 +356,20 @@ public void overlapping_tree_entries(ConvexShape p_shape, int p_layer, int[] p_i boolean is_45_degree = p_shape instanceof IntOctagon; - while (it.hasNext()) - { + while (it.hasNext()) { Leaf curr_leaf = it.next(); SearchTreeObject curr_object = (SearchTreeObject) curr_leaf.object; int shape_index = curr_leaf.shape_index_in_object; boolean ignore_object = p_layer >= 0 && curr_object.shape_layer(shape_index) != p_layer; - if (!ignore_object) - { - for (int i = 0; i < p_ignore_net_nos.length; ++i) - { - if (!curr_object.is_obstacle(p_ignore_net_nos[i])) - { + if (!ignore_object) { + for (int i = 0; i < p_ignore_net_nos.length; ++i) { + if (!curr_object.is_obstacle(p_ignore_net_nos[i])) { ignore_object = true; } } } - if (!ignore_object) - { + if (!ignore_object) { TileShape curr_shape = curr_object.get_tree_shape(this, curr_leaf.shape_index_in_object); boolean add_item; @@ -439,13 +378,10 @@ public void overlapping_tree_entries(ConvexShape p_shape, int p_layer, int[] p_i // therefore skipped for performance reasons { add_item = true; - } - else - { + } else { add_item = curr_shape.intersects(p_shape); } - if (add_item) - { + if (add_item) { TreeEntry new_entry = new TreeEntry(curr_object, shape_index); p_tree_entries.add(new_entry); @@ -464,21 +400,17 @@ public void overlapping_tree_entries(ConvexShape p_shape, int p_layer, int[] p_i * Used only internally, because the clearance compensation is not taken iinnto account. */ void overlapping_tree_entries_with_clearance(ConvexShape p_shape, int p_layer, int[] p_ignore_net_nos, - int p_cl_type, Collection p_obstacle_entries) - { - if (p_shape == null) - { + int p_cl_type, Collection p_obstacle_entries) { + if (p_shape == null) { return; } - if (p_obstacle_entries == null) - { + if (p_obstacle_entries == null) { System.out.println("board.ShapeSearchTree.overlaps_with_clearance: p_obstacle_entries is null"); return; } ClearanceMatrix cl_matrix = board.rules.clearance_matrix; RegularTileShape bounds = p_shape.bounding_shape(bounding_directions); - if (bounds == null) - { + if (bounds == null) { System.out.println("board.ShapeSearchTree.overlaps_with_clearance: p_shape is not bounded"); bounds = board.get_bounding_box(); } @@ -495,25 +427,20 @@ void overlapping_tree_entries_with_clearance(ConvexShape p_shape, int p_layer, i // sort the found items by its clearances tp p_cl_type on layer p_layer Set sorted_items = new TreeSet(); - while (it1.hasNext()) - { + while (it1.hasNext()) { Leaf curr_leaf = it1.next(); Item curr_item = (Item) curr_leaf.object; int shape_index = curr_leaf.shape_index_in_object; boolean ignore_item = p_layer >= 0 && curr_item.shape_layer(shape_index) != p_layer; - if (!ignore_item) - { - for (int i = 0; i < p_ignore_net_nos.length; ++i) - { - if (!curr_item.is_obstacle(p_ignore_net_nos[i])) - { + if (!ignore_item) { + for (int i = 0; i < p_ignore_net_nos.length; ++i) { + if (!curr_item.is_obstacle(p_ignore_net_nos[i])) { ignore_item = true; } } } - if (!ignore_item) - { + if (!ignore_item) { int curr_clearance = cl_matrix.value(p_cl_type, curr_item.clearance_class_no(), p_layer); EntrySortedByClearance sorted_ob = @@ -524,12 +451,10 @@ void overlapping_tree_entries_with_clearance(ConvexShape p_shape, int p_layer, i Iterator it = sorted_items.iterator(); int curr_half_clearance = 0; ConvexShape curr_offset_shape = p_shape; - while (it.hasNext()) - { + while (it.hasNext()) { EntrySortedByClearance tmp_entry = it.next(); int tmp_half_clearance = tmp_entry.clearance / 2; - if (tmp_half_clearance != curr_half_clearance) - { + if (tmp_half_clearance != curr_half_clearance) { curr_half_clearance = tmp_half_clearance; curr_offset_shape = (TileShape) p_shape.enlarge(curr_half_clearance); @@ -540,8 +465,7 @@ void overlapping_tree_entries_with_clearance(ConvexShape p_shape, int p_layer, i // symmetry. ConvexShape tmp_offset_shape = (ConvexShape) tmp_shape.enlarge(curr_half_clearance); - if (curr_offset_shape.intersects(tmp_offset_shape)) - { + if (curr_offset_shape.intersects(tmp_offset_shape)) { p_obstacle_entries.add(new TreeEntry(tmp_entry.leaf.object, tmp_entry.leaf.shape_index_in_object)); } } @@ -553,22 +477,16 @@ void overlapping_tree_entries_with_clearance(ConvexShape p_shape, int p_layer, i * If p_layer < 0, the layer is ignored. */ public void overlapping_objects_with_clearance(ConvexShape p_shape, int p_layer, int[] p_ignore_net_nos, - int p_cl_type, Set p_obstacles) - { + int p_cl_type, Set p_obstacles) { Collection tree_entries = new LinkedList(); - if (this.is_clearance_compensation_used()) - { + if (this.is_clearance_compensation_used()) { overlapping_tree_entries(p_shape, p_layer, p_ignore_net_nos, tree_entries); - } - else - { + } else { overlapping_tree_entries_with_clearance(p_shape, p_layer, p_ignore_net_nos, p_cl_type, tree_entries); } - if (p_obstacles != null) - { + if (p_obstacles != null) { Iterator it = tree_entries.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { TreeEntry curr_entry = it.next(); p_obstacles.add((SearchTreeObject) curr_entry.object); } @@ -585,17 +503,14 @@ public void overlapping_objects_with_clearance(ConvexShape p_shape, int p_layer, * If p_layer < 0, the layer is ignored. */ public Set overlapping_items_with_clearance(ConvexShape p_shape, int p_layer, int[] p_ignore_net_nos, - int p_clearance_class) - { + int p_clearance_class) { Set overlaps = new TreeSet(); this.overlapping_objects_with_clearance(p_shape, p_layer, p_ignore_net_nos, p_clearance_class, overlaps); Set result = new TreeSet(); - for (SearchTreeObject curr_object : overlaps) - { - if (curr_object instanceof Item) - { + for (SearchTreeObject curr_object : overlaps) { + if (curr_object instanceof Item) { result.add((Item) curr_object); } } @@ -610,15 +525,11 @@ public Set overlapping_items_with_clearance(ConvexShape p_shape, int p_lay * If p_layer < 0, the layer is ignored. */ public Collection overlapping_tree_entries_with_clearance(ConvexShape p_shape, int p_layer, - int[] p_ignore_net_nos, int p_clearance_class) - { + int[] p_ignore_net_nos, int p_clearance_class) { Collection result = new LinkedList(); - if (this.is_clearance_compensation_used()) - { + if (this.is_clearance_compensation_used()) { this.overlapping_tree_entries(p_shape, p_layer, p_ignore_net_nos, result); - } - else - { + } else { this.overlapping_tree_entries_with_clearance(p_shape, p_layer, p_ignore_net_nos, p_clearance_class, result); } @@ -637,26 +548,21 @@ public Collection overlapping_tree_entries_with_clearance(ConvexShape * are ignored. */ public Collection complete_shape(IncompleteFreeSpaceExpansionRoom p_room, int p_net_no, - SearchTreeObject p_ignore_object, TileShape p_ignore_shape) - { - if (p_room.get_contained_shape() == null) - { + SearchTreeObject p_ignore_object, TileShape p_ignore_shape) { + if (p_room.get_contained_shape() == null) { System.out.println("ShapeSearchTree.complete_shape: p_shape_to_be_contained != null expected"); return new LinkedList(); } - if (this.root == null) - { + if (this.root == null) { return new LinkedList(); } TileShape start_shape = board.get_bounding_box(); - if (p_room.get_shape() != null) - { + if (p_room.get_shape() != null) { start_shape = start_shape.intersection(p_room.get_shape()); } RegularTileShape bounding_shape = start_shape.bounding_shape(this.bounding_directions); Collection result = new LinkedList(); - if (start_shape.dimension() == 2) - { + if (start_shape.dimension() == 2) { IncompleteFreeSpaceExpansionRoom new_room = new IncompleteFreeSpaceExpansionRoom(start_shape, p_room.get_layer(), p_room.get_contained_shape()); result.add(new_room); @@ -666,50 +572,40 @@ public Collection complete_shape(IncompleteFre TreeNode curr_node; int room_layer = p_room.get_layer(); - for (;;) - { + for (; ; ) { curr_node = this.node_stack.pop(); - if (curr_node == null) - { + if (curr_node == null) { break; } - if (curr_node.bounding_shape.intersects(bounding_shape)) - { - if (curr_node instanceof Leaf) - { + if (curr_node.bounding_shape.intersects(bounding_shape)) { + if (curr_node instanceof Leaf) { Leaf curr_leaf = (Leaf) curr_node; SearchTreeObject curr_object = (SearchTreeObject) curr_leaf.object; int shape_index = curr_leaf.shape_index_in_object; - if (curr_object.is_trace_obstacle(p_net_no) && curr_object.shape_layer(shape_index) == room_layer && curr_object != p_ignore_object) - { + if (curr_object.is_trace_obstacle(p_net_no) && curr_object.shape_layer(shape_index) == room_layer && curr_object != p_ignore_object) { TileShape curr_object_shape = curr_object.get_tree_shape(this, shape_index); Collection new_result = new LinkedList(); RegularTileShape new_bounding_shape = IntOctagon.EMPTY; - for (IncompleteFreeSpaceExpansionRoom curr_incomplete_room : result) - { + for (IncompleteFreeSpaceExpansionRoom curr_incomplete_room : result) { boolean something_changed = false; TileShape intersection = curr_incomplete_room.get_shape().intersection(curr_object_shape); - if (intersection.dimension() == 2) - { + if (intersection.dimension() == 2) { boolean ignore_expansion_room = curr_object instanceof CompleteFreeSpaceExpansionRoom && p_ignore_shape != null && p_ignore_shape.contains(intersection); // cannot happen in free angle roouting, because then expansion_rooms // may not overlap. Therefore that can be removed as soon as special // function for 45-degree routing is used. - if (!ignore_expansion_room) - { + if (!ignore_expansion_room) { something_changed = true; new_result.addAll(restrain_shape(curr_incomplete_room, curr_object_shape)); - for (IncompleteFreeSpaceExpansionRoom tmp_room : new_result) - { + for (IncompleteFreeSpaceExpansionRoom tmp_room : new_result) { new_bounding_shape = new_bounding_shape.union(tmp_room.get_shape().bounding_shape(this.bounding_directions)); } } } - if (!something_changed) - { + if (!something_changed) { new_result.add(curr_incomplete_room); new_bounding_shape = new_bounding_shape.union(curr_incomplete_room.get_shape().bounding_shape(this.bounding_directions)); } @@ -717,9 +613,7 @@ public Collection complete_shape(IncompleteFre result = new_result; bounding_shape = new_bounding_shape; } - } - else - { + } else { this.node_stack.push(((InnerNode) curr_node).first_child); this.node_stack.push(((InnerNode) curr_node).second_child); } @@ -735,8 +629,7 @@ public Collection complete_shape(IncompleteFre * the result room. If that is not possible, several rooms are returned with shapes, * which intersect with p_incomplete_room.get_contained_shape(). */ - private Collection restrain_shape(IncompleteFreeSpaceExpansionRoom p_incomplete_room, TileShape p_obstacle_shape) - { + private Collection restrain_shape(IncompleteFreeSpaceExpansionRoom p_incomplete_room, TileShape p_obstacle_shape) { // Search the edge line of p_obstacle_shape, so that p_shape_to_be_contained // are on the right side of this line, and that the line segment // intersects with the interiour of p_shape. @@ -749,21 +642,17 @@ private Collection restrain_shape(IncompleteFr Collection result = new LinkedList(); TileShape room_shape = p_incomplete_room.get_shape(); int layer = p_incomplete_room.get_layer(); - if (shape_to_be_contained.is_empty()) - { - if (this.board.get_test_level().ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (shape_to_be_contained.is_empty()) { + if (this.board.get_test_level().ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("ShapeSearchTree.restrain_shape: p_shape_to_be_contained is empty"); } return result; } Line cut_line = null; double cut_line_distance = -1; - for (int i = 0; i < obstacle_simplex.border_line_count(); ++i) - { + for (int i = 0; i < obstacle_simplex.border_line_count(); ++i) { LineSegment curr_line_segment = new LineSegment(obstacle_simplex, i); - if (room_shape.is_intersected_interiour_by(curr_line_segment)) - { + if (room_shape.is_intersected_interiour_by(curr_line_segment)) { // otherwise curr_object may not touch the intersection // of p_shape with the half_plane defined by the cut_line. // That may lead to problems when creating the ExpansionRooms. @@ -771,44 +660,34 @@ private Collection restrain_shape(IncompleteFr double curr_min_distance = shape_to_be_contained.distance_to_the_left(curr_line); - if (curr_min_distance > cut_line_distance) - { + if (curr_min_distance > cut_line_distance) { cut_line_distance = curr_min_distance; cut_line = curr_line.opposite(); } } } - if (cut_line != null) - { + if (cut_line != null) { TileShape result_piece = TileShape.get_instance(cut_line); - if (room_shape != null) - { + if (room_shape != null) { result_piece = room_shape.intersection(result_piece); } - if (result_piece.dimension() >= 2) - { + if (result_piece.dimension() >= 2) { result.add(new IncompleteFreeSpaceExpansionRoom(result_piece, layer, shape_to_be_contained)); } - } - else - { + } else { // There is no cut line, so that all p_shape_to_be_contained is // completely on the right side of that line. Search a cut line, so that // at least part of p_shape_to_be_contained is on the right side. - if (shape_to_be_contained.dimension() < 1) - { + if (shape_to_be_contained.dimension() < 1) { // There is already a completed expansion room around p_shape_to_be_contained. return result; } - for (int i = 0; i < obstacle_simplex.border_line_count(); ++i) - { + for (int i = 0; i < obstacle_simplex.border_line_count(); ++i) { LineSegment curr_line_segment = new LineSegment(obstacle_simplex, i); - if (room_shape.is_intersected_interiour_by(curr_line_segment)) - { + if (room_shape.is_intersected_interiour_by(curr_line_segment)) { Line curr_line = obstacle_simplex.border_line(i); - if (shape_to_be_contained.side_of(curr_line) == Side.COLLINEAR) - { + if (shape_to_be_contained.side_of(curr_line) == Side.COLLINEAR) { // curr_line intersects with the interiour of p_shape_to_be_contained cut_line = curr_line.opposite(); break; @@ -817,8 +696,7 @@ private Collection restrain_shape(IncompleteFr } - if (cut_line == null) - { + if (cut_line == null) { // cut line not found, parts or the whole of p_shape may be already // occupied from somewhere else. return result; @@ -828,30 +706,22 @@ private Collection restrain_shape(IncompleteFr TileShape new_shape_to_be_contained = shape_to_be_contained.intersection(cut_half_plane); TileShape result_piece; - if (room_shape == null) - { + if (room_shape == null) { result_piece = cut_half_plane; - } - else - { + } else { result_piece = room_shape.intersection(cut_half_plane); } - if (result_piece.dimension() >= 2) - { + if (result_piece.dimension() >= 2) { result.add(new IncompleteFreeSpaceExpansionRoom(result_piece, layer, new_shape_to_be_contained)); } TileShape opposite_half_plane = TileShape.get_instance(cut_line.opposite()); TileShape rest_piece; - if (room_shape == null) - { + if (room_shape == null) { rest_piece = opposite_half_plane; - } - else - { + } else { rest_piece = room_shape.intersection(opposite_half_plane); } - if (rest_piece.dimension() >= 2) - { + if (rest_piece.dimension() >= 2) { TileShape rest_shape_to_be_contained = shape_to_be_contained.intersection(opposite_half_plane); IncompleteFreeSpaceExpansionRoom rest_incomplete_room = new IncompleteFreeSpaceExpansionRoom(rest_piece, layer, rest_shape_to_be_contained); result.addAll(restrain_shape(rest_incomplete_room, obstacle_simplex)); @@ -864,40 +734,30 @@ private Collection restrain_shape(IncompleteFr * Reduces the first or last shape of p_trace at a tie pin, so that the autorouter algorithm * can find a connection for a different net. */ - public void reduce_trace_shape_at_tie_pin(Pin p_tie_pin, PolylineTrace p_trace) - { + public void reduce_trace_shape_at_tie_pin(Pin p_tie_pin, PolylineTrace p_trace) { TileShape pin_shape = p_tie_pin.get_tree_shape_on_layer(this, p_trace.get_layer()); FloatPoint compare_corner; int trace_shape_no; - if (p_trace.first_corner().equals(p_tie_pin.get_center())) - { + if (p_trace.first_corner().equals(p_tie_pin.get_center())) { trace_shape_no = 0; compare_corner = p_trace.polyline().corner_approx(1); - } - else if (p_trace.last_corner().equals(p_tie_pin.get_center())) - { + } else if (p_trace.last_corner().equals(p_tie_pin.get_center())) { trace_shape_no = p_trace.corner_count() - 2; compare_corner = p_trace.polyline().corner_approx(p_trace.corner_count() - 2); - } - else - { + } else { return; } TileShape trace_shape = p_trace.get_tree_shape(this, trace_shape_no); TileShape intersection = trace_shape.intersection(pin_shape); - if (intersection.dimension() < 2) - { + if (intersection.dimension() < 2) { return; } TileShape[] shape_pieces = trace_shape.cutout(pin_shape); TileShape new_trace_shape = Simplex.EMPTY; - for (int i = 0; i < shape_pieces.length; ++i) - { - if (shape_pieces[i].dimension() == 2) - { - if (new_trace_shape == Simplex.EMPTY || shape_pieces[i].contains(compare_corner)) - { + for (int i = 0; i < shape_pieces.length; ++i) { + if (shape_pieces[i].dimension() == 2) { + if (new_trace_shape == Simplex.EMPTY || shape_pieces[i].contains(compare_corner)) { new_trace_shape = shape_pieces[i]; } } @@ -909,21 +769,16 @@ else if (p_trace.last_corner().equals(p_tie_pin.get_center())) * Changes the shape with index p_shape_no of this item to p_new_shape * and updates the entry in the tree. */ - void change_item_shape(Item p_item, int p_shape_no, TileShape p_new_shape) - { + void change_item_shape(Item p_item, int p_shape_no, TileShape p_new_shape) { Leaf[] old_entries = p_item.get_search_tree_entries(this); Leaf[] new_leaf_arr = new Leaf[old_entries.length]; TileShape[] new_precalculated_tree_shapes = new TileShape[old_entries.length]; remove_leaf(old_entries[p_shape_no]); - for (int i = 0; i < new_precalculated_tree_shapes.length; ++i) - { - if (i == p_shape_no) - { + for (int i = 0; i < new_precalculated_tree_shapes.length; ++i) { + if (i == p_shape_no) { new_precalculated_tree_shapes[i] = p_new_shape; - } - else - { + } else { new_precalculated_tree_shapes[i] = p_item.get_tree_shape(this, i); new_leaf_arr[i] = old_entries[i]; } @@ -933,42 +788,28 @@ void change_item_shape(Item p_item, int p_shape_no, TileShape p_new_shape) p_item.set_search_tree_entries(new_leaf_arr, this); } - TileShape[] calculate_tree_shapes(DrillItem p_drill_item) - { - if (this.board == null) - { + TileShape[] calculate_tree_shapes(DrillItem p_drill_item) { + if (this.board == null) { return new TileShape[0]; } TileShape[] result = new TileShape[p_drill_item.tile_shape_count()]; - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { Shape curr_shape = p_drill_item.get_shape(i); - if (curr_shape == null) - { + if (curr_shape == null) { result[i] = null; - } - else - { + } else { TileShape curr_tile_shape; - if (this.board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (this.board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { curr_tile_shape = curr_shape.bounding_box(); - } - else if (this.board.rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (this.board.rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) { curr_tile_shape = curr_shape.bounding_octagon(); - } - else - { + } else { curr_tile_shape = curr_shape.bounding_tile(); } int offset_width = this.clearance_compensation_value(p_drill_item.clearance_class_no(), p_drill_item.shape_layer(i)); - if (curr_tile_shape == null) - { + if (curr_tile_shape == null) { System.out.println("ShapeSearchTree.calculate_tree_shapes: shape is null"); - } - else - { + } else { curr_tile_shape = (TileShape) curr_tile_shape.enlarge(offset_width); } result[i] = curr_tile_shape; @@ -977,66 +818,53 @@ else if (this.board.rules.get_trace_angle_restriction() == AngleRestriction.FORT return result; } - TileShape[] calculate_tree_shapes(ObstacleArea p_obstacle_area) - { - if (this.board == null) - { + TileShape[] calculate_tree_shapes(ObstacleArea p_obstacle_area) { + if (this.board == null) { return new TileShape[0]; } TileShape[] convex_shapes = p_obstacle_area.split_to_convex(); - if (convex_shapes == null) - { + if (convex_shapes == null) { return new TileShape[0]; } double max_tree_shape_width = 50000; - if (this.board.communication.host_cad_exists()) - { + if (this.board.communication.host_cad_exists()) { max_tree_shape_width = Math.min(500 * this.board.communication.get_resolution(Unit.MIL), max_tree_shape_width); - // Problem with low resolution on Kicad. - // Called only for designs from host cad systems because otherwise the old sample.dsn gets to many tree shapes. + // Problem with low resolution on Kicad. + // Called only for designs from host cad systems because otherwise the old sample.dsn gets to many tree shapes. } Collection tree_shape_list = new LinkedList(); - for (int i = 0; i < convex_shapes.length; ++i) - { + for (int i = 0; i < convex_shapes.length; ++i) { TileShape curr_convex_shape = convex_shapes[i]; int offset_width = this.clearance_compensation_value(p_obstacle_area.clearance_class_no(), p_obstacle_area.get_layer()); curr_convex_shape = (TileShape) curr_convex_shape.enlarge(offset_width); TileShape[] curr_tree_shapes = curr_convex_shape.divide_into_sections(max_tree_shape_width); - for (int j = 0; j < curr_tree_shapes.length; ++j) - { + for (int j = 0; j < curr_tree_shapes.length; ++j) { tree_shape_list.add(curr_tree_shapes[j]); } } TileShape[] result = new TileShape[tree_shape_list.size()]; Iterator it = tree_shape_list.iterator(); - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = it.next(); } return result; } - TileShape[] calculate_tree_shapes(BoardOutline p_board_outline) - { - if (this.board == null) - { + TileShape[] calculate_tree_shapes(BoardOutline p_board_outline) { + if (this.board == null) { return new TileShape[0]; } TileShape[] result; - if (p_board_outline.keepout_outside_outline_generated()) - { + if (p_board_outline.keepout_outside_outline_generated()) { TileShape[] convex_shapes = p_board_outline.get_keepout_area().split_to_convex(); - if (convex_shapes == null) - { + if (convex_shapes == null) { return new TileShape[0]; } Collection tree_shape_list = new LinkedList(); - for (int layer_no = 0; layer_no < this.board.layer_structure.arr.length; ++layer_no) - { - for (int i = 0; i < convex_shapes.length; ++i) - { + for (int layer_no = 0; layer_no < this.board.layer_structure.arr.length; ++layer_no) { + for (int i = 0; i < convex_shapes.length; ++i) { TileShape curr_convex_shape = convex_shapes[i]; int offset_width = this.clearance_compensation_value(p_board_outline.clearance_class_no(), 0); curr_convex_shape = (TileShape) curr_convex_shape.enlarge(offset_width); @@ -1045,27 +873,21 @@ TileShape[] calculate_tree_shapes(BoardOutline p_board_outline) } result = new TileShape[tree_shape_list.size()]; Iterator it = tree_shape_list.iterator(); - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = it.next(); } - } - else - { + } else { // Only the line shapes of the outline are inserted as obstales into the tree. result = new TileShape[p_board_outline.line_count() * this.board.layer_structure.arr.length]; int half_width = p_board_outline.get_half_width(); Line[] curr_line_arr = new Line[3]; int curr_no = 0; - for (int layer_no = 0; layer_no < this.board.layer_structure.arr.length; ++layer_no) - { - for (int shape_no = 0; shape_no < p_board_outline.shape_count(); ++shape_no) - { + for (int layer_no = 0; layer_no < this.board.layer_structure.arr.length; ++layer_no) { + for (int shape_no = 0; shape_no < p_board_outline.shape_count(); ++shape_no) { PolylineShape curr_outline_shape = p_board_outline.get_shape(shape_no); int border_line_count = curr_outline_shape.border_line_count(); curr_line_arr[0] = curr_outline_shape.border_line(border_line_count - 1); - for (int i = 0; i < border_line_count; ++i) - { + for (int i = 0; i < border_line_count; ++i) { curr_line_arr[1] = curr_outline_shape.border_line(i); curr_line_arr[2] = curr_outline_shape.border_line((i + 1) % border_line_count); Polyline tmp_polyline = new Polyline(curr_line_arr); @@ -1084,8 +906,7 @@ TileShape[] calculate_tree_shapes(BoardOutline p_board_outline) * Used for creating the shapes of a polyline_trace for this tree. * Overwritten in derived classes. */ - TileShape offset_shape(Polyline p_polyline, int p_half_width, int p_no) - { + TileShape offset_shape(Polyline p_polyline, int p_half_width, int p_no) { return p_polyline.offset_shape(p_half_width, p_no); } @@ -1094,22 +915,18 @@ TileShape offset_shape(Polyline p_polyline, int p_half_width, int p_no) * Overwritten in derived classes. */ public TileShape[] offset_shapes(Polyline p_polyline, int p_half_width, - int p_from_no, int p_to_no) - { + int p_from_no, int p_to_no) { return p_polyline.offset_shapes(p_half_width, p_from_no, p_to_no); } - TileShape[] calculate_tree_shapes(PolylineTrace p_trace) - { - if (this.board == null) - { + TileShape[] calculate_tree_shapes(PolylineTrace p_trace) { + if (this.board == null) { return new TileShape[0]; } int offset_width = p_trace.get_half_width() + this.clearance_compensation_value(p_trace.clearance_class_no(), p_trace.get_layer()); TileShape[] result = new TileShape[p_trace.tile_shape_count()]; - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = this.offset_shape(p_trace.polyline(), offset_width, i); } return result; @@ -1121,88 +938,66 @@ TileShape[] calculate_tree_shapes(PolylineTrace p_trace) * with vias. */ protected Collection divide_large_room( - Collection p_room_list, IntBox p_board_bounding_box) - { - if (p_room_list.size() != 1) - { + Collection p_room_list, IntBox p_board_bounding_box) { + if (p_room_list.size() != 1) { return p_room_list; } IncompleteFreeSpaceExpansionRoom curr_room = p_room_list.iterator().next(); IntBox room_bounding_box = curr_room.get_shape().bounding_box(); - if (2 * room_bounding_box.height() <= p_board_bounding_box.height() || 2 * room_bounding_box.width() <= p_board_bounding_box.width()) - { + if (2 * room_bounding_box.height() <= p_board_bounding_box.height() || 2 * room_bounding_box.width() <= p_board_bounding_box.width()) { return p_room_list; } double max_section_width = 0.5 * Math.max(p_board_bounding_box.height(), p_board_bounding_box.width()); TileShape[] section_arr = curr_room.get_shape().divide_into_sections(max_section_width); Collection result = new LinkedList(); - for (TileShape curr_section : section_arr) - { + for (TileShape curr_section : section_arr) { TileShape curr_shape_to_be_contained = curr_section.intersection(curr_room.get_contained_shape()); IncompleteFreeSpaceExpansionRoom curr_section_room = new IncompleteFreeSpaceExpansionRoom(curr_section, curr_room.get_layer(), - curr_shape_to_be_contained); + curr_shape_to_be_contained); result.add(curr_section_room); } return result; } - boolean validate_entries(Item p_item) - { + boolean validate_entries(Item p_item) { Leaf[] curr_tree_entries = p_item.get_search_tree_entries(this); - for (int i = 0; i < curr_tree_entries.length; ++i) - { + for (int i = 0; i < curr_tree_entries.length; ++i) { Leaf curr_leaf = curr_tree_entries[i]; - if (curr_leaf.shape_index_in_object != i) - { + if (curr_leaf.shape_index_in_object != i) { System.out.println("tree entry inconsistent for Item"); return false; } } return true; } - /** - * The clearance class number for which the shapes of this tree is compensated. - * If compensated_clearance_class_no = 0, the shapes are not compensated. - */ - public final int compensated_clearance_class_no; - protected final BasicBoard board; - /** used in objects of class EntrySortedByClearance */ - static private int last_generated_id_no = 0; /** * created for sorting Items according to their clearance * to p_cl_type on layer p_layer */ - static private class EntrySortedByClearance implements Comparable - { + static private class EntrySortedByClearance implements Comparable { - EntrySortedByClearance(Leaf p_leaf, int p_clearance) - { + private final int entry_id_no; + Leaf leaf; + int clearance; + EntrySortedByClearance(Leaf p_leaf, int p_clearance) { leaf = p_leaf; clearance = p_clearance; - if (last_generated_id_no >= Integer.MAX_VALUE) - { + if (last_generated_id_no >= Integer.MAX_VALUE) { last_generated_id_no = 0; - } - else - { + } else { ++last_generated_id_no; } entry_id_no = last_generated_id_no; } - public int compareTo(EntrySortedByClearance p_other) - { - if (clearance != p_other.clearance) - { + public int compareTo(EntrySortedByClearance p_other) { + if (clearance != p_other.clearance) { return Signum.as_int(clearance - p_other.clearance); } return entry_id_no - p_other.entry_id_no; } - Leaf leaf; - int clearance; - private final int entry_id_no; } } diff --git a/src/main/java/net/freerouting/board/ShapeSearchTree45Degree.java b/src/main/java/net/freerouting/board/ShapeSearchTree45Degree.java index ff82bf96..e4e0bfe5 100644 --- a/src/main/java/net/freerouting/board/ShapeSearchTree45Degree.java +++ b/src/main/java/net/freerouting/board/ShapeSearchTree45Degree.java @@ -20,35 +20,87 @@ */ package net.freerouting.board; +import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.IncompleteFreeSpaceExpansionRoom; +import net.freerouting.geometry.planar.*; + import java.util.Collection; import java.util.LinkedList; -import net.freerouting.geometry.planar.FortyfiveDegreeBoundingDirections; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Shape; -import net.freerouting.geometry.planar.IntOctagon; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.Side; -import net.freerouting.geometry.planar.Line; - -import net.freerouting.autoroute.IncompleteFreeSpaceExpansionRoom; -import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; - /** * A special simple ShapeSearchtree, where the shapes are of class IntOctagon. * It is used in the 45-degree autorouter algorithm. * * @author Alfons Wirtz */ -public class ShapeSearchTree45Degree extends ShapeSearchTree -{ +public class ShapeSearchTree45Degree extends ShapeSearchTree { - /** Creates a new instance of ShapeSearchTree45Degree */ - public ShapeSearchTree45Degree(BasicBoard p_board, int p_compensated_clearance_class_no) - { + /** + * Creates a new instance of ShapeSearchTree45Degree + */ + public ShapeSearchTree45Degree(BasicBoard p_board, int p_compensated_clearance_class_no) { super(FortyfiveDegreeBoundingDirections.INSTANCE, p_board, p_compensated_clearance_class_no); } + /** + * Checks, if the border line segment with index p_obstacle_border_line_no intersects with the inside + * of p_room_shape. + */ + private static boolean obstacle_segment_touches_inside(IntOctagon p_obstacle_shape, + int p_obstacle_border_line_no, IntOctagon p_room_shape) { + int curr_border_line_no = p_obstacle_border_line_no; + int curr_obstacle_corner_x = p_obstacle_shape.corner_x(p_obstacle_border_line_no); + int curr_obstacle_corner_y = p_obstacle_shape.corner_y(p_obstacle_border_line_no); + for (int j = 0; j < 5; ++j) { + + if (p_room_shape.side_of_border_line(curr_obstacle_corner_x, curr_obstacle_corner_y, + curr_border_line_no) != Side.ON_THE_LEFT) { + return false; + } + curr_border_line_no = (curr_border_line_no + 1) % 8; + } + + int next_obstacle_border_line_no = (p_obstacle_border_line_no + 1) % 8; + int next_obstacle_corner_x = p_obstacle_shape.corner_x(next_obstacle_border_line_no); + int next_obstacle_corner_y = p_obstacle_shape.corner_y(next_obstacle_border_line_no); + curr_border_line_no = (p_obstacle_border_line_no + 5) % 8; + for (int j = 0; j < 3; ++j) { + if (p_room_shape.side_of_border_line(next_obstacle_corner_x, next_obstacle_corner_y, + curr_border_line_no) != Side.ON_THE_LEFT) { + return false; + } + curr_border_line_no = (curr_border_line_no + 1) % 8; + } + return true; + } + + private static double signed_line_distance(IntOctagon p_obstacle_shape, int p_obstacle_line_no, IntOctagon p_contained_shape) { + double result; + if (p_obstacle_line_no == 0) { + result = p_obstacle_shape.ly - p_contained_shape.uy; + } else if (p_obstacle_line_no == 2) { + result = p_contained_shape.lx - p_obstacle_shape.rx; + } else if (p_obstacle_line_no == 4) { + result = p_contained_shape.ly - p_obstacle_shape.uy; + } else if (p_obstacle_line_no == 6) { + result = p_obstacle_shape.lx - p_contained_shape.rx; + } + // factor 0.5 used instead to 1 / sqrt(2) to prefer orthogonal lines slightly to diagonal restraining lines. + else if (p_obstacle_line_no == 1) { + result = 0.5 * (p_contained_shape.ulx - p_obstacle_shape.lrx); + } else if (p_obstacle_line_no == 3) { + result = 0.5 * (p_contained_shape.llx - p_obstacle_shape.urx); + } else if (p_obstacle_line_no == 5) { + result = 0.5 * (p_obstacle_shape.ulx - p_contained_shape.lrx); + } else if (p_obstacle_line_no == 7) { + result = 0.5 * (p_obstacle_shape.llx - p_contained_shape.urx); + } else { + System.out.println("ShapeSearchTree45Degree.signed_line_distance: p_obstacle_line_no out of range"); + result = 0; + } + return result; + } + /** * Calculates a new incomplete room with a maximal TileShape contained in the shape of p_room, * which may overlap only with items of the input net on the input layer. @@ -58,23 +110,18 @@ public ShapeSearchTree45Degree(BasicBoard p_board, int p_compensated_clearance_c * The result room is not yet complete, because its doors are not yet calculated. */ public Collection complete_shape(IncompleteFreeSpaceExpansionRoom p_room, - int p_net_no, SearchTreeObject p_ignore_object, TileShape p_ignore_shape) - { - if (!(p_room.get_contained_shape().is_IntOctagon()) && this.board.get_test_level() != TestLevel.RELEASE_VERSION) - { + int p_net_no, SearchTreeObject p_ignore_object, TileShape p_ignore_shape) { + if (!(p_room.get_contained_shape().is_IntOctagon()) && this.board.get_test_level() != TestLevel.RELEASE_VERSION) { System.out.println("ShapeSearchTree45Degree.complete_shape: unexpected p_shape_to_be_contained"); return new LinkedList(); } IntOctagon shape_to_be_contained = p_room.get_contained_shape().bounding_octagon(); - if (this.root == null) - { + if (this.root == null) { return new LinkedList(); } IntOctagon start_shape = board.get_bounding_box().bounding_octagon(); - if (p_room.get_shape() != null) - { - if (!(p_room.get_shape() instanceof IntOctagon)) - { + if (p_room.get_shape() != null) { + if (!(p_room.get_shape() instanceof IntOctagon)) { System.out.println("ShapeSearchTree45Degree.complete_shape: p_start_shape of type IntOctagon expected"); return new LinkedList(); } @@ -88,42 +135,32 @@ public Collection complete_shape(IncompleteFre this.node_stack.push(this.root); TreeNode curr_node; - for (;;) - { + for (; ; ) { curr_node = this.node_stack.pop(); - if (curr_node == null) - { + if (curr_node == null) { break; } - if (curr_node.bounding_shape.intersects(bounding_shape)) - { - if (curr_node instanceof Leaf) - { + if (curr_node.bounding_shape.intersects(bounding_shape)) { + if (curr_node instanceof Leaf) { Leaf curr_leaf = (Leaf) curr_node; SearchTreeObject curr_object = (SearchTreeObject) curr_leaf.object; boolean is_obstacle = curr_object.is_trace_obstacle(p_net_no); int shape_index = curr_leaf.shape_index_in_object; - if (is_obstacle && curr_object.shape_layer(shape_index) == room_layer && curr_object != p_ignore_object) - { + if (is_obstacle && curr_object.shape_layer(shape_index) == room_layer && curr_object != p_ignore_object) { IntOctagon curr_object_shape = curr_object.get_tree_shape(this, shape_index).bounding_octagon(); Collection new_result = new LinkedList(); IntOctagon new_bounding_shape = IntOctagon.EMPTY; - for (IncompleteFreeSpaceExpansionRoom curr_room : result) - { + for (IncompleteFreeSpaceExpansionRoom curr_room : result) { IntOctagon curr_shape = (IntOctagon) curr_room.get_shape(); - if (curr_shape.overlaps(curr_object_shape)) - { - if (curr_object instanceof CompleteFreeSpaceExpansionRoom && p_ignore_shape != null) - { + if (curr_shape.overlaps(curr_object_shape)) { + if (curr_object instanceof CompleteFreeSpaceExpansionRoom && p_ignore_shape != null) { IntOctagon intersection = curr_shape.intersection(curr_object_shape); - if (p_ignore_shape.contains(intersection)) - { + if (p_ignore_shape.contains(intersection)) { // ignore also all objects, whose intersection is contained in the // 2-dim overlap-door with the from_room. - if (!p_ignore_shape.contains(curr_shape)) - { + if (!p_ignore_shape.contains(curr_shape)) { new_result.add(curr_room); new_bounding_shape = new_bounding_shape.union(curr_shape.bounding_box()); } @@ -135,13 +172,10 @@ public Collection complete_shape(IncompleteFre new_result.addAll(new_restrained_shapes); - for (IncompleteFreeSpaceExpansionRoom tmp_shape : new_result) - { + for (IncompleteFreeSpaceExpansionRoom tmp_shape : new_result) { new_bounding_shape = new_bounding_shape.union(tmp_shape.get_shape().bounding_box()); } - } - else - { + } else { new_result.add(curr_room); new_bounding_shape = new_bounding_shape.union(curr_shape.bounding_box()); } @@ -149,9 +183,7 @@ public Collection complete_shape(IncompleteFre result = new_result; bounding_shape = new_bounding_shape; } - } - else - { + } else { this.node_stack.push(((InnerNode) curr_node).first_child); this.node_stack.push(((InnerNode) curr_node).second_child); } @@ -160,11 +192,9 @@ public Collection complete_shape(IncompleteFre result = divide_large_room(result, board.get_bounding_box()); // remove rooms with shapes equal to the contained shape to prevent endless loop. java.util.Iterator it = result.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { IncompleteFreeSpaceExpansionRoom curr_room = it.next(); - if (curr_room.get_contained_shape().contains(curr_room.get_shape())) - { + if (curr_room.get_contained_shape().contains(curr_room.get_shape())) { it.remove(); } } @@ -177,62 +207,22 @@ public Collection complete_shape(IncompleteFre * with vias. */ protected Collection divide_large_room( - Collection p_room_list, IntBox p_board_bounding_box) - { + Collection p_room_list, IntBox p_board_bounding_box) { Collection result = super.divide_large_room(p_room_list, p_board_bounding_box); - for (IncompleteFreeSpaceExpansionRoom curr_room : result) - { + for (IncompleteFreeSpaceExpansionRoom curr_room : result) { curr_room.set_shape(curr_room.get_shape().bounding_octagon()); curr_room.set_contained_shape(curr_room.get_contained_shape().bounding_octagon()); } return result; } - /** - * Checks, if the border line segment with index p_obstacle_border_line_no intersects with the inside - * of p_room_shape. - */ - private static boolean obstacle_segment_touches_inside(IntOctagon p_obstacle_shape, - int p_obstacle_border_line_no, IntOctagon p_room_shape) - { - int curr_border_line_no = p_obstacle_border_line_no; - int curr_obstacle_corner_x = p_obstacle_shape.corner_x(p_obstacle_border_line_no); - int curr_obstacle_corner_y = p_obstacle_shape.corner_y(p_obstacle_border_line_no); - for (int j = 0; j < 5; ++j) - { - - if (p_room_shape.side_of_border_line(curr_obstacle_corner_x, curr_obstacle_corner_y, - curr_border_line_no) != Side.ON_THE_LEFT) - { - return false; - } - curr_border_line_no = (curr_border_line_no + 1) % 8; - } - - int next_obstacle_border_line_no = (p_obstacle_border_line_no + 1) % 8; - int next_obstacle_corner_x = p_obstacle_shape.corner_x(next_obstacle_border_line_no); - int next_obstacle_corner_y = p_obstacle_shape.corner_y(next_obstacle_border_line_no); - curr_border_line_no = (p_obstacle_border_line_no + 5) % 8; - for (int j = 0; j < 3; ++j) - { - if (p_room_shape.side_of_border_line(next_obstacle_corner_x, next_obstacle_corner_y, - curr_border_line_no) != Side.ON_THE_LEFT) - { - return false; - } - curr_border_line_no = (curr_border_line_no + 1) % 8; - } - return true; - } - /** * Restrains the shape of p_incomplete_room to a octagon shape, which does not intersect with the interiour * of p_obstacle_shape. p_incomplete_room.get_contained_shape() must be contained in the shape of * the result room. */ - private Collection restrain_shape(IncompleteFreeSpaceExpansionRoom p_incomplete_room, IntOctagon p_obstacle_shape) - { + private Collection restrain_shape(IncompleteFreeSpaceExpansionRoom p_incomplete_room, IntOctagon p_obstacle_shape) { // Search the edge line of p_obstacle_shape, so that p_shape_to_be_contained // are on the right side of this line, and that the line segment // intersects with the interiour of p_shape. @@ -242,10 +232,8 @@ private Collection restrain_shape(IncompleteFr // opposite of this line. Collection result = new LinkedList(); - if (p_incomplete_room.get_contained_shape().is_empty()) - { - if (this.board.get_test_level().ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (p_incomplete_room.get_contained_shape().is_empty()) { + if (this.board.get_test_level().ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("ShapeSearchTree45Degree.restrain_shape: p_shape_to_be_contained is empty"); } return result; @@ -255,20 +243,16 @@ private Collection restrain_shape(IncompleteFr double cut_line_distance = -1; int restraining_line_no = -1; - for (int obstacle_line_no = 0; obstacle_line_no < 8; ++obstacle_line_no) - { + for (int obstacle_line_no = 0; obstacle_line_no < 8; ++obstacle_line_no) { double curr_distance = signed_line_distance(p_obstacle_shape, obstacle_line_no, shape_to_be_contained); - if (curr_distance > cut_line_distance) - { - if (obstacle_segment_touches_inside(p_obstacle_shape, obstacle_line_no, room_shape)) - { + if (curr_distance > cut_line_distance) { + if (obstacle_segment_touches_inside(p_obstacle_shape, obstacle_line_no, room_shape)) { cut_line_distance = curr_distance; restraining_line_no = obstacle_line_no; } } } - if (cut_line_distance >= 0) - { + if (cut_line_distance >= 0) { IntOctagon restrained_shape = calc_outside_restrained_shape(p_obstacle_shape, restraining_line_no, room_shape); result.add(new IncompleteFreeSpaceExpansionRoom(restrained_shape, p_incomplete_room.get_layer(), shape_to_be_contained)); @@ -278,49 +262,40 @@ private Collection restrain_shape(IncompleteFr // There is no cut line, so that all p_shape_to_be_contained is // completely on the right side of that line. Search a cut line, so that // at least part of p_shape_to_be_contained is on the right side. - if (shape_to_be_contained.dimension() < 1) - { + if (shape_to_be_contained.dimension() < 1) { // There is already a completed expansion room around p_shape_to_be_contained. return result; } restraining_line_no = -1; - for (int obstacle_line_no = 0; obstacle_line_no < 8; ++obstacle_line_no) - { - if (obstacle_segment_touches_inside(p_obstacle_shape, obstacle_line_no, room_shape)) - { + for (int obstacle_line_no = 0; obstacle_line_no < 8; ++obstacle_line_no) { + if (obstacle_segment_touches_inside(p_obstacle_shape, obstacle_line_no, room_shape)) { Line curr_line = p_obstacle_shape.border_line(obstacle_line_no); - if (shape_to_be_contained.side_of(curr_line) == Side.COLLINEAR) - { + if (shape_to_be_contained.side_of(curr_line) == Side.COLLINEAR) { // curr_line intersects with the interiour of p_shape_to_be_contained restraining_line_no = obstacle_line_no; break; } } } - if (restraining_line_no < 0) - { + if (restraining_line_no < 0) { // cut line not found, parts or the whole of p_shape may be already // occupied from somewhere else. return result; } IntOctagon restrained_shape = calc_outside_restrained_shape(p_obstacle_shape, restraining_line_no, room_shape); - if (restrained_shape.dimension() == 2) - { + if (restrained_shape.dimension() == 2) { IntOctagon new_shape_to_be_contained = shape_to_be_contained.intersection(restrained_shape); - if (new_shape_to_be_contained.dimension() > 0) - { + if (new_shape_to_be_contained.dimension() > 0) { result.add(new IncompleteFreeSpaceExpansionRoom(restrained_shape, p_incomplete_room.get_layer(), new_shape_to_be_contained)); } } IntOctagon rest_piece = calc_inside_restrained_shape(p_obstacle_shape, restraining_line_no, room_shape); - if (rest_piece.dimension() >= 2) - { + if (rest_piece.dimension() >= 2) { TileShape rest_shape_to_be_contained = shape_to_be_contained.intersection(rest_piece); - if (rest_shape_to_be_contained.dimension() >= 0) - { + if (rest_shape_to_be_contained.dimension() >= 0) { IncompleteFreeSpaceExpansionRoom rest_incomplete_room = new IncompleteFreeSpaceExpansionRoom(rest_piece, p_incomplete_room.get_layer(), rest_shape_to_be_contained); result.addAll(restrain_shape(rest_incomplete_room, p_obstacle_shape)); } @@ -328,55 +303,11 @@ private Collection restrain_shape(IncompleteFr return result; } - private static double signed_line_distance(IntOctagon p_obstacle_shape, int p_obstacle_line_no, IntOctagon p_contained_shape) - { - double result; - if (p_obstacle_line_no == 0) - { - result = p_obstacle_shape.ly - p_contained_shape.uy; - } - else if (p_obstacle_line_no == 2) - { - result = p_contained_shape.lx - p_obstacle_shape.rx; - } - else if (p_obstacle_line_no == 4) - { - result = p_contained_shape.ly - p_obstacle_shape.uy; - } - else if (p_obstacle_line_no == 6) - { - result = p_obstacle_shape.lx - p_contained_shape.rx; - } - // factor 0.5 used instead to 1 / sqrt(2) to prefer orthogonal lines slightly to diagonal restraining lines. - else if (p_obstacle_line_no == 1) - { - result = 0.5 * (p_contained_shape.ulx - p_obstacle_shape.lrx); - } - else if (p_obstacle_line_no == 3) - { - result = 0.5 * (p_contained_shape.llx - p_obstacle_shape.urx); - } - else if (p_obstacle_line_no == 5) - { - result = 0.5 * (p_obstacle_shape.ulx - p_contained_shape.lrx); - } - else if (p_obstacle_line_no == 7) - { - result = 0.5 * (p_obstacle_shape.llx - p_contained_shape.urx); - } - else - { - System.out.println("ShapeSearchTree45Degree.signed_line_distance: p_obstacle_line_no out of range"); - result = 0; - } - return result; - } - - /** Intersects p_room_shape with the half plane defined by the outside of the borderline + /** + * Intersects p_room_shape with the half plane defined by the outside of the borderline * with index p_obstacle_line_no of p_obstacle_shape. */ - IntOctagon calc_outside_restrained_shape(IntOctagon p_obstacle_shape, int p_obstacle_line_no, IntOctagon p_room_shape) - { + IntOctagon calc_outside_restrained_shape(IntOctagon p_obstacle_shape, int p_obstacle_line_no, IntOctagon p_room_shape) { int lx = p_room_shape.lx; int ly = p_room_shape.ly; int rx = p_room_shape.rx; @@ -386,40 +317,23 @@ IntOctagon calc_outside_restrained_shape(IntOctagon p_obstacle_shape, int p_obst int llx = p_room_shape.llx; int urx = p_room_shape.urx; - if (p_obstacle_line_no == 0) - { + if (p_obstacle_line_no == 0) { uy = p_obstacle_shape.ly; - } - else if (p_obstacle_line_no == 2) - { + } else if (p_obstacle_line_no == 2) { lx = p_obstacle_shape.rx; - } - else if (p_obstacle_line_no == 4) - { + } else if (p_obstacle_line_no == 4) { ly = p_obstacle_shape.uy; - } - else if (p_obstacle_line_no == 6) - { + } else if (p_obstacle_line_no == 6) { rx = p_obstacle_shape.lx; - } - else if (p_obstacle_line_no == 1) - { + } else if (p_obstacle_line_no == 1) { ulx = p_obstacle_shape.lrx; - } - else if (p_obstacle_line_no == 3) - { + } else if (p_obstacle_line_no == 3) { llx = p_obstacle_shape.urx; - } - else if (p_obstacle_line_no == 5) - { + } else if (p_obstacle_line_no == 5) { lrx = p_obstacle_shape.ulx; - } - else if (p_obstacle_line_no == 7) - { + } else if (p_obstacle_line_no == 7) { urx = p_obstacle_shape.llx; - } - else - { + } else { System.out.println("ShapeSearchTree45Degree.calc_outside_restrained_shape: p_obstacle_line_no out of range"); } @@ -427,11 +341,11 @@ else if (p_obstacle_line_no == 7) return result.normalize(); } - /** Intersects p_room_shape with the half plane defined by the inside of the borderline + /** + * Intersects p_room_shape with the half plane defined by the inside of the borderline * with index p_obstacle_line_no of p_obstacle_shape. */ - IntOctagon calc_inside_restrained_shape(IntOctagon p_obstacle_shape, int p_obstacle_line_no, IntOctagon p_room_shape) - { + IntOctagon calc_inside_restrained_shape(IntOctagon p_obstacle_shape, int p_obstacle_line_no, IntOctagon p_room_shape) { int lx = p_room_shape.lx; int ly = p_room_shape.ly; int rx = p_room_shape.rx; @@ -441,40 +355,23 @@ IntOctagon calc_inside_restrained_shape(IntOctagon p_obstacle_shape, int p_obsta int llx = p_room_shape.llx; int urx = p_room_shape.urx; - if (p_obstacle_line_no == 0) - { + if (p_obstacle_line_no == 0) { ly = p_obstacle_shape.ly; - } - else if (p_obstacle_line_no == 2) - { + } else if (p_obstacle_line_no == 2) { rx = p_obstacle_shape.rx; - } - else if (p_obstacle_line_no == 4) - { + } else if (p_obstacle_line_no == 4) { uy = p_obstacle_shape.uy; - } - else if (p_obstacle_line_no == 6) - { + } else if (p_obstacle_line_no == 6) { lx = p_obstacle_shape.lx; - } - else if (p_obstacle_line_no == 1) - { + } else if (p_obstacle_line_no == 1) { lrx = p_obstacle_shape.lrx; - } - else if (p_obstacle_line_no == 3) - { + } else if (p_obstacle_line_no == 3) { urx = p_obstacle_shape.urx; - } - else if (p_obstacle_line_no == 5) - { + } else if (p_obstacle_line_no == 5) { ulx = p_obstacle_shape.ulx; - } - else if (p_obstacle_line_no == 7) - { + } else if (p_obstacle_line_no == 7) { llx = p_obstacle_shape.llx; - } - else - { + } else { System.out.println("ShapeSearchTree45Degree.calc_inside_restrained_shape: p_obstacle_line_no out of range"); } @@ -482,25 +379,18 @@ else if (p_obstacle_line_no == 7) return result.normalize(); } - TileShape[] calculate_tree_shapes(DrillItem p_drill_item) - { - if (this.board == null) - { + TileShape[] calculate_tree_shapes(DrillItem p_drill_item) { + if (this.board == null) { return new TileShape[0]; } TileShape[] result = new TileShape[p_drill_item.tile_shape_count()]; - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { Shape curr_shape = p_drill_item.get_shape(i); - if (curr_shape == null) - { + if (curr_shape == null) { result[i] = null; - } - else - { + } else { TileShape curr_tile_shape = curr_shape.bounding_octagon(); - if (curr_tile_shape.is_IntBox()) - { + if (curr_tile_shape.is_IntBox()) { curr_tile_shape = curr_shape.bounding_box(); // To avoid small corner cutoffs when taking the offset as an octagon. @@ -515,21 +405,17 @@ TileShape[] calculate_tree_shapes(DrillItem p_drill_item) return result; } - TileShape[] calculate_tree_shapes(ObstacleArea p_obstacle_area) - { + TileShape[] calculate_tree_shapes(ObstacleArea p_obstacle_area) { TileShape[] result = super.calculate_tree_shapes(p_obstacle_area); - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = result[i].bounding_octagon(); } return result; } - TileShape[] calculate_tree_shapes(BoardOutline p_outline) - { + TileShape[] calculate_tree_shapes(BoardOutline p_outline) { TileShape[] result = super.calculate_tree_shapes(p_outline); - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = result[i].bounding_octagon(); } return result; diff --git a/src/main/java/net/freerouting/board/ShapeSearchTree90Degree.java b/src/main/java/net/freerouting/board/ShapeSearchTree90Degree.java index 255c485f..26d28312 100644 --- a/src/main/java/net/freerouting/board/ShapeSearchTree90Degree.java +++ b/src/main/java/net/freerouting/board/ShapeSearchTree90Degree.java @@ -21,33 +21,28 @@ package net.freerouting.board; +import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; +import net.freerouting.autoroute.IncompleteFreeSpaceExpansionRoom; +import net.freerouting.geometry.planar.*; + import java.util.Collection; import java.util.LinkedList; -import net.freerouting.geometry.planar.OrthogonalBoundingDirections; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Shape; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.Polyline; - -import net.freerouting.autoroute.IncompleteFreeSpaceExpansionRoom; -import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; - /** * A special simple ShapeSearchtree, where the shapes are of class IntBox. * It is used in the 90-degree autorouter algorithm. * * @author Alfons Wirtz */ -public class ShapeSearchTree90Degree extends ShapeSearchTree -{ - - /** Creates a new instance of ShapeSearchTree90Degree */ - public ShapeSearchTree90Degree(BasicBoard p_board, int p_compensated_clearance_class_no) - { +public class ShapeSearchTree90Degree extends ShapeSearchTree { + + /** + * Creates a new instance of ShapeSearchTree90Degree + */ + public ShapeSearchTree90Degree(BasicBoard p_board, int p_compensated_clearance_class_no) { super(OrthogonalBoundingDirections.INSTANCE, p_board, p_compensated_clearance_class_no); } - + /** * Calculates a new incomplete room with a maximal TileShape contained in the shape of p_room, * which may overlap only with items of the input net on the input layer. @@ -57,27 +52,22 @@ public ShapeSearchTree90Degree(BasicBoard p_board, int p_compensated_clearance_c * The result room is not yet complete, because its doors are not yet calculated. */ public Collection complete_shape(IncompleteFreeSpaceExpansionRoom p_room, - int p_net_no, SearchTreeObject p_ignore_object, TileShape p_ignore_shape) - { - if (!(p_room.get_contained_shape() instanceof IntBox)) - { + int p_net_no, SearchTreeObject p_ignore_object, TileShape p_ignore_shape) { + if (!(p_room.get_contained_shape() instanceof IntBox)) { System.out.println("BoxShapeSearchTree.complete_shape: unexpected p_shape_to_be_contained"); return new LinkedList(); } IntBox shape_to_be_contained = (IntBox) p_room.get_contained_shape(); - if (this.root == null) - { + if (this.root == null) { return new LinkedList(); } IntBox start_shape = board.get_bounding_box(); - if (p_room.get_shape() != null) - { - if (!(p_room.get_shape() instanceof IntBox)) - { + if (p_room.get_shape() != null) { + if (!(p_room.get_shape() instanceof IntBox)) { System.out.println("BoxShapeSearchTree.complete_shape: p_start_shape of type IntBox expected"); return new LinkedList(); } - start_shape = ((IntBox)p_room.get_shape()).intersection(start_shape); + start_shape = ((IntBox) p_room.get_shape()).intersection(start_shape); } IntBox bounding_shape = start_shape; int room_layer = p_room.get_layer(); @@ -86,56 +76,44 @@ public Collection complete_shape(IncompleteFre this.node_stack.reset(); this.node_stack.push(this.root); TreeNode curr_node; - - for (;;) - { + + for (; ; ) { curr_node = this.node_stack.pop(); - if (curr_node == null) - { + if (curr_node == null) { break; } - if (curr_node.bounding_shape.intersects(bounding_shape)) - { - if (curr_node instanceof Leaf) - { + if (curr_node.bounding_shape.intersects(bounding_shape)) { + if (curr_node instanceof Leaf) { Leaf curr_leaf = (Leaf) curr_node; SearchTreeObject curr_object = (SearchTreeObject) curr_leaf.object; int shape_index = curr_leaf.shape_index_in_object; if (curr_object.is_trace_obstacle(p_net_no) && curr_object.shape_layer(shape_index) == room_layer - && curr_object != p_ignore_object) - { - + && curr_object != p_ignore_object) { + IntBox curr_object_shape = curr_object.get_tree_shape(this, shape_index).bounding_box(); Collection new_result = new LinkedList(); IntBox new_bounding_shape = IntBox.EMPTY; - for (IncompleteFreeSpaceExpansionRoom curr_room : result) - { + for (IncompleteFreeSpaceExpansionRoom curr_room : result) { IntBox curr_shape = (IntBox) curr_room.get_shape(); - if (curr_shape.overlaps(curr_object_shape)) - { + if (curr_shape.overlaps(curr_object_shape)) { if (curr_object instanceof CompleteFreeSpaceExpansionRoom - && p_ignore_shape != null ) - { + && p_ignore_shape != null) { IntBox intersection = curr_shape.intersection(curr_object_shape); - if (p_ignore_shape.contains(intersection)) - { + if (p_ignore_shape.contains(intersection)) { // ignore also all objects, whose intersection is contained in the // 2-dim overlap-door with the from_room. continue; } } - Collection new_restrained_shapes = + Collection new_restrained_shapes = restrain_shape(curr_room, curr_object_shape); new_result.addAll(new_restrained_shapes); - - - for (IncompleteFreeSpaceExpansionRoom tmp_shape : new_result) - { + + + for (IncompleteFreeSpaceExpansionRoom tmp_shape : new_result) { new_bounding_shape = new_bounding_shape.union(tmp_shape.get_shape().bounding_box()); } - } - else - { + } else { new_result.add(curr_room); new_bounding_shape = new_bounding_shape.union(curr_shape.bounding_box()); } @@ -143,24 +121,21 @@ public Collection complete_shape(IncompleteFre result = new_result; bounding_shape = new_bounding_shape; } - } - else - { - this.node_stack.push(((InnerNode)curr_node).first_child); - this.node_stack.push(((InnerNode)curr_node).second_child); + } else { + this.node_stack.push(((InnerNode) curr_node).first_child); + this.node_stack.push(((InnerNode) curr_node).second_child); } } } return result; } - + /** * Restrains the shape of p_incomplete_room to a box shape, which does not intersect with the interiour * of p_obstacle_shape. p_incomplete_room.get_contained_shape() must be contained in the shape of * the result room. */ - private Collection restrain_shape(IncompleteFreeSpaceExpansionRoom p_incomplete_room, IntBox p_obstacle_shape) - { + private Collection restrain_shape(IncompleteFreeSpaceExpansionRoom p_incomplete_room, IntBox p_obstacle_shape) { // Search the edge line of p_obstacle_shape, so that p_shape_to_be_contained // are on the right side of this line, and that the line segment // intersects with the interiour of p_shape. @@ -168,12 +143,10 @@ private Collection restrain_shape(IncompleteFr // furthest away from the shape_to_be_contained // Then insersect p_shape with the halfplane defined by the // opposite of this line. - + Collection result = new LinkedList(); - if (p_incomplete_room.get_contained_shape().is_empty()) - { - if (this.board.get_test_level().ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) - { + if (p_incomplete_room.get_contained_shape().is_empty()) { + if (this.board.get_test_level().ordinal() >= TestLevel.ALL_DEBUGGING_OUTPUT.ordinal()) { System.out.println("BoxShapeSearchTree.restrain_shape: p_shape_to_be_contained is empty"); } return result; @@ -182,177 +155,142 @@ private Collection restrain_shape(IncompleteFr IntBox shape_to_be_contained = p_incomplete_room.get_contained_shape().bounding_box(); int cut_line_distance = 0; IntBox restrained_shape = null; - - if (room_shape.ll.x < p_obstacle_shape.ur.x && room_shape.ur.x > p_obstacle_shape.ur.x - && room_shape.ur.y > p_obstacle_shape.ll.y && room_shape.ll.y < p_obstacle_shape.ur.y ) - { + + if (room_shape.ll.x < p_obstacle_shape.ur.x && room_shape.ur.x > p_obstacle_shape.ur.x + && room_shape.ur.y > p_obstacle_shape.ll.y && room_shape.ll.y < p_obstacle_shape.ur.y) { // The right line segment of the obstacle_shape intersects the interiour of p_shape int curr_distance = shape_to_be_contained.ll.x - p_obstacle_shape.ur.x; - if (curr_distance > cut_line_distance) - { + if (curr_distance > cut_line_distance) { cut_line_distance = curr_distance; restrained_shape = new IntBox(p_obstacle_shape.ur.x, room_shape.ll.y, room_shape.ur.x, room_shape.ur.y); } } - if (room_shape.ll.x < p_obstacle_shape.ll.x && room_shape.ur.x > p_obstacle_shape.ll.x - && room_shape.ur.y > p_obstacle_shape.ll.y && room_shape.ll.y < p_obstacle_shape.ur.y ) - { + if (room_shape.ll.x < p_obstacle_shape.ll.x && room_shape.ur.x > p_obstacle_shape.ll.x + && room_shape.ur.y > p_obstacle_shape.ll.y && room_shape.ll.y < p_obstacle_shape.ur.y) { // The left line segment of the obstacle_shape intersects the interiour of p_shape int curr_distance = p_obstacle_shape.ll.x - shape_to_be_contained.ur.x; - if (curr_distance > cut_line_distance) - { + if (curr_distance > cut_line_distance) { cut_line_distance = curr_distance; restrained_shape = new IntBox(room_shape.ll.x, room_shape.ll.y, p_obstacle_shape.ll.x, room_shape.ur.y); } } - if (room_shape.ll.y < p_obstacle_shape.ll.y && room_shape.ur.y > p_obstacle_shape.ll.y - && room_shape.ur.x > p_obstacle_shape.ll.x && room_shape.ll.x < p_obstacle_shape.ur.x ) - { + if (room_shape.ll.y < p_obstacle_shape.ll.y && room_shape.ur.y > p_obstacle_shape.ll.y + && room_shape.ur.x > p_obstacle_shape.ll.x && room_shape.ll.x < p_obstacle_shape.ur.x) { // The lower line segment of the obstacle_shape intersects the interiour of p_shape int curr_distance = p_obstacle_shape.ll.y - shape_to_be_contained.ur.y; - if (curr_distance > cut_line_distance) - { + if (curr_distance > cut_line_distance) { cut_line_distance = curr_distance; restrained_shape = new IntBox(room_shape.ll.x, room_shape.ll.y, room_shape.ur.x, p_obstacle_shape.ll.y); } } - if (room_shape.ll.y < p_obstacle_shape.ur.y && room_shape.ur.y > p_obstacle_shape.ur.y - && room_shape.ur.x > p_obstacle_shape.ll.x && room_shape.ll.x < p_obstacle_shape.ur.x ) - { + if (room_shape.ll.y < p_obstacle_shape.ur.y && room_shape.ur.y > p_obstacle_shape.ur.y + && room_shape.ur.x > p_obstacle_shape.ll.x && room_shape.ll.x < p_obstacle_shape.ur.x) { // The upper line segment of the obstacle_shape intersects the interiour of p_shape int curr_distance = shape_to_be_contained.ll.y - p_obstacle_shape.ur.y; - if (curr_distance > cut_line_distance) - { + if (curr_distance > cut_line_distance) { cut_line_distance = curr_distance; restrained_shape = new IntBox(room_shape.ll.x, p_obstacle_shape.ur.y, room_shape.ur.x, room_shape.ur.y); } } - if (restrained_shape != null) - { + if (restrained_shape != null) { result.add(new IncompleteFreeSpaceExpansionRoom(restrained_shape, p_incomplete_room.get_layer(), shape_to_be_contained)); return result; } - + // Now shape_to_be_contained intersects with the obstacle_shape. // shape_to_be_contained and p_shape evtl. need to be divided in two. IntBox is = shape_to_be_contained.intersection(p_obstacle_shape); - if (is.is_empty()) - { + if (is.is_empty()) { System.out.println("BoxShapeSearchTree.restrain_shape: Intersection between obstacle_shape and shape_to_be_contained expected"); return result; } IntBox new_shape_1 = null; IntBox new_shape_2 = null; - if (is.ll.x > room_shape.ll.x && is.ll.x == p_obstacle_shape.ll.x && is.ll.x < room_shape.ur.x) - { + if (is.ll.x > room_shape.ll.x && is.ll.x == p_obstacle_shape.ll.x && is.ll.x < room_shape.ur.x) { new_shape_1 = new IntBox(room_shape.ll.x, room_shape.ll.y, is.ll.x, room_shape.ur.y); new_shape_2 = new IntBox(is.ll.x, room_shape.ll.y, room_shape.ur.x, room_shape.ur.y); - } - else if (is.ur.x > room_shape.ll.x && is.ur.x == p_obstacle_shape.ur.x && is.ur.x < room_shape.ur.x) - { + } else if (is.ur.x > room_shape.ll.x && is.ur.x == p_obstacle_shape.ur.x && is.ur.x < room_shape.ur.x) { new_shape_2 = new IntBox(room_shape.ll.x, room_shape.ll.y, is.ur.x, room_shape.ur.y); new_shape_1 = new IntBox(is.ur.x, room_shape.ll.y, room_shape.ur.x, room_shape.ur.y); - } - else if (is.ll.y > room_shape.ll.y && is.ll.y == p_obstacle_shape.ll.y && is.ll.y < room_shape.ur.y) - { + } else if (is.ll.y > room_shape.ll.y && is.ll.y == p_obstacle_shape.ll.y && is.ll.y < room_shape.ur.y) { new_shape_1 = new IntBox(room_shape.ll.x, room_shape.ll.y, room_shape.ur.x, is.ll.y); new_shape_2 = new IntBox(room_shape.ll.x, is.ll.y, room_shape.ur.x, room_shape.ur.y); - } - else if (is.ur.y > room_shape.ll.y && is.ur.y == p_obstacle_shape.ur.y && is.ur.y < room_shape.ur.y) - { + } else if (is.ur.y > room_shape.ll.y && is.ur.y == p_obstacle_shape.ur.y && is.ur.y < room_shape.ur.y) { new_shape_2 = new IntBox(room_shape.ll.x, room_shape.ll.y, room_shape.ur.x, is.ur.y); new_shape_1 = new IntBox(room_shape.ll.x, is.ur.y, room_shape.ur.x, room_shape.ur.y); } - if (new_shape_1 != null) - { + if (new_shape_1 != null) { IntBox new_shape_to_be_contained = shape_to_be_contained.intersection(new_shape_1); - if (new_shape_to_be_contained.dimension() > 0) - { + if (new_shape_to_be_contained.dimension() > 0) { result.add(new IncompleteFreeSpaceExpansionRoom(new_shape_1, p_incomplete_room.get_layer(), new_shape_to_be_contained)); IncompleteFreeSpaceExpansionRoom new_incomplete_room = - new IncompleteFreeSpaceExpansionRoom( new_shape_2, p_incomplete_room.get_layer(), - shape_to_be_contained.intersection(new_shape_2)); + new IncompleteFreeSpaceExpansionRoom(new_shape_2, p_incomplete_room.get_layer(), + shape_to_be_contained.intersection(new_shape_2)); result.addAll(restrain_shape(new_incomplete_room, p_obstacle_shape)); } } return result; } - - TileShape[] calculate_tree_shapes(DrillItem p_drill_item) - { - if (this.board == null) - { + + TileShape[] calculate_tree_shapes(DrillItem p_drill_item) { + if (this.board == null) { return new TileShape[0]; } - TileShape[] result = new TileShape [p_drill_item.tile_shape_count()]; - for (int i = 0; i < result.length; ++i) - { + TileShape[] result = new TileShape[p_drill_item.tile_shape_count()]; + for (int i = 0; i < result.length; ++i) { Shape curr_shape = p_drill_item.get_shape(i); - if (curr_shape == null) - { + if (curr_shape == null) { result[i] = null; - } - else - { + } else { IntBox curr_tile_shape = curr_shape.bounding_box(); int offset_width = this.clearance_compensation_value(p_drill_item.clearance_class_no(), p_drill_item.shape_layer(i)); - if (curr_tile_shape == null) - { + if (curr_tile_shape == null) { System.out.println("BoxShapeSearchTree.calculate_tree_shapes: shape is null"); - } - else - { + } else { curr_tile_shape = curr_tile_shape.offset(offset_width); } - result [i] = curr_tile_shape; + result[i] = curr_tile_shape; } } - return result; + return result; } - - TileShape[] calculate_tree_shapes(ObstacleArea p_obstacle_area) - { + + TileShape[] calculate_tree_shapes(ObstacleArea p_obstacle_area) { TileShape[] result = super.calculate_tree_shapes(p_obstacle_area); - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = result[i].bounding_box(); } return result; } - - TileShape[] calculate_tree_shapes(BoardOutline p_outline) - { + + TileShape[] calculate_tree_shapes(BoardOutline p_outline) { TileShape[] result = super.calculate_tree_shapes(p_outline); - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = result[i].bounding_box(); } return result; } - + /** * Used for creating the shapes of a polyline_trace for this tree. */ - TileShape offset_shape(Polyline p_polyline, int p_half_width, int p_no) - { + TileShape offset_shape(Polyline p_polyline, int p_half_width, int p_no) { return p_polyline.offset_box(p_half_width, p_no); } - + /** * Used for creating the shapes of a polyline_trace for this tree. */ public TileShape[] offset_shapes(Polyline p_polyline, int p_half_width, - int p_from_no, int p_to_no) - { + int p_from_no, int p_to_no) { int from_no = Math.max(p_from_no, 0); - int to_no = Math.min(p_to_no, p_polyline.arr.length -1); - int shape_count = Math.max(to_no - from_no -1, 0); + int to_no = Math.min(p_to_no, p_polyline.arr.length - 1); + int shape_count = Math.max(to_no - from_no - 1, 0); TileShape[] shape_arr = new TileShape[shape_count]; - for (int j = from_no; j < to_no - 1; ++j) - { - shape_arr [j - from_no] = p_polyline.offset_box(p_half_width, j); + for (int j = from_no; j < to_no - 1; ++j) { + shape_arr[j - from_no] = p_polyline.offset_box(p_half_width, j); } return shape_arr; } diff --git a/src/main/java/net/freerouting/board/ShapeTraceEntries.java b/src/main/java/net/freerouting/board/ShapeTraceEntries.java index 35b436ae..689b908d 100644 --- a/src/main/java/net/freerouting/board/ShapeTraceEntries.java +++ b/src/main/java/net/freerouting/board/ShapeTraceEntries.java @@ -16,34 +16,40 @@ package net.freerouting.board; -import net.freerouting.geometry.planar.ConvexShape; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.TileShape; +import net.freerouting.geometry.planar.*; import java.util.Collection; import java.util.Iterator; - /** * Auxiliary class used by the shove functions * * @author Alfons Wirtz */ -public class ShapeTraceEntries -{ +public class ShapeTraceEntries { + private static final double c_offset_add = 1; + final Collection shove_via_list; + private final TileShape shape; + private final int layer; + private final int[] own_net_nos; + private final int cl_class; + private final RoutingBoard board; + private CalcFromSide from_side; + private EntryPoint list_anchor; + private int trace_piece_count; + private int max_stack_level; + private boolean shape_contains_trace_tails = false; + private Item found_obstacle = null; + /** * Used for shoving traces and vias out of the input shape. * p_from_side.no is the side of p_shape, from where the shove comes. * if p_from_side.no < 0, it will be calculated internally. */ ShapeTraceEntries(TileShape p_shape, int p_layer, int[] p_own_net_nos, int p_cl_type, - CalcFromSide p_from_side, RoutingBoard p_board) - { + CalcFromSide p_from_side, RoutingBoard p_board) { shape = p_shape; layer = p_layer; own_net_nos = p_own_net_nos; @@ -55,7 +61,87 @@ public class ShapeTraceEntries max_stack_level = 0; shove_via_list = new java.util.LinkedList(); } - + + public static void cutout_trace(PolylineTrace p_trace, ConvexShape p_shape, int p_cl_class) { + if (!p_trace.is_on_the_board()) { + System.out.println("ShapeTraceEntries.cutout_trace : trace is deleted"); + return; + } + ConvexShape offset_shape; + BasicBoard board = p_trace.board; + ShapeSearchTree search_tree = board.search_tree_manager.get_default_tree(); + if (search_tree.is_clearance_compensation_used()) { + double curr_offset = p_trace.get_compensated_half_width(search_tree) + c_offset_add; + offset_shape = p_shape.offset(curr_offset); + } else { + // enlarge the shape in 2 steps for symmetry reasons + double cl_offset = board.clearance_value(p_trace.clearance_class_no(), + p_cl_class, p_trace.get_layer()) + c_offset_add; + offset_shape = p_shape.offset(p_trace.get_half_width()); + offset_shape = offset_shape.offset(cl_offset); + } + Polyline trace_lines = p_trace.polyline(); + Polyline[] pieces = offset_shape.cutout(trace_lines); + if (pieces.length == 1 && pieces[0] == trace_lines) { + // nothing cut off + return; + } + if (pieces.length == 2 && offset_shape.is_outside(pieces[0].first_corner()) + && offset_shape.is_outside(pieces[1].last_corner())) { + fast_cutout_trace(p_trace, pieces[0], pieces[1]); + } else { + board.remove_item(p_trace); + for (int i = 0; i < pieces.length; ++i) { + board.insert_trace_without_cleaning(pieces[i], p_trace.get_layer(), + p_trace.get_half_width(), p_trace.net_no_arr, p_trace.clearance_class_no(), FixedState.UNFIXED); + } + } + } + + /** + * Optimized function handling the performance critical standard cutout case + */ + private static void fast_cutout_trace(PolylineTrace p_trace, Polyline p_start_piece, Polyline p_end_piece) { + BasicBoard board = p_trace.board; + board.additional_update_after_change(p_trace); + board.item_list.save_for_undo(p_trace); + PolylineTrace start_piece = new PolylineTrace(p_start_piece, p_trace.get_layer(), p_trace.get_half_width(), + p_trace.net_no_arr, p_trace.clearance_class_no(), 0, 0, FixedState.UNFIXED, board); + start_piece.board = board; + board.item_list.insert(start_piece); + start_piece.set_on_the_board(true); + + PolylineTrace end_piece = new PolylineTrace(p_end_piece, p_trace.get_layer(), p_trace.get_half_width(), + p_trace.net_no_arr, p_trace.clearance_class_no(), 0, 0, FixedState.UNFIXED, board); + end_piece.board = board; + board.item_list.insert(end_piece); + end_piece.set_on_the_board(true); + + board.search_tree_manager.reuse_entries_after_cutout(p_trace, start_piece, end_piece); + board.remove_item(p_trace); + + board.communication.observers.notify_new(start_piece); + board.communication.observers.notify_new(end_piece); + } + + static private boolean net_nos_equal(int[] p_net_nos_1, int[] p_net_nos_2) { + if (p_net_nos_1.length != p_net_nos_2.length) { + return false; + } + for (int curr_net_no_1 : p_net_nos_1) { + boolean net_no_found = false; + for (int curr_net_no_2 : p_net_nos_2) { + if (curr_net_no_1 == curr_net_no_2) { + net_no_found = true; + } + } + if (!net_no_found) { + return false; + } + } + return true; + } + /** * Stores traces and vias in p_item_list. * Returns false, if p_item_list contains obstacles, @@ -63,61 +149,44 @@ public class ShapeTraceEntries * If p_is_pad_check. the check is for vias, otherwise it is for traces. * If p_copper_sharing_allowed, overlaps with traces or pads of the own net are allowed. */ - boolean store_items(Collection p_item_list, boolean p_is_pad_check, boolean p_copper_sharing_allowed) - { + boolean store_items(Collection p_item_list, boolean p_is_pad_check, boolean p_copper_sharing_allowed) { Iterator it = p_item_list.iterator(); - while(it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - - if (!p_is_pad_check && curr_item instanceof ViaObstacleArea || curr_item instanceof ComponentObstacleArea) - { + + if (!p_is_pad_check && curr_item instanceof ViaObstacleArea || curr_item instanceof ComponentObstacleArea) { continue; } boolean contains_own_net = curr_item.shares_net_no(this.own_net_nos); if (curr_item instanceof ConductionArea && - (contains_own_net || !((ConductionArea)curr_item).get_is_obstacle())) - { + (contains_own_net || !((ConductionArea) curr_item).get_is_obstacle())) { continue; } - if (curr_item.is_shove_fixed() && !contains_own_net) - { + if (curr_item.is_shove_fixed() && !contains_own_net) { this.found_obstacle = curr_item; return false; } - if (curr_item instanceof Via) - { - if (p_is_pad_check || !contains_own_net) - { + if (curr_item instanceof Via) { + if (p_is_pad_check || !contains_own_net) { shove_via_list.add((Via) curr_item); } - } - else if (curr_item instanceof PolylineTrace) - { + } else if (curr_item instanceof PolylineTrace) { PolylineTrace curr_trace = (PolylineTrace) curr_item; - - if (!store_trace(curr_trace)) - { + + if (!store_trace(curr_trace)) { return false; } - } - else - { - if (contains_own_net) - { - if (!p_copper_sharing_allowed) - { + } else { + if (contains_own_net) { + if (!p_copper_sharing_allowed) { this.found_obstacle = curr_item; return false; } - if (p_is_pad_check && !((curr_item instanceof Pin) && ((Pin)curr_item).drill_allowed())) - { + if (p_is_pad_check && !((curr_item instanceof Pin) && ((Pin) curr_item).drill_allowed())) { this.found_obstacle = curr_item; return false; } - } - else - { + } else { this.found_obstacle = curr_item; return false; } @@ -125,47 +194,40 @@ else if (curr_item instanceof PolylineTrace) } search_from_side(); resort(); - if (!calculate_stack_levels()) - { + if (!calculate_stack_levels()) { return false; } return true; } - - + /** * calculates the next substitute trace piece. * Returns null at he end of the substitute trace list. */ - PolylineTrace next_substitute_trace_piece() - { - + PolylineTrace next_substitute_trace_piece() { + EntryPoint[] entries = pop_piece(); - if (entries == null) - { + if (entries == null) { return null; } PolylineTrace curr_trace = entries[0].trace; TileShape offset_shape; ShapeSearchTree search_tree = this.board.search_tree_manager.get_default_tree(); - if (search_tree.is_clearance_compensation_used()) - { + if (search_tree.is_clearance_compensation_used()) { double curr_offset = curr_trace.get_compensated_half_width(search_tree) + c_offset_add; - offset_shape = (TileShape)shape.offset(curr_offset); - } - else - { + offset_shape = (TileShape) shape.offset(curr_offset); + } else { // enlarge the shape in 2 steps for symmetry reasons - offset_shape = (TileShape)shape.offset(curr_trace.get_half_width()); + offset_shape = (TileShape) shape.offset(curr_trace.get_half_width()); double cl_offset = board.clearance_value(curr_trace.clearance_class_no(), cl_class, layer) + c_offset_add; offset_shape = (TileShape) offset_shape.offset(cl_offset); } int edge_count = shape.border_line_count(); int edge_diff = entries[1].edge_no - entries[0].edge_no; - + // calculate the polyline of the substitute trace - - Line [] piece_lines = new Line[edge_diff + 3]; + + Line[] piece_lines = new Line[edge_diff + 3]; // start with the intersecting line of the trace at the start entry. piece_lines[0] = entries[0].trace.polyline().arr[entries[0].trace_line_no]; // end with the intersecting line of the trace at the end entry @@ -174,21 +236,16 @@ PolylineTrace next_substitute_trace_piece() // fill the interiour lines of piece_lines with the appropriate edge // lines of the offset shape int curr_edge_no = entries[0].edge_no % edge_count; - for (int i = 1; i < piece_lines.length - 1; ++i) - { - piece_lines [i] = offset_shape.border_line(curr_edge_no); - if (curr_edge_no == edge_count - 1) - { + for (int i = 1; i < piece_lines.length - 1; ++i) { + piece_lines[i] = offset_shape.border_line(curr_edge_no); + if (curr_edge_no == edge_count - 1) { curr_edge_no = 0; - } - else - { + } else { ++curr_edge_no; } } Polyline piece_polyline = new Polyline(piece_lines); - if (piece_polyline.is_empty()) - { + if (piece_polyline.is_empty()) { // no valid trace piece, return the next one return next_substitute_trace_piece(); } @@ -196,266 +253,158 @@ PolylineTrace next_substitute_trace_piece() curr_trace.get_half_width(), curr_trace.net_no_arr, curr_trace.clearance_class_no(), 0, 0, FixedState.UNFIXED, this.board); } - + /** * returns the maximum recursion depth for shoving the obstacle traces */ - int stack_depth() - { + int stack_depth() { return max_stack_level; } - + /** * returns the number of substitute trace pieces. */ - int substitute_trace_count() - { + int substitute_trace_count() { return trace_piece_count; } - + /** * Looks if an unconnected endpoint of a trace of a foreign net * is contained in the interiour of the shape. */ - public boolean trace_tails_in_shape() - { + public boolean trace_tails_in_shape() { return this.shape_contains_trace_tails; } - + /** * Cuts out all traces in p_item_list out of the stored shape. * Traces with net number p_except_net_no are ignored */ - void cutout_traces(Collection p_item_list) - { + void cutout_traces(Collection p_item_list) { Iterator it = p_item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_item instanceof PolylineTrace && !curr_item.shares_net_no(this.own_net_nos)) - { + if (curr_item instanceof PolylineTrace && !curr_item.shares_net_no(this.own_net_nos)) { cutout_trace((PolylineTrace) curr_item, this.shape, this.cl_class); } } } - + /** * Returns the item responsible for the failing, if the shove algorithm failed. */ - Item get_found_obstacle() - { + Item get_found_obstacle() { return this.found_obstacle; } - - public static void cutout_trace(PolylineTrace p_trace, ConvexShape p_shape, int p_cl_class) - { - if (!p_trace.is_on_the_board()) - { - System.out.println("ShapeTraceEntries.cutout_trace : trace is deleted"); - return; - } - ConvexShape offset_shape; - BasicBoard board = p_trace.board; - ShapeSearchTree search_tree = board.search_tree_manager.get_default_tree(); - if (search_tree.is_clearance_compensation_used()) - { - double curr_offset = p_trace.get_compensated_half_width(search_tree) + c_offset_add; - offset_shape = p_shape.offset(curr_offset); - } - else - { - // enlarge the shape in 2 steps for symmetry reasons - double cl_offset = board.clearance_value(p_trace.clearance_class_no(), - p_cl_class, p_trace.get_layer()) + c_offset_add; - offset_shape = p_shape.offset(p_trace.get_half_width()); - offset_shape = offset_shape.offset(cl_offset); - } - Polyline trace_lines = p_trace.polyline(); - Polyline [] pieces = offset_shape.cutout(trace_lines); - if (pieces.length == 1 && pieces[0] == trace_lines) - { - // nothing cut off - return; - } - if (pieces.length == 2 && offset_shape.is_outside(pieces[0].first_corner()) - && offset_shape.is_outside(pieces[1].last_corner())) - { - fast_cutout_trace(p_trace, pieces[0], pieces[1]); - } - else - { - board.remove_item(p_trace); - for (int i = 0; i < pieces.length; ++i) - { - board.insert_trace_without_cleaning(pieces[i], p_trace.get_layer(), - p_trace.get_half_width(), p_trace.net_no_arr, p_trace.clearance_class_no(), FixedState.UNFIXED); - } - } - } - - /** Optimized function handling the performance critical standard cutout case */ - private static void fast_cutout_trace(PolylineTrace p_trace, Polyline p_start_piece, Polyline p_end_piece) - { - BasicBoard board = p_trace.board; - board.additional_update_after_change(p_trace); - board.item_list.save_for_undo(p_trace); - PolylineTrace start_piece = new PolylineTrace(p_start_piece, p_trace.get_layer(), p_trace.get_half_width(), - p_trace.net_no_arr, p_trace.clearance_class_no(), 0, 0, FixedState.UNFIXED, board); - start_piece.board = board; - board.item_list.insert(start_piece); - start_piece.set_on_the_board(true); - - PolylineTrace end_piece = new PolylineTrace(p_end_piece, p_trace.get_layer(), p_trace.get_half_width(), - p_trace.net_no_arr, p_trace.clearance_class_no(), 0, 0, FixedState.UNFIXED, board); - end_piece.board = board; - board.item_list.insert(end_piece); - end_piece.set_on_the_board(true); - - board.search_tree_manager.reuse_entries_after_cutout(p_trace, start_piece, end_piece); - board.remove_item(p_trace); - - board.communication.observers.notify_new(start_piece); - board.communication.observers.notify_new(end_piece); - } - - - /** Stores all intersection points of p_trace + + /** + * Stores all intersection points of p_trace * with the border of the internal shape enlarged by the * half width and the clearance of the corresponding trace pen. */ - private boolean store_trace( PolylineTrace p_trace) - { + private boolean store_trace(PolylineTrace p_trace) { ShapeSearchTree search_tree = this.board.search_tree_manager.get_default_tree(); TileShape offset_shape; - if (search_tree.is_clearance_compensation_used()) - { + if (search_tree.is_clearance_compensation_used()) { double curr_offset = p_trace.get_compensated_half_width(search_tree) + c_offset_add; - offset_shape = (TileShape)shape.offset(curr_offset); - } - else - { + offset_shape = (TileShape) shape.offset(curr_offset); + } else { // enlarge the shape in 2 steps for symmetry reasons double cl_offset = board.clearance_value(p_trace.clearance_class_no(), this.cl_class, p_trace.get_layer()) + c_offset_add; - offset_shape = (TileShape)shape.offset(p_trace.get_half_width()); + offset_shape = (TileShape) shape.offset(p_trace.get_half_width()); offset_shape = (TileShape) offset_shape.offset(cl_offset); } - + // using enlarge here instead offset causes problems because of a // comparison in the constructor of class EntryPoint - int [][] entries = offset_shape.entrance_points(p_trace.polyline()); - for (int i = 0; i < entries.length; ++i) - { - int [] entry_tuple = entries[i]; + int[][] entries = offset_shape.entrance_points(p_trace.polyline()); + for (int i = 0; i < entries.length; ++i) { + int[] entry_tuple = entries[i]; FloatPoint entry_approx = p_trace.polyline().arr[entry_tuple[0]]. - intersection_approx(offset_shape.border_line(entry_tuple[1])); - insert_entry_point(p_trace, entry_tuple[0],entry_tuple[1], entry_approx); + intersection_approx(offset_shape.border_line(entry_tuple[1])); + insert_entry_point(p_trace, entry_tuple[0], entry_tuple[1], entry_approx); } - + // Look, if an end point of the trace lies in the interiour of // the shape. This may be the case, if a via touches the shape - - if (!p_trace.shares_net_no(own_net_nos)) - { - if (!(p_trace.nets_normal())) - { + + if (!p_trace.shares_net_no(own_net_nos)) { + if (!(p_trace.nets_normal())) { return false; } Point end_corner = p_trace.first_corner(); Collection contact_list; - for (int i = 0; i < 2; ++i) - { - if (offset_shape.contains(end_corner)) - { - if (i == 0) - { + for (int i = 0; i < 2; ++i) { + if (offset_shape.contains(end_corner)) { + if (i == 0) { contact_list = p_trace.get_start_contacts(); - } - else - { + } else { contact_list = p_trace.get_end_contacts(); } int contact_count = 0; boolean store_end_corner = true; - + // check for contact object, which is not shovable Iterator it = contact_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item contact_item = it.next(); - if (!contact_item.is_route()) - { + if (!contact_item.is_route()) { this.found_obstacle = contact_item; return false; } - if (contact_item instanceof Trace) - { - - if (contact_item.is_shove_fixed() || ((Trace)contact_item).get_half_width() != p_trace.get_half_width() || - contact_item.clearance_class_no() != p_trace.clearance_class_no()) - { - if (offset_shape.contains_inside(end_corner)) - { + if (contact_item instanceof Trace) { + + if (contact_item.is_shove_fixed() || ((Trace) contact_item).get_half_width() != p_trace.get_half_width() || + contact_item.clearance_class_no() != p_trace.clearance_class_no()) { + if (offset_shape.contains_inside(end_corner)) { this.found_obstacle = contact_item; return false; } } - } - else if (contact_item instanceof Via) - { + } else if (contact_item instanceof Via) { TileShape via_shape = ((Via) contact_item).get_tile_shape_on_layer(layer); - + double via_trace_diff = via_shape.smallest_radius() - p_trace.get_compensated_half_width(search_tree); - if (!search_tree.is_clearance_compensation_used()) - { + if (!search_tree.is_clearance_compensation_used()) { int via_clearance = board.clearance_value(contact_item.clearance_class_no(), this.cl_class, this.layer); int trace_clearance = board.clearance_value(p_trace.clearance_class_no(), this.cl_class, this.layer); - if (trace_clearance > via_clearance) - { + if (trace_clearance > via_clearance) { via_trace_diff += via_clearance - trace_clearance; } } - if (via_trace_diff < 0) - { + if (via_trace_diff < 0) { // the via is smaller than the trace this.found_obstacle = contact_item; return false; } - - if (via_trace_diff == 0 && !offset_shape.contains_inside(end_corner)) - { + + if (via_trace_diff == 0 && !offset_shape.contains_inside(end_corner)) { // the via need not to be shoved store_end_corner = false; } } ++contact_count; } - if (contact_count == 1 && store_end_corner) - { + if (contact_count == 1 && store_end_corner) { Point projection = offset_shape.nearest_border_point(end_corner); { int projection_side = offset_shape.contains_on_border_line_no(projection); int trace_line_segment_no; // the following may not be correct because the trace may not conntain a suitable // line for the construction oof the end line of the substitute trace. - if (i == 0) - { + if (i == 0) { trace_line_segment_no = 0; - } - else - { + } else { trace_line_segment_no = p_trace.polyline().arr.length - 1; } - - if (projection_side >= 0) - { + + if (projection_side >= 0) { insert_entry_point(p_trace, trace_line_segment_no, projection_side, projection.to_float()); } } - } - else if (contact_count == 0 && offset_shape.contains_inside(end_corner)) - { + } else if (contact_count == 0 && offset_shape.contains_inside(end_corner)) { shape_contains_trace_tails = true; } } @@ -465,20 +414,16 @@ else if (contact_count == 0 && offset_shape.contains_inside(end_corner)) this.found_obstacle = p_trace; return true; } - - private void search_from_side() - { - if (this.from_side != null && this.from_side.no >= 0) - { + + private void search_from_side() { + if (this.from_side != null && this.from_side.no >= 0) { return; // from side is already legal } EntryPoint curr_node = this.list_anchor; int curr_fromside_no = 0; FloatPoint curr_entry_approx = null; - while (curr_node != null) - { - if (curr_node.trace.shares_net_no(this.own_net_nos)) - { + while (curr_node != null) { + if (curr_node.trace.shares_net_no(this.own_net_nos)) { curr_fromside_no = curr_node.edge_no; curr_entry_approx = curr_node.entry_approx; break; @@ -487,40 +432,33 @@ private void search_from_side() } this.from_side = new CalcFromSide(curr_fromside_no, curr_entry_approx); } - + /** * resorts the intersection points according to from_side_no and * removes redundant points */ - private void resort() - { + private void resort() { int edge_count = this.shape.border_line_count(); - if (this.from_side.no < 0 || from_side.no >= edge_count) - { + if (this.from_side.no < 0 || from_side.no >= edge_count) { System.out.println("ShapeTraceEntries.resort: from side not calculated"); return; } // resort the intersection points, so that they start in the // middle of from_side. - FloatPoint compare_corner_1 = shape.corner_approx(this.from_side.no); - FloatPoint compare_corner_2; - if (from_side.no == edge_count - 1) - { + FloatPoint compare_corner_1 = shape.corner_approx(this.from_side.no); + FloatPoint compare_corner_2; + if (from_side.no == edge_count - 1) { compare_corner_2 = shape.corner_approx(0); - } - else - { + } else { compare_corner_2 = shape.corner_approx(from_side.no + 1); } double from_point_dist = 0; FloatPoint from_point_projection = null; - if (from_side.border_intersection != null) - { + if (from_side.border_intersection != null) { from_point_projection = from_side.border_intersection.projection_approx(shape.border_line(from_side.no)); from_point_dist = from_point_projection.distance_square(compare_corner_1); if (from_point_dist >= - compare_corner_1.distance_square(compare_corner_2)) - { + compare_corner_1.distance_square(compare_corner_2)) { from_side = new CalcFromSide(from_side.no, null); } } @@ -528,30 +466,22 @@ private void resort() // and compare_corner_2 EntryPoint curr = list_anchor; EntryPoint prev = null; - - while (curr != null) - { - if (curr.edge_no > this.from_side.no) - { + + while (curr != null) { + if (curr.edge_no > this.from_side.no) { break; } - if (curr.edge_no == from_side.no) - { - if (from_side.border_intersection != null) - { + if (curr.edge_no == from_side.no) { + if (from_side.border_intersection != null) { FloatPoint curr_projection = curr.entry_approx.projection_approx(shape.border_line(from_side.no)); - if ( curr_projection.distance_square(compare_corner_1) >= from_point_dist + if (curr_projection.distance_square(compare_corner_1) >= from_point_dist && curr_projection.distance_square(from_point_projection) <= - curr_projection.distance_square(compare_corner_1)) - { + curr_projection.distance_square(compare_corner_1)) { break; } - } - else - { + } else { if (curr.entry_approx.distance_square(compare_corner_2) - <= curr.entry_approx.distance_square(compare_corner_1)) - { + <= curr.entry_approx.distance_square(compare_corner_1)) { break; } } @@ -559,19 +489,16 @@ private void resort() prev = curr; curr = prev.next; } - if (curr != null && curr != list_anchor) - { + if (curr != null && curr != list_anchor) { EntryPoint new_anchor = curr; - - while (curr != null) - { + + while (curr != null) { prev = curr; curr = prev.next; } prev.next = list_anchor; curr = list_anchor; - while (curr != new_anchor) - { + while (curr != new_anchor) { // add edge_count to curr.side to differentiate points // before and after the middle of from_side curr.edge_no += edge_count; @@ -583,37 +510,29 @@ private void resort() } // remove intersections between two other intersections of the same // connected set, so that only first and last intersection is kept. - if (list_anchor == null) - { + if (list_anchor == null) { return; } prev = list_anchor; int[] prev_net_nos = prev.trace.net_no_arr; - + curr = list_anchor.next; int[] curr_net_nos; EntryPoint next; - - if (curr != null) - { + + if (curr != null) { curr_net_nos = curr.trace.net_no_arr; next = curr.next; - } - else - { + } else { next = null; curr_net_nos = new int[0]; } EntryPoint before_prev = null; - while (next != null) - { + while (next != null) { int[] next_net_nos = next.trace.net_no_arr; - if (net_nos_equal(prev_net_nos, curr_net_nos) && net_nos_equal(curr_net_nos, next_net_nos)) - { + if (net_nos_equal(prev_net_nos, curr_net_nos) && net_nos_equal(curr_net_nos, next_net_nos)) { prev.next = next; - } - else - { + } else { before_prev = prev; prev = curr; prev_net_nos = curr_net_nos; @@ -622,70 +541,55 @@ private void resort() curr = next; next = curr.next; } - + // remove nodes of own net at start and end of the list - if (curr != null && net_nos_equal(curr_net_nos, own_net_nos)) - { + if (curr != null && net_nos_equal(curr_net_nos, own_net_nos)) { prev.next = null; - if (net_nos_equal(prev_net_nos, own_net_nos)) - { - if (before_prev != null) - { + if (net_nos_equal(prev_net_nos, own_net_nos)) { + if (before_prev != null) { before_prev.next = null; - } - else - { + } else { list_anchor = null; } } } - - if (list_anchor != null && list_anchor.trace.nets_equal(own_net_nos)) - { + + if (list_anchor != null && list_anchor.trace.nets_equal(own_net_nos)) { list_anchor = list_anchor.next; - - if (list_anchor != null && list_anchor.trace.nets_equal(own_net_nos)) - { + + if (list_anchor != null && list_anchor.trace.nets_equal(own_net_nos)) { list_anchor = list_anchor.next; } } } - - private boolean calculate_stack_levels() - { - if (list_anchor == null) - { + + private boolean calculate_stack_levels() { + if (list_anchor == null) { return true; } EntryPoint curr_entry = list_anchor; int[] curr_net_nos = curr_entry.trace.net_no_arr; int curr_level; - if (net_nos_equal(curr_net_nos, this.own_net_nos)) - { + if (net_nos_equal(curr_net_nos, this.own_net_nos)) { // ignore own net when calculating the stack level curr_level = 0; - } - else - { + } else { curr_level = 1; } - - while (curr_entry != null) - { + + while (curr_entry != null) { if (curr_entry.stack_level < 0) // not yet calculated { ++trace_piece_count; curr_entry.stack_level = curr_level; - if (curr_level > max_stack_level) - { - if (max_stack_level > 1) - { + if (curr_level > max_stack_level) { + if (max_stack_level > 1) { this.found_obstacle = curr_entry.trace; } max_stack_level = curr_level; } } - + // set stack level for all entries of the current net; EntryPoint check_entry = curr_entry.next; int index_of_next_foreign_set = 0; @@ -693,20 +597,15 @@ private boolean calculate_stack_levels() int next_index = 0; EntryPoint last_own_entry = null; EntryPoint first_foreign_entry = null; - - while (check_entry != null) - { + + while (check_entry != null) { ++next_index; int[] check_net_nos = check_entry.trace.net_no_arr; - if (net_nos_equal(check_net_nos, curr_net_nos)) - { + if (net_nos_equal(check_net_nos, curr_net_nos)) { index_of_last_occurance_of_set = next_index; last_own_entry = check_entry; check_entry.stack_level = curr_entry.stack_level; - } - - else if (index_of_next_foreign_set == 0) - { + } else if (index_of_next_foreign_set == 0) { // first occurance of a foreign connected set index_of_next_foreign_set = next_index; first_foreign_entry = check_entry; @@ -714,12 +613,11 @@ else if (index_of_next_foreign_set == 0) check_entry = check_entry.next; } EntryPoint next_entry = null; - - if (next_index != 0) - { + + if (next_index != 0) { if (index_of_next_foreign_set != 0 && index_of_next_foreign_set < index_of_last_occurance_of_set) - // raise level + // raise level { next_entry = first_foreign_entry; if (next_entry.stack_level >= 0) // already calculated @@ -728,21 +626,15 @@ else if (index_of_next_foreign_set == 0) return false; } ++curr_level; - } - else - { - if (index_of_last_occurance_of_set != 0) - { + } else { + if (index_of_last_occurance_of_set != 0) { next_entry = last_own_entry; - } - else - { + } else { next_entry = first_foreign_entry; if (next_entry.stack_level >= 0) // already calculated { --curr_level; - if (next_entry.stack_level != curr_level) - { + if (next_entry.stack_level != curr_level) { return false; } } @@ -752,139 +644,114 @@ else if (index_of_next_foreign_set == 0) // remove all entries between curr_entry and next_entry, because // they are irrelevant; check_entry = curr_entry.next; - while (check_entry != next_entry) - { + while (check_entry != next_entry) { check_entry = check_entry.next; } curr_entry.next = next_entry; curr_entry = next_entry; - } - else - { + } else { curr_entry = null; } } - if (curr_level != 1) - { + if (curr_level != 1) { System.out.println( "ShapeTraceEntries.calculate_stack_levels: curr_level inconsistent"); return false; } return true; } - + /** * Pops the next piece with minimal level from the imtersection list * Returns null, if the stack is empty. * The returned array has 2 elements. The first is the first entry point, * and the second is the last entry point of the minimal level. */ - private EntryPoint [] pop_piece() - { - if (list_anchor == null) - { - if (this.trace_piece_count != 0) - { + private EntryPoint[] pop_piece() { + if (list_anchor == null) { + if (this.trace_piece_count != 0) { System.out.println("ShapeTraceEntries: trace_piece_count is inconsistent"); } return null; } EntryPoint first = list_anchor; EntryPoint prev_first = null; - - while (first != null) - { - if (first.stack_level == this.max_stack_level) - { + + while (first != null) { + if (first.stack_level == this.max_stack_level) { break; } prev_first = first; first = first.next; } - if (first == null) - { + if (first == null) { System.out.println("ShapeTraceEntries: max_stack_level not found"); return null; } - EntryPoint [] result = new EntryPoint [2]; + EntryPoint[] result = new EntryPoint[2]; result[0] = first; EntryPoint last = first; EntryPoint after_last = first.next; - - while (after_last != null) - { + + while (after_last != null) { if (after_last.stack_level != max_stack_level || - !after_last.trace.nets_equal( first.trace)) - { + !after_last.trace.nets_equal(first.trace)) { break; } last = after_last; after_last = last.next; } result[1] = last; - + // remove the nodes from first to last inclusive - - if (prev_first != null) - { + + if (prev_first != null) { prev_first.next = after_last; - } - else - { + } else { list_anchor = after_last; } - + // recalculate max_stack_level; max_stack_level = 0; EntryPoint curr = list_anchor; - while (curr != null) - { - if (curr.stack_level > max_stack_level) - { + while (curr != null) { + if (curr.stack_level > max_stack_level) { max_stack_level = curr.stack_level; } curr = curr.next; } --trace_piece_count; - if (first.trace.nets_equal(this.own_net_nos)) - { + if (first.trace.nets_equal(this.own_net_nos)) { // own net is ignored and nay occur only at the lowest level result = pop_piece(); } return result; } - + private void insert_entry_point(PolylineTrace p_trace, int p_trace_line_no, - int p_edge_no, FloatPoint p_entry_approx) - { + int p_edge_no, FloatPoint p_entry_approx) { EntryPoint new_entry = new EntryPoint(p_trace, p_trace_line_no, p_edge_no, p_entry_approx); EntryPoint curr_prev = null; EntryPoint curr_next = list_anchor; // insert the new entry into the sorted list - while (curr_next != null) - { - if (curr_next.edge_no > new_entry.edge_no) - { + while (curr_next != null) { + if (curr_next.edge_no > new_entry.edge_no) { break; } - if (curr_next.edge_no == new_entry.edge_no) - { + if (curr_next.edge_no == new_entry.edge_no) { FloatPoint prev_corner = shape.corner_approx(p_edge_no); FloatPoint next_corner; - if (p_edge_no == shape.border_line_count() - 1) - { + if (p_edge_no == shape.border_line_count() - 1) { next_corner = shape.corner_approx(0); - } - else - { + } else { next_corner = shape.corner_approx(new_entry.edge_no + 1); } - if( prev_corner.scalar_product(p_entry_approx, next_corner) - <= prev_corner.scalar_product(curr_next.entry_approx, next_corner)) - // the projection of the line from prev_corner to p_entry_approx - // onto the line from prev_corner to next_corner is smaller - // than the projection of the line from prev_corner to - // next.entry_approx onto the same line. + if (prev_corner.scalar_product(p_entry_approx, next_corner) + <= prev_corner.scalar_product(curr_next.entry_approx, next_corner)) + // the projection of the line from prev_corner to p_entry_approx + // onto the line from prev_corner to next_corner is smaller + // than the projection of the line from prev_corner to + // next.entry_approx onto the same line. { break; } @@ -893,75 +760,31 @@ private void insert_entry_point(PolylineTrace p_trace, int p_trace_line_no, curr_next = curr_next.next; } new_entry.next = curr_next; - if (curr_prev != null) - { + if (curr_prev != null) { curr_prev.next = new_entry; - } - else - { + } else { list_anchor = new_entry; } } - - final Collection shove_via_list; - private final TileShape shape; - private final int layer; - private final int[] own_net_nos; - private final int cl_class; - private CalcFromSide from_side; - private final RoutingBoard board; - private EntryPoint list_anchor; - private int trace_piece_count; - private int max_stack_level; - private boolean shape_contains_trace_tails = false; - private Item found_obstacle = null; - private static final double c_offset_add = 1; - + /** * Information about an entry point of p_trace into the shape. * The entry points are sorted around the border of the shape */ - private static class EntryPoint - { + private static class EntryPoint { + final PolylineTrace trace; + final int trace_line_no; + final FloatPoint entry_approx; + int edge_no; + int stack_level; + EntryPoint next; EntryPoint(PolylineTrace p_trace, int p_trace_line_no, int p_edge_no, - FloatPoint p_entry_approx) - { + FloatPoint p_entry_approx) { trace = p_trace; edge_no = p_edge_no; trace_line_no = p_trace_line_no; entry_approx = p_entry_approx; stack_level = -1; //not yet calculated } - - final PolylineTrace trace; - final int trace_line_no; - int edge_no; - final FloatPoint entry_approx; - int stack_level; - EntryPoint next; - } - - static private boolean net_nos_equal(int[] p_net_nos_1, int [] p_net_nos_2) - { - if (p_net_nos_1.length != p_net_nos_2.length) - { - return false; - } - for (int curr_net_no_1 : p_net_nos_1) - { - boolean net_no_found = false; - for (int curr_net_no_2 : p_net_nos_2) - { - if (curr_net_no_1 == curr_net_no_2) - { - net_no_found = true; - } - } - if (!net_no_found) - { - return false; - } - } - return true; } } \ No newline at end of file diff --git a/src/main/java/net/freerouting/board/ShoveTraceAlgo.java b/src/main/java/net/freerouting/board/ShoveTraceAlgo.java index 6c77cf9e..bb409a81 100644 --- a/src/main/java/net/freerouting/board/ShoveTraceAlgo.java +++ b/src/main/java/net/freerouting/board/ShoveTraceAlgo.java @@ -16,18 +16,7 @@ package net.freerouting.board; import net.freerouting.datastructures.TimeLimit; - -import net.freerouting.geometry.planar.ConvexShape; -import net.freerouting.geometry.planar.Direction; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.LineSegment; +import net.freerouting.geometry.planar.*; import java.util.Collection; import java.util.Iterator; @@ -39,157 +28,12 @@ * * @author Alfons Wirtz */ -public class ShoveTraceAlgo -{ - - public ShoveTraceAlgo(RoutingBoard p_board) - { - board = p_board; - } - - /** - * Checks if a shove with the input parameters is possible without clearance violations - * p_dir is used internally to prevent the check from bouncing back. - * Returns false, if the shove failed. - */ - public boolean check(TileShape p_trace_shape, CalcFromSide p_from_side, - Direction p_dir, int p_layer, int[] p_net_no_arr, - int p_cl_type, int p_max_recursion_depth, int p_max_via_recursion_depth, - int p_max_spring_over_recursion_depth, TimeLimit p_time_limit) - { - if (p_time_limit != null && p_time_limit.limit_exceeded()) - { - return false; - } - - if (p_trace_shape.is_empty()) - { - System.out.println("ShoveTraceAux.check: p_trace_shape is empty"); - return true; - } - if (!p_trace_shape.is_contained_in(board.get_bounding_box())) - { - this.board.set_shove_failing_obstacle(board.get_outline()); - return false; - } - ShapeTraceEntries shape_entries = - new ShapeTraceEntries(p_trace_shape, p_layer, p_net_no_arr, p_cl_type, p_from_side, board); - ShapeSearchTree search_tree = this.board.search_tree_manager.get_default_tree(); - Collection obstacles = - search_tree.overlapping_items_with_clearance(p_trace_shape, p_layer, new int[0], p_cl_type); - obstacles.removeAll(get_ignore_items_at_tie_pins(p_trace_shape, p_layer, p_net_no_arr)); - boolean obstacles_shovable = shape_entries.store_items(obstacles, false, true); - if (!obstacles_shovable) - { - this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); - return false; - } - int trace_piece_count = shape_entries.substitute_trace_count(); - - if (shape_entries.stack_depth() > 1) - { - this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); - return false; - } - double shape_radius = 0.5 * p_trace_shape.bounding_box().min_width(); - - // check, if the obstacle vias can be shoved - - - for (Via curr_shove_via : shape_entries.shove_via_list) - { - if (curr_shove_via.shares_net_no(p_net_no_arr)) - { - continue; - } - if (p_max_via_recursion_depth <= 0) - { - this.board.set_shove_failing_obstacle(curr_shove_via); - return false; - } - FloatPoint curr_shove_via_center = curr_shove_via.get_center().to_float(); - IntPoint[] try_via_centers = - MoveDrillItemAlgo.try_shove_via_points(p_trace_shape, p_layer, curr_shove_via, p_cl_type, - true, board); - - double max_dist = 0.5 * curr_shove_via.get_shape_on_layer(p_layer).bounding_box().max_width() + shape_radius; - double max_dist_square = max_dist * max_dist; - boolean shove_via_ok = false; - for (int i = 0; i < try_via_centers.length; ++i) - { - if (i == 0 || curr_shove_via_center.distance_square(try_via_centers[i].to_float()) <= max_dist_square) - { - Vector delta = try_via_centers[i].difference_by(curr_shove_via.get_center()); - Collection ignore_items = new java.util.LinkedList(); - if (MoveDrillItemAlgo.check(curr_shove_via, delta, p_max_recursion_depth, - p_max_via_recursion_depth - 1, ignore_items, this.board, p_time_limit)) - { - shove_via_ok = true; - break; - } - } - } - if (!shove_via_ok) - { - return false; - } - } +public class ShoveTraceAlgo { - if (trace_piece_count == 0) - { - return true; - } - if (p_max_recursion_depth <= 0) - { - this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); - return false; - } + private final RoutingBoard board; - boolean is_orthogonal_mode = p_trace_shape instanceof IntBox; - for (;;) - { - PolylineTrace curr_substitute_trace = - shape_entries.next_substitute_trace_piece(); - if (curr_substitute_trace == null) - { - break; - } - if (p_max_spring_over_recursion_depth > 0) - { - Polyline new_polyline = spring_over(curr_substitute_trace.polyline(), - curr_substitute_trace.get_compensated_half_width(search_tree), p_layer, curr_substitute_trace.net_no_arr, - curr_substitute_trace.clearance_class_no(), false, p_max_spring_over_recursion_depth, null); - if (new_polyline == null) - { - // spring_over did not work - return false; - } - if (new_polyline != curr_substitute_trace.polyline()) - { - // spring_over changed something - --p_max_spring_over_recursion_depth; - curr_substitute_trace.change(new_polyline); - } - } - for (int i = 0; i < curr_substitute_trace.tile_shape_count(); ++i) - { - Direction curr_dir = curr_substitute_trace.polyline().arr[i + 1].direction(); - boolean is_in_front = p_dir == null || p_dir.equals(curr_dir); - if (is_in_front) - { - CalcShapeAndFromSide curr = - new CalcShapeAndFromSide(curr_substitute_trace, i, is_orthogonal_mode, true); - if (!this.check(curr.shape, curr.from_side, curr_dir, p_layer, curr_substitute_trace.net_no_arr, - curr_substitute_trace.clearance_class_no(), - p_max_recursion_depth - 1, p_max_via_recursion_depth, - p_max_spring_over_recursion_depth, p_time_limit)) - { - return false; - } - } - } - } - return true; + public ShoveTraceAlgo(RoutingBoard p_board) { + board = p_board; } /** @@ -199,28 +43,23 @@ public boolean check(TileShape p_trace_shape, CalcFromSide p_from_side, * If the algorithm succeedes completely, the result will be equal to Integer.MAX_VALUE. */ public static double check(RoutingBoard p_board, LineSegment p_line_segment, boolean p_shove_to_the_left, int p_layer, int[] p_net_no_arr, int p_trace_half_width, - int p_cl_type, int p_max_recursion_depth, int p_max_via_recursion_depth) - { + int p_cl_type, int p_max_recursion_depth, int p_max_via_recursion_depth) { ShapeSearchTree search_tree = p_board.search_tree_manager.get_default_tree(); - if (search_tree.is_clearance_compensation_used()) - { + if (search_tree.is_clearance_compensation_used()) { p_trace_half_width += search_tree.clearance_compensation_value(p_cl_type, p_layer); } TileShape[] trace_shapes = p_line_segment.to_polyline().offset_shapes(p_trace_half_width); - if (trace_shapes.length != 1) - { + if (trace_shapes.length != 1) { System.out.println("ShoveTraceAlgo.check: trace_shape count 1 expected"); return 0; } TileShape trace_shape = trace_shapes[0]; - if (trace_shape.is_empty()) - { + if (trace_shape.is_empty()) { System.out.println("ShoveTraceAlgo.check: trace_shape is empty"); return 0; } - if (!trace_shape.is_contained_in(p_board.get_bounding_box())) - { + if (!trace_shape.is_contained_in(p_board.get_bounding_box())) { return 0; } CalcFromSide from_side = new CalcFromSide(p_line_segment, trace_shape, p_shove_to_the_left); @@ -229,14 +68,12 @@ public static double check(RoutingBoard p_board, LineSegment p_line_segment, boo Collection obstacles = search_tree.overlapping_items_with_clearance(trace_shape, p_layer, new int[0], p_cl_type); boolean obstacles_shovable = shape_entries.store_items(obstacles, false, true); - if (!obstacles_shovable || shape_entries.trace_tails_in_shape()) - { + if (!obstacles_shovable || shape_entries.trace_tails_in_shape()) { return 0; } int trace_piece_count = shape_entries.substitute_trace_count(); - if (shape_entries.stack_depth() > 1) - { + if (shape_entries.stack_depth() > 1) { return 0; } @@ -250,22 +87,18 @@ public static double check(RoutingBoard p_board, LineSegment p_line_segment, boo // check, if the obstacle vias can be shoved - for (Via curr_shove_via : shape_entries.shove_via_list) - { - if (curr_shove_via.shares_net_no(p_net_no_arr)) - { + for (Via curr_shove_via : shape_entries.shove_via_list) { + if (curr_shove_via.shares_net_no(p_net_no_arr)) { continue; } boolean shove_via_ok = false; - if (p_max_via_recursion_depth > 0) - { + if (p_max_via_recursion_depth > 0) { IntPoint[] new_via_center = MoveDrillItemAlgo.try_shove_via_points(trace_shape, p_layer, curr_shove_via, p_cl_type, - false, p_board); + false, p_board); - if (new_via_center.length <= 0) - { + if (new_via_center.length <= 0) { return 0; } Vector delta = new_via_center[0].difference_by(curr_shove_via.get_center()); @@ -274,79 +107,63 @@ public static double check(RoutingBoard p_board, LineSegment p_line_segment, boo p_max_via_recursion_depth - 1, ignore_items, p_board, null); } - if (!shove_via_ok) - { + if (!shove_via_ok) { FloatPoint via_center_appprox = curr_shove_via.get_center().to_float(); double projection = start_corner_appprox.scalar_product(end_corner_appprox, via_center_appprox); projection /= segment_length; IntBox via_box = curr_shove_via.get_tree_shape_on_layer(search_tree, p_layer).bounding_box(); double via_radius = 0.5 * via_box.max_width(); double curr_ok_lenght = projection - via_radius - p_trace_half_width; - if (!search_tree.is_clearance_compensation_used()) - { + if (!search_tree.is_clearance_compensation_used()) { curr_ok_lenght -= cl_matrix.value(p_cl_type, curr_shove_via.clearance_class_no(), p_layer); } - if (curr_ok_lenght <= 0) - { + if (curr_ok_lenght <= 0) { return 0; } result = Math.min(result, curr_ok_lenght); } } - if (trace_piece_count == 0) - { + if (trace_piece_count == 0) { return result; } - if (p_max_recursion_depth <= 0) - { + if (p_max_recursion_depth <= 0) { return 0; } Direction line_direction = p_line_segment.get_line().direction(); - for (;;) - { + for (; ; ) { PolylineTrace curr_substitute_trace = shape_entries.next_substitute_trace_piece(); - if (curr_substitute_trace == null) - { + if (curr_substitute_trace == null) { break; } - for (int i = 0; i < curr_substitute_trace.tile_shape_count(); ++i) - { + for (int i = 0; i < curr_substitute_trace.tile_shape_count(); ++i) { LineSegment curr_line_segment = new LineSegment(curr_substitute_trace.polyline(), i + 1); - if (p_shove_to_the_left) - { + if (p_shove_to_the_left) { // swap the line segmment to get the corredct shove length // in case it is smmaller than the length of the whole line segmment. curr_line_segment = curr_line_segment.opposite(); } boolean is_in_front = curr_line_segment.get_line().direction().equals(line_direction); - if (is_in_front) - { + if (is_in_front) { double shove_ok_length = check(p_board, curr_line_segment, p_shove_to_the_left, p_layer, curr_substitute_trace.net_no_arr, curr_substitute_trace.get_half_width(), curr_substitute_trace.clearance_class_no(), p_max_recursion_depth - 1, p_max_via_recursion_depth); - if (shove_ok_length < Integer.MAX_VALUE) - { - if (shove_ok_length <= 0) - { + if (shove_ok_length < Integer.MAX_VALUE) { + if (shove_ok_length <= 0) { return 0; } double projection = Math.min(start_corner_appprox.scalar_product(end_corner_appprox, curr_line_segment.start_point_approx()), - start_corner_appprox.scalar_product(end_corner_appprox, curr_line_segment.end_point_approx())); + start_corner_appprox.scalar_product(end_corner_appprox, curr_line_segment.end_point_approx())); projection /= segment_length; double curr_ok_length = shove_ok_length + projection - p_trace_half_width - curr_substitute_trace.get_half_width(); - if (search_tree.is_clearance_compensation_used()) - { + if (search_tree.is_clearance_compensation_used()) { curr_ok_length -= search_tree.clearance_compensation_value(curr_substitute_trace.clearance_class_no(), p_layer); - } - else - { + } else { curr_ok_length -= cl_matrix.value(p_cl_type, curr_substitute_trace.clearance_class_no(), p_layer); } - if (curr_ok_length <= 0) - { + if (curr_ok_length <= 0) { return 0; } result = Math.min(curr_ok_length, result); @@ -358,28 +175,146 @@ public static double check(RoutingBoard p_board, LineSegment p_line_segment, boo return result; } + /** + * Checks if a shove with the input parameters is possible without clearance violations + * p_dir is used internally to prevent the check from bouncing back. + * Returns false, if the shove failed. + */ + public boolean check(TileShape p_trace_shape, CalcFromSide p_from_side, + Direction p_dir, int p_layer, int[] p_net_no_arr, + int p_cl_type, int p_max_recursion_depth, int p_max_via_recursion_depth, + int p_max_spring_over_recursion_depth, TimeLimit p_time_limit) { + if (p_time_limit != null && p_time_limit.limit_exceeded()) { + return false; + } + + if (p_trace_shape.is_empty()) { + System.out.println("ShoveTraceAux.check: p_trace_shape is empty"); + return true; + } + if (!p_trace_shape.is_contained_in(board.get_bounding_box())) { + this.board.set_shove_failing_obstacle(board.get_outline()); + return false; + } + ShapeTraceEntries shape_entries = + new ShapeTraceEntries(p_trace_shape, p_layer, p_net_no_arr, p_cl_type, p_from_side, board); + ShapeSearchTree search_tree = this.board.search_tree_manager.get_default_tree(); + Collection obstacles = + search_tree.overlapping_items_with_clearance(p_trace_shape, p_layer, new int[0], p_cl_type); + obstacles.removeAll(get_ignore_items_at_tie_pins(p_trace_shape, p_layer, p_net_no_arr)); + boolean obstacles_shovable = shape_entries.store_items(obstacles, false, true); + if (!obstacles_shovable) { + this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); + return false; + } + int trace_piece_count = shape_entries.substitute_trace_count(); + + if (shape_entries.stack_depth() > 1) { + this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); + return false; + } + double shape_radius = 0.5 * p_trace_shape.bounding_box().min_width(); + + // check, if the obstacle vias can be shoved + + + for (Via curr_shove_via : shape_entries.shove_via_list) { + if (curr_shove_via.shares_net_no(p_net_no_arr)) { + continue; + } + if (p_max_via_recursion_depth <= 0) { + this.board.set_shove_failing_obstacle(curr_shove_via); + return false; + } + FloatPoint curr_shove_via_center = curr_shove_via.get_center().to_float(); + IntPoint[] try_via_centers = + MoveDrillItemAlgo.try_shove_via_points(p_trace_shape, p_layer, curr_shove_via, p_cl_type, + true, board); + + double max_dist = 0.5 * curr_shove_via.get_shape_on_layer(p_layer).bounding_box().max_width() + shape_radius; + double max_dist_square = max_dist * max_dist; + boolean shove_via_ok = false; + for (int i = 0; i < try_via_centers.length; ++i) { + if (i == 0 || curr_shove_via_center.distance_square(try_via_centers[i].to_float()) <= max_dist_square) { + Vector delta = try_via_centers[i].difference_by(curr_shove_via.get_center()); + Collection ignore_items = new java.util.LinkedList(); + if (MoveDrillItemAlgo.check(curr_shove_via, delta, p_max_recursion_depth, + p_max_via_recursion_depth - 1, ignore_items, this.board, p_time_limit)) { + shove_via_ok = true; + break; + } + } + } + if (!shove_via_ok) { + return false; + } + } + + if (trace_piece_count == 0) { + return true; + } + if (p_max_recursion_depth <= 0) { + this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); + return false; + } + + boolean is_orthogonal_mode = p_trace_shape instanceof IntBox; + for (; ; ) { + PolylineTrace curr_substitute_trace = + shape_entries.next_substitute_trace_piece(); + if (curr_substitute_trace == null) { + break; + } + if (p_max_spring_over_recursion_depth > 0) { + Polyline new_polyline = spring_over(curr_substitute_trace.polyline(), + curr_substitute_trace.get_compensated_half_width(search_tree), p_layer, curr_substitute_trace.net_no_arr, + curr_substitute_trace.clearance_class_no(), false, p_max_spring_over_recursion_depth, null); + if (new_polyline == null) { + // spring_over did not work + return false; + } + if (new_polyline != curr_substitute_trace.polyline()) { + // spring_over changed something + --p_max_spring_over_recursion_depth; + curr_substitute_trace.change(new_polyline); + } + } + for (int i = 0; i < curr_substitute_trace.tile_shape_count(); ++i) { + Direction curr_dir = curr_substitute_trace.polyline().arr[i + 1].direction(); + boolean is_in_front = p_dir == null || p_dir.equals(curr_dir); + if (is_in_front) { + CalcShapeAndFromSide curr = + new CalcShapeAndFromSide(curr_substitute_trace, i, is_orthogonal_mode, true); + if (!this.check(curr.shape, curr.from_side, curr_dir, p_layer, curr_substitute_trace.net_no_arr, + curr_substitute_trace.clearance_class_no(), + p_max_recursion_depth - 1, p_max_via_recursion_depth, + p_max_spring_over_recursion_depth, p_time_limit)) { + return false; + } + } + } + } + return true; + } + /** * Puts in a trace segment with the input parameters and * shoves obstacles out of the way. If the shove does not work, * the database may be damaged. To prevent this, call check first. */ public boolean insert(TileShape p_trace_shape, CalcFromSide p_from_side, int p_layer, int[] p_net_no_arr, - int p_cl_type, Collection p_ignore_items, - int p_max_recursion_depth, int p_max_via_recursion_depth, int p_max_spring_over_recursion_depth) - { - if (p_trace_shape.is_empty()) - { + int p_cl_type, Collection p_ignore_items, + int p_max_recursion_depth, int p_max_via_recursion_depth, int p_max_spring_over_recursion_depth) { + if (p_trace_shape.is_empty()) { System.out.println("ShoveTraceAux.insert: p_trace_shape is empty"); return true; } - if (!p_trace_shape.is_contained_in(board.get_bounding_box())) - { + if (!p_trace_shape.is_contained_in(board.get_bounding_box())) { this.board.set_shove_failing_obstacle(board.get_outline()); return false; } if (!MoveDrillItemAlgo.shove_vias(p_trace_shape, p_from_side, p_layer, p_net_no_arr, p_cl_type, - p_ignore_items, p_max_recursion_depth, p_max_via_recursion_depth, true, this.board)) - { + p_ignore_items, p_max_recursion_depth, p_max_via_recursion_depth, true, this.board)) { return false; } ShapeTraceEntries shape_entries = @@ -389,95 +324,77 @@ public boolean insert(TileShape p_trace_shape, CalcFromSide p_from_side, int p_l search_tree.overlapping_items_with_clearance(p_trace_shape, p_layer, new int[0], p_cl_type); obstacles.removeAll(get_ignore_items_at_tie_pins(p_trace_shape, p_layer, p_net_no_arr)); boolean obstacles_shovable = shape_entries.store_items(obstacles, false, true); - if (!shape_entries.shove_via_list.isEmpty()) - { + if (!shape_entries.shove_via_list.isEmpty()) { obstacles_shovable = false; this.board.set_shove_failing_obstacle(shape_entries.shove_via_list.iterator().next()); return false; } - if (!obstacles_shovable) - { + if (!obstacles_shovable) { this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); return false; } int trace_piece_count = shape_entries.substitute_trace_count(); - if (trace_piece_count == 0) - { + if (trace_piece_count == 0) { return true; } - if (p_max_recursion_depth <= 0) - { + if (p_max_recursion_depth <= 0) { this.board.set_shove_failing_obstacle(shape_entries.get_found_obstacle()); return false; } boolean tails_exist_before = board.contains_trace_tails(obstacles, p_net_no_arr); shape_entries.cutout_traces(obstacles); boolean is_orthogonal_mode = p_trace_shape instanceof IntBox; - for (;;) - { + for (; ; ) { PolylineTrace curr_substitute_trace = shape_entries.next_substitute_trace_piece(); - if (curr_substitute_trace == null) - { + if (curr_substitute_trace == null) { break; } - if (curr_substitute_trace.first_corner().equals(curr_substitute_trace.last_corner())) - { + if (curr_substitute_trace.first_corner().equals(curr_substitute_trace.last_corner())) { continue; } - if (p_max_spring_over_recursion_depth > 0) - { + if (p_max_spring_over_recursion_depth > 0) { Polyline new_polyline = spring_over(curr_substitute_trace.polyline(), curr_substitute_trace.get_compensated_half_width(search_tree), p_layer, curr_substitute_trace.net_no_arr, curr_substitute_trace.clearance_class_no(), false, p_max_spring_over_recursion_depth, null); - if (new_polyline == null) - { + if (new_polyline == null) { // spring_over did not work return false; } - if (new_polyline != curr_substitute_trace.polyline()) - { + if (new_polyline != curr_substitute_trace.polyline()) { // spring_over changed something --p_max_spring_over_recursion_depth; curr_substitute_trace.change(new_polyline); } } int[] curr_net_no_arr = curr_substitute_trace.net_no_arr; - for (int i = 0; i < curr_substitute_trace.tile_shape_count(); ++i) - { + for (int i = 0; i < curr_substitute_trace.tile_shape_count(); ++i) { CalcShapeAndFromSide curr = new CalcShapeAndFromSide(curr_substitute_trace, i, is_orthogonal_mode, false); if (!this.insert(curr.shape, curr.from_side, p_layer, curr_net_no_arr, curr_substitute_trace.clearance_class_no(), - p_ignore_items, p_max_recursion_depth - 1, p_max_via_recursion_depth, p_max_spring_over_recursion_depth)) - { + p_ignore_items, p_max_recursion_depth - 1, p_max_via_recursion_depth, p_max_spring_over_recursion_depth)) { return false; } } - for (int i = 0; i < curr_substitute_trace.corner_count(); ++i) - { + for (int i = 0; i < curr_substitute_trace.corner_count(); ++i) { board.join_changed_area( curr_substitute_trace.polyline().corner_approx(i), p_layer); } Point[] end_corners = null; - if (!tails_exist_before) - { + if (!tails_exist_before) { end_corners = new Point[2]; end_corners[0] = curr_substitute_trace.first_corner(); end_corners[1] = curr_substitute_trace.last_corner(); } board.insert_item(curr_substitute_trace); curr_substitute_trace.normalize(board.changed_area.get_area(p_layer)); - if (!tails_exist_before) - { - for (int i = 0; i < 2; ++i) - { + if (!tails_exist_before) { + for (int i = 0; i < 2; ++i) { Trace tail = board.get_trace_tail(end_corners[i], p_layer, curr_net_no_arr); - if (tail != null) - { + if (tail != null) { board.remove_items(tail.get_connection_items(Item.StopConnectionOption.VIA), false); - for (int curr_net_no : curr_net_no_arr) - { + for (int curr_net_no : curr_net_no_arr) { board.combine_traces(curr_net_no); } } @@ -487,17 +404,13 @@ public boolean insert(TileShape p_trace_shape, CalcFromSide p_from_side, int p_l return true; } - Collection get_ignore_items_at_tie_pins(TileShape p_trace_shape, int p_layer, int[] p_net_no_arr) - { + Collection get_ignore_items_at_tie_pins(TileShape p_trace_shape, int p_layer, int[] p_net_no_arr) { Collection overlaps = this.board.overlapping_objects(p_trace_shape, p_layer); Set result = new java.util.TreeSet(); - for (SearchTreeObject curr_object : overlaps) - { - if (curr_object instanceof Pin) - { + for (SearchTreeObject curr_object : overlaps) { + if (curr_object instanceof Pin) { Pin curr_pin = (Pin) curr_object; - if (curr_pin.shares_net_no(p_net_no_arr)) - { + if (curr_pin.shares_net_no(p_net_no_arr)) { result.addAll(curr_pin.get_all_contacts(p_layer)); } } @@ -514,208 +427,145 @@ Collection get_ignore_items_at_tie_pins(TileShape p_trace_shape, int p_lay * regarded as obstacles, even if they are of the own net. */ private Polyline spring_over(Polyline p_polyline, int p_half_width, - int p_layer, int[] p_net_no_arr, int p_cl_type, boolean p_over_connected_pins, - int p_recursion_depth, Set p_contact_pins) - { + int p_layer, int[] p_net_no_arr, int p_cl_type, boolean p_over_connected_pins, + int p_recursion_depth, Set p_contact_pins) { Item found_obstacle = null; IntBox found_obstacle_bounding_box = null; ShapeSearchTree search_tree = this.board.search_tree_manager.get_default_tree(); int[] check_net_no_arr; - if (p_contact_pins == null) - { + if (p_contact_pins == null) { check_net_no_arr = p_net_no_arr; - } - else - { + } else { check_net_no_arr = new int[0]; } - for (int i = 0; i < p_polyline.arr.length - 2; ++i) - { + for (int i = 0; i < p_polyline.arr.length - 2; ++i) { TileShape curr_shape = p_polyline.offset_shape(p_half_width, i); Collection obstacles = search_tree.overlapping_items_with_clearance(curr_shape, p_layer, check_net_no_arr, p_cl_type); Iterator it = obstacles.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); boolean is_obstacle; - if (curr_item.shares_net_no(p_net_no_arr)) - { + if (curr_item.shares_net_no(p_net_no_arr)) { // to avoid acid traps is_obstacle = curr_item instanceof Pin && p_contact_pins != null && !p_contact_pins.contains(curr_item); - } - else if (curr_item instanceof ConductionArea) - { + } else if (curr_item instanceof ConductionArea) { is_obstacle = ((ConductionArea) curr_item).get_is_obstacle(); - } - else if (curr_item instanceof ViaObstacleArea || curr_item instanceof ComponentObstacleArea) - { + } else if (curr_item instanceof ViaObstacleArea || curr_item instanceof ComponentObstacleArea) { is_obstacle = false; - } - else if (curr_item instanceof PolylineTrace) - { - if (curr_item.is_shove_fixed()) - { + } else if (curr_item instanceof PolylineTrace) { + if (curr_item.is_shove_fixed()) { is_obstacle = true; - if (curr_item instanceof PolylineTrace) - { - // check for a shove fixed trace exit stub, which has to be be ignored at a tie pin. + if (curr_item instanceof PolylineTrace) { + // check for a shove fixed trace exit stub, which has to be be ignored at a tie pin. Collection curr_contacts = curr_item.get_normal_contacts(); - for (Item curr_contact : curr_contacts) - { - if (curr_contact.shares_net_no(p_net_no_arr)) - { + for (Item curr_contact : curr_contacts) { + if (curr_contact.shares_net_no(p_net_no_arr)) { is_obstacle = false; } } } - } - else - { + } else { // a unfixed trace can be pushed aside eventually is_obstacle = false; } - } - else - { + } else { // a unfixed via can be pushed aside eventually is_obstacle = !curr_item.is_route(); } - if (is_obstacle) - { - if (found_obstacle == null) - { + if (is_obstacle) { + if (found_obstacle == null) { found_obstacle = curr_item; found_obstacle_bounding_box = curr_item.bounding_box(); - } - else if (found_obstacle != curr_item) - { + } else if (found_obstacle != curr_item) { // check, if 1 obstacle is contained in the other obstacle and take // the bigger obstacle in this case. // That may happen in case of fixed vias inside of pins. IntBox curr_item_bounding_box = curr_item.bounding_box(); - if (found_obstacle_bounding_box.intersects(curr_item_bounding_box)) - { - if (curr_item_bounding_box.contains(found_obstacle_bounding_box)) - { + if (found_obstacle_bounding_box.intersects(curr_item_bounding_box)) { + if (curr_item_bounding_box.contains(found_obstacle_bounding_box)) { found_obstacle = curr_item; found_obstacle_bounding_box = curr_item_bounding_box; - } - else if (!found_obstacle_bounding_box.contains(curr_item_bounding_box)) - { + } else if (!found_obstacle_bounding_box.contains(curr_item_bounding_box)) { return null; } } } } } - if (found_obstacle != null) - { + if (found_obstacle != null) { break; } } - if (found_obstacle == null) - { + if (found_obstacle == null) { // no obstacle in the way, nothing to do return p_polyline; } - - - - - - - - - if (p_recursion_depth <= 0 || found_obstacle instanceof BoardOutline || (found_obstacle instanceof Trace && !found_obstacle.is_shove_fixed())) - { + if (p_recursion_depth <= 0 || found_obstacle instanceof BoardOutline || (found_obstacle instanceof Trace && !found_obstacle.is_shove_fixed())) { this.board.set_shove_failing_obstacle(found_obstacle); return null; } boolean try_spring_over = true; - if (!p_over_connected_pins) - { + if (!p_over_connected_pins) { // Check if the obstacle has a trace contact on p_layer Collection contacts_on_layer = found_obstacle.get_all_contacts(p_layer); - for (Item curr_contact : contacts_on_layer) - { - if (curr_contact instanceof Trace) - { + for (Item curr_contact : contacts_on_layer) { + if (curr_contact instanceof Trace) { try_spring_over = false; break; } } } ConvexShape obstacle_shape = null; - if (try_spring_over) - { - if (found_obstacle instanceof ObstacleArea || found_obstacle instanceof Trace) - { - if (found_obstacle.tree_shape_count(search_tree) == 1) - { + if (try_spring_over) { + if (found_obstacle instanceof ObstacleArea || found_obstacle instanceof Trace) { + if (found_obstacle.tree_shape_count(search_tree) == 1) { obstacle_shape = found_obstacle.get_tree_shape(search_tree, 0); - } - else - { + } else { try_spring_over = false; } - } - else if (found_obstacle instanceof DrillItem) - { + } else if (found_obstacle instanceof DrillItem) { DrillItem found_drill_item = (DrillItem) found_obstacle; obstacle_shape = (found_drill_item.get_tree_shape_on_layer(search_tree, p_layer)); } } - if (!try_spring_over) - { + if (!try_spring_over) { this.board.set_shove_failing_obstacle(found_obstacle); return null; } TileShape offset_shape; - if (search_tree.is_clearance_compensation_used()) - { + if (search_tree.is_clearance_compensation_used()) { int offset = p_half_width + 1; offset_shape = (TileShape) obstacle_shape.enlarge(offset); - } - else - { + } else { // enlarge the shape in 2 steps for symmetry reasons int offset = p_half_width + 1; double half_cl_offset = 0.5 * board.clearance_value(found_obstacle.clearance_class_no(), p_cl_type, p_layer); offset_shape = (TileShape) obstacle_shape.enlarge(offset + half_cl_offset); offset_shape = (TileShape) offset_shape.enlarge(half_cl_offset); } - if (this.board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (this.board.rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { offset_shape = offset_shape.bounding_box(); - } - else if (this.board.rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (this.board.rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) { offset_shape = offset_shape.bounding_octagon(); } - - - - if (offset_shape.contains_inside(p_polyline.first_corner()) || offset_shape.contains_inside(p_polyline.last_corner())) - { + if (offset_shape.contains_inside(p_polyline.first_corner()) || offset_shape.contains_inside(p_polyline.last_corner())) { // can happen with clearance compensation off because of asymmetry in calculations with the offset shapes this.board.set_shove_failing_obstacle(found_obstacle); return null; } int[][] entries = offset_shape.entrance_points(p_polyline); - if (entries.length == 0) - { + if (entries.length == 0) { return p_polyline; // no obstacle } if (entries.length < - 2) - { + 2) { this.board.set_shove_failing_obstacle(found_obstacle); return null; } @@ -727,17 +577,13 @@ else if (this.board.rules.get_trace_angle_restriction() == AngleRestriction.FORT int last_intersection_line_no = entries[entries.length - 1][0]; int side_diff = last_intersection_side_no - first_intersection_side_no; if (side_diff < - 0) - { + 0) { side_diff += offset_shape.border_line_count(); - } - else if (side_diff == 0) - { + } else if (side_diff == 0) { FloatPoint compare_corner = offset_shape.corner_approx(first_intersection_side_no); FloatPoint first_intersection = p_polyline.arr[first_intersection_line_no].intersection_approx(offset_shape.border_line(first_intersection_side_no)); FloatPoint second_intersection = p_polyline.arr[last_intersection_line_no].intersection_approx(offset_shape.border_line(last_intersection_side_no)); - if (compare_corner.distance(second_intersection) < compare_corner.distance(first_intersection)) - { + if (compare_corner.distance(second_intersection) < compare_corner.distance(first_intersection)) { side_diff += offset_shape.border_line_count(); } } @@ -746,16 +592,12 @@ else if (side_diff == 0) int curr_edge_line_no = first_intersection_side_no; for (int i = 1; - i <= side_diff + 1; - ++i) - { + i <= side_diff + 1; + ++i) { substitute_lines[i] = offset_shape.border_line(curr_edge_line_no); - if (curr_edge_line_no == offset_shape.border_line_count() - 1) - { + if (curr_edge_line_no == offset_shape.border_line_count() - 1) { curr_edge_line_no = 0; - } - else - { + } else { ++curr_edge_line_no; } } @@ -764,15 +606,10 @@ else if (side_diff == 0) Polyline result = substitute_polyline; - - - - if (pieces.length > 0) - { + if (pieces.length > 0) { result = pieces[0].combine(substitute_polyline); } - if (pieces.length > 1) - { + if (pieces.length > 1) { result = result.combine(pieces[1]); } return spring_over(result, p_half_width, p_layer, p_net_no_arr, p_cl_type, p_over_connected_pins, @@ -791,41 +628,30 @@ else if (side_diff == 0) */ Polyline spring_over_obstacles( Polyline p_polyline, int p_half_width, int p_layer, int[] p_net_no_arr, - int p_cl_type, Set p_contact_pins) - { + int p_cl_type, Set p_contact_pins) { final int c_max_spring_over_recursion_depth = 20; Polyline counter_clock_wise_result = spring_over(p_polyline, p_half_width, p_layer, p_net_no_arr, p_cl_type, true, c_max_spring_over_recursion_depth, p_contact_pins); - if (counter_clock_wise_result == p_polyline) - { + if (counter_clock_wise_result == p_polyline) { return p_polyline; // no obstacle } Polyline clock_wise_result = spring_over(p_polyline.reverse(), p_half_width, p_layer, p_net_no_arr, p_cl_type, true, c_max_spring_over_recursion_depth, p_contact_pins); Polyline result = null; - if (clock_wise_result != null && counter_clock_wise_result != null) - { - if (clock_wise_result.length_approx() <= counter_clock_wise_result.length_approx()) - { + if (clock_wise_result != null && counter_clock_wise_result != null) { + if (clock_wise_result.length_approx() <= counter_clock_wise_result.length_approx()) { result = clock_wise_result.reverse(); - } - else - { + } else { result = counter_clock_wise_result; } - } - else if (clock_wise_result != null) - { + } else if (clock_wise_result != null) { result = clock_wise_result.reverse(); - } - else if (counter_clock_wise_result != null) - { + } else if (counter_clock_wise_result != null) { result = counter_clock_wise_result; } return result; } - private final RoutingBoard board; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/board/TestLevel.java b/src/main/java/net/freerouting/board/TestLevel.java index 5476588e..f52fb1f7 100644 --- a/src/main/java/net/freerouting/board/TestLevel.java +++ b/src/main/java/net/freerouting/board/TestLevel.java @@ -27,7 +27,6 @@ * * @author alfons */ -public enum TestLevel -{ +public enum TestLevel { RELEASE_VERSION, TEST_VERSION, CRITICAL_DEBUGGING_OUTPUT, ALL_DEBUGGING_OUTPUT } diff --git a/src/main/java/net/freerouting/board/Trace.java b/src/main/java/net/freerouting/board/Trace.java index cb893eab..f0fa1a8f 100644 --- a/src/main/java/net/freerouting/board/Trace.java +++ b/src/main/java/net/freerouting/board/Trace.java @@ -28,216 +28,179 @@ /** - * * Class describing functionality required for traces in the plane. * * @author Alfons Wirtz */ -public abstract class Trace extends Item implements Connectable, java.io.Serializable -{ - +public abstract class Trace extends Item implements Connectable, java.io.Serializable { + + private final int half_width; // half width of the trace pen + private int layer; // board layer of the trace + Trace(int p_layer, int p_half_width, int[] p_net_no_arr, int p_clearance_type, - int p_id_no, int p_group_no, FixedState p_fixed_state, BasicBoard p_board) - { + int p_id_no, int p_group_no, FixedState p_fixed_state, BasicBoard p_board) { super(p_net_no_arr, p_clearance_type, p_id_no, p_group_no, p_fixed_state, p_board); - half_width = p_half_width ; + half_width = p_half_width; p_layer = Math.max(p_layer, 0); - if (p_board != null) - { + if (p_board != null) { p_layer = Math.min(p_layer, p_board.get_layer_count() - 1); } layer = p_layer; } - + /** * returns the first corner of the trace */ public abstract Point first_corner(); - + /** * returns the last corner of the trace */ public abstract Point last_corner(); - - public int first_layer() - { + + public int first_layer() { return this.layer; } - - public int last_layer() - { + + public int last_layer() { return this.layer; } - - public int get_layer() - { + + public int get_layer() { return this.layer; } - - public void set_layer(int p_layer) - { + + public void set_layer(int p_layer) { this.layer = p_layer; } - - public int get_half_width() - { + + public int get_half_width() { return half_width; } - + /** * Returns the length of this trace. */ public abstract double get_length(); - + /** * Returns the half with enlarged by the clearance compensation value for the tree * with id number p_ttree_id_no * Equals get_half_width(), if no clearance compensation is used in this tree. */ - public int get_compensated_half_width(ShapeSearchTree p_search_tree) - { + public int get_compensated_half_width(ShapeSearchTree p_search_tree) { int result = this.half_width + p_search_tree.clearance_compensation_value(clearance_class_no(), this.layer); return result; } - - public boolean is_obstacle(Item p_other) - { - if (p_other == this || p_other instanceof ViaObstacleArea || p_other instanceof ComponentObstacleArea) - { + + public boolean is_obstacle(Item p_other) { + if (p_other == this || p_other instanceof ViaObstacleArea || p_other instanceof ComponentObstacleArea) { return false; } - if (p_other instanceof ConductionArea && !((ConductionArea) p_other).get_is_obstacle()) - { + if (p_other instanceof ConductionArea && !((ConductionArea) p_other).get_is_obstacle()) { return false; } - if (!p_other.shares_net(this)) - { + if (!p_other.shares_net(this)) { return true; } return false; } - + /** * Get a list of all items with a connection point on the layer * of this trace equal to its first corner. */ - public Set get_start_contacts() - { + public Set get_start_contacts() { return get_normal_contacts(first_corner(), false); } - + /** * Get a list of all items with a connection point on the layer * of this trace equal to its last corner. */ - public Set get_end_contacts() - { + public Set get_end_contacts() { return get_normal_contacts(last_corner(), false); } - - public Point normal_contact_point(Item p_other) - { + + public Point normal_contact_point(Item p_other) { return p_other.normal_contact_point(this); } - - public Set get_normal_contacts() - { + + public Set get_normal_contacts() { Set result = new TreeSet(); Point start_corner = this.first_corner(); - if (start_corner != null) - { + if (start_corner != null) { result.addAll(get_normal_contacts(start_corner, false)); } Point end_corner = this.last_corner(); - if (end_corner != null) - { + if (end_corner != null) { result.addAll(get_normal_contacts(end_corner, false)); } return result; } - - public boolean is_route() - { + + public boolean is_route() { return !is_user_fixed() && this.net_count() > 0; } - + /** * Returns true, if this trace is not contacted at its first or at its last point. */ - public boolean is_tail() - { + public boolean is_tail() { Collection contact_list = this.get_start_contacts(); - if (contact_list.size() == 0) - { + if (contact_list.size() == 0) { return true; } contact_list = this.get_end_contacts(); return (contact_list.size() == 0); } - - - public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { + + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_trace_colors(this.is_user_fixed()); } - - public int get_draw_priority() - { + + public int get_draw_priority() { return net.freerouting.boardgraphics.Drawable.MAX_DRAW_PRIORITY; } - - public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { + + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_trace_color_intensity(); } - + /** * Get a list of all items having a connection point at p_point * on the layer of this trace. * If p_ignore_net is false, only contacts to items sharing a net with this trace * are calculated. This is the normal case. */ - public Set get_normal_contacts(Point p_point, boolean p_ignore_net) - { - if (p_point == null || !(p_point.equals(this.first_corner()) || p_point.equals(this.last_corner()))) - { + public Set get_normal_contacts(Point p_point, boolean p_ignore_net) { + if (p_point == null || !(p_point.equals(this.first_corner()) || p_point.equals(this.last_corner()))) { return new TreeSet(); } TileShape search_shape = TileShape.get_instance(p_point); Set overlaps = board.overlapping_objects(search_shape, this.layer); - Set result = new TreeSet (); - for (SearchTreeObject curr_ob : overlaps) - { - if (!(curr_ob instanceof Item)) - { + Set result = new TreeSet(); + for (SearchTreeObject curr_ob : overlaps) { + if (!(curr_ob instanceof Item)) { continue; } Item curr_item = (Item) curr_ob; - if (curr_item != this && curr_item.shares_layer(this) && (p_ignore_net || curr_item.shares_net(this))) - { - if (curr_item instanceof Trace) - { + if (curr_item != this && curr_item.shares_layer(this) && (p_ignore_net || curr_item.shares_net(this))) { + if (curr_item instanceof Trace) { Trace curr_trace = (Trace) curr_item; if (p_point.equals(curr_trace.first_corner()) - || p_point.equals(curr_trace.last_corner())) - { + || p_point.equals(curr_trace.last_corner())) { result.add(curr_item); } - } - else if (curr_item instanceof DrillItem) - { + } else if (curr_item instanceof DrillItem) { DrillItem curr_drill_item = (DrillItem) curr_item; - if(p_point.equals(curr_drill_item.get_center())) - { + if (p_point.equals(curr_drill_item.get_center())) { result.add(curr_item); } - } - else if (curr_item instanceof ConductionArea) - { + } else if (curr_item instanceof ConductionArea) { ConductionArea curr_area = (ConductionArea) curr_item; - if (curr_area.get_area().contains(p_point)) - { + if (curr_area.get_area().contains(p_point)) { result.add(curr_item); } } @@ -245,246 +208,201 @@ else if (curr_item instanceof ConductionArea) } return result; } - - Point normal_contact_point(DrillItem p_drill_item) - { + + Point normal_contact_point(DrillItem p_drill_item) { return p_drill_item.normal_contact_point(this); } - - Point normal_contact_point(Trace p_other) - { - if (this.layer != p_other.layer) - { + + Point normal_contact_point(Trace p_other) { + if (this.layer != p_other.layer) { return null; } boolean contact_at_first_corner = this.first_corner().equals(p_other.first_corner()) - || this.first_corner().equals(p_other.last_corner()); + || this.first_corner().equals(p_other.last_corner()); boolean contact_at_last_corner = this.last_corner().equals(p_other.first_corner()) - || this.last_corner().equals(p_other.last_corner()); + || this.last_corner().equals(p_other.last_corner()); Point result; if (!(contact_at_first_corner || contact_at_last_corner) - || contact_at_first_corner && contact_at_last_corner) - { + || contact_at_first_corner && contact_at_last_corner) { // no contact point or more than 1 contact point result = null; - } - else if (contact_at_first_corner) - { + } else if (contact_at_first_corner) { result = this.first_corner(); - } - else // contact at last corner + } else // contact at last corner { result = this.last_corner(); } return result; } - - public boolean is_drillable(int p_net_no) - { + + public boolean is_drillable(int p_net_no) { return this.contains_net(p_net_no); } - + /** * looks, if this trace is connectet to the same object * at its start and its end point */ - public boolean is_overlap() - { + public boolean is_overlap() { Set start_contacts = this.get_start_contacts(); Set end_contacts = this.get_end_contacts(); Iterator it = end_contacts.iterator(); - while (it.hasNext()) - { - if (start_contacts.contains(it.next())) - { + while (it.hasNext()) { + if (start_contacts.contains(it.next())) { return true; } } return false; } - + /** * Returns true, if it is not allowed to change the location of this item by the push algorithm. */ - public boolean is_shove_fixed() - { - if (super.is_shove_fixed()) - { + public boolean is_shove_fixed() { + if (super.is_shove_fixed()) { return true; } - + // check, if the trace belongs to a net, which is not shovable. net.freerouting.rules.Nets nets = this.board.rules.nets; - for (int curr_net_no : this.net_no_arr) - { - if (net.freerouting.rules.Nets.is_normal_net_no(curr_net_no)) - { - if (nets.get(curr_net_no).get_class().is_shove_fixed()) - { + for (int curr_net_no : this.net_no_arr) { + if (net.freerouting.rules.Nets.is_normal_net_no(curr_net_no)) { + if (nets.get(curr_net_no).get_class().is_shove_fixed()) { return true; } } } return false; } - + /** * returns the endpoint of this trace with the shortest distance * to p_from_point */ - public Point nearest_end_point(Point p_from_point) - { + public Point nearest_end_point(Point p_from_point) { Point p1 = first_corner(); Point p2 = last_corner(); FloatPoint from_point = p_from_point.to_float(); double d1 = from_point.distance(p1.to_float()); double d2 = from_point.distance(p2.to_float()); Point result; - if (d1 < d2) - { + if (d1 < d2) { result = p1; - } - else - { + } else { result = p2; } return result; } - + /** * Checks, if this trace can be reached by other items via more than one path */ - public boolean is_cycle() - { - if (this.is_overlap()) - { + public boolean is_cycle() { + if (this.is_overlap()) { return true; } Set visited_items = new TreeSet(); Collection start_contacts = this.get_start_contacts(); // a cycle exists if through expanding the start contact we reach // this trace again via an end contact - for (Item curr_contact : start_contacts) - { + for (Item curr_contact : start_contacts) { // make shure, that all direct neighbours are // expanded from here, to block coming back to // this trace via a start contact. visited_items.add(curr_contact); } boolean ignore_areas = false; - if (this.net_no_arr.length > 0) - { + if (this.net_no_arr.length > 0) { net.freerouting.rules.Net curr_net = this.board.rules.nets.get(this.net_no_arr[0]); - if (curr_net != null && curr_net.get_class() != null) - { + if (curr_net != null && curr_net.get_class() != null) { ignore_areas = curr_net.get_class().get_ignore_cycles_with_areas(); } } - for (Item curr_contact : start_contacts) - { - if (curr_contact.is_cycle_recu(visited_items, this, this, ignore_areas)) - { + for (Item curr_contact : start_contacts) { + if (curr_contact.is_cycle_recu(visited_items, this, this, ignore_areas)) { return true; } } return false; } - - public int shape_layer(int p_index) - { + + public int shape_layer(int p_index) { return layer; } - - public Point[] get_ratsnest_corners() - { + + public Point[] get_ratsnest_corners() { // Use only uncontacted enpoints of the trace. // Otherwise the allocated memory in the calculation of the incompletes might become very big. int stub_count = 0; boolean stub_at_start = false; boolean stub_at_end = false; - if (get_start_contacts().isEmpty()) - { + if (get_start_contacts().isEmpty()) { ++stub_count; stub_at_start = true; } - if (get_end_contacts().isEmpty()) - { + if (get_end_contacts().isEmpty()) { ++stub_count; stub_at_end = true; } Point[] result = new Point[stub_count]; int stub_no = 0; - if (stub_at_start) - { + if (stub_at_start) { result[stub_no] = first_corner(); ++stub_no; } - if (stub_at_end) - { + if (stub_at_end) { result[stub_no] = last_corner(); } - for (int i = 0; i < result.length; ++i) - { - if (result[i] == null) - { + for (int i = 0; i < result.length; ++i) { + if (result[i] == null) { return new Point[0];// Trace is inconsistent } } return result; } - - + /** * checks, that the connection restrictions to the contact pins * are satisfied. If p_at_start, the start of this trace is checked, * else the end. Returns false, if a pin is at that end, where * the connection is checked and the connection is not ok. */ - public abstract boolean check_connection_to_pin(boolean p_at_start); - - public boolean is_selected_by_filter(ItemSelectionFilter p_filter) - { - if (!this.is_selected_by_fixed_filter(p_filter)) - { + public abstract boolean check_connection_to_pin(boolean p_at_start); + + public boolean is_selected_by_filter(ItemSelectionFilter p_filter) { + if (!this.is_selected_by_fixed_filter(p_filter)) { return false; } return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.TRACES); } - - + /** * Looks up touching pins at the first corner and the last corner of the trace. * Used to avoid acid traps. */ - Set touching_pins_at_end_corners() - { + Set touching_pins_at_end_corners() { Set result = new TreeSet(); - if (this.board == null) - { + if (this.board == null) { return result; } Point curr_end_point = this.first_corner(); - for (int i = 0; i < 2; ++i) - { + for (int i = 0; i < 2; ++i) { IntOctagon curr_oct = curr_end_point.surrounding_octagon(); curr_oct = curr_oct.enlarge(this.half_width); Set curr_overlaps = this.board.overlapping_items_with_clearance(curr_oct, this.layer, new int[0], this.clearance_class_no()); - for (Item curr_item : curr_overlaps) - { - if ((curr_item instanceof Pin) && curr_item.shares_net(this)) - { - result.add((Pin)curr_item); + for (Item curr_item : curr_overlaps) { + if ((curr_item instanceof Pin) && curr_item.shares_net(this)) { + result.add((Pin) curr_item); } } curr_end_point = this.last_corner(); } return result; } - - public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { + + public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("trace")); @@ -501,26 +419,23 @@ public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) this.print_connectable_item_info(p_window, p_locale); p_window.newline(); } - - public boolean validate() - { + + public boolean validate() { boolean result = super.validate(); - - if (this.first_corner().equals(this.last_corner())) - { + + if (this.first_corner().equals(this.last_corner())) { System.out.println("Trace.validate: first and last corner are equal"); result = false; } return result; } - - + /** * looks, if this trace can be combined with other traces . * Returns true, if somthing has been combined. */ abstract boolean combine(); - + /** * Looks up traces intersecting with this trace and splits them at the intersection points. * In case of an overlaps, the traces are split at their first and their last common point. @@ -529,21 +444,17 @@ public boolean validate() * If p_clip_shape != null, the split may be resticted to p_clip_shape. */ public abstract Collection split(IntOctagon p_clip_shape); - + /** * Splits this trace into two at p_point. - * Returns the 2 pieces of the splitted trace, or null if nothing was splitted because for example + * Returns the 2 pieces of the splitted trace, or null if nothing was splitted because for example * p_point is not located on this trace. */ public abstract Trace[] split(Point p_point); - + /** * Tries to make this trace shorter according to its rules. * Returns true if the geometry of the trace was changed. */ public abstract boolean pull_tight(PullTightAlgo p_pull_tight_algo); - - - private final int half_width ; // half width of the trace pen - private int layer ; // board layer of the trace } diff --git a/src/main/java/net/freerouting/board/Unit.java b/src/main/java/net/freerouting/board/Unit.java index cb30e1c7..2f37a32e 100644 --- a/src/main/java/net/freerouting/board/Unit.java +++ b/src/main/java/net/freerouting/board/Unit.java @@ -25,139 +25,97 @@ * * @author Alfons Wirtz */ -public enum Unit implements java.io.Serializable -{ - MIL - { - public String toString() - { +public enum Unit implements java.io.Serializable { + MIL { + public String toString() { return "mil"; } }, - INCH - { - public String toString() - { + INCH { + public String toString() { return "inch"; } }, - - MM - { - public String toString() - { + + MM { + public String toString() { return "mm"; } }, - - UM - { - public String toString() - { + + UM { + public String toString() { return "um"; } }; - - /** Scales p_value from p_from_unit to p_to_unit */ - public static double scale(double p_value, Unit p_from_unit, Unit p_to_unit) - { + + public static final double INCH_TO_MM = 25.4; + + /** + * Scales p_value from p_from_unit to p_to_unit + */ + public static double scale(double p_value, Unit p_from_unit, Unit p_to_unit) { double result; - if (p_from_unit == p_to_unit) - { + if (p_from_unit == p_to_unit) { result = p_value; - } - else if (p_from_unit == INCH) - { - if(p_to_unit == MIL) - { - result = p_value * 1000.0; - } - else if (p_to_unit == MM) - { + } else if (p_from_unit == INCH) { + if (p_to_unit == MIL) { + result = p_value * 1000.0; + } else if (p_to_unit == MM) { result = p_value * INCH_TO_MM; - } - else // um + } else // um { result = p_value * INCH_TO_MM * 1000.0; } - } - else if (p_from_unit == MIL) - { - if(p_to_unit == INCH) - { - result = p_value / 1000.0; - } - else if(p_to_unit == MM) - { - result = p_value * INCH_TO_MM; - } - else // um + } else if (p_from_unit == MIL) { + if (p_to_unit == INCH) { + result = p_value / 1000.0; + } else if (p_to_unit == MM) { + result = p_value * INCH_TO_MM; + } else // um { result = (p_value * INCH_TO_MM) * 1000.0; } - } - else if (p_from_unit == MM) - { - if(p_to_unit == INCH) - { - result = p_value / INCH_TO_MM; - } - else if(p_to_unit == UM) - { - result = p_value * 1000; - } - else // mil + } else if (p_from_unit == MM) { + if (p_to_unit == INCH) { + result = p_value / INCH_TO_MM; + } else if (p_to_unit == UM) { + result = p_value * 1000; + } else // mil { result = (p_value * 1000.0) / INCH_TO_MM; } - } - else //UM + } else //UM { - if(p_to_unit == INCH) - { - result = p_value / (INCH_TO_MM * 1000.0); - } - else if(p_to_unit == MM) - { - result = p_value / 1000.0; - } - else // mil + if (p_to_unit == INCH) { + result = p_value / (INCH_TO_MM * 1000.0); + } else if (p_to_unit == MM) { + result = p_value / 1000.0; + } else // mil { result = p_value / INCH_TO_MM; } } return result; } - + /** * Return the unit corresponding to the input string, * or null, if the input string is different from mil, inch and mm. */ - public static Unit from_string(String p_string) - { + public static Unit from_string(String p_string) { Unit result; - if (p_string.compareToIgnoreCase("mil") == 0) - { + if (p_string.compareToIgnoreCase("mil") == 0) { result = MIL; - } - else if (p_string.compareToIgnoreCase("inch") == 0) - { + } else if (p_string.compareToIgnoreCase("inch") == 0) { result = INCH; - } - else if (p_string.compareToIgnoreCase("mm") == 0) - { + } else if (p_string.compareToIgnoreCase("mm") == 0) { result = MM; - } - else if (p_string.compareToIgnoreCase("um") == 0) - { + } else if (p_string.compareToIgnoreCase("um") == 0) { result = UM; - } - else - { + } else { result = null; } return result; } - - public static final double INCH_TO_MM = 25.4; } diff --git a/src/main/java/net/freerouting/board/Via.java b/src/main/java/net/freerouting/board/Via.java index fd10c9c2..fe43ab36 100644 --- a/src/main/java/net/freerouting/board/Via.java +++ b/src/main/java/net/freerouting/board/Via.java @@ -19,63 +19,62 @@ */ package net.freerouting.board; +import net.freerouting.geometry.planar.*; +import net.freerouting.library.Padstack; + import java.util.Collection; import java.util.Iterator; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Shape; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.library.Padstack; - /** * Class describing the functionality of an electrical Item on the board, * which may have a shape on several layer, whose geometry is described by a * padstack. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Via extends DrillItem implements java.io.Serializable -{ +public class Via extends DrillItem implements java.io.Serializable { + + /** + * True, if coppersharing of this via with smd pins of the same net is allowed. + */ + public final boolean attach_allowed; + private Padstack padstack; + transient private Shape[] precalculated_shapes = null; + /** + * Temporary data used in the autoroute algorithm. + */ + transient private net.freerouting.autoroute.ExpansionDrill autoroute_drill_info = null; - /** Creates a new instance of Via with the input parameters*/ + /** + * Creates a new instance of Via with the input parameters + */ public Via(Padstack p_padstack, Point p_center, int[] p_net_no_arr, int p_clearance_type, int p_id_no, - int p_group_no, FixedState p_fixed_state, boolean p_attach_allowed, BasicBoard p_board) - { + int p_group_no, FixedState p_fixed_state, boolean p_attach_allowed, BasicBoard p_board) { super(p_center, p_net_no_arr, p_clearance_type, p_id_no, p_group_no, p_fixed_state, p_board); this.padstack = p_padstack; this.attach_allowed = p_attach_allowed; } - public Item copy(int p_id_no) - { + public Item copy(int p_id_no) { return new Via(padstack, get_center(), net_no_arr, clearance_class_no(), p_id_no, get_component_no(), get_fixed_state(), attach_allowed, board); } - public Shape get_shape(int p_index) - { - if (padstack == null) - { + public Shape get_shape(int p_index) { + if (padstack == null) { System.out.println("Via.get_shape: padstack is null"); return null; } - if (this.precalculated_shapes == null) - { + if (this.precalculated_shapes == null) { this.precalculated_shapes = new Shape[padstack.to_layer() - padstack.from_layer() + 1]; - for (int i = 0; i < this.precalculated_shapes.length; ++i) - { + for (int i = 0; i < this.precalculated_shapes.length; ++i) { int padstack_layer = i + this.first_layer(); Vector translate_vector = get_center().difference_by(Point.ZERO); Shape curr_shape = padstack.get_shape(padstack_layer); - if (curr_shape == null) - { + if (curr_shape == null) { this.precalculated_shapes[i] = null; - } - else - { + } else { this.precalculated_shapes[i] = (Shape) curr_shape.translate_by(translate_vector); } } @@ -83,41 +82,32 @@ public Shape get_shape(int p_index) return this.precalculated_shapes[p_index]; } - public Padstack get_padstack() - { + public Padstack get_padstack() { return padstack; } - public void set_padstack(Padstack p_padstack) - { + public void set_padstack(Padstack p_padstack) { padstack = p_padstack; } - public boolean is_route() - { + public boolean is_route() { return !is_user_fixed() && this.net_count() > 0; } - public boolean is_obstacle(Item p_other) - { - if (p_other == this || p_other instanceof ComponentObstacleArea) - { + public boolean is_obstacle(Item p_other) { + if (p_other == this || p_other instanceof ComponentObstacleArea) { return false; } - if ((p_other instanceof ConductionArea) && !((ConductionArea) p_other).get_is_obstacle()) - { + if ((p_other instanceof ConductionArea) && !((ConductionArea) p_other).get_is_obstacle()) { return false; } - if (!p_other.shares_net(this)) - { + if (!p_other.shares_net(this)) { return true; } - if (p_other instanceof Trace) - { + if (p_other instanceof Trace) { return false; } - if (this.attach_allowed && p_other instanceof Pin && ((Pin) p_other).drill_allowed()) - { + if (this.attach_allowed && p_other instanceof Pin && ((Pin) p_other).drill_allowed()) { return false; } return true; @@ -126,37 +116,30 @@ public boolean is_obstacle(Item p_other) /** * Checks, if the Via has contacts on at most 1 layer. */ - public boolean is_tail() - { + public boolean is_tail() { Collection contact_list = this.get_normal_contacts(); - if (contact_list.size() <= 1) - { + if (contact_list.size() <= 1) { return true; } Iterator it = contact_list.iterator(); Item curr_contact_item = it.next(); int first_contact_first_layer = curr_contact_item.first_layer(); int first_contact_last_layer = curr_contact_item.last_layer(); - while (it.hasNext()) - { + while (it.hasNext()) { curr_contact_item = it.next(); - if (curr_contact_item.first_layer() != first_contact_first_layer || curr_contact_item.last_layer() != first_contact_last_layer) - { + if (curr_contact_item.first_layer() != first_contact_first_layer || curr_contact_item.last_layer() != first_contact_last_layer) { return false; } } return true; } - public void change_placement_side(IntPoint p_pole) - { - if (this.board == null) - { + public void change_placement_side(IntPoint p_pole) { + if (this.board == null) { return; } Padstack new_padstack = this.board.library.get_mirrored_via_padstack(this.padstack); - if (new_padstack == null) - { + if (new_padstack == null) { return; } this.padstack = new_padstack; @@ -164,89 +147,69 @@ public void change_placement_side(IntPoint p_pole) clear_derived_data(); } - public net.freerouting.autoroute.ExpansionDrill get_autoroute_drill_info(ShapeSearchTree p_autoroute_tree) - { - if (this.autoroute_drill_info == null) - { + public net.freerouting.autoroute.ExpansionDrill get_autoroute_drill_info(ShapeSearchTree p_autoroute_tree) { + if (this.autoroute_drill_info == null) { net.freerouting.autoroute.ItemAutorouteInfo via_autoroute_info = this.get_autoroute_info(); TileShape curr_drill_shape = TileShape.get_instance(this.get_center()); this.autoroute_drill_info = new net.freerouting.autoroute.ExpansionDrill(curr_drill_shape, this.get_center(), this.first_layer(), this.last_layer()); int via_layer_count = this.last_layer() - this.first_layer() + 1; - for (int i = 0; i < via_layer_count; ++i) - { + for (int i = 0; i < via_layer_count; ++i) { this.autoroute_drill_info.room_arr[i] = via_autoroute_info.get_expansion_room(i, p_autoroute_tree); } } return this.autoroute_drill_info; } - public void clear_derived_data() - { + public void clear_derived_data() { super.clear_derived_data(); this.precalculated_shapes = null; this.autoroute_drill_info = null; } - - public void clear_autoroute_info() - { + + public void clear_autoroute_info() { super.clear_autoroute_info(); this.autoroute_drill_info = null; } - public boolean is_selected_by_filter(ItemSelectionFilter p_filter) - { - if (!this.is_selected_by_fixed_filter(p_filter)) - { + public boolean is_selected_by_filter(ItemSelectionFilter p_filter) { + if (!this.is_selected_by_fixed_filter(p_filter)) { return false; } return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.VIAS); } - public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { java.awt.Color[] result; - if (this.net_count() == 0) - { + if (this.net_count() == 0) { // display unconnected vias as obstacles result = p_graphics_context.get_obstacle_colors(); - } - else if (this.first_layer() >= this.last_layer()) - { + } else if (this.first_layer() >= this.last_layer()) { // display vias with only one layer as pins result = p_graphics_context.get_pin_colors(); - } - else - { + } else { result = p_graphics_context.get_via_colors(this.is_user_fixed()); } return result; } - public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { double result; - if (this.net_count() == 0) - { + if (this.net_count() == 0) { // display unconnected vias as obstacles result = p_graphics_context.get_obstacle_color_intensity(); - } - else if (this.first_layer() >= this.last_layer()) - { + } else if (this.first_layer() >= this.last_layer()) { // display vias with only one layer as pins result = p_graphics_context.get_pin_color_intensity(); - } - else - { + } else { result = p_graphics_context.get_via_color_intensity(); } return result; } - public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { + public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("via")); @@ -258,21 +221,12 @@ public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) p_window.newline(); } - public boolean write(java.io.ObjectOutputStream p_stream) - { - try - { + public boolean write(java.io.ObjectOutputStream p_stream) { + try { p_stream.writeObject(this); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { return false; } return true; } - private Padstack padstack; - /** True, if coppersharing of this via with smd pins of the same net is allowed. */ - public final boolean attach_allowed; - transient private Shape[] precalculated_shapes = null; - /** Temporary data used in the autoroute algorithm. */ - transient private net.freerouting.autoroute.ExpansionDrill autoroute_drill_info = null; } diff --git a/src/main/java/net/freerouting/board/ViaObstacleArea.java b/src/main/java/net/freerouting/board/ViaObstacleArea.java index 668a9b88..d4f0379b 100644 --- a/src/main/java/net/freerouting/board/ViaObstacleArea.java +++ b/src/main/java/net/freerouting/board/ViaObstacleArea.java @@ -26,65 +26,55 @@ /** * Describes Areas on the board, where vias are not allowed. * - * @author alfons + * @author alfons */ -public class ViaObstacleArea extends ObstacleArea -{ - +public class ViaObstacleArea extends ObstacleArea { + /** * Creates a new area item which may belong to several nets */ ViaObstacleArea(Area p_area, int p_layer, Vector p_translation, double p_rotation_in_degree, boolean p_side_changed, - int[] p_net_no_arr, int p_clearance_type, int p_id_no, int p_group_no, String p_name, FixedState p_fixed_state, BasicBoard p_board) - { - super(p_area, p_layer, p_translation, p_rotation_in_degree, p_side_changed, p_net_no_arr, + int[] p_net_no_arr, int p_clearance_type, int p_id_no, int p_group_no, String p_name, FixedState p_fixed_state, BasicBoard p_board) { + super(p_area, p_layer, p_translation, p_rotation_in_degree, p_side_changed, p_net_no_arr, p_clearance_type, p_id_no, p_group_no, p_name, p_fixed_state, p_board); } - + /** * Creates a new area item without net */ ViaObstacleArea(Area p_area, int p_layer, Vector p_translation, double p_rotation_in_degree, boolean p_side_changed, - int p_clearance_type, int p_id_no, int p_group_no, String p_name, FixedState p_fixed_state, BasicBoard p_board) - { + int p_clearance_type, int p_id_no, int p_group_no, String p_name, FixedState p_fixed_state, BasicBoard p_board) { this(p_area, p_layer, p_translation, p_rotation_in_degree, p_side_changed, new int[0], p_clearance_type, p_id_no, p_group_no, p_name, p_fixed_state, p_board); } - - public Item copy(int p_id_no) - { - int [] copied_net_nos = new int[net_no_arr.length]; + + public Item copy(int p_id_no) { + int[] copied_net_nos = new int[net_no_arr.length]; System.arraycopy(net_no_arr, 0, copied_net_nos, 0, net_no_arr.length); return new ViaObstacleArea(get_relative_area(), get_layer(), get_translation(), get_rotation_in_degree(), - get_side_changed(), copied_net_nos, clearance_class_no(), p_id_no, get_component_no(), + get_side_changed(), copied_net_nos, clearance_class_no(), p_id_no, get_component_no(), this.name, get_fixed_state(), board); } - - public boolean is_obstacle(Item p_other) - { - if (p_other.shares_net(this)) - { + + public boolean is_obstacle(Item p_other) { + if (p_other.shares_net(this)) { return false; } return p_other instanceof Via; } - - public boolean is_trace_obstacle(int p_net_no) - { + + public boolean is_trace_obstacle(int p_net_no) { return false; } - - public boolean is_selected_by_filter(ItemSelectionFilter p_filter) - { - if (!this.is_selected_by_fixed_filter(p_filter)) - { + + public boolean is_selected_by_filter(ItemSelectionFilter p_filter) { + if (!this.is_selected_by_fixed_filter(p_filter)) { return false; } return p_filter.is_selected(ItemSelectionFilter.SelectableChoices.VIA_KEEPOUT); } - - public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("via_keepout")); this.print_shape_info(p_window, p_locale); @@ -92,15 +82,13 @@ public void print_info(ObjectInfoPanel p_window, java.util.Locale p_locale) this.print_clearance_violation_info(p_window, p_locale); p_window.newline(); } - - public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { + + public java.awt.Color[] get_draw_colors(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_via_obstacle_colors(); } - - public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) - { + + public double get_draw_intensity(net.freerouting.boardgraphics.GraphicsContext p_graphics_context) { return p_graphics_context.get_via_obstacle_color_intensity(); } - + } diff --git a/src/main/java/net/freerouting/board/package.html b/src/main/java/net/freerouting/board/package.html index 3b397ae8..bffe051b 100644 --- a/src/main/java/net/freerouting/board/package.html +++ b/src/main/java/net/freerouting/board/package.html @@ -1,5 +1,6 @@ -java.text package - Contains classes describing items on a printed circuit board and the board itself. -
-
-

The class LayeredBoard implements elementary functionality for the layout of 2-dimensional items on a board. The board may have several layers.  It allows to insert, change, or delete items, or to check, if inserting would result in violations (overlaps) with other items. For fast checking, picking  and changing items  the class contains a 2-dimensional search tree, whose entries point into the list of items on the board.  The search tree  is decoupled from the items it is pointing to and may even point into several different databases at the same time.

-

The class LayeredBoard implements elementary functionality for the layout of 2-dimensional items on a board. The board may have several layers.  It allows to insert, change, or delete items, or to check, if inserting would result in violations (overlaps) with other items. For fast checking, picking  and changing items  the class contains a 2-dimensional search tree, whose entries point into the list of items on the board.  The search tree  is decoupled from the items it is pointing to and may even point into several different databases at the same time. +

+ +

LayeredBoard contains also a list of components, a library of packages and padstacks, and a collection of rules and restrictions, which must be respected by the items on the board.

-

The class RoutingBoard derived from BasicBoard contains higher level functionality, such as shoving items and pulling tight traces, and autorouting incomplete connections. contains also a list of components, a library of packages and padstacks, and a collection of rules and restrictions, which must be respected by the items on the board.

+ +

The class RoutingBoard derived from BasicBoard contains higher level functionality, such as shoving items and pulling tight traces, and autorouting incomplete connections.

-

The base classes of all physical items on the board is the abstract class  Item. Items must implement the interfaces ShapeTree.Storable and Drawable, so that they can be stored in a search ree and painted onto a graphics screen. Additionally an item contains a pointer to the physical board the item is on, an id number and a list of numbers of nets it belongs to, which may be empty.

-

Classes derived from Item are currently Trace, DrillItem , ObstacleArea and BoardOutline. The class ObstacleArea describe areas on the board, which may be conduction areas or obstacle areas for traces or vias. The abstact class DrillItem describes items with a layer range, a centre point and a (convex) shape on each  layer. It has the two implementations Pin and Via. Pins belong to a component, and its shapes are defined by the padstack of the corresponding pin of the components library package. The shapes of a Via are defined directly by a library padstack. The class abstract Trace is used for paths connecting  drill items and eventual conduction areas. The only implementation of the class Trace is currently the class PolylineTrace.  It adds the concrete description of the geometric path as a Polyline to the class Trace. The reason, why Polylines and not Polygons are used to implement the paths of non-curved tracess, has to do with numerical exactness and performance, as described in the package geometry.planar.

-

Items, which may be electrically connected must implement the interface Connectable. Connectable Items are currently Pins, Vias, Traces and ConductionAreas.

-
-
- \ No newline at end of file + +

The base classes of all physical items on the board is the abstract class  Item. Items must implement the interfaces ShapeTree.Storable and Drawable, so that they can be stored in a search ree and painted onto a graphics screen. Additionally an item contains a pointer to the physical board the item is on, an id number and a list of numbers of nets it belongs to, which may be empty. +

+ +

Classes derived from Item are currently Trace, DrillItem , ObstacleArea and BoardOutline. The class ObstacleArea describe areas on the board, which may be conduction areas or obstacle areas for traces or vias. The abstact class DrillItem describes items with a layer range, a centre point and a (convex) shape on each  layer. It has the two implementations Pin and Via. Pins belong to a component, and its shapes are defined by the padstack of the corresponding pin of the components library package. The shapes of a Via are defined directly by a library padstack. The class abstract Trace is used for paths connecting  drill items and eventual conduction areas. The only implementation of the class Trace is currently the class PolylineTrace.  It adds the concrete description of the geometric path as a Polyline to the class Trace. The reason, why Polylines and not Polygons are used to implement the paths of non-curved tracess, has to do with numerical exactness and performance, as described in the package geometry.planar.

+ +

Items, which may be electrically connected must implement the interface Connectable. Connectable Items are currently Pins, Vias, Traces and ConductionAreas.

+ + + + \ No newline at end of file diff --git a/src/main/java/net/freerouting/boardgraphics/ColorIntensityTable.java b/src/main/java/net/freerouting/boardgraphics/ColorIntensityTable.java index dedddc2f..7e074ffb 100644 --- a/src/main/java/net/freerouting/boardgraphics/ColorIntensityTable.java +++ b/src/main/java/net/freerouting/boardgraphics/ColorIntensityTable.java @@ -24,18 +24,18 @@ * The color intensities for each item type. * The values are between 0 (invisible) and 1 (full intensity). * - * @author alfons + * @author alfons */ -public class ColorIntensityTable implements java.io.Serializable -{ - +public class ColorIntensityTable implements java.io.Serializable { + + private final double[] arr; + /** * Creates a new instance of ColorIntensityTable. * The elements of p_intensities are expected between 0 and 1. */ - public ColorIntensityTable() - { - arr = new double [ObjectNames.values().length]; + public ColorIntensityTable() { + arr = new double[ObjectNames.values().length]; arr[ObjectNames.TRACES.ordinal()] = 0.4; arr[ObjectNames.VIAS.ordinal()] = 0.6; arr[ObjectNames.PINS.ordinal()] = 0.6; @@ -48,44 +48,35 @@ public ColorIntensityTable() arr[ObjectNames.INCOMPLETES.ordinal()] = 1; arr[ObjectNames.LENGTH_MATCHING_AREAS.ordinal()] = 0.1; } - + /** * Copy constructor. */ - public ColorIntensityTable(ColorIntensityTable p_color_intesity_table) - { - this.arr = new double [p_color_intesity_table.arr.length]; - for (int i = 0; i < this.arr.length; ++i) - { + public ColorIntensityTable(ColorIntensityTable p_color_intesity_table) { + this.arr = new double[p_color_intesity_table.arr.length]; + for (int i = 0; i < this.arr.length; ++i) { this.arr[i] = p_color_intesity_table.arr[i]; } } - - public double get_value(int p_no) - { - if (p_no < 0 || p_no >= ObjectNames.values().length) - { + + public double get_value(int p_no) { + if (p_no < 0 || p_no >= ObjectNames.values().length) { System.out.println("ColorIntensityTable.get_value: p_no out of range"); return 0; } return arr[p_no]; } - - public void set_value(int p_no, double p_value) - { - if (p_no < 0 || p_no >= ObjectNames.values().length) - { + + public void set_value(int p_no, double p_value) { + if (p_no < 0 || p_no >= ObjectNames.values().length) { System.out.println("ColorIntensityTable.set_value: p_no out of range"); return; } - arr [p_no] = p_value; + arr[p_no] = p_value; } - - private final double [] arr; - - public enum ObjectNames - { - TRACES, VIAS, PINS, CONDUCTION_AREAS, KEEPOUTS, VIA_KEEPOUTS, PLACE_KEEPOUTS, COMPONENT_OUTLINES, + + public enum ObjectNames { + TRACES, VIAS, PINS, CONDUCTION_AREAS, KEEPOUTS, VIA_KEEPOUTS, PLACE_KEEPOUTS, COMPONENT_OUTLINES, HILIGHT, INCOMPLETES, LENGTH_MATCHING_AREAS } } diff --git a/src/main/java/net/freerouting/boardgraphics/ColorTableModel.java b/src/main/java/net/freerouting/boardgraphics/ColorTableModel.java index d940a6c6..3f72e544 100644 --- a/src/main/java/net/freerouting/boardgraphics/ColorTableModel.java +++ b/src/main/java/net/freerouting/boardgraphics/ColorTableModel.java @@ -26,34 +26,31 @@ * * @author Alfons Wirtz */ -public abstract class ColorTableModel extends AbstractTableModel -{ +public abstract class ColorTableModel extends AbstractTableModel { - protected ColorTableModel(int p_row_count, java.util.Locale p_locale) - { - this.data = new Object[p_row_count] []; + protected final Object[][] data; + protected final java.util.Locale locale; + + protected ColorTableModel(int p_row_count, java.util.Locale p_locale) { + this.data = new Object[p_row_count][]; this.locale = p_locale; } - + protected ColorTableModel(java.io.ObjectInputStream p_stream) - throws java.io.IOException, java.lang.ClassNotFoundException - { + throws java.io.IOException, java.lang.ClassNotFoundException { this.data = (Object[][]) p_stream.readObject(); this.locale = (java.util.Locale) p_stream.readObject(); } - public int getRowCount() - { + public int getRowCount() { return data.length; } - public Object getValueAt(int p_row, int p_col) - { + public Object getValueAt(int p_row, int p_col) { return data[p_row][p_col]; } - public void setValueAt(Object p_value, int p_row, int p_col) - { + public void setValueAt(Object p_value, int p_row, int p_col) { data[p_row][p_col] = p_value; fireTableCellUpdated(p_row, p_col); } @@ -64,19 +61,13 @@ public void setValueAt(Object p_value, int p_row, int p_col) * then the last column would contain text ("true"/"false"), * rather than a check box. */ - public Class getColumnClass(int p_c) - { + public Class getColumnClass(int p_c) { return getValueAt(0, p_c).getClass(); } - protected void write_object(java.io.ObjectOutputStream p_stream) - throws java.io.IOException - { + throws java.io.IOException { p_stream.writeObject(this.data); p_stream.writeObject(this.locale); } - - protected final Object[][] data; - protected final java.util.Locale locale; } diff --git a/src/main/java/net/freerouting/boardgraphics/CoordinateTransform.java b/src/main/java/net/freerouting/boardgraphics/CoordinateTransform.java index 749c0245..7c322908 100644 --- a/src/main/java/net/freerouting/boardgraphics/CoordinateTransform.java +++ b/src/main/java/net/freerouting/boardgraphics/CoordinateTransform.java @@ -20,7 +20,7 @@ import net.freerouting.geometry.planar.IntBox; import net.freerouting.geometry.planar.Limits; -import java.awt.Dimension; +import java.awt.*; import java.awt.geom.Point2D; /** @@ -30,39 +30,52 @@ */ -public class CoordinateTransform implements java.io.Serializable -{ - public CoordinateTransform(IntBox p_design_box, Dimension p_panel_bounds ) - { +public class CoordinateTransform implements java.io.Serializable { + final IntBox design_box; + final IntBox design_box_with_offset; + final Dimension screen_bounds; + private final double scale_factor; + private final double display_x_offset; + private final double display_y_offset; + /** + * Left side and right side of the board are swapped. + */ + private boolean mirror_left_right = false; + /** + * Top side and bottom side of the board are swapped. + */ + private boolean mirror_top_bottom = true; + private double rotation = 0; + private FloatPoint rotation_pole; + + public CoordinateTransform(IntBox p_design_box, Dimension p_panel_bounds) { this.screen_bounds = p_panel_bounds; this.design_box = p_design_box; this.rotation_pole = p_design_box.centre_of_gravity(); - + int min_ll = Math.min(p_design_box.ll.x, p_design_box.ll.y); int max_ur = Math.max(p_design_box.ur.x, p_design_box.ur.y); - if (Math.max(Math.abs(min_ll), Math.abs(max_ur)) <= 0.3 * Limits.CRIT_INT) - { + if (Math.max(Math.abs(min_ll), Math.abs(max_ur)) <= 0.3 * Limits.CRIT_INT) { // create an offset to p_design_box to enable deep zoom out double design_offset = Math.max(p_design_box.width(), p_design_box.height()); design_box_with_offset = p_design_box.offset(design_offset); - } - else - { + } else { // no offset because of danger of integer overflow design_box_with_offset = p_design_box; } - - double x_scale_factor = screen_bounds.getWidth()/design_box_with_offset.width(); - double y_scale_factor = screen_bounds.getHeight()/design_box_with_offset.height(); - - scale_factor = Math.min(x_scale_factor, y_scale_factor) ; + + double x_scale_factor = screen_bounds.getWidth() / design_box_with_offset.width(); + double y_scale_factor = screen_bounds.getHeight() / design_box_with_offset.height(); + + scale_factor = Math.min(x_scale_factor, y_scale_factor); display_x_offset = scale_factor * design_box_with_offset.ll.x; - display_y_offset = scale_factor * design_box_with_offset.ll.y ; + display_y_offset = scale_factor * design_box_with_offset.ll.y; } - - /** Copy constructor */ - public CoordinateTransform(CoordinateTransform p_coordinate_transform) - { + + /** + * Copy constructor + */ + public CoordinateTransform(CoordinateTransform p_coordinate_transform) { this.screen_bounds = new Dimension(p_coordinate_transform.screen_bounds); this.design_box = new IntBox(p_coordinate_transform.design_box.ll, p_coordinate_transform.design_box.ur); this.rotation_pole = new FloatPoint(p_coordinate_transform.rotation_pole.x, p_coordinate_transform.rotation_pole.y); @@ -74,109 +87,86 @@ public CoordinateTransform(CoordinateTransform p_coordinate_transform) this.mirror_top_bottom = p_coordinate_transform.mirror_top_bottom; this.rotation = p_coordinate_transform.rotation; } - + /** * scale a value from the board to the screen coordinate system */ - public double board_to_screen(double p_val) - { - return p_val * scale_factor ; + public double board_to_screen(double p_val) { + return p_val * scale_factor; } - + /** * scale a value the screen to the board coordinate system */ - public double screen_to_board(double p_val) - { + public double screen_to_board(double p_val) { return p_val / scale_factor; } - - + /** * transform a geometry.planar.FloatPoint to a java.awt.geom.Point2D */ - public Point2D board_to_screen(FloatPoint p_point) - { + public Point2D board_to_screen(FloatPoint p_point) { FloatPoint rotated_point = p_point.rotate(this.rotation, this.rotation_pole); - + double x, y; - if (this.mirror_left_right) - { - x = (design_box_with_offset.width() - rotated_point.x - 1) * scale_factor + display_x_offset; - } - else - { + if (this.mirror_left_right) { + x = (design_box_with_offset.width() - rotated_point.x - 1) * scale_factor + display_x_offset; + } else { x = rotated_point.x * scale_factor - display_x_offset; } - if (this.mirror_top_bottom) - { + if (this.mirror_top_bottom) { y = (design_box_with_offset.height() - rotated_point.y - 1) * scale_factor + display_y_offset; - } - else - { + } else { y = rotated_point.y * scale_factor - display_y_offset; } return new Point2D.Double(x, y); } - + /** * Transform a java.awt.geom.Point2D to a geometry.planar.FloatPoint */ - public FloatPoint screen_to_board(Point2D p_point) - { + public FloatPoint screen_to_board(Point2D p_point) { double x, y; - if (this.mirror_left_right) - { - x = design_box_with_offset.width() -(p_point.getX() - display_x_offset) / scale_factor - 1; - } - else - { - x = (p_point.getX() + display_x_offset)/ scale_factor; + if (this.mirror_left_right) { + x = design_box_with_offset.width() - (p_point.getX() - display_x_offset) / scale_factor - 1; + } else { + x = (p_point.getX() + display_x_offset) / scale_factor; } - if (this.mirror_top_bottom) - { - y = design_box_with_offset.height() -(p_point.getY() - display_y_offset) / scale_factor - 1; - } - else - { - y = (p_point.getY() + display_y_offset)/ scale_factor; + if (this.mirror_top_bottom) { + y = design_box_with_offset.height() - (p_point.getY() - display_y_offset) / scale_factor - 1; + } else { + y = (p_point.getY() + display_y_offset) / scale_factor; } FloatPoint result = new FloatPoint(x, y); return result.rotate(-this.rotation, this.rotation_pole); } - + /** * Transforms an angle in radian on the board to an angle on the screen. */ - public double board_to_screen_angle(double p_angle) - { + public double board_to_screen_angle(double p_angle) { double result = p_angle + this.rotation; - if (this.mirror_left_right) - { + if (this.mirror_left_right) { result = Math.PI - result; } - if (this.mirror_top_bottom) - { + if (this.mirror_top_bottom) { result = -result; } - while (result >= 2 * Math.PI) - { + while (result >= 2 * Math.PI) { result -= 2 * Math.PI; } - while (result < 0) - { + while (result < 0) { result += 2 * Math.PI; } return result; } - + /** * Transform a geometry.planar.IntBox to a java.awt.Rectangle * If the internal rotation is not a multiple of Pi/2, a bounding rectangle of the * rotated rectangular shape is returned. */ - public java.awt.Rectangle board_to_screen(IntBox p_box) - { + public java.awt.Rectangle board_to_screen(IntBox p_box) { Point2D corner_1 = board_to_screen(p_box.ll.to_float()); Point2D corner_2 = board_to_screen(p_box.ur.to_float()); double ll_x = Math.min(corner_1.getX(), corner_2.getX()); @@ -184,18 +174,17 @@ public java.awt.Rectangle board_to_screen(IntBox p_box) double dx = Math.abs(corner_2.getX() - corner_1.getX()); double dy = Math.abs(corner_2.getY() - corner_1.getY()); java.awt.Rectangle result = - new java.awt. Rectangle((int) Math.floor(ll_x), (int) Math.floor(ll_y), - (int) Math.ceil(dx), (int) Math.ceil(dy)); + new java.awt.Rectangle((int) Math.floor(ll_x), (int) Math.floor(ll_y), + (int) Math.ceil(dx), (int) Math.ceil(dy)); return result; } - + /** * Transform a java.awt.Rectangle to a geometry.planar.IntBox * If the internal rotation is not a multiple of Pi/2, a bounding box of the * rotated rectangular shape is returned. */ - public IntBox screen_to_board(java.awt.Rectangle p_rect) - { + public IntBox screen_to_board(java.awt.Rectangle p_rect) { FloatPoint corner_1 = screen_to_board(new Point2D.Double(p_rect.getX(), p_rect.getY())); FloatPoint corner_2 = screen_to_board(new Point2D.Double(p_rect.getX() + p_rect.getWidth(), p_rect.getY() + p_rect.getHeight())); @@ -205,95 +194,65 @@ public IntBox screen_to_board(java.awt.Rectangle p_rect) int ury = (int) Math.ceil(Math.max(corner_1.y, corner_2.y)); return new IntBox(llx, lly, urx, ury); } - - /** - * If p_value is true, the left side and the right side of the board will be swapped. - */ - public void set_mirror_left_right(boolean p_value) - { - mirror_left_right = p_value; - } - + /** * Returns, if the left side and the right side of the board are swapped. */ - public boolean is_mirror_left_right() - { + public boolean is_mirror_left_right() { return mirror_left_right; } - + /** - * If p_value is true, the top side and the botton side of the board will be swapped. + * If p_value is true, the left side and the right side of the board will be swapped. */ - public void set_mirror_top_bottom(boolean p_value) - { - // Because the origin of display is the upper left corner, the internal value - // will be opposite to the input value of this function. - mirror_top_bottom = !p_value; + public void set_mirror_left_right(boolean p_value) { + mirror_left_right = p_value; } - + /** * Returns, if the top side and the botton side of the board are swapped. */ - public boolean is_mirror_top_bottom() - { + public boolean is_mirror_top_bottom() { // Because the origin of display is the upper left corner, the internal value // is opposite to the result of this function. return !mirror_top_bottom; } - + /** - * Sets the rotation of the displayed board to p_value. + * If p_value is true, the top side and the botton side of the board will be swapped. */ - public void set_rotation(double p_value) - { - rotation = p_value; + public void set_mirror_top_bottom(boolean p_value) { + // Because the origin of display is the upper left corner, the internal value + // will be opposite to the input value of this function. + mirror_top_bottom = !p_value; } - + /** * Returns the rotation of the displayed board. */ - public double get_rotation() - { + public double get_rotation() { return rotation; } - + + /** + * Sets the rotation of the displayed board to p_value. + */ + public void set_rotation(double p_value) { + rotation = p_value; + } + /** * Returns the internal rotation snapped to the nearest multiple of 90 degree. * The result will be 0, 1, 2 or 3. */ - public int get_90_degree_rotation() - { - int multiple = (int) Math.round(Math.toDegrees(rotation) / 90.0); - while (multiple < 0) - { + public int get_90_degree_rotation() { + int multiple = (int) Math.round(Math.toDegrees(rotation) / 90.0); + while (multiple < 0) { multiple += 4; } - while (multiple >= 4) - { + while (multiple >= 4) { multiple -= 4; } return multiple; } - - final IntBox design_box; - final IntBox design_box_with_offset ; - final Dimension screen_bounds ; - private final double scale_factor ; - private final double display_x_offset; - private final double display_y_offset; - - /** - * Left side and right side of the board are swapped. - */ - private boolean mirror_left_right = false; - - /** - * Top side and bottom side of the board are swapped. - */ - private boolean mirror_top_bottom = true; - - private double rotation = 0; - - private FloatPoint rotation_pole; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/boardgraphics/Drawable.java b/src/main/java/net/freerouting/boardgraphics/Drawable.java index f713be2c..f5cc842c 100644 --- a/src/main/java/net/freerouting/boardgraphics/Drawable.java +++ b/src/main/java/net/freerouting/boardgraphics/Drawable.java @@ -16,8 +16,7 @@ package net.freerouting.boardgraphics; -import java.awt.Color; -import java.awt.Graphics; +import java.awt.*; /** * items to be drawn by the functions in GraphicsContext @@ -26,39 +25,38 @@ * @author Alfons Wirtz */ -public interface Drawable -{ +public interface Drawable { + static final int MIN_DRAW_PRIORITY = 1; + static final int MIDDLE_DRAW_PRIORITY = 3; + static final int MAX_DRAW_PRIORITY = 3; + /** * Draws this item to the device provided in p_graphics_context. * p_color_arr is an array of dimenssion layer_count. * p_intensity is a number between between 0 and 1. */ void draw(Graphics p_g, GraphicsContext p_graphics_context, Color[] p_color_arr, double p_intensity); - + /** * Draws this item to the device provided in p_graphics_context. * It is drawn on each layer with the same color p_color. * p_intensity is a number between 0 and 1. */ void draw(Graphics p_g, GraphicsContext p_graphics_context, Color p_color, double p_intensity); - + /** * Returns the priority for drawing an item. * Items with higher priority are drawn later than items with lower priority. */ int get_draw_priority(); - + /** * Gets the drawing intensity in the alpha blending for this item. */ double get_draw_intensity(GraphicsContext p_graphics_context); - + /** * gets the draw colors for this object from p_graphics_context */ Color[] get_draw_colors(GraphicsContext p_graphics_context); - - static final int MIN_DRAW_PRIORITY = 1; - static final int MIDDLE_DRAW_PRIORITY = 3; - static final int MAX_DRAW_PRIORITY = 3; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/boardgraphics/GraphicsContext.java b/src/main/java/net/freerouting/boardgraphics/GraphicsContext.java index 28eb10f4..82aff810 100644 --- a/src/main/java/net/freerouting/boardgraphics/GraphicsContext.java +++ b/src/main/java/net/freerouting/boardgraphics/GraphicsContext.java @@ -17,29 +17,12 @@ package net.freerouting.boardgraphics; import net.freerouting.geometry.planar.Area; -import net.freerouting.geometry.planar.Circle; -import net.freerouting.geometry.planar.Ellipse; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.PolylineShape; +import net.freerouting.geometry.planar.*; import net.freerouting.geometry.planar.Shape; -import net.freerouting.geometry.planar.TileShape; - -import java.awt.AlphaComposite; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; + +import java.awt.*; import java.awt.Polygon; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.geom.Ellipse2D; -import java.awt.geom.GeneralPath; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; -import java.awt.geom.AffineTransform; +import java.awt.geom.*; /** @@ -49,62 +32,93 @@ */ -public class GraphicsContext implements java.io.Serializable -{ - public GraphicsContext( IntBox p_design_bounds, - Dimension p_panel_bounds, net.freerouting.board.LayerStructure p_layer_structure, java.util.Locale p_locale) - { +public class GraphicsContext implements java.io.Serializable { + private static final int update_offset = 10000; + private static final boolean show_line_segments = false; + private static final boolean show_area_division = false; + public transient ItemColorTableModel item_color_table; + public transient OtherColorTableModel other_color_table; + public ColorIntensityTable color_intensity_table; + public CoordinateTransform coordinate_transform = null; + /** + * layer_visibility_arr[i] is between 0 and 1, for each layer i, 0 is invisible and 1 fully visible. + */ + private double[] layer_visibility_arr; + /** + * The factor for autoomatic layer dimming of layers different from the current layer. + * Values are between 0 and 1. If 1, there is no automatic layer dimming. + */ + private double auto_layer_dim_factor = 0.7; + /** + * The layer, which is not automatically dimmed. + */ + private int fully_visible_layer = 0; + + public GraphicsContext(IntBox p_design_bounds, + Dimension p_panel_bounds, net.freerouting.board.LayerStructure p_layer_structure, java.util.Locale p_locale) { coordinate_transform = new CoordinateTransform(p_design_bounds, p_panel_bounds); item_color_table = new ItemColorTableModel(p_layer_structure, p_locale); other_color_table = new OtherColorTableModel(p_locale); color_intensity_table = new ColorIntensityTable(); - layer_visibility_arr = new double [p_layer_structure.arr.length]; - for (int i = 0; i < layer_visibility_arr.length; ++i) - { - if (p_layer_structure.arr[i].is_signal) - { - layer_visibility_arr [i] = 1; - } - else - { - layer_visibility_arr [i] = 0; + layer_visibility_arr = new double[p_layer_structure.arr.length]; + for (int i = 0; i < layer_visibility_arr.length; ++i) { + if (p_layer_structure.arr[i].is_signal) { + layer_visibility_arr[i] = 1; + } else { + layer_visibility_arr[i] = 0; } } } - + + /** * Copy constructor */ - public GraphicsContext(GraphicsContext p_graphics_context) - { + public GraphicsContext(GraphicsContext p_graphics_context) { this.coordinate_transform = new CoordinateTransform(p_graphics_context.coordinate_transform); this.item_color_table = new ItemColorTableModel(p_graphics_context.item_color_table); this.other_color_table = new OtherColorTableModel(p_graphics_context.other_color_table); this.color_intensity_table = new ColorIntensityTable(p_graphics_context.color_intensity_table); this.layer_visibility_arr = p_graphics_context.copy_layer_visibility_arr(); } - + /** - * Changes the bounds of the board design to p_design_bounds. - * Useful when components are still placed outside the boaed. + * initialise some values in p_graphics */ - public void change_design_bounds(IntBox p_new_design_bounds) - { - if (p_new_design_bounds.equals(this.coordinate_transform.design_box)) - { + private static void init_draw_graphics(Graphics2D p_graphics, Color p_color, float p_width) { + BasicStroke bs = new BasicStroke(Math.max(p_width, 0), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); + p_graphics.setStroke(bs); + p_graphics.setColor(p_color); + p_graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + } + + private static void set_translucency(Graphics2D p_g2, double p_factor) { + AlphaComposite curr_alpha_composite; + if (p_factor >= 0) { + curr_alpha_composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) p_factor); + } else { + curr_alpha_composite = AlphaComposite.getInstance(AlphaComposite.DST_OVER, (float) -p_factor); + } + p_g2.setComposite(curr_alpha_composite); + } + + /** + * Changes the bounds of the board design to p_design_bounds. + * Useful when components are still placed outside the boaed. + */ + public void change_design_bounds(IntBox p_new_design_bounds) { + if (p_new_design_bounds.equals(this.coordinate_transform.design_box)) { return; } Dimension screen_bounds = this.coordinate_transform.screen_bounds; this.coordinate_transform = new CoordinateTransform(p_new_design_bounds, screen_bounds); } - + /** * changes the size of the panel to p_new_bounds */ - public void change_panel_size(Dimension p_new_bounds) - { - if (coordinate_transform == null) - { + public void change_panel_size(Dimension p_new_bounds) { + if (coordinate_transform == null) { return; } IntBox design_box = coordinate_transform.design_box; @@ -116,739 +130,582 @@ public void change_panel_size(Dimension p_new_bounds) coordinate_transform.set_mirror_top_bottom(top_bottom_swapped); coordinate_transform.set_rotation(rotation); } - + /** * draws a polygon with corners p_points */ - public void draw(FloatPoint[] p_points, double p_half_width, Color p_color, Graphics p_g, double p_translucency_factor) - { - if (p_color == null) - { + public void draw(FloatPoint[] p_points, double p_half_width, Color p_color, Graphics p_g, double p_translucency_factor) { + if (p_color == null) { return; } - Graphics2D g2 = (Graphics2D)p_g; - Rectangle clip_shape = p_g.getClip().getBounds() ; + Graphics2D g2 = (Graphics2D) p_g; + Rectangle clip_shape = p_g.getClip().getBounds(); // the class member update_box cannot be used here, because // the dirty rectangle is internally enlarged by the system. // Therefore we can not improve the performance by using an // update octagon instead of a box. IntBox clip_box = coordinate_transform.screen_to_board(clip_shape); double scaled_width = coordinate_transform.board_to_screen(p_half_width); - - init_draw_graphics(g2, p_color, (float)scaled_width*2); + + init_draw_graphics(g2, p_color, (float) scaled_width * 2); set_translucency(g2, p_translucency_factor); - + GeneralPath draw_path = null; - if (!show_line_segments) - { + if (!show_line_segments) { draw_path = new GeneralPath(); } - - for(int i= 0; i<(p_points.length-1); i++) - { + + for (int i = 0; i < (p_points.length - 1); i++) { if (line_outside_update_box(p_points[i], p_points[i + 1], - p_half_width + update_offset, clip_box)) - { + p_half_width + update_offset, clip_box)) { // this check should be unnessersary here, // the system should do it in the draw(line) function continue; } - Point2D p1 = coordinate_transform.board_to_screen(p_points[i]) ; - Point2D p2 = coordinate_transform.board_to_screen(p_points[i+1]) ; - Line2D line = new Line2D.Double(p1, p2) ; - - if (show_line_segments) - { + Point2D p1 = coordinate_transform.board_to_screen(p_points[i]); + Point2D p2 = coordinate_transform.board_to_screen(p_points[i + 1]); + Line2D line = new Line2D.Double(p1, p2); + + if (show_line_segments) { g2.draw(line); - } - else - { + } else { draw_path.append(line, false); } } - if (!show_line_segments) - { + if (!show_line_segments) { g2.draw(draw_path); } } - + /* * draws the boundary of a circle */ - public void draw_circle(FloatPoint p_center, double p_radius, double p_draw_half_width, - Color p_color, Graphics p_g, double p_translucency_factor) - { - if (p_color == null) - { + public void draw_circle(FloatPoint p_center, double p_radius, double p_draw_half_width, + Color p_color, Graphics p_g, double p_translucency_factor) { + if (p_color == null) { return; } - Graphics2D g2 = (Graphics2D)p_g; + Graphics2D g2 = (Graphics2D) p_g; Point2D center = coordinate_transform.board_to_screen(p_center); - + double radius = coordinate_transform.board_to_screen(p_radius); double diameter = 2 * radius; - float draw_width = (float)(2 * coordinate_transform.board_to_screen(p_draw_half_width)); + float draw_width = (float) (2 * coordinate_transform.board_to_screen(p_draw_half_width)); Ellipse2D circle = - new Ellipse2D.Double(center.getX() - radius,center.getY() - radius, diameter, diameter); + new Ellipse2D.Double(center.getX() - radius, center.getY() - radius, diameter, diameter); set_translucency(g2, p_translucency_factor); init_draw_graphics(g2, p_color, draw_width); g2.draw(circle); } - - /* - * draws a rectangle - */ + + /* + * draws a rectangle + */ public void draw_rectangle(FloatPoint p_corner1, FloatPoint p_corner2, - double p_draw_half_width, Color p_color, Graphics p_g, double p_translucency_factor) - { - if (p_color == null) - { + double p_draw_half_width, Color p_color, Graphics p_g, double p_translucency_factor) { + if (p_color == null) { return; } - Graphics2D g2 = (Graphics2D)p_g ; - Point2D corner1 = coordinate_transform.board_to_screen(p_corner1) ; - Point2D corner2 = coordinate_transform.board_to_screen(p_corner2) ; - - double xmin = Math.min(corner1.getX(), corner2.getX()) ; - double ymin = Math.min(corner1.getY(), corner2.getY()) ; - - float draw_width = (float)(2 * coordinate_transform.board_to_screen(p_draw_half_width)) ; - double width = Math.abs(corner2.getX() - corner1.getX()) ; - double height = Math.abs(corner2.getY() - corner1.getY()) ; - Rectangle2D rectangle = new Rectangle2D.Double(xmin, ymin, width, height) ; + Graphics2D g2 = (Graphics2D) p_g; + Point2D corner1 = coordinate_transform.board_to_screen(p_corner1); + Point2D corner2 = coordinate_transform.board_to_screen(p_corner2); + + double xmin = Math.min(corner1.getX(), corner2.getX()); + double ymin = Math.min(corner1.getY(), corner2.getY()); + + float draw_width = (float) (2 * coordinate_transform.board_to_screen(p_draw_half_width)); + double width = Math.abs(corner2.getX() - corner1.getX()); + double height = Math.abs(corner2.getY() - corner1.getY()); + Rectangle2D rectangle = new Rectangle2D.Double(xmin, ymin, width, height); set_translucency(g2, p_translucency_factor); - init_draw_graphics(g2, p_color, draw_width) ; - g2.draw(rectangle) ; + init_draw_graphics(g2, p_color, draw_width); + g2.draw(rectangle); } - + /** * Draws the boundary of p_shape. */ - public void draw_boundary(Shape p_shape, double p_draw_half_width, Color p_color, Graphics p_g, double p_translucency_factor) - { - if (p_shape instanceof PolylineShape) - { + public void draw_boundary(Shape p_shape, double p_draw_half_width, Color p_color, Graphics p_g, double p_translucency_factor) { + if (p_shape instanceof PolylineShape) { FloatPoint[] draw_corners = p_shape.corner_approx_arr(); - if (draw_corners.length <= 1) - { + if (draw_corners.length <= 1) { return; } FloatPoint[] closed_draw_corners = new FloatPoint[draw_corners.length + 1]; System.arraycopy(draw_corners, 0, closed_draw_corners, 0, draw_corners.length); - closed_draw_corners[closed_draw_corners.length - 1] = draw_corners [0]; - this.draw( closed_draw_corners, p_draw_half_width, p_color, p_g, p_translucency_factor); - } - else if (p_shape instanceof Circle) - { + closed_draw_corners[closed_draw_corners.length - 1] = draw_corners[0]; + this.draw(closed_draw_corners, p_draw_half_width, p_color, p_g, p_translucency_factor); + } else if (p_shape instanceof Circle) { Circle curr_circle = (Circle) p_shape; this.draw_circle(curr_circle.center.to_float(), curr_circle.radius, p_draw_half_width, p_color, p_g, p_translucency_factor); } } - + /** * Draws the boundary of p_area. */ - public void draw_boundary(Area p_area, double p_draw_half_width, Color p_color, Graphics p_g, double p_translucency_factor) - { + public void draw_boundary(Area p_area, double p_draw_half_width, Color p_color, Graphics p_g, double p_translucency_factor) { draw_boundary(p_area.get_border(), p_draw_half_width, p_color, p_g, p_translucency_factor); Shape[] holes = p_area.get_holes(); - for (int i = 0; i < holes.length; ++i) - { + for (int i = 0; i < holes.length; ++i) { draw_boundary(holes[i], p_draw_half_width, p_color, p_g, p_translucency_factor); } } - + /** * Draws the interiour of a circle */ - public void fill_circle(Circle p_circle, Graphics p_g, Color p_color, double p_translucency_factor) - { - if (p_color == null) - { + public void fill_circle(Circle p_circle, Graphics p_g, Color p_color, double p_translucency_factor) { + if (p_color == null) { return; } Point2D center = coordinate_transform.board_to_screen(p_circle.center.to_float()); double radius = coordinate_transform.board_to_screen(p_circle.radius); - if (!point_near_rectangle(center.getX(), center.getY(), p_g.getClip().getBounds(), radius)) - { + if (!point_near_rectangle(center.getX(), center.getY(), p_g.getClip().getBounds(), radius)) { return; } double diameter = 2 * radius; Ellipse2D circle = - new Ellipse2D.Double(center.getX() - radius,center.getY() - radius, diameter, diameter); - Graphics2D g2 = (Graphics2D)p_g; + new Ellipse2D.Double(center.getX() - radius, center.getY() - radius, diameter, diameter); + Graphics2D g2 = (Graphics2D) p_g; g2.setColor(p_color); set_translucency(g2, p_translucency_factor); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.fill(circle); } - + /** * Draws the interiour of an ellipse. */ - public void fill_ellipse(Ellipse p_ellipse, Graphics p_g, Color p_color, double p_translucency_factor) - { - Ellipse [] ellipse_arr = new Ellipse[1]; + public void fill_ellipse(Ellipse p_ellipse, Graphics p_g, Color p_color, double p_translucency_factor) { + Ellipse[] ellipse_arr = new Ellipse[1]; ellipse_arr[0] = p_ellipse; fill_ellipse_arr(ellipse_arr, p_g, p_color, p_translucency_factor); } - - + /** * Draws the interiour of an array of ellipses. * Ellipses contained in an other ellipse are treated as holes. */ - public void fill_ellipse_arr(Ellipse [] p_ellipse_arr, Graphics p_g, Color p_color, double p_translucency_factor) - { - if (p_color == null || p_ellipse_arr.length <= 0) - { + public void fill_ellipse_arr(Ellipse[] p_ellipse_arr, Graphics p_g, Color p_color, double p_translucency_factor) { + if (p_color == null || p_ellipse_arr.length <= 0) { return; } GeneralPath draw_path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); - for (Ellipse curr_ellipse : p_ellipse_arr) - { + for (Ellipse curr_ellipse : p_ellipse_arr) { Point2D center = coordinate_transform.board_to_screen(curr_ellipse.center); double bigger_radius = coordinate_transform.board_to_screen(curr_ellipse.bigger_radius); - if (!point_near_rectangle(center.getX(), center.getY(), p_g.getClip().getBounds(), bigger_radius)) - { + if (!point_near_rectangle(center.getX(), center.getY(), p_g.getClip().getBounds(), bigger_radius)) { continue; } - double smaller_radius = coordinate_transform.board_to_screen(curr_ellipse.smaller_radius); + double smaller_radius = coordinate_transform.board_to_screen(curr_ellipse.smaller_radius); Ellipse2D draw_ellipse = - new Ellipse2D.Double(center.getX() - bigger_radius,center.getY() - smaller_radius, - 2 * bigger_radius, 2 * smaller_radius); + new Ellipse2D.Double(center.getX() - bigger_radius, center.getY() - smaller_radius, + 2 * bigger_radius, 2 * smaller_radius); double rotation = coordinate_transform.board_to_screen_angle(curr_ellipse.rotation); - AffineTransform affine_transform = new AffineTransform(); + AffineTransform affine_transform = new AffineTransform(); affine_transform.rotate(rotation, center.getX(), center.getY()); java.awt.Shape rotated_ellipse = affine_transform.createTransformedShape(draw_ellipse); draw_path.append(rotated_ellipse, false); } - Graphics2D g2 = (Graphics2D)p_g; + Graphics2D g2 = (Graphics2D) p_g; g2.setColor(p_color); set_translucency(g2, p_translucency_factor); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.fill(draw_path); } - + /** * Checks, if the distance of the point with coordinates p_x, p_y to p_rect ist at most p_dist. */ - private boolean point_near_rectangle(double p_x, double p_y, Rectangle p_rect, double p_dist) - { - if (p_x < p_rect.x - p_dist) - { + private boolean point_near_rectangle(double p_x, double p_y, Rectangle p_rect, double p_dist) { + if (p_x < p_rect.x - p_dist) { return false; } - if (p_y < p_rect.y - p_dist) - { + if (p_y < p_rect.y - p_dist) { return false; } - if (p_x > p_rect.x + p_rect.width + p_dist) - { + if (p_x > p_rect.x + p_rect.width + p_dist) { return false; } - if (p_y > p_rect.y + p_rect.height + p_dist) - { + if (p_y > p_rect.y + p_rect.height + p_dist) { return false; } return true; } - + /** * Fill the interior of the polygon shape represented by p_points. */ - public void fill_shape(FloatPoint[] p_points, Graphics p_g, Color p_color, double p_translucency_factor) - { - if (p_color == null) - { + public void fill_shape(FloatPoint[] p_points, Graphics p_g, Color p_color, double p_translucency_factor) { + if (p_color == null) { return; } - Graphics2D g2 = (Graphics2D)p_g; + Graphics2D g2 = (Graphics2D) p_g; Polygon draw_polygon = new Polygon(); - for(int i= 0; i < p_points.length; i++) - { + for (int i = 0; i < p_points.length; i++) { Point2D curr_corner = coordinate_transform.board_to_screen(p_points[i]); - draw_polygon.addPoint((int)Math.round(curr_corner.getX()), - (int)Math.round(curr_corner.getY())); + draw_polygon.addPoint((int) Math.round(curr_corner.getX()), + (int) Math.round(curr_corner.getY())); } g2.setColor(p_color); set_translucency(g2, p_translucency_factor); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.fill(draw_polygon); } - + /** * Fill the interiour of a list of polygons. * Used for example with an area consisting of a border polygon and some holes. */ - public void fill_area(FloatPoint[][] p_point_lists, Graphics p_g, Color p_color, double p_translucency_factor) - { - if (p_color == null) - { + public void fill_area(FloatPoint[][] p_point_lists, Graphics p_g, Color p_color, double p_translucency_factor) { + if (p_color == null) { return; } GeneralPath draw_path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); - for (int j = 0; j < p_point_lists.length; ++j) - { + for (int j = 0; j < p_point_lists.length; ++j) { Polygon draw_polygon = new Polygon(); FloatPoint[] curr_point_list = p_point_lists[j]; - for(int i= 0; i < curr_point_list.length; i++) - { + for (int i = 0; i < curr_point_list.length; i++) { Point2D curr_corner = coordinate_transform.board_to_screen(curr_point_list[i]); - draw_polygon.addPoint((int)Math.round(curr_corner.getX()), - (int)Math.round(curr_corner.getY())); + draw_polygon.addPoint((int) Math.round(curr_corner.getX()), + (int) Math.round(curr_corner.getY())); } draw_path.append(draw_polygon, false); } - Graphics2D g2 = (Graphics2D)p_g; + Graphics2D g2 = (Graphics2D) p_g; g2.setColor(p_color); set_translucency(g2, p_translucency_factor); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.fill(draw_path); } - + /** * draws the interiour of an item of class geometry.planar.Area */ - public void fill_area(Area p_area, Graphics p_g, Color p_color, double p_translucency_factor) - { - if (p_color == null || p_area.is_empty()) - { + public void fill_area(Area p_area, Graphics p_g, Color p_color, double p_translucency_factor) { + if (p_color == null || p_area.is_empty()) { return; } - if (p_area instanceof Circle) - { + if (p_area instanceof Circle) { fill_circle((Circle) p_area, p_g, p_color, p_translucency_factor); - } - else - { + } else { PolylineShape border = (PolylineShape) p_area.get_border(); - if (!border.is_bounded()) - { + if (!border.is_bounded()) { System.out.println("GraphicsContext.fill_area: shape not bounded"); return; } - Rectangle clip_shape = p_g.getClip().getBounds() ; + Rectangle clip_shape = p_g.getClip().getBounds(); IntBox clip_box = coordinate_transform.screen_to_board(clip_shape); - if (!border.bounding_box().intersects(clip_box)) - { + if (!border.bounding_box().intersects(clip_box)) { return; } - Shape [] holes = p_area.get_holes(); - - FloatPoint[] [] draw_polygons = new FloatPoint [holes.length + 1][]; - for (int j = 0; j < draw_polygons.length; ++j) - { + Shape[] holes = p_area.get_holes(); + + FloatPoint[][] draw_polygons = new FloatPoint[holes.length + 1][]; + for (int j = 0; j < draw_polygons.length; ++j) { PolylineShape curr_draw_shape; - if (j == 0) - { + if (j == 0) { curr_draw_shape = border; - } - else - { + } else { curr_draw_shape = (PolylineShape) holes[j - 1]; } - draw_polygons[j] = new FloatPoint [curr_draw_shape.border_line_count() + 1]; + draw_polygons[j] = new FloatPoint[curr_draw_shape.border_line_count() + 1]; FloatPoint curr_draw_polygon[] = draw_polygons[j]; - for (int i = 0; i < curr_draw_polygon.length - 1; ++i) - { + for (int i = 0; i < curr_draw_polygon.length - 1; ++i) { curr_draw_polygon[i] = curr_draw_shape.corner_approx(i); } // close the polygon curr_draw_polygon[curr_draw_polygon.length - 1] = curr_draw_polygon[0]; } - fill_area(draw_polygons, p_g, p_color, p_translucency_factor) ; + fill_area(draw_polygons, p_g, p_color, p_translucency_factor); } - if (show_area_division) - { + if (show_area_division) { TileShape[] tiles = p_area.split_to_convex(); - for (int i = 0; i < tiles.length; ++i) - { - FloatPoint[] corners = new FloatPoint [tiles[i].border_line_count() + 1]; + for (int i = 0; i < tiles.length; ++i) { + FloatPoint[] corners = new FloatPoint[tiles[i].border_line_count() + 1]; TileShape curr_tile = tiles[i]; - for (int j = 0; j < corners.length - 1; ++j) - { - corners[j]= curr_tile.corner_approx(j); + for (int j = 0; j < corners.length - 1; ++j) { + corners[j] = curr_tile.corner_approx(j); } corners[corners.length - 1] = corners[0]; draw(corners, 1, java.awt.Color.white, p_g, 0.7); } } } - - public Color get_background_color() - { + + public Color get_background_color() { return other_color_table.get_background_color(); } - - public Color get_hilight_color() - { + + public Color get_hilight_color() { return other_color_table.get_hilight_color(); } - - public Color get_incomplete_color() - { + + public Color get_incomplete_color() { return other_color_table.get_incomplete_color(); } - - public Color get_outline_color() - { + + public Color get_outline_color() { return other_color_table.get_outline_color(); } - - public Color get_component_color(boolean p_front) - { + + public Color get_component_color(boolean p_front) { return other_color_table.get_component_color(p_front); } - - public Color get_violations_color() - { + + public Color get_violations_color() { return other_color_table.get_violations_color(); } - - public Color get_length_matching_area_color() - { + + public Color get_length_matching_area_color() { return other_color_table.get_length_matching_area_color(); } - - public Color[] get_trace_colors(boolean p_fixed) - { - + + public Color[] get_trace_colors(boolean p_fixed) { + return item_color_table.get_trace_colors(p_fixed); } - - public Color[] get_via_colors(boolean p_fixed) - { + + public Color[] get_via_colors(boolean p_fixed) { return item_color_table.get_via_colors(p_fixed); } - - public Color[] get_pin_colors() - { + + public Color[] get_pin_colors() { return item_color_table.get_pin_colors(); } - - public Color[] get_conduction_colors() - { + + public Color[] get_conduction_colors() { return item_color_table.get_conduction_colors(); } - - public Color[] get_obstacle_colors() - { + + public Color[] get_obstacle_colors() { return item_color_table.get_obstacle_colors(); } - - public Color[] get_via_obstacle_colors() - { + + public Color[] get_via_obstacle_colors() { return item_color_table.get_via_obstacle_colors(); } - - public Color[] get_place_obstacle_colors() - { + + public Color[] get_place_obstacle_colors() { return item_color_table.get_place_obstacle_colors(); } - - public double get_trace_color_intensity() - { + + public double get_trace_color_intensity() { return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.TRACES.ordinal()); } - - public double get_via_color_intensity() - { + + public void set_trace_color_intensity(double p_value) { + color_intensity_table.set_value(ColorIntensityTable.ObjectNames.TRACES.ordinal(), p_value); + } + + public double get_via_color_intensity() { return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.VIAS.ordinal()); } - - public double get_pin_color_intensity() - { + + public void set_via_color_intensity(double p_value) { + color_intensity_table.set_value(ColorIntensityTable.ObjectNames.VIAS.ordinal(), p_value); + } + + public double get_pin_color_intensity() { return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.PINS.ordinal()); } - - public double get_conduction_color_intensity() - { + + public void set_pin_color_intensity(double p_value) { + color_intensity_table.set_value(ColorIntensityTable.ObjectNames.PINS.ordinal(), p_value); + } + + public double get_conduction_color_intensity() { return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.CONDUCTION_AREAS.ordinal()); } - - public double get_obstacle_color_intensity() - { + + public void set_conduction_color_intensity(double p_value) { + color_intensity_table.set_value(ColorIntensityTable.ObjectNames.CONDUCTION_AREAS.ordinal(), p_value); + } + + public double get_obstacle_color_intensity() { return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.KEEPOUTS.ordinal()); } - - public double get_via_obstacle_color_intensity() - { + + public void set_obstacle_color_intensity(double p_value) { + color_intensity_table.set_value(ColorIntensityTable.ObjectNames.KEEPOUTS.ordinal(), p_value); + } + + public double get_via_obstacle_color_intensity() { return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.VIA_KEEPOUTS.ordinal()); } - - public double get_place_obstacle_color_intensity() - { + + public void set_via_obstacle_color_intensity(double p_value) { + color_intensity_table.set_value(ColorIntensityTable.ObjectNames.VIA_KEEPOUTS.ordinal(), p_value); + } + + public double get_place_obstacle_color_intensity() { return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.PLACE_KEEPOUTS.ordinal()); } - - public double get_component_outline_color_intensity() - { + + public double get_component_outline_color_intensity() { return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.COMPONENT_OUTLINES.ordinal()); } - - public double get_hilight_color_intensity() - { + + public double get_hilight_color_intensity() { return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.HILIGHT.ordinal()); } - - public double get_incomplete_color_intensity() - { - return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.INCOMPLETES.ordinal()); - } - - public double get_length_matching_area_color_intensity() - { - return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.LENGTH_MATCHING_AREAS.ordinal()); - } - - public void set_trace_color_intensity(double p_value) - { - color_intensity_table.set_value(ColorIntensityTable.ObjectNames.TRACES.ordinal(), p_value); - } - - public void set_via_color_intensity(double p_value) - { - color_intensity_table.set_value(ColorIntensityTable.ObjectNames.VIAS.ordinal(), p_value); - } - - public void set_pin_color_intensity(double p_value) - { - color_intensity_table.set_value(ColorIntensityTable.ObjectNames.PINS.ordinal(), p_value); - } - - public void set_conduction_color_intensity(double p_value) - { - color_intensity_table.set_value(ColorIntensityTable.ObjectNames.CONDUCTION_AREAS.ordinal(), p_value); - } - - public void set_obstacle_color_intensity(double p_value) - { - color_intensity_table.set_value(ColorIntensityTable.ObjectNames.KEEPOUTS.ordinal(), p_value); - } - - public void set_via_obstacle_color_intensity(double p_value) - { - color_intensity_table.set_value(ColorIntensityTable.ObjectNames.VIA_KEEPOUTS.ordinal(), p_value); - } - - public void set_hilight_color_intensity(double p_value) - { + + public void set_hilight_color_intensity(double p_value) { color_intensity_table.set_value(ColorIntensityTable.ObjectNames.HILIGHT.ordinal(), p_value); } - - public void set_incomplete_color_intensity(double p_value) - { + + public double get_incomplete_color_intensity() { + return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.INCOMPLETES.ordinal()); + } + + public void set_incomplete_color_intensity(double p_value) { color_intensity_table.set_value(ColorIntensityTable.ObjectNames.INCOMPLETES.ordinal(), p_value); } - - public void set_length_matching_area_color_intensity(double p_value) - { + + public double get_length_matching_area_color_intensity() { + return color_intensity_table.get_value(ColorIntensityTable.ObjectNames.LENGTH_MATCHING_AREAS.ordinal()); + } + + public void set_length_matching_area_color_intensity(double p_value) { color_intensity_table.set_value(ColorIntensityTable.ObjectNames.LENGTH_MATCHING_AREAS.ordinal(), p_value); } - - public java.awt.Dimension get_panel_size() - { + + public java.awt.Dimension get_panel_size() { return coordinate_transform.screen_bounds; } - + /** * Returns the center of the design on the screen. */ - public Point2D get_design_center() - { + public Point2D get_design_center() { FloatPoint center = coordinate_transform.design_box_with_offset.centre_of_gravity(); return coordinate_transform.board_to_screen(center); } - + /** * Returns the bounding box of the design in screen coordinates. */ - public java.awt.Rectangle get_design_bounds() - { + public java.awt.Rectangle get_design_bounds() { return coordinate_transform.board_to_screen(coordinate_transform.design_box); } - + + /** + * gets the factor for automatic layer dimming + */ + public double get_auto_layer_dim_factor() { + return this.auto_layer_dim_factor; + } + /** * Sets the factor for automatic layer dimming. * Values are between 0 and 1. If 1, there is no automatic layer dimming. */ - public void set_auto_layer_dim_factor(double p_value) - { + public void set_auto_layer_dim_factor(double p_value) { auto_layer_dim_factor = p_value; } - - /** gets the factor for automatic layer dimming */ - public double get_auto_layer_dim_factor() - { - return this.auto_layer_dim_factor; - } - - /** Sets the layer, which will be excluded from automatic layer dimming. */ - public void set_fully_visible_layer(int p_layer_no) - { + + /** + * Sets the layer, which will be excluded from automatic layer dimming. + */ + public void set_fully_visible_layer(int p_layer_no) { fully_visible_layer = p_layer_no; } - + /** * Gets the visibility factor of the input layer. * The result is between 0 and 1. * If the result is 0, the layer is invisible, * if the result is 1, the layer is fully visible. */ - public double get_layer_visibility(int p_layer_no) - { + public double get_layer_visibility(int p_layer_no) { double result; - if (p_layer_no == this.fully_visible_layer) - { + if (p_layer_no == this.fully_visible_layer) { result = layer_visibility_arr[p_layer_no]; - } - else - { + } else { result = this.auto_layer_dim_factor * layer_visibility_arr[p_layer_no]; } return result; } - + /** * Gets the visibility factor of the input layer without the aoutomatic layer dimming. */ - public double get_raw_layer_visibility(int p_layer_no) - { + public double get_raw_layer_visibility(int p_layer_no) { return layer_visibility_arr[p_layer_no]; } - + /** * Gets the visibility factor of the input layer. * The value is expected between 0 and 1. * If the value is 0, the layer is invisible, * if the value is 1, the layer is fully visible. - * */ - public void set_layer_visibility(int p_layer_no, double p_value) - { + public void set_layer_visibility(int p_layer_no, double p_value) { layer_visibility_arr[p_layer_no] = Math.max(0, Math.min(p_value, 1)); } - - public void set_layer_visibility_arr(double [] p_layer_visibility_arr) - { + + public void set_layer_visibility_arr(double[] p_layer_visibility_arr) { this.layer_visibility_arr = p_layer_visibility_arr; } - - - public double[] copy_layer_visibility_arr() - { - double[] result = new double [this.layer_visibility_arr.length]; + + public double[] copy_layer_visibility_arr() { + double[] result = new double[this.layer_visibility_arr.length]; System.arraycopy(this.layer_visibility_arr, 0, result, 0, this.layer_visibility_arr.length); return result; } - - /** Returns the number of layers on the board */ - public int layer_count() - { + + /** + * Returns the number of layers on the board + */ + public int layer_count() { return layer_visibility_arr.length; } - + /** * filter lines, which cannot touch the update_box to improve the * performance of the draw function by avoiding unnessesary calls * of draw (line) */ private boolean line_outside_update_box(FloatPoint p_1, - FloatPoint p_2, double p_update_offset, IntBox p_update_box) - { - if (p_1 == null || p_2 == null) - { + FloatPoint p_2, double p_update_offset, IntBox p_update_box) { + if (p_1 == null || p_2 == null) { return true; } - if (Math.max(p_1.x, p_2.x) < p_update_box.ll.x - p_update_offset) - { + if (Math.max(p_1.x, p_2.x) < p_update_box.ll.x - p_update_offset) { return true; } - if (Math.max(p_1.y, p_2.y) < p_update_box.ll.y - p_update_offset ) - { + if (Math.max(p_1.y, p_2.y) < p_update_box.ll.y - p_update_offset) { return true; } - if (Math.min(p_1.x, p_2.x) > p_update_box.ur.x + p_update_offset) - { + if (Math.min(p_1.x, p_2.x) > p_update_box.ur.x + p_update_offset) { return true; } - if (Math.min(p_1.y, p_2.y) > p_update_box.ur.y + p_update_offset) - { + if (Math.min(p_1.y, p_2.y) > p_update_box.ur.y + p_update_offset) { return true; } return false; } - + /** - * initialise some values in p_graphics - */ - private static void init_draw_graphics(Graphics2D p_graphics, Color p_color, float p_width) - { - BasicStroke bs = new BasicStroke(Math.max(p_width, 0), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); - p_graphics.setStroke(bs); - p_graphics.setColor(p_color); - p_graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - } - - private static void set_translucency(Graphics2D p_g2, double p_factor) - { - AlphaComposite curr_alpha_composite; - if (p_factor >= 0) - { - curr_alpha_composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) p_factor); - } - else - { - curr_alpha_composite = AlphaComposite.getInstance(AlphaComposite.DST_OVER, (float) -p_factor); - } - p_g2.setComposite(curr_alpha_composite); - } - - /** * Writes an instance of this class to a file. */ private void writeObject(java.io.ObjectOutputStream p_stream) - throws java.io.IOException - { + throws java.io.IOException { p_stream.defaultWriteObject(); item_color_table.write_object(p_stream); other_color_table.write_object(p_stream); } - - /** Reads an instance of this class from a file */ + + /** + * Reads an instance of this class from a file + */ private void readObject(java.io.ObjectInputStream p_stream) - throws java.io.IOException, java.lang.ClassNotFoundException - { + throws java.io.IOException, java.lang.ClassNotFoundException { p_stream.defaultReadObject(); this.item_color_table = new ItemColorTableModel(p_stream); this.other_color_table = new OtherColorTableModel(p_stream); } - - public transient ItemColorTableModel item_color_table; - public transient OtherColorTableModel other_color_table; - public ColorIntensityTable color_intensity_table; - - - public CoordinateTransform coordinate_transform = null; - - /** layer_visibility_arr[i] is between 0 and 1, for each layer i, 0 is invisible and 1 fully visible. */ - private double [] layer_visibility_arr; - - - /** - * The factor for autoomatic layer dimming of layers different from the current layer. - * Values are between 0 and 1. If 1, there is no automatic layer dimming. - */ - private double auto_layer_dim_factor = 0.7; - - /** The layer, which is not automatically dimmed. */ - private int fully_visible_layer = 0; - - private static final int update_offset = 10000; - - private static final boolean show_line_segments = false; - private static final boolean show_area_division = false; - + } \ No newline at end of file diff --git a/src/main/java/net/freerouting/boardgraphics/ItemColorTableModel.java b/src/main/java/net/freerouting/boardgraphics/ItemColorTableModel.java index 5f3255a6..3b1fe77c 100644 --- a/src/main/java/net/freerouting/boardgraphics/ItemColorTableModel.java +++ b/src/main/java/net/freerouting/boardgraphics/ItemColorTableModel.java @@ -20,80 +20,63 @@ package net.freerouting.boardgraphics; -import java.awt.Color; +import java.awt.*; /** * Stores the layer dependent colors used for drawing for the items on the board. * * @author Alfons Wirtz */ -public class ItemColorTableModel extends ColorTableModel implements java.io.Serializable -{ - - public ItemColorTableModel(net.freerouting.board.LayerStructure p_layer_structure, java.util.Locale p_locale) - { +public class ItemColorTableModel extends ColorTableModel implements java.io.Serializable { + + private transient boolean item_colors_precalculated = false; + private transient Color[][] precalculated_item_colors = null; + + public ItemColorTableModel(net.freerouting.board.LayerStructure p_layer_structure, java.util.Locale p_locale) { super(p_layer_structure.arr.length, p_locale); - + int row_count = p_layer_structure.arr.length; final int item_type_count = ColumnNames.values().length - 1; int signal_layer_no = 0; - for( int layer = 0; layer < row_count; ++layer) - { + for (int layer = 0; layer < row_count; ++layer) { boolean is_signal_layer = p_layer_structure.arr[layer].is_signal; - data[layer] = new Object [item_type_count + 1]; + data[layer] = new Object[item_type_count + 1]; Object[] curr_row = data[layer]; curr_row[0] = p_layer_structure.arr[layer].name; - if (layer == 0) - { + if (layer == 0) { curr_row[ColumnNames.PINS.ordinal()] = new Color(150, 50, 0); curr_row[ColumnNames.TRACES.ordinal()] = Color.red; curr_row[ColumnNames.CONDUCTION_AREAS.ordinal()] = new Color(0, 150, 0); curr_row[ColumnNames.KEEPOUTS.ordinal()] = new Color(0, 110, 110); curr_row[ColumnNames.PLACE_KEEPOUTS.ordinal()] = new Color(150, 50, 0); - } - else if (layer == row_count - 1) - { + } else if (layer == row_count - 1) { curr_row[ColumnNames.PINS.ordinal()] = new Color(160, 80, 0); curr_row[ColumnNames.TRACES.ordinal()] = Color.blue; curr_row[ColumnNames.CONDUCTION_AREAS.ordinal()] = new Color(100, 100, 0); curr_row[ColumnNames.KEEPOUTS.ordinal()] = new Color(0, 100, 160); curr_row[ColumnNames.PLACE_KEEPOUTS.ordinal()] = new Color(160, 80, 0); - } - else // inner layer + } else // inner layer { - if (is_signal_layer) - { + if (is_signal_layer) { // currenntly 6 different default colors for traces on the inner layers final int different_inner_colors = 6; int remainder = signal_layer_no % different_inner_colors; - if (remainder % different_inner_colors == 1) - { + if (remainder % different_inner_colors == 1) { curr_row[ColumnNames.TRACES.ordinal()] = Color.GREEN; - } - else if (remainder % different_inner_colors == 2) - { + } else if (remainder % different_inner_colors == 2) { curr_row[ColumnNames.TRACES.ordinal()] = Color.YELLOW; - } - else if (remainder % different_inner_colors == 3) - { + } else if (remainder % different_inner_colors == 3) { curr_row[ColumnNames.TRACES.ordinal()] = new Color(200, 100, 255); - } - else if (remainder % different_inner_colors == 4) - { + } else if (remainder % different_inner_colors == 4) { curr_row[ColumnNames.TRACES.ordinal()] = new Color(255, 150, 150); - } - else if (remainder % different_inner_colors == 5) - { + } else if (remainder % different_inner_colors == 5) { curr_row[ColumnNames.TRACES.ordinal()] = new Color(100, 150, 0); - } - else - { + } else { curr_row[ColumnNames.TRACES.ordinal()] = new Color(0, 200, 255); } - } - else // power layer + } else // power layer { - curr_row [ColumnNames.TRACES.ordinal()] = Color.BLACK; + curr_row[ColumnNames.TRACES.ordinal()] = Color.BLACK; } curr_row[ColumnNames.PINS.ordinal()] = new Color(255, 150, 0); curr_row[ColumnNames.CONDUCTION_AREAS.ordinal()] = new Color(0, 200, 60); @@ -104,232 +87,176 @@ else if (remainder % different_inner_colors == 5) curr_row[ColumnNames.FIXED_VIAS.ordinal()] = curr_row[ColumnNames.VIAS.ordinal()]; curr_row[ColumnNames.FIXED_TRACES.ordinal()] = curr_row[ColumnNames.TRACES.ordinal()]; curr_row[ColumnNames.VIA_KEEPOUTS.ordinal()] = new Color(100, 100, 100); - if (is_signal_layer) - { + if (is_signal_layer) { ++signal_layer_no; } } } - + public ItemColorTableModel(java.io.ObjectInputStream p_stream) - throws java.io.IOException, java.lang.ClassNotFoundException - { + throws java.io.IOException, java.lang.ClassNotFoundException { super(p_stream); } - + /** * Copy construcror. */ - public ItemColorTableModel(ItemColorTableModel p_item_color_model) - { + public ItemColorTableModel(ItemColorTableModel p_item_color_model) { super(p_item_color_model.data.length, p_item_color_model.locale); - for (int i = 0; i < this.data.length; ++i) - { + for (int i = 0; i < this.data.length; ++i) { this.data[i] = new Object[p_item_color_model.data[i].length]; System.arraycopy(p_item_color_model.data[i], 0, this.data[i], 0, this.data[i].length); } } - - public int getColumnCount() - { + + public int getColumnCount() { return ColumnNames.values().length; } - - public int getRowCount() - { + + public int getRowCount() { return data.length; } - - public String getColumnName(int p_col) - { - java.util.ResourceBundle resources = + + public String getColumnName(int p_col) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.boardgraphics.ColorTableModel", this.locale); return resources.getString(ColumnNames.values()[p_col].toString()); } - - public void setValueAt(Object p_value, int p_row, int p_col) - { + + public void setValueAt(Object p_value, int p_row, int p_col) { super.setValueAt(p_value, p_row, p_col); this.item_colors_precalculated = false; } - + /** * Don't need to implement this method unless your table's * editable. */ - public boolean isCellEditable(int p_row, int p_col) - { + public boolean isCellEditable(int p_row, int p_col) { //Note that the data/cell address is constant, //no matter where the cell appears onscreen. return p_col >= 1; } - - Color[] get_trace_colors(boolean p_fixed) - { - if (!item_colors_precalculated) - { + + Color[] get_trace_colors(boolean p_fixed) { + if (!item_colors_precalculated) { precalulate_item_colors(); } Color[] result; - if (p_fixed) - { + if (p_fixed) { result = precalculated_item_colors[ColumnNames.FIXED_TRACES.ordinal() - 1]; - } - else - { + } else { result = precalculated_item_colors[ColumnNames.TRACES.ordinal() - 1]; } return result; } - - Color[] get_via_colors(boolean p_fixed) - { - if (!item_colors_precalculated) - { + + Color[] get_via_colors(boolean p_fixed) { + if (!item_colors_precalculated) { precalulate_item_colors(); } Color[] result; - if (p_fixed) - { + if (p_fixed) { result = precalculated_item_colors[ColumnNames.FIXED_VIAS.ordinal() - 1]; - } - else - { + } else { result = precalculated_item_colors[ColumnNames.VIAS.ordinal() - 1]; } return result; } - - Color[] get_pin_colors() - { - if (!item_colors_precalculated) - { + + Color[] get_pin_colors() { + if (!item_colors_precalculated) { precalulate_item_colors(); } return precalculated_item_colors[ColumnNames.PINS.ordinal() - 1]; } - - Color[] get_conduction_colors() - { - if (!item_colors_precalculated) - { + + public void set_pin_colors(Color[] p_color_arr) { + set_colors(ColumnNames.PINS.ordinal(), p_color_arr); + } + + Color[] get_conduction_colors() { + if (!item_colors_precalculated) { precalulate_item_colors(); } return precalculated_item_colors[ColumnNames.CONDUCTION_AREAS.ordinal() - 1]; } - - Color[] get_obstacle_colors() - { - if (!item_colors_precalculated) - { + + public void set_conduction_colors(Color[] p_color_arr) { + set_colors(ColumnNames.CONDUCTION_AREAS.ordinal(), p_color_arr); + } + + Color[] get_obstacle_colors() { + if (!item_colors_precalculated) { precalulate_item_colors(); } return precalculated_item_colors[ColumnNames.KEEPOUTS.ordinal() - 1]; } - - Color[] get_via_obstacle_colors() - { - if (!item_colors_precalculated) - { + + Color[] get_via_obstacle_colors() { + if (!item_colors_precalculated) { precalulate_item_colors(); } return precalculated_item_colors[ColumnNames.VIA_KEEPOUTS.ordinal() - 1]; } - - Color[] get_place_obstacle_colors() - { - if (!item_colors_precalculated) - { + + Color[] get_place_obstacle_colors() { + if (!item_colors_precalculated) { precalulate_item_colors(); } return precalculated_item_colors[ColumnNames.PLACE_KEEPOUTS.ordinal() - 1]; } - - - public void set_trace_colors(Color[] p_color_arr, boolean p_fixed) - { - if (p_fixed) - { + + public void set_trace_colors(Color[] p_color_arr, boolean p_fixed) { + if (p_fixed) { set_colors(ColumnNames.FIXED_TRACES.ordinal(), p_color_arr); - } - else - { + } else { set_colors(ColumnNames.TRACES.ordinal(), p_color_arr); } } - - public void set_via_colors(Color[] p_color_arr, boolean p_fixed) - { - if (p_fixed) - { + + public void set_via_colors(Color[] p_color_arr, boolean p_fixed) { + if (p_fixed) { set_colors(ColumnNames.FIXED_VIAS.ordinal(), p_color_arr); - } - else - { + } else { set_colors(ColumnNames.VIAS.ordinal(), p_color_arr); } } - - public void set_pin_colors(Color[] p_color_arr) - { - set_colors(ColumnNames.PINS.ordinal(), p_color_arr); - } - - public void set_conduction_colors(Color[] p_color_arr) - { - set_colors(ColumnNames.CONDUCTION_AREAS.ordinal(), p_color_arr); - } - - public void set_keepout_colors(Color[] p_color_arr) - { + + public void set_keepout_colors(Color[] p_color_arr) { set_colors(ColumnNames.KEEPOUTS.ordinal(), p_color_arr); } - - public void set_via_keepout_colors(Color[] p_color_arr) - { + + public void set_via_keepout_colors(Color[] p_color_arr) { set_colors(ColumnNames.VIA_KEEPOUTS.ordinal(), p_color_arr); } - - public void set_place_keepout_colors(Color[] p_color_arr) - { + + public void set_place_keepout_colors(Color[] p_color_arr) { set_colors(ColumnNames.PLACE_KEEPOUTS.ordinal(), p_color_arr); } - - - - private void set_colors(int p_item_type, Color[] p_color_arr) - { - for (int layer = 0; layer < this.data.length - 1; ++layer) - { + + private void set_colors(int p_item_type, Color[] p_color_arr) { + for (int layer = 0; layer < this.data.length - 1; ++layer) { int color_index = layer % p_color_arr.length; this.data[layer][p_item_type] = p_color_arr[color_index]; } data[this.data.length - 1][p_item_type] = p_color_arr[p_color_arr.length - 1]; this.item_colors_precalculated = false; } - - - private void precalulate_item_colors() - { + + private void precalulate_item_colors() { precalculated_item_colors = new Color[ColumnNames.values().length - 1][]; - for (int i = 0; i < precalculated_item_colors.length; ++i) - { + for (int i = 0; i < precalculated_item_colors.length; ++i) { precalculated_item_colors[i] = new Color[data.length]; Color[] curr_row = precalculated_item_colors[i]; - for (int j = 0; j < data.length; ++j) - { + for (int j = 0; j < data.length; ++j) { curr_row[j] = (Color) getValueAt(j, i + 1); } } this.item_colors_precalculated = true; } - - private transient boolean item_colors_precalculated = false; - - private transient Color[][] precalculated_item_colors = null; - - private enum ColumnNames - { + + private enum ColumnNames { LAYER, TRACES, FIXED_TRACES, VIAS, FIXED_VIAS, PINS, CONDUCTION_AREAS, KEEPOUTS, VIA_KEEPOUTS, PLACE_KEEPOUTS } } diff --git a/src/main/java/net/freerouting/boardgraphics/ItemDrawInfo.java b/src/main/java/net/freerouting/boardgraphics/ItemDrawInfo.java index e0ac839b..58c30277 100644 --- a/src/main/java/net/freerouting/boardgraphics/ItemDrawInfo.java +++ b/src/main/java/net/freerouting/boardgraphics/ItemDrawInfo.java @@ -20,26 +20,27 @@ package net.freerouting.boardgraphics; -import java.awt.Color; +import java.awt.*; /** * Information for drawing an item on the screen. * - * @author alfons + * @author alfons */ -public class ItemDrawInfo -{ - - /** Creates a new instance of ItemDrawInfo */ - public ItemDrawInfo(Color[] p_layer_color, double p_intensity) - { - layer_color = p_layer_color; - intensity = p_intensity; - } - - /** The color of the item on each layer */ +public class ItemDrawInfo { + + /** + * The color of the item on each layer + */ public final Color[] layer_color; - // The translucency factor of the color. Must be between 0 and 1. public final double intensity; + + /** + * Creates a new instance of ItemDrawInfo + */ + public ItemDrawInfo(Color[] p_layer_color, double p_intensity) { + layer_color = p_layer_color; + intensity = p_intensity; + } } diff --git a/src/main/java/net/freerouting/boardgraphics/OtherColorTableModel.java b/src/main/java/net/freerouting/boardgraphics/OtherColorTableModel.java index 9125c279..5ce291ee 100644 --- a/src/main/java/net/freerouting/boardgraphics/OtherColorTableModel.java +++ b/src/main/java/net/freerouting/boardgraphics/OtherColorTableModel.java @@ -20,20 +20,18 @@ package net.freerouting.boardgraphics; -import java.awt.Color; +import java.awt.*; /** * Stores the colors used for the background and highlighting. * * @author Alfons Wirtz */ -public class OtherColorTableModel extends ColorTableModel implements java.io.Serializable -{ - - public OtherColorTableModel(java.util.Locale p_locale) - { +public class OtherColorTableModel extends ColorTableModel implements java.io.Serializable { + + public OtherColorTableModel(java.util.Locale p_locale) { super(1, p_locale); - data[0] = new Color [ColumnNames.values().length]; + data[0] = new Color[ColumnNames.values().length]; Object[] curr_row = data[0]; curr_row[ColumnNames.BACKGROUND.ordinal()] = new Color(70, 70, 70); curr_row[ColumnNames.HIGHLIGHT.ordinal()] = Color.white; @@ -44,132 +42,105 @@ public OtherColorTableModel(java.util.Locale p_locale) curr_row[ColumnNames.COMPONENT_BACK.ordinal()] = Color.red; curr_row[ColumnNames.LENGTH_MATCHING_AREA.ordinal()] = Color.green; } - + public OtherColorTableModel(java.io.ObjectInputStream p_stream) - throws java.io.IOException, java.lang.ClassNotFoundException - { + throws java.io.IOException, java.lang.ClassNotFoundException { super(p_stream); } - + /** * Copy construcror. */ - public OtherColorTableModel(OtherColorTableModel p_item_color_model) - { + public OtherColorTableModel(OtherColorTableModel p_item_color_model) { super(p_item_color_model.data.length, p_item_color_model.locale); - for (int i = 0; i < this.data.length; ++i) - { + for (int i = 0; i < this.data.length; ++i) { this.data[i] = new Object[p_item_color_model.data[i].length]; System.arraycopy(p_item_color_model.data[i], 0, this.data[i], 0, this.data[i].length); } } - - - public int getColumnCount() - { + + + public int getColumnCount() { return ColumnNames.values().length; } - - public String getColumnName(int p_col) - { - java.util.ResourceBundle resources = + + public String getColumnName(int p_col) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.boardgraphics.ColorTableModel", this.locale); return resources.getString(ColumnNames.values()[p_col].toString()); } - - public boolean isCellEditable(int p_row, int p_col) - { + + public boolean isCellEditable(int p_row, int p_col) { return true; } - - public Color get_background_color() - { - return (Color)(data[0][ColumnNames.BACKGROUND.ordinal()]); + + public Color get_background_color() { + return (Color) (data[0][ColumnNames.BACKGROUND.ordinal()]); + } + + public void set_background_color(Color p_color) { + data[0][ColumnNames.BACKGROUND.ordinal()] = p_color; } - - public Color get_hilight_color() - { + + public Color get_hilight_color() { return (Color) (data[0][ColumnNames.HIGHLIGHT.ordinal()]); } - - public Color get_incomplete_color() - { + + public void set_hilight_color(Color p_color) { + data[0][ColumnNames.HIGHLIGHT.ordinal()] = p_color; + } + + public Color get_incomplete_color() { return (Color) (data[0][ColumnNames.INCOMPLETES.ordinal()]); } - - public Color get_outline_color() - { + + public void set_incomplete_color(Color p_color) { + data[0][ColumnNames.INCOMPLETES.ordinal()] = p_color; + } + + public Color get_outline_color() { return (Color) (data[0][ColumnNames.OUTLINE.ordinal()]); } - - public Color get_violations_color() - { + + public void set_outline_color(Color p_color) { + data[0][ColumnNames.OUTLINE.ordinal()] = p_color; + } + + public Color get_violations_color() { return (Color) (data[0][ColumnNames.VIOLATIONS.ordinal()]); } - - public Color get_component_color(boolean p_front) - { + + public void set_violations_color(Color p_color) { + data[0][ColumnNames.VIOLATIONS.ordinal()] = p_color; + } + + public Color get_component_color(boolean p_front) { Color result; - if (p_front) - { + if (p_front) { result = (Color) (data[0][ColumnNames.COMPONENT_FRONT.ordinal()]); - } - else - { + } else { result = (Color) (data[0][ColumnNames.COMPONENT_BACK.ordinal()]); } return result; } - - public Color get_length_matching_area_color() - { + + public Color get_length_matching_area_color() { return (Color) (data[0][ColumnNames.LENGTH_MATCHING_AREA.ordinal()]); } - - public void set_background_color(Color p_color) - { - data[0][ColumnNames.BACKGROUND.ordinal()] = p_color; - } - - public void set_hilight_color(Color p_color) - { - data[0][ColumnNames.HIGHLIGHT.ordinal()] = p_color; - } - - public void set_incomplete_color(Color p_color) - { - data[0][ColumnNames.INCOMPLETES.ordinal()] = p_color; - } - - public void set_violations_color(Color p_color) - { - data[0][ColumnNames.VIOLATIONS.ordinal()] = p_color; - } - - public void set_outline_color(Color p_color) - { - data[0][ColumnNames.OUTLINE.ordinal()] = p_color; + + public void set_length_matching_area_color(Color p_color) { + data[0][ColumnNames.LENGTH_MATCHING_AREA.ordinal()] = p_color; } - - public void set_component_color(Color p_color, boolean p_front) - { - if (p_front) - { + + public void set_component_color(Color p_color, boolean p_front) { + if (p_front) { data[0][ColumnNames.COMPONENT_FRONT.ordinal()] = p_color; - } - else - { + } else { data[0][ColumnNames.COMPONENT_BACK.ordinal()] = p_color; } } - - public void set_length_matching_area_color(Color p_color) - { - data[0][ColumnNames.LENGTH_MATCHING_AREA.ordinal()] = p_color; - } - - private enum ColumnNames - { + + private enum ColumnNames { BACKGROUND, HIGHLIGHT, INCOMPLETES, VIOLATIONS, OUTLINE, COMPONENT_FRONT, COMPONENT_BACK, LENGTH_MATCHING_AREA } } diff --git a/src/main/java/net/freerouting/boardgraphics/package.html b/src/main/java/net/freerouting/boardgraphics/package.html index 0867456a..d376d399 100644 --- a/src/main/java/net/freerouting/boardgraphics/package.html +++ b/src/main/java/net/freerouting/boardgraphics/package.html @@ -1,5 +1,6 @@ -java.text package -Contains user interface independent functionality for displaying a board on a sccreen. \ No newline at end of file +Contains user interface independent functionality for displaying a board on a sccreen. + \ No newline at end of file diff --git a/src/main/java/net/freerouting/datastructures/ArrayStack.java b/src/main/java/net/freerouting/datastructures/ArrayStack.java index 7d245d0d..f8c05fc8 100644 --- a/src/main/java/net/freerouting/datastructures/ArrayStack.java +++ b/src/main/java/net/freerouting/datastructures/ArrayStack.java @@ -28,63 +28,54 @@ * * @author Alfons Wirtz */ -public class ArrayStack -{ +public class ArrayStack { + private int level = -1; + private p_element_type[] node_arr; + /** * Creates a new instance of ArrayStack with an initial maximal capacity for p_max_stack_depth elements. */ - public ArrayStack(int p_max_stack_depth) - { - node_arr = (p_element_type [] ) new Object [p_max_stack_depth]; + public ArrayStack(int p_max_stack_depth) { + node_arr = (p_element_type[]) new Object[p_max_stack_depth]; } - + /** * Sets the stack to empty. */ - public void reset() - { + public void reset() { level = -1; } - + /** - * Pushed p_element onto the stack. + * Pushed p_element onto the stack. */ - public void push(p_element_type p_element) - { - + public void push(p_element_type p_element) { + ++level; - - if (level >= node_arr.length) - { + + if (level >= node_arr.length) { reallocate(); } - + node_arr[level] = p_element; } - + /** * Pops the next element from the top of the stack. * Returns null, if the stack is exhausted. */ - public p_element_type pop() - { - if (level < 0) - { + public p_element_type pop() { + if (level < 0) { return null; } p_element_type result = node_arr[level]; --level; return result; } - - private void reallocate() - { - p_element_type [] new_arr = (p_element_type [] ) new Object[4 * this.node_arr.length]; + + private void reallocate() { + p_element_type[] new_arr = (p_element_type[]) new Object[4 * this.node_arr.length]; System.arraycopy(node_arr, 0, new_arr, 0, node_arr.length); this.node_arr = new_arr; } - - private int level = -1; - - private p_element_type[] node_arr ; } diff --git a/src/main/java/net/freerouting/datastructures/BigIntAux.java b/src/main/java/net/freerouting/datastructures/BigIntAux.java index 2f923f69..486c7bf0 100644 --- a/src/main/java/net/freerouting/datastructures/BigIntAux.java +++ b/src/main/java/net/freerouting/datastructures/BigIntAux.java @@ -14,34 +14,59 @@ import java.math.BigInteger; /** - * * Auxiliary functions with BigInteger Parameters - + * * @author Alfons Wirtz */ -public class BigIntAux -{ +public class BigIntAux { + /* + * trailingZeroTable[i] is the number of trailing zero bits in the binary + * representaion of i. + */ + final static byte trailingZeroTable[] = { + -25, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0}; + + + private BigIntAux() // disallow instantiation + { + } + + // the following function binaryGcd is copied from private parts of java.math + // because we need it public. + /** * calculates the determinant of the vectors * (p_x_1, p_y_1) and (p_x_2, p_y_2) */ - public static final BigInteger determinant (BigInteger p_x_1, BigInteger p_y_1, - BigInteger p_x_2, BigInteger p_y_2) - { + public static final BigInteger determinant(BigInteger p_x_1, BigInteger p_y_1, + BigInteger p_x_2, BigInteger p_y_2) { BigInteger tmp1 = p_x_1.multiply(p_y_2); BigInteger tmp2 = p_x_2.multiply(p_y_1); return tmp1.subtract(tmp2); } - /** * auxiliary function to implement addition and translation in the * classes RationalVector and RationalPoint */ public static final BigInteger[] add_rational_coordinates(BigInteger[] p_first, - BigInteger [] p_second) - { + BigInteger[] p_second) { BigInteger[] result = new BigInteger[3]; if (p_first[2].equals(p_second[2])) // both rational numbers have the same denominator @@ -49,8 +74,7 @@ public static final BigInteger[] add_rational_coordinates(BigInteger[] p_first, result[2] = p_first[2]; result[0] = p_first[0].add(p_second[0]); result[1] = p_first[1].add(p_second[1]); - } - else + } else // multiply both denominators for the new denominator // to be on the save side: // taking the leat common multiple whould be optimal @@ -66,38 +90,13 @@ public static final BigInteger[] add_rational_coordinates(BigInteger[] p_first, return result; } - // the following function binaryGcd is copied from private parts of java.math - // because we need it public. - - /* - * trailingZeroTable[i] is the number of trailing zero bits in the binary - * representaion of i. - */ - final static byte trailingZeroTable[] = { - -25, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0}; - /** * Calculate GCD of a and b interpreted as unsigned integers. */ public static final int binaryGcd(int a, int b) { - if (b==0) + if (b == 0) return a; - if (a==0) + if (a == 0) return b; int x; @@ -122,7 +121,7 @@ public static final int binaryGcd(int a, int b) { int t = (aZeros < bZeros ? aZeros : bZeros); while (a != b) { - if ((a+0x80000000) > (b+0x80000000)) { // a > b as unsigned + if ((a + 0x80000000) > (b + 0x80000000)) { // a > b as unsigned a -= b; while ((x = a & 0xff) == 0) @@ -136,10 +135,6 @@ public static final int binaryGcd(int a, int b) { b >>>= trailingZeroTable[x]; } } - return a< node_stack = new ArrayStack(10000); + /** * Constructor with a fixed set of directions defining the keys and and * the surrounding shapes */ - public MinAreaTree(ShapeBoundingDirections p_directions) - { + public MinAreaTree(ShapeBoundingDirections p_directions) { super(p_directions); } - + /** * Calculates the objects in this tree, which overlap with p_shape */ - public Set overlaps(RegularTileShape p_shape) - { - Set found_overlaps = new TreeSet() ; - if (this.root == null) - { + public Set overlaps(RegularTileShape p_shape) { + Set found_overlaps = new TreeSet(); + if (this.root == null) { return found_overlaps; } this.node_stack.reset(); this.node_stack.push(this.root); TreeNode curr_node; - for (;;) - { + for (; ; ) { curr_node = this.node_stack.pop(); - if (curr_node == null) - { + if (curr_node == null) { break; } - if (curr_node.bounding_shape.intersects(p_shape)) - { - if (curr_node instanceof Leaf) - { + if (curr_node.bounding_shape.intersects(p_shape)) { + if (curr_node instanceof Leaf) { found_overlaps.add((Leaf) curr_node); - } - else - { - this.node_stack.push(((InnerNode)curr_node).first_child); - this.node_stack.push(((InnerNode)curr_node).second_child); + } else { + this.node_stack.push(((InnerNode) curr_node).first_child); + this.node_stack.push(((InnerNode) curr_node).second_child); } } } - return found_overlaps ; + return found_overlaps; } - - - void insert(Leaf p_leaf) - { + + void insert(Leaf p_leaf) { ++this.leaf_count; - + // Tree is empty - just insert the new leaf - if ( root == null ) - { - root = p_leaf ; + if (root == null) { + root = p_leaf; return; } - + // Non-empty tree - do a recursive location for leaf replacement - Leaf leaf_to_replace = position_locate(root, p_leaf) ; - + Leaf leaf_to_replace = position_locate(root, p_leaf); + // Construct a new node - whenever a leaf is added so is a new node - RegularTileShape new_bounds = p_leaf.bounding_shape.union(leaf_to_replace.bounding_shape) ; + RegularTileShape new_bounds = p_leaf.bounding_shape.union(leaf_to_replace.bounding_shape); InnerNode curr_parent = leaf_to_replace.parent; - InnerNode new_node = new InnerNode(new_bounds, curr_parent) ; - - if ( leaf_to_replace.parent!= null ) - { + InnerNode new_node = new InnerNode(new_bounds, curr_parent); + + if (leaf_to_replace.parent != null) { // Replace the pointer from the parent to the leaf with our new node - if ( leaf_to_replace == curr_parent.first_child ) - { - curr_parent.first_child = new_node ; - } - else - { - curr_parent.second_child = new_node ; + if (leaf_to_replace == curr_parent.first_child) { + curr_parent.first_child = new_node; + } else { + curr_parent.second_child = new_node; } } // Update the parent pointers of the old leaf and new leaf to point to new node - leaf_to_replace.parent = new_node ; - p_leaf.parent = new_node ; - + leaf_to_replace.parent = new_node; + p_leaf.parent = new_node; + // Insert the children in any order. - new_node.first_child = leaf_to_replace ; - new_node.second_child = p_leaf ; - - if (root == leaf_to_replace) - { + new_node.first_child = leaf_to_replace; + new_node.second_child = p_leaf; + + if (root == leaf_to_replace) { root = new_node; } } - - private final Leaf position_locate(TreeNode p_curr_node, Leaf p_leaf_to_insert) - { + + private final Leaf position_locate(TreeNode p_curr_node, Leaf p_leaf_to_insert) { TreeNode curr_node = p_curr_node; - - while (!(curr_node instanceof Leaf)) - { + + while (!(curr_node instanceof Leaf)) { InnerNode curr_inner_node = (InnerNode) curr_node; - curr_inner_node.bounding_shape = p_leaf_to_insert.bounding_shape.union(curr_inner_node.bounding_shape) ; - + curr_inner_node.bounding_shape = p_leaf_to_insert.bounding_shape.union(curr_inner_node.bounding_shape); + // Choose the the child, so that the area increase of that child after taking the union // with the shape of p_leaf_to_insert is minimal. - + RegularTileShape first_child_shape = curr_inner_node.first_child.bounding_shape; RegularTileShape union_with_first_child_shape = p_leaf_to_insert.bounding_shape.union(first_child_shape); - double first_area_increase = union_with_first_child_shape.area()- first_child_shape.area(); - + double first_area_increase = union_with_first_child_shape.area() - first_child_shape.area(); + RegularTileShape second_child_shape = curr_inner_node.second_child.bounding_shape; RegularTileShape union_with_second_child_shape = p_leaf_to_insert.bounding_shape.union(second_child_shape); - double second_area_increase = union_with_second_child_shape.area() - second_child_shape.area(); - - if (first_area_increase <= second_area_increase) - { - curr_node = curr_inner_node.first_child ; - } - else - { - curr_node = curr_inner_node.second_child ; + double second_area_increase = union_with_second_child_shape.area() - second_child_shape.area(); + + if (first_area_increase <= second_area_increase) { + curr_node = curr_inner_node.first_child; + } else { + curr_node = curr_inner_node.second_child; } } return (Leaf) curr_node; } - + /** * removes an entry from this tree */ - public void remove_leaf(Leaf p_leaf) - { - if (p_leaf == null) - { + public void remove_leaf(Leaf p_leaf) { + if (p_leaf == null) { return; } // remove the leaf node @@ -179,47 +156,33 @@ public void remove_leaf(Leaf p_leaf) p_leaf.parent = null; p_leaf.object = null; --this.leaf_count; - if (parent == null) - { + if (parent == null) { // tree gets empty root = null; return; } // find the other leaf of the parent TreeNode other_leaf; - if (parent.second_child == p_leaf) - { + if (parent.second_child == p_leaf) { other_leaf = parent.first_child; - } - else if (parent.first_child == p_leaf) - { + } else if (parent.first_child == p_leaf) { other_leaf = parent.second_child; - } - else - { + } else { System.out.println("MinAreaTree.remove_leaf: parent inconsistent"); other_leaf = null; } // link the other leaf to the grand_parent and remove the parent node InnerNode grand_parent = parent.parent; other_leaf.parent = grand_parent; - if (grand_parent == null) - { + if (grand_parent == null) { // only one leaf left in the tree root = other_leaf; - } - else - { - if (grand_parent.second_child == parent) - { + } else { + if (grand_parent.second_child == parent) { grand_parent.second_child = other_leaf; - } - else if (grand_parent.first_child == parent) - { + } else if (grand_parent.first_child == parent) { grand_parent.first_child = other_leaf; - } - else - { + } else { System.out.println("MinAreaTree.remove_leaf: grand_parent inconsistent"); } } @@ -227,25 +190,21 @@ else if (grand_parent.first_child == parent) parent.first_child = null; parent.second_child = null; parent.bounding_shape = null; - + // recalculate the bounding shapes of the ancestors // as long as it gets smaller after removing p_leaf InnerNode node_to_recalculate = grand_parent; - while (node_to_recalculate != null) - { + while (node_to_recalculate != null) { RegularTileShape new_bounds = node_to_recalculate.second_child.bounding_shape.union(node_to_recalculate.first_child.bounding_shape); - if (new_bounds.contains(node_to_recalculate.bounding_shape)) - { + if (new_bounds.contains(node_to_recalculate.bounding_shape)) { // the new bounds are not smaller, no further recalculate nessesary break; - + } node_to_recalculate.bounding_shape = new_bounds; - node_to_recalculate = node_to_recalculate.parent; + node_to_recalculate = node_to_recalculate.parent; } } - - protected ArrayStack node_stack = new ArrayStack (10000); } diff --git a/src/main/java/net/freerouting/datastructures/Observers.java b/src/main/java/net/freerouting/datastructures/Observers.java index 9102e181..416d0c56 100644 --- a/src/main/java/net/freerouting/datastructures/Observers.java +++ b/src/main/java/net/freerouting/datastructures/Observers.java @@ -25,29 +25,32 @@ * * @author Alfons Wirtz */ -public interface Observers -{ +public interface Observers { /** * Tell the observers the deletion p_object. */ void notify_deleted(ObjectType p_object); - + /** * Notify the observers, that they can syncronize the changes on p_object. */ void notify_changed(ObjectType p_object); - + /** * Enable the observers to syncronize the new created item. */ void notify_new(ObjectType p_object); - - /** Starts notifying the observers */ + + /** + * Starts notifying the observers + */ void activate(); - - /** Ends notifying the observers */ + + /** + * Ends notifying the observers + */ void deactivate(); - + /** * Returns, if the observer is activated. */ diff --git a/src/main/java/net/freerouting/datastructures/PlanarDelaunayTriangulation.java b/src/main/java/net/freerouting/datastructures/PlanarDelaunayTriangulation.java index 8b24d922..6e52fbf7 100644 --- a/src/main/java/net/freerouting/datastructures/PlanarDelaunayTriangulation.java +++ b/src/main/java/net/freerouting/datastructures/PlanarDelaunayTriangulation.java @@ -20,17 +20,12 @@ package net.freerouting.datastructures; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import net.freerouting.geometry.planar.Point; import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Side; import net.freerouting.geometry.planar.Limits; +import net.freerouting.geometry.planar.Point; +import net.freerouting.geometry.planar.Side; + +import java.util.*; /** * Creates a Delaunay triangulation in the plane for the input objects. @@ -42,90 +37,99 @@ * * @author Alfons Wirtz */ -public class PlanarDelaunayTriangulation -{ - - /** Creates a new instance of PlanarDelaunayTriangulation from p_object_list. */ - public PlanarDelaunayTriangulation(Collection p_object_list) - { +public class PlanarDelaunayTriangulation { + + /** + * Randum generatur to shuffle the input corners. + * A fixed seed is used to make the results reproduceble. + */ + static private int seed = 99; + static private java.util.Random random_generator = new java.util.Random(seed); + /** + * The structure for seaching the triangle containing a given input corner. + */ + private final TriangleGraph search_graph; + /** + * This list contain the edges of the trinangulation, where the start corner and end corner are equal. + */ + private Collection degenerate_edges; + /** + * id numbers are for implementing an ordering on the Edges so that they can be used in a set for example + */ + private int last_edge_id_no = 0; + + /** + * Creates a new instance of PlanarDelaunayTriangulation from p_object_list. + */ + public PlanarDelaunayTriangulation(Collection p_object_list) { List corner_list = new LinkedList(); - for (PlanarDelaunayTriangulation.Storable curr_object : p_object_list) - { + for (PlanarDelaunayTriangulation.Storable curr_object : p_object_list) { Point[] curr_corners = curr_object.get_triangulation_corners(); - for (Point curr_corner : curr_corners) - { + for (Point curr_corner : curr_corners) { corner_list.add(new Corner(curr_object, curr_corner)); } } - + // create a random permutation of the corners. // use a fixed seed to get reproducable result random_generator.setSeed(seed); Collections.shuffle(corner_list, random_generator); - + // create a big triangle contaning all corners in the list to start with. - + int bounding_coor = Limits.CRIT_INT; Corner[] bounding_corners = new Corner[3]; bounding_corners[0] = new Corner(null, new IntPoint(bounding_coor, 0)); - bounding_corners[1] = new Corner(null, new IntPoint(0, bounding_coor)); + bounding_corners[1] = new Corner(null, new IntPoint(0, bounding_coor)); bounding_corners[2] = new Corner(null, new IntPoint(-bounding_coor, -bounding_coor)); - - Edge [] edge_lines = new Edge[3]; - for (int i = 0; i < 2; ++i) - { - edge_lines[i] = new Edge(bounding_corners[i], bounding_corners[i+1]); + + Edge[] edge_lines = new Edge[3]; + for (int i = 0; i < 2; ++i) { + edge_lines[i] = new Edge(bounding_corners[i], bounding_corners[i + 1]); } edge_lines[2] = new Edge(bounding_corners[2], bounding_corners[0]); - + Triangle start_triangle = new Triangle(edge_lines, null); - + // Set the left triangle of the edge lines to start_triangle. // The right triangles remains null. - for (Edge curr_edge : edge_lines) - { + for (Edge curr_edge : edge_lines) { curr_edge.set_left_triangle(start_triangle); } - + // Initialize the search graph. - + this.search_graph = new TriangleGraph(start_triangle); this.degenerate_edges = new LinkedList(); - + // Insert the corners in the corner list into the search graph. - - for (Corner curr_corner : corner_list) - { + + for (Corner curr_corner : corner_list) { Triangle triangle_to_split = this.search_graph.position_locate(curr_corner); this.split(triangle_to_split, curr_corner); } } - + /** * Returns all edge lines of the result of the Delaunay Triangulation. */ - public Collection get_edge_lines() - { + public Collection get_edge_lines() { Collection result = new LinkedList(); - for (Edge curr_edge : this.degenerate_edges) - { + for (Edge curr_edge : this.degenerate_edges) { result.add(new ResultEdge(curr_edge.start_corner.coor, curr_edge.start_corner.object, curr_edge.end_corner.coor, curr_edge.end_corner.object)); } - if (this.search_graph.anchor != null) - { + if (this.search_graph.anchor != null) { Set result_edges = new TreeSet(); this.search_graph.anchor.get_leaf_edges(result_edges); - for (Edge curr_edge : result_edges) - { + for (Edge curr_edge : result_edges) { result.add(new ResultEdge(curr_edge.start_corner.coor, curr_edge.start_corner.object, curr_edge.end_corner.coor, curr_edge.end_corner.object)); } } return result; } - - + /** * Splits p_triangle into 3 new triangles at p_corner, if p_corner lies in the interiour. * If p_corner lies on the border, p_triangle and the corresponding neighbour @@ -133,45 +137,34 @@ public Collection get_edge_lines() * If p_corner lies outside this triangle or on a corner, nothing is split. * In this case the function returns false. */ - private boolean split(Triangle p_triangle, Corner p_corner) - { - + private boolean split(Triangle p_triangle, Corner p_corner) { + // check, if p_corner is in the interiour of this triangle or // if p_corner is contained in an edge line. - + Edge containing_edge = null; - for (int i = 0; i < 3; ++i) - { + for (int i = 0; i < 3; ++i) { Edge curr_edge = p_triangle.edge_lines[i]; Side curr_side; - if (curr_edge.left_triangle == p_triangle) - { + if (curr_edge.left_triangle == p_triangle) { curr_side = p_corner.side_of(curr_edge.start_corner, curr_edge.end_corner); - } - else - { + } else { curr_side = p_corner.side_of(curr_edge.end_corner, curr_edge.start_corner); } - if (curr_side == Side.ON_THE_RIGHT) - { + if (curr_side == Side.ON_THE_RIGHT) { // p_corner is outside this triangle System.out.println("PlanarDelaunayTriangulation.split: p_corner is outside"); return false; - } - else if (curr_side == Side.COLLINEAR) - { - if (containing_edge != null) - { + } else if (curr_side == Side.COLLINEAR) { + if (containing_edge != null) { // p_corner is equal to a corner of this triangle - + Corner common_corner = curr_edge.common_corner(containing_edge); - if (common_corner == null) - { + if (common_corner == null) { System.out.println("PlanarDelaunayTriangulation.split: common corner expected"); return false; } - if (p_corner.object == common_corner.object) - { + if (p_corner.object == common_corner.object) { return false; } this.degenerate_edges.add(new Edge(p_corner, common_corner)); @@ -180,355 +173,370 @@ else if (curr_side == Side.COLLINEAR) containing_edge = curr_edge; } } - - if (containing_edge == null) - { + + if (containing_edge == null) { // split p_triangle into 3 new triangles by adding edges from // the corners of p_triangle to p_corner. - + Triangle[] new_triangles = p_triangle.split_at_inner_point(p_corner); - - if (new_triangles == null) - { + + if (new_triangles == null) { return false; } - - for (Triangle curr_triangle : new_triangles) - { + + for (Triangle curr_triangle : new_triangles) { this.search_graph.insert(curr_triangle, p_triangle); } - - for (int i = 0; i < 3; ++i) - { + + for (int i = 0; i < 3; ++i) { legalize_edge(p_corner, p_triangle.edge_lines[i]); } - - } - else - { + + } else { // split this triangle and the neighbour triangle into 4 new triangles by adding edges from // the corners of the triangles to p_corner. - + Triangle neighbour_to_split = containing_edge.other_neighbour(p_triangle); - + Triangle[] new_triangles = p_triangle.split_at_border_point(p_corner, neighbour_to_split); - if (new_triangles == null) - { + if (new_triangles == null) { return false; } - + // There are exact four new triangles with the first 2 dividing p_triangle and // the last 2 dividing neighbour_to_split. this.search_graph.insert(new_triangles[0], p_triangle); this.search_graph.insert(new_triangles[1], p_triangle); this.search_graph.insert(new_triangles[2], neighbour_to_split); this.search_graph.insert(new_triangles[3], neighbour_to_split); - - for (int i = 0; i < 3; ++i) - { + + for (int i = 0; i < 3; ++i) { Edge curr_edge = p_triangle.edge_lines[i]; - if (curr_edge != containing_edge) - { + if (curr_edge != containing_edge) { legalize_edge(p_corner, curr_edge); } } - for (int i = 0; i < 3; ++i) - { + for (int i = 0; i < 3; ++i) { Edge curr_edge = neighbour_to_split.edge_lines[i]; - if (curr_edge != containing_edge) - { + if (curr_edge != containing_edge) { legalize_edge(p_corner, curr_edge); } } } return true; } - + /** * Flips p_edge, if it is no legal edge of the Delaunay Triangulation. * p_corner is the last inserted corner of the triangulation * Return true, if the triangulation was changed. */ - private boolean legalize_edge(Corner p_corner, Edge p_edge) - { - if (p_edge.is_legal()) - { + private boolean legalize_edge(Corner p_corner, Edge p_edge) { + if (p_edge.is_legal()) { return false; } Triangle triangle_to_change; - if (p_edge.left_triangle.opposite_corner(p_edge) == p_corner) - { + if (p_edge.left_triangle.opposite_corner(p_edge) == p_corner) { triangle_to_change = p_edge.right_triangle; - } - else if (p_edge.right_triangle.opposite_corner(p_edge) == p_corner) - { + } else if (p_edge.right_triangle.opposite_corner(p_edge) == p_corner) { triangle_to_change = p_edge.left_triangle; - } - else - { + } else { System.out.println("PlanarDelaunayTriangulation.legalize_edge: edge lines inconsistant"); return false; } Edge flipped_edge = p_edge.flip(); - + // Update the search graph. - + this.search_graph.insert(flipped_edge.left_triangle, p_edge.left_triangle); this.search_graph.insert(flipped_edge.right_triangle, p_edge.left_triangle); this.search_graph.insert(flipped_edge.left_triangle, p_edge.right_triangle); this.search_graph.insert(flipped_edge.right_triangle, p_edge.right_triangle); - + // Call this function recursively for the other edge lines of triangle_to_change. - for (int i = 0; i < 3; ++i) - { + for (int i = 0; i < 3; ++i) { Edge curr_edge = triangle_to_change.edge_lines[i]; - if (curr_edge != p_edge) - { + if (curr_edge != p_edge) { legalize_edge(p_corner, curr_edge); } } return true; } - - + /** * Checks the consistancy of the triangles in this triagulation. * Used for debugging purposes. */ - public boolean validate() - { + public boolean validate() { boolean result = this.search_graph.anchor.validate(); - if (result == true) - { + if (result == true) { System.out.println("Delauny triangulation check passed ok"); - } - else - { + } else { System.out.println("Delauny triangulation check has detected problems"); } return result; } - + /** * Creates a new unique edge id number. */ - private int new_edge_id_no() - { + private int new_edge_id_no() { ++this.last_edge_id_no; return this.last_edge_id_no; } - - /** - * The structure for seaching the triangle containing a given input corner. - */ - private final TriangleGraph search_graph; - - /** - * This list contain the edges of the trinangulation, where the start corner and end corner are equal. - */ - private Collection degenerate_edges; - - /** - * id numbers are for implementing an ordering on the Edges so that they can be used in a set for example - */ - private int last_edge_id_no = 0; - - /** - * Randum generatur to shuffle the input corners. - * A fixed seed is used to make the results reproduceble. - */ - static private int seed = 99; - static private java.util.Random random_generator = new java.util.Random(seed); - + /** * Interface with funktionality required for objects to be used * in a planar triangulation. */ - public interface Storable - { + public interface Storable { /** * Returns an array of corners, which can be used in a planar triangulation. */ net.freerouting.geometry.planar.Point[] get_triangulation_corners(); } - + /** * Describes a line segment in the result of the Delaunay Triangulation. */ - public static class ResultEdge - { + public static class ResultEdge { + /** + * The start point of the line segment + */ + public final Point start_point; + /** + * The object at the start point of the line segment + */ + public final PlanarDelaunayTriangulation.Storable start_object; + /** + * The end point of the line segment + */ + public final Point end_point; + /** + * The object at the end point of the line segment + */ + public final PlanarDelaunayTriangulation.Storable end_object; private ResultEdge(Point p_start_point, PlanarDelaunayTriangulation.Storable p_start_object, - Point p_end_point, PlanarDelaunayTriangulation.Storable p_end_object) - { + Point p_end_point, PlanarDelaunayTriangulation.Storable p_end_object) { start_point = p_start_point; start_object = p_start_object; end_point = p_end_point; end_object = p_end_object; } - /** The start point of the line segment */ - public final Point start_point; - /** The object at the start point of the line segment */ - public final PlanarDelaunayTriangulation.Storable start_object; - /** The end point of the line segment */ - public final Point end_point; - /** The object at the end point of the line segment */ - public final PlanarDelaunayTriangulation.Storable end_object; } - + /** * Contains a corner point together with the objects this corner belongs to. */ - private static class Corner - { - public Corner(PlanarDelaunayTriangulation.Storable p_object, Point p_coor) - { + private static class Corner { + public final PlanarDelaunayTriangulation.Storable object; + public final Point coor; + + public Corner(PlanarDelaunayTriangulation.Storable p_object, Point p_coor) { object = p_object; coor = p_coor; } - + /** * The function returns - * Side.ON_THE_LEFT, if this corner is on the left of the line from p_1 to p_2; - * Side.ON_THE_RIGHT, if this corner is on the right of the line from p_1 to p_2; - * and Side.COLLINEAR, if this corner is collinear with p_1 and p_2. + * Side.ON_THE_LEFT, if this corner is on the left of the line from p_1 to p_2; + * Side.ON_THE_RIGHT, if this corner is on the right of the line from p_1 to p_2; + * and Side.COLLINEAR, if this corner is collinear with p_1 and p_2. */ - public Side side_of(Corner p_1, Corner p_2) - { + public Side side_of(Corner p_1, Corner p_2) { return this.coor.side_of(p_1.coor, p_2.coor); } - - public final PlanarDelaunayTriangulation.Storable object; - public final Point coor; } - + + /** + * Directed acyclic graph for finding the triangle containing a search point p. + * The leaves contain the trianngles of the current triangulation. + * The internal nodes are triangles, that were part of the triangulationn at some earlier stage, + * but have been replaced their children. + */ + + private static class TriangleGraph { + private Triangle anchor = null; + + public TriangleGraph(Triangle p_triangle) { + if (p_triangle != null) { + insert(p_triangle, null); + } else { + this.anchor = null; + } + } + + public void insert(Triangle p_triangle, Triangle p_parent) { + p_triangle.initialize_is_on_the_left_of_edge_line_array(); + if (p_parent == null) { + anchor = p_triangle; + } else { + p_parent.children.add(p_triangle); + } + } + + /** + * Search for the leaf triangle containing p_corner. + * It will not be unique, if p_corner lies on a triangle edge. + */ + public Triangle position_locate(Corner p_corner) { + if (this.anchor == null) { + return null; + } + if (this.anchor.children.isEmpty()) { + return this.anchor; + } + for (Triangle curr_child : this.anchor.children) { + Triangle result = position_locate_reku(p_corner, curr_child); + if (result != null) { + return result; + } + } + System.out.println("TriangleGraph.position_locate: containing triangle not found"); + return null; + } + + /** + * Recursive part of position_locate. + */ + private Triangle position_locate_reku(Corner p_corner, Triangle p_triangle) { + if (!p_triangle.contains(p_corner)) { + return null; + } + + if (p_triangle.is_leaf()) { + return p_triangle; + } + for (Triangle curr_child : p_triangle.children) { + Triangle result = position_locate_reku(p_corner, curr_child); + if (result != null) { + return result; + } + } + System.out.println("TriangleGraph.position_locate_reku: containing triangle not found"); + return null; + } + } + /** * Describes an edge between two triangles in the triangulation. * The unique id_nos are for making edges comparable. */ - private class Edge implements Comparable - { - public Edge(Corner p_start_corner, Corner p_end_corner) - { + private class Edge implements Comparable { + public final Corner start_corner; + public final Corner end_corner; + /** + * The unique id number of this triangle. + */ + private final int id_no; + /** + * The triangle on the left side of this edge. + */ + private Triangle left_triangle = null; + /** + * The triangle on the right side of this edge. + */ + private Triangle right_triangle = null; + + public Edge(Corner p_start_corner, Corner p_end_corner) { start_corner = p_start_corner; end_corner = p_end_corner; id_no = new_edge_id_no(); } - - public int compareTo(Edge p_other) - { + + public int compareTo(Edge p_other) { return (this.id_no - p_other.id_no); } - - public void set_left_triangle(Triangle p_triangle) - { - left_triangle = p_triangle; - } - - public Triangle get_left_triangle() - { + + public Triangle get_left_triangle() { return left_triangle; } - - public void set_right_triangle(Triangle p_triangle) - { - right_triangle = p_triangle; + + public void set_left_triangle(Triangle p_triangle) { + left_triangle = p_triangle; } - - public Triangle get_right_triangle() - { + + public Triangle get_right_triangle() { return right_triangle; } - + + public void set_right_triangle(Triangle p_triangle) { + right_triangle = p_triangle; + } + /** * Returns the common corner of this edge and p_other, * or null, if no commen corner exists. */ - public Corner common_corner(Edge p_other) - { + public Corner common_corner(Edge p_other) { Corner result = null; - if (p_other.start_corner.equals(this.start_corner) || p_other.end_corner.equals(this.start_corner)) - { + if (p_other.start_corner.equals(this.start_corner) || p_other.end_corner.equals(this.start_corner)) { result = this.start_corner; - } - else if (p_other.start_corner.equals(this.end_corner) || p_other.end_corner.equals(this.end_corner)) - { + } else if (p_other.start_corner.equals(this.end_corner) || p_other.end_corner.equals(this.end_corner)) { result = this.end_corner; } return result; } - + /** * Returns the neighbour triangle of this edge, which is different from p_triangle. * If p_triangle is not a neighbour of this edge, null is returned. */ - public Triangle other_neighbour( Triangle p_triangle) - { + public Triangle other_neighbour(Triangle p_triangle) { Triangle result; - if (p_triangle == this.left_triangle) - { + if (p_triangle == this.left_triangle) { result = this.right_triangle; - } - else if (p_triangle == this.right_triangle) - { + } else if (p_triangle == this.right_triangle) { result = this.left_triangle; - } - else - { + } else { System.out.println("Edge.other_neighbour: inconsistant neigbour triangle"); result = null; } return result; } - + /** * Returns true, if this is a legal edge of the Delaunay Triangulation. */ - public boolean is_legal() - { - if (this.left_triangle == null || this.right_triangle == null) - { + public boolean is_legal() { + if (this.left_triangle == null || this.right_triangle == null) { return true; } Corner left_opposite_corner = this.left_triangle.opposite_corner(this); Corner right_opposite_corner = this.right_triangle.opposite_corner(this); - - boolean inside_circle = right_opposite_corner.coor.to_float().inside_circle( - this.start_corner.coor.to_float(),left_opposite_corner.coor.to_float(), + + boolean inside_circle = right_opposite_corner.coor.to_float().inside_circle( + this.start_corner.coor.to_float(), left_opposite_corner.coor.to_float(), this.end_corner.coor.to_float()); return !inside_circle; } - + /** * Flips this edge line to the edge line between the opposite corners * of the adjacent triangles. * Returns the new constructed Edge. */ - public Edge flip() - { + public Edge flip() { // Create the flipped edge, so that the start corner of this edge is on the left // and the end corner of this edge on the right. Edge flipped_edge = new Edge(this.right_triangle.opposite_corner(this), this.left_triangle.opposite_corner(this)); - + Triangle first_parent = this.left_triangle; - + // Calculate the index of this edge line in the left and right adjacent triangles. - + int left_index = -1; int right_index = -1; - for (int i = 0; i < 3; ++i) - { - if (this.left_triangle.edge_lines[i] == this) - { + for (int i = 0; i < 3; ++i) { + if (this.left_triangle.edge_lines[i] == this) { left_index = i; } - if (this.right_triangle.edge_lines[i] == this) - { + if (this.right_triangle.edge_lines[i] == this) { right_index = i; } } - if (left_index < 0 || right_index < 0) - { + if (left_index < 0 || right_index < 0) { System.out.println("Edge.flip: edge line inconsistant"); return null; } @@ -536,278 +544,228 @@ public Edge flip() Edge left_next_edge = this.left_triangle.edge_lines[(left_index + 1) % 3]; Edge right_prev_edge = this.right_triangle.edge_lines[(right_index + 2) % 3]; Edge right_next_edge = this.right_triangle.edge_lines[(right_index + 1) % 3]; - + // Create the left triangle of the flipped edge. - - Edge [] curr_edge_lines = new Edge[3]; + + Edge[] curr_edge_lines = new Edge[3]; curr_edge_lines[0] = flipped_edge; curr_edge_lines[1] = left_prev_edge; curr_edge_lines[2] = right_next_edge; Triangle new_left_triangle = new Triangle(curr_edge_lines, first_parent); flipped_edge.left_triangle = new_left_triangle; - if (left_prev_edge.left_triangle == this.left_triangle) - { + if (left_prev_edge.left_triangle == this.left_triangle) { left_prev_edge.left_triangle = new_left_triangle; - } - else - { + } else { left_prev_edge.right_triangle = new_left_triangle; } - if (right_next_edge.left_triangle == this.right_triangle) - { + if (right_next_edge.left_triangle == this.right_triangle) { right_next_edge.left_triangle = new_left_triangle; - } - else - { + } else { right_next_edge.right_triangle = new_left_triangle; } - + // Create the right triangle of the flipped edge. - + curr_edge_lines = new Edge[3]; curr_edge_lines[0] = flipped_edge; curr_edge_lines[1] = right_prev_edge; curr_edge_lines[2] = left_next_edge; Triangle new_right_triangle = new Triangle(curr_edge_lines, first_parent); flipped_edge.right_triangle = new_right_triangle; - if (right_prev_edge.left_triangle == this.right_triangle) - { + if (right_prev_edge.left_triangle == this.right_triangle) { right_prev_edge.left_triangle = new_right_triangle; - } - else - { + } else { right_prev_edge.right_triangle = new_right_triangle; } - if (left_next_edge.left_triangle == this.left_triangle) - { + if (left_next_edge.left_triangle == this.left_triangle) { left_next_edge.left_triangle = new_right_triangle; - } - else - { + } else { left_next_edge.right_triangle = new_right_triangle; } - + return flipped_edge; } - + /** * Checks the consistancy of this edge in its database. * Used for debugging purposes. */ - public boolean validate() - { + public boolean validate() { boolean result = true; - if (this.left_triangle == null) - { - if (this.start_corner.object != null || this.end_corner.object != null) - { + if (this.left_triangle == null) { + if (this.start_corner.object != null || this.end_corner.object != null) { System.out.println("Edge.validate: left triangle may be null only for bounding edges"); result = false; } - } - else - { + } else { // check if the left triangle contains this edge boolean found = false; - for (int i = 0; i < 3; ++i) - { - if (left_triangle.edge_lines[i] == this) - { + for (int i = 0; i < 3; ++i) { + if (left_triangle.edge_lines[i] == this) { found = true; break; } } - if (!found) - { + if (!found) { System.out.println("Edge.validate: left triangle does not contain this edge"); result = false; } } - if (this.right_triangle == null) - { - if (this.start_corner.object != null || this.end_corner.object != null) - { + if (this.right_triangle == null) { + if (this.start_corner.object != null || this.end_corner.object != null) { System.out.println("Edge.validate: right triangle may be null only for bounding edges"); result = false; } - } - else - { + } else { // check if the left triangle contains this edge boolean found = false; - for (int i = 0; i < 3; ++i) - { - if (right_triangle.edge_lines[i] == this) - { + for (int i = 0; i < 3; ++i) { + if (right_triangle.edge_lines[i] == this) { found = true; break; } } - if (!found) - { + if (!found) { System.out.println("Edge.validate: right triangle does not contain this edge"); result = false; } } - + return result; } - - - public final Corner start_corner; - public final Corner end_corner; - - - /** The triangle on the left side of this edge. */ - private Triangle left_triangle = null; - /** The triangle on the right side of this edge. */ - private Triangle right_triangle = null; - /** The unique id number of this triangle. */ - private final int id_no; } - - + /** * Describes a triangle in the triagulation. edge_lines ia an array of dimension 3. * The edge lines arec sorted in counter clock sense around the border of this triangle. * The list children points to the children of this triangle, when used as a node in the * search graph. */ - private class Triangle - { - public Triangle(Edge[] p_edge_lines, Triangle p_first_parent) - { + private class Triangle { + /** + * The 3 edge lines of this triangle sorted in counter clock sense around the border. + */ + private final Edge[] edge_lines; + /** + * Triangles resulting from an edge flip have 2 parents, all other triangles have 1 parent. + * first parent is used when traversing the graph sequentially to avoid + * visiting children nodes more than once. + */ + private final Triangle first_parent; + /** + * Indicates, if this triangle is on the left of the i-th edge line for i = 0 to 2. + * Must be set, if this triagngle is an inner node + * because left_triangle and right_triangle of edge lines point only to leaf nodes. + */ + private boolean[] is_on_the_left_of_edge_line = null; + /** + * The children of this triangle when used as a node in the triangle search graph. + */ + private Collection children; + + public Triangle(Edge[] p_edge_lines, Triangle p_first_parent) { this.edge_lines = p_edge_lines; // create an empty list for the children. this.children = new LinkedList(); this.first_parent = p_first_parent; } - + /** * Returns true, if this triangle node is a leaf, * and false, if it is an inner node. */ - public boolean is_leaf() - { + public boolean is_leaf() { return this.children.isEmpty(); } - + /** * Gets the corner with index p_no. */ - public Corner get_corner(int p_no) - { - if (p_no < 0 || p_no >= 3) - { + public Corner get_corner(int p_no) { + if (p_no < 0 || p_no >= 3) { System.out.println("Triangle.get_corner: p_no out of range"); return null; } Edge curr_edge = edge_lines[p_no]; Corner result; - if (curr_edge.left_triangle == this) - { + if (curr_edge.left_triangle == this) { result = curr_edge.start_corner; - } - else if (curr_edge.right_triangle == this) - { + } else if (curr_edge.right_triangle == this) { result = curr_edge.end_corner; - } - else - { + } else { System.out.println("Triangle.get_corner: inconsistant edge lines"); result = null; } return result; } - + /** * Calculates the opposite corner of this triangle to p_edge_line. * Returns null, if p_edge_line is nor an edge line of this triangle. */ - public Corner opposite_corner(Edge p_edge_line) - { + public Corner opposite_corner(Edge p_edge_line) { int edge_line_no = -1; - for (int i = 0; i < 3; ++i) - { - if (this.edge_lines[i] == p_edge_line) - { + for (int i = 0; i < 3; ++i) { + if (this.edge_lines[i] == p_edge_line) { edge_line_no = i; break; } } - if (edge_line_no < 0) - { + if (edge_line_no < 0) { System.out.println("Triangle.opposite_corner: p_edge_line not found"); return null; } - Edge next_edge = this.edge_lines[(edge_line_no + 1)% 3]; + Edge next_edge = this.edge_lines[(edge_line_no + 1) % 3]; Corner result; - if (next_edge.left_triangle == this) - { + if (next_edge.left_triangle == this) { result = next_edge.end_corner; - } - else - { + } else { result = next_edge.start_corner; } return result; } - + /** * Checks if p_point is inside or on the border of this triangle. */ - public boolean contains(Corner p_corner) - { - if (this.is_on_the_left_of_edge_line == null) - { + public boolean contains(Corner p_corner) { + if (this.is_on_the_left_of_edge_line == null) { System.out.println("Triangle.contains: array is_on_the_left_of_edge_line not initialized"); return false; } - for (int i = 0; i < 3; ++i) - { + for (int i = 0; i < 3; ++i) { Edge curr_edge = this.edge_lines[i]; Side curr_side = p_corner.side_of(curr_edge.start_corner, curr_edge.end_corner); if (this.is_on_the_left_of_edge_line[i]) - // checking curr_edge.left_triangle == this instead will not work, if this triangle is an inner node. + // checking curr_edge.left_triangle == this instead will not work, if this triangle is an inner node. { - if (curr_side == Side.ON_THE_RIGHT) - { + if (curr_side == Side.ON_THE_RIGHT) { return false; } - } - else - { - if (curr_side == Side.ON_THE_LEFT) - { + } else { + if (curr_side == Side.ON_THE_LEFT) { return false; } } } return true; } - + /** * Puts the edges of all leafs below this node into the list p_result_edges */ - public void get_leaf_edges(Set p_result_edges) - { - if (this.is_leaf()) - { - for (int i = 0; i < 3; ++i) - { + public void get_leaf_edges(Set p_result_edges) { + if (this.is_leaf()) { + for (int i = 0; i < 3; ++i) { Edge curr_edge = this.edge_lines[i]; - if (curr_edge.start_corner.object != null && curr_edge.end_corner.object != null) - { + if (curr_edge.start_corner.object != null && curr_edge.end_corner.object != null) { // Skip edges containing a bounding corner. p_result_edges.add(curr_edge); } } - - } - else - { - for (Triangle curr_child : this.children) - { + + } else { + for (Triangle curr_child : this.children) { if (curr_child.first_parent == this) // to prevent traversing nodes more than once { curr_child.get_leaf_edges(p_result_edges); @@ -815,72 +773,67 @@ public void get_leaf_edges(Set p_result_edges) } } } - - /** Split this triangle into 3 new triangles by adding edges from + + /** + * Split this triangle into 3 new triangles by adding edges from * the corners of this triangle to p_corner, * p_corner has to be located in the interiour of this triangle. */ - - public Triangle[] split_at_inner_point(Corner p_corner) - { - Triangle [] new_triangles = new Triangle[3]; - + + public Triangle[] split_at_inner_point(Corner p_corner) { + Triangle[] new_triangles = new Triangle[3]; + Edge[] new_edges = new Edge[3]; - for (int i = 0; i < 3; ++i) - { + for (int i = 0; i < 3; ++i) { new_edges[i] = new Edge(this.get_corner(i), p_corner); } - + // construct the 3 new triangles. - Edge [] curr_edge_lines = new Edge[3]; - + Edge[] curr_edge_lines = new Edge[3]; + curr_edge_lines[0] = this.edge_lines[0]; curr_edge_lines[1] = new Edge(this.get_corner(1), p_corner); curr_edge_lines[2] = new Edge(p_corner, this.get_corner(0)); new_triangles[0] = new Triangle(curr_edge_lines, this); - + curr_edge_lines = new Edge[3]; curr_edge_lines[0] = this.edge_lines[1]; curr_edge_lines[1] = new Edge(this.get_corner(2), p_corner); curr_edge_lines[2] = new_triangles[0].edge_lines[1]; new_triangles[1] = new Triangle(curr_edge_lines, this); - + curr_edge_lines = new Edge[3]; curr_edge_lines[0] = this.edge_lines[2]; curr_edge_lines[1] = new_triangles[0].edge_lines[2]; curr_edge_lines[2] = new_triangles[1].edge_lines[1]; new_triangles[2] = new Triangle(curr_edge_lines, this); - + // Set the new neigbour triangles of the edge lines. - - for(int i = 0; i < 3; ++i) - { + + for (int i = 0; i < 3; ++i) { Edge curr_edge = new_triangles[i].edge_lines[0]; - if (curr_edge.get_left_triangle() == this) - { + if (curr_edge.get_left_triangle() == this) { curr_edge.set_left_triangle(new_triangles[i]); - } - else - { + } else { curr_edge.set_right_triangle(new_triangles[i]); } // The other neighbour triangle remains valid. } - + Edge curr_edge = new_triangles[0].edge_lines[1]; curr_edge.set_left_triangle(new_triangles[0]); curr_edge.set_right_triangle(new_triangles[1]); - + curr_edge = new_triangles[1].edge_lines[1]; curr_edge.set_left_triangle(new_triangles[1]); curr_edge.set_right_triangle(new_triangles[2]); - + curr_edge = new_triangles[2].edge_lines[1]; curr_edge.set_left_triangle(new_triangles[0]); curr_edge.set_right_triangle(new_triangles[2]); return new_triangles; } - + /** * Split this triangle and p_neighbour_to_split into 4 new triangles by adding edges from * the corners of the triangles to p_corner. @@ -889,67 +842,55 @@ public Triangle[] split_at_inner_point(Corner p_corner) * The first 2 result triangles are from splitting this triangle, * and the last 2 result triangles are from splitting p_neighbour_to_split. */ - public Triangle[] split_at_border_point(Corner p_corner, Triangle p_neighbour_to_split) - { + public Triangle[] split_at_border_point(Corner p_corner, Triangle p_neighbour_to_split) { Triangle[] new_triangles = new Triangle[4]; // look for the triangle edge of this and the neighbour triangle containing p_point; int this_touching_edge_no = -1; int neigbbour_touching_edge_no = -1; Edge touching_edge = null; Edge other_touching_edge = null; - for (int i = 0; i < 3; ++i) - { + for (int i = 0; i < 3; ++i) { Edge curr_edge = this.edge_lines[i]; - if (p_corner.side_of(curr_edge.start_corner, curr_edge.end_corner) == Side.COLLINEAR) - { + if (p_corner.side_of(curr_edge.start_corner, curr_edge.end_corner) == Side.COLLINEAR) { this_touching_edge_no = i; touching_edge = curr_edge; } curr_edge = p_neighbour_to_split.edge_lines[i]; - if (p_corner.side_of(curr_edge.start_corner, curr_edge.end_corner) == Side.COLLINEAR) - { + if (p_corner.side_of(curr_edge.start_corner, curr_edge.end_corner) == Side.COLLINEAR) { neigbbour_touching_edge_no = i; other_touching_edge = curr_edge; } } - if (this_touching_edge_no < 0 || neigbbour_touching_edge_no < 0) - { + if (this_touching_edge_no < 0 || neigbbour_touching_edge_no < 0) { System.out.println("Triangle.split_at_border_point: touching edge not found"); return null; } - if (touching_edge != other_touching_edge) - { + if (touching_edge != other_touching_edge) { System.out.println("Triangle.split_at_border_point: edges inconsistent"); return null; } - + Edge first_common_new_edge; Edge second_common_new_edge; // Construct the new edge lines that 2 split triangles of this triangle // will be on the left side of the new common touching edges. - if (this == touching_edge.left_triangle) - { + if (this == touching_edge.left_triangle) { first_common_new_edge = new Edge(touching_edge.start_corner, p_corner); second_common_new_edge = new Edge(p_corner, touching_edge.end_corner); - } - else - { + } else { first_common_new_edge = new Edge(touching_edge.end_corner, p_corner); - second_common_new_edge = new Edge( p_corner, touching_edge.start_corner); + second_common_new_edge = new Edge(p_corner, touching_edge.start_corner); } - + // Construct the first split triangle of this triangle. - + Edge prev_edge = this.edge_lines[(this_touching_edge_no + 2) % 3]; Edge this_splitting_edge; // construct the splitting edge line of this triangle, so that the first split // triangle lies on the left side, and the second split triangle on the right side. - if (this == prev_edge.left_triangle) - { + if (this == prev_edge.left_triangle) { this_splitting_edge = new Edge(p_corner, prev_edge.start_corner); - } - else - { + } else { this_splitting_edge = new Edge(p_corner, prev_edge.end_corner); } Edge[] curr_edge_lines = new Edge[3]; @@ -957,19 +898,16 @@ public Triangle[] split_at_border_point(Corner p_corner, Triangle p_neighbour_to curr_edge_lines[1] = first_common_new_edge; curr_edge_lines[2] = this_splitting_edge; new_triangles[0] = new Triangle(curr_edge_lines, this); - if (this == prev_edge.left_triangle) - { + if (this == prev_edge.left_triangle) { prev_edge.set_left_triangle(new_triangles[0]); - } - else - { + } else { prev_edge.set_right_triangle(new_triangles[0]); } first_common_new_edge.set_left_triangle(new_triangles[0]); this_splitting_edge.set_left_triangle(new_triangles[0]); - + // Construct the second split triangle of this triangle. - + Edge next_edge = this.edge_lines[(this_touching_edge_no + 1) % 3]; curr_edge_lines = new Edge[3]; curr_edge_lines[0] = this_splitting_edge; @@ -978,26 +916,20 @@ public Triangle[] split_at_border_point(Corner p_corner, Triangle p_neighbour_to new_triangles[1] = new Triangle(curr_edge_lines, this); this_splitting_edge.set_right_triangle(new_triangles[1]); second_common_new_edge.set_left_triangle(new_triangles[1]); - if (this == next_edge.left_triangle) - { + if (this == next_edge.left_triangle) { next_edge.set_left_triangle(new_triangles[1]); - } - else - { + } else { next_edge.set_right_triangle(new_triangles[1]); } - + // construct the first split triangle of p_neighbour_to_split next_edge = p_neighbour_to_split.edge_lines[(neigbbour_touching_edge_no + 1) % 3]; Edge neighbour_splitting_edge; // construct the splitting edge line of p_neighbour_to_split, so that the first split // triangle lies on the left side, and the second split triangle on the right side. - if (p_neighbour_to_split == next_edge.left_triangle) - { + if (p_neighbour_to_split == next_edge.left_triangle) { neighbour_splitting_edge = new Edge(next_edge.end_corner, p_corner); - } - else - { + } else { neighbour_splitting_edge = new Edge(next_edge.start_corner, p_corner); } curr_edge_lines = new Edge[3]; @@ -1007,16 +939,13 @@ public Triangle[] split_at_border_point(Corner p_corner, Triangle p_neighbour_to new_triangles[2] = new Triangle(curr_edge_lines, p_neighbour_to_split); neighbour_splitting_edge.set_left_triangle(new_triangles[2]); first_common_new_edge.set_right_triangle(new_triangles[2]); - if (p_neighbour_to_split == next_edge.left_triangle) - { + if (p_neighbour_to_split == next_edge.left_triangle) { next_edge.set_left_triangle(new_triangles[2]); - } - else - { + } else { next_edge.set_right_triangle(new_triangles[2]); - + } - + // construct the second split triangle of p_neighbour_to_split prev_edge = p_neighbour_to_split.edge_lines[(neigbbour_touching_edge_no + 2) % 3]; curr_edge_lines = new Edge[3]; @@ -1024,74 +953,55 @@ public Triangle[] split_at_border_point(Corner p_corner, Triangle p_neighbour_to curr_edge_lines[1] = second_common_new_edge; curr_edge_lines[2] = neighbour_splitting_edge; new_triangles[3] = new Triangle(curr_edge_lines, p_neighbour_to_split); - if (p_neighbour_to_split == prev_edge.left_triangle) - { + if (p_neighbour_to_split == prev_edge.left_triangle) { prev_edge.set_left_triangle(new_triangles[3]); - } - else - { + } else { prev_edge.set_right_triangle(new_triangles[3]); - + } second_common_new_edge.set_right_triangle(new_triangles[3]); neighbour_splitting_edge.set_right_triangle(new_triangles[3]); - + return new_triangles; } - + /** * Checks the consistancy of this triangle and its children. * Used for debugging purposes. */ - public boolean validate() - { + public boolean validate() { boolean result = true; - if (this.is_leaf()) - { + if (this.is_leaf()) { Edge prev_edge = this.edge_lines[2]; - for (int i = 0; i < 3; ++i) - { + for (int i = 0; i < 3; ++i) { Edge curr_edge = this.edge_lines[i]; - if (!curr_edge.validate()) - { + if (!curr_edge.validate()) { result = false; } // Check, if the ens corner of the previous line equals to the start corner of this line. Corner prev_end_corner; - if (prev_edge.left_triangle == this) - { + if (prev_edge.left_triangle == this) { prev_end_corner = prev_edge.end_corner; - } - else - { + } else { prev_end_corner = prev_edge.start_corner; } Corner curr_start_corner; - if (curr_edge.left_triangle == this) - { + if (curr_edge.left_triangle == this) { curr_start_corner = curr_edge.start_corner; - } - else if (curr_edge.right_triangle == this) - { + } else if (curr_edge.right_triangle == this) { curr_start_corner = curr_edge.end_corner; - } - else - { + } else { System.out.println("Triangle.validate: edge inconsistent"); return false; } - if (curr_start_corner != prev_end_corner) - { + if (curr_start_corner != prev_end_corner) { System.out.println("Triangle.validate: corner inconsistent"); result = false; } prev_edge = curr_edge; } - } - else - { - for (Triangle curr_child: this.children) - { + } else { + for (Triangle curr_child : this.children) { if (curr_child.first_parent == this) // to avoid traversing nodes more than once. { curr_child.validate(); @@ -1100,131 +1010,19 @@ else if (curr_edge.right_triangle == this) } return result; } - + /** * Must be done as long as this triangle node is a leaf and after for all its edge lines * the left_triangle or the right_triangle reference is set to this triangle. */ - private void initialize_is_on_the_left_of_edge_line_array() - { - if (this.is_on_the_left_of_edge_line != null) - { + private void initialize_is_on_the_left_of_edge_line_array() { + if (this.is_on_the_left_of_edge_line != null) { return; // already initialized } this.is_on_the_left_of_edge_line = new boolean[3]; - for (int i = 0; i < 3; ++i) - { + for (int i = 0; i < 3; ++i) { this.is_on_the_left_of_edge_line[i] = (this.edge_lines[i].left_triangle == this); } } - - /** The 3 edge lines of this triangle sorted in counter clock sense around the border. */ - private final Edge[] edge_lines; - - /** - * Indicates, if this triangle is on the left of the i-th edge line for i = 0 to 2. - * Must be set, if this triagngle is an inner node - * because left_triangle and right_triangle of edge lines point only to leaf nodes. - */ - private boolean[] is_on_the_left_of_edge_line = null; - - /** The children of this triangle when used as a node in the triangle search graph. */ - private Collection children; - - /** - * Triangles resulting from an edge flip have 2 parents, all other triangles have 1 parent. - * first parent is used when traversing the graph sequentially to avoid - * visiting children nodes more than once. - */ - private final Triangle first_parent; - } - - /** - * Directed acyclic graph for finding the triangle containing a search point p. - * The leaves contain the trianngles of the current triangulation. - * The internal nodes are triangles, that were part of the triangulationn at some earlier stage, - * but have been replaced their children. - */ - - private static class TriangleGraph - { - public TriangleGraph(Triangle p_triangle) - { - if (p_triangle != null) - { - insert(p_triangle, null); - } - else - { - this.anchor = null; - } - } - - public void insert(Triangle p_triangle, Triangle p_parent) - { - p_triangle.initialize_is_on_the_left_of_edge_line_array(); - if (p_parent == null) - { - anchor = p_triangle; - } - else - { - p_parent.children.add(p_triangle); - } - } - - /** - * Search for the leaf triangle containing p_corner. - * It will not be unique, if p_corner lies on a triangle edge. - */ - public Triangle position_locate(Corner p_corner) - { - if (this.anchor == null) - { - return null; - } - if (this.anchor.children.isEmpty()) - { - return this.anchor; - } - for (Triangle curr_child : this.anchor.children) - { - Triangle result = position_locate_reku(p_corner, curr_child); - if (result != null) - { - return result; - } - } - System.out.println("TriangleGraph.position_locate: containing triangle not found"); - return null; - } - - /** - * Recursive part of position_locate. - */ - private Triangle position_locate_reku(Corner p_corner, Triangle p_triangle) - { - if (!p_triangle.contains(p_corner)) - { - return null; - } - - if (p_triangle.is_leaf()) - { - return p_triangle; - } - for (Triangle curr_child : p_triangle.children) - { - Triangle result = position_locate_reku(p_corner, curr_child); - if (result != null) - { - return result; - } - } - System.out.println("TriangleGraph.position_locate_reku: containing triangle not found"); - return null; - } - - private Triangle anchor = null; } } diff --git a/src/main/java/net/freerouting/datastructures/ShapeTree.java b/src/main/java/net/freerouting/datastructures/ShapeTree.java index 1537fa2d..17ec6f70 100644 --- a/src/main/java/net/freerouting/datastructures/ShapeTree.java +++ b/src/main/java/net/freerouting/datastructures/ShapeTree.java @@ -20,9 +20,9 @@ package net.freerouting.datastructures; -import net.freerouting.geometry.planar.ShapeBoundingDirections; import net.freerouting.geometry.planar.RegularTileShape; import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.ShapeBoundingDirections; import net.freerouting.geometry.planar.TileShape; /** @@ -30,136 +30,133 @@ * The shapes are stored in the leafs of the tree. * Objects to be stored in the tree must implement the interface ShapeTree.Storable. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public abstract class ShapeTree -{ - - /** Creates a new instance of ShapeTree */ - public ShapeTree(ShapeBoundingDirections p_directions) - { - bounding_directions = p_directions ; - root = null ; +public abstract class ShapeTree { + + /** + * the fixed directions for calculating bounding RegularTileShapes + * of shapes to store in this tree. + */ + final protected ShapeBoundingDirections bounding_directions; + /** + * Root node - initially null + */ + protected TreeNode root; + /** + * The number of entries stored in the tree + */ + protected int leaf_count; + + + /** + * Creates a new instance of ShapeTree + */ + public ShapeTree(ShapeBoundingDirections p_directions) { + bounding_directions = p_directions; + root = null; leaf_count = 0; } - - + /** * Inserts all shapes of p_obj into the tree */ - public void insert(ShapeTree.Storable p_obj) - { + public void insert(ShapeTree.Storable p_obj) { int shape_count = p_obj.tree_shape_count(this); - if (shape_count <= 0) - { + if (shape_count <= 0) { return; } - Leaf [] leaf_arr = new Leaf [shape_count]; - for (int i = 0; i < shape_count; ++i) - { - leaf_arr [i] = insert(p_obj, i); + Leaf[] leaf_arr = new Leaf[shape_count]; + for (int i = 0; i < shape_count; ++i) { + leaf_arr[i] = insert(p_obj, i); } p_obj.set_search_tree_entries(leaf_arr, this); } - + /** * Insert a shape - creates a new node with a bounding shape */ - protected Leaf insert(ShapeTree.Storable p_object, int p_index) - { + protected Leaf insert(ShapeTree.Storable p_object, int p_index) { Shape object_shape = p_object.get_tree_shape(this, p_index); - if (object_shape == null) - { + if (object_shape == null) { return null; } - - RegularTileShape bounding_shape = object_shape.bounding_shape(bounding_directions) ; - if ( bounding_shape == null ) - { + + RegularTileShape bounding_shape = object_shape.bounding_shape(bounding_directions); + if (bounding_shape == null) { System.out.println("ShapeTree.insert: bounding shape of TreeObject is null"); return null; } // Construct a new KdLeaf and set it up - Leaf new_leaf = new Leaf(p_object, p_index, null, bounding_shape) ; + Leaf new_leaf = new Leaf(p_object, p_index, null, bounding_shape); this.insert(new_leaf); return new_leaf; } - - - /** Inserts the leaves of this tree into an array. */ - public Leaf[] to_array() - { - Leaf [] result = new Leaf[this.leaf_count]; - if (result.length == 0) - { + + /** + * Inserts the leaves of this tree into an array. + */ + public Leaf[] to_array() { + Leaf[] result = new Leaf[this.leaf_count]; + if (result.length == 0) { return result; } TreeNode curr_node = this.root; int curr_index = 0; - for (;;) - { + for (; ; ) { // go down from curr_node to the left most leaf - while (curr_node instanceof InnerNode) - { + while (curr_node instanceof InnerNode) { curr_node = ((InnerNode) curr_node).first_child; } result[curr_index] = (Leaf) curr_node; - + ++curr_index; // go up until parent.second_child != curr_node, which means we came from first_child InnerNode curr_parent = curr_node.parent; - while (curr_parent != null && curr_parent.second_child == curr_node) - { + while (curr_parent != null && curr_parent.second_child == curr_node) { curr_node = curr_parent; curr_parent = curr_node.parent; } - if (curr_parent == null) - { + if (curr_parent == null) { break; } curr_node = curr_parent.second_child; } return result; } - + abstract void insert(Leaf p_leaf); - + abstract void remove_leaf(Leaf p_leaf); - - - + /** * removes all entries of p_obj in the tree. */ - public void remove(Leaf [] p_entries) - { - if (p_entries == null) - { + public void remove(Leaf[] p_entries) { + if (p_entries == null) { return; } - for (int i = 0; i < p_entries.length; ++i) - { + for (int i = 0; i < p_entries.length; ++i) { remove_leaf(p_entries[i]); } } - - /** Returns the number of entries stored in the tree. */ - public int size() - { + + /** + * Returns the number of entries stored in the tree. + */ + public int size() { return leaf_count; } - - - /** Outputs some statistic information about the tree. */ - public void statistics(String p_message) - { + + /** + * Outputs some statistic information about the tree. + */ + public void statistics(String p_message) { Leaf[] leaf_arr = this.to_array(); double cumulative_depth = 0; int maximum_depth = 0; - for (int i = 0; i < leaf_arr.length; ++ i) - { - if (leaf_arr[i] != null) - { + for (int i = 0; i < leaf_arr.length; ++i) { + if (leaf_arr[i] != null) { int distance_to_root = leaf_arr[i].distance_to_root(); cumulative_depth += distance_to_root; maximum_depth = Math.max(maximum_depth, distance_to_root); @@ -178,127 +175,111 @@ public void statistics(String p_message) System.out.print(" "); System.out.println(p_message); } - - - /** - * the fixed directions for calculating bounding RegularTileShapes - * of shapes to store in this tree. - */ - final protected ShapeBoundingDirections bounding_directions ; - - /** Root node - initially null */ - protected TreeNode root ; - - /** The number of entries stored in the tree */ - protected int leaf_count; - + /** * Interface, which must be implemented by objects to be stored * in a ShapeTree. */ - public interface Storable extends Comparable - { + public interface Storable extends Comparable { /** * Number of shapes of an object to store in p_shape_tree */ - int tree_shape_count(ShapeTree p_shape_tree) ; - + int tree_shape_count(ShapeTree p_shape_tree); + /** * Get the Shape of this object with index p_index stored in the ShapeTree with index identification number p_tree_id_no */ - TileShape get_tree_shape(ShapeTree p_tree, int p_index) ; - + TileShape get_tree_shape(ShapeTree p_tree, int p_index); + /** * Stores the entries in the ShapeTrees of this object for * better performance while for example deleting tree entries. * Called only by insert methods of class ShapeTree. */ - void set_search_tree_entries(Leaf [] p_entries, ShapeTree p_tree); + void set_search_tree_entries(Leaf[] p_entries, ShapeTree p_tree); } - + /** * Information of a single object stored in a tree */ - public static class TreeEntry - { - public TreeEntry(ShapeTree.Storable p_object, int p_shape_index_in_object) - { + public static class TreeEntry { + public final ShapeTree.Storable object; + public final int shape_index_in_object; + public TreeEntry(ShapeTree.Storable p_object, int p_shape_index_in_object) { object = p_object; shape_index_in_object = p_shape_index_in_object; } - public final ShapeTree.Storable object; - public final int shape_index_in_object; } - + ////////////////////////////////////////////////////////// - /** Common functionality of inner nodes and leaf nodes. */ - protected static class TreeNode - { - public RegularTileShape bounding_shape ; + + /** + * Common functionality of inner nodes and leaf nodes. + */ + protected static class TreeNode { + public RegularTileShape bounding_shape; InnerNode parent; } - + ////////////////////////////////////////////////////////// + /** * Desscription of an inner node of the tree, * which implements a fork to its two children. */ - public static class InnerNode extends TreeNode - { - public InnerNode( RegularTileShape p_bounding_shape, InnerNode p_parent ) - { + public static class InnerNode extends TreeNode { + public TreeNode first_child; + public TreeNode second_child; + public InnerNode(RegularTileShape p_bounding_shape, InnerNode p_parent) { bounding_shape = p_bounding_shape; parent = p_parent; - first_child = null ; - second_child = null ; + first_child = null; + second_child = null; } - - public TreeNode first_child ; - public TreeNode second_child ; } - + ////////////////////////////////////////////////////////// + /** * Description of a leaf of the Tree, where the geometric * information is stored. */ - public static class Leaf extends TreeNode implements Comparable - { - public Leaf( ShapeTree.Storable p_object, int p_index, InnerNode p_parent, RegularTileShape p_bounding_shape) - { + public static class Leaf extends TreeNode implements Comparable { + /** + * Actual object stored + */ + public ShapeTree.Storable object; + /** + * index of the shape in the object + */ + public int shape_index_in_object; + + public Leaf(ShapeTree.Storable p_object, int p_index, InnerNode p_parent, RegularTileShape p_bounding_shape) { bounding_shape = p_bounding_shape; parent = p_parent; - object = p_object ; - shape_index_in_object = p_index ; + object = p_object; + shape_index_in_object = p_index; } - - public int compareTo(Leaf p_other) - { + + public int compareTo(Leaf p_other) { int result = this.object.compareTo(p_other.object); - if (result == 0) - { - result = shape_index_in_object - p_other.shape_index_in_object; + if (result == 0) { + result = shape_index_in_object - p_other.shape_index_in_object; } return result; } - - /** Returns the number of nodes between this leaf and the croot of the tree. */ - public int distance_to_root() - { + + /** + * Returns the number of nodes between this leaf and the croot of the tree. + */ + public int distance_to_root() { int result = 1; InnerNode curr_parent = this.parent; - while (curr_parent.parent != null) - { + while (curr_parent.parent != null) { curr_parent = curr_parent.parent; ++result; } return result; } - - /** Actual object stored */ - public ShapeTree.Storable object ; - - /** index of the shape in the object */ - public int shape_index_in_object; } } diff --git a/src/main/java/net/freerouting/datastructures/Signum.java b/src/main/java/net/freerouting/datastructures/Signum.java index b3ab7b9b..64b59ee8 100644 --- a/src/main/java/net/freerouting/datastructures/Signum.java +++ b/src/main/java/net/freerouting/datastructures/Signum.java @@ -17,37 +17,33 @@ package net.freerouting.datastructures; /** - * * Implements the mathematical signum function. * - * @author Alfons Wirtz */ -public class Signum -{ - public static final Signum POSITIVE = new Signum ("positive"); - public static final Signum NEGATIVE = new Signum ("negative"); - public static final Signum ZERO = new Signum ("zero"); +public class Signum { + public static final Signum POSITIVE = new Signum("positive"); + public static final Signum NEGATIVE = new Signum("negative"); + public static final Signum ZERO = new Signum("zero"); + private final String name; + + private Signum(String p_name) { + name = p_name; + } /** * Returns the signum of p_value. * Values are Signum.POSITIVE, Signum.NEGATIVE and Signum.ZERO */ - public static final Signum of (double p_value) - { + public static final Signum of(double p_value) { Signum result; - if (p_value > 0) - { + if (p_value > 0) { result = POSITIVE; - } - else if (p_value < 0) - { + } else if (p_value < 0) { result = NEGATIVE; - } - else - { + } else { result = ZERO; } return result; @@ -57,20 +53,14 @@ else if (p_value < 0) * Returns the signum of p_value as an int. * Values are +1, 0 and -1 */ - public static final int as_int (double p_value) - { + public static final int as_int(double p_value) { int result; - if (p_value > 0) - { + if (p_value > 0) { result = 1; - } - else if (p_value < 0) - { + } else if (p_value < 0) { result = -1; - } - else - { + } else { result = 0; } return result; @@ -79,37 +69,22 @@ else if (p_value < 0) /** * Returns the string of this instance */ - public String to_string () - { + public String to_string() { return name; } /** * Returns the opposite Signum of this Signum */ - public final Signum negate() - { + public final Signum negate() { Signum result; - if (this == POSITIVE) - { + if (this == POSITIVE) { result = NEGATIVE; - } - else if (this == NEGATIVE) - { + } else if (this == NEGATIVE) { result = POSITIVE; - } - else - { + } else { result = this; } return result; } - - - private Signum(String p_name) - { - name = p_name; - } - - private final String name; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/datastructures/Stoppable.java b/src/main/java/net/freerouting/datastructures/Stoppable.java index 00b9e2d7..23f14c20 100644 --- a/src/main/java/net/freerouting/datastructures/Stoppable.java +++ b/src/main/java/net/freerouting/datastructures/Stoppable.java @@ -26,13 +26,12 @@ * * @author alfons */ -public interface Stoppable -{ +public interface Stoppable { /** * Requests this thread to be stopped. */ void request_stop(); - + /** * Returns true, if this thread is requested to be stopped. */ diff --git a/src/main/java/net/freerouting/datastructures/TimeLimit.java b/src/main/java/net/freerouting/datastructures/TimeLimit.java index eecccebb..5eae8d91 100644 --- a/src/main/java/net/freerouting/datastructures/TimeLimit.java +++ b/src/main/java/net/freerouting/datastructures/TimeLimit.java @@ -23,43 +23,39 @@ /** * Class used to cancel a performance critical algorithm after a time limit is exceeded. + * * @author Alfons Wirtz */ -public class TimeLimit -{ - +public class TimeLimit { + + private final long time_stamp; + private int time_limit; + /** * Creates a new instance with a time limit of p_milli_seconds milli seconds */ - public TimeLimit(int p_milli_seconds) - { + public TimeLimit(int p_milli_seconds) { this.time_limit = p_milli_seconds; this.time_stamp = (new java.util.Date()).getTime(); } - + /** * Returns true, if the time limit provided in the constructor of this class is exceeded. */ - public boolean limit_exceeded() - { + public boolean limit_exceeded() { long curr_time = (new java.util.Date()).getTime(); return (curr_time - this.time_stamp > this.time_limit); } - + /** * Multiplies this TimeLimit by p_factor. */ - public void muultiply(double p_factor) - { - if (p_factor <= 0) - { + public void muultiply(double p_factor) { + if (p_factor <= 0) { return; } double new_limit = (p_factor * this.time_limit); new_limit = Math.min(new_limit, Integer.MAX_VALUE); this.time_limit = (int) new_limit; } - - private final long time_stamp; - private int time_limit; } diff --git a/src/main/java/net/freerouting/datastructures/UndoableObjects.java b/src/main/java/net/freerouting/datastructures/UndoableObjects.java index f86aab12..4e7aeba2 100644 --- a/src/main/java/net/freerouting/datastructures/UndoableObjects.java +++ b/src/main/java/net/freerouting/datastructures/UndoableObjects.java @@ -22,22 +22,37 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import java.util.concurrent.ConcurrentSkipListMap; -import java.util.concurrent.ConcurrentMap; import java.util.Vector; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentSkipListMap; /** * Database of objects, for which Undo and Redo operations are made possible. * The algorithm works only for objects containing no references. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class UndoableObjects implements java.io.Serializable -{ +public class UndoableObjects implements java.io.Serializable { + + /** + * The entries of this map are of type UnduableObject, the keys of type UndoableObjects.Storable. + */ + private ConcurrentMap objects; + /** + * the current undo level + */ + private int stack_level; + /** + * the lists of deleted objects on each undo level, which where already + * existing before the previous snapshot. + */ + private Vector> deleted_objects_stack; + private boolean redo_possible = false; - /** Creates a new instance of UndoableObjectsList */ - public UndoableObjects() - { + /** + * Creates a new instance of UndoableObjectsList + */ + public UndoableObjects() { stack_level = 0; objects = new ConcurrentSkipListMap(); deleted_objects_stack = new Vector>(); @@ -47,8 +62,7 @@ public UndoableObjects() * Returns an iterator for sequential reading of the object list. * Use it together with this.read_object(). */ - public Iterator start_read_object() - { + public Iterator start_read_object() { Collection object_list = objects.values(); return object_list.iterator(); } @@ -58,14 +72,11 @@ public Iterator start_read_object() * Returns null, if the list is exhausted. * p_it must be created by start_read_object. */ - public UndoableObjects.Storable read_object(Iterator p_it) - { - while (p_it.hasNext()) - { + public UndoableObjects.Storable read_object(Iterator p_it) { + while (p_it.hasNext()) { UndoableObjectNode curr_node = p_it.next(); // skip objects getting alive only by redo - if (curr_node != null && curr_node.level <= this.stack_level) - { + if (curr_node != null && curr_node.level <= this.stack_level) { return (curr_node.object); } } @@ -75,8 +86,7 @@ public UndoableObjects.Storable read_object(Iterator p_it) /** * Adds p_object to the UndoableObjectsList. */ - public void insert(UndoableObjects.Storable p_object) - { + public void insert(UndoableObjects.Storable p_object) { disable_redo(); UndoableObjectNode curr_undoable_object = new UndoableObjectNode(p_object, stack_level); objects.put(p_object, curr_undoable_object); @@ -86,40 +96,30 @@ public void insert(UndoableObjects.Storable p_object) * Removes p_object from the top level of the UndoableObjectsList. * Returns false, if p_object was not found in the list. */ - public boolean delete(UndoableObjects.Storable p_object) - { + public boolean delete(UndoableObjects.Storable p_object) { disable_redo(); Collection curr_delete_list; - if (deleted_objects_stack.isEmpty()) - { + if (deleted_objects_stack.isEmpty()) { // stack_level 0 curr_delete_list = null; - } - else - { + } else { curr_delete_list = deleted_objects_stack.lastElement(); } // search p_object in the list UndoableObjectNode object_node = objects.get(p_object); - if (object_node == null) - { + if (object_node == null) { return false; } - if (object_node.object != p_object) - { + if (object_node.object != p_object) { System.out.println("UndoableObjectList.delete: Object inconsistent"); return false; } - if (curr_delete_list != null) - { - if (object_node.level < this.stack_level) - { + if (curr_delete_list != null) { + if (object_node.level < this.stack_level) { // add curr_ob to the current delete list to make Undo possible. curr_delete_list.add(object_node); - } - else if (object_node.undo_object != null) - { + } else if (object_node.undo_object != null) { // add curr_ob.undo_object to the current delete list to make Undo possible. curr_delete_list.add(object_node.undo_object); @@ -132,8 +132,7 @@ else if (object_node.undo_object != null) /** * Makes the current state of the list restorable by Undo. */ - public void generate_snapshot() - { + public void generate_snapshot() { disable_redo(); Collection curr_deleted_objects_list = new LinkedList(); deleted_objects_stack.add(curr_deleted_objects_list); @@ -146,30 +145,23 @@ public void generate_snapshot() * the calling function to take additional actions needed for these objects. * Returns false, if no more undo is possible */ - public boolean undo(Collection p_cancelled_objects, Collection p_restored_objects) - { - if (stack_level == 0) - { + public boolean undo(Collection p_cancelled_objects, Collection p_restored_objects) { + if (stack_level == 0) { return false; // no more undo possible } Iterator it = objects.values().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { UndoableObjectNode curr_node = it.next(); - if (curr_node.level == stack_level) - { - if (curr_node.undo_object != null) - { + if (curr_node.level == stack_level) { + if (curr_node.undo_object != null) { // replace the current object by its previous state. curr_node.undo_object.redo_object = curr_node; objects.put(curr_node.object, curr_node.undo_object); - if (p_restored_objects != null) - { + if (p_restored_objects != null) { p_restored_objects.add(curr_node.undo_object.object); } } - if (p_cancelled_objects != null) - { + if (p_cancelled_objects != null) { p_cancelled_objects.add(curr_node.object); } } @@ -177,12 +169,10 @@ public boolean undo(Collection p_cancelled_objects, Co // restore the deleted objects Collection curr_delete_list = deleted_objects_stack.elementAt(stack_level - 1); Iterator it2 = curr_delete_list.iterator(); - while (it2.hasNext()) - { + while (it2.hasNext()) { UndoableObjectNode curr_deleted_node = it2.next(); this.objects.put(curr_deleted_node.object, curr_deleted_node); - if (p_restored_objects != null) - { + if (p_restored_objects != null) { p_restored_objects.add(curr_deleted_node.object); } } @@ -197,34 +187,26 @@ public boolean undo(Collection p_cancelled_objects, Co * the calling function to take additional actions needed for these objects. * Returns false, if no more redo is possible. */ - public boolean redo(Collection p_cancelled_objects, Collection p_restored_objects) - { - if (this.stack_level >= deleted_objects_stack.size()) - { + public boolean redo(Collection p_cancelled_objects, Collection p_restored_objects) { + if (this.stack_level >= deleted_objects_stack.size()) { return false; // alredy at the top level } ++this.stack_level; Iterator it = objects.values().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { UndoableObjectNode curr_node = it.next(); - if (curr_node.redo_object != null && curr_node.redo_object.level == this.stack_level) - { + if (curr_node.redo_object != null && curr_node.redo_object.level == this.stack_level) { // Object was created on a lower level and changed on the currenzt level, // replace the lower level object by the object on the current layer. objects.put(curr_node.object, curr_node.redo_object); - if (p_cancelled_objects != null) - { + if (p_cancelled_objects != null) { p_cancelled_objects.add(curr_node.object); } - if (p_restored_objects != null) - { + if (p_restored_objects != null) { p_restored_objects.add(curr_node.redo_object.object); - // else the redo_object was deleted on the redo level + // else the redo_object was deleted on the redo level } - } - else if (curr_node.level == this.stack_level) - { + } else if (curr_node.level == this.stack_level) { // Object was created on the current level, allow it to be restored. p_restored_objects.add(curr_node.object); } @@ -232,23 +214,18 @@ else if (curr_node.level == this.stack_level) // Delete the objects, which were deleted on the current level, again. Collection curr_delete_list = deleted_objects_stack.elementAt(stack_level - 1); Iterator it2 = curr_delete_list.iterator(); - while (it2.hasNext()) - { + while (it2.hasNext()) { UndoableObjectNode curr_deleted_node = it2.next(); while (curr_deleted_node.redo_object != null && - curr_deleted_node.redo_object.level <= this.stack_level) - { + curr_deleted_node.redo_object.level <= this.stack_level) { curr_deleted_node = curr_deleted_node.redo_object; } - if (this.objects.remove(curr_deleted_node.object) == null) - { + if (this.objects.remove(curr_deleted_node.object) == null) { System.out.println("previous deleted object not found"); } - if (p_restored_objects == null || !p_restored_objects.remove(curr_deleted_node.object)) - { + if (p_restored_objects == null || !p_restored_objects.remove(curr_deleted_node.object)) { // the object needs only be cancelled if it is already in the board - if (p_cancelled_objects != null) - { + if (p_cancelled_objects != null) { p_cancelled_objects.add(curr_deleted_node.object); } } @@ -257,53 +234,40 @@ else if (curr_node.level == this.stack_level) } /** - * Removes the top snapshot from the undo stack, so that its situation cannot be - * restored any more. - * Returns false, if no more snapshot could be popped. + * Removes the top snapshot from the undo stack, so that its situation cannot be + * restored any more. + * Returns false, if no more snapshot could be popped. */ - public boolean pop_snapshot() - { + public boolean pop_snapshot() { disable_redo(); - if (stack_level == 0) - { + if (stack_level == 0) { return false; } Iterator it = objects.values().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { UndoableObjectNode curr_node = it.next(); - if (curr_node.level == stack_level - 1) - { - if (curr_node.redo_object != null && curr_node.redo_object.level == stack_level) - { + if (curr_node.level == stack_level - 1) { + if (curr_node.redo_object != null && curr_node.redo_object.level == stack_level) { curr_node.redo_object.undo_object = curr_node.undo_object; - if (curr_node.undo_object != null) - { + if (curr_node.undo_object != null) { curr_node.undo_object.redo_object = curr_node.redo_object; } } - } - else if (curr_node.level >= stack_level) - { + } else if (curr_node.level >= stack_level) { --curr_node.level; } } int deleted_objects_stack_size = deleted_objects_stack.size(); - if (deleted_objects_stack_size >= 2) - { + if (deleted_objects_stack_size >= 2) { // join the top delete list with the delete list of the second top level Collection from_delete_list = deleted_objects_stack.elementAt(deleted_objects_stack_size - 1); Collection to_delete_list = deleted_objects_stack.elementAt(deleted_objects_stack_size - 2); - for (UndoableObjectNode curr_deleted_node : from_delete_list) - { - if (curr_deleted_node.level < this.stack_level - 1) - { + for (UndoableObjectNode curr_deleted_node : from_delete_list) { + if (curr_deleted_node.level < this.stack_level - 1) { to_delete_list.add(curr_deleted_node); - } - else if (curr_deleted_node.undo_object != null) - { + } else if (curr_deleted_node.undo_object != null) { to_delete_list.add(curr_deleted_node.undo_object); } } @@ -317,18 +281,15 @@ else if (curr_deleted_node.undo_object != null) * Must be callel before p_object will be modified after a snapshot * for the first time, if it may have existed before that snapshot. */ - public void save_for_undo(UndoableObjects.Storable p_object) - { + public void save_for_undo(UndoableObjects.Storable p_object) { disable_redo(); // search p_object in the map UndoableObjectNode curr_node = objects.get(p_object); - if (curr_node == null) - { + if (curr_node == null) { System.out.println("UndoableObjects.save_for_undo: object node not found"); return; } - if (curr_node.level < this.stack_level) - { + if (curr_node.level < this.stack_level) { UndoableObjectNode old_node = new UndoableObjectNode((UndoableObjects.Storable) p_object.clone(), curr_node.level); old_node.undo_object = curr_node.undo_object; @@ -342,51 +303,31 @@ public void save_for_undo(UndoableObjects.Storable p_object) /** * Must be called, if objects are changed for the first time after undo. */ - private void disable_redo() - { - if (!redo_possible) - { + private void disable_redo() { + if (!redo_possible) { return; } redo_possible = false; // shorten the size of the deleted_objects_stack to this.stack_level - for (int i = deleted_objects_stack.size() - 1; i >= this.stack_level; --i) - { + for (int i = deleted_objects_stack.size() - 1; i >= this.stack_level; --i) { deleted_objects_stack.remove(i); } Iterator it = objects.values().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { UndoableObjectNode curr_node = it.next(); - if (curr_node.level > this.stack_level) - { + if (curr_node.level > this.stack_level) { it.remove(); - } - else if (curr_node.level == this.stack_level) - { + } else if (curr_node.level == this.stack_level) { curr_node.redo_object = null; } } } - /** The entries of this map are of type UnduableObject, the keys of type UndoableObjects.Storable. */ - private ConcurrentMap objects; - /** - * the current undo level - */ - private int stack_level; - /** - * the lists of deleted objects on each undo level, which where already - * existing before the previous snapshot. - */ - private Vector> deleted_objects_stack; - private boolean redo_possible = false; /** * Conditiom for an Object to be stored in an UndoableObjects database. * An object of class UndoableObjects.Storable must not contain any references. */ - public interface Storable extends Comparable - { + public interface Storable extends Comparable { /** * Creates an exact copy of this object @@ -400,20 +341,20 @@ public interface Storable extends Comparable * in an undo or redo operation. * p_level is the level in the Undo stack, where this object was inserted. */ - public static class UndoableObjectNode implements java.io.Serializable - { + public static class UndoableObjectNode implements java.io.Serializable { - /** Creates a new instance of UndoableObjectNode */ - UndoableObjectNode(Storable p_object, int p_level) - { + final Storable object; // the object in the node + int level; // the level in the Undo stack, where this node was inserted + UndoableObjectNode undo_object; // the object to restore in an undo or null. + UndoableObjectNode redo_object; // the object to restore in a redo or null. + /** + * Creates a new instance of UndoableObjectNode + */ + UndoableObjectNode(Storable p_object, int p_level) { object = p_object; level = p_level; undo_object = null; redo_object = null; } - final Storable object; // the object in the node - int level; // the level in the Undo stack, where this node was inserted - UndoableObjectNode undo_object; // the object to restore in an undo or null. - UndoableObjectNode redo_object; // the object to restore in a redo or null. } } diff --git a/src/main/java/net/freerouting/datastructures/package.html b/src/main/java/net/freerouting/datastructures/package.html index ac85df08..53fb1223 100644 --- a/src/main/java/net/freerouting/datastructures/package.html +++ b/src/main/java/net/freerouting/datastructures/package.html @@ -1,5 +1,6 @@ -java.text package - Contains general purpose datastructures. - \ No newline at end of file +Contains general purpose datastructures. + + \ No newline at end of file diff --git a/src/main/java/net/freerouting/designformats/specctra/AutorouteSettings.java b/src/main/java/net/freerouting/designformats/specctra/AutorouteSettings.java index 56e65162..7776c5e1 100644 --- a/src/main/java/net/freerouting/designformats/specctra/AutorouteSettings.java +++ b/src/main/java/net/freerouting/designformats/specctra/AutorouteSettings.java @@ -20,88 +20,59 @@ */ package net.freerouting.designformats.specctra; -import net.freerouting.datastructures.IndentFileWriter; import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; /** - * * @author Alfons Wirtz */ -public class AutorouteSettings -{ +public class AutorouteSettings { - static net.freerouting.interactive.AutorouteSettings read_scope(Scanner p_scanner, LayerStructure p_layer_structure) - { + static net.freerouting.interactive.AutorouteSettings read_scope(Scanner p_scanner, LayerStructure p_layer_structure) { net.freerouting.interactive.AutorouteSettings result = new net.freerouting.interactive.AutorouteSettings(p_layer_structure.arr.length); boolean with_fanout = false; boolean with_autoroute = true; boolean with_postroute = true; Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = p_scanner.next_token(); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("AutorouteSettings.read_scope: IO error scanning file"); return null; } - if (next_token == null) - { + if (next_token == null) { System.out.println("AutorouteSettings.read_scope: unexpected end of file"); return null; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.FANOUT) - { + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.FANOUT) { with_fanout = DsnFile.read_on_off_scope(p_scanner); - } - else if (next_token == Keyword.AUTOROUTE) - { + } else if (next_token == Keyword.AUTOROUTE) { with_autoroute = DsnFile.read_on_off_scope(p_scanner); - } - else if (next_token == Keyword.POSTROUTE) - { + } else if (next_token == Keyword.POSTROUTE) { with_postroute = DsnFile.read_on_off_scope(p_scanner); - } - else if (next_token == Keyword.VIAS) - { + } else if (next_token == Keyword.VIAS) { result.set_vias_allowed(DsnFile.read_on_off_scope(p_scanner)); - } - else if (next_token == Keyword.VIA_COSTS) - { + } else if (next_token == Keyword.VIA_COSTS) { result.set_via_costs(DsnFile.read_integer_scope(p_scanner)); - } - else if (next_token == Keyword.PLANE_VIA_COSTS) - { + } else if (next_token == Keyword.PLANE_VIA_COSTS) { result.set_plane_via_costs(DsnFile.read_integer_scope(p_scanner)); - } - else if (next_token == Keyword.START_RIPUP_COSTS) - { + } else if (next_token == Keyword.START_RIPUP_COSTS) { result.set_start_ripup_costs(DsnFile.read_integer_scope(p_scanner)); - } - else if (next_token == Keyword.START_PASS_NO) - { + } else if (next_token == Keyword.START_PASS_NO) { result.set_pass_no(DsnFile.read_integer_scope(p_scanner)); - } - else if (next_token == Keyword.LAYER_RULE) - { + } else if (next_token == Keyword.LAYER_RULE) { result = read_layer_rule(p_scanner, p_layer_structure, result); - if (result == null) - { + if (result == null) { return null; } - } - else - { + } else { ScopeKeyword.skip_scope(p_scanner); } } @@ -113,94 +84,68 @@ else if (next_token == Keyword.LAYER_RULE) } static net.freerouting.interactive.AutorouteSettings read_layer_rule(Scanner p_scanner, LayerStructure p_layer_structure, - net.freerouting.interactive.AutorouteSettings p_settings) - { + net.freerouting.interactive.AutorouteSettings p_settings) { p_scanner.yybegin(SpecctraFileScanner.NAME); Object next_token; - try - { + try { next_token = p_scanner.next_token(); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("AutorouteSettings.read_layer_rule: IO error scanning file"); return null; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("AutorouteSettings.read_layer_rule: String expected"); return null; } int layer_no = p_layer_structure.get_no((String) next_token); - if (layer_no < 0) - { + if (layer_no < 0) { System.out.println("AutorouteSettings.read_layer_rule: layer not found"); return null; } - for (;;) - { + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = p_scanner.next_token(); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("AutorouteSettings.read_layer_rule: IO error scanning file"); return null; } - if (next_token == null) - { + if (next_token == null) { System.out.println("AutorouteSettings.read_layer_rule: unexpected end of file"); return null; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.ACTIVE) - { + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.ACTIVE) { p_settings.set_layer_active(layer_no, DsnFile.read_on_off_scope(p_scanner)); - } - else if (next_token == Keyword.PREFERRED_DIRECTION) - { - try - { + } else if (next_token == Keyword.PREFERRED_DIRECTION) { + try { boolean pref_dir_is_horizontal = true; next_token = p_scanner.next_token(); - if (next_token == Keyword.VERTICAL) - { + if (next_token == Keyword.VERTICAL) { pref_dir_is_horizontal = false; - } - else if (next_token != Keyword.HORIZONTAL) - { + } else if (next_token != Keyword.HORIZONTAL) { System.out.println("AutorouteSettings.read_layer_rule: unexpected key word"); return null; } p_settings.set_preferred_direction_is_horizontal(layer_no, pref_dir_is_horizontal); next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("AutorouteSettings.read_layer_rule: uclosing bracket expected"); return null; } - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("AutorouteSettings.read_layer_rule: IO error scanning file"); return null; } - } - else if (next_token == Keyword.PREFERRED_DIRECTION_TRACE_COSTS) - { + } else if (next_token == Keyword.PREFERRED_DIRECTION_TRACE_COSTS) { p_settings.set_preferred_direction_trace_costs(layer_no, DsnFile.read_float_scope(p_scanner)); - } - else if (next_token == Keyword.AGAINST_PREFERRED_DIRECTION_TRACE_COSTS) - { + } else if (next_token == Keyword.AGAINST_PREFERRED_DIRECTION_TRACE_COSTS) { p_settings.set_against_preferred_direction_trace_costs(layer_no, DsnFile.read_float_scope(p_scanner)); - } - else - { + } else { ScopeKeyword.skip_scope(p_scanner); } } @@ -209,48 +154,35 @@ else if (next_token == Keyword.AGAINST_PREFERRED_DIRECTION_TRACE_COSTS) } static void write_scope(IndentFileWriter p_file, net.freerouting.interactive.AutorouteSettings p_settings, - net.freerouting.board.LayerStructure p_layer_structure, IdentifierType p_identifier_type) throws java.io.IOException - { + net.freerouting.board.LayerStructure p_layer_structure, IdentifierType p_identifier_type) throws java.io.IOException { p_file.start_scope(); p_file.write("autoroute_settings"); p_file.new_line(); p_file.write("(fanout "); - if (p_settings.get_with_fanout()) - { + if (p_settings.get_with_fanout()) { p_file.write("on)"); - } - else - { + } else { p_file.write("off)"); } p_file.new_line(); p_file.write("(autoroute "); - if (p_settings.get_with_autoroute()) - { + if (p_settings.get_with_autoroute()) { p_file.write("on)"); - } - else - { + } else { p_file.write("off)"); } p_file.new_line(); p_file.write("(postroute "); - if (p_settings.get_with_postroute()) - { + if (p_settings.get_with_postroute()) { p_file.write("on)"); - } - else - { + } else { p_file.write("off)"); } p_file.new_line(); p_file.write("(vias "); - if (p_settings.get_vias_allowed()) - { + if (p_settings.get_vias_allowed()) { p_file.write("on)"); - } - else - { + } else { p_file.write("off)"); } p_file.new_line(); @@ -281,30 +213,23 @@ static void write_scope(IndentFileWriter p_file, net.freerouting.interactive.Aut p_file.write(pass_no.toString()); } p_file.write(")"); - for (int i = 0; i < p_layer_structure.arr.length; ++i) - { + for (int i = 0; i < p_layer_structure.arr.length; ++i) { net.freerouting.board.Layer curr_layer = p_layer_structure.arr[i]; p_file.start_scope(); p_file.write("layer_rule "); p_identifier_type.write(curr_layer.name, p_file); p_file.new_line(); p_file.write("(active "); - if (p_settings.get_layer_active(i)) - { + if (p_settings.get_layer_active(i)) { p_file.write("on)"); - } - else - { + } else { p_file.write("off)"); } p_file.new_line(); p_file.write("(preferred_direction "); - if (p_settings.get_preferred_direction_is_horizontal(i)) - { + if (p_settings.get_preferred_direction_is_horizontal(i)) { p_file.write("horizontal)"); - } - else - { + } else { p_file.write("vertical)"); } p_file.new_line(); diff --git a/src/main/java/net/freerouting/designformats/specctra/Circle.java b/src/main/java/net/freerouting/designformats/specctra/Circle.java index 0e79269e..b338612d 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Circle.java +++ b/src/main/java/net/freerouting/designformats/specctra/Circle.java @@ -20,17 +20,18 @@ package net.freerouting.designformats.specctra; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.datastructures.IndentFileWriter; import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.geometry.planar.IntPoint; /** * Class for reading and writing circle scopes from dsn-files. * - * @author alfons + * @author alfons */ -public class Circle extends Shape -{ +public class Circle extends Shape { + public final double[] coor; + /** * Creates a new circle from the input parameters. * p_coor is an array of dimension 3. @@ -38,78 +39,66 @@ public class Circle extends Shape * p_coor [1] is the x coordinate of the circle, * p_coor [2] is the y coordinate of the circle. */ - public Circle(Layer p_layer, double [] p_coor) - { + public Circle(Layer p_layer, double[] p_coor) { super(p_layer); coor = p_coor; } - - public Circle(Layer p_layer, double p_radius, double p_center_x, double p_center_y) - { + + public Circle(Layer p_layer, double p_radius, double p_center_x, double p_center_y) { super(p_layer); coor = new double[3]; coor[0] = p_radius; coor[1] = p_center_x; coor[2] = p_center_y; } - - public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) - { - double [] location = new double[2]; + + public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) { + double[] location = new double[2]; location[0] = coor[1]; location[1] = coor[2]; - IntPoint center = p_coordinate_transform.dsn_to_board(location).round(); + IntPoint center = p_coordinate_transform.dsn_to_board(location).round(); int radius = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[0]) / 2); return new net.freerouting.geometry.planar.Circle(center, radius); } - - public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) - { - int [] new_coor = new int[3]; + + public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) { + int[] new_coor = new int[3]; new_coor[0] = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[0]) / 2); - for (int i = 1; i < 3; ++i) - { + for (int i = 1; i < 3; ++i) { new_coor[i] = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[i])); } return new net.freerouting.geometry.planar.Circle(new IntPoint(new_coor[1], new_coor[2]), new_coor[0]); } - - public Rectangle bounding_box() - { - double[] bounds = new double[4]; + + public Rectangle bounding_box() { + double[] bounds = new double[4]; bounds[0] = coor[1] - coor[0]; bounds[1] = coor[2] - coor[0]; bounds[2] = coor[1] + coor[0]; bounds[3] = coor[2] + coor[0]; return new Rectangle(layer, bounds); } - - public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException - { + + public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.new_line(); p_file.write("(circle "); p_identifier_type.write(this.layer.name, p_file); - for (int i = 0; i < coor.length; ++i) - { + for (int i = 0; i < coor.length; ++i) { p_file.write(" "); p_file.write(new Double(coor[i]).toString()); } p_file.write(")"); } - - public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException - { + + public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.new_line(); p_file.write("(circle "); p_identifier_type.write(this.layer.name, p_file); - for (int i = 0; i < coor.length; ++i) - { + for (int i = 0; i < coor.length; ++i) { p_file.write(" "); Integer curr_coor = (int) Math.round(coor[i]); p_file.write(curr_coor.toString()); } p_file.write(")"); } - - public final double[] coor; } diff --git a/src/main/java/net/freerouting/designformats/specctra/Circuit.java b/src/main/java/net/freerouting/designformats/specctra/Circuit.java index 87b9fab1..3167b693 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Circuit.java +++ b/src/main/java/net/freerouting/designformats/specctra/Circuit.java @@ -22,160 +22,123 @@ package net.freerouting.designformats.specctra; /** - * * @author Alfons Wirtz */ -public class Circuit -{ +public class Circuit { /** * Currently only the length matching rule is read from a circuit scope. * If the scope does not contain a length matching rule, nulll is returned. */ - public static ReadScopeResult read_scope( Scanner p_scanner) - { + public static ReadScopeResult read_scope(Scanner p_scanner) { Object next_token = null; double min_trace_length = 0; double max_trace_length = 0; java.util.Collection use_via = new java.util.LinkedList(); java.util.Collection use_layer = new java.util.LinkedList(); - for (;;) - { + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = p_scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Circuit.read_scope: IO error scanning file"); return null; } - if (next_token == null) - { + if (next_token == null) { System.out.println("Circuit.read_scope: unexpected end of file"); return null; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.LENGTH) - { + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.LENGTH) { LengthMatchingRule length_rule = read_length_scope(p_scanner); - if (length_rule != null) - { + if (length_rule != null) { min_trace_length = length_rule.min_length; max_trace_length = length_rule.max_length; } - } - else if (next_token == Keyword.USE_VIA) - { + } else if (next_token == Keyword.USE_VIA) { use_via.addAll(Structure.read_via_padstacks(p_scanner)); - } - else if (next_token == Keyword.USE_LAYER) - { + } else if (next_token == Keyword.USE_LAYER) { use_layer.addAll(DsnFile.read_string_list_scope(p_scanner)); - } - else - { + } else { ScopeKeyword.skip_scope(p_scanner); } } } return new ReadScopeResult(max_trace_length, min_trace_length, use_via, use_layer); } - - static LengthMatchingRule read_length_scope( Scanner p_scanner) - { + + static LengthMatchingRule read_length_scope(Scanner p_scanner) { LengthMatchingRule result = null; double[] length_arr = new double[2]; Object next_token = null; - for (int i = 0; i < 2; ++i) - { - try - { + for (int i = 0; i < 2; ++i) { + try { next_token = p_scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Circuit.read_length_scope: IO error scanning file"); return null; } - if (next_token instanceof Double) - { + if (next_token instanceof Double) { length_arr[i] = ((Double) next_token).doubleValue(); - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { length_arr[i] = ((Integer) next_token).intValue(); - } - else - { + } else { System.out.println("Circuit.read_length_scope: number expected"); return null; } } - result = new LengthMatchingRule(length_arr[0], length_arr[1]); - for (;;) - { + result = new LengthMatchingRule(length_arr[0], length_arr[1]); + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = p_scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Circuit.read_length_scope: IO error scanning file"); return null; } - if (next_token == null) - { + if (next_token == null) { System.out.println("Circuit.read_length_scope: unexpected end of file"); return null; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - if (prev_token == Keyword.OPEN_BRACKET) - { + if (prev_token == Keyword.OPEN_BRACKET) { ScopeKeyword.skip_scope(p_scanner); } } return result; } - - /** A max_length of -1 indicates, tha no maximum length is defined. */ - public static class ReadScopeResult - { - public ReadScopeResult(double p_max_length, double p_min_length, java.util.Collection p_use_via, java.util.Collection p_use_layer) - { + + /** + * A max_length of -1 indicates, tha no maximum length is defined. + */ + public static class ReadScopeResult { + public final double max_length; + public final double min_length; + public final java.util.Collection use_via; + public final java.util.Collection use_layer; + public ReadScopeResult(double p_max_length, double p_min_length, java.util.Collection p_use_via, java.util.Collection p_use_layer) { max_length = p_max_length; min_length = p_min_length; use_via = p_use_via; use_layer = p_use_layer; } - + } + + /** + * A max_length of -1 indicates, tha no maximum length is defined. + */ + private static class LengthMatchingRule { public final double max_length; public final double min_length; - public final java.util.Collection use_via; - public final java.util.Collection use_layer; - } - - /** A max_length of -1 indicates, tha no maximum length is defined. */ - private static class LengthMatchingRule - { - public LengthMatchingRule(double p_max_length, double p_min_length) - { + public LengthMatchingRule(double p_max_length, double p_min_length) { max_length = p_max_length; min_length = p_min_length; } - - public final double max_length; - public final double min_length; } } diff --git a/src/main/java/net/freerouting/designformats/specctra/Component.java b/src/main/java/net/freerouting/designformats/specctra/Component.java index 7eb78b4b..782b54bc 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Component.java +++ b/src/main/java/net/freerouting/designformats/specctra/Component.java @@ -24,61 +24,34 @@ /** * Handels the placement bata of a library component. * - * @author alfons + * @author alfons */ -public class Component extends ScopeKeyword -{ - - /** Creates a new instance of Component */ - public Component() - { - super("component"); - } - +public class Component extends ScopeKeyword { + /** - * Overwrites the function read_scope in ScopeKeyword + * Creates a new instance of Component */ - public boolean read_scope(ReadScopeParameter p_par) - { - try - { - ComponentPlacement component_placement = read_scope(p_par.scanner); - if(component_placement == null) - { - return false; - } - p_par.placement_list.add(component_placement); - } - catch (java.io.IOException e) - { - System.out.println("Component.read_scope: IO error scanning file"); - return false; - } - return true; + public Component() { + super("component"); } - + /** * Used also when reading a session file. */ - public static ComponentPlacement read_scope(Scanner p_scanner) throws java.io.IOException - { + public static ComponentPlacement read_scope(Scanner p_scanner) throws java.io.IOException { Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Component.read_scope: component name expected"); return null; } - String name = (String) next_token; + String name = (String) next_token; ComponentPlacement component_placement = new ComponentPlacement(name); Object prev_token = next_token; next_token = p_scanner.next_token(); - while ( next_token != Keyword.CLOSED_BRACKET) - { - if (prev_token == Keyword.OPEN_BRACKET && next_token == Keyword.PLACE) - { + while (next_token != Keyword.CLOSED_BRACKET) { + if (prev_token == Keyword.OPEN_BRACKET && next_token == Keyword.PLACE) { ComponentPlacement.ComponentLocation next_location = read_place_scope(p_scanner); - if (next_location != null) - { + if (next_location != null) { component_placement.locations.add(next_location); } } @@ -87,69 +60,56 @@ public static ComponentPlacement read_scope(Scanner p_scanner) throws java.io.IO } return component_placement; } - + public static void write_scope(WriteScopeParameter p_par, net.freerouting.board.Component p_component) - throws java.io.IOException - { + throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("place "); p_par.file.new_line(); p_par.identifier_type.write(p_component.name, p_par.file); - if (p_component.is_placed()) - { - double [] coor = p_par.coordinate_transform.board_to_dsn(p_component.get_location().to_float()); - for (int i = 0; i < coor.length; ++i) - { + if (p_component.is_placed()) { + double[] coor = p_par.coordinate_transform.board_to_dsn(p_component.get_location().to_float()); + for (int i = 0; i < coor.length; ++i) { p_par.file.write(" "); p_par.file.write((new Double(coor[i])).toString()); } - if (p_component.placed_on_front()) - { + if (p_component.placed_on_front()) { p_par.file.write(" front "); - } - else - { + } else { p_par.file.write(" back "); } int rotation = (int) Math.round(p_component.get_rotation_in_degree()); p_par.file.write((new Integer(rotation).toString())); } - if (p_component.position_fixed) - { + if (p_component.position_fixed) { p_par.file.new_line(); p_par.file.write(" (lock_type position)"); } int pin_count = p_component.get_package().pin_count(); - for (int i = 0; i < pin_count; ++i) - { + for (int i = 0; i < pin_count; ++i) { write_pin_info(p_par, p_component, i); } write_keepout_infos(p_par, p_component); p_par.file.end_scope(); } - + private static void write_pin_info(WriteScopeParameter p_par, net.freerouting.board.Component p_component, int p_pin_no) - throws java.io.IOException - { - if (!p_component.is_placed()) - { + throws java.io.IOException { + if (!p_component.is_placed()) { return; } net.freerouting.library.Package.Pin package_pin = p_component.get_package().get_pin(p_pin_no); - if (package_pin == null) - { + if (package_pin == null) { System.out.println("Component.write_pin_info: package pin not found"); return; } net.freerouting.board.Pin component_pin = p_par.board.get_pin(p_component.no, p_pin_no); - if (component_pin == null) - { + if (component_pin == null) { System.out.println("Component.write_pin_info: component pin not found"); return; } String cl_class_name = p_par.board.rules.clearance_matrix.get_name(component_pin.clearance_class_no()); - if (cl_class_name == null) - { + if (cl_class_name == null) { System.out.println("Component.write_pin_info: clearance class name not found"); return; } @@ -160,44 +120,33 @@ private static void write_pin_info(WriteScopeParameter p_par, net.freerouting.bo p_par.identifier_type.write(cl_class_name, p_par.file); p_par.file.write("))"); } - + private static void write_keepout_infos(WriteScopeParameter p_par, net.freerouting.board.Component p_component) - throws java.io.IOException - { - if (!p_component.is_placed()) - { + throws java.io.IOException { + if (!p_component.is_placed()) { return; } net.freerouting.library.Package.Keepout[] curr_keepout_arr; String keepout_type; - for (int j = 0; j < 3; ++j) - { - if (j == 0) - { + for (int j = 0; j < 3; ++j) { + if (j == 0) { curr_keepout_arr = p_component.get_package().keepout_arr; keepout_type = "(keepout "; - } - else if (j == 1) - { + } else if (j == 1) { curr_keepout_arr = p_component.get_package().via_keepout_arr; keepout_type = "(via_keepout "; - } - else - { + } else { curr_keepout_arr = p_component.get_package().place_keepout_arr; keepout_type = "(place_keepout "; } - for (int i = 0; i < curr_keepout_arr.length; ++i) - { + for (int i = 0; i < curr_keepout_arr.length; ++i) { net.freerouting.library.Package.Keepout curr_keepout = curr_keepout_arr[i]; net.freerouting.board.ObstacleArea curr_obstacle_area = get_keepout(p_par.board, p_component.no, curr_keepout.name); - if (curr_obstacle_area == null || curr_obstacle_area.clearance_class_no() == 0) - { + if (curr_obstacle_area == null || curr_obstacle_area.clearance_class_no() == 0) { continue; } String cl_class_name = p_par.board.rules.clearance_matrix.get_name(curr_obstacle_area.clearance_class_no()); - if (cl_class_name == null) - { + if (cl_class_name == null) { System.out.println("Component.write_keepout_infos: clearance class name not found"); return; } @@ -210,221 +159,181 @@ else if (j == 1) } } } - - private static net.freerouting.board.ObstacleArea get_keepout(net.freerouting.board.BasicBoard p_board, int p_component_no, String p_name) - { + + private static net.freerouting.board.ObstacleArea get_keepout(net.freerouting.board.BasicBoard p_board, int p_component_no, String p_name) { java.util.Iterator it = p_board.item_list.start_read_object(); - for(;;) - { - net.freerouting.board.Item curr_item = (net.freerouting.board.Item)p_board.item_list.read_object(it); - if (curr_item == null) - { + for (; ; ) { + net.freerouting.board.Item curr_item = (net.freerouting.board.Item) p_board.item_list.read_object(it); + if (curr_item == null) { break; } - if (curr_item.get_component_no() == p_component_no && curr_item instanceof net.freerouting.board.ObstacleArea) - { + if (curr_item.get_component_no() == p_component_no && curr_item instanceof net.freerouting.board.ObstacleArea) { net.freerouting.board.ObstacleArea curr_area = (net.freerouting.board.ObstacleArea) curr_item; - if (curr_area.name != null && curr_area.name.equals(p_name)) - { + if (curr_area.name != null && curr_area.name.equals(p_name)) { return curr_area; } } } return null; } - - - - private static ComponentPlacement.ComponentLocation read_place_scope(Scanner p_scanner) - { - try - { - java.util.Map pin_infos = + + private static ComponentPlacement.ComponentLocation read_place_scope(Scanner p_scanner) { + try { + java.util.Map pin_infos = new java.util.TreeMap(); - java.util.Map keepout_infos = + java.util.Map keepout_infos = new java.util.TreeMap(); - java.util.Map via_keepout_infos = + java.util.Map via_keepout_infos = new java.util.TreeMap(); - java.util.Map place_keepout_infos = + java.util.Map place_keepout_infos = new java.util.TreeMap(); Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Component.read_place_scope: String expected"); return null; } String name = (String) next_token; double[] location = new double[2]; - for (int i = 0; i < 2; ++i) - { + for (int i = 0; i < 2; ++i) { next_token = p_scanner.next_token(); - if (next_token instanceof Double) - { + if (next_token instanceof Double) { location[i] = ((Double) next_token).doubleValue(); - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { location[i] = ((Integer) next_token).intValue(); - } - else if (next_token == Keyword.CLOSED_BRACKET) - { + } else if (next_token == Keyword.CLOSED_BRACKET) { // component is not yet placed return new ComponentPlacement.ComponentLocation(name, null, true, 0, false, pin_infos, keepout_infos, via_keepout_infos, place_keepout_infos); - } - else - { + } else { System.out.println("Component.read_place_scope: number expected"); return null; } } next_token = p_scanner.next_token(); boolean is_front = true; - if (next_token == Keyword.BACK) - { + if (next_token == Keyword.BACK) { is_front = false; - } - else if (next_token != Keyword.FRONT) - { + } else if (next_token != Keyword.FRONT) { System.out.println("Component.read_place_scope: Keyword.FRONT expected"); } double rotation; next_token = p_scanner.next_token(); - if (next_token instanceof Double) - { + if (next_token instanceof Double) { rotation = ((Double) next_token).doubleValue(); - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { rotation = ((Integer) next_token).intValue(); - } - else - { + } else { System.out.println("Component.read_place_scope: number expected"); return null; } boolean position_fixed = false; next_token = p_scanner.next_token(); - while (next_token == Keyword.OPEN_BRACKET) - { + while (next_token == Keyword.OPEN_BRACKET) { next_token = p_scanner.next_token(); - if (next_token == Keyword.LOCK_TYPE) - { + if (next_token == Keyword.LOCK_TYPE) { position_fixed = read_lock_type(p_scanner); - } - else if (next_token == Keyword.PIN) - { + } else if (next_token == Keyword.PIN) { ComponentPlacement.ItemClearanceInfo curr_pin_info = read_item_clearance_info(p_scanner); - if (curr_pin_info == null) - { + if (curr_pin_info == null) { return null; } - pin_infos.put(curr_pin_info.name, curr_pin_info); - } - else if (next_token == Keyword.KEEPOUT) - { + pin_infos.put(curr_pin_info.name, curr_pin_info); + } else if (next_token == Keyword.KEEPOUT) { ComponentPlacement.ItemClearanceInfo curr_keepout_info = read_item_clearance_info(p_scanner); - if (curr_keepout_info == null) - { + if (curr_keepout_info == null) { return null; } - keepout_infos.put(curr_keepout_info.name, curr_keepout_info); - } - else if (next_token == Keyword.VIA_KEEPOUT) - { + keepout_infos.put(curr_keepout_info.name, curr_keepout_info); + } else if (next_token == Keyword.VIA_KEEPOUT) { ComponentPlacement.ItemClearanceInfo curr_keepout_info = read_item_clearance_info(p_scanner); - if (curr_keepout_info == null) - { + if (curr_keepout_info == null) { return null; } - via_keepout_infos.put(curr_keepout_info.name, curr_keepout_info); - } - else if (next_token == Keyword.PLACE_KEEPOUT) - { + via_keepout_infos.put(curr_keepout_info.name, curr_keepout_info); + } else if (next_token == Keyword.PLACE_KEEPOUT) { ComponentPlacement.ItemClearanceInfo curr_keepout_info = read_item_clearance_info(p_scanner); - if (curr_keepout_info == null) - { + if (curr_keepout_info == null) { return null; } - place_keepout_infos.put(curr_keepout_info.name, curr_keepout_info); - } - else - { + place_keepout_infos.put(curr_keepout_info.name, curr_keepout_info); + } else { skip_scope(p_scanner); } next_token = p_scanner.next_token(); } - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Component.read_place_scope: ) expected"); return null; } ComponentPlacement.ComponentLocation result = new ComponentPlacement.ComponentLocation(name, location, is_front, rotation, position_fixed, pin_infos, - keepout_infos, via_keepout_infos, place_keepout_infos); + keepout_infos, via_keepout_infos, place_keepout_infos); return result; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Component.read_scope: IO error scanning file"); System.out.println(e); - return null; + return null; } } - - private static ComponentPlacement.ItemClearanceInfo read_item_clearance_info(Scanner p_scanner) throws java.io.IOException - { + + private static ComponentPlacement.ItemClearanceInfo read_item_clearance_info(Scanner p_scanner) throws java.io.IOException { p_scanner.yybegin(SpecctraFileScanner.NAME); Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Component.read_item_clearance_info: String expected"); return null; } String name = (String) next_token; String cl_class_name = null; next_token = p_scanner.next_token(); - while (next_token == Keyword.OPEN_BRACKET) - { + while (next_token == Keyword.OPEN_BRACKET) { next_token = p_scanner.next_token(); - if (next_token == Keyword.CLEARANCE_CLASS) - { + if (next_token == Keyword.CLEARANCE_CLASS) { cl_class_name = DsnFile.read_string_scope(p_scanner); - } - else - { + } else { skip_scope(p_scanner); } next_token = p_scanner.next_token(); } - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Component.read_item_clearance_info: ) expected"); return null; } - if (cl_class_name == null) - { + if (cl_class_name == null) { System.out.println("Component.read_item_clearance_info: clearance class name not found"); return null; } return new ComponentPlacement.ItemClearanceInfo(name, cl_class_name); } - - private static boolean read_lock_type(Scanner p_scanner) throws java.io.IOException - { + + private static boolean read_lock_type(Scanner p_scanner) throws java.io.IOException { boolean result = false; - for (;;) - { + for (; ; ) { Object next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (next_token == Keyword.POSITION) - { + if (next_token == Keyword.POSITION) { result = true; } } return result; } + + /** + * Overwrites the function read_scope in ScopeKeyword + */ + public boolean read_scope(ReadScopeParameter p_par) { + try { + ComponentPlacement component_placement = read_scope(p_par.scanner); + if (component_placement == null) { + return false; + } + p_par.placement_list.add(component_placement); + } catch (java.io.IOException e) { + System.out.println("Component.read_scope: IO error scanning file"); + return false; + } + return true; + } } diff --git a/src/main/java/net/freerouting/designformats/specctra/ComponentPlacement.java b/src/main/java/net/freerouting/designformats/specctra/ComponentPlacement.java index 025d1af5..c5cc535f 100644 --- a/src/main/java/net/freerouting/designformats/specctra/ComponentPlacement.java +++ b/src/main/java/net/freerouting/designformats/specctra/ComponentPlacement.java @@ -27,80 +27,79 @@ /** * Describes the placement data of a library component * - * @author alfons + * @author alfons */ -public class ComponentPlacement -{ - - /** Creates a new instance of ComponentPlacement */ - public ComponentPlacement(String p_lib_name) - { +public class ComponentPlacement { + + /** + * The name of the corresponding library component + */ + public final String lib_name; + /** + * The list of ComponentLocations of the library component on the board. + */ + public final Collection locations; + + /** + * Creates a new instance of ComponentPlacement + */ + public ComponentPlacement(String p_lib_name) { lib_name = p_lib_name; locations = new LinkedList(); } - - /** The name of the corresponding library component */ - public final String lib_name; - - /** The list of ComponentLocations of the library component on the board. */ - public final Collection locations; - - /** The structure of an entry in the list locations. */ - public static class ComponentLocation - { - ComponentLocation(String p_name, double[] p_coor, boolean p_is_front, double p_rotation, boolean p_position_fixed, - Map p_pin_infos, Map p_keepout_infos, - Map p_via_keepout_infos, Map p_place_keepout_infos) - { - name = p_name; - coor = p_coor; - is_front = p_is_front; - rotation = p_rotation; - position_fixed = p_position_fixed; - pin_infos = p_pin_infos; - keepout_infos = p_keepout_infos; - via_keepout_infos = p_via_keepout_infos; - place_keepout_infos = p_place_keepout_infos; - - } - + + /** + * The structure of an entry in the list locations. + */ + public static class ComponentLocation { public final String name; - - /** the x- and the y-coordinate of the location. */ - public final double [] coor; - + /** + * the x- and the y-coordinate of the location. + */ + public final double[] coor; /** * True, if the component is placed at the component side. * Else the component is placed at the solder side. */ public final boolean is_front; - - /** The rotation of the component in degree. */ + /** + * The rotation of the component in degree. + */ public final double rotation; - - /** If true, the component cannot be moved. */ + /** + * If true, the component cannot be moved. + */ public final boolean position_fixed; - /** * The entries of this map are of type ItemClearanceInfo, the keys are the pin names. */ public final Map pin_infos; - public final Map keepout_infos; - public final Map via_keepout_infos; - public final Map place_keepout_infos; - } - - public static class ItemClearanceInfo - { - ItemClearanceInfo( String p_name, String p_clearance_class) - { + + ComponentLocation(String p_name, double[] p_coor, boolean p_is_front, double p_rotation, boolean p_position_fixed, + Map p_pin_infos, Map p_keepout_infos, + Map p_via_keepout_infos, Map p_place_keepout_infos) { name = p_name; - clearance_class = p_clearance_class; + coor = p_coor; + is_front = p_is_front; + rotation = p_rotation; + position_fixed = p_position_fixed; + pin_infos = p_pin_infos; + keepout_infos = p_keepout_infos; + via_keepout_infos = p_via_keepout_infos; + place_keepout_infos = p_place_keepout_infos; + } + } + + public static class ItemClearanceInfo { public final String name; public final String clearance_class; + ItemClearanceInfo(String p_name, String p_clearance_class) { + name = p_name; + clearance_class = p_clearance_class; + } } } diff --git a/src/main/java/net/freerouting/designformats/specctra/CoordinateTransform.java b/src/main/java/net/freerouting/designformats/specctra/CoordinateTransform.java index 26787b5b..674316db 100644 --- a/src/main/java/net/freerouting/designformats/specctra/CoordinateTransform.java +++ b/src/main/java/net/freerouting/designformats/specctra/CoordinateTransform.java @@ -20,96 +20,86 @@ package net.freerouting.designformats.specctra; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.PolylineShape; +import net.freerouting.geometry.planar.*; /** * Computes transformations between a specctra dsn-file coordinates and board coordinates. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class CoordinateTransform implements java.io.Serializable -{ - +public class CoordinateTransform implements java.io.Serializable { + + private final double scale_factor; + private final double base_x; + private final double base_y; + /** * Creates a new instance of CoordinateTransform. * The base point of the dsn coordinate system will be translated to zero in the board * coordinate system. */ - public CoordinateTransform(double p_scale_factor, double p_base_x, double p_base_y) - { + public CoordinateTransform(double p_scale_factor, double p_base_x, double p_base_y) { scale_factor = p_scale_factor; base_x = p_base_x; base_y = p_base_y; } - + /** * Scale a value from the board to the dsn coordinate system */ - public double board_to_dsn(double p_val) - { + public double board_to_dsn(double p_val) { return p_val / scale_factor; } - + /** * Scale a value from the dsn to the board coordinate system */ - public double dsn_to_board(double p_val) - { + public double dsn_to_board(double p_val) { return p_val * scale_factor; } - + /** * Transforms a geometry.planar.FloatPoint to a tuple of doubles * in the dsn coordinate system. */ - public double[] board_to_dsn(FloatPoint p_point) - { - double [] result = new double[2]; - result [0] = board_to_dsn(p_point.x) + base_x; - result [1] = board_to_dsn(p_point.y) + base_y; + public double[] board_to_dsn(FloatPoint p_point) { + double[] result = new double[2]; + result[0] = board_to_dsn(p_point.x) + base_x; + result[1] = board_to_dsn(p_point.y) + base_y; return result; } - + /** * Transforms a geometry.planar.FloatPoint to a tuple of doubles * in the dsn coordinate system in relative (vector) coordinates. */ - public double[] board_to_dsn_rel(FloatPoint p_point) - { - double [] result = new double[2]; - result [0] = board_to_dsn(p_point.x); - result [1] = board_to_dsn(p_point.y); + public double[] board_to_dsn_rel(FloatPoint p_point) { + double[] result = new double[2]; + result[0] = board_to_dsn(p_point.x); + result[1] = board_to_dsn(p_point.y); return result; } - + /** * Transforms an array of n geometry.planar.FloatPoints to * an array of 2*n doubles in the dsn coordinate system. */ - public double [] board_to_dsn(FloatPoint [] p_points) - { - double [] result = new double[2 * p_points.length]; - for (int i = 0; i < p_points.length; ++ i) - { + public double[] board_to_dsn(FloatPoint[] p_points) { + double[] result = new double[2 * p_points.length]; + for (int i = 0; i < p_points.length; ++i) { result[2 * i] = board_to_dsn(p_points[i].x) + base_x; result[2 * i + 1] = board_to_dsn(p_points[i].y) + base_y; } return result; } - + /** * Transforms an array of n geometry.planar.Lines to * an array of 4*n doubles in the dsn coordinate system. */ - public double [] board_to_dsn(Line [] p_lines) - { - double [] result = new double[4 * p_lines.length]; - for (int i = 0; i < p_lines.length; ++ i) - { + public double[] board_to_dsn(Line[] p_lines) { + double[] result = new double[4 * p_lines.length]; + for (int i = 0; i < p_lines.length; ++i) { FloatPoint a = p_lines[i].a.to_float(); FloatPoint b = p_lines[i].b.to_float(); result[4 * i] = board_to_dsn(a.x) + base_x; @@ -119,144 +109,117 @@ public double[] board_to_dsn_rel(FloatPoint p_point) } return result; } - + /** * Transforms an array of n geometry.planar.FloatPoints to * an array of 2*n doubles in the dsn coordinate system in relative (vector) coordinates. */ - public double [] board_to_dsn_rel(FloatPoint [] p_points) - { - double [] result = new double[2 * p_points.length]; - for (int i = 0; i < p_points.length; ++ i) - { + public double[] board_to_dsn_rel(FloatPoint[] p_points) { + double[] result = new double[2 * p_points.length]; + for (int i = 0; i < p_points.length; ++i) { result[2 * i] = board_to_dsn(p_points[i].x); result[2 * i + 1] = board_to_dsn(p_points[i].y); } return result; } - + /** * Transforms a geometry.planar.Vector to a tuple of doubles * in the dsn coordinate system. */ - public double[] board_to_dsn(Vector p_vector) - { - double [] result = new double[2]; + public double[] board_to_dsn(Vector p_vector) { + double[] result = new double[2]; FloatPoint v = p_vector.to_float(); - result [0] = board_to_dsn(v.x); - result [1] = board_to_dsn(v.y); + result[0] = board_to_dsn(v.x); + result[1] = board_to_dsn(v.y); return result; } - + /** * Transforms a dsn tuple to a geometry.planar.FloatPoint */ - public FloatPoint dsn_to_board(double [] p_tuple) - { + public FloatPoint dsn_to_board(double[] p_tuple) { double x = dsn_to_board(p_tuple[0] - base_x); double y = dsn_to_board(p_tuple[1] - base_y); return new FloatPoint(x, y); } - + /** * Transforms a dsn tuple to a geometry.planar.FloatPoint in relative (vector) coordinates. */ - public FloatPoint dsn_to_board_rel(double [] p_tuple) - { + public FloatPoint dsn_to_board_rel(double[] p_tuple) { double x = dsn_to_board(p_tuple[0]); double y = dsn_to_board(p_tuple[1]); return new FloatPoint(x, y); } - + /** * Transforms a geometry.planar.Intbox to the coordinates of a Rectangle. */ - public double [] board_to_dsn(IntBox p_box) - { - double [] result = new double[4]; + public double[] board_to_dsn(IntBox p_box) { + double[] result = new double[4]; result[0] = p_box.ll.x / scale_factor + base_x; result[1] = p_box.ll.y / scale_factor + base_y; result[2] = p_box.ur.x / scale_factor + base_x; result[3] = p_box.ur.y / scale_factor + base_y; return result; } - + /** * Transforms a geometry.planar.Intbox to a Rectangle in relative (vector) coordinates. */ - public double [] board_to_dsn_rel(IntBox p_box) - { - double [] result = new double[4]; + public double[] board_to_dsn_rel(IntBox p_box) { + double[] result = new double[4]; result[0] = p_box.ll.x / scale_factor; - result[1] = p_box.ll.y / scale_factor ; + result[1] = p_box.ll.y / scale_factor; result[2] = p_box.ur.x / scale_factor; result[3] = p_box.ur.y / scale_factor; return result; } - + /** * Transforms a board shape to a dsn shape. */ - public Shape board_to_dsn(net.freerouting.geometry.planar.Shape p_board_shape, Layer p_layer) - { + public Shape board_to_dsn(net.freerouting.geometry.planar.Shape p_board_shape, Layer p_layer) { Shape result; - if (p_board_shape instanceof IntBox) - { + if (p_board_shape instanceof IntBox) { result = new Rectangle(p_layer, board_to_dsn((IntBox) p_board_shape)); - } - else if (p_board_shape instanceof PolylineShape) - { - FloatPoint [] corners = ((PolylineShape)p_board_shape).corner_approx_arr(); - double [] coors = board_to_dsn(corners); - result = new Polygon(p_layer, coors); - } - else if (p_board_shape instanceof net.freerouting.geometry.planar.Circle) - { + } else if (p_board_shape instanceof PolylineShape) { + FloatPoint[] corners = ((PolylineShape) p_board_shape).corner_approx_arr(); + double[] coors = board_to_dsn(corners); + result = new Polygon(p_layer, coors); + } else if (p_board_shape instanceof net.freerouting.geometry.planar.Circle) { net.freerouting.geometry.planar.Circle board_circle = (net.freerouting.geometry.planar.Circle) p_board_shape; double diameter = 2 * board_to_dsn(board_circle.radius); - double [] center_coor = board_to_dsn(board_circle.center.to_float()); - result = new Circle(p_layer, diameter, center_coor[0], center_coor[1]); - } - else - { + double[] center_coor = board_to_dsn(board_circle.center.to_float()); + result = new Circle(p_layer, diameter, center_coor[0], center_coor[1]); + } else { System.out.println("CoordinateTransform.board_to_dsn not yet implemented for p_board_shape"); result = null; } return result; } - + /** * Transforms the relative (vector) coordinates of a geometry.planar.Shape to a specctra dsn shape. */ - public Shape board_to_dsn_rel(net.freerouting.geometry.planar.Shape p_board_shape, Layer p_layer) - { + public Shape board_to_dsn_rel(net.freerouting.geometry.planar.Shape p_board_shape, Layer p_layer) { Shape result; - if (p_board_shape instanceof IntBox) - { + if (p_board_shape instanceof IntBox) { result = new Rectangle(p_layer, board_to_dsn_rel((IntBox) p_board_shape)); - } - else if (p_board_shape instanceof PolylineShape) - { - FloatPoint [] corners = ((PolylineShape)p_board_shape).corner_approx_arr(); - double [] coors = board_to_dsn_rel(corners); - result = new Polygon(p_layer, coors); - } - else if (p_board_shape instanceof net.freerouting.geometry.planar.Circle) - { + } else if (p_board_shape instanceof PolylineShape) { + FloatPoint[] corners = ((PolylineShape) p_board_shape).corner_approx_arr(); + double[] coors = board_to_dsn_rel(corners); + result = new Polygon(p_layer, coors); + } else if (p_board_shape instanceof net.freerouting.geometry.planar.Circle) { net.freerouting.geometry.planar.Circle board_circle = (net.freerouting.geometry.planar.Circle) p_board_shape; double diameter = 2 * board_to_dsn(board_circle.radius); - double [] center_coor = board_to_dsn_rel(board_circle.center.to_float()); - result = new Circle(p_layer, diameter, center_coor[0], center_coor[1]); - } - else - { + double[] center_coor = board_to_dsn_rel(board_circle.center.to_float()); + result = new Circle(p_layer, diameter, center_coor[0], center_coor[1]); + } else { System.out.println("CoordinateTransform.board_to_dsn not yet implemented for p_board_shape"); result = null; } return result; } - - private final double scale_factor; - private final double base_x; - private final double base_y; } diff --git a/src/main/java/net/freerouting/designformats/specctra/DsnFile.java b/src/main/java/net/freerouting/designformats/specctra/DsnFile.java index a2798a8d..6330e077 100644 --- a/src/main/java/net/freerouting/designformats/specctra/DsnFile.java +++ b/src/main/java/net/freerouting/designformats/specctra/DsnFile.java @@ -19,24 +19,18 @@ */ package net.freerouting.designformats.specctra; -import net.freerouting.datastructures.IndentFileWriter; - import net.freerouting.board.BasicBoard; import net.freerouting.board.TestLevel; +import net.freerouting.datastructures.IndentFileWriter; /** * Class for reading and writing dsn-files. * - * @author alfons + * @author alfons */ -public class DsnFile -{ - - public enum ReadResult - { +public class DsnFile { - OK, OUTLINE_MISSING, ERROR - } + static final String CLASS_CLEARANCE_SEPARATOR = "-"; /** * Creates a routing board from a Specctra dns file. @@ -45,34 +39,25 @@ public enum ReadResult * Returns false, if an error occured. */ public static ReadResult read(java.io.InputStream p_input_stream, net.freerouting.interactive.BoardHandling p_board_handling, - net.freerouting.board.BoardObservers p_observers, net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, TestLevel p_test_level) - { + net.freerouting.board.BoardObservers p_observers, net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, TestLevel p_test_level) { Scanner scanner = new SpecctraFileScanner(p_input_stream); Object curr_token = null; - for (int i = 0; i < 3; ++i) - { - try - { + for (int i = 0; i < 3; ++i) { + try { curr_token = scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("DsnFile.read: IO error scanning file"); System.out.println(e); return ReadResult.ERROR; } boolean keyword_ok = true; - if (i == 0) - { + if (i == 0) { keyword_ok = (curr_token == Keyword.OPEN_BRACKET); - } - else if (i == 1) - { + } else if (i == 1) { keyword_ok = (curr_token == Keyword.PCB_SCOPE); scanner.yybegin(SpecctraFileScanner.NAME); // to overread the name of the pcb for i = 2 } - if (!keyword_ok) - { + if (!keyword_ok) { System.out.println("DsnFile.read: specctra dsn file format expected"); return ReadResult.ERROR; } @@ -81,21 +66,15 @@ else if (i == 1) new ReadScopeParameter(scanner, p_board_handling, p_observers, p_item_id_no_generator, p_test_level); boolean read_ok = Keyword.PCB_SCOPE.read_scope(read_scope_par); ReadResult result; - if (read_ok) - { + if (read_ok) { result = ReadResult.OK; - if (read_scope_par.autoroute_settings == null) - { + if (read_scope_par.autoroute_settings == null) { // look for power planes with incorrect layer type and adjust autoroute parameters adjust_plane_autoroute_settings(p_board_handling); } - } - else if (!read_scope_par.board_outline_ok) - { + } else if (!read_scope_par.board_outline_ok) { result = ReadResult.OUTLINE_MISSING; - } - else - { + } else { result = ReadResult.ERROR; } //tests.Validate.check("after reading dsn", read_scope_par.board_handling.get_routing_board()); @@ -103,44 +82,35 @@ else if (!read_scope_par.board_outline_ok) } /** - * Sets contains_plane to true for nets with a conduction_area covering a + * Sets contains_plane to true for nets with a conduction_area covering a * large part of a signal layer, if that layer does not contain any traces * This is useful in case the layer type was not set correctly to plane in the dsn-file. * Returns true, if something was changed. */ - private static boolean adjust_plane_autoroute_settings(net.freerouting.interactive.BoardHandling p_board_handling) - { + private static boolean adjust_plane_autoroute_settings(net.freerouting.interactive.BoardHandling p_board_handling) { BasicBoard routing_board = p_board_handling.get_routing_board(); net.freerouting.board.LayerStructure board_layer_structure = routing_board.layer_structure; - if (board_layer_structure.arr.length <= 2) - { + if (board_layer_structure.arr.length <= 2) { return false; } - for (net.freerouting.board.Layer curr_layer : board_layer_structure.arr) - { - if (!curr_layer.is_signal) - { + for (net.freerouting.board.Layer curr_layer : board_layer_structure.arr) { + if (!curr_layer.is_signal) { return false; } } boolean[] layer_contains_wires_arr = new boolean[board_layer_structure.arr.length]; boolean[] changed_layer_arr = new boolean[board_layer_structure.arr.length]; - for (int i = 0; i < layer_contains_wires_arr.length; ++i) - { + for (int i = 0; i < layer_contains_wires_arr.length; ++i) { layer_contains_wires_arr[i] = false; changed_layer_arr[i] = false; } java.util.Collection conduction_area_list = new java.util.LinkedList(); java.util.Collection item_list = routing_board.get_items(); - for (net.freerouting.board.Item curr_item : item_list) - { - if (curr_item instanceof net.freerouting.board.Trace) - { + for (net.freerouting.board.Item curr_item : item_list) { + if (curr_item instanceof net.freerouting.board.Trace) { int curr_layer = ((net.freerouting.board.Trace) curr_item).get_layer(); layer_contains_wires_arr[curr_layer] = true; - } - else if (curr_item instanceof net.freerouting.board.ConductionArea) - { + } else if (curr_item instanceof net.freerouting.board.ConductionArea) { conduction_area_list.add((net.freerouting.board.ConductionArea) curr_item); } } @@ -148,56 +118,45 @@ else if (curr_item instanceof net.freerouting.board.ConductionArea) net.freerouting.board.BoardOutline board_outline = routing_board.get_outline(); double board_area = 0; - for (int i = 0; i < board_outline.shape_count(); ++i) - { + for (int i = 0; i < board_outline.shape_count(); ++i) { net.freerouting.geometry.planar.TileShape[] curr_piece_arr = board_outline.get_shape(i).split_to_convex(); - if (curr_piece_arr != null) - { - for (net.freerouting.geometry.planar.TileShape curr_piece : curr_piece_arr) - { + if (curr_piece_arr != null) { + for (net.freerouting.geometry.planar.TileShape curr_piece : curr_piece_arr) { board_area += curr_piece.area(); } } } - for (net.freerouting.board.ConductionArea curr_conduction_area : conduction_area_list) - { + for (net.freerouting.board.ConductionArea curr_conduction_area : conduction_area_list) { int layer_no = curr_conduction_area.get_layer(); - if (layer_contains_wires_arr[layer_no]) - { + if (layer_contains_wires_arr[layer_no]) { continue; } net.freerouting.board.Layer curr_layer = routing_board.layer_structure.arr[layer_no]; - if (!curr_layer.is_signal || layer_no == 0 || layer_no == board_layer_structure.arr.length - 1) - { + if (!curr_layer.is_signal || layer_no == 0 || layer_no == board_layer_structure.arr.length - 1) { continue; } net.freerouting.geometry.planar.TileShape[] convex_pieces = curr_conduction_area.get_area().split_to_convex(); double curr_area = 0; - for (net.freerouting.geometry.planar.TileShape curr_piece : convex_pieces) - { + for (net.freerouting.geometry.planar.TileShape curr_piece : convex_pieces) { curr_area += curr_piece.area(); } - if (curr_area < 0.5 * board_area) - { + if (curr_area < 0.5 * board_area) { // skip conduction areas not covering most of the board continue; } - for (int i = 0; i < curr_conduction_area.net_count(); ++i) - { + for (int i = 0; i < curr_conduction_area.net_count(); ++i) { net.freerouting.rules.Net curr_net = routing_board.rules.nets.get(curr_conduction_area.get_net_no(i)); curr_net.set_contains_plane(true); nothing_changed = false; } changed_layer_arr[layer_no] = true; - if (curr_conduction_area.get_fixed_state().ordinal() < net.freerouting.board.FixedState.USER_FIXED.ordinal()) - { + if (curr_conduction_area.get_fixed_state().ordinal() < net.freerouting.board.FixedState.USER_FIXED.ordinal()) { curr_conduction_area.set_fixed_state(net.freerouting.board.FixedState.USER_FIXED); } } - if (nothing_changed) - { + if (nothing_changed) { return false; } // Adjust the layer prefered directions in the autoroute settings. @@ -206,14 +165,10 @@ else if (curr_item instanceof net.freerouting.board.ConductionArea) int layer_count = routing_board.get_layer_count(); boolean curr_preferred_direction_is_horizontal = autoroute_settings.get_preferred_direction_is_horizontal(0); - for (int i = 0; i < layer_count; ++i) - { - if (changed_layer_arr[i]) - { + for (int i = 0; i < layer_count; ++i) { + if (changed_layer_arr[i]) { autoroute_settings.set_layer_active(i, false); - } - else if (autoroute_settings.get_layer_active(i)) - { + } else if (autoroute_settings.get_layer_active(i)) { autoroute_settings.set_preferred_direction_is_horizontal(i, curr_preferred_direction_is_horizontal); curr_preferred_direction_is_horizontal = !curr_preferred_direction_is_horizontal; } @@ -227,31 +182,23 @@ else if (autoroute_settings.get_layer_active(i)) * If p_compat_mode is true, only standard speecctra dsn scopes are written, so that any * host system with an specctra interface can read them. */ - public static boolean write(net.freerouting.interactive.BoardHandling p_board_handling, java.io.OutputStream p_file, String p_design_name, boolean p_compat_mode) - { + public static boolean write(net.freerouting.interactive.BoardHandling p_board_handling, java.io.OutputStream p_file, String p_design_name, boolean p_compat_mode) { //tests.Validate.check("before writing dsn", p_board); IndentFileWriter output_file = new IndentFileWriter(p_file); - if (output_file == null) - { + if (output_file == null) { System.out.println("unable to write dsn file"); return false; } - try - { + try { write_pcb_scope(p_board_handling, output_file, p_design_name, p_compat_mode); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to write dsn file"); return false; } - try - { + try { output_file.close(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to close dsn file"); return false; } @@ -259,13 +206,12 @@ public static boolean write(net.freerouting.interactive.BoardHandling p_board_ha } private static void write_pcb_scope(net.freerouting.interactive.BoardHandling p_board_handling, IndentFileWriter p_file, String p_design_name, boolean p_compat_mode) - throws java.io.IOException - { + throws java.io.IOException { BasicBoard routing_board = p_board_handling.get_routing_board(); WriteScopeParameter write_scope_parameter = new WriteScopeParameter(routing_board, p_board_handling.settings.autoroute_settings, p_file, - routing_board.communication.specctra_parser_info.string_quote, - routing_board.communication.coordinate_transform, p_compat_mode); + routing_board.communication.specctra_parser_info.string_quote, + routing_board.communication.coordinate_transform, p_compat_mode); p_file.start_scope(); p_file.write("PCB "); @@ -282,146 +228,112 @@ private static void write_pcb_scope(net.freerouting.interactive.BoardHandling p_ p_file.end_scope(); } - static boolean read_on_off_scope(Scanner p_scanner) - { - try - { + static boolean read_on_off_scope(Scanner p_scanner) { + try { Object next_token = p_scanner.next_token(); boolean result = false; - if (next_token == Keyword.ON) - { + if (next_token == Keyword.ON) { result = true; - } - else if (next_token != Keyword.OFF) - { + } else if (next_token != Keyword.OFF) { System.out.println("DsnFile.read_boolean: Keyword.OFF expected"); } ScopeKeyword.skip_scope(p_scanner); return result; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("DsnFile.read_boolean: IO error scanning file"); return false; } } - static int read_integer_scope(Scanner p_scanner) - { - try - { + static int read_integer_scope(Scanner p_scanner) { + try { int value; Object next_token = p_scanner.next_token(); - if (next_token instanceof Integer) - { + if (next_token instanceof Integer) { value = ((Integer) next_token).intValue(); - } - else - { + } else { System.out.println("DsnFile.read_integer_scope: number expected"); return 0; } next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("DsnFile.read_integer_scope: closing bracket expected"); return 0; } return value; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("DsnFile.read_integer_scope: IO error scanning file"); return 0; } } - static double read_float_scope(Scanner p_scanner) - { - try - { + static double read_float_scope(Scanner p_scanner) { + try { double value; Object next_token = p_scanner.next_token(); - if (next_token instanceof Double) - { + if (next_token instanceof Double) { value = ((Double) next_token).doubleValue(); - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { value = ((Integer) next_token).intValue(); - } - else - { + } else { System.out.println("DsnFile.read_float_scope: number expected"); return 0; } next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("DsnFile.read_float_scope: closing bracket expected"); return 0; } return value; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("DsnFile.read_float_scope: IO error scanning file"); return 0; } } - public static String read_string_scope(Scanner p_scanner) - { - try - { + public static String read_string_scope(Scanner p_scanner) { + try { p_scanner.yybegin(SpecctraFileScanner.NAME); Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("DsnFile:read_string_scope: String expected"); return null; } String result = (String) next_token; next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("DsnFile.read_string_scope: closing bracket expected"); } return result; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("DsnFile.read_string_scope: IO error scanning file"); return null; } } - public static java.util.Collection read_string_list_scope(Scanner p_scanner) - { + public static java.util.Collection read_string_list_scope(Scanner p_scanner) { java.util.Collection result = new java.util.LinkedList(); - try - { - for (;;) - { + try { + for (; ; ) { p_scanner.yybegin(SpecctraFileScanner.NAME); Object next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("DsnFileread_string_list_scope: string expected"); return null; } result.add((String) next_token); } - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("DsnFile.read_string_list_scope: IO error scanning file"); } return result; } - static final String CLASS_CLEARANCE_SEPARATOR = "-"; + + public enum ReadResult { + + OK, OUTLINE_MISSING, ERROR + } } diff --git a/src/main/java/net/freerouting/designformats/specctra/Keyword.java b/src/main/java/net/freerouting/designformats/specctra/Keyword.java index c7810289..40fa5873 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Keyword.java +++ b/src/main/java/net/freerouting/designformats/specctra/Keyword.java @@ -22,14 +22,13 @@ /** * Enumeration class for keywords of the specctra dsn file format * - * @author alfons + * @author alfons */ -public class Keyword -{ +public class Keyword { /** * The only instances of the internal classes: - * + *

* ScopeKeywords with an inividual read_scope method are defined in an extra class, */ public static final Keyword ABSOLUTE = new Keyword("absolute"); @@ -136,20 +135,20 @@ public class Keyword public static final Keyword WIRE = new Keyword("wire"); public static final ScopeKeyword WIRING_SCOPE = new Wiring(); public static final Keyword WRITE_RESOLUTION = new Keyword("write_resolution"); + private final String name; + + /** + * prevents creating more instances + */ + protected Keyword(String p_name) { + name = p_name; + } /** * Returns the name string of this Keyword. * The name is used for debugging purposes. */ - public String get_name() - { + public String get_name() { return name; } - private final String name; - - /** prevents creating more instances */ - protected Keyword(String p_name) - { - name = p_name; - } } diff --git a/src/main/java/net/freerouting/designformats/specctra/Layer.java b/src/main/java/net/freerouting/designformats/specctra/Layer.java index 558be4e7..7982422c 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Layer.java +++ b/src/main/java/net/freerouting/designformats/specctra/Layer.java @@ -27,15 +27,21 @@ /** * Describes a layer in a Specctra dsn file. * - * @author alfons + * @author alfons */ -public class Layer -{ - /** all layers of the board */ +public class Layer { + /** + * all layers of the board + */ public static final Layer PCB = new Layer("pcb", -1, false); - /** the signal layers */ + /** + * the signal layers + */ public static final Layer SIGNAL = new Layer("signal", -1, true); - + public final String name; + public final int no; + public final boolean is_signal; + public final java.util.Collection net_names; /** * Creates a new instance of Layer. * p_no is the physical layer number starting with 0 at the component side @@ -44,14 +50,12 @@ public class Layer * For Layer objects describing more than 1 layer the number is -1. * p_net_names is a list of nets for this layer, if the layer is a power plane. */ - public Layer(String p_name, int p_no, boolean p_is_signal, Collection p_net_names) - { + public Layer(String p_name, int p_no, boolean p_is_signal, Collection p_net_names) { name = p_name; no = p_no; is_signal = p_is_signal; net_names = p_net_names; } - /** * Creates a new instance of Layer. * p_no is the physical layer number starting with 0 at the component side @@ -59,42 +63,32 @@ public Layer(String p_name, int p_no, boolean p_is_signal, Collection p_ * If p_is_signal, the layer is a signal layer, otherwise it is a powerground layer. * For Layer objects describing more than 1 layer the number is -1. */ - public Layer(String p_name, int p_no, boolean p_is_signal) - { + public Layer(String p_name, int p_no, boolean p_is_signal) { name = p_name; no = p_no; is_signal = p_is_signal; net_names = new LinkedList(); } - + /** * Writes a layer scope in the stucture scope. */ public static void write_scope(WriteScopeParameter p_par, int p_layer_no, - boolean p_write_rule) throws java.io.IOException - { + boolean p_write_rule) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("layer "); net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[p_layer_no]; p_par.identifier_type.write(board_layer.name, p_par.file); p_par.file.new_line(); p_par.file.write("(type "); - if (board_layer.is_signal) - { + if (board_layer.is_signal) { p_par.file.write("signal)"); - } - else - { + } else { p_par.file.write("power)"); } - if (p_write_rule) - { + if (p_write_rule) { Rule.write_default_rule(p_par, p_layer_no); } p_par.file.end_scope(); } - public final String name; - public final int no; - public final boolean is_signal; - public final java.util.Collection net_names; } diff --git a/src/main/java/net/freerouting/designformats/specctra/LayerStructure.java b/src/main/java/net/freerouting/designformats/specctra/LayerStructure.java index e0e71e4f..ffddfcfa 100644 --- a/src/main/java/net/freerouting/designformats/specctra/LayerStructure.java +++ b/src/main/java/net/freerouting/designformats/specctra/LayerStructure.java @@ -25,18 +25,19 @@ /** * Describes a layer structure read from a dsn file. * - * @author alfons + * @author alfons */ -public class LayerStructure -{ +public class LayerStructure { - /** Creates a new instance of LayerStructure from a list of layers*/ - public LayerStructure(Collection p_layer_list) - { + public final Layer[] arr; + + /** + * Creates a new instance of LayerStructure from a list of layers + */ + public LayerStructure(Collection p_layer_list) { arr = new Layer[p_layer_list.size()]; Iterator it = p_layer_list.iterator(); - for (int i = 0; i < arr.length; ++i) - { + for (int i = 0; i < arr.length; ++i) { arr[i] = it.next(); } } @@ -44,11 +45,9 @@ public LayerStructure(Collection p_layer_list) /** * Creates a dsn-LayerStructure from a board LayerStructure. */ - public LayerStructure(net.freerouting.board.LayerStructure p_board_layer_structure) - { + public LayerStructure(net.freerouting.board.LayerStructure p_board_layer_structure) { arr = new Layer[p_board_layer_structure.arr.length]; - for (int i = 0; i < arr.length; ++i) - { + for (int i = 0; i < arr.length; ++i) { net.freerouting.board.Layer board_layer = p_board_layer_structure.arr[i]; arr[i] = new Layer(board_layer.name, i, board_layer.is_signal); } @@ -58,34 +57,26 @@ public LayerStructure(net.freerouting.board.LayerStructure p_board_layer_structu * returns the number of the layer with the name p_name, * -1, if no layer with name p_name exists. */ - public int get_no(String p_name) - { - for (int i = 0; i < arr.length; ++i) - { - if (p_name.equals(arr[i].name)) - { + public int get_no(String p_name) { + for (int i = 0; i < arr.length; ++i) { + if (p_name.equals(arr[i].name)) { return i; } } // check for special layers of the Electra autorouter used for the outline - if (p_name.contains("Top")) - { + if (p_name.contains("Top")) { return 0; } - if (p_name.contains("Bottom")) - { + if (p_name.contains("Bottom")) { return arr.length - 1; } return -1; } - public int signal_layer_count() - { + public int signal_layer_count() { int result = 0; - for (Layer curr_layer : arr) - { - if (curr_layer.is_signal) - { + for (Layer curr_layer : arr) { + if (curr_layer.is_signal) { ++result; } } @@ -95,21 +86,15 @@ public int signal_layer_count() /** * Returns, if the net with name p_net_name contains a powwer plane. */ - public boolean contains_plane(String p_net_name) - { + public boolean contains_plane(String p_net_name) { - for (Layer curr_layer : arr) - { - if (!curr_layer.is_signal) - { - if (curr_layer.net_names.contains(p_net_name)) - { + for (Layer curr_layer : arr) { + if (!curr_layer.is_signal) { + if (curr_layer.net_names.contains(p_net_name)) { return true; } } } return false; } - - public final Layer[] arr; } diff --git a/src/main/java/net/freerouting/designformats/specctra/Library.java b/src/main/java/net/freerouting/designformats/specctra/Library.java index f99ba58f..8b0b4d08 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Library.java +++ b/src/main/java/net/freerouting/designformats/specctra/Library.java @@ -21,9 +21,9 @@ package net.freerouting.designformats.specctra; import net.freerouting.geometry.planar.IntVector; -import net.freerouting.geometry.planar.Vector; import net.freerouting.geometry.planar.PolygonShape; import net.freerouting.geometry.planar.Simplex; +import net.freerouting.geometry.planar.Vector; import java.util.Collection; import java.util.Iterator; @@ -33,226 +33,56 @@ /** * Class for reading and writing library scopes from dsn-files. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Library extends ScopeKeyword -{ - - /** Creates a new instance of Library */ - public Library() - { +public class Library extends ScopeKeyword { + + /** + * Creates a new instance of Library + */ + public Library() { super("net/freerouting/library"); } - - public boolean read_scope(ReadScopeParameter p_par) - { - net.freerouting.board.RoutingBoard board = p_par.board_handling.get_routing_board(); - board.library.padstacks = new net.freerouting.library.Padstacks(p_par.board_handling.get_routing_board().layer_structure); - Collection package_list = new LinkedList(); - Object next_token = null; - for (;;) - { - Object prev_token = next_token; - try - { - next_token = p_par.scanner.next_token(); - } - catch (java.io.IOException e) - { - System.out.println("Library.read_scope: IO error scanning file"); - System.out.println(e); - return false; - } - if (next_token == null) - { - System.out.println("Library.read_scope: unexpected end of file"); - return false; - } - if (next_token == CLOSED_BRACKET) - { - // end of scope - break; - } - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.PADSTACK) - { - if (!read_padstack_scope(p_par.scanner, p_par.layer_structure, - p_par.coordinate_transform, board.library.padstacks)) - { - return false; - } - } - else if (next_token == Keyword.IMAGE) - { - Package curr_package = Package.read_scope(p_par.scanner, p_par.layer_structure); - if (curr_package == null) - { - return false; - } - package_list.add(curr_package); - } - else - { - skip_scope(p_par.scanner); - } - } - } - - // Set the via padstacks. - if (p_par.via_padstack_names != null) - { - net.freerouting.library.Padstack[] via_padstacks = new net.freerouting.library.Padstack[p_par.via_padstack_names.size()]; - Iterator it = p_par.via_padstack_names.iterator(); - int found_padstack_count = 0; - for (int i = 0; i < via_padstacks.length; ++i) - { - String curr_padstack_name = it.next(); - net.freerouting.library.Padstack curr_padstack = board.library.padstacks.get(curr_padstack_name); - if (curr_padstack != null) - { - via_padstacks[found_padstack_count] = curr_padstack; - ++found_padstack_count; - } - else - { - System.out.print("Library.read_scope: via padstack with name "); - System.out.print(curr_padstack_name); - System.out.println(" not found"); - } - } - if (found_padstack_count != via_padstacks.length) - { - // Some via padstacks were not found in the padstacks scope of the dsn-file. - net.freerouting.library.Padstack[] corrected_padstacks = new net.freerouting.library.Padstack[found_padstack_count]; - System.arraycopy(via_padstacks, 0, corrected_padstacks, 0, found_padstack_count); - via_padstacks = corrected_padstacks; - } - board.library.set_via_padstacks(via_padstacks); - } - - // Create the library packages on the board - board.library.packages = new net.freerouting.library.Packages(board.library.padstacks); - Iterator it = package_list.iterator(); - while (it.hasNext()) - { - Package curr_package = it.next(); - net.freerouting.library.Package.Pin[] pin_arr = new net.freerouting.library.Package.Pin[curr_package.pin_info_arr.length]; - for (int i = 0; i < pin_arr.length; ++i) - { - Package.PinInfo pin_info = curr_package.pin_info_arr[i]; - int rel_x = (int) Math.round(p_par.coordinate_transform.dsn_to_board(pin_info.rel_coor[0])); - int rel_y = (int) Math.round(p_par.coordinate_transform.dsn_to_board(pin_info.rel_coor[1])); - Vector rel_coor = new IntVector(rel_x, rel_y); - net.freerouting.library.Padstack board_padstack = board.library.padstacks.get(pin_info.padstack_name); - if (board_padstack == null) - { - System.out.println("Library.read_scope: board padstack not found"); - return false; - } - pin_arr[i] = new net.freerouting.library.Package.Pin(pin_info.pin_name, board_padstack.no, rel_coor, pin_info.rotation); - } - net.freerouting.geometry.planar.Shape[] outline_arr = new net.freerouting.geometry.planar.Shape[curr_package.outline.size()]; - - Iterator it3 = curr_package.outline.iterator(); - for (int i = 0; i < outline_arr.length; ++i) - { - Shape curr_shape = it3.next(); - if (curr_shape != null) - { - outline_arr[i] = curr_shape.transform_to_board_rel(p_par.coordinate_transform); - } - else - { - System.out.println("Library.read_scope: outline shape is null"); - } - } - generate_missing_keepout_names("keepout_", curr_package.keepouts); - generate_missing_keepout_names("via_keepout_", curr_package.via_keepouts); - generate_missing_keepout_names("place_keepout_", curr_package.place_keepouts); - net.freerouting.library.Package.Keepout [] keepout_arr = new net.freerouting.library.Package.Keepout [curr_package.keepouts.size()]; - Iterator it2 = curr_package.keepouts.iterator(); - for (int i = 0; i < keepout_arr.length; ++i) - { - Shape.ReadAreaScopeResult curr_keepout = it2.next(); - Layer curr_layer = curr_keepout.shape_list.iterator().next().layer; - net.freerouting.geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); - keepout_arr[i] = new net.freerouting.library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); - } - net.freerouting.library.Package.Keepout [] via_keepout_arr = new net.freerouting.library.Package.Keepout [curr_package.via_keepouts.size()]; - it2 = curr_package.via_keepouts.iterator(); - for (int i = 0; i < via_keepout_arr.length; ++i) - { - Shape.ReadAreaScopeResult curr_keepout = it2.next(); - Layer curr_layer = (curr_keepout.shape_list.iterator().next()).layer; - net.freerouting.geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); - via_keepout_arr[i] = new net.freerouting.library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); - } - net.freerouting.library.Package.Keepout [] place_keepout_arr = new net.freerouting.library.Package.Keepout [curr_package.place_keepouts.size()]; - it2 = curr_package.place_keepouts.iterator(); - for (int i = 0; i < place_keepout_arr.length; ++i) - { - Shape.ReadAreaScopeResult curr_keepout = it2.next(); - Layer curr_layer = (curr_keepout.shape_list.iterator().next()).layer; - net.freerouting.geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); - place_keepout_arr[i] = new net.freerouting.library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); - } - board.library.packages.add(curr_package.name, pin_arr, outline_arr, - keepout_arr, via_keepout_arr, place_keepout_arr, curr_package.is_front); - } - return true; - } - - public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException - { + + public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("net/freerouting/library"); - for (int i = 1; i <= p_par.board.library.packages.count(); ++i) - { + for (int i = 1; i <= p_par.board.library.packages.count(); ++i) { Package.write_scope(p_par, p_par.board.library.packages.get(i)); } - for (int i = 1; i <= p_par.board.library.padstacks.count(); ++i) - { + for (int i = 1; i <= p_par.board.library.padstacks.count(); ++i) { write_padstack_scope(p_par, p_par.board.library.padstacks.get(i)); } p_par.file.end_scope(); } - - public static void write_padstack_scope(WriteScopeParameter p_par, net.freerouting.library.Padstack p_padstack) throws java.io.IOException - { + + public static void write_padstack_scope(WriteScopeParameter p_par, net.freerouting.library.Padstack p_padstack) throws java.io.IOException { // search the layer range of the padstack int first_layer_no = 0; - while (first_layer_no < p_par.board.get_layer_count()) - { - if (p_padstack.get_shape(first_layer_no) != null) - { + while (first_layer_no < p_par.board.get_layer_count()) { + if (p_padstack.get_shape(first_layer_no) != null) { break; } ++first_layer_no; } int last_layer_no = p_par.board.get_layer_count() - 1; - while (last_layer_no >= 0 ) - { - if (p_padstack.get_shape(last_layer_no) != null) - { + while (last_layer_no >= 0) { + if (p_padstack.get_shape(last_layer_no) != null) { break; } --last_layer_no; } - if (first_layer_no >= p_par.board.get_layer_count() || last_layer_no < 0) - { + if (first_layer_no >= p_par.board.get_layer_count() || last_layer_no < 0) { System.out.println("Library.write_padstack_scope: padstack shape not found"); return; } - + p_par.file.start_scope(); p_par.file.write("padstack "); p_par.identifier_type.write(p_padstack.name, p_par.file); - for (int i = first_layer_no; i <= last_layer_no; ++i) - { + for (int i = first_layer_no; i <= last_layer_no; ++i) { net.freerouting.geometry.planar.Shape curr_board_shape = p_padstack.get_shape(i); - if (curr_board_shape == null) - { + if (curr_board_shape == null) { continue; } net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[i]; @@ -263,153 +93,115 @@ public static void write_padstack_scope(WriteScopeParameter p_par, net.freerouti curr_shape.write_scope(p_par.file, p_par.identifier_type); p_par.file.end_scope(); } - if (!p_padstack.attach_allowed) - { + if (!p_padstack.attach_allowed) { p_par.file.new_line(); p_par.file.write("(attach off)"); } - if (p_padstack.placed_absolute) - { + if (p_padstack.placed_absolute) { p_par.file.new_line(); p_par.file.write("(absolute on)"); } p_par.file.end_scope(); } - - static boolean read_padstack_scope(Scanner p_scanner, LayerStructure p_layer_structure, - CoordinateTransform p_coordinate_transform, net.freerouting.library.Padstacks p_board_padstacks) - { + + static boolean read_padstack_scope(Scanner p_scanner, LayerStructure p_layer_structure, + CoordinateTransform p_coordinate_transform, net.freerouting.library.Padstacks p_board_padstacks) { String padstack_name = null; boolean is_drilllable = true; boolean placed_absolute = false; Collection shape_list = new LinkedList(); - try - { + try { Object next_token = p_scanner.next_token(); - if (next_token instanceof String) - { + if (next_token instanceof String) { padstack_name = (String) next_token; - } - else - { + } else { System.out.println("Library.read_padstack_scope: unexpected padstack identifier"); return false; } - - while (next_token != Keyword.CLOSED_BRACKET) - { + + while (next_token != Keyword.CLOSED_BRACKET) { Object prev_token = next_token; - next_token = p_scanner.next_token(); - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.SHAPE) - { + next_token = p_scanner.next_token(); + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.SHAPE) { Shape curr_shape = Shape.read_scope(p_scanner, p_layer_structure); - if (curr_shape != null) - { + if (curr_shape != null) { shape_list.add(curr_shape); } // overread the closing bracket and unknown scopes. - Object curr_next_token = p_scanner.next_token(); - while (curr_next_token == Keyword.OPEN_BRACKET) - { + Object curr_next_token = p_scanner.next_token(); + while (curr_next_token == Keyword.OPEN_BRACKET) { ScopeKeyword.skip_scope(p_scanner); - curr_next_token = p_scanner.next_token(); + curr_next_token = p_scanner.next_token(); } - if (curr_next_token != Keyword.CLOSED_BRACKET) - { + if (curr_next_token != Keyword.CLOSED_BRACKET) { System.out.println("Library.read_padstack_scope: closing bracket expected"); return false; } - } - else if (next_token == Keyword.ATTACH) - { + } else if (next_token == Keyword.ATTACH) { is_drilllable = DsnFile.read_on_off_scope(p_scanner); - } - else if (next_token == Keyword.ABSOLUTE) - { + } else if (next_token == Keyword.ABSOLUTE) { placed_absolute = DsnFile.read_on_off_scope(p_scanner); - } - else - { + } else { ScopeKeyword.skip_scope(p_scanner); } } - + } - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Library.read_padstack_scope: IO error scanning file"); System.out.println(e); return false; } - if (p_board_padstacks.get(padstack_name) != null) - { + if (p_board_padstacks.get(padstack_name) != null) { // Padstack exists already return true; } - if (shape_list.isEmpty()) - { + if (shape_list.isEmpty()) { System.out.print("Library.read_padstack_scope: shape not found for padstack with name "); System.out.println(padstack_name); return true; } net.freerouting.geometry.planar.ConvexShape[] padstack_shapes = new net.freerouting.geometry.planar.ConvexShape[p_layer_structure.arr.length]; Iterator it = shape_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Shape pad_shape = it.next(); net.freerouting.geometry.planar.Shape curr_shape = pad_shape.transform_to_board_rel(p_coordinate_transform); net.freerouting.geometry.planar.ConvexShape convex_shape; - if (curr_shape instanceof net.freerouting.geometry.planar.ConvexShape) - { + if (curr_shape instanceof net.freerouting.geometry.planar.ConvexShape) { convex_shape = (net.freerouting.geometry.planar.ConvexShape) curr_shape; - } - else - { - if (curr_shape instanceof PolygonShape) - { - curr_shape = ((PolygonShape)curr_shape).convex_hull(); + } else { + if (curr_shape instanceof PolygonShape) { + curr_shape = ((PolygonShape) curr_shape).convex_hull(); } net.freerouting.geometry.planar.TileShape[] convex_shapes = curr_shape.split_to_convex(); - if (convex_shapes.length != 1) - { + if (convex_shapes.length != 1) { System.out.println("Library.read_padstack_scope: convex shape expected"); } convex_shape = convex_shapes[0]; - if (convex_shape instanceof Simplex) - { + if (convex_shape instanceof Simplex) { convex_shape = ((Simplex) convex_shape).simplify(); } } net.freerouting.geometry.planar.ConvexShape padstack_shape = convex_shape; - if (padstack_shape != null) - { - if (padstack_shape.dimension() < 2) - { + if (padstack_shape != null) { + if (padstack_shape.dimension() < 2) { System.out.print("Library.read_padstack_scope: shape is not an area "); // enllarge the shape a little bit, so that it is an area padstack_shape = padstack_shape.offset(1); - if (padstack_shape.dimension() < 2) - { + if (padstack_shape.dimension() < 2) { padstack_shape = null; } } } - - if (pad_shape.layer == Layer.PCB || pad_shape.layer == Layer.SIGNAL) - { - for (int i = 0; i < padstack_shapes.length; ++i) - { + + if (pad_shape.layer == Layer.PCB || pad_shape.layer == Layer.SIGNAL) { + for (int i = 0; i < padstack_shapes.length; ++i) { padstack_shapes[i] = padstack_shape; } - } - else - { + } else { int shape_layer = p_layer_structure.get_no(pad_shape.layer.name); - if (shape_layer < 0 || shape_layer >= padstack_shapes.length) - { + if (shape_layer < 0 || shape_layer >= padstack_shapes.length) { System.out.println("Library.read_padstack_scope: layer number found"); return false; } @@ -419,26 +211,149 @@ else if (next_token == Keyword.ABSOLUTE) p_board_padstacks.add(padstack_name, padstack_shapes, is_drilllable, placed_absolute); return true; } - - private void generate_missing_keepout_names(String p_keepout_type, Collection p_keepout_list) - { + + public boolean read_scope(ReadScopeParameter p_par) { + net.freerouting.board.RoutingBoard board = p_par.board_handling.get_routing_board(); + board.library.padstacks = new net.freerouting.library.Padstacks(p_par.board_handling.get_routing_board().layer_structure); + Collection package_list = new LinkedList(); + Object next_token = null; + for (; ; ) { + Object prev_token = next_token; + try { + next_token = p_par.scanner.next_token(); + } catch (java.io.IOException e) { + System.out.println("Library.read_scope: IO error scanning file"); + System.out.println(e); + return false; + } + if (next_token == null) { + System.out.println("Library.read_scope: unexpected end of file"); + return false; + } + if (next_token == CLOSED_BRACKET) { + // end of scope + break; + } + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.PADSTACK) { + if (!read_padstack_scope(p_par.scanner, p_par.layer_structure, + p_par.coordinate_transform, board.library.padstacks)) { + return false; + } + } else if (next_token == Keyword.IMAGE) { + Package curr_package = Package.read_scope(p_par.scanner, p_par.layer_structure); + if (curr_package == null) { + return false; + } + package_list.add(curr_package); + } else { + skip_scope(p_par.scanner); + } + } + } + + // Set the via padstacks. + if (p_par.via_padstack_names != null) { + net.freerouting.library.Padstack[] via_padstacks = new net.freerouting.library.Padstack[p_par.via_padstack_names.size()]; + Iterator it = p_par.via_padstack_names.iterator(); + int found_padstack_count = 0; + for (int i = 0; i < via_padstacks.length; ++i) { + String curr_padstack_name = it.next(); + net.freerouting.library.Padstack curr_padstack = board.library.padstacks.get(curr_padstack_name); + if (curr_padstack != null) { + via_padstacks[found_padstack_count] = curr_padstack; + ++found_padstack_count; + } else { + System.out.print("Library.read_scope: via padstack with name "); + System.out.print(curr_padstack_name); + System.out.println(" not found"); + } + } + if (found_padstack_count != via_padstacks.length) { + // Some via padstacks were not found in the padstacks scope of the dsn-file. + net.freerouting.library.Padstack[] corrected_padstacks = new net.freerouting.library.Padstack[found_padstack_count]; + System.arraycopy(via_padstacks, 0, corrected_padstacks, 0, found_padstack_count); + via_padstacks = corrected_padstacks; + } + board.library.set_via_padstacks(via_padstacks); + } + + // Create the library packages on the board + board.library.packages = new net.freerouting.library.Packages(board.library.padstacks); + Iterator it = package_list.iterator(); + while (it.hasNext()) { + Package curr_package = it.next(); + net.freerouting.library.Package.Pin[] pin_arr = new net.freerouting.library.Package.Pin[curr_package.pin_info_arr.length]; + for (int i = 0; i < pin_arr.length; ++i) { + Package.PinInfo pin_info = curr_package.pin_info_arr[i]; + int rel_x = (int) Math.round(p_par.coordinate_transform.dsn_to_board(pin_info.rel_coor[0])); + int rel_y = (int) Math.round(p_par.coordinate_transform.dsn_to_board(pin_info.rel_coor[1])); + Vector rel_coor = new IntVector(rel_x, rel_y); + net.freerouting.library.Padstack board_padstack = board.library.padstacks.get(pin_info.padstack_name); + if (board_padstack == null) { + System.out.println("Library.read_scope: board padstack not found"); + return false; + } + pin_arr[i] = new net.freerouting.library.Package.Pin(pin_info.pin_name, board_padstack.no, rel_coor, pin_info.rotation); + } + net.freerouting.geometry.planar.Shape[] outline_arr = new net.freerouting.geometry.planar.Shape[curr_package.outline.size()]; + + Iterator it3 = curr_package.outline.iterator(); + for (int i = 0; i < outline_arr.length; ++i) { + Shape curr_shape = it3.next(); + if (curr_shape != null) { + outline_arr[i] = curr_shape.transform_to_board_rel(p_par.coordinate_transform); + } else { + System.out.println("Library.read_scope: outline shape is null"); + } + } + generate_missing_keepout_names("keepout_", curr_package.keepouts); + generate_missing_keepout_names("via_keepout_", curr_package.via_keepouts); + generate_missing_keepout_names("place_keepout_", curr_package.place_keepouts); + net.freerouting.library.Package.Keepout[] keepout_arr = new net.freerouting.library.Package.Keepout[curr_package.keepouts.size()]; + Iterator it2 = curr_package.keepouts.iterator(); + for (int i = 0; i < keepout_arr.length; ++i) { + Shape.ReadAreaScopeResult curr_keepout = it2.next(); + Layer curr_layer = curr_keepout.shape_list.iterator().next().layer; + net.freerouting.geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); + keepout_arr[i] = new net.freerouting.library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); + } + net.freerouting.library.Package.Keepout[] via_keepout_arr = new net.freerouting.library.Package.Keepout[curr_package.via_keepouts.size()]; + it2 = curr_package.via_keepouts.iterator(); + for (int i = 0; i < via_keepout_arr.length; ++i) { + Shape.ReadAreaScopeResult curr_keepout = it2.next(); + Layer curr_layer = (curr_keepout.shape_list.iterator().next()).layer; + net.freerouting.geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); + via_keepout_arr[i] = new net.freerouting.library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); + } + net.freerouting.library.Package.Keepout[] place_keepout_arr = new net.freerouting.library.Package.Keepout[curr_package.place_keepouts.size()]; + it2 = curr_package.place_keepouts.iterator(); + for (int i = 0; i < place_keepout_arr.length; ++i) { + Shape.ReadAreaScopeResult curr_keepout = it2.next(); + Layer curr_layer = (curr_keepout.shape_list.iterator().next()).layer; + net.freerouting.geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform); + place_keepout_arr[i] = new net.freerouting.library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no); + } + board.library.packages.add(curr_package.name, pin_arr, outline_arr, + keepout_arr, via_keepout_arr, place_keepout_arr, curr_package.is_front); + } + return true; + } + + private void generate_missing_keepout_names(String p_keepout_type, Collection p_keepout_list) { boolean all_names_existing = true; - for (Shape.ReadAreaScopeResult curr_keepout : p_keepout_list) - { - if (curr_keepout.area_name == null) - { + for (Shape.ReadAreaScopeResult curr_keepout : p_keepout_list) { + if (curr_keepout.area_name == null) { all_names_existing = false; break; } } - if (all_names_existing) - { + if (all_names_existing) { return; } // generate names Integer curr_name_index = 1; - for (Shape.ReadAreaScopeResult curr_keepout : p_keepout_list) - { + for (Shape.ReadAreaScopeResult curr_keepout : p_keepout_list) { curr_keepout.area_name = p_keepout_type + curr_name_index.toString(); ++curr_name_index; } diff --git a/src/main/java/net/freerouting/designformats/specctra/Net.java b/src/main/java/net/freerouting/designformats/specctra/Net.java index 9b7fa8ac..33681c3b 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Net.java +++ b/src/main/java/net/freerouting/designformats/specctra/Net.java @@ -20,69 +20,68 @@ package net.freerouting.designformats.specctra; +import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; + import java.util.Collection; +import java.util.Iterator; import java.util.Set; import java.util.TreeSet; -import java.util.Iterator; - -import net.freerouting.datastructures.IndentFileWriter; -import net.freerouting.datastructures.IdentifierType; /** * Class for reading and writing net scopes from dsn-files. * - * @author alfons + * @author alfons */ -public class Net -{ - - /** Creates a new instance of Net */ - public Net(Id p_net_id) - { +public class Net { + + public final Id id; + /** + * List of elements of type Pin. + */ + private Set pin_list = null; + + /** + * Creates a new instance of Net + */ + public Net(Id p_net_id) { id = p_net_id; } - - public static void write_scope(WriteScopeParameter p_par, net.freerouting.rules.Net p_net, Collection p_pin_list) throws java.io.IOException - { + + public static void write_scope(WriteScopeParameter p_par, net.freerouting.rules.Net p_net, Collection p_pin_list) throws java.io.IOException { p_par.file.start_scope(); write_net_id(p_net, p_par.file, p_par.identifier_type); // write the pins scope p_par.file.start_scope(); p_par.file.write("pins"); Iterator it = p_pin_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { net.freerouting.board.Pin curr_pin = it.next(); - if (curr_pin.contains_net(p_net.net_number)) - { + if (curr_pin.contains_net(p_net.net_number)) { write_pin(p_par, curr_pin); } } p_par.file.end_scope(); p_par.file.end_scope(); } - - public static void write_net_id( net.freerouting.rules.Net p_net, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException - { + + public static void write_net_id(net.freerouting.rules.Net p_net, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.write("net "); p_identifier_type.write(p_net.name, p_file); p_file.write(" "); Integer subnet_number = p_net.subnet_number; p_file.write(subnet_number.toString()); } - - public static void write_pin(WriteScopeParameter p_par, net.freerouting.board.Pin p_pin) throws java.io.IOException - { + + public static void write_pin(WriteScopeParameter p_par, net.freerouting.board.Pin p_pin) throws java.io.IOException { net.freerouting.board.Component curr_component = p_par.board.components.get(p_pin.get_component_no()); - if (curr_component == null) - { + if (curr_component == null) { System.out.println("Net.write_scope: component not found"); return; } net.freerouting.library.Package.Pin lib_pin = curr_component.get_package().get_pin(p_pin.get_index_in_package()); - if (lib_pin == null) - { + if (lib_pin == null) { System.out.println("Net.write_scope: pin number out of range"); return; } @@ -90,73 +89,57 @@ public static void write_pin(WriteScopeParameter p_par, net.freerouting.board.Pi p_par.identifier_type.write(curr_component.name, p_par.file); p_par.file.write("-"); p_par.identifier_type.write(lib_pin.name, p_par.file); - + } - - public void set_pins(Collection p_pin_list) - { + + public Set get_pins() { + return pin_list; + } + + public void set_pins(Collection p_pin_list) { pin_list = new TreeSet(); - for (Pin curr_pin : p_pin_list) - { + for (Pin curr_pin : p_pin_list) { pin_list.add(curr_pin); } } - - public Set get_pins() - { - return pin_list; - } - - public final Id id; - - /** List of elements of type Pin. */ - private Set pin_list = null; - - public static class Id implements Comparable - { - public Id(String p_name, int p_subnet_number) - { + + public static class Id implements Comparable { + public final String name; + public final int subnet_number; + + public Id(String p_name, int p_subnet_number) { name = p_name; subnet_number = p_subnet_number; } - - public int compareTo(Id p_other) - { + + public int compareTo(Id p_other) { int result = this.name.compareTo(p_other.name); - if (result == 0) - { + if (result == 0) { result = this.subnet_number - p_other.subnet_number; } return result; } - - public final String name; - public final int subnet_number; } - - + + /** * Sorted tuple of component name and pin name. */ - public static class Pin implements Comparable - { - public Pin(String p_component_name, String p_pin_name) - { + public static class Pin implements Comparable { + public final String component_name; + public final String pin_name; + + public Pin(String p_component_name, String p_pin_name) { component_name = p_component_name; pin_name = p_pin_name; } - - public int compareTo(Pin p_other) - { + + public int compareTo(Pin p_other) { int result = this.component_name.compareTo(p_other.component_name); - if (result == 0) - { + if (result == 0) { result = this.pin_name.compareTo(p_other.pin_name); } return result; } - - public final String component_name; - public final String pin_name; } } \ No newline at end of file diff --git a/src/main/java/net/freerouting/designformats/specctra/NetClass.java b/src/main/java/net/freerouting/designformats/specctra/NetClass.java index af7da4bf..3ad07360 100644 --- a/src/main/java/net/freerouting/designformats/specctra/NetClass.java +++ b/src/main/java/net/freerouting/designformats/specctra/NetClass.java @@ -28,19 +28,48 @@ * * @author alfons */ -public class NetClass -{ - - public static NetClass read_scope(Scanner p_scanner) - { - - try - { +public class NetClass { + + public final String name; + public final String trace_clearance_class; + public final Collection net_list; + public final Collection rules; + public final Collection layer_rules; + public final Collection use_via; + public final Collection use_layer; + public final String via_rule; + public final boolean shove_fixed; + public final boolean pull_tight; + public final double min_trace_length; + public final double max_trace_length; + /** + * Creates a new instance of NetClass + */ + public NetClass(String p_name, String p_trace_clearance_class, Collection p_net_list, + Collection p_rules, Collection p_layer_rules, Collection p_use_via, + Collection p_use_layer, String p_via_rule, boolean p_shove_fixed, boolean p_pull_tight, + double p_min_trace_length, double p_max_trace_length) { + name = p_name; + trace_clearance_class = p_trace_clearance_class; + net_list = p_net_list; + rules = p_rules; + layer_rules = p_layer_rules; + use_via = p_use_via; + use_layer = p_use_layer; + via_rule = p_via_rule; + shove_fixed = p_shove_fixed; + pull_tight = p_pull_tight; + min_trace_length = p_min_trace_length; + max_trace_length = p_max_trace_length; + } + + public static NetClass read_scope(Scanner p_scanner) { + + try { // read the class name p_scanner.yybegin(SpecctraFileScanner.NAME); Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("NetClass.read_scope: String expected"); return null; } @@ -48,21 +77,17 @@ public static NetClass read_scope(Scanner p_scanner) Collection net_list = new LinkedList(); boolean rules_missing = false; // read the nets belonging to the class - for (;;) - { + for (; ; ) { p_scanner.yybegin(SpecctraFileScanner.NAME); next_token = p_scanner.next_token(); - if (next_token == Keyword.OPEN_BRACKET) - { + if (next_token == Keyword.OPEN_BRACKET) { break; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { rules_missing = true; break; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("NetClass.read_scope: String expected"); return null; } @@ -78,172 +103,100 @@ public static NetClass read_scope(Scanner p_scanner) boolean shove_fixed = false; double min_trace_length = 0; double max_trace_length = 0; - if (!rules_missing) - { + if (!rules_missing) { Object prev_token = next_token; - for (;;) - { + for (; ; ) { next_token = p_scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { System.out.println("NetClass.read_scope: unexpected end of file"); return null; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.RULE) - { + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.RULE) { rules.addAll(Rule.read_scope(p_scanner)); - } - else if (next_token == Keyword.LAYER_RULE) - { + } else if (next_token == Keyword.LAYER_RULE) { layer_rules.add(Rule.read_layer_rule_scope(p_scanner)); - } - else if (next_token == Keyword.VIA_RULE) - { + } else if (next_token == Keyword.VIA_RULE) { via_rule = DsnFile.read_string_scope(p_scanner); - } - else if (next_token == Keyword.CIRCUIT) - { + } else if (next_token == Keyword.CIRCUIT) { Circuit.ReadScopeResult curr_rule = Circuit.read_scope(p_scanner); - if (curr_rule != null) - { + if (curr_rule != null) { max_trace_length = curr_rule.max_length; min_trace_length = curr_rule.min_length; use_via.addAll(curr_rule.use_via); use_layer.addAll(curr_rule.use_layer); } - } - else if (next_token == Keyword.CLEARANCE_CLASS) - { + } else if (next_token == Keyword.CLEARANCE_CLASS) { trace_clearance_class = DsnFile.read_string_scope(p_scanner); - if (trace_clearance_class == null) - { + if (trace_clearance_class == null) { return null; } - } - else if (next_token == Keyword.SHOVE_FIXED) - { + } else if (next_token == Keyword.SHOVE_FIXED) { shove_fixed = DsnFile.read_on_off_scope(p_scanner); - } - else if (next_token == Keyword.PULL_TIGHT) - { + } else if (next_token == Keyword.PULL_TIGHT) { pull_tight = DsnFile.read_on_off_scope(p_scanner); - } - else - { + } else { ScopeKeyword.skip_scope(p_scanner); } } prev_token = next_token; } } - return new NetClass(class_name, trace_clearance_class, net_list, rules, layer_rules, + return new NetClass(class_name, trace_clearance_class, net_list, rules, layer_rules, use_via, use_layer, via_rule, shove_fixed, pull_tight, min_trace_length, max_trace_length); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("NetClass.read_scope: IO error while scanning file"); return null; } } - - public static ClassClass read_class_class_scope(Scanner p_scanner) - { - try - { + + public static ClassClass read_class_class_scope(Scanner p_scanner) { + try { Collection classes = new LinkedList(); Collection rules = new LinkedList(); Collection layer_rules = new LinkedList(); Object prev_token = null; - for (;;) - { + for (; ; ) { Object next_token = p_scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { System.out.println("ClassClass.read_scope: unexpected end of file"); return null; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.CLASSES) - { + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.CLASSES) { classes.addAll(DsnFile.read_string_list_scope(p_scanner)); - } - else if (next_token == Keyword.RULE) - { + } else if (next_token == Keyword.RULE) { rules.addAll(Rule.read_scope(p_scanner)); - } - else if (next_token == Keyword.LAYER_RULE) - { + } else if (next_token == Keyword.LAYER_RULE) { layer_rules.add(Rule.read_layer_rule_scope(p_scanner)); } } prev_token = next_token; } return new ClassClass(classes, rules, layer_rules); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("NetClass.read_scope: IO error while scanning file"); return null; } } - - /** Creates a new instance of NetClass */ - public NetClass(String p_name, String p_trace_clearance_class, Collection p_net_list, - Collection p_rules, Collection p_layer_rules, Collection p_use_via, - Collection p_use_layer, String p_via_rule, boolean p_shove_fixed, boolean p_pull_tight, - double p_min_trace_length, double p_max_trace_length) - { - name = p_name; - trace_clearance_class = p_trace_clearance_class; - net_list = p_net_list; - rules = p_rules; - layer_rules = p_layer_rules; - use_via = p_use_via; - use_layer = p_use_layer; - via_rule = p_via_rule; - shove_fixed = p_shove_fixed; - pull_tight = p_pull_tight; - min_trace_length = p_min_trace_length; - max_trace_length = p_max_trace_length; - } - - public final String name; - public final String trace_clearance_class; - public final Collection net_list; - public final Collection rules; - public final Collection layer_rules; - public final Collection use_via; - public final Collection use_layer; - public final String via_rule; - public final boolean shove_fixed; - public final boolean pull_tight; - public final double min_trace_length; - public final double max_trace_length; - - public static class ClassClass - { - public ClassClass( Collection p_class_names, Collection p_rules, - Collection p_layer_rules) - { + + public static class ClassClass { + public final Collection class_names; + public final Collection rules; + public final Collection layer_rules; + public ClassClass(Collection p_class_names, Collection p_rules, + Collection p_layer_rules) { class_names = p_class_names; rules = p_rules; layer_rules = p_layer_rules; } - public final Collection class_names; - public final Collection rules; - public final Collection layer_rules; } } diff --git a/src/main/java/net/freerouting/designformats/specctra/NetList.java b/src/main/java/net/freerouting/designformats/specctra/NetList.java index 48a7fcd6..65e9aa80 100644 --- a/src/main/java/net/freerouting/designformats/specctra/NetList.java +++ b/src/main/java/net/freerouting/designformats/specctra/NetList.java @@ -20,81 +20,69 @@ package net.freerouting.designformats.specctra; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.TreeMap; -import java.util.Set; +import java.util.*; /** * Describes a list of nets sorted by its names. * The net number is generated internally. * - * @author alfons + * @author alfons */ -public class NetList -{ - +public class NetList { + + /** + * The entries of this map are of type Net, the keys are the net_ids. + */ + private final Map nets = new TreeMap(); + /** * Returns true, if the netlist contains a net with the input name. */ - public boolean contains(Net.Id p_net_id) - { + public boolean contains(Net.Id p_net_id) { return nets.containsKey(p_net_id); } - + /** * Adds a new net mit the input name to the net list. * Returns null, if a net with p_name already exists in the net list. * In this case no new net is added. */ - public Net add_net(Net.Id p_net_id) - { + public Net add_net(Net.Id p_net_id) { Net result; - if (nets.containsKey(p_net_id)) - { + if (nets.containsKey(p_net_id)) { result = null; - } - else - { + } else { result = new Net(p_net_id); nets.put(p_net_id, result); } return result; } - + /** * Returns the net with the input name, or null, * if the netlist does not contain a net with the input name. */ - public Net get_net(Net.Id p_net_id) - { + public Net get_net(Net.Id p_net_id) { Object value = nets.get(p_net_id); return ((Net) value); } - + /** * Returns all nets in this net list containing the input pin. */ - public Collection get_nets(String p_component_name, String p_pin_name) - { + public Collection get_nets(String p_component_name, String p_pin_name) { Collection result = new java.util.LinkedList(); Net.Pin search_pin = new Net.Pin(p_component_name, p_pin_name); - Collection net_list = nets.values(); + Collection net_list = nets.values(); Iterator it = net_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Net curr_net = it.next(); Set net_pins = curr_net.get_pins(); - if (net_pins != null && net_pins.contains(search_pin)) - { + if (net_pins != null && net_pins.contains(search_pin)) { result.add(curr_net); } } return result; } - - /** The entries of this map are of type Net, the keys are the net_ids. */ - private final Map nets = new TreeMap(); - + } diff --git a/src/main/java/net/freerouting/designformats/specctra/Network.java b/src/main/java/net/freerouting/designformats/specctra/Network.java index 87c7758d..da56e1fc 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Network.java +++ b/src/main/java/net/freerouting/designformats/specctra/Network.java @@ -19,130 +19,39 @@ */ package net.freerouting.designformats.specctra; +import net.freerouting.board.RoutingBoard; +import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; import net.freerouting.geometry.planar.IntPoint; import net.freerouting.geometry.planar.Point; import net.freerouting.geometry.planar.Vector; +import net.freerouting.rules.BoardRules; +import net.freerouting.rules.DefaultItemClearanceClasses.ItemClass; import java.util.Collection; +import java.util.Iterator; import java.util.LinkedList; import java.util.Set; -import java.util.Iterator; - -import net.freerouting.datastructures.IndentFileWriter; -import net.freerouting.datastructures.IdentifierType; - -import net.freerouting.rules.BoardRules; -import net.freerouting.rules.DefaultItemClearanceClasses.ItemClass; -import net.freerouting.board.RoutingBoard; /** * Class for reading and writing net network from dsn-files. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Network extends ScopeKeyword -{ +public class Network extends ScopeKeyword { - /** Creates a new instance of Network */ - public Network() - { + /** + * Creates a new instance of Network + */ + public Network() { super("network"); } - public boolean read_scope(ReadScopeParameter p_par) - { - Collection classes = new LinkedList(); - Collection class_class_list = new LinkedList(); - Collection via_infos = new LinkedList(); - Collection> via_rules = new LinkedList>(); - Object next_token = null; - for (;;) - { - Object prev_token = next_token; - try - { - next_token = p_par.scanner.next_token(); - } catch (java.io.IOException e) - { - System.out.println("Network.read_scope: IO error scanning file"); - System.out.println(e); - return false; - } - if (next_token == null) - { - System.out.println("Network.read_scope: unexpected end of file"); - return false; - } - if (next_token == CLOSED_BRACKET) - { - // end of scope - break; - } - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.NET) - { - read_net_scope(p_par.scanner, p_par.netlist, p_par.board_handling.get_routing_board(), - p_par.coordinate_transform, p_par.layer_structure, p_par.board_handling.get_locale()); - } - else if (next_token == Keyword.VIA) - { - net.freerouting.rules.ViaInfo curr_via_info = read_via_info(p_par.scanner, p_par.board_handling.get_routing_board()); - if (curr_via_info == null) - { - return false; - } - via_infos.add(curr_via_info); - } - else if (next_token == Keyword.VIA_RULE) - { - Collection curr_via_rule = read_via_rule(p_par.scanner, p_par.board_handling.get_routing_board()); - if (curr_via_rule == null) - { - return false; - } - via_rules.add(curr_via_rule); - } - else if (next_token == Keyword.CLASS) - { - NetClass curr_class = NetClass.read_scope(p_par.scanner); - if (curr_class == null) - { - return false; - } - classes.add(curr_class); - } - else if (next_token == Keyword.CLASS_CLASS) - { - NetClass.ClassClass curr_class_class = NetClass.read_class_class_scope(p_par.scanner); - if (curr_class_class == null) - { - return false; - } - class_class_list.add(curr_class_class); - } - else - { - skip_scope(p_par.scanner); - } - } - } - insert_via_infos(via_infos, p_par.board_handling.get_routing_board(), p_par.via_at_smd_allowed); - insert_via_rules(via_rules, p_par.board_handling.get_routing_board()); - insert_net_classes(classes, p_par); - insert_class_pairs(class_class_list, p_par); - insert_compoments(p_par); - insert_logical_parts(p_par); - return true; - } - - public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException - { + public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("network"); Collection board_pins = p_par.board.get_pins(); - for (int i = 1; i <= p_par.board.rules.nets.max_net_no(); ++i) - { + for (int i = 1; i <= p_par.board.rules.nets.max_net_no(); ++i) { Net.write_scope(p_par, p_par.board.rules.nets.get(i), board_pins); } write_via_infos(p_par.board.rules, p_par.file, p_par.identifier_type); @@ -152,10 +61,8 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep } public static void write_via_infos(net.freerouting.rules.BoardRules p_rules, IndentFileWriter p_file, IdentifierType p_identifier_type) - throws java.io.IOException - { - for (int i = 0; i < p_rules.via_infos.count(); ++i) - { + throws java.io.IOException { + for (int i = 0; i < p_rules.via_infos.count(); ++i) { net.freerouting.rules.ViaInfo curr_via = p_rules.via_infos.get(i); p_file.start_scope(); p_file.write("via "); @@ -165,8 +72,7 @@ public static void write_via_infos(net.freerouting.rules.BoardRules p_rules, Ind p_identifier_type.write(curr_via.get_padstack().name, p_file); p_file.write(" "); p_identifier_type.write(p_rules.clearance_matrix.get_name(curr_via.get_clearance_class()), p_file); - if (curr_via.attach_smd_allowed()) - { + if (curr_via.attach_smd_allowed()) { p_file.write(" attach"); } p_file.end_scope(); @@ -174,16 +80,13 @@ public static void write_via_infos(net.freerouting.rules.BoardRules p_rules, Ind } public static void write_via_rules(net.freerouting.rules.BoardRules p_rules, IndentFileWriter p_file, IdentifierType p_identifier_type) - throws java.io.IOException - { - for (net.freerouting.rules.ViaRule curr_rule : p_rules.via_rules) - { + throws java.io.IOException { + for (net.freerouting.rules.ViaRule curr_rule : p_rules.via_rules) { p_file.start_scope(); p_file.write("via_rule"); p_file.new_line(); p_identifier_type.write(curr_rule.name, p_file); - for (int i = 0; i < curr_rule.via_count(); ++i) - { + for (int i = 0; i < curr_rule.via_count(); ++i) { p_file.write(" "); p_identifier_type.write(curr_rule.get_via(i).get_name(), p_file); } @@ -192,32 +95,24 @@ public static void write_via_rules(net.freerouting.rules.BoardRules p_rules, Ind } public static void write_net_classes(WriteScopeParameter p_par) - throws java.io.IOException - { - for (int i = 0; i < p_par.board.rules.net_classes.count(); ++i) - { + throws java.io.IOException { + for (int i = 0; i < p_par.board.rules.net_classes.count(); ++i) { write_net_class(p_par.board.rules.net_classes.get(i), p_par); } } public static void write_net_class(net.freerouting.rules.NetClass p_net_class, WriteScopeParameter p_par) - throws java.io.IOException - { + throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("class "); p_par.identifier_type.write(p_net_class.get_name(), p_par.file); final int nets_per_row = 8; int net_counter = 0; - for (int i = 1; i <= p_par.board.rules.nets.max_net_no(); ++i) - { - if (p_par.board.rules.nets.get(i).get_class() == p_net_class) - { - if (net_counter % nets_per_row == 0) - { + for (int i = 1; i <= p_par.board.rules.nets.max_net_no(); ++i) { + if (p_par.board.rules.nets.get(i).get_class() == p_net_class) { + if (net_counter % nets_per_row == 0) { p_par.file.new_line(); - } - else - { + } else { p_par.file.write(" "); } p_par.identifier_type.write(p_par.board.rules.nets.get(i).name, p_par.file); @@ -240,14 +135,12 @@ public static void write_net_class(net.freerouting.rules.NetClass p_net_class, W write_circuit(p_net_class, p_par); - if (!p_net_class.get_pull_tight()) - { + if (!p_net_class.get_pull_tight()) { p_par.file.new_line(); p_par.file.write("(pull_tight off)"); } - if (p_net_class.is_shove_fixed()) - { + if (p_net_class.is_shove_fixed()) { p_par.file.new_line(); p_par.file.write("(shove_fixed on)"); } @@ -256,8 +149,7 @@ public static void write_net_class(net.freerouting.rules.NetClass p_net_class, W } private static void write_circuit(net.freerouting.rules.NetClass p_net_class, WriteScopeParameter p_par) - throws java.io.IOException - { + throws java.io.IOException { double min_trace_length = p_net_class.get_minimum_trace_length(); double max_trace_length = p_net_class.get_maximum_trace_length(); p_par.file.start_scope(); @@ -265,37 +157,28 @@ private static void write_circuit(net.freerouting.rules.NetClass p_net_class, Wr p_par.file.new_line(); p_par.file.write("(use_layer"); int layer_count = p_net_class.layer_count(); - for (int i = 0; i < layer_count; ++i) - { - if (p_net_class.is_active_routing_layer(i)) - { + for (int i = 0; i < layer_count; ++i) { + if (p_net_class.is_active_routing_layer(i)) { p_par.file.write(" "); p_par.file.write(p_par.board.layer_structure.arr[i].name); } } p_par.file.write(")"); - if (min_trace_length > 0 || max_trace_length > 0) - { + if (min_trace_length > 0 || max_trace_length > 0) { p_par.file.new_line(); p_par.file.write("(length "); Double transformed_max_length; - if (max_trace_length <= 0) - { + if (max_trace_length <= 0) { transformed_max_length = (double) -1; - } - else - { + } else { transformed_max_length = p_par.coordinate_transform.board_to_dsn(max_trace_length); } p_par.file.write(transformed_max_length.toString()); p_par.file.write(" "); Double transformed_min_length; - if (min_trace_length <= 0) - { + if (min_trace_length <= 0) { transformed_min_length = (double) 0; - } - else - { + } else { transformed_min_length = p_par.coordinate_transform.board_to_dsn(min_trace_length); } p_par.file.write(transformed_min_length.toString()); @@ -304,193 +187,18 @@ private static void write_circuit(net.freerouting.rules.NetClass p_net_class, Wr p_par.file.end_scope(); } - private boolean read_net_scope(Scanner p_scanner, NetList p_net_list, RoutingBoard p_board, - CoordinateTransform p_coordinate_transform, LayerStructure p_layer_structure, java.util.Locale p_locale) - { - // read the net name - Object next_token; - try - { - next_token = p_scanner.next_token(); - } catch (java.io.IOException e) - { - System.out.println("Network.read_net_scope: IO error while scanning file"); - return false; - } - if (!(next_token instanceof String)) - { - System.out.println("Network.read_net_scope: String expected"); - return false; - } - String net_name = (String) next_token; - int subnet_number = 1; - try - { - next_token = p_scanner.next_token(); - } catch (java.io.IOException e) - { - System.out.println("Network.read_net_scope: IO error while scanning file"); - return false; - } - boolean scope_is_empty = (next_token == CLOSED_BRACKET); - if (next_token instanceof Integer) - { - subnet_number = ((Integer) next_token).intValue(); - } - boolean pin_order_found = false; - Collection pin_list = new LinkedList(); - Collection net_rules = new LinkedList(); - Collection> subnet_pin_lists = new LinkedList>(); - if (!scope_is_empty) - { - for (;;) - { - Object prev_token = next_token; - try - { - next_token = p_scanner.next_token(); - } catch (java.io.IOException e) - { - System.out.println("Network.read_net_scope: IO error scanning file"); - return false; - } - if (next_token == null) - { - System.out.println("Network.read_net_scope: unexpected end of file"); - return false; - } - if (next_token == CLOSED_BRACKET) - { - // end of scope - break; - } - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.PINS) - { - if (!read_net_pins(p_scanner, pin_list)) - { - return false; - } - } - else if (next_token == Keyword.ORDER) - { - pin_order_found = true; - if (!read_net_pins(p_scanner, pin_list)) - { - return false; - } - } - else if (next_token == Keyword.FROMTO) - { - Set curr_subnet_pin_list = new java.util.TreeSet(); - if (!read_net_pins(p_scanner, curr_subnet_pin_list)) - { - return false; - } - subnet_pin_lists.add(curr_subnet_pin_list); - } - else if (next_token == Keyword.RULE) - { - net_rules.addAll(Rule.read_scope(p_scanner)); - } - else if (next_token == Keyword.LAYER_RULE) - { - System.out.println("Netwark.read_net_scope: layer_rule not yet implemented"); - skip_scope(p_scanner); - } - else - { - skip_scope(p_scanner); - } - } - } - } - if (subnet_pin_lists.isEmpty()) - { - if (pin_order_found) - { - subnet_pin_lists = create_ordered_subnets(pin_list); - } - else - { - subnet_pin_lists.add(pin_list); - } - } - for (Collection curr_pin_list : subnet_pin_lists) - { - Net.Id net_id = new Net.Id(net_name, subnet_number); - if (!p_net_list.contains(net_id)) - { - Net new_net = p_net_list.add_net(net_id); - boolean contains_plane = p_layer_structure.contains_plane(net_name); - if (new_net != null) - { - p_board.rules.nets.add(new_net.id.name, new_net.id.subnet_number, contains_plane); - } - } - Net curr_subnet = p_net_list.get_net(net_id); - if (curr_subnet == null) - { - System.out.println("Network.read_net_scope: net not found in netlist"); - return false; - } - curr_subnet.set_pins(curr_pin_list); - if (!net_rules.isEmpty()) - { - // Evaluate the net rules. - net.freerouting.rules.Net board_net = p_board.rules.nets.get(curr_subnet.id.name, curr_subnet.id.subnet_number); - if (board_net == null) - { - System.out.println("Network.read_net_scope: board net not found"); - return false; - } - Iterator it = net_rules.iterator(); - while (it.hasNext()) - { - Rule curr_ob = it.next(); - if (curr_ob instanceof Rule.WidthRule) - { - net.freerouting.rules.NetClass default_net_rule = p_board.rules.get_default_net_class(); - double wire_width = ((Rule.WidthRule) curr_ob).value; - int trace_halfwidth = (int) Math.round(p_coordinate_transform.dsn_to_board(wire_width) / 2); - net.freerouting.rules.NetClass net_rule = - p_board.rules.net_classes.find(trace_halfwidth, default_net_rule.get_trace_clearance_class(), - default_net_rule.get_via_rule()); - if (net_rule == null) - { - // create a new net rule - net_rule = p_board.rules.get_new_net_class(p_locale); - } - net_rule.set_trace_half_width(trace_halfwidth); - board_net.set_class(net_rule); - } - else - { - System.out.println("Network.read_net_scope: Rule not yet implemented"); - } - } - } - ++subnet_number; - } - return true; - } - /** * Creates a sequence of subnets with 2 pins from p_pin_list */ - private static Collection> create_ordered_subnets(Collection p_pin_list) - { + private static Collection> create_ordered_subnets(Collection p_pin_list) { Collection> result = new LinkedList>(); - if (p_pin_list.isEmpty()) - { + if (p_pin_list.isEmpty()) { return result; } Iterator it = p_pin_list.iterator(); Net.Pin prev_pin = it.next(); - while (it.hasNext()) - { + while (it.hasNext()) { Net.Pin next_pin = it.next(); Set curr_subnet_pin_list = new java.util.TreeSet(); curr_subnet_pin_list.add(prev_pin); @@ -501,43 +209,34 @@ private static Collection> create_ordered_subnets(Collection return result; } - private static boolean read_net_pins(Scanner p_scanner, Collection p_pin_list) - { + private static boolean read_net_pins(Scanner p_scanner, Collection p_pin_list) { Object next_token; - for (;;) - { - try - { + for (; ; ) { + try { p_scanner.yybegin(SpecctraFileScanner.COMPONENT_NAME); next_token = p_scanner.next_token(); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Network.read_net_pins: IO error while scanning file"); return false; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Network.read_net_pins: String expected"); return false; } String component_name = (String) next_token; - try - { + try { p_scanner.yybegin(SpecctraFileScanner.SPEC_CHAR); next_token = p_scanner.next_token(); // overread the hyphen p_scanner.yybegin(SpecctraFileScanner.NAME); next_token = p_scanner.next_token(); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Network.read_net_pins: IO error while scanning file"); return false; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Network.read_net_pins: String expected"); return false; } @@ -548,33 +247,27 @@ private static boolean read_net_pins(Scanner p_scanner, Collection p_pi return true; } - static net.freerouting.rules.ViaInfo read_via_info(Scanner p_scanner, net.freerouting.board.BasicBoard p_board) - { - try - { + static net.freerouting.rules.ViaInfo read_via_info(Scanner p_scanner, net.freerouting.board.BasicBoard p_board) { + try { p_scanner.yybegin(SpecctraFileScanner.NAME); Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Network.read_via_info: string expected"); return null; } String name = (String) next_token; p_scanner.yybegin(SpecctraFileScanner.NAME); next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Network.read_via_info: string expected"); return null; } String padstack_name = (String) next_token; net.freerouting.library.Padstack via_padstack = p_board.library.get_via_padstack(padstack_name); - if (via_padstack == null) - { + if (via_padstack == null) { // The padstack may not yet be inserted into the list of via padstacks via_padstack = p_board.library.padstacks.get(padstack_name); - if (via_padstack == null) - { + if (via_padstack == null) { System.out.println("Network.read_via_info: padstack not found"); return null; } @@ -582,100 +275,79 @@ static net.freerouting.rules.ViaInfo read_via_info(Scanner p_scanner, net.freero } p_scanner.yybegin(SpecctraFileScanner.NAME); next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Network.read_via_info: string expected"); return null; } int clearance_class = p_board.rules.clearance_matrix.get_no((String) next_token); - if (clearance_class < 0) - { + if (clearance_class < 0) { // Clearance class not stored, because it is identical to the default clearance class. clearance_class = BoardRules.default_clearance_class(); } boolean attach_allowed = false; next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { - if (next_token != Keyword.ATTACH) - { + if (next_token != Keyword.CLOSED_BRACKET) { + if (next_token != Keyword.ATTACH) { System.out.println("Network.read_via_info: Keyword.ATTACH expected"); return null; } attach_allowed = true; next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Network.read_via_info: closing bracket expected"); return null; } } return new net.freerouting.rules.ViaInfo(name, via_padstack, clearance_class, attach_allowed, p_board.rules); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Network.read_via_info: IO error while scanning file"); return null; } } - static Collection read_via_rule(Scanner p_scanner, net.freerouting.board.BasicBoard p_board) - { - try - { + static Collection read_via_rule(Scanner p_scanner, net.freerouting.board.BasicBoard p_board) { + try { Collection result = new LinkedList(); - for (;;) - { + for (; ; ) { p_scanner.yybegin(SpecctraFileScanner.NAME); Object next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Network.read_via_rule: string expected"); return null; } result.add((String) next_token); } return result; - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Network.read_via_rule: IO error while scanning file"); return null; } } - private static void insert_via_infos(Collection p_via_infos, RoutingBoard p_board, boolean p_attach_allowed) - { - if (p_via_infos.size() > 0) - { - for (net.freerouting.rules.ViaInfo curr_info : p_via_infos) - { + private static void insert_via_infos(Collection p_via_infos, RoutingBoard p_board, boolean p_attach_allowed) { + if (p_via_infos.size() > 0) { + for (net.freerouting.rules.ViaInfo curr_info : p_via_infos) { p_board.rules.via_infos.add(curr_info); } - } - else // no via infos found, create default via infos from the via padstacks. + } else // no via infos found, create default via infos from the via padstacks. { create_default_via_infos(p_board, p_board.rules.get_default_net_class(), p_attach_allowed); } } - private static void create_default_via_infos(net.freerouting.board.BasicBoard p_board, net.freerouting.rules.NetClass p_net_class, boolean p_attach_allowed) - { + private static void create_default_via_infos(net.freerouting.board.BasicBoard p_board, net.freerouting.rules.NetClass p_net_class, boolean p_attach_allowed) { int cl_class = p_net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.VIA); boolean is_default_class = (p_net_class == p_board.rules.get_default_net_class()); - for (int i = 0; i < p_board.library.via_padstack_count(); ++i) - { + for (int i = 0; i < p_board.library.via_padstack_count(); ++i) { net.freerouting.library.Padstack curr_padstack = p_board.library.get_via_padstack(i); boolean attach_allowed = p_attach_allowed && curr_padstack.attach_allowed; String via_name; - if (is_default_class) - { + if (is_default_class) { via_name = curr_padstack.name; - } - else - { + } else { via_name = curr_padstack.name + DsnFile.CLASS_CLEARANCE_SEPARATOR + p_net_class.get_name(); } net.freerouting.rules.ViaInfo found_via_info = @@ -684,26 +356,20 @@ private static void create_default_via_infos(net.freerouting.board.BasicBoard p_ } } - private static void insert_via_rules(Collection> p_via_rules, net.freerouting.board.BasicBoard p_board) - { + private static void insert_via_rules(Collection> p_via_rules, net.freerouting.board.BasicBoard p_board) { boolean rule_found = false; - for (Collection curr_list : p_via_rules) - { - if (curr_list.size() < 2) - { + for (Collection curr_list : p_via_rules) { + if (curr_list.size() < 2) { continue; } - if (add_via_rule(curr_list, p_board)) - { + if (add_via_rule(curr_list, p_board)) { rule_found = true; } } - if (!rule_found) - { + if (!rule_found) { p_board.rules.create_default_via_rule(p_board.rules.get_default_net_class(), "default"); } - for (int i = 0; i < p_board.rules.net_classes.count(); ++i) - { + for (int i = 0; i < p_board.rules.net_classes.count(); ++i) { p_board.rules.net_classes.get(i).set_via_rule(p_board.rules.get_default_via_rule()); } } @@ -712,30 +378,23 @@ private static void insert_via_rules(Collection> p_via_rules, * Inserts a via rule into the board. * Replaces an already existing via rule with the same */ - static boolean add_via_rule(Collection p_name_list, net.freerouting.board.BasicBoard p_board) - { + static boolean add_via_rule(Collection p_name_list, net.freerouting.board.BasicBoard p_board) { Iterator it = p_name_list.iterator(); String rule_name = it.next(); net.freerouting.rules.ViaRule existing_rule = p_board.rules.get_via_rule(rule_name); net.freerouting.rules.ViaRule curr_rule = new net.freerouting.rules.ViaRule(rule_name); boolean rule_ok = true; - while (it.hasNext()) - { + while (it.hasNext()) { net.freerouting.rules.ViaInfo curr_via = p_board.rules.via_infos.get(it.next()); - if (curr_via != null) - { + if (curr_via != null) { curr_rule.append_via(curr_via); - } - else - { + } else { System.out.println("Network.insert_via_rules: via_info not found"); rule_ok = false; } } - if (rule_ok) - { - if (existing_rule != null) - { + if (rule_ok) { + if (existing_rule != null) { // Replace already existing rule. p_board.rules.via_rules.remove(existing_rule); } @@ -744,56 +403,41 @@ static boolean add_via_rule(Collection p_name_list, net.freerouting.boar return rule_ok; } - private static void insert_net_classes(Collection p_net_classes, ReadScopeParameter p_par) - { + private static void insert_net_classes(Collection p_net_classes, ReadScopeParameter p_par) { net.freerouting.board.BasicBoard routing_board = p_par.board_handling.get_routing_board(); - for (NetClass curr_class : p_net_classes) - { + for (NetClass curr_class : p_net_classes) { insert_net_class(curr_class, p_par.layer_structure, routing_board, p_par.coordinate_transform, p_par.via_at_smd_allowed); } } static void insert_net_class(NetClass p_class, LayerStructure p_layer_structure, net.freerouting.board.BasicBoard p_board, CoordinateTransform p_coordinate_transform, - boolean p_via_at_smd_allowed) - { + boolean p_via_at_smd_allowed) { net.freerouting.rules.NetClass board_net_class = p_board.rules.append_net_class(p_class.name); - if (p_class.trace_clearance_class != null) - { + if (p_class.trace_clearance_class != null) { int trace_clearance_class = p_board.rules.clearance_matrix.get_no(p_class.trace_clearance_class); - if (trace_clearance_class >= 0) - { + if (trace_clearance_class >= 0) { board_net_class.set_trace_clearance_class(trace_clearance_class); - } - else - { + } else { System.out.println("Network.insert_net_class: clearance class not found"); } } - if (p_class.via_rule != null) - { + if (p_class.via_rule != null) { net.freerouting.rules.ViaRule via_rule = p_board.rules.get_via_rule(p_class.via_rule); - if (via_rule != null) - { + if (via_rule != null) { board_net_class.set_via_rule(via_rule); - } - else - { + } else { System.out.println("Network.insert_net_class: via rule not found"); } } - if (p_class.max_trace_length > 0) - { + if (p_class.max_trace_length > 0) { board_net_class.set_maximum_trace_length(p_coordinate_transform.dsn_to_board(p_class.max_trace_length)); } - if (p_class.min_trace_length > 0) - { + if (p_class.min_trace_length > 0) { board_net_class.set_minimum_trace_length(p_coordinate_transform.dsn_to_board(p_class.min_trace_length)); } - for (String curr_net_name : p_class.net_list) - { + for (String curr_net_name : p_class.net_list) { Collection curr_net_list = p_board.rules.nets.get(curr_net_name); - for (net.freerouting.rules.Net curr_net : curr_net_list) - { + for (net.freerouting.rules.Net curr_net : curr_net_list) { curr_net.set_class(board_net_class); } } @@ -802,21 +446,15 @@ static void insert_net_class(NetClass p_class, LayerStructure p_layer_structure, boolean clearance_rule_found = false; - for (Rule curr_rule : p_class.rules) - { - if (curr_rule instanceof Rule.WidthRule) - { + for (Rule curr_rule : p_class.rules) { + if (curr_rule instanceof Rule.WidthRule) { int trace_halfwidth = (int) Math.round(p_coordinate_transform.dsn_to_board(((Rule.WidthRule) curr_rule).value / 2)); board_net_class.set_trace_half_width(trace_halfwidth); - } - else if (curr_rule instanceof Rule.ClearanceRule) - { + } else if (curr_rule instanceof Rule.ClearanceRule) { add_clearance_rule(p_board.rules.clearance_matrix, board_net_class, (Rule.ClearanceRule) curr_rule, -1, p_coordinate_transform); clearance_rule_found = true; - } - else - { + } else { System.out.println("Network.insert_net_class: rule type not yet implemented"); } @@ -824,30 +462,21 @@ else if (curr_rule instanceof Rule.ClearanceRule) // read the layer dependent rules. - for (Rule.LayerRule curr_layer_rule : p_class.layer_rules) - { - for (String curr_layer_name : curr_layer_rule.layer_names) - { + for (Rule.LayerRule curr_layer_rule : p_class.layer_rules) { + for (String curr_layer_name : curr_layer_rule.layer_names) { int layer_no = p_board.layer_structure.get_no(curr_layer_name); - if (layer_no < 0) - { + if (layer_no < 0) { System.out.println("Network.insert_net_class: layer not found"); continue; } - for (Rule curr_rule : curr_layer_rule.rules) - { - if (curr_rule instanceof Rule.WidthRule) - { + for (Rule curr_rule : curr_layer_rule.rules) { + if (curr_rule instanceof Rule.WidthRule) { int trace_halfwidth = (int) Math.round(p_coordinate_transform.dsn_to_board(((Rule.WidthRule) curr_rule).value / 2)); board_net_class.set_trace_half_width(layer_no, trace_halfwidth); - } - else if (curr_rule instanceof Rule.ClearanceRule) - { + } else if (curr_rule instanceof Rule.ClearanceRule) { add_clearance_rule(p_board.rules.clearance_matrix, board_net_class, (Rule.ClearanceRule) curr_rule, layer_no, p_coordinate_transform); clearance_rule_found = true; - } - else - { + } else { System.out.println("Network.insert_net_class: layer rule type not yet implemented"); } } @@ -858,53 +487,38 @@ else if (curr_rule instanceof Rule.ClearanceRule) board_net_class.set_shove_fixed(p_class.shove_fixed); boolean via_infos_created = false; - if (clearance_rule_found && board_net_class != p_board.rules.get_default_net_class()) - { + if (clearance_rule_found && board_net_class != p_board.rules.get_default_net_class()) { create_default_via_infos(p_board, board_net_class, p_via_at_smd_allowed); via_infos_created = true; } - if (!p_class.use_via.isEmpty()) - { + if (!p_class.use_via.isEmpty()) { create_via_rule(p_class.use_via, board_net_class, p_board, p_via_at_smd_allowed); - } - else if (via_infos_created) - { + } else if (via_infos_created) { p_board.rules.create_default_via_rule(board_net_class, board_net_class.get_name()); } - if (!p_class.use_layer.isEmpty()) - { + if (!p_class.use_layer.isEmpty()) { create_active_trace_layers(p_class.use_layer, p_layer_structure, board_net_class); } } - static private void insert_class_pairs(Collection p_class_classes, ReadScopeParameter p_par) - { - for (NetClass.ClassClass curr_class_class : p_class_classes) - { + static private void insert_class_pairs(Collection p_class_classes, ReadScopeParameter p_par) { + for (NetClass.ClassClass curr_class_class : p_class_classes) { java.util.Iterator it1 = curr_class_class.class_names.iterator(); net.freerouting.board.BasicBoard routing_board = p_par.board_handling.get_routing_board(); - while (it1.hasNext()) - { + while (it1.hasNext()) { String first_name = it1.next(); net.freerouting.rules.NetClass first_class = routing_board.rules.net_classes.get(first_name); - if (first_class == null) - { + if (first_class == null) { System.out.println("Network.insert_class_pairs: first class not found"); - } - else - { + } else { java.util.Iterator it2 = it1; - while (it2.hasNext()) - { + while (it2.hasNext()) { String second_name = it2.next(); net.freerouting.rules.NetClass second_class = routing_board.rules.net_classes.get(second_name); - if (second_class == null) - { + if (second_class == null) { System.out.println("Network.insert_class_pairs: second class not found"); - } - else - { + } else { insert_class_pair_info(curr_class_class, first_class, second_class, routing_board, p_par.coordinate_transform); } @@ -915,41 +529,29 @@ static private void insert_class_pairs(Collection p_class_c } static private void insert_class_pair_info(NetClass.ClassClass p_class_class, net.freerouting.rules.NetClass p_first_class, net.freerouting.rules.NetClass p_second_class, - net.freerouting.board.BasicBoard p_board, CoordinateTransform p_coordinate_transform) - { - for (Rule curr_rule : p_class_class.rules) - { - if (curr_rule instanceof Rule.ClearanceRule) - { + net.freerouting.board.BasicBoard p_board, CoordinateTransform p_coordinate_transform) { + for (Rule curr_rule : p_class_class.rules) { + if (curr_rule instanceof Rule.ClearanceRule) { Rule.ClearanceRule curr_clearance_rule = (Rule.ClearanceRule) curr_rule; add_mixed_clearance_rule(p_board.rules.clearance_matrix, p_first_class, p_second_class, curr_clearance_rule, -1, p_coordinate_transform); - } - else - { + } else { System.out.println("Network.insert_class_pair_info: unexpected rule"); } } - for (Rule.LayerRule curr_layer_rule : p_class_class.layer_rules) - { - for (String curr_layer_name : curr_layer_rule.layer_names) - { + for (Rule.LayerRule curr_layer_rule : p_class_class.layer_rules) { + for (String curr_layer_name : curr_layer_rule.layer_names) { int layer_no = p_board.layer_structure.get_no(curr_layer_name); - if (layer_no < 0) - { + if (layer_no < 0) { System.out.println("Network.insert_class_pair_info: layer not found"); continue; } - for (Rule curr_rule : curr_layer_rule.rules) - { - if (curr_rule instanceof Rule.ClearanceRule) - { + for (Rule curr_rule : curr_layer_rule.rules) { + if (curr_rule instanceof Rule.ClearanceRule) { add_mixed_clearance_rule(p_board.rules.clearance_matrix, p_first_class, p_second_class, (Rule.ClearanceRule) curr_rule, layer_no, p_coordinate_transform); - } - else - { + } else { System.out.println("Network.insert_class_pair_info: unexpected layer rule type"); } } @@ -958,70 +560,52 @@ static private void insert_class_pair_info(NetClass.ClassClass p_class_class, ne } static private void add_mixed_clearance_rule(net.freerouting.rules.ClearanceMatrix p_clearance_matrix, net.freerouting.rules.NetClass p_first_class, - net.freerouting.rules.NetClass p_second_class, Rule.ClearanceRule p_clearance_rule, int p_layer_no, - CoordinateTransform p_coordinate_transform) - { + net.freerouting.rules.NetClass p_second_class, Rule.ClearanceRule p_clearance_rule, int p_layer_no, + CoordinateTransform p_coordinate_transform) { int curr_clearance = (int) Math.round(p_coordinate_transform.dsn_to_board(p_clearance_rule.value)); final String first_class_name = p_first_class.get_name(); int first_class_no = p_clearance_matrix.get_no(first_class_name); - if (first_class_no < 0) - { + if (first_class_no < 0) { p_clearance_matrix.append_class(first_class_name); first_class_no = p_clearance_matrix.get_no(first_class_name); } final String second_class_name = p_second_class.get_name(); int second_class_no = p_clearance_matrix.get_no(second_class_name); - if (second_class_no < 0) - { + if (second_class_no < 0) { p_clearance_matrix.append_class(second_class_name); second_class_no = p_clearance_matrix.get_no(second_class_name); } - if (p_clearance_rule.clearance_class_pairs.isEmpty()) - { - if (p_layer_no < 0) - { + if (p_clearance_rule.clearance_class_pairs.isEmpty()) { + if (p_layer_no < 0) { p_clearance_matrix.set_value(first_class_no, second_class_no, curr_clearance); p_clearance_matrix.set_value(second_class_no, first_class_no, curr_clearance); - } - else - { + } else { p_clearance_matrix.set_value(first_class_no, second_class_no, p_layer_no, curr_clearance); p_clearance_matrix.set_value(second_class_no, first_class_no, p_layer_no, curr_clearance); } - } - else - { + } else { Iterator it = p_clearance_rule.clearance_class_pairs.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { String curr_string = it.next(); String[] curr_pair = curr_string.split("_"); - if (curr_pair.length != 2) - { + if (curr_pair.length != 2) { continue; } int curr_first_class_no; int curr_second_class_no; - for (int i = 0; i < 2; ++i) - { - if (i == 0) - { + for (int i = 0; i < 2; ++i) { + if (i == 0) { curr_first_class_no = get_clearance_class(p_clearance_matrix, p_first_class, curr_pair[0]); curr_second_class_no = get_clearance_class(p_clearance_matrix, p_second_class, curr_pair[1]); - } - else - { + } else { curr_first_class_no = get_clearance_class(p_clearance_matrix, p_second_class, curr_pair[0]); curr_second_class_no = get_clearance_class(p_clearance_matrix, p_first_class, curr_pair[1]); } - if (p_layer_no < 0) - { + if (p_layer_no < 0) { p_clearance_matrix.set_value(curr_first_class_no, curr_second_class_no, curr_clearance); p_clearance_matrix.set_value(curr_second_class_no, curr_first_class_no, curr_clearance); - } - else - { + } else { p_clearance_matrix.set_value(curr_first_class_no, curr_second_class_no, p_layer_no, curr_clearance); p_clearance_matrix.set_value(curr_second_class_no, curr_first_class_no, p_layer_no, curr_clearance); } @@ -1031,27 +615,21 @@ static private void add_mixed_clearance_rule(net.freerouting.rules.ClearanceMatr } static private void create_default_clearance_classes(net.freerouting.rules.NetClass p_net_class, - net.freerouting.rules.ClearanceMatrix p_clearance_matrix) - { + net.freerouting.rules.ClearanceMatrix p_clearance_matrix) { get_clearance_class(p_clearance_matrix, p_net_class, "via"); get_clearance_class(p_clearance_matrix, p_net_class, "smd"); get_clearance_class(p_clearance_matrix, p_net_class, "pin"); get_clearance_class(p_clearance_matrix, p_net_class, "area"); } - private static void create_via_rule(Collection p_use_via, net.freerouting.rules.NetClass p_net_class, net.freerouting.board.BasicBoard p_board, boolean p_attach_allowed) - { + private static void create_via_rule(Collection p_use_via, net.freerouting.rules.NetClass p_net_class, net.freerouting.board.BasicBoard p_board, boolean p_attach_allowed) { net.freerouting.rules.ViaRule new_via_rule = new net.freerouting.rules.ViaRule(p_net_class.get_name()); int default_via_cl_class = p_net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.VIA); - for (String curr_via_name : p_use_via) - { - for (int i = 0; i < p_board.rules.via_infos.count(); ++i) - { + for (String curr_via_name : p_use_via) { + for (int i = 0; i < p_board.rules.via_infos.count(); ++i) { net.freerouting.rules.ViaInfo curr_via_info = p_board.rules.via_infos.get(i); - if (curr_via_info.get_clearance_class() == default_via_cl_class) - { - if (curr_via_info.get_padstack().name.equals(curr_via_name)) - { + if (curr_via_info.get_clearance_class() == default_via_cl_class) { + if (curr_via_info.get_padstack().name.equals(curr_via_name)) { new_via_rule.append_via(curr_via_info); } } @@ -1061,44 +639,35 @@ private static void create_via_rule(Collection p_use_via, net.freeroutin p_net_class.set_via_rule(new_via_rule); } - private static void create_active_trace_layers(Collection p_use_layer, LayerStructure p_layer_structure, net.freerouting.rules.NetClass p_net_class) - { - for (int i = 0; i < p_layer_structure.arr.length; ++i) - { + private static void create_active_trace_layers(Collection p_use_layer, LayerStructure p_layer_structure, net.freerouting.rules.NetClass p_net_class) { + for (int i = 0; i < p_layer_structure.arr.length; ++i) { p_net_class.set_active_routing_layer(i, false); } - for (String cur_layer_name : p_use_layer) - { + for (String cur_layer_name : p_use_layer) { int curr_no = p_layer_structure.get_no(cur_layer_name); p_net_class.set_active_routing_layer(curr_no, true); } // currently all inactive layers have tracewidth 0. - for (int i = 0; i < p_layer_structure.arr.length; ++i) - { - if (!p_net_class.is_active_routing_layer(i)) - { + for (int i = 0; i < p_layer_structure.arr.length; ++i) { + if (!p_net_class.is_active_routing_layer(i)) { p_net_class.set_trace_half_width(i, 0); } } } private static void add_clearance_rule(net.freerouting.rules.ClearanceMatrix p_clearance_matrix, net.freerouting.rules.NetClass p_net_class, - Rule.ClearanceRule p_rule, int p_layer_no, CoordinateTransform p_coordinate_transform) - { + Rule.ClearanceRule p_rule, int p_layer_no, CoordinateTransform p_coordinate_transform) { int curr_clearance = (int) Math.round(p_coordinate_transform.dsn_to_board(p_rule.value)); final String class_name = p_net_class.get_name(); int class_no = p_clearance_matrix.get_no(class_name); - if (class_no < 0) - { + if (class_no < 0) { // class not yet existing, create a new class p_clearance_matrix.append_class(class_name); class_no = p_clearance_matrix.get_no(class_name); // set the clearance values of the new class to the maximum of curr_clearance and the // the existing values. - for (int i = 1; i < p_clearance_matrix.get_class_count(); ++i) - { - for (int j = 0; j < p_clearance_matrix.get_layer_count(); ++j) - { + for (int i = 1; i < p_clearance_matrix.get_class_count(); ++i) { + for (int j = 0; j < p_clearance_matrix.get_layer_count(); ++j) { int curr_value = Math.max(p_clearance_matrix.value(class_no, i, j), curr_clearance); p_clearance_matrix.set_value(class_no, i, j, curr_value); p_clearance_matrix.set_value(i, class_no, j, curr_value); @@ -1107,42 +676,32 @@ private static void add_clearance_rule(net.freerouting.rules.ClearanceMatrix p_c p_net_class.default_item_clearance_classes.set_all(class_no); } p_net_class.set_trace_clearance_class(class_no); - if (p_rule.clearance_class_pairs.isEmpty()) - { - if (p_layer_no < 0) - { + if (p_rule.clearance_class_pairs.isEmpty()) { + if (p_layer_no < 0) { p_clearance_matrix.set_value(class_no, class_no, curr_clearance); - } - else - { + } else { p_clearance_matrix.set_value(class_no, class_no, p_layer_no, curr_clearance); } return; } - if (Structure.contains_wire_clearance_pair(p_rule.clearance_class_pairs)) - { + if (Structure.contains_wire_clearance_pair(p_rule.clearance_class_pairs)) { create_default_clearance_classes(p_net_class, p_clearance_matrix); } Iterator it = p_rule.clearance_class_pairs.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { String curr_string = it.next(); String[] curr_pair = curr_string.split("_"); - if (curr_pair.length != 2) - { + if (curr_pair.length != 2) { continue; } int first_class_no = get_clearance_class(p_clearance_matrix, p_net_class, curr_pair[0]); int second_class_no = get_clearance_class(p_clearance_matrix, p_net_class, curr_pair[1]); - if (p_layer_no < 0) - { + if (p_layer_no < 0) { p_clearance_matrix.set_value(first_class_no, second_class_no, curr_clearance); p_clearance_matrix.set_value(second_class_no, first_class_no, curr_clearance); - } - else - { + } else { p_clearance_matrix.set_value(first_class_no, second_class_no, p_layer_no, curr_clearance); p_clearance_matrix.set_value(second_class_no, first_class_no, p_layer_no, curr_clearance); } @@ -1154,66 +713,50 @@ private static void add_clearance_rule(net.freerouting.rules.ClearanceMatrix p_c * Creates a new class, if that class is not yet existing. */ static private int get_clearance_class(net.freerouting.rules.ClearanceMatrix p_clearance_matrix, - net.freerouting.rules.NetClass p_net_class, String p_item_class_name) - { + net.freerouting.rules.NetClass p_net_class, String p_item_class_name) { String net_class_name = p_net_class.get_name(); String new_class_name = net_class_name; - if (!p_item_class_name.equals("wire")) - { + if (!p_item_class_name.equals("wire")) { new_class_name = new_class_name + DsnFile.CLASS_CLEARANCE_SEPARATOR + p_item_class_name; } int found_class_no = p_clearance_matrix.get_no(new_class_name); - if (found_class_no >= 0) - { + if (found_class_no >= 0) { return found_class_no; } p_clearance_matrix.append_class(new_class_name); int result = p_clearance_matrix.get_no(new_class_name); int net_class_no = p_clearance_matrix.get_no(net_class_name); - if (net_class_no < 0 || result < 0) - { + if (net_class_no < 0 || result < 0) { System.out.println("Network.get_clearance_class: clearance class not found"); return result; } // initalise the clearance values of p_new_class_name from p_net_class_name - for (int i = 1; i < p_clearance_matrix.get_class_count(); ++i) - { + for (int i = 1; i < p_clearance_matrix.get_class_count(); ++i) { - for (int j = 0; j < p_clearance_matrix.get_layer_count(); ++j) - { + for (int j = 0; j < p_clearance_matrix.get_layer_count(); ++j) { int curr_value = p_clearance_matrix.value(net_class_no, i, j); p_clearance_matrix.set_value(result, i, j, curr_value); p_clearance_matrix.set_value(i, result, j, curr_value); } } - if (p_item_class_name.equals("via")) - { + if (p_item_class_name.equals("via")) { p_net_class.default_item_clearance_classes.set(ItemClass.VIA, result); - } - else if (p_item_class_name.equals("pin")) - { + } else if (p_item_class_name.equals("pin")) { p_net_class.default_item_clearance_classes.set(ItemClass.PIN, result); - } - else if (p_item_class_name.equals("smd")) - { + } else if (p_item_class_name.equals("smd")) { p_net_class.default_item_clearance_classes.set(ItemClass.SMD, result); - } - else if (p_item_class_name.equals("area")) - { + } else if (p_item_class_name.equals("area")) { p_net_class.default_item_clearance_classes.set(ItemClass.AREA, result); } return result; } - private static void insert_compoments(ReadScopeParameter p_par) - { + private static void insert_compoments(ReadScopeParameter p_par) { Iterator it = p_par.placement_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { ComponentPlacement next_lib_component = it.next(); Iterator it2 = next_lib_component.locations.iterator(); - while (it2.hasNext()) - { + while (it2.hasNext()) { ComponentPlacement.ComponentLocation next_component = it2.next(); insert_component(next_component, next_lib_component.lib_name, p_par); } @@ -1225,54 +768,43 @@ private static void insert_compoments(ReadScopeParameter p_par) * Create the part library on the board. Can be called after the components are inserted. * Returns false, if an error occured. */ - private static boolean insert_logical_parts(ReadScopeParameter p_par) - { + private static boolean insert_logical_parts(ReadScopeParameter p_par) { net.freerouting.board.BasicBoard routing_board = p_par.board_handling.get_routing_board(); - for (PartLibrary.LogicalPart next_part : p_par.logical_parts) - { + for (PartLibrary.LogicalPart next_part : p_par.logical_parts) { net.freerouting.library.Package lib_package = search_lib_package(next_part.name, p_par.logical_part_mappings, routing_board); - if (lib_package == null) - { + if (lib_package == null) { return false; } net.freerouting.library.LogicalPart.PartPin[] board_part_pins = new net.freerouting.library.LogicalPart.PartPin[next_part.part_pins.size()]; int curr_index = 0; - for (PartLibrary.PartPin curr_part_pin : next_part.part_pins) - { + for (PartLibrary.PartPin curr_part_pin : next_part.part_pins) { int pin_no = lib_package.get_pin_no(curr_part_pin.pin_name); - if (pin_no < 0) - { + if (pin_no < 0) { System.out.println("Network.insert_logical_parts: package pin not found"); return false; } board_part_pins[curr_index] = new net.freerouting.library.LogicalPart.PartPin(pin_no, curr_part_pin.pin_name, - curr_part_pin.gate_name, curr_part_pin.gate_swap_code, - curr_part_pin.gate_pin_name, curr_part_pin.gate_pin_swap_code); + curr_part_pin.gate_name, curr_part_pin.gate_swap_code, + curr_part_pin.gate_pin_name, curr_part_pin.gate_pin_swap_code); ++curr_index; } routing_board.library.logical_parts.add(next_part.name, board_part_pins); } - for (PartLibrary.LogicalPartMapping next_mapping : p_par.logical_part_mappings) - { + for (PartLibrary.LogicalPartMapping next_mapping : p_par.logical_part_mappings) { net.freerouting.library.LogicalPart curr_logical_part = routing_board.library.logical_parts.get(next_mapping.name); { - if (curr_logical_part == null) - { + if (curr_logical_part == null) { System.out.println("Network.insert_logical_parts: logical part not found"); } } - for (String curr_cmp_name : next_mapping.components) - { + for (String curr_cmp_name : next_mapping.components) { net.freerouting.board.Component curr_component = routing_board.components.get(curr_cmp_name); - if (curr_component != null) - { + if (curr_component != null) { curr_component.set_logical_part(curr_logical_part); - } - else - { + } else { System.out.println("Network.insert_logical_parts: board component not found"); } } @@ -1285,26 +817,20 @@ private static boolean insert_logical_parts(ReadScopeParameter p_par) * Returns null, if the package was not found. */ private static net.freerouting.library.Package search_lib_package(String p_part_name, - java.util.Collection p_logical_part_mappings, net.freerouting.board.BasicBoard p_board) - { - for (PartLibrary.LogicalPartMapping curr_mapping : p_logical_part_mappings) - { - if (curr_mapping.name.equals(p_part_name)) - { - if (curr_mapping.components.isEmpty()) - { + java.util.Collection p_logical_part_mappings, net.freerouting.board.BasicBoard p_board) { + for (PartLibrary.LogicalPartMapping curr_mapping : p_logical_part_mappings) { + if (curr_mapping.name.equals(p_part_name)) { + if (curr_mapping.components.isEmpty()) { System.out.println("Network.search_lib_package: component list empty"); return null; } String component_name = curr_mapping.components.first(); - if (component_name == null) - { + if (component_name == null) { System.out.println("Network.search_lib_package: component list empty"); return null; } net.freerouting.board.Component curr_component = p_board.components.get(component_name); - if (curr_component == null) - { + if (curr_component == null) { System.out.println("Network.search_lib_package: component not found"); return null; } @@ -1321,24 +847,19 @@ private static net.freerouting.library.Package search_lib_package(String p_part_ * Inserts all board components belonging to the input library component. */ private static void insert_component(ComponentPlacement.ComponentLocation p_location, String p_lib_key, - ReadScopeParameter p_par) - { + ReadScopeParameter p_par) { net.freerouting.board.RoutingBoard routing_board = p_par.board_handling.get_routing_board(); net.freerouting.library.Package curr_front_package = routing_board.library.packages.get(p_lib_key, true); net.freerouting.library.Package curr_back_package = routing_board.library.packages.get(p_lib_key, false); - if (curr_front_package == null || curr_back_package == null) - { + if (curr_front_package == null || curr_back_package == null) { System.out.println("Network.insert_component: component package not found"); return; } IntPoint component_location; - if (p_location.coor != null) - { + if (p_location.coor != null) { component_location = p_par.coordinate_transform.dsn_to_board(p_location.coor).round(); - } - else - { + } else { component_location = null; } double rotation_in_degree = p_location.rotation; @@ -1346,84 +867,62 @@ private static void insert_component(ComponentPlacement.ComponentLocation p_loca net.freerouting.board.Component new_component = routing_board.components.add(p_location.name, component_location, rotation_in_degree, p_location.is_front, curr_front_package, curr_back_package, p_location.position_fixed); - if (component_location == null) - { + if (component_location == null) { return; // component is not yet placed. } Vector component_translation = component_location.difference_by(Point.ZERO); net.freerouting.board.FixedState fixed_state; - if (p_location.position_fixed) - { + if (p_location.position_fixed) { fixed_state = net.freerouting.board.FixedState.SYSTEM_FIXED; - } - else - { + } else { fixed_state = net.freerouting.board.FixedState.UNFIXED; } net.freerouting.library.Package curr_package = new_component.get_package(); - for (int i = 0; i < curr_package.pin_count(); ++i) - { + for (int i = 0; i < curr_package.pin_count(); ++i) { net.freerouting.library.Package.Pin curr_pin = curr_package.get_pin(i); net.freerouting.library.Padstack curr_padstack = routing_board.library.padstacks.get(curr_pin.padstack_no); - if (curr_padstack == null) - { + if (curr_padstack == null) { System.out.println("Network.insert_component: pin padstack not found"); return; } Collection pin_nets = p_par.netlist.get_nets(p_location.name, curr_pin.name); Collection net_numbers = new LinkedList(); - for (Net curr_pin_net : pin_nets) - { + for (Net curr_pin_net : pin_nets) { net.freerouting.rules.Net curr_board_net = routing_board.rules.nets.get(curr_pin_net.id.name, curr_pin_net.id.subnet_number); - if (curr_board_net == null) - { + if (curr_board_net == null) { System.out.println("Network.insert_component: board net not found"); - } - else - { + } else { net_numbers.add(curr_board_net.net_number); } } int[] net_no_arr = new int[net_numbers.size()]; int net_index = 0; - for (Integer curr_net_no : net_numbers) - { + for (Integer curr_net_no : net_numbers) { net_no_arr[net_index] = curr_net_no; ++net_index; } net.freerouting.rules.NetClass net_class; net.freerouting.rules.Net board_net; - if (net_no_arr.length > 0) - { + if (net_no_arr.length > 0) { board_net = routing_board.rules.nets.get(net_no_arr[0]); - } - else - { + } else { board_net = null; } - if (board_net != null) - { + if (board_net != null) { net_class = board_net.get_class(); - } - else - { + } else { net_class = routing_board.rules.get_default_net_class(); } int clearance_class = -1; ComponentPlacement.ItemClearanceInfo pin_info = p_location.pin_infos.get(curr_pin.name); - if (pin_info != null) - { + if (pin_info != null) { clearance_class = routing_board.rules.clearance_matrix.get_no(pin_info.clearance_class); } - if (clearance_class < 0) - { - if (curr_padstack.from_layer() == curr_padstack.to_layer()) - { + if (clearance_class < 0) { + if (curr_padstack.from_layer() == curr_padstack.to_layer()) { clearance_class = net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.SMD); - } - else - { + } else { clearance_class = net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.PIN); } } @@ -1431,91 +930,65 @@ private static void insert_component(ComponentPlacement.ComponentLocation p_loca } // insert the keepouts belonging to the package (k = 1 for via keepouts) - for (int k = 0; k <= 2; ++k) - { + for (int k = 0; k <= 2; ++k) { net.freerouting.library.Package.Keepout[] keepout_arr; java.util.Map curr_keepout_infos; - if (k == 0) - { + if (k == 0) { keepout_arr = curr_package.keepout_arr; curr_keepout_infos = p_location.keepout_infos; - } - else if (k == 1) - { + } else if (k == 1) { keepout_arr = curr_package.via_keepout_arr; curr_keepout_infos = p_location.via_keepout_infos; - } - else - { + } else { keepout_arr = curr_package.place_keepout_arr; curr_keepout_infos = p_location.place_keepout_infos; } - for (int i = 0; i < keepout_arr.length; ++i) - { + for (int i = 0; i < keepout_arr.length; ++i) { net.freerouting.library.Package.Keepout curr_keepout = keepout_arr[i]; int layer = curr_keepout.layer; - if (layer >= routing_board.get_layer_count()) - { + if (layer >= routing_board.get_layer_count()) { System.out.println("Network.insert_component: keepout layer is to big"); continue; } - if (layer >= 0 && !p_location.is_front) - { + if (layer >= 0 && !p_location.is_front) { layer = routing_board.get_layer_count() - curr_keepout.layer - 1; } int clearance_class = routing_board.rules.get_default_net_class().default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.AREA); ComponentPlacement.ItemClearanceInfo keepout_info = curr_keepout_infos.get(curr_keepout.name); - if (keepout_info != null) - { + if (keepout_info != null) { int curr_clearance_class = routing_board.rules.clearance_matrix.get_no(keepout_info.clearance_class); - if (curr_clearance_class > 0) - { + if (curr_clearance_class > 0) { clearance_class = curr_clearance_class; } } - if (layer >= 0) - { - if (k == 0) - { + if (layer >= 0) { + if (k == 0) { routing_board.insert_obstacle(curr_keepout.area, layer, component_translation, rotation_in_degree, !p_location.is_front, clearance_class, new_component.no, curr_keepout.name, fixed_state); - } - else if (k == 1) - { + } else if (k == 1) { routing_board.insert_via_obstacle(curr_keepout.area, layer, component_translation, rotation_in_degree, !p_location.is_front, clearance_class, new_component.no, curr_keepout.name, fixed_state); - } - else - { + } else { routing_board.insert_component_obstacle(curr_keepout.area, layer, component_translation, rotation_in_degree, !p_location.is_front, clearance_class, new_component.no, curr_keepout.name, fixed_state); } - } - else - { + } else { // insert the obstacle on all signal layers - for (int j = 0; j < routing_board.layer_structure.arr.length; ++j) - { - if (routing_board.layer_structure.arr[j].is_signal) - { - if (k == 0) - { + for (int j = 0; j < routing_board.layer_structure.arr.length; ++j) { + if (routing_board.layer_structure.arr[j].is_signal) { + if (k == 0) { routing_board.insert_obstacle(curr_keepout.area, j, component_translation, rotation_in_degree, !p_location.is_front, clearance_class, new_component.no, curr_keepout.name, fixed_state); - } - else if (k == 1) - { + } else if (k == 1) { routing_board.insert_via_obstacle(curr_keepout.area, j, component_translation, rotation_in_degree, !p_location.is_front, clearance_class, new_component.no, curr_keepout.name, fixed_state); - } - else - { + } else { routing_board.insert_component_obstacle(curr_keepout.area, j, component_translation, rotation_in_degree, !p_location.is_front, clearance_class, new_component.no, curr_keepout.name, fixed_state); @@ -1526,11 +999,204 @@ else if (k == 1) } } // insert the outline as component keepout - for (int i = 0; i < curr_package.outline.length; ++i) - { + for (int i = 0; i < curr_package.outline.length; ++i) { routing_board.insert_component_outline(curr_package.outline[i], p_location.is_front, component_translation, rotation_in_degree, new_component.no, fixed_state); } } + + public boolean read_scope(ReadScopeParameter p_par) { + Collection classes = new LinkedList(); + Collection class_class_list = new LinkedList(); + Collection via_infos = new LinkedList(); + Collection> via_rules = new LinkedList>(); + Object next_token = null; + for (; ; ) { + Object prev_token = next_token; + try { + next_token = p_par.scanner.next_token(); + } catch (java.io.IOException e) { + System.out.println("Network.read_scope: IO error scanning file"); + System.out.println(e); + return false; + } + if (next_token == null) { + System.out.println("Network.read_scope: unexpected end of file"); + return false; + } + if (next_token == CLOSED_BRACKET) { + // end of scope + break; + } + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.NET) { + read_net_scope(p_par.scanner, p_par.netlist, p_par.board_handling.get_routing_board(), + p_par.coordinate_transform, p_par.layer_structure, p_par.board_handling.get_locale()); + } else if (next_token == Keyword.VIA) { + net.freerouting.rules.ViaInfo curr_via_info = read_via_info(p_par.scanner, p_par.board_handling.get_routing_board()); + if (curr_via_info == null) { + return false; + } + via_infos.add(curr_via_info); + } else if (next_token == Keyword.VIA_RULE) { + Collection curr_via_rule = read_via_rule(p_par.scanner, p_par.board_handling.get_routing_board()); + if (curr_via_rule == null) { + return false; + } + via_rules.add(curr_via_rule); + } else if (next_token == Keyword.CLASS) { + NetClass curr_class = NetClass.read_scope(p_par.scanner); + if (curr_class == null) { + return false; + } + classes.add(curr_class); + } else if (next_token == Keyword.CLASS_CLASS) { + NetClass.ClassClass curr_class_class = NetClass.read_class_class_scope(p_par.scanner); + if (curr_class_class == null) { + return false; + } + class_class_list.add(curr_class_class); + } else { + skip_scope(p_par.scanner); + } + } + } + insert_via_infos(via_infos, p_par.board_handling.get_routing_board(), p_par.via_at_smd_allowed); + insert_via_rules(via_rules, p_par.board_handling.get_routing_board()); + insert_net_classes(classes, p_par); + insert_class_pairs(class_class_list, p_par); + insert_compoments(p_par); + insert_logical_parts(p_par); + return true; + } + + private boolean read_net_scope(Scanner p_scanner, NetList p_net_list, RoutingBoard p_board, + CoordinateTransform p_coordinate_transform, LayerStructure p_layer_structure, java.util.Locale p_locale) { + // read the net name + Object next_token; + try { + next_token = p_scanner.next_token(); + } catch (java.io.IOException e) { + System.out.println("Network.read_net_scope: IO error while scanning file"); + return false; + } + if (!(next_token instanceof String)) { + System.out.println("Network.read_net_scope: String expected"); + return false; + } + String net_name = (String) next_token; + int subnet_number = 1; + try { + next_token = p_scanner.next_token(); + } catch (java.io.IOException e) { + System.out.println("Network.read_net_scope: IO error while scanning file"); + return false; + } + boolean scope_is_empty = (next_token == CLOSED_BRACKET); + if (next_token instanceof Integer) { + subnet_number = ((Integer) next_token).intValue(); + } + boolean pin_order_found = false; + Collection pin_list = new LinkedList(); + Collection net_rules = new LinkedList(); + Collection> subnet_pin_lists = new LinkedList>(); + if (!scope_is_empty) { + for (; ; ) { + Object prev_token = next_token; + try { + next_token = p_scanner.next_token(); + } catch (java.io.IOException e) { + System.out.println("Network.read_net_scope: IO error scanning file"); + return false; + } + if (next_token == null) { + System.out.println("Network.read_net_scope: unexpected end of file"); + return false; + } + if (next_token == CLOSED_BRACKET) { + // end of scope + break; + } + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.PINS) { + if (!read_net_pins(p_scanner, pin_list)) { + return false; + } + } else if (next_token == Keyword.ORDER) { + pin_order_found = true; + if (!read_net_pins(p_scanner, pin_list)) { + return false; + } + } else if (next_token == Keyword.FROMTO) { + Set curr_subnet_pin_list = new java.util.TreeSet(); + if (!read_net_pins(p_scanner, curr_subnet_pin_list)) { + return false; + } + subnet_pin_lists.add(curr_subnet_pin_list); + } else if (next_token == Keyword.RULE) { + net_rules.addAll(Rule.read_scope(p_scanner)); + } else if (next_token == Keyword.LAYER_RULE) { + System.out.println("Netwark.read_net_scope: layer_rule not yet implemented"); + skip_scope(p_scanner); + } else { + skip_scope(p_scanner); + } + } + } + } + if (subnet_pin_lists.isEmpty()) { + if (pin_order_found) { + subnet_pin_lists = create_ordered_subnets(pin_list); + } else { + subnet_pin_lists.add(pin_list); + } + } + for (Collection curr_pin_list : subnet_pin_lists) { + Net.Id net_id = new Net.Id(net_name, subnet_number); + if (!p_net_list.contains(net_id)) { + Net new_net = p_net_list.add_net(net_id); + boolean contains_plane = p_layer_structure.contains_plane(net_name); + if (new_net != null) { + p_board.rules.nets.add(new_net.id.name, new_net.id.subnet_number, contains_plane); + } + } + Net curr_subnet = p_net_list.get_net(net_id); + if (curr_subnet == null) { + System.out.println("Network.read_net_scope: net not found in netlist"); + return false; + } + curr_subnet.set_pins(curr_pin_list); + if (!net_rules.isEmpty()) { + // Evaluate the net rules. + net.freerouting.rules.Net board_net = p_board.rules.nets.get(curr_subnet.id.name, curr_subnet.id.subnet_number); + if (board_net == null) { + System.out.println("Network.read_net_scope: board net not found"); + return false; + } + Iterator it = net_rules.iterator(); + while (it.hasNext()) { + Rule curr_ob = it.next(); + if (curr_ob instanceof Rule.WidthRule) { + net.freerouting.rules.NetClass default_net_rule = p_board.rules.get_default_net_class(); + double wire_width = ((Rule.WidthRule) curr_ob).value; + int trace_halfwidth = (int) Math.round(p_coordinate_transform.dsn_to_board(wire_width) / 2); + net.freerouting.rules.NetClass net_rule = + p_board.rules.net_classes.find(trace_halfwidth, default_net_rule.get_trace_clearance_class(), + default_net_rule.get_via_rule()); + if (net_rule == null) { + // create a new net rule + net_rule = p_board.rules.get_new_net_class(p_locale); + } + net_rule.set_trace_half_width(trace_halfwidth); + board_net.set_class(net_rule); + } else { + System.out.println("Network.read_net_scope: Rule not yet implemented"); + } + } + } + ++subnet_number; + } + return true; + } } diff --git a/src/main/java/net/freerouting/designformats/specctra/Package.java b/src/main/java/net/freerouting/designformats/specctra/Package.java index 484da097..9deffa8c 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Package.java +++ b/src/main/java/net/freerouting/designformats/specctra/Package.java @@ -20,24 +20,50 @@ package net.freerouting.designformats.specctra; +import net.freerouting.board.Item; + import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import net.freerouting.board.Item; - /** * Class for reading and writing package scopes from dsn-files. * - * @author alfons + * @author alfons */ -public class Package -{ - - /** Creates a new instance of Package */ +public class Package { + + public final String name; + /** + * List of objects of type PinInfo. + */ + public final PinInfo[] pin_info_arr; + /** + * The outline of the package. + */ + public final Collection outline; + /** + * Collection of keepoouts belonging to this package + */ + public final Collection keepouts; + /** + * Collection of via keepoouts belonging to this package + */ + public final Collection via_keepouts; + /** + * Collection of place keepoouts belonging to this package + */ + public final Collection place_keepouts; + /** + * If false, the package is placed on the back side of the board + */ + public final boolean is_front; + + /** + * Creates a new instance of Package + */ public Package(String p_name, PinInfo[] p_pin_info_arr, Collection p_outline, Collection p_keepouts, - Collection p_via_keepouts, Collection p_place_keepouts, boolean p_is_front) - { + Collection p_via_keepouts, Collection p_place_keepouts, boolean p_is_front) { name = p_name; pin_info_arr = p_pin_info_arr; outline = p_outline; @@ -46,134 +72,100 @@ public Package(String p_name, PinInfo[] p_pin_info_arr, Collection p_outl place_keepouts = p_place_keepouts; is_front = p_is_front; } - - public static Package read_scope(Scanner p_scanner, LayerStructure p_layer_structure) - { - try - { + + public static Package read_scope(Scanner p_scanner, LayerStructure p_layer_structure) { + try { boolean is_front = true; - Collection outline = new LinkedList(); + Collection outline = new LinkedList(); Collection keepouts = new LinkedList(); Collection via_keepouts = new LinkedList(); Collection place_keepouts = new LinkedList(); Object next_token = p_scanner.next_token(); - if ( !(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Package.read_scope: String expected"); return null; } String package_name = (String) next_token; Collection pin_info_list = new LinkedList(); - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = p_scanner.next_token(); - - if (next_token == null) - { + + if (next_token == null) { System.out.println("Package.read_scope: unexpected end of file"); return null; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.PIN) - { + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.PIN) { PinInfo next_pin = read_pin_info(p_scanner); - if (next_pin == null) - { + if (next_pin == null) { return null; } pin_info_list.add(next_pin); - } - else if (next_token == Keyword.SIDE) - { + } else if (next_token == Keyword.SIDE) { is_front = read_placement_side(p_scanner); - } - else if (next_token == Keyword.OUTLINE) - { - Shape curr_shape = Shape.read_scope(p_scanner, p_layer_structure); - if (curr_shape != null) - { + } else if (next_token == Keyword.OUTLINE) { + Shape curr_shape = Shape.read_scope(p_scanner, p_layer_structure); + if (curr_shape != null) { outline.add(curr_shape); } // overread closing bracket next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Package.read_scope: closed bracket expected"); return null; } - } - else if (next_token == Keyword.KEEPOUT) - { - Shape.ReadAreaScopeResult keepout_area = Shape.read_area_scope(p_scanner, p_layer_structure, false); - if (keepout_area != null) - { + } else if (next_token == Keyword.KEEPOUT) { + Shape.ReadAreaScopeResult keepout_area = Shape.read_area_scope(p_scanner, p_layer_structure, false); + if (keepout_area != null) { keepouts.add(keepout_area); } - } - else if (next_token == Keyword.VIA_KEEPOUT) - { - Shape.ReadAreaScopeResult keepout_area = Shape.read_area_scope(p_scanner, p_layer_structure, false); - if (keepout_area != null) - { + } else if (next_token == Keyword.VIA_KEEPOUT) { + Shape.ReadAreaScopeResult keepout_area = Shape.read_area_scope(p_scanner, p_layer_structure, false); + if (keepout_area != null) { via_keepouts.add(keepout_area); } - } - else if (next_token == Keyword.PLACE_KEEPOUT) - { - Shape.ReadAreaScopeResult keepout_area = Shape.read_area_scope(p_scanner, p_layer_structure, false); - if (keepout_area != null) - { + } else if (next_token == Keyword.PLACE_KEEPOUT) { + Shape.ReadAreaScopeResult keepout_area = Shape.read_area_scope(p_scanner, p_layer_structure, false); + if (keepout_area != null) { place_keepouts.add(keepout_area); } - } - else - { + } else { ScopeKeyword.skip_scope(p_scanner); } } } - PinInfo [] pin_info_arr = new PinInfo[pin_info_list.size()]; + PinInfo[] pin_info_arr = new PinInfo[pin_info_list.size()]; Iterator it = pin_info_list.iterator(); - for (int i = 0; i < pin_info_arr.length; ++i) - { + for (int i = 0; i < pin_info_arr.length; ++i) { pin_info_arr[i] = it.next(); } return new Package(package_name, pin_info_arr, outline, keepouts, via_keepouts, place_keepouts, is_front); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Package.read_scope: IO error scanning file"); System.out.println(e); return null; } } - - public static void write_scope(WriteScopeParameter p_par, net.freerouting.library.Package p_package) throws java.io.IOException - { + + public static void write_scope(WriteScopeParameter p_par, net.freerouting.library.Package p_package) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("image "); p_par.identifier_type.write(p_package.name, p_par.file); // write the placement side of the package p_par.file.new_line(); p_par.file.write("(side "); - if (p_package.is_front) - { + if (p_package.is_front) { p_par.file.write("front)"); - } - else - { + } else { p_par.file.write("back)"); } // write the pins of the package - for (int i = 0; i < p_package.pin_count(); ++i) - { + for (int i = 0; i < p_package.pin_count(); ++i) { net.freerouting.library.Package.Pin curr_pin = p_package.get_pin(i); p_par.file.new_line(); p_par.file.write("(pin "); @@ -181,15 +173,13 @@ public static void write_scope(WriteScopeParameter p_par, net.freerouting.librar p_par.identifier_type.write(curr_padstack.name, p_par.file); p_par.file.write(" "); p_par.identifier_type.write(curr_pin.name, p_par.file); - double [] rel_coor = p_par.coordinate_transform.board_to_dsn(curr_pin.relative_location); - for(int j = 0; j < rel_coor.length; ++j) - { + double[] rel_coor = p_par.coordinate_transform.board_to_dsn(curr_pin.relative_location); + for (int j = 0; j < rel_coor.length; ++j) { p_par.file.write(" "); p_par.file.write((new Double(rel_coor[j])).toString()); } int rotation = (int) Math.round(curr_pin.rotation_in_degree); - if (rotation != 0) - { + if (rotation != 0) { p_par.file.write("(rotate "); p_par.file.write((new Integer(rotation)).toString()); p_par.file.write(")"); @@ -197,17 +187,14 @@ public static void write_scope(WriteScopeParameter p_par, net.freerouting.librar p_par.file.write(")"); } // write the keepouts belonging to the package. - for (int i = 0; i < p_package.keepout_arr.length; ++i) - { + for (int i = 0; i < p_package.keepout_arr.length; ++i) { write_package_keepout(p_package.keepout_arr[i], p_par, false); } - for (int i = 0; i < p_package.via_keepout_arr.length; ++i) - { + for (int i = 0; i < p_package.via_keepout_arr.length; ++i) { write_package_keepout(p_package.via_keepout_arr[i], p_par, true); } // write the package outline. - for (int i = 0; i < p_package.outline.length; ++i) - { + for (int i = 0; i < p_package.outline.length; ++i) { p_par.file.start_scope(); p_par.file.write("outline"); Shape curr_outline = p_par.coordinate_transform.board_to_dsn_rel(p_package.outline[i], Layer.SIGNAL); @@ -216,90 +203,69 @@ public static void write_scope(WriteScopeParameter p_par, net.freerouting.librar } p_par.file.end_scope(); } - + private static void write_package_keepout(net.freerouting.library.Package.Keepout p_keepout, WriteScopeParameter p_par, - boolean p_is_via_keepout) throws java.io.IOException - { + boolean p_is_via_keepout) throws java.io.IOException { Layer keepout_layer; - if (p_keepout.layer >= 0) - { + if (p_keepout.layer >= 0) { net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[p_keepout.layer]; keepout_layer = new Layer(board_layer.name, p_keepout.layer, board_layer.is_signal); - } - else - { + } else { keepout_layer = Layer.SIGNAL; } net.freerouting.geometry.planar.Shape boundary_shape; - net.freerouting.geometry.planar.Shape [] holes; - if (p_keepout.area instanceof net.freerouting.geometry.planar.Shape) - { - boundary_shape = (net.freerouting.geometry.planar.Shape) p_keepout.area ; - holes = new net.freerouting.geometry.planar.Shape [0]; - } - else - { - boundary_shape = p_keepout.area .get_border(); - holes = p_keepout.area .get_holes(); + net.freerouting.geometry.planar.Shape[] holes; + if (p_keepout.area instanceof net.freerouting.geometry.planar.Shape) { + boundary_shape = (net.freerouting.geometry.planar.Shape) p_keepout.area; + holes = new net.freerouting.geometry.planar.Shape[0]; + } else { + boundary_shape = p_keepout.area.get_border(); + holes = p_keepout.area.get_holes(); } p_par.file.start_scope(); - if (p_is_via_keepout) - { + if (p_is_via_keepout) { p_par.file.write("via_keepout"); - } - else - { + } else { p_par.file.write("keepout"); } Shape dsn_shape = p_par.coordinate_transform.board_to_dsn(boundary_shape, keepout_layer); - if (dsn_shape != null) - { + if (dsn_shape != null) { dsn_shape.write_scope(p_par.file, p_par.identifier_type); } - for (int j = 0; j < holes.length; ++j) - { + for (int j = 0; j < holes.length; ++j) { Shape dsn_hole = p_par.coordinate_transform.board_to_dsn(holes[j], keepout_layer); dsn_hole.write_hole_scope(p_par.file, p_par.identifier_type); } p_par.file.end_scope(); } - - /** Reads the information of a single pin in a package. */ - private static PinInfo read_pin_info(Scanner p_scanner) - { - try - { + + /** + * Reads the information of a single pin in a package. + */ + private static PinInfo read_pin_info(Scanner p_scanner) { + try { // Read the padstack name. p_scanner.yybegin(SpecctraFileScanner.NAME); String padstack_name = null; Object next_token = p_scanner.next_token(); - if ( next_token instanceof String) - { + if (next_token instanceof String) { padstack_name = (String) next_token; - } - else if ( next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { padstack_name = ((Integer) next_token).toString(); - } - else - { + } else { System.out.println("Package.read_pin_info: String or Integer expected"); return null; } double rotation = 0; - + p_scanner.yybegin(SpecctraFileScanner.NAME); // to be able to handle pin names starting with a digit. next_token = p_scanner.next_token(); - if (next_token == Keyword.OPEN_BRACKET) - { + if (next_token == Keyword.OPEN_BRACKET) { // read the padstack rotation next_token = p_scanner.next_token(); - if (next_token == Keyword.ROTATE) - { + if (next_token == Keyword.ROTATE) { rotation = read_rotation(p_scanner); - } - else - { + } else { ScopeKeyword.skip_scope(p_scanner); } p_scanner.yybegin(SpecctraFileScanner.NAME); @@ -307,136 +273,99 @@ else if ( next_token instanceof Integer) } // Read the pin name. String pin_name = null; - if ( next_token instanceof String) - { + if (next_token instanceof String) { pin_name = (String) next_token; - } - else if ( next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { pin_name = ((Integer) next_token).toString(); - } - else - { + } else { System.out.println("Package.read_pin_info: String or Integer expected"); return null; } - - double [] pin_coor = new double [2]; - for (int i = 0; i < 2; ++i) - { + + double[] pin_coor = new double[2]; + for (int i = 0; i < 2; ++i) { next_token = p_scanner.next_token(); - if (next_token instanceof Double) - { + if (next_token instanceof Double) { pin_coor[i] = ((Double) next_token).doubleValue(); - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { pin_coor[i] = ((Integer) next_token).intValue(); - } - else - { + } else { System.out.println("Package.read_pin_info: number expected"); return null; } } // Handle scopes at the end of the pin scope. - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = p_scanner.next_token(); - - if (next_token == null) - { + + if (next_token == null) { System.out.println("Package.read_pin_info: unexpected end of file"); return null; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.ROTATE) - { + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.ROTATE) { rotation = read_rotation(p_scanner); - } - else - { + } else { ScopeKeyword.skip_scope(p_scanner); } } } return new PinInfo(padstack_name, pin_name, pin_coor, rotation); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Package.read_pin_info: IO error while scanning file"); return null; } } - - private static double read_rotation(Scanner p_scanner) - { + + private static double read_rotation(Scanner p_scanner) { double result = 0; - try - { + try { Object next_token = p_scanner.next_token(); - if (next_token instanceof Integer) - { - result = ((Integer)next_token).intValue(); - } - else if (next_token instanceof Double) - { - result = ((Double)next_token).doubleValue(); - } - else - { + if (next_token instanceof Integer) { + result = ((Integer) next_token).intValue(); + } else if (next_token instanceof Double) { + result = ((Double) next_token).doubleValue(); + } else { System.out.println("Package.read_rotation: number expected"); } // Overread The closing bracket. next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Package.read_rotation: closing bracket expected"); } - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Package.read_rotation: IO error while scanning file"); } return result; } - + /** * Writes the placements of p_package to a Specctra dsn-file. */ public static void write_placement_scope(WriteScopeParameter p_par, net.freerouting.library.Package p_package) - throws java.io.IOException - { - Collection board_items = p_par.board.get_items(); + throws java.io.IOException { + Collection board_items = p_par.board.get_items(); boolean component_found = false; - for (int i = 1; i <= p_par.board.components.count(); ++i) - { - net.freerouting.board.Component curr_component = p_par.board.components.get(i); - if (curr_component.get_package() == p_package) - { + for (int i = 1; i <= p_par.board.components.count(); ++i) { + net.freerouting.board.Component curr_component = p_par.board.components.get(i); + if (curr_component.get_package() == p_package) { // check, if not all items of the component are deleted boolean undeleted_item_found = false; Iterator it = board_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_item.get_component_no() == curr_component.no) - { + if (curr_item.get_component_no() == curr_component.no) { undeleted_item_found = true; break; } } - if (undeleted_item_found || !curr_component.is_placed()) - { - if (!component_found) - { + if (undeleted_item_found || !curr_component.is_placed()) { + if (!component_found) { // write the scope header p_par.file.start_scope(); p_par.file.write("component "); @@ -447,58 +376,47 @@ public static void write_placement_scope(WriteScopeParameter p_par, net.freerout } } } - if (component_found) - { + if (component_found) { p_par.file.end_scope(); } } - - private static boolean read_placement_side(Scanner p_scanner) throws java.io.IOException - { + + private static boolean read_placement_side(Scanner p_scanner) throws java.io.IOException { Object next_token = p_scanner.next_token(); boolean result = (next_token != Keyword.BACK); - + next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Package.read_placement_side: closing bracket expected"); } return result; } - - - public final String name; - /** List of objects of type PinInfo. */ - public final PinInfo[] pin_info_arr; - /** The outline of the package. */ - public final Collection outline; - /** Collection of keepoouts belonging to this package */ - public final Collection keepouts; - /** Collection of via keepoouts belonging to this package */ - public final Collection via_keepouts; - /** Collection of place keepoouts belonging to this package */ - public final Collection place_keepouts; - /** If false, the package is placed on the back side of the board */ - public final boolean is_front; - - - /** Describes the Iinformation of a pin in a package. */ - static public class PinInfo - { - PinInfo(String p_padstack_name, String p_pin_name, double [] p_rel_coor, double p_rotation) - { + + /** + * Describes the Iinformation of a pin in a package. + */ + static public class PinInfo { + /** + * Phe name of the pastack of this pin. + */ + public final String padstack_name; + /** + * Phe name of this pin. + */ + public final String pin_name; + /** + * The x- and y-coordinates relative to the package location. + */ + public final double[] rel_coor; + /** + * The rotation of the pin relative to the package. + */ + public final double rotation; + PinInfo(String p_padstack_name, String p_pin_name, double[] p_rel_coor, double p_rotation) { padstack_name = p_padstack_name; pin_name = p_pin_name; rel_coor = p_rel_coor; rotation = p_rotation; } - /** Phe name of the pastack of this pin. */ - public final String padstack_name; - /** Phe name of this pin. */ - public final String pin_name; - /** The x- and y-coordinates relative to the package location. */ - public final double [] rel_coor; - /** The rotation of the pin relative to the package. */ - public final double rotation; } } diff --git a/src/main/java/net/freerouting/designformats/specctra/Parser.java b/src/main/java/net/freerouting/designformats/specctra/Parser.java index da2da788..c383cbc6 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Parser.java +++ b/src/main/java/net/freerouting/designformats/specctra/Parser.java @@ -26,155 +26,65 @@ * * @author Alfons Wirtz */ -public class Parser extends ScopeKeyword -{ +public class Parser extends ScopeKeyword { - /** Creates a new instance of Parser */ - public Parser() - { + /** + * Creates a new instance of Parser + */ + public Parser() { super("parser"); } - public boolean read_scope(ReadScopeParameter p_par) - { - Object next_token = null; - for (;;) - { - Object prev_token = next_token; - try - { - next_token = p_par.scanner.next_token(); - } - catch (java.io.IOException e) - { - System.out.println("Parser.read_scope: IO error scanning file"); - return false; - } - if (next_token == null) - { - System.out.println("Parser.read_scope: unexpected end of file"); - return false; - } - if (next_token == CLOSED_BRACKET) - { - // end of scope - break; - } - boolean read_ok = true; - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.STRING_QUOTE) - { - String quote_char = read_quote_char(p_par.scanner); - if (quote_char == null) - { - return false; - } - p_par.string_quote = quote_char; - } - else if (next_token == Keyword.HOST_CAD) - { - p_par.host_cad = DsnFile.read_string_scope(p_par.scanner); - } - else if (next_token == Keyword.HOST_VERSION) - { - p_par.host_version = DsnFile.read_string_scope(p_par.scanner); - } - else if (next_token == Keyword.CONSTANT) - { - String[] curr_constant = read_constant(p_par); - if (curr_constant != null) - { - p_par.constants.add(curr_constant); - } - } - else if (next_token == Keyword.WRITE_RESOLUTION) - { - p_par.write_resolution = read_write_solution(p_par); - } - else if (next_token == Keyword.GENERATED_BY_FREEROUTE) - { - p_par.dsn_file_generated_by_host = false; - // skip the closing bracket - skip_scope(p_par.scanner); - } - else - { - skip_scope(p_par.scanner); - } - } - if (!read_ok) - { - return false; - } - } - return true; - } - - private static SpecctraParserInfo.WriteResolution read_write_solution(ReadScopeParameter p_par) - { - try - { + private static SpecctraParserInfo.WriteResolution read_write_solution(ReadScopeParameter p_par) { + try { Object next_token = p_par.scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Parser.read_write_solution: string expected"); return null; } String resolution_string = (String) next_token; next_token = p_par.scanner.next_token(); - if (!(next_token instanceof Integer)) - { + if (!(next_token instanceof Integer)) { System.out.println("Parser.read_write_solution: integer expected expected"); return null; } int resolution_value = (Integer) next_token; next_token = p_par.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Parser.read_write_solution: closing_bracket expected"); return null; } return new SpecctraParserInfo.WriteResolution(resolution_string, resolution_value); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Parser.read_write_solution: IO error scanning file"); return null; } } - private static String[] read_constant(ReadScopeParameter p_par) - { - try - { + private static String[] read_constant(ReadScopeParameter p_par) { + try { String[] result = new String[2]; p_par.scanner.yybegin(SpecctraFileScanner.NAME); Object next_token = p_par.scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Parser.read_constant: string expected"); return null; } result[0] = (String) next_token; p_par.scanner.yybegin(SpecctraFileScanner.NAME); next_token = p_par.scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Parser.read_constant: string expected"); return null; } result[1] = (String) next_token; next_token = p_par.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Parser.read_constant: closing_bracket expected"); return null; } return result; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Parser.read_constant: IO error scanning file"); return null; } @@ -184,12 +94,10 @@ private static String[] read_constant(ReadScopeParameter p_par) * p_reduced is true if the scope is written to a session file. */ public static void write_scope(net.freerouting.datastructures.IndentFileWriter p_file, SpecctraParserInfo p_parser_info, - net.freerouting.datastructures.IdentifierType p_identifier_type, boolean p_reduced) throws java.io.IOException - { + net.freerouting.datastructures.IdentifierType p_identifier_type, boolean p_reduced) throws java.io.IOException { p_file.start_scope(); p_file.write("parser"); - if (!p_reduced) - { + if (!p_reduced) { p_file.new_line(); p_file.write("(string_quote "); p_file.write(p_parser_info.string_quote); @@ -197,36 +105,30 @@ public static void write_scope(net.freerouting.datastructures.IndentFileWriter p p_file.new_line(); p_file.write("(space_in_quoted_tokens on)"); } - if (p_parser_info.host_cad != null) - { + if (p_parser_info.host_cad != null) { p_file.new_line(); p_file.write("(host_cad "); p_identifier_type.write(p_parser_info.host_cad, p_file); p_file.write(")"); } - if (p_parser_info.host_version != null) - { + if (p_parser_info.host_version != null) { p_file.new_line(); p_file.write("(host_version "); p_identifier_type.write(p_parser_info.host_version, p_file); p_file.write(")"); } - if (p_parser_info.constants != null) - { - for (String[] curr_constant : p_parser_info.constants) - { + if (p_parser_info.constants != null) { + for (String[] curr_constant : p_parser_info.constants) { p_file.new_line(); p_file.write("(constant "); - for (int i = 0; i < curr_constant.length; ++i) - { + for (int i = 0; i < curr_constant.length; ++i) { p_identifier_type.write(curr_constant[i], p_file); p_file.write(" "); } p_file.write(")"); } } - if (p_parser_info.write_resolution != null) - { + if (p_parser_info.write_resolution != null) { p_file.new_line(); p_file.write("(write_resolution "); p_file.write(p_parser_info.write_resolution.char_name.substring(0, 1)); @@ -235,37 +137,82 @@ public static void write_scope(net.freerouting.datastructures.IndentFileWriter p p_file.write(positive_int.toString()); p_file.write(")"); } - if (!p_reduced) - { + if (!p_reduced) { p_file.new_line(); p_file.write("(generated_by_freeroute)"); } p_file.end_scope(); } - private static String read_quote_char(Scanner p_scanner) - { - try - { + private static String read_quote_char(Scanner p_scanner) { + try { Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Parser.read_quote_char: string expected"); return null; } String result = (String) next_token; next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Parser.read_quote_char: closing bracket expected"); return null; } return result; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Parser.read_quote_char: IO error scanning file"); return null; } } + + public boolean read_scope(ReadScopeParameter p_par) { + Object next_token = null; + for (; ; ) { + Object prev_token = next_token; + try { + next_token = p_par.scanner.next_token(); + } catch (java.io.IOException e) { + System.out.println("Parser.read_scope: IO error scanning file"); + return false; + } + if (next_token == null) { + System.out.println("Parser.read_scope: unexpected end of file"); + return false; + } + if (next_token == CLOSED_BRACKET) { + // end of scope + break; + } + boolean read_ok = true; + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.STRING_QUOTE) { + String quote_char = read_quote_char(p_par.scanner); + if (quote_char == null) { + return false; + } + p_par.string_quote = quote_char; + } else if (next_token == Keyword.HOST_CAD) { + p_par.host_cad = DsnFile.read_string_scope(p_par.scanner); + } else if (next_token == Keyword.HOST_VERSION) { + p_par.host_version = DsnFile.read_string_scope(p_par.scanner); + } else if (next_token == Keyword.CONSTANT) { + String[] curr_constant = read_constant(p_par); + if (curr_constant != null) { + p_par.constants.add(curr_constant); + } + } else if (next_token == Keyword.WRITE_RESOLUTION) { + p_par.write_resolution = read_write_solution(p_par); + } else if (next_token == Keyword.GENERATED_BY_FREEROUTE) { + p_par.dsn_file_generated_by_host = false; + // skip the closing bracket + skip_scope(p_par.scanner); + } else { + skip_scope(p_par.scanner); + } + } + if (!read_ok) { + return false; + } + } + return true; + } } diff --git a/src/main/java/net/freerouting/designformats/specctra/PartLibrary.java b/src/main/java/net/freerouting/designformats/specctra/PartLibrary.java index 8cf9135d..7a0d5f54 100644 --- a/src/main/java/net/freerouting/designformats/specctra/PartLibrary.java +++ b/src/main/java/net/freerouting/designformats/specctra/PartLibrary.java @@ -21,98 +21,37 @@ package net.freerouting.designformats.specctra; /** - * * @author Alfons Wirtz */ -public class PartLibrary extends ScopeKeyword -{ - - /** Creates a new instance of PartLibrary */ - public PartLibrary() - { +public class PartLibrary extends ScopeKeyword { + + /** + * Creates a new instance of PartLibrary + */ + public PartLibrary() { super("part_library"); } - - public boolean read_scope(ReadScopeParameter p_par) - { - Object next_token = null; - for (;;) - { - Object prev_token = next_token; - try - { - next_token = p_par.scanner.next_token(); - } - catch (java.io.IOException e) - { - System.out.println("PartLibrary.read_scope: IO error scanning file"); - System.out.println(e); - return false; - } - if (next_token == null) - { - System.out.println("PartLibrary.read_scope: unexpected end of file"); - return false; - } - if (next_token == CLOSED_BRACKET) - { - // end of scope - break; - } - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.LOGICAL_PART_MAPPING) - { - LogicalPartMapping next_mapping = read_logical_part_mapping(p_par.scanner); - if (next_mapping == null) - { - return false; - } - p_par.logical_part_mappings.add(next_mapping); - } - else if (next_token == Keyword.LOGICAL_PART) - { - LogicalPart next_part = read_logical_part(p_par.scanner); - if (next_part == null) - { - return false; - } - p_par.logical_parts.add(next_part); - } - else - { - skip_scope(p_par.scanner); - } - } - } - return true; - } - - public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException - { + + public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException { net.freerouting.library.LogicalParts logical_parts = p_par.board.library.logical_parts; - if (logical_parts.count() <= 0) - { + if (logical_parts.count() <= 0) { return; } p_par.file.start_scope(); p_par.file.write("part_library"); - + // write the logical part mappings - - for (int i = 1; i <= logical_parts.count(); ++i) - { - net.freerouting.library.LogicalPart curr_part = logical_parts.get(i); + + for (int i = 1; i <= logical_parts.count(); ++i) { + net.freerouting.library.LogicalPart curr_part = logical_parts.get(i); p_par.file.start_scope(); p_par.file.write("logical_part_mapping "); p_par.identifier_type.write(curr_part.name, p_par.file); p_par.file.new_line(); p_par.file.write("(comp"); - for (int j = 1; j <= p_par.board.components.count(); ++j) - { + for (int j = 1; j <= p_par.board.components.count(); ++j) { net.freerouting.board.Component curr_compomnent = p_par.board.components.get(j); - if (curr_compomnent.get_logical_part() == curr_part) - { + if (curr_compomnent.get_logical_part() == curr_part) { p_par.file.write(" "); p_par.file.write(curr_compomnent.name); } @@ -120,21 +59,19 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep p_par.file.write(")"); p_par.file.end_scope(); } - + // write the logical parts. - - for (int i = 1; i <= logical_parts.count(); ++i) - { - net.freerouting.library.LogicalPart curr_part = logical_parts.get(i); - + + for (int i = 1; i <= logical_parts.count(); ++i) { + net.freerouting.library.LogicalPart curr_part = logical_parts.get(i); + p_par.file.start_scope(); p_par.file.write("logical_part "); p_par.identifier_type.write(curr_part.name, p_par.file); p_par.file.new_line(); - for (int j = 0; j < curr_part.pin_count(); ++j) - { + for (int j = 0; j < curr_part.pin_count(); ++j) { p_par.file.new_line(); - net.freerouting.library.LogicalPart.PartPin curr_pin = curr_part.get_pin(j); + net.freerouting.library.LogicalPart.PartPin curr_pin = curr_part.get_pin(j); p_par.file.write("(pin "); p_par.identifier_type.write(curr_pin.pin_name, p_par.file); p_par.file.write(" 0 "); @@ -153,241 +90,242 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep } p_par.file.end_scope(); } - + + public boolean read_scope(ReadScopeParameter p_par) { + Object next_token = null; + for (; ; ) { + Object prev_token = next_token; + try { + next_token = p_par.scanner.next_token(); + } catch (java.io.IOException e) { + System.out.println("PartLibrary.read_scope: IO error scanning file"); + System.out.println(e); + return false; + } + if (next_token == null) { + System.out.println("PartLibrary.read_scope: unexpected end of file"); + return false; + } + if (next_token == CLOSED_BRACKET) { + // end of scope + break; + } + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.LOGICAL_PART_MAPPING) { + LogicalPartMapping next_mapping = read_logical_part_mapping(p_par.scanner); + if (next_mapping == null) { + return false; + } + p_par.logical_part_mappings.add(next_mapping); + } else if (next_token == Keyword.LOGICAL_PART) { + LogicalPart next_part = read_logical_part(p_par.scanner); + if (next_part == null) { + return false; + } + p_par.logical_parts.add(next_part); + } else { + skip_scope(p_par.scanner); + } + } + } + return true; + } + /** * Reads the component list of a logical part mapping. * Returns null, if an error occured. */ - private LogicalPartMapping read_logical_part_mapping(Scanner p_scanner) - { - try - { + private LogicalPartMapping read_logical_part_mapping(Scanner p_scanner) { + try { Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("PartLibrary.read_logical_part_mapping: string expected"); return null; } String name = (String) next_token; next_token = p_scanner.next_token(); - if (next_token != Keyword.OPEN_BRACKET) - { + if (next_token != Keyword.OPEN_BRACKET) { System.out.println("PartLibrary.read_logical_part_mapping: open bracket expected"); return null; } next_token = p_scanner.next_token(); - if (next_token != Keyword.COMPONENT_SCOPE) - { + if (next_token != Keyword.COMPONENT_SCOPE) { System.out.println("PartLibrary.read_logical_part_mapping: Keyword.COMPONENT_SCOPE expected"); return null; } - java.util.SortedSet result = new java.util.TreeSet(); - for(;;) - { + java.util.SortedSet result = new java.util.TreeSet(); + for (; ; ) { p_scanner.yybegin(SpecctraFileScanner.NAME); next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("PartLibrary.read_logical_part_mapping: string expected"); return null; } result.add((String) next_token); } next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("PartLibrary.read_logical_part_mapping: closing bracket expected"); return null; } return new LogicalPartMapping(name, result); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("PartLibrary.read_logical_part_mapping: IO error scanning file"); return null; } } - - private LogicalPart read_logical_part(Scanner p_scanner) - { + + private LogicalPart read_logical_part(Scanner p_scanner) { java.util.Collection part_pins = new java.util.LinkedList(); Object next_token = null; - try - { + try { next_token = p_scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("PartLibrary.read_logical_part: IO error scanning file"); return null; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("PartLibrary.read_logical_part: string expected"); return null; } String part_name = (String) next_token; - for (;;) - { + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = p_scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("PartLibrary.read_logical_part: IO error scanning file"); return null; } - if (next_token == null) - { + if (next_token == null) { System.out.println("PartLibrary.read_logical_part: unexpected end of file"); return null; } - if (next_token == CLOSED_BRACKET) - { + if (next_token == CLOSED_BRACKET) { // end of scope break; } boolean read_ok = true; - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.PIN) - { + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.PIN) { PartPin curr_part_pin = read_part_pin(p_scanner); - if (curr_part_pin == null) - { + if (curr_part_pin == null) { return null; } part_pins.add(curr_part_pin); - } - else - { + } else { skip_scope(p_scanner); } } - if (!read_ok) - { + if (!read_ok) { return null; } } return new LogicalPart(part_name, part_pins); } - - private PartPin read_part_pin(Scanner p_scanner) - { - try - { + + private PartPin read_part_pin(Scanner p_scanner) { + try { p_scanner.yybegin(SpecctraFileScanner.NAME); Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("PartLibrary.read_part_pin: string expected"); return null; } String pin_name = (String) next_token; next_token = p_scanner.next_token(); - if (!(next_token instanceof Integer)) - { + if (!(next_token instanceof Integer)) { System.out.println("PartLibrary.read_part_pin: integer expected"); return null; } p_scanner.yybegin(SpecctraFileScanner.NAME); next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("PartLibrary.read_part_pin: string expected"); return null; } String gate_name = (String) next_token; next_token = p_scanner.next_token(); - if (!(next_token instanceof Integer)) - { + if (!(next_token instanceof Integer)) { System.out.println("PartLibrary.read_part_pin: integer expected"); return null; } int gate_swap_code = (Integer) next_token; p_scanner.yybegin(SpecctraFileScanner.NAME); next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("PartLibrary.read_part_pin: string expected"); return null; } String gate_pin_name = (String) next_token; next_token = p_scanner.next_token(); - if (!(next_token instanceof Integer)) - { + if (!(next_token instanceof Integer)) { System.out.println("PartLibrary.read_part_pin: integer expected"); return null; } int gate_pin_swap_code = (Integer) next_token; // overread subgates - for (;;) - { + for (; ; ) { next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } } return new PartPin(pin_name, gate_name, gate_swap_code, gate_pin_name, gate_pin_swap_code); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("PartLibrary.read_part_pin: IO error scanning file"); return null; } } - - public static class LogicalPartMapping - { - private LogicalPartMapping(String p_name, java.util.SortedSet p_components) - { + + public static class LogicalPartMapping { + /** + * The name of the maopping. + */ + public final String name; + /** + * The conponents belonging to the mapping. + */ + public final java.util.SortedSet components; + + private LogicalPartMapping(String p_name, java.util.SortedSet p_components) { name = p_name; components = p_components; } - /** The name of the maopping. */ - public final String name; - - /** The conponents belonging to the mapping. */ - public final java.util.SortedSet components; } - - public static class PartPin - { + + public static class PartPin { + public final String pin_name; + public final String gate_name; + public final int gate_swap_code; + public final String gate_pin_name; + public final int gate_pin_swap_code; private PartPin(String p_pin_name, String p_gate_name, int p_gate_swap_code, - String p_gate_pin_name, int p_gate_pin_swap_code) - { + String p_gate_pin_name, int p_gate_pin_swap_code) { pin_name = p_pin_name; gate_name = p_gate_name; gate_swap_code = p_gate_swap_code; gate_pin_name = p_gate_pin_name; gate_pin_swap_code = p_gate_pin_swap_code; } - - public final String pin_name; - public final String gate_name; - public final int gate_swap_code; - public final String gate_pin_name; - public final int gate_pin_swap_code; } - - public static class LogicalPart - { - private LogicalPart(String p_name, java.util.Collection p_part_pins) - { + + public static class LogicalPart { + /** + * The name of the maopping. + */ + public final String name; + /** + * The pins of this logical part + */ + public final java.util.Collection part_pins; + + private LogicalPart(String p_name, java.util.Collection p_part_pins) { name = p_name; part_pins = p_part_pins; } - /** The name of the maopping. */ - public final String name; - - /** The pins of this logical part */ - public final java.util.Collection part_pins; } } diff --git a/src/main/java/net/freerouting/designformats/specctra/Path.java b/src/main/java/net/freerouting/designformats/specctra/Path.java index 8fa8eec4..75c29b4c 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Path.java +++ b/src/main/java/net/freerouting/designformats/specctra/Path.java @@ -20,30 +20,30 @@ package net.freerouting.designformats.specctra; -import net.freerouting.datastructures.IndentFileWriter; import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; /** * Class for writing path scopes from dsn-files. * - * @author alfons + * @author alfons */ -public abstract class Path extends Shape -{ - - /** Creates a new instance of Path */ - Path(Layer p_layer, double p_width, double[] p_coordinate_arr) - { - super (p_layer); +public abstract class Path extends Shape { + + public final double width; + public final double[] coordinate_arr; + + /** + * Creates a new instance of Path + */ + Path(Layer p_layer, double p_width, double[] p_coordinate_arr) { + super(p_layer); width = p_width; coordinate_arr = p_coordinate_arr; } - + /** * Writes this path as a scope to an output dsn-file. */ public abstract void write_scope(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException; - - public final double width; - public final double [] coordinate_arr; } diff --git a/src/main/java/net/freerouting/designformats/specctra/PlaceControl.java b/src/main/java/net/freerouting/designformats/specctra/PlaceControl.java index a3e7885e..6eee19dd 100644 --- a/src/main/java/net/freerouting/designformats/specctra/PlaceControl.java +++ b/src/main/java/net/freerouting/designformats/specctra/PlaceControl.java @@ -23,88 +23,73 @@ /** * Class for reading place_control scopes from dsn-files. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class PlaceControl extends ScopeKeyword -{ - - /** Creates a new instance of PlaceControl */ - public PlaceControl() - { +public class PlaceControl extends ScopeKeyword { + + /** + * Creates a new instance of PlaceControl + */ + public PlaceControl() { super("place_control"); } - - /** Reads the flip_style */ - public boolean read_scope(ReadScopeParameter p_par) - { + + /** + * Returns true, if rotate_first is read, else false. + */ + static boolean read_flip_style_rotate_first(Scanner p_scanner) { + try { + boolean result = false; + Object next_token = p_scanner.next_token(); + if (next_token == Keyword.ROTATE_FIRST) { + if (next_token == Keyword.ROTATE_FIRST) { + result = true; + } + } + next_token = p_scanner.next_token(); + if (next_token != Keyword.CLOSED_BRACKET) { + System.out.println("Structure.read_flip_style: closing bracket expected"); + return false; + } + return result; + } catch (java.io.IOException e) { + System.out.println("Structure.read_flip_style: IO error scanning file"); + return false; + } + } + + /** + * Reads the flip_style + */ + public boolean read_scope(ReadScopeParameter p_par) { boolean flip_style_rotate_first = false; Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = p_par.scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("PlaceControl.read_scope: IO error scanning file"); return false; } - if (next_token == null) - { + if (next_token == null) { System.out.println("PlaceControl.read_scope: unexpected end of file"); return false; } - if (next_token == CLOSED_BRACKET) - { + if (next_token == CLOSED_BRACKET) { // end of scope break; } - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.FLIP_STYLE) - { + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.FLIP_STYLE) { flip_style_rotate_first = read_flip_style_rotate_first(p_par.scanner); } } - } - if (flip_style_rotate_first) - { + } + if (flip_style_rotate_first) { p_par.board_handling.get_routing_board().components.set_flip_style_rotate_first(true); } return true; } - - /** - * Returns true, if rotate_first is read, else false. - */ - static boolean read_flip_style_rotate_first(Scanner p_scanner) - { - try - { - boolean result = false; - Object next_token = p_scanner.next_token(); - if (next_token == Keyword.ROTATE_FIRST) - { - if (next_token == Keyword.ROTATE_FIRST) - { - result = true; - } - } - next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { - System.out.println("Structure.read_flip_style: closing bracket expected"); - return false; - } - return result; - } - catch (java.io.IOException e) - { - System.out.println("Structure.read_flip_style: IO error scanning file"); - return false; - } - } - + } diff --git a/src/main/java/net/freerouting/designformats/specctra/Placement.java b/src/main/java/net/freerouting/designformats/specctra/Placement.java index befa1259..64288bc8 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Placement.java +++ b/src/main/java/net/freerouting/designformats/specctra/Placement.java @@ -23,28 +23,25 @@ /** * Class for writing placement scopes from dsn-files. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Placement extends ScopeKeyword -{ - - /** Creates a new instance of Placemet */ - public Placement() - { +public class Placement extends ScopeKeyword { + + /** + * Creates a new instance of Placemet + */ + public Placement() { super("placement"); } - - public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException - { + + public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("placement"); - if (p_par.board.components.get_flip_style_rotate_first()) - { + if (p_par.board.components.get_flip_style_rotate_first()) { p_par.file.new_line(); p_par.file.write("(place_control (flip_style rotate_first))"); } - for (int i = 1; i <= p_par.board.library.packages.count(); ++i) - { + for (int i = 1; i <= p_par.board.library.packages.count(); ++i) { Package.write_placement_scope(p_par, p_par.board.library.packages.get(i)); } p_par.file.end_scope(); diff --git a/src/main/java/net/freerouting/designformats/specctra/Plane.java b/src/main/java/net/freerouting/designformats/specctra/Plane.java index 8e1e48d5..b4af1ff7 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Plane.java +++ b/src/main/java/net/freerouting/designformats/specctra/Plane.java @@ -21,73 +21,37 @@ package net.freerouting.designformats.specctra; - /** * Class for reading and writing plane scopes from dsn-files. * - * @author alfons + * @author alfons */ -public class Plane extends ScopeKeyword -{ - - /** Creates a new instance of Plane */ - public Plane() - { +public class Plane extends ScopeKeyword { + + /** + * Creates a new instance of Plane + */ + public Plane() { super("plane"); } - - public boolean read_scope(ReadScopeParameter p_par) - { - // read the net name - String net_name = null; - boolean skip_window_scopes = p_par.host_cad != null && p_par.host_cad.equalsIgnoreCase("allegro"); - // Cadence Allegro cutouts the pins on power planes, which leads to performance problems - // when dividing a conduction area into convex pieces. - Shape.ReadAreaScopeResult conduction_area = null; - try - { - Object next_token = p_par.scanner.next_token(); - if (!(next_token instanceof String)) - { - System.out.println("Plane.read_scope: String expected"); - return false; - } - net_name = (String) next_token; - conduction_area = Shape.read_area_scope(p_par.scanner, p_par.layer_structure, skip_window_scopes); - } - catch (java.io.IOException e) - { - System.out.println("Plane.read_scope: IO error scanning file"); - System.out.println(e); - return false; - } - ReadScopeParameter.PlaneInfo plane_info = new ReadScopeParameter.PlaneInfo(conduction_area, net_name); - p_par.plane_list.add(plane_info); - return true; - } - - public static void write_scope(WriteScopeParameter p_par, net.freerouting.board.ConductionArea p_conduction) throws java.io.IOException - { + + public static void write_scope(WriteScopeParameter p_par, net.freerouting.board.ConductionArea p_conduction) throws java.io.IOException { int net_count = p_conduction.net_count(); - if (net_count <= 0 || net_count > 1) - { + if (net_count <= 0 || net_count > 1) { System.out.println("Plane.write_scope: unexpected net count"); return; } String net_name = p_par.board.rules.nets.get(p_conduction.get_net_no(0)).name; net.freerouting.geometry.planar.Area curr_area = p_conduction.get_area(); int layer_no = p_conduction.get_layer(); - net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[ layer_no]; + net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[layer_no]; Layer plane_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal); net.freerouting.geometry.planar.Shape boundary_shape; - net.freerouting.geometry.planar.Shape [] holes; - if (curr_area instanceof net.freerouting.geometry.planar.Shape) - { + net.freerouting.geometry.planar.Shape[] holes; + if (curr_area instanceof net.freerouting.geometry.planar.Shape) { boundary_shape = (net.freerouting.geometry.planar.Shape) curr_area; - holes = new net.freerouting.geometry.planar.Shape [0]; - } - else - { + holes = new net.freerouting.geometry.planar.Shape[0]; + } else { boundary_shape = curr_area.get_border(); holes = curr_area.get_holes(); } @@ -95,15 +59,38 @@ public static void write_scope(WriteScopeParameter p_par, net.freerouting.board. p_par.file.write("plane "); p_par.identifier_type.write(net_name, p_par.file); Shape dsn_shape = p_par.coordinate_transform.board_to_dsn(boundary_shape, plane_layer); - if (dsn_shape != null) - { + if (dsn_shape != null) { dsn_shape.write_scope(p_par.file, p_par.identifier_type); } - for (int i = 0; i < holes.length; ++i) - { + for (int i = 0; i < holes.length; ++i) { Shape dsn_hole = p_par.coordinate_transform.board_to_dsn(holes[i], plane_layer); dsn_hole.write_hole_scope(p_par.file, p_par.identifier_type); } p_par.file.end_scope(); } + + public boolean read_scope(ReadScopeParameter p_par) { + // read the net name + String net_name = null; + boolean skip_window_scopes = p_par.host_cad != null && p_par.host_cad.equalsIgnoreCase("allegro"); + // Cadence Allegro cutouts the pins on power planes, which leads to performance problems + // when dividing a conduction area into convex pieces. + Shape.ReadAreaScopeResult conduction_area = null; + try { + Object next_token = p_par.scanner.next_token(); + if (!(next_token instanceof String)) { + System.out.println("Plane.read_scope: String expected"); + return false; + } + net_name = (String) next_token; + conduction_area = Shape.read_area_scope(p_par.scanner, p_par.layer_structure, skip_window_scopes); + } catch (java.io.IOException e) { + System.out.println("Plane.read_scope: IO error scanning file"); + System.out.println(e); + return false; + } + ReadScopeParameter.PlaneInfo plane_info = new ReadScopeParameter.PlaneInfo(conduction_area, net_name); + p_par.plane_list.add(plane_info); + return true; + } } diff --git a/src/main/java/net/freerouting/designformats/specctra/Polygon.java b/src/main/java/net/freerouting/designformats/specctra/Polygon.java index a10ea6a0..718960ec 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Polygon.java +++ b/src/main/java/net/freerouting/designformats/specctra/Polygon.java @@ -19,74 +19,65 @@ */ package net.freerouting.designformats.specctra; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.datastructures.IndentFileWriter; + import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.geometry.planar.IntPoint; /** * Describes a polygon in a Specctra dsn file. * - * @author alfons + * @author alfons */ -public class Polygon extends Shape -{ +public class Polygon extends Shape { + public final double[] coor; + /** * Creates a new instance of Polygon * p_coor is an array of dimension of dimension 2 * point_count and contains x0, y0, x1, y1, ... * If the polygon is used as rectangle, */ - public Polygon(Layer p_layer, double[] p_coor) - { + public Polygon(Layer p_layer, double[] p_coor) { super(p_layer); coor = p_coor; } - - public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) - { - IntPoint [] corner_arr = new IntPoint[coor.length / 2]; - double [] curr_point = new double [2]; - for (int i = 0; i < corner_arr.length; ++i) - { + + public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) { + IntPoint[] corner_arr = new IntPoint[coor.length / 2]; + double[] curr_point = new double[2]; + for (int i = 0; i < corner_arr.length; ++i) { curr_point[0] = coor[2 * i]; curr_point[1] = coor[2 * i + 1]; - corner_arr[i] = p_coordinate_transform.dsn_to_board(curr_point).round(); + corner_arr[i] = p_coordinate_transform.dsn_to_board(curr_point).round(); } return new net.freerouting.geometry.planar.PolygonShape(corner_arr); } - - public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) - { - if (coor.length < 2) - { + + public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) { + if (coor.length < 2) { return net.freerouting.geometry.planar.Simplex.EMPTY; } - IntPoint [] corner_arr = new IntPoint[coor.length / 2]; - for (int i = 0; i < corner_arr.length; ++i) - { + IntPoint[] corner_arr = new IntPoint[coor.length / 2]; + for (int i = 0; i < corner_arr.length; ++i) { int curr_x = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[2 * i])); int curr_y = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[2 * i + 1])); corner_arr[i] = new IntPoint(curr_x, curr_y); } return new net.freerouting.geometry.planar.PolygonShape(corner_arr); } - - public Rectangle bounding_box() - { - double[] bounds = new double[4]; + + public Rectangle bounding_box() { + double[] bounds = new double[4]; bounds[0] = Integer.MAX_VALUE; bounds[1] = Integer.MAX_VALUE; bounds[2] = Integer.MIN_VALUE; bounds[3] = Integer.MIN_VALUE; - for (int i = 0; i < coor.length; ++i) - { - if (i % 2 == 0) - { + for (int i = 0; i < coor.length; ++i) { + if (i % 2 == 0) { // x coordinate bounds[0] = Math.min(bounds[0], coor[i]); bounds[2] = Math.max(bounds[2], coor[i]); - } - else - { + } else { // x coordinate bounds[1] = Math.min(bounds[1], coor[i]); bounds[3] = Math.max(bounds[3], coor[i]); @@ -94,20 +85,18 @@ public Rectangle bounding_box() } return new Rectangle(layer, bounds); } - + /** * Writes this polygon as a scope to an output dsn-file. */ - public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException - { + public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.start_scope(); p_file.write("polygon "); p_identifier_type.write(this.layer.name, p_file); p_file.write(" "); p_file.write((new Integer(0)).toString()); - int corner_count = coor.length/ 2; - for (int i = 0; i < corner_count; ++i) - { + int corner_count = coor.length / 2; + for (int i = 0; i < corner_count; ++i) { p_file.new_line(); p_file.write(new Double(coor[2 * i]).toString()); p_file.write(" "); @@ -115,26 +104,22 @@ public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier_typ } p_file.end_scope(); } - - public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException - { + + public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.start_scope(); p_file.write("polygon "); p_identifier_type.write(this.layer.name, p_file); p_file.write(" "); p_file.write((new Integer(0)).toString()); - int corner_count = coor.length/ 2; - for (int i = 0; i < corner_count; ++i) - { + int corner_count = coor.length / 2; + for (int i = 0; i < corner_count; ++i) { p_file.new_line(); - Integer curr_coor = (int) Math.round(coor[2* i ]); + Integer curr_coor = (int) Math.round(coor[2 * i]); p_file.write(curr_coor.toString()); p_file.write(" "); - curr_coor = (int) Math.round(coor[2* i + 1]); + curr_coor = (int) Math.round(coor[2 * i + 1]); p_file.write(curr_coor.toString()); } p_file.end_scope(); } - - public final double [] coor; } diff --git a/src/main/java/net/freerouting/designformats/specctra/PolygonPath.java b/src/main/java/net/freerouting/designformats/specctra/PolygonPath.java index 884ee4a7..50c1e83e 100644 --- a/src/main/java/net/freerouting/designformats/specctra/PolygonPath.java +++ b/src/main/java/net/freerouting/designformats/specctra/PolygonPath.java @@ -20,41 +20,39 @@ package net.freerouting.designformats.specctra; +import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntPoint; import net.freerouting.geometry.planar.IntOctagon; -import net.freerouting.datastructures.IndentFileWriter; -import net.freerouting.datastructures.IdentifierType; +import net.freerouting.geometry.planar.IntPoint; /** * Class for reading and writing path scopes consisting of a polygon from dsn-files. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class PolygonPath extends Path -{ - - /** Creates a new instance of PolygonPath */ - public PolygonPath(Layer p_layer, double p_width, double[] p_coordinate_arr) - { +public class PolygonPath extends Path { + + /** + * Creates a new instance of PolygonPath + */ + public PolygonPath(Layer p_layer, double p_width, double[] p_coordinate_arr) { super(p_layer, p_width, p_coordinate_arr); } - - + + /** * Writes this path as a scope to an output dsn-file. */ - public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException - { + public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.start_scope(); p_file.write("path "); p_identifier_type.write(this.layer.name, p_file); p_file.write(" "); p_file.write((new Double(this.width)).toString()); - int corner_count = coordinate_arr.length/ 2; - for (int i = 0; i < corner_count; ++i) - { + int corner_count = coordinate_arr.length / 2; + for (int i = 0; i < corner_count; ++i) { p_file.new_line(); p_file.write(new Double(coordinate_arr[2 * i]).toString()); p_file.write(" "); @@ -62,103 +60,86 @@ public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier_typ } p_file.end_scope(); } - - public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException - { + + public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.start_scope(); p_file.write("path "); p_identifier_type.write(this.layer.name, p_file); p_file.write(" "); p_file.write((new Double(this.width)).toString()); - int corner_count = coordinate_arr.length/ 2; - for (int i = 0; i < corner_count; ++i) - { + int corner_count = coordinate_arr.length / 2; + for (int i = 0; i < corner_count; ++i) { p_file.new_line(); - Integer curr_coor = (int) Math.round(coordinate_arr[2* i ]); + Integer curr_coor = (int) Math.round(coordinate_arr[2 * i]); p_file.write(curr_coor.toString()); p_file.write(" "); - curr_coor = (int) Math.round(coordinate_arr[2* i + 1]); + curr_coor = (int) Math.round(coordinate_arr[2 * i + 1]); p_file.write(curr_coor.toString()); } p_file.end_scope(); } - - public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) - { - FloatPoint [] corner_arr = new FloatPoint[this.coordinate_arr.length / 2]; - double [] curr_point = new double [2]; - for (int i = 0; i < corner_arr.length; ++i) - { + + public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) { + FloatPoint[] corner_arr = new FloatPoint[this.coordinate_arr.length / 2]; + double[] curr_point = new double[2]; + for (int i = 0; i < corner_arr.length; ++i) { curr_point[0] = this.coordinate_arr[2 * i]; curr_point[1] = this.coordinate_arr[2 * i + 1]; - corner_arr[i] = p_coordinate_transform.dsn_to_board(curr_point); + corner_arr[i] = p_coordinate_transform.dsn_to_board(curr_point); } double offset = p_coordinate_transform.dsn_to_board(this.width) / 2; - if (corner_arr.length <= 2) - { + if (corner_arr.length <= 2) { IntOctagon bounding_oct = FloatPoint.bounding_octagon(corner_arr); return bounding_oct.enlarge(offset); } - IntPoint [] rounded_corner_arr = new IntPoint[corner_arr.length]; - for (int i = 0; i < corner_arr.length; ++i) - { + IntPoint[] rounded_corner_arr = new IntPoint[corner_arr.length]; + for (int i = 0; i < corner_arr.length; ++i) { rounded_corner_arr[i] = corner_arr[i].round(); } net.freerouting.geometry.planar.Shape result = new net.freerouting.geometry.planar.PolygonShape(rounded_corner_arr); - if (offset > 0) - { + if (offset > 0) { result = result.bounding_tile().enlarge(offset); } return result; } - - public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) - { - FloatPoint [] corner_arr = new FloatPoint[this.coordinate_arr.length / 2]; - double [] curr_point = new double [2]; - for (int i = 0; i < corner_arr.length; ++i) - { + + public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) { + FloatPoint[] corner_arr = new FloatPoint[this.coordinate_arr.length / 2]; + double[] curr_point = new double[2]; + for (int i = 0; i < corner_arr.length; ++i) { curr_point[0] = this.coordinate_arr[2 * i]; curr_point[1] = this.coordinate_arr[2 * i + 1]; - corner_arr[i] = p_coordinate_transform.dsn_to_board_rel(curr_point); + corner_arr[i] = p_coordinate_transform.dsn_to_board_rel(curr_point); } double offset = p_coordinate_transform.dsn_to_board(this.width) / 2; - if (corner_arr.length <= 2) - { + if (corner_arr.length <= 2) { IntOctagon bounding_oct = FloatPoint.bounding_octagon(corner_arr); return bounding_oct.enlarge(offset); } - IntPoint [] rounded_corner_arr = new IntPoint[corner_arr.length]; - for (int i = 0; i < corner_arr.length; ++i) - { + IntPoint[] rounded_corner_arr = new IntPoint[corner_arr.length]; + for (int i = 0; i < corner_arr.length; ++i) { rounded_corner_arr[i] = corner_arr[i].round(); } net.freerouting.geometry.planar.Shape result = new net.freerouting.geometry.planar.PolygonShape(rounded_corner_arr); - if (offset > 0) - { + if (offset > 0) { result = result.bounding_tile().enlarge(offset); } return result; } - - public Rectangle bounding_box() - { - double offset = this.width/2; - double[] bounds = new double[4]; + + public Rectangle bounding_box() { + double offset = this.width / 2; + double[] bounds = new double[4]; bounds[0] = Integer.MAX_VALUE; bounds[1] = Integer.MAX_VALUE; bounds[2] = Integer.MIN_VALUE; bounds[3] = Integer.MIN_VALUE; - for (int i = 0; i < coordinate_arr.length; ++i) - { - if (i % 2 == 0) - { + for (int i = 0; i < coordinate_arr.length; ++i) { + if (i % 2 == 0) { // x coordinate bounds[0] = Math.min(bounds[0], coordinate_arr[i] - offset); bounds[2] = Math.max(bounds[2], coordinate_arr[i]) + offset; - } - else - { + } else { // x coordinate bounds[1] = Math.min(bounds[1], coordinate_arr[i] - offset); bounds[3] = Math.max(bounds[3], coordinate_arr[i] + offset); diff --git a/src/main/java/net/freerouting/designformats/specctra/PolylinePath.java b/src/main/java/net/freerouting/designformats/specctra/PolylinePath.java index 58a2ffb9..28305bcc 100644 --- a/src/main/java/net/freerouting/designformats/specctra/PolylinePath.java +++ b/src/main/java/net/freerouting/designformats/specctra/PolylinePath.java @@ -20,60 +20,54 @@ package net.freerouting.designformats.specctra; -import net.freerouting.datastructures.IndentFileWriter; import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; /** * Describes a path defined by a sequence of lines (instead of a sequence of corners. * - * @author alfons + * @author alfons */ -public class PolylinePath extends Path -{ - - /** Creates a new instance of PolylinePath */ - public PolylinePath(Layer p_layer, double p_width, double[] p_corner_arr) - { +public class PolylinePath extends Path { + + /** + * Creates a new instance of PolylinePath + */ + public PolylinePath(Layer p_layer, double p_width, double[] p_corner_arr) { super(p_layer, p_width, p_corner_arr); } - + /** * Writes this path as a scope to an output dsn-file. */ - public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException - { + public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException { p_file.start_scope(); p_file.write("polyline_path "); p_identifier.write(this.layer.name, p_file); p_file.write(" "); p_file.write((new Double(this.width)).toString()); - int line_count = coordinate_arr.length/ 4; - for (int i = 0; i < line_count; ++i) - { + int line_count = coordinate_arr.length / 4; + for (int i = 0; i < line_count; ++i) { p_file.new_line(); - for (int j = 0; j < 4; ++j) - { + for (int j = 0; j < 4; ++j) { p_file.write(new Double(coordinate_arr[4 * i + j]).toString()); p_file.write(" "); } } p_file.end_scope(); } - - public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException - { + + public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException { p_file.start_scope(); p_file.write("polyline_path "); p_identifier.write(this.layer.name, p_file); p_file.write(" "); p_file.write((new Double(this.width)).toString()); - int line_count = coordinate_arr.length/ 4; - for (int i = 0; i < line_count; ++i) - { + int line_count = coordinate_arr.length / 4; + for (int i = 0; i < line_count; ++i) { p_file.new_line(); - for (int j = 0; j < 4; ++j) - { + for (int j = 0; j < 4; ++j) { Integer curr_coor = (int) Math.round(coordinate_arr[4 * i + j]); p_file.write(curr_coor.toString()); p_file.write(" "); @@ -81,22 +75,19 @@ public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier } p_file.end_scope(); } - - public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) - { + + public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) { System.out.println("PolylinePath.transform_to_board_rel not implemented"); return null; } - - public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) - { + + public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) { System.out.println("PolylinePath.transform_to_board_rel not implemented"); return null; } - - - public Rectangle bounding_box() - { + + + public Rectangle bounding_box() { System.out.println("PolylinePath.boundingbox not implemented"); return null; } diff --git a/src/main/java/net/freerouting/designformats/specctra/ReadScopeParameter.java b/src/main/java/net/freerouting/designformats/specctra/ReadScopeParameter.java index 5ffad240..150e04b4 100644 --- a/src/main/java/net/freerouting/designformats/specctra/ReadScopeParameter.java +++ b/src/main/java/net/freerouting/designformats/specctra/ReadScopeParameter.java @@ -26,89 +26,85 @@ /** * Default parameter type used while reading a Specctra dsn-file. * - * @author alfons + * @author alfons */ -public class ReadScopeParameter -{ - - /** Creates a new instance of ReadScopeParameter */ - ReadScopeParameter(Scanner p_scanner, net.freerouting.interactive.BoardHandling p_board_handling, - net.freerouting.board.BoardObservers p_observers, - net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, net.freerouting.board.TestLevel p_test_level) - { - scanner = p_scanner; - board_handling = p_board_handling; - observers = p_observers; - item_id_no_generator = p_item_id_no_generator; - test_level = p_test_level; - } - +public class ReadScopeParameter { + final Scanner scanner; final net.freerouting.interactive.BoardHandling board_handling; final NetList netlist = new NetList(); - - final net.freerouting.board.BoardObservers observers; + final net.freerouting.board.BoardObservers observers; final net.freerouting.datastructures.IdNoGenerator item_id_no_generator; final net.freerouting.board.TestLevel test_level; - - /** Collection of elements of class PlaneInfo. + /** + * Collection of elements of class PlaneInfo. * The plane cannot be inserted directly into the boards, because the layers may not be read completely. */ final Collection plane_list = new LinkedList(); - /** * Component placement information. * It is filled while reading the placement scope and can be * evaluated after reading the library and network scope. */ final Collection placement_list = new LinkedList(); - - + final Collection constants = new LinkedList(); /** * The names of the via padstacks filled while reading the structure scope * and evaluated after reading the library scope. */ Collection via_padstack_names = null; - + boolean via_at_smd_allowed = false; net.freerouting.board.AngleRestriction snap_angle = net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE; - - /** The logical parts are used for pin and gate swaw */ + + /** + * The logical parts are used for pin and gate swaw + */ java.util.Collection logical_part_mappings = new java.util.LinkedList(); java.util.Collection logical_parts = new java.util.LinkedList(); - - /** The following objects are from the parser scope. */ + + /** + * The following objects are from the parser scope. + */ String string_quote = "\""; String host_cad = null; String host_version = null; - + boolean dsn_file_generated_by_host = true; - + boolean board_outline_ok = true; - - final Collection constants = new LinkedList(); net.freerouting.board.Communication.SpecctraParserInfo.WriteResolution write_resolution = null; - - - /** The following objects will be initialised when the structure scope is read. */ + /** + * The following objects will be initialised when the structure scope is read. + */ CoordinateTransform coordinate_transform = null; LayerStructure layer_structure = null; net.freerouting.interactive.AutorouteSettings autoroute_settings = null; - net.freerouting.board.Unit unit = net.freerouting.board.Unit.MIL; int resolution = 100; // default resulution - - /** Information for inserting a plane */ - static class PlaneInfo - { - PlaneInfo(Shape.ReadAreaScopeResult p_area, String p_net_name) - { + /** + * Creates a new instance of ReadScopeParameter + */ + ReadScopeParameter(Scanner p_scanner, net.freerouting.interactive.BoardHandling p_board_handling, + net.freerouting.board.BoardObservers p_observers, + net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, net.freerouting.board.TestLevel p_test_level) { + scanner = p_scanner; + board_handling = p_board_handling; + observers = p_observers; + item_id_no_generator = p_item_id_no_generator; + test_level = p_test_level; + } + + /** + * Information for inserting a plane + */ + static class PlaneInfo { + final Shape.ReadAreaScopeResult area; + final String net_name; + PlaneInfo(Shape.ReadAreaScopeResult p_area, String p_net_name) { area = p_area; net_name = p_net_name; } - - final Shape.ReadAreaScopeResult area; - final String net_name; } } diff --git a/src/main/java/net/freerouting/designformats/specctra/Rectangle.java b/src/main/java/net/freerouting/designformats/specctra/Rectangle.java index e65133e3..652e60b1 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Rectangle.java +++ b/src/main/java/net/freerouting/designformats/specctra/Rectangle.java @@ -20,110 +20,96 @@ package net.freerouting.designformats.specctra; +import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntBox; -import net.freerouting.datastructures.IndentFileWriter; -import net.freerouting.datastructures.IdentifierType; /** * Describes a rectangle in a Specctra dsn file. * - * @author alfons + * @author alfons */ -public class Rectangle extends Shape -{ +public class Rectangle extends Shape { + public final double[] coor; + /** * Creates a new instance of Rectangle * p_coor is an array of dimension 4 and contains the rectangle coordinates * in the following order: lower left x, lower left y, upper right x, uppper right y. */ - public Rectangle(Layer p_layer, double[] p_coor) - { + public Rectangle(Layer p_layer, double[] p_coor) { super(p_layer); coor = p_coor; } - - public Rectangle bounding_box() - { + + public Rectangle bounding_box() { return this; } - + /** - * Creates the smallest rectangle containing this rectangle and p_other + * Creates the smallest rectangle containing this rectangle and p_other */ - public Rectangle union (Rectangle p_other) - { - double[] result_coor = new double[4]; - result_coor[0] = Math.min(this.coor[0], p_other.coor[0]); - result_coor[1] = Math.min(this.coor[1], p_other.coor[1]); - result_coor[2] = Math.max(this.coor[2], p_other.coor[2]); - result_coor[3] = Math.max(this.coor[3], p_other.coor[3]); - return new Rectangle(this.layer, result_coor); + public Rectangle union(Rectangle p_other) { + double[] result_coor = new double[4]; + result_coor[0] = Math.min(this.coor[0], p_other.coor[0]); + result_coor[1] = Math.min(this.coor[1], p_other.coor[1]); + result_coor[2] = Math.max(this.coor[2], p_other.coor[2]); + result_coor[3] = Math.max(this.coor[3], p_other.coor[3]); + return new Rectangle(this.layer, result_coor); } - - public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) - { + + public net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform) { int box_coor[] = new int[4]; - for (int i = 0; i < 4; ++i) - { + for (int i = 0; i < 4; ++i) { box_coor[i] = (int) Math.round(p_coordinate_transform.dsn_to_board(this.coor[i])); } - + IntBox result; - if (box_coor[1] <= box_coor[3]) - { + if (box_coor[1] <= box_coor[3]) { // box_coor describe lower left and upper right corner result = new IntBox(box_coor[0], box_coor[1], box_coor[2], box_coor[3]); - } - else - { + } else { // box_coor describe upper left and lower right corner result = new IntBox(box_coor[0], box_coor[3], box_coor[2], box_coor[1]); } return result; } - - public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) - { - double [] curr_point = new double [2]; + + public net.freerouting.geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform) { + double[] curr_point = new double[2]; curr_point[0] = Math.min(coor[0], coor[2]); curr_point[1] = Math.min(coor[1], coor[3]); FloatPoint lower_left = p_coordinate_transform.dsn_to_board(curr_point); curr_point[0] = Math.max(coor[0], coor[2]); curr_point[1] = Math.max(coor[1], coor[3]); - FloatPoint upper_right= p_coordinate_transform.dsn_to_board(curr_point); + FloatPoint upper_right = p_coordinate_transform.dsn_to_board(curr_point); return new IntBox(lower_left.round(), upper_right.round()); } - + /** * Writes this rectangle as a scope to an output dsn-file. */ - public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException - { + public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException { p_file.new_line(); p_file.write("(rect "); p_identifier.write(this.layer.name, p_file); - for (int i = 0; i < coor.length; ++i) - { + for (int i = 0; i < coor.length; ++i) { p_file.write(" "); p_file.write(new Double(coor[i]).toString()); } p_file.write(")"); } - - public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException - { + + public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException { p_file.new_line(); p_file.write("(rect "); p_identifier.write(this.layer.name, p_file); - for (int i = 0; i < coor.length; ++i) - { + for (int i = 0; i < coor.length; ++i) { p_file.write(" "); Integer curr_coor = (int) Math.round(coor[i]); p_file.write(curr_coor.toString()); } p_file.write(")"); } - - public final double [] coor; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/designformats/specctra/Resolution.java b/src/main/java/net/freerouting/designformats/specctra/Resolution.java index 6b8c7596..b24870b9 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Resolution.java +++ b/src/main/java/net/freerouting/designformats/specctra/Resolution.java @@ -23,66 +23,57 @@ /** * Class for reading resolution scopes from dsn-files. * - * @author alfons + * @author alfons */ -public class Resolution extends ScopeKeyword -{ - - /** Creates a new instance of Resolution */ - public Resolution() - { +public class Resolution extends ScopeKeyword { + + /** + * Creates a new instance of Resolution + */ + public Resolution() { super("resolution"); } - - public boolean read_scope(ReadScopeParameter p_par) - { - try - { + + public static void write_scope(net.freerouting.datastructures.IndentFileWriter p_file, net.freerouting.board.Communication p_board_communication) throws java.io.IOException { + p_file.new_line(); + p_file.write("(resolution "); + p_file.write(p_board_communication.unit.toString()); + p_file.write(" "); + p_file.write((new Integer(p_board_communication.resolution)).toString()); + p_file.write(")"); + } + + public boolean read_scope(ReadScopeParameter p_par) { + try { // read the unit Object next_token = p_par.scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Resolution.read_scope: string expected"); return false; } p_par.unit = net.freerouting.board.Unit.from_string((String) next_token); - if (p_par.unit == null) - { + if (p_par.unit == null) { System.out.println("Resolution.read_scope: unit mil, inch or mm expected"); return false; } // read the scale factor next_token = p_par.scanner.next_token(); - if (!(next_token instanceof Integer)) - { + if (!(next_token instanceof Integer)) { System.out.println("Resolution.read_scope: integer expected"); return false; } - p_par.resolution = ((Integer)next_token).intValue(); + p_par.resolution = ((Integer) next_token).intValue(); // overread the closing bracket next_token = p_par.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Resolution.read_scope: closing bracket expected"); return false; } return true; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Resolution.read_scope: IO error scanning file"); return false; } } - - public static void write_scope(net.freerouting.datastructures.IndentFileWriter p_file, net.freerouting.board.Communication p_board_communication) throws java.io.IOException - { - p_file.new_line(); - p_file.write("(resolution "); - p_file.write(p_board_communication.unit.toString()); - p_file.write(" "); - p_file.write((new Integer(p_board_communication.resolution)).toString()); - p_file.write(")"); - } - + } diff --git a/src/main/java/net/freerouting/designformats/specctra/Rule.java b/src/main/java/net/freerouting/designformats/specctra/Rule.java index 415e8edc..0167da24 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Rule.java +++ b/src/main/java/net/freerouting/designformats/specctra/Rule.java @@ -27,153 +27,117 @@ /** * Class for reading and writing rule scopes from dsn-files. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public abstract class Rule -{ +public abstract class Rule { /** * Returns a collection of objects of class Rule. */ - public static Collection read_scope( Scanner p_scanner) - { + public static Collection read_scope(Scanner p_scanner) { Collection result = new LinkedList(); Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = p_scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Rule.read_scope: IO error scanning file"); System.out.println(e); return null; } - if (next_token == null) - { + if (next_token == null) { System.out.println("Rule.read_scope: unexpected end of file"); return null; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - if (prev_token == Keyword.OPEN_BRACKET) - { + if (prev_token == Keyword.OPEN_BRACKET) { Rule curr_rule = null; - if (next_token == Keyword.WIDTH) - { + if (next_token == Keyword.WIDTH) { curr_rule = read_width_rule(p_scanner); - } - else if (next_token == Keyword.CLEARANCE) - { + } else if (next_token == Keyword.CLEARANCE) { curr_rule = read_clearance_rule(p_scanner); - } - else - { + } else { ScopeKeyword.skip_scope(p_scanner); } - if (curr_rule != null) - { + if (curr_rule != null) { result.add(curr_rule); } - + } } return result; } - + /** * Reads a LayerRule from dsn-file. */ - public static LayerRule read_layer_rule_scope( Scanner p_scanner) - { - try - { + public static LayerRule read_layer_rule_scope(Scanner p_scanner) { + try { Collection layer_names = new LinkedList(); Collection rule_list = new LinkedList(); - for (;;) - { + for (; ; ) { p_scanner.yybegin(SpecctraFileScanner.LAYER_NAME); Object next_token = p_scanner.next_token(); - if (next_token == Keyword.OPEN_BRACKET) - { + if (next_token == Keyword.OPEN_BRACKET) { break; } - if (!(next_token instanceof String)) - { - + if (!(next_token instanceof String)) { + System.out.println("Rule.read_layer_rule_scope: string expected"); return null; } layer_names.add((String) next_token); } - for (;;) - { + for (; ; ) { Object next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (next_token != Keyword.RULE) - { - + if (next_token != Keyword.RULE) { + System.out.println("Rule.read_layer_rule_scope: rule expected"); return null; } rule_list.addAll(read_scope(p_scanner)); } return new LayerRule(layer_names, rule_list); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Rule.read_layer_rule_scope: IO error scanning file"); return null; } } - - public static WidthRule read_width_rule(Scanner p_scanner) - { - try - { + + public static WidthRule read_width_rule(Scanner p_scanner) { + try { double value; Object next_token = p_scanner.next_token(); - if (next_token instanceof Double) - { + if (next_token instanceof Double) { value = ((Double) next_token).doubleValue(); - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { value = ((Integer) next_token).intValue(); - } - else - { + } else { System.out.println("Rule.read_width_rule: number expected"); return null; } next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Rule.read_width_rule: closing bracket expected"); return null; } return new WidthRule(value); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Rule.read_width_rule: IO error scanning file"); return null; } } - - public static void write_scope(net.freerouting.rules.NetClass p_net_class, WriteScopeParameter p_par) throws java.io.IOException - { + + public static void write_scope(net.freerouting.rules.NetClass p_net_class, WriteScopeParameter p_par) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("rule"); - + // write the trace width int default_trace_half_width = p_net_class.get_trace_half_width(0); double trace_width = 2 * p_par.coordinate_transform.board_to_dsn(default_trace_half_width); @@ -182,28 +146,25 @@ public static void write_scope(net.freerouting.rules.NetClass p_net_class, Write p_par.file.write((new Double(trace_width)).toString()); p_par.file.write(")"); p_par.file.end_scope(); - for (int i = 1; i < p_par.board.layer_structure.arr.length; ++i) - { - if (p_net_class.get_trace_half_width(i) != default_trace_half_width) - { + for (int i = 1; i < p_par.board.layer_structure.arr.length; ++i) { + if (p_net_class.get_trace_half_width(i) != default_trace_half_width) { write_layer_rule(p_net_class, i, p_par); } } } - - private static void write_layer_rule(net.freerouting.rules.NetClass p_net_class, int p_layer_no, WriteScopeParameter p_par) throws java.io.IOException - { + + private static void write_layer_rule(net.freerouting.rules.NetClass p_net_class, int p_layer_no, WriteScopeParameter p_par) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("layer_rule "); - + net.freerouting.board.Layer curr_board_layer = p_par.board.layer_structure.arr[p_layer_no]; - + p_par.file.write(curr_board_layer.name); p_par.file.start_scope(); p_par.file.write("rule "); - + int curr_trace_half_width = p_net_class.get_trace_half_width(p_layer_no); - + // write the trace width double trace_width = 2 * p_par.coordinate_transform.board_to_dsn(curr_trace_half_width); p_par.file.new_line(); @@ -213,12 +174,11 @@ private static void write_layer_rule(net.freerouting.rules.NetClass p_net_class, p_par.file.end_scope(); p_par.file.end_scope(); } - + /** * Writes the default rule as a scope to an output dsn-file. */ - public static void write_default_rule(WriteScopeParameter p_par, int p_layer) throws java.io.IOException - { + public static void write_default_rule(WriteScopeParameter p_par, int p_layer) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("rule"); // write the trace width @@ -242,25 +202,21 @@ public static void write_default_rule(WriteScopeParameter p_par, int p_layer) th p_par.file.write(smd_to_turn_dist.toString()); p_par.file.write(" (type smd_to_turn_gap))"); int cl_count = p_par.board.rules.clearance_matrix.get_class_count(); - for (int i = 1; i <= cl_count; ++i) - { + for (int i = 1; i <= cl_count; ++i) { write_clearance_rules(p_par, p_layer, i, cl_count, default_board_clearance); } p_par.file.end_scope(); } - + /** * Write the clearance rules, which are different from the default clearance. */ private static void write_clearance_rules(WriteScopeParameter p_par, - int p_layer, int p_cl_class, int p_max_cl_class, int p_default_clearance) throws java.io.IOException - { + int p_layer, int p_cl_class, int p_max_cl_class, int p_default_clearance) throws java.io.IOException { net.freerouting.rules.ClearanceMatrix cl_matrix = p_par.board.rules.clearance_matrix; - for (int i = p_cl_class; i < p_max_cl_class; ++i) - { + for (int i = p_cl_class; i < p_max_cl_class; ++i) { int curr_board_clearance = cl_matrix.value(p_cl_class, i, p_layer); - if (curr_board_clearance == p_default_clearance) - { + if (curr_board_clearance == p_default_clearance) { continue; } double curr_clearance = p_par.coordinate_transform.board_to_dsn(curr_board_clearance); @@ -274,110 +230,88 @@ private static void write_clearance_rules(WriteScopeParameter p_par, p_par.file.write("))"); } } - - public static ClearanceRule read_clearance_rule(Scanner p_scanner) - { - try - { + + public static ClearanceRule read_clearance_rule(Scanner p_scanner) { + try { double value; Object next_token = p_scanner.next_token(); - if (next_token instanceof Double) - { + if (next_token instanceof Double) { value = ((Double) next_token).doubleValue(); - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { value = ((Integer) next_token).intValue(); - } - else - { + } else { System.out.println("Rule.read_clearance_rule: number expected"); return null; } - Collection class_pairs = new LinkedList (); + Collection class_pairs = new LinkedList(); next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { - if (next_token != Keyword.OPEN_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { + if (next_token != Keyword.OPEN_BRACKET) { System.out.println("Rule.read_clearance_rule: ( expected"); return null; } next_token = p_scanner.next_token(); - if (next_token != Keyword.TYPE) - { + if (next_token != Keyword.TYPE) { System.out.println("Rule.read_clearance_rule: type expected"); return null; } - for (;;) - { + for (; ; ) { p_scanner.yybegin(SpecctraFileScanner.IGNORE_QUOTE); next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Rule.read_clearance_rule: string expected"); return null; } - class_pairs.add((String)next_token); + class_pairs.add((String) next_token); } next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Rule.read_clearance_rule: closing bracket expected"); return null; } } return new ClearanceRule(value, class_pairs); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Rule.read_clearance_rule: IO error scanning file"); return null; } - + } - - static public void write_item_clearance_class( String p_name, net.freerouting.datastructures.IndentFileWriter p_file, - net.freerouting.datastructures.IdentifierType p_identifier_type) throws java.io.IOException - { + + static public void write_item_clearance_class(String p_name, net.freerouting.datastructures.IndentFileWriter p_file, + net.freerouting.datastructures.IdentifierType p_identifier_type) throws java.io.IOException { p_file.new_line(); p_file.write("(clearance_class "); p_identifier_type.write(p_name, p_file); p_file.write(")"); } - - public static class WidthRule extends Rule - { - public WidthRule(double p_value) - { + + public static class WidthRule extends Rule { + final double value; + + public WidthRule(double p_value) { value = p_value; } - final double value; } - - public static class ClearanceRule extends Rule - { - public ClearanceRule(double p_value, Collection p_class_pairs) - { + + public static class ClearanceRule extends Rule { + final double value; + final Collection clearance_class_pairs; + public ClearanceRule(double p_value, Collection p_class_pairs) { value = p_value; clearance_class_pairs = p_class_pairs; } - final double value; - final Collection clearance_class_pairs; } - - public static class LayerRule - { - LayerRule(Collection p_layer_names, Collection p_rules) - { + + public static class LayerRule { + final Collection layer_names; + final Collection rules; + LayerRule(Collection p_layer_names, Collection p_rules) { layer_names = p_layer_names; rules = p_rules; } - final Collection layer_names; - final Collection rules; } } diff --git a/src/main/java/net/freerouting/designformats/specctra/RulesFile.java b/src/main/java/net/freerouting/designformats/specctra/RulesFile.java index 98425864..48a84d88 100644 --- a/src/main/java/net/freerouting/designformats/specctra/RulesFile.java +++ b/src/main/java/net/freerouting/designformats/specctra/RulesFile.java @@ -21,182 +21,135 @@ package net.freerouting.designformats.specctra; +import net.freerouting.board.BasicBoard; import net.freerouting.datastructures.IndentFileWriter; -import net.freerouting.board.BasicBoard; - /** * File for saving the board rules, so that they can be restored after the Board * is creates anew from the host system. * * @author Alfons Wirtz */ -public class RulesFile -{ - - public static void write(net.freerouting.interactive.BoardHandling p_board_handling, java.io.OutputStream p_output_stream, String p_design_name) - { +public class RulesFile { + + public static void write(net.freerouting.interactive.BoardHandling p_board_handling, java.io.OutputStream p_output_stream, String p_design_name) { IndentFileWriter output_file = new IndentFileWriter(p_output_stream); BasicBoard routing_board = p_board_handling.get_routing_board(); WriteScopeParameter write_scope_parameter = new WriteScopeParameter(routing_board, p_board_handling.settings.autoroute_settings, - output_file, routing_board.communication.specctra_parser_info.string_quote, - routing_board.communication.coordinate_transform, false); - try - { + output_file, routing_board.communication.specctra_parser_info.string_quote, + routing_board.communication.coordinate_transform, false); + try { write_rules(write_scope_parameter, p_design_name); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to write rules to file"); } - try - { + try { output_file.close(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to close rules file"); } } - - public static boolean read(java.io.InputStream p_input_stream, String p_design_name, - net.freerouting.interactive.BoardHandling p_board_handling) - { + + public static boolean read(java.io.InputStream p_input_stream, String p_design_name, + net.freerouting.interactive.BoardHandling p_board_handling) { BasicBoard routing_board = p_board_handling.get_routing_board(); - Scanner scanner = new SpecctraFileScanner(p_input_stream); - try - { + Scanner scanner = new SpecctraFileScanner(p_input_stream); + try { Object curr_token = scanner.next_token(); - if (curr_token != Keyword.OPEN_BRACKET) - { + if (curr_token != Keyword.OPEN_BRACKET) { System.out.println("RulesFile.read: open bracket expected"); return false; } curr_token = scanner.next_token(); - if (curr_token != Keyword.RULES) - { + if (curr_token != Keyword.RULES) { System.out.println("RulesFile.read: keyword rules expected"); return false; } curr_token = scanner.next_token(); - if (curr_token != Keyword.PCB_SCOPE) - { + if (curr_token != Keyword.PCB_SCOPE) { System.out.println("RulesFile.read: keyword pcb expected"); return false; } scanner.yybegin(SpecctraFileScanner.NAME); curr_token = scanner.next_token(); - if (!(curr_token instanceof String) || !((String) curr_token).equals(p_design_name)) - { + if (!(curr_token instanceof String) || !((String) curr_token).equals(p_design_name)) { System.out.println("RulesFile.read: design_name not matching"); return false; } - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("RulesFile.read: IO error scanning file"); return false; } LayerStructure layer_structure = new LayerStructure(routing_board.layer_structure); CoordinateTransform coordinate_transform = routing_board.communication.coordinate_transform; Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("RulesFile.read: IO error scanning file"); return false; } - if (next_token == null) - { + if (next_token == null) { System.out.println("Structure.read_scope: unexpected end of file"); return false; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } boolean read_ok = true; - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.RULE) - { + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.RULE) { add_rules(Rule.read_scope(scanner), routing_board, null); - } - else if (next_token == Keyword.LAYER) - { + } else if (next_token == Keyword.LAYER) { add_layer_rules(scanner, routing_board); - } - else if (next_token == Keyword.PADSTACK) - { + } else if (next_token == Keyword.PADSTACK) { Library.read_padstack_scope(scanner, layer_structure, coordinate_transform, routing_board.library.padstacks); - } - else if (next_token == Keyword.VIA) - { + } else if (next_token == Keyword.VIA) { read_via_info(scanner, routing_board); - } - else if (next_token == Keyword.VIA_RULE) - { + } else if (next_token == Keyword.VIA_RULE) { read_via_rule(scanner, routing_board); - } - else if (next_token == Keyword.CLASS) - { + } else if (next_token == Keyword.CLASS) { read_net_class(scanner, layer_structure, routing_board); - } - else if (next_token == Keyword.SNAP_ANGLE) - { - + } else if (next_token == Keyword.SNAP_ANGLE) { + net.freerouting.board.AngleRestriction snap_angle = Structure.read_snap_angle(scanner); - if (snap_angle != null) - { + if (snap_angle != null) { routing_board.rules.set_trace_angle_restriction(snap_angle); } - } - else if (next_token == Keyword.AUTOROUTE_SETTINGS) - { - net.freerouting.interactive.AutorouteSettings autoroute_settings - = AutorouteSettings.read_scope(scanner, layer_structure); - if (autoroute_settings != null) - { - p_board_handling.settings.autoroute_settings = autoroute_settings; - } - } - else - { + } else if (next_token == Keyword.AUTOROUTE_SETTINGS) { + net.freerouting.interactive.AutorouteSettings autoroute_settings + = AutorouteSettings.read_scope(scanner, layer_structure); + if (autoroute_settings != null) { + p_board_handling.settings.autoroute_settings = autoroute_settings; + } + } else { ScopeKeyword.skip_scope(scanner); } } - if (!read_ok) - { + if (!read_ok) { return false; } } return true; } - - private static void write_rules( WriteScopeParameter p_par, String p_design_name) throws java.io.IOException - { + + private static void write_rules(WriteScopeParameter p_par, String p_design_name) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("rules PCB "); p_par.file.write(p_design_name); Structure.write_snap_angle(p_par.file, p_par.board.rules.get_trace_angle_restriction()); - AutorouteSettings.write_scope(p_par.file, p_par.autoroute_settings, + AutorouteSettings.write_scope(p_par.file, p_par.autoroute_settings, p_par.board.layer_structure, p_par.identifier_type); // write the default rule using 0 as default layer. Rule.write_default_rule(p_par, 0); // write the via padstacks - for (int i = 1; i <= p_par.board.library.padstacks.count(); ++i) - { + for (int i = 1; i <= p_par.board.library.padstacks.count(); ++i) { net.freerouting.library.Padstack curr_padstack = p_par.board.library.padstacks.get(i); - if (p_par.board.library.get_via_padstack(curr_padstack.name )!= null) - { + if (p_par.board.library.get_via_padstack(curr_padstack.name) != null) { Library.write_padstack_scope(p_par, curr_padstack); } } @@ -205,114 +158,88 @@ private static void write_rules( WriteScopeParameter p_par, String p_design_name Network.write_net_classes(p_par); p_par.file.end_scope(); } - - private static void add_rules(java.util.Collection p_rules, BasicBoard p_board, String p_layer_name) - { + + private static void add_rules(java.util.Collection p_rules, BasicBoard p_board, String p_layer_name) { int layer_no = -1; - if (p_layer_name != null) - { + if (p_layer_name != null) { layer_no = p_board.layer_structure.get_no(p_layer_name); - if (layer_no < 0) - { + if (layer_no < 0) { System.out.println("RulesFile.add_rules: layer not found"); } } CoordinateTransform coordinate_transform = p_board.communication.coordinate_transform; String string_quote = p_board.communication.specctra_parser_info.string_quote; - for (Rule curr_rule : p_rules) - { - if (curr_rule instanceof Rule.WidthRule) - { - double wire_width = ((Rule.WidthRule)curr_rule).value; - int trace_halfwidth = (int) Math.round(coordinate_transform.dsn_to_board(wire_width) / 2); - if (layer_no < 0) - { + for (Rule curr_rule : p_rules) { + if (curr_rule instanceof Rule.WidthRule) { + double wire_width = ((Rule.WidthRule) curr_rule).value; + int trace_halfwidth = (int) Math.round(coordinate_transform.dsn_to_board(wire_width) / 2); + if (layer_no < 0) { p_board.rules.set_default_trace_half_widths(trace_halfwidth); - } - else - { + } else { p_board.rules.set_default_trace_half_width(layer_no, trace_halfwidth); } - } - else if (curr_rule instanceof Rule.ClearanceRule) - { - Structure.set_clearance_rule(( Rule.ClearanceRule)curr_rule, layer_no, coordinate_transform, p_board.rules, string_quote); + } else if (curr_rule instanceof Rule.ClearanceRule) { + Structure.set_clearance_rule((Rule.ClearanceRule) curr_rule, layer_no, coordinate_transform, p_board.rules, string_quote); } } } - - private static boolean add_layer_rules(Scanner p_scanner, BasicBoard p_board) - { - try - { + + private static boolean add_layer_rules(Scanner p_scanner, BasicBoard p_board) { + try { Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("RulesFile.add_layer_rules: String expected"); return false; } String layer_string = (String) next_token; next_token = p_scanner.next_token(); - while (next_token != Keyword.CLOSED_BRACKET) - { - if (next_token != Keyword.OPEN_BRACKET) - { + while (next_token != Keyword.CLOSED_BRACKET) { + if (next_token != Keyword.OPEN_BRACKET) { System.out.println("RulesFile.add_layer_rules: ( expected"); return false; } next_token = p_scanner.next_token(); - if (next_token == Keyword.RULE) - { + if (next_token == Keyword.RULE) { java.util.Collection curr_rules = Rule.read_scope(p_scanner); add_rules(curr_rules, p_board, layer_string); - } - else - { + } else { ScopeKeyword.skip_scope(p_scanner); } next_token = p_scanner.next_token(); } return true; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("RulesFile.add_layer_rules: IO error scanning file"); return false; } } - private static boolean read_via_info(Scanner p_scanner, BasicBoard p_board) - { + + private static boolean read_via_info(Scanner p_scanner, BasicBoard p_board) { net.freerouting.rules.ViaInfo curr_via_info = Network.read_via_info(p_scanner, p_board); - if (curr_via_info == null) - { + if (curr_via_info == null) { return false; } net.freerouting.rules.ViaInfo existing_via = p_board.rules.via_infos.get(curr_via_info.get_name()); - if (existing_via != null) - { + if (existing_via != null) { // replace existing via info - p_board.rules.via_infos.remove(existing_via); + p_board.rules.via_infos.remove(existing_via); } p_board.rules.via_infos.add(curr_via_info); return true; } - - private static boolean read_via_rule(Scanner p_scanner, BasicBoard p_board) - { + + private static boolean read_via_rule(Scanner p_scanner, BasicBoard p_board) { java.util.Collection via_rule = Network.read_via_rule(p_scanner, p_board); - if (via_rule == null) - { + if (via_rule == null) { return false; } Network.add_via_rule(via_rule, p_board); return true; } - - private static boolean read_net_class(Scanner p_scanner, LayerStructure p_layer_structure, BasicBoard p_board) - { + + private static boolean read_net_class(Scanner p_scanner, LayerStructure p_layer_structure, BasicBoard p_board) { NetClass curr_class = NetClass.read_scope(p_scanner); - if (curr_class == null) - { + if (curr_class == null) { return false; } Network.insert_net_class(curr_class, p_layer_structure, p_board, p_board.communication.coordinate_transform, false); diff --git a/src/main/java/net/freerouting/designformats/specctra/Scanner.java b/src/main/java/net/freerouting/designformats/specctra/Scanner.java index 659c6041..c07e337b 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Scanner.java +++ b/src/main/java/net/freerouting/designformats/specctra/Scanner.java @@ -23,15 +23,14 @@ /** * Interface for scanner generated by jflex. * - * @author alfons + * @author alfons */ -public interface Scanner -{ +public interface Scanner { /** * Reads the next token from the input file. */ Object next_token() throws java.io.IOException; - + /** * Starts a new state. */ diff --git a/src/main/java/net/freerouting/designformats/specctra/ScopeKeyword.java b/src/main/java/net/freerouting/designformats/specctra/ScopeKeyword.java index 242727bf..ae4e25de 100644 --- a/src/main/java/net/freerouting/designformats/specctra/ScopeKeyword.java +++ b/src/main/java/net/freerouting/designformats/specctra/ScopeKeyword.java @@ -21,104 +21,80 @@ package net.freerouting.designformats.specctra; /** - * - * @author alfons + * @author alfons */ /** Keywords defining a scope object*/ -public class ScopeKeyword extends Keyword -{ - public ScopeKeyword(String p_name) - { +public class ScopeKeyword extends Keyword { + public ScopeKeyword(String p_name) { super(p_name); } - + /** * Scips the current scope while reading a dsn file. * Returns false, if no legal scope was found. */ - public static boolean skip_scope(Scanner p_scanner) - { + public static boolean skip_scope(Scanner p_scanner) { int open_bracked_count = 1; - while (open_bracked_count > 0) - { + while (open_bracked_count > 0) { p_scanner.yybegin(SpecctraFileScanner.NAME); Object curr_token = null; - try - { + try { curr_token = p_scanner.next_token(); - } - catch (Exception e) - { + } catch (Exception e) { System.out.println("ScopeKeyword.skip_scope: Error while scanning file"); System.out.println(e); return false; } - if (curr_token == null) - { + if (curr_token == null) { return false; // end of file } - if (curr_token == Keyword.OPEN_BRACKET) - { + if (curr_token == Keyword.OPEN_BRACKET) { ++open_bracked_count; - } - else if (curr_token == Keyword.CLOSED_BRACKET) - { + } else if (curr_token == Keyword.CLOSED_BRACKET) { --open_bracked_count; } } return true; } - + /** * Reads the next scope of this keyword from dsn file. */ - public boolean read_scope(ReadScopeParameter p_par) - { + public boolean read_scope(ReadScopeParameter p_par) { Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = p_par.scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("ScopeKeyword.read_scope: IO error scanning file"); System.out.println(e); return false; } - if (next_token == null) - { + if (next_token == null) { // end of file return true; } - if (next_token == CLOSED_BRACKET) - { + if (next_token == CLOSED_BRACKET) { // end of scope break; } - - if (prev_token == OPEN_BRACKET) - { + + if (prev_token == OPEN_BRACKET) { ScopeKeyword next_scope; // a new scope is expected - if (next_token instanceof ScopeKeyword) - { + if (next_token instanceof ScopeKeyword) { next_scope = (ScopeKeyword) next_token; - if (!next_scope.read_scope(p_par)) - { + if (!next_scope.read_scope(p_par)) { return false; } - - } - else - { + + } else { // skip unknown scope skip_scope(p_par.scanner); } - + } } return true; diff --git a/src/main/java/net/freerouting/designformats/specctra/SessionFile.java b/src/main/java/net/freerouting/designformats/specctra/SessionFile.java index 7179b47f..d28d59c3 100644 --- a/src/main/java/net/freerouting/designformats/specctra/SessionFile.java +++ b/src/main/java/net/freerouting/designformats/specctra/SessionFile.java @@ -20,73 +20,59 @@ package net.freerouting.designformats.specctra; -import java.util.Collection; -import java.util.Iterator; - -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Point; - import net.freerouting.board.BasicBoard; +import net.freerouting.board.ConductionArea; import net.freerouting.board.PolylineTrace; import net.freerouting.board.Via; -import net.freerouting.board.ConductionArea; -import net.freerouting.datastructures.IndentFileWriter; import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Point; + +import java.util.Collection; +import java.util.Iterator; /** * Methods to handle a Specctra session file. * - * @author alfons + * @author alfons */ -public class SessionFile -{ +public class SessionFile { /** * Creates a Specctra session file to update the host system from the RoutingBooard */ - public static boolean write( BasicBoard p_board, java.io.OutputStream p_output_stream, String p_design_name) - { - if (p_output_stream == null) - { + public static boolean write(BasicBoard p_board, java.io.OutputStream p_output_stream, String p_design_name) { + if (p_output_stream == null) { return false; } IndentFileWriter output_file = null; - try - { + try { output_file = new IndentFileWriter(p_output_stream); - } - catch (Exception e) - { + } catch (Exception e) { System.out.println("unable to create session file"); return false; } String session_name = p_design_name.replace(".dsn", ".ses"); - try - { - String [] reserved_chars = {"(", ")", " ", "-"}; + try { + String[] reserved_chars = {"(", ")", " ", "-"}; IdentifierType identifier_type = new IdentifierType(reserved_chars, p_board.communication.specctra_parser_info.string_quote); write_session_scope(p_board, identifier_type, output_file, session_name, p_design_name); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to write session file"); return false; } - try - { + try { output_file.close(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to close session file"); return false; } return true; } - + private static void write_session_scope(BasicBoard p_board, IdentifierType p_identifier_type, - IndentFileWriter p_file, String p_session_name, String p_design_name) throws java.io.IOException - { - double scale_factor = p_board.communication.coordinate_transform.dsn_to_board(1)/p_board.communication.resolution; + IndentFileWriter p_file, String p_session_name, String p_design_name) throws java.io.IOException { + double scale_factor = p_board.communication.coordinate_transform.dsn_to_board(1) / p_board.communication.resolution; CoordinateTransform coordinate_transform = new CoordinateTransform(scale_factor, 0, 0); p_file.start_scope(); p_file.write("session "); @@ -100,50 +86,41 @@ private static void write_session_scope(BasicBoard p_board, IdentifierType p_ide write_routes(p_board, p_identifier_type, coordinate_transform, p_file); p_file.end_scope(); } - + public static void write_placement(BasicBoard p_board, IdentifierType p_identifier_type, - CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException - { + CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException { p_file.start_scope(); p_file.write("placement"); Resolution.write_scope(p_file, p_board.communication); - - for (int i = 1; i <= p_board.library.packages.count(); ++i) - { + + for (int i = 1; i <= p_board.library.packages.count(); ++i) { write_components(p_board, p_identifier_type, p_coordinate_transform, p_file, p_board.library.packages.get(i)); } p_file.end_scope(); } - + /** * Writes all components with the package p_package to the session file. */ public static void write_components(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, - IndentFileWriter p_file, net.freerouting.library.Package p_package) throws java.io.IOException - { - Collection board_items = p_board.get_items(); + IndentFileWriter p_file, net.freerouting.library.Package p_package) throws java.io.IOException { + Collection board_items = p_board.get_items(); boolean component_found = false; - for (int i = 1; i <= p_board.components.count(); ++i) - { - net.freerouting.board.Component curr_component = p_board.components.get(i); - if (curr_component.get_package() == p_package) - { + for (int i = 1; i <= p_board.components.count(); ++i) { + net.freerouting.board.Component curr_component = p_board.components.get(i); + if (curr_component.get_package() == p_package) { // check, if not all items of the component are deleted boolean undeleted_item_found = false; Iterator it = board_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { net.freerouting.board.Item curr_item = it.next(); - if (curr_item.get_component_no() == curr_component.no) - { + if (curr_item.get_component_no() == curr_component.no) { undeleted_item_found = true; break; } } - if (undeleted_item_found) - { - if (!component_found) - { + if (undeleted_item_found) { + if (!component_found) { // write the scope header p_file.start_scope(); p_file.write("component "); @@ -154,15 +131,13 @@ public static void write_components(BasicBoard p_board, IdentifierType p_identif } } } - if (component_found) - { + if (component_found) { p_file.end_scope(); } } - + public static void write_component(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, - IndentFileWriter p_file, net.freerouting.board.Component p_component) throws java.io.IOException - { + IndentFileWriter p_file, net.freerouting.board.Component p_component) throws java.io.IOException { p_file.new_line(); p_file.write("(place "); p_identifier_type.write(p_component.name, p_file); @@ -173,60 +148,47 @@ public static void write_component(BasicBoard p_board, IdentifierType p_identifi p_file.write(x_coor.toString()); p_file.write(" "); p_file.write(y_coor.toString()); - if (p_component.placed_on_front()) - { + if (p_component.placed_on_front()) { p_file.write(" front "); - } - else - { + } else { p_file.write(" back "); } int rotation = (int) Math.round(p_component.get_rotation_in_degree()); p_file.write((new Integer(rotation).toString())); - if (p_component.position_fixed) - { + if (p_component.position_fixed) { p_file.new_line(); p_file.write(" (lock_type position)"); } p_file.write(")"); } - + public static void write_was_is(BasicBoard p_board, IdentifierType p_identifier_type, - IndentFileWriter p_file) throws java.io.IOException - { + IndentFileWriter p_file) throws java.io.IOException { p_file.start_scope(); p_file.write("was_is"); Collection board_pins = p_board.get_pins(); - for (net.freerouting.board.Pin curr_pin : board_pins) - { + for (net.freerouting.board.Pin curr_pin : board_pins) { net.freerouting.board.Pin swapped_with = curr_pin.get_changed_to(); - if (curr_pin.get_changed_to() != curr_pin) - { + if (curr_pin.get_changed_to() != curr_pin) { p_file.new_line(); p_file.write("(pins "); net.freerouting.board.Component curr_cmp = p_board.components.get(curr_pin.get_component_no()); - if (curr_cmp != null) - { + if (curr_cmp != null) { p_identifier_type.write(curr_cmp.name, p_file); p_file.write("-"); net.freerouting.library.Package.Pin package_pin = curr_cmp.get_package().get_pin(curr_pin.get_index_in_package()); p_identifier_type.write(package_pin.name, p_file); - } - else - { + } else { System.out.println("SessionFile.write_was_is: component not found"); } p_file.write(" "); net.freerouting.board.Component swap_cmp = p_board.components.get(swapped_with.get_component_no()); - if (swap_cmp != null) - { + if (swap_cmp != null) { p_identifier_type.write(swap_cmp.name, p_file); p_file.write("-"); net.freerouting.library.Package.Pin package_pin = swap_cmp.get_package().get_pin(swapped_with.get_index_in_package()); p_identifier_type.write(package_pin.name, p_file); - } - else - { + } else { System.out.println("SessionFile.write_was_is: component not found"); } p_file.write(")"); @@ -234,68 +196,57 @@ public static void write_was_is(BasicBoard p_board, IdentifierType p_identifier_ } p_file.end_scope(); } - + private static void write_routes(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, - IndentFileWriter p_file) throws java.io.IOException - { + IndentFileWriter p_file) throws java.io.IOException { p_file.start_scope(); p_file.write("routes "); Resolution.write_scope(p_file, p_board.communication); - Parser.write_scope(p_file,p_board.communication.specctra_parser_info, p_identifier_type, true); + Parser.write_scope(p_file, p_board.communication.specctra_parser_info, p_identifier_type, true); write_library(p_board, p_identifier_type, p_coordinate_transform, p_file); write_network(p_board, p_identifier_type, p_coordinate_transform, p_file); p_file.end_scope(); } - + private static void write_library(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, - IndentFileWriter p_file) throws java.io.IOException - { + IndentFileWriter p_file) throws java.io.IOException { p_file.start_scope(); p_file.write("library_out "); - for (int i = 0; i < p_board.library.via_padstack_count(); ++i) - { + for (int i = 0; i < p_board.library.via_padstack_count(); ++i) { write_padstack(p_board.library.get_via_padstack(i), p_board, p_identifier_type, p_coordinate_transform, p_file); } p_file.end_scope(); } - + private static void write_padstack(net.freerouting.library.Padstack p_padstack, BasicBoard p_board, IdentifierType p_identifier_type, - CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) - throws java.io.IOException - { + CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) + throws java.io.IOException { // search the layer range of the padstack int first_layer_no = 0; - while (first_layer_no < p_board.get_layer_count()) - { - if (p_padstack.get_shape(first_layer_no) != null) - { + while (first_layer_no < p_board.get_layer_count()) { + if (p_padstack.get_shape(first_layer_no) != null) { break; } ++first_layer_no; } int last_layer_no = p_board.get_layer_count() - 1; - while (last_layer_no >= 0 ) - { - if (p_padstack.get_shape(last_layer_no) != null) - { + while (last_layer_no >= 0) { + if (p_padstack.get_shape(last_layer_no) != null) { break; } --last_layer_no; } - if (first_layer_no >= p_board.get_layer_count() || last_layer_no < 0) - { + if (first_layer_no >= p_board.get_layer_count() || last_layer_no < 0) { System.out.println("SessionFile.write_padstack: padstack shape not found"); return; } - + p_file.start_scope(); p_file.write("padstack "); p_identifier_type.write(p_padstack.name, p_file); - for (int i = first_layer_no; i <= last_layer_no; ++i) - { + for (int i = first_layer_no; i <= last_layer_no; ++i) { net.freerouting.geometry.planar.Shape curr_board_shape = p_padstack.get_shape(i); - if (curr_board_shape == null) - { + if (curr_board_shape == null) { continue; } net.freerouting.board.Layer board_layer = p_board.layer_structure.arr[i]; @@ -306,113 +257,91 @@ private static void write_padstack(net.freerouting.library.Padstack p_padstack, curr_shape.write_scope_int(p_file, p_identifier_type); p_file.end_scope(); } - if (!p_padstack.attach_allowed) - { + if (!p_padstack.attach_allowed) { p_file.new_line(); p_file.write("(attach off)"); } p_file.end_scope(); } - - - + + private static void write_network(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, - IndentFileWriter p_file) throws java.io.IOException - { + IndentFileWriter p_file) throws java.io.IOException { p_file.start_scope(); p_file.write("network_out "); - for (int i = 1; i <= p_board.rules.nets.max_net_no(); ++i) - { + for (int i = 1; i <= p_board.rules.nets.max_net_no(); ++i) { write_net(i, p_board, p_identifier_type, p_coordinate_transform, p_file); } p_file.end_scope(); } - + private static void write_net(int p_net_no, BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, - IndentFileWriter p_file) throws java.io.IOException - { + IndentFileWriter p_file) throws java.io.IOException { Collection net_items = p_board.get_connectable_items(p_net_no); boolean header_written = false; Iterator it = net_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { net.freerouting.board.Item curr_item = it.next(); - if (curr_item.get_fixed_state() == net.freerouting.board.FixedState.SYSTEM_FIXED) - { + if (curr_item.get_fixed_state() == net.freerouting.board.FixedState.SYSTEM_FIXED) { continue; } boolean is_wire = curr_item instanceof PolylineTrace; boolean is_via = curr_item instanceof Via; - boolean is_conduction_area = curr_item instanceof ConductionArea - && p_board.layer_structure.arr [curr_item.first_layer()].is_signal; - if (!header_written && (is_wire || is_via || is_conduction_area)) - { + boolean is_conduction_area = curr_item instanceof ConductionArea + && p_board.layer_structure.arr[curr_item.first_layer()].is_signal; + if (!header_written && (is_wire || is_via || is_conduction_area)) { p_file.start_scope(); p_file.write("net "); net.freerouting.rules.Net curr_net = p_board.rules.nets.get(p_net_no); - if (curr_net == null) - { + if (curr_net == null) { System.out.println("SessionFile.write_net: net not found"); - } - else - { + } else { p_identifier_type.write(curr_net.name, p_file); } header_written = true; } - if (is_wire) - { - write_wire((PolylineTrace)curr_item, p_board, p_identifier_type, p_coordinate_transform, p_file); - } - else if (is_via) - { + if (is_wire) { + write_wire((PolylineTrace) curr_item, p_board, p_identifier_type, p_coordinate_transform, p_file); + } else if (is_via) { write_via((Via) curr_item, p_board, p_identifier_type, p_coordinate_transform, p_file); - } - else if (is_conduction_area) - { - write_conduction_area( (ConductionArea) curr_item, p_board, p_identifier_type, - p_coordinate_transform, p_file); + } else if (is_conduction_area) { + write_conduction_area((ConductionArea) curr_item, p_board, p_identifier_type, + p_coordinate_transform, p_file); } } - if (header_written) - { + if (header_written) { p_file.end_scope(); } } - + private static void write_wire(PolylineTrace p_wire, BasicBoard p_board, IdentifierType p_identifier_type, - CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException - { + CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException { int layer_no = p_wire.get_layer(); net.freerouting.board.Layer board_layer = p_board.layer_structure.arr[layer_no]; int wire_width = (int) Math.round(p_coordinate_transform.board_to_dsn(2 * p_wire.get_half_width())); p_file.start_scope(); p_file.write("wire"); Point[] corner_arr = p_wire.polyline().corner_arr(); - int [] coors = new int [2 * corner_arr.length]; + int[] coors = new int[2 * corner_arr.length]; int corner_index = 0; - int [] prev_coors = null; - for (int i = 0; i < corner_arr.length; ++i) - { + int[] prev_coors = null; + for (int i = 0; i < corner_arr.length; ++i) { double[] curr_float_coors = p_coordinate_transform.board_to_dsn(corner_arr[i].to_float()); - int [] curr_coors = new int[2]; + int[] curr_coors = new int[2]; curr_coors[0] = (int) Math.round(curr_float_coors[0]); curr_coors[1] = (int) Math.round(curr_float_coors[1]); - if (i == 0 || ( curr_coors[0] != prev_coors[0] || curr_coors[1] != prev_coors[1])) - { + if (i == 0 || (curr_coors[0] != prev_coors[0] || curr_coors[1] != prev_coors[1])) { coors[corner_index] = curr_coors[0]; ++corner_index; coors[corner_index] = curr_coors[1]; ++corner_index; prev_coors = curr_coors; - + } } - if (corner_index < coors.length) - { - int [] adjusted_coors = new int[corner_index]; - for (int i = 0; i < adjusted_coors.length; ++i) - { + if (corner_index < coors.length) { + int[] adjusted_coors = new int[corner_index]; + for (int i = 0; i < adjusted_coors.length; ++i) { adjusted_coors[i] = coors[i]; } coors = adjusted_coors; @@ -421,10 +350,9 @@ private static void write_wire(PolylineTrace p_wire, BasicBoard p_board, Identif write_fixed_state(p_file, p_wire.get_fixed_state()); p_file.end_scope(); } - + private static void write_via(Via p_via, BasicBoard p_board, IdentifierType p_identifier_type, - CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException - { + CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException { net.freerouting.library.Padstack via_padstack = p_via.get_padstack(); FloatPoint via_location = p_via.get_center().to_float(); p_file.start_scope(); @@ -440,37 +368,30 @@ private static void write_via(Via p_via, BasicBoard p_board, IdentifierType p_id write_fixed_state(p_file, p_via.get_fixed_state()); p_file.end_scope(); } - - static private void write_fixed_state(IndentFileWriter p_file, net.freerouting.board.FixedState p_fixed_state) throws java.io.IOException - { - if (p_fixed_state.ordinal() <= net.freerouting.board.FixedState.SHOVE_FIXED.ordinal()) - { + + static private void write_fixed_state(IndentFileWriter p_file, net.freerouting.board.FixedState p_fixed_state) throws java.io.IOException { + if (p_fixed_state.ordinal() <= net.freerouting.board.FixedState.SHOVE_FIXED.ordinal()) { return; } p_file.new_line(); p_file.write("(type "); - if (p_fixed_state == net.freerouting.board.FixedState.SYSTEM_FIXED) - { + if (p_fixed_state == net.freerouting.board.FixedState.SYSTEM_FIXED) { p_file.write("fix)"); - } - else - { + } else { p_file.write("protect)"); } } - + private static void write_path(String p_layer_name, int p_width, int[] p_coors, IdentifierType p_identifier_type, - IndentFileWriter p_file) - throws java.io.IOException - { + IndentFileWriter p_file) + throws java.io.IOException { p_file.start_scope(); p_file.write("path "); p_identifier_type.write(p_layer_name, p_file); p_file.write(" "); p_file.write((new Integer(p_width)).toString()); - int corner_count = p_coors.length/ 2; - for (int i = 0; i < corner_count; ++i) - { + int corner_count = p_coors.length / 2; + for (int i = 0; i < corner_count; ++i) { p_file.new_line(); p_file.write(new Integer(p_coors[2 * i]).toString()); p_file.write(" "); @@ -478,42 +399,35 @@ private static void write_path(String p_layer_name, int p_width, int[] p_coors, } p_file.end_scope(); } - - private static void write_conduction_area( ConductionArea p_conduction_area, BasicBoard p_board, - IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, - IndentFileWriter p_file) throws java.io.IOException - { + + private static void write_conduction_area(ConductionArea p_conduction_area, BasicBoard p_board, + IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform, + IndentFileWriter p_file) throws java.io.IOException { int net_count = p_conduction_area.net_count(); - if (net_count <= 0 || net_count > 1) - { + if (net_count <= 0 || net_count > 1) { System.out.println("SessionFile.write_conduction_area: unexpected net count"); return; } net.freerouting.geometry.planar.Area curr_area = p_conduction_area.get_area(); int layer_no = p_conduction_area.get_layer(); - net.freerouting.board.Layer board_layer = p_board.layer_structure.arr[ layer_no]; + net.freerouting.board.Layer board_layer = p_board.layer_structure.arr[layer_no]; Layer conduction_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal); net.freerouting.geometry.planar.Shape boundary_shape; - net.freerouting.geometry.planar.Shape [] holes; - if (curr_area instanceof net.freerouting.geometry.planar.Shape) - { + net.freerouting.geometry.planar.Shape[] holes; + if (curr_area instanceof net.freerouting.geometry.planar.Shape) { boundary_shape = (net.freerouting.geometry.planar.Shape) curr_area; - holes = new net.freerouting.geometry.planar.Shape [0]; - } - else - { + holes = new net.freerouting.geometry.planar.Shape[0]; + } else { boundary_shape = curr_area.get_border(); holes = curr_area.get_holes(); } p_file.start_scope(); p_file.write("wire "); Shape dsn_shape = p_coordinate_transform.board_to_dsn(boundary_shape, conduction_layer); - if (dsn_shape != null) - { + if (dsn_shape != null) { dsn_shape.write_scope_int(p_file, p_identifier_type); } - for (int i = 0; i < holes.length; ++i) - { + for (int i = 0; i < holes.length; ++i) { Shape dsn_hole = p_coordinate_transform.board_to_dsn(holes[i], conduction_layer); dsn_hole.write_hole_scope(p_file, p_identifier_type); } diff --git a/src/main/java/net/freerouting/designformats/specctra/SessionToEagle.java b/src/main/java/net/freerouting/designformats/specctra/SessionToEagle.java index 9f9a4bb7..f25db905 100644 --- a/src/main/java/net/freerouting/designformats/specctra/SessionToEagle.java +++ b/src/main/java/net/freerouting/designformats/specctra/SessionToEagle.java @@ -26,126 +26,135 @@ * * @author Alfons Wirtz */ -public class SessionToEagle extends javax.swing.JFrame -{ - +public class SessionToEagle extends javax.swing.JFrame { + + /** + * The function for scanning the session file + */ + private final Scanner scanner; + /** + * The generated Eagle script file. + */ + private final java.io.OutputStreamWriter out_file; + /** + * Some information is read from the board, because it is not contained in the speccctra session file. + */ + private final net.freerouting.board.BasicBoard board; + /** + * The layer structure in specctra format + */ + private final LayerStructure specctra_layer_structure; + private final net.freerouting.board.Unit unit; + /** + * The scale factor for transforming coordinates from the session file to Eagle + */ + private final double session_file_scale_denominator; + /** + * The scale factor for transforming coordinates from the board to Eagle + */ + private final double board_scale_factor; + + SessionToEagle(Scanner p_scanner, java.io.OutputStreamWriter p_out_file, net.freerouting.board.BasicBoard p_board, + net.freerouting.board.Unit p_unit, double p_session_file_scale_dominator, double p_board_scale_factor) { + scanner = p_scanner; + out_file = p_out_file; + board = p_board; + this.specctra_layer_structure = new LayerStructure(p_board.layer_structure); + unit = p_unit; + session_file_scale_denominator = p_session_file_scale_dominator; + board_scale_factor = p_board_scale_factor; + } + public static boolean get_instance(java.io.InputStream p_session, java.io.OutputStream p_output_stream, - net.freerouting.board.BasicBoard p_board) - { - if (p_output_stream == null) - { + net.freerouting.board.BasicBoard p_board) { + if (p_output_stream == null) { return false; } - + // create a scanner for reading the session_file. - + Scanner scanner = new SpecctraFileScanner(p_session); - + // create a file_writer for the eagle script file. java.io.OutputStreamWriter file_writer = new java.io.OutputStreamWriter(p_output_stream); - + boolean result = true; - + double board_scale_factor = p_board.communication.coordinate_transform.board_to_dsn(1); SessionToEagle new_instance = new SessionToEagle(scanner, file_writer, p_board, - p_board.communication.unit, p_board.communication.resolution, board_scale_factor); - - try - { + p_board.communication.unit, p_board.communication.resolution, board_scale_factor); + + try { result = new_instance.process_session_scope(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to process session scope"); result = false; } - + // close files - try - { + try { p_session.close(); file_writer.close(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to close files"); } return result; } - - SessionToEagle(Scanner p_scanner, java.io.OutputStreamWriter p_out_file, net.freerouting.board.BasicBoard p_board, - net.freerouting.board.Unit p_unit, double p_session_file_scale_dominator, double p_board_scale_factor) - { - scanner = p_scanner; - out_file = p_out_file; - board = p_board; - this.specctra_layer_structure = new LayerStructure(p_board.layer_structure); - unit = p_unit; - session_file_scale_denominator = p_session_file_scale_dominator; - board_scale_factor = p_board_scale_factor; - } - + /** * Processes the outmost scope of the session file. * Returns false, if an error occured. */ - private boolean process_session_scope() throws java.io.IOException - { - + private boolean process_session_scope() throws java.io.IOException { + // read the first line of the session file Object next_token = null; - for (int i = 0; i < 3; ++i) - { + for (int i = 0; i < 3; ++i) { next_token = this.scanner.next_token(); boolean keyword_ok = true; - if (i == 0) - { + if (i == 0) { keyword_ok = (next_token == Keyword.OPEN_BRACKET); - } - else if (i == 1) - { + } else if (i == 1) { keyword_ok = (next_token == Keyword.SESSION); this.scanner.yybegin(SpecctraFileScanner.NAME); // to overread the name of the pcb for i = 2 } - if (!keyword_ok) - { + if (!keyword_ok) { System.out.println("SessionToEagle.process_session_scope specctra session file format expected"); return false; } } - + // Write the header of the eagle script file. - + this.out_file.write("GRID "); this.out_file.write(this.unit.toString()); this.out_file.write("\n"); this.out_file.write("SET WIRE_BEND 2\n"); this.out_file.write("SET OPTIMIZING OFF\n"); - + // Activate all layers in Eagle. - - for (int i = 0; i < this.board.layer_structure.arr.length; ++i) - { + + for (int i = 0; i < this.board.layer_structure.arr.length; ++i) { this.out_file.write("LAYER " + this.get_eagle_layer_string(i) + ";\n"); } - + this.out_file.write("LAYER 17;\n"); this.out_file.write("LAYER 18;\n"); this.out_file.write("LAYER 19;\n"); this.out_file.write("LAYER 20;\n"); this.out_file.write("LAYER 23;\n"); this.out_file.write("LAYER 24;\n"); - + // Generate Code to remove the complete route. // Write a bounding rectangle with GROUP (Min_X-1 Min_Y-1) (Max_X+1 Max_Y+1); - + net.freerouting.geometry.planar.IntBox board_bounding_box = this.board.get_bounding_box(); - + Float min_x = (float) this.board_scale_factor * (board_bounding_box.ll.x - 1); Float min_y = (float) this.board_scale_factor * (board_bounding_box.ll.y - 1); Float max_x = (float) this.board_scale_factor * (board_bounding_box.ur.x + 1); Float max_y = (float) this.board_scale_factor * (board_bounding_box.ur.y + 1); - + this.out_file.write("GROUP ("); this.out_file.write(min_x.toString()); this.out_file.write(" "); @@ -156,41 +165,30 @@ else if (i == 1) this.out_file.write(max_y.toString()); this.out_file.write(");\n"); this.out_file.write("RIPUP;\n"); - + // read the direct subscopes of the session scope - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = this.scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { // end of file return true; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.ROUTES) - { - if (!process_routes_scope()) - { + + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.ROUTES) { + if (!process_routes_scope()) { return false; } - } - else if (next_token == Keyword.PLACEMENT_SCOPE) - { - if (!process_placement_scope()) - { + } else if (next_token == Keyword.PLACEMENT_SCOPE) { + if (!process_placement_scope()) { return false; } - } - else - { + } else { // overread all scopes except the routes scope for the time being ScopeKeyword.skip_scope(this.scanner); } @@ -200,66 +198,51 @@ else if (next_token == Keyword.PLACEMENT_SCOPE) this.out_file.write("RATSNEST\n"); return true; } - - private boolean process_placement_scope() throws java.io.IOException - { + + private boolean process_placement_scope() throws java.io.IOException { // read the component scopes Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = this.scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { // unexpected end of file return false; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - - if (prev_token == Keyword.OPEN_BRACKET) - { - - if (next_token == Keyword.COMPONENT_SCOPE) - { - if (!process_component_placement()) - { + + if (prev_token == Keyword.OPEN_BRACKET) { + + if (next_token == Keyword.COMPONENT_SCOPE) { + if (!process_component_placement()) { return false; } - } - else - { + } else { // skip unknown scope ScopeKeyword.skip_scope(this.scanner); } - + } } process_swapped_pins(); return true; } - - private boolean process_component_placement() throws java.io.IOException - { + + private boolean process_component_placement() throws java.io.IOException { ComponentPlacement component_placement = Component.read_scope(this.scanner); - if (component_placement == null) - { + if (component_placement == null) { return false; } - for (ComponentPlacement.ComponentLocation curr_location : component_placement.locations) - { + for (ComponentPlacement.ComponentLocation curr_location : component_placement.locations) { this.out_file.write("ROTATE ="); Integer rotation = (int) Math.round(curr_location.rotation); String rotation_string; - if (curr_location.is_front) - { + if (curr_location.is_front) { rotation_string = "R" + rotation.toString(); - } - else - { + } else { rotation_string = "MR" + rotation.toString(); } this.out_file.write(rotation_string); @@ -278,313 +261,248 @@ private boolean process_component_placement() throws java.io.IOException } return true; } - - private boolean process_routes_scope() throws java.io.IOException - { + + private boolean process_routes_scope() throws java.io.IOException { // read the direct subscopes of the routes scope boolean result = true; Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = this.scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { // unexpected end of file return false; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - - if (prev_token == Keyword.OPEN_BRACKET) - { - - if (next_token == Keyword.NETWORK_OUT) - { + + if (prev_token == Keyword.OPEN_BRACKET) { + + if (next_token == Keyword.NETWORK_OUT) { result = process_network_scope(); - } - else - { + } else { // skip unknown scope ScopeKeyword.skip_scope(this.scanner); } - + } } return result; } - - private boolean process_network_scope() throws java.io.IOException - { + + private boolean process_network_scope() throws java.io.IOException { boolean result = true; Object next_token = null; // read the net scopes - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = this.scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { // unexpected end of file return false; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - - if (prev_token == Keyword.OPEN_BRACKET) - { - - if (next_token == Keyword.NET) - { + + if (prev_token == Keyword.OPEN_BRACKET) { + + if (next_token == Keyword.NET) { result = process_net_scope(); - } - else - { + } else { // skip unknown scope ScopeKeyword.skip_scope(this.scanner); } - + } } return result; } - - private boolean process_net_scope() throws java.io.IOException - { + + private boolean process_net_scope() throws java.io.IOException { // read the net name Object next_token = this.scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("SessionToEagle.processnet_scope: String expected"); return false; } String net_name = (String) next_token; - + // Hier alle nicht gefixten Traces und Vias des Netz mit Namen net_name // in der Eagle Datenhaltung loeschen. - + // read the wires and vias of this net - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = this.scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { // end of file return true; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.WIRE) - { - if (!process_wire_scope(net_name)) - { + + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.WIRE) { + if (!process_wire_scope(net_name)) { return false; } - } - else if (next_token == Keyword.VIA) - { - if (!process_via_scope(net_name)) - { + } else if (next_token == Keyword.VIA) { + if (!process_via_scope(net_name)) { return false; } - } - else - { + } else { ScopeKeyword.skip_scope(this.scanner); } } } return true; } - - private boolean process_wire_scope(String p_net_name) throws java.io.IOException - { + + private boolean process_wire_scope(String p_net_name) throws java.io.IOException { PolygonPath wire_path = null; Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = this.scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { System.out.println("SessionToEagle.process_wire_scope: unexpected end of file"); return false; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.POLYGON_PATH) - { + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.POLYGON_PATH) { wire_path = Shape.read_polygon_path_scope(this.scanner, this.specctra_layer_structure); - } - else - { + } else { ScopeKeyword.skip_scope(this.scanner); } } } - if (wire_path == null) - { + if (wire_path == null) { // conduction areas are skipped return true; } - + this.out_file.write("CHANGE LAYER "); - + this.out_file.write(wire_path.layer.name); this.out_file.write(";\n"); - + //WIRE ['signal_name'] [width] [ROUND | FLAT] [curve | @radius] - + this.out_file.write("WIRE '"); - + this.out_file.write(p_net_name); this.out_file.write("' "); Double wire_width = wire_path.width / this.session_file_scale_denominator; this.out_file.write(wire_width.toString()); this.out_file.write(" ("); - for (int i = 0; i < wire_path.coordinate_arr.length; ++i) - { + for (int i = 0; i < wire_path.coordinate_arr.length; ++i) { Double wire_coor = wire_path.coordinate_arr[i] / this.session_file_scale_denominator; this.out_file.write(wire_coor.toString()); - if (i % 2 == 0) - { + if (i % 2 == 0) { this.out_file.write(" "); - } - else - { - if (i == wire_path.coordinate_arr.length - 1) - { + } else { + if (i == wire_path.coordinate_arr.length - 1) { this.out_file.write(")"); - } - else - { + } else { this.out_file.write(") ("); } } } this.out_file.write(";\n"); - + return true; } - - private boolean process_via_scope(String p_net_name) throws java.io.IOException - { + + private boolean process_via_scope(String p_net_name) throws java.io.IOException { // read the padstack name Object next_token = this.scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("SessionToEagle.process_via_scope: padstack name expected"); return false; } String padstack_name = (String) next_token; // read the location - double []location = new double [2]; - for (int i = 0; i < 2; ++i) - { + double[] location = new double[2]; + for (int i = 0; i < 2; ++i) { next_token = this.scanner.next_token(); - if (next_token instanceof Double) - { + if (next_token instanceof Double) { location[i] = ((Double) next_token).doubleValue(); - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { location[i] = ((Integer) next_token).intValue(); - } - else - { + } else { System.out.println("SessionToEagle.process_via_scope: number expected"); return false; } } next_token = this.scanner.next_token(); - while (next_token == Keyword.OPEN_BRACKET) - { + while (next_token == Keyword.OPEN_BRACKET) { // skip unknown scopes ScopeKeyword.skip_scope(this.scanner); next_token = this.scanner.next_token(); } - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("SessionToEagle.process_via_scope: closing bracket expected"); return false; } - - if (padstack_name == null) - { + + if (padstack_name == null) { System.out.println("SessionToEagle.process_via_scope: padstack_name missing"); return false; } - + net.freerouting.library.Padstack via_padstack = this.board.library.padstacks.get(padstack_name); - - if (via_padstack == null) - { + + if (via_padstack == null) { System.out.println("SessionToEagle.process_via_scope: via padstack not found"); return false; } - + net.freerouting.geometry.planar.ConvexShape via_shape = via_padstack.get_shape(via_padstack.from_layer()); - + Double via_diameter = via_shape.max_width() * this.board_scale_factor; - + // The Padstack name is of the form Name$drill_diameter$from_layer-to_layer - - String [] name_parts = via_padstack.name.split("\\$", 3); - + + String[] name_parts = via_padstack.name.split("\\$", 3); + // example CHANGE DRILL 0.2 - + this.out_file.write("CHANGE DRILL "); - if (name_parts.length > 1) - { + if (name_parts.length > 1) { this.out_file.write(name_parts[1]); - } - else - { + } else { // create a default drill, because it is needed in Eagle this.out_file.write("0.1"); } this.out_file.write(";\n"); - - + + //VIA ['signal_name'] [diameter] [shape] [layers] [flags] // Via Net2 0.6 round 1-4 (20.0, 222.0); this.out_file.write("VIA '"); - + this.out_file.write(p_net_name); this.out_file.write("' "); - + //Durchmesser aus Padstack this.out_file.write(via_diameter.toString()); - + //Shape lesen und einsetzen Square / Round / Octagon - if (via_shape instanceof net.freerouting.geometry.planar.Circle) - { + if (via_shape instanceof net.freerouting.geometry.planar.Circle) { this.out_file.write(" round "); - } - else if (via_shape instanceof net.freerouting.geometry.planar.IntOctagon) - { + } else if (via_shape instanceof net.freerouting.geometry.planar.IntOctagon) { this.out_file.write(" octagon "); - } - else - { + } else { this.out_file.write(" square "); } this.out_file.write(get_eagle_layer_string(via_padstack.from_layer())); @@ -597,70 +515,55 @@ else if (via_shape instanceof net.freerouting.geometry.planar.IntOctagon) Double y_coor = location[1] / this.session_file_scale_denominator; this.out_file.write(y_coor.toString()); this.out_file.write(");\n"); - + return true; } - - private String get_eagle_layer_string(int p_layer_no) - { - if (p_layer_no < 0 || p_layer_no >= specctra_layer_structure.arr.length) - { + + private String get_eagle_layer_string(int p_layer_no) { + if (p_layer_no < 0 || p_layer_no >= specctra_layer_structure.arr.length) { return "0"; } - String [] name_pieces = this.specctra_layer_structure.arr[p_layer_no].name.split("#", 2); + String[] name_pieces = this.specctra_layer_structure.arr[p_layer_no].name.split("#", 2); return name_pieces[0]; } - - private boolean process_swapped_pins() throws java.io.IOException - { - for (int i = 1; i <= this.board.components.count(); ++i) - { - if (!process_swapped_pins(i)) - { + + private boolean process_swapped_pins() throws java.io.IOException { + for (int i = 1; i <= this.board.components.count(); ++i) { + if (!process_swapped_pins(i)) { return false; } } return true; } - - private boolean process_swapped_pins(int p_component_no) throws java.io.IOException - { + + private boolean process_swapped_pins(int p_component_no) throws java.io.IOException { java.util.Collection component_pins = this.board.get_component_pins(p_component_no); boolean component_has_swapped_pins = false; - for (net.freerouting.board.Pin curr_pin : component_pins) - { - if (curr_pin.get_changed_to() != curr_pin) - { - component_has_swapped_pins = true; + for (net.freerouting.board.Pin curr_pin : component_pins) { + if (curr_pin.get_changed_to() != curr_pin) { + component_has_swapped_pins = true; break; } } - if (!component_has_swapped_pins) - { + if (!component_has_swapped_pins) { return true; } PinInfo[] pin_info_arr = new PinInfo[component_pins.size()]; int i = 0; - for (net.freerouting.board.Pin curr_pin : component_pins) - { + for (net.freerouting.board.Pin curr_pin : component_pins) { pin_info_arr[i] = new PinInfo(curr_pin); ++i; } - for (i = 0; i < pin_info_arr.length; ++i) - { + for (i = 0; i < pin_info_arr.length; ++i) { PinInfo curr_pin_info = pin_info_arr[i]; - if (curr_pin_info.curr_changed_to != curr_pin_info.pin.get_changed_to()) - { + if (curr_pin_info.curr_changed_to != curr_pin_info.pin.get_changed_to()) { PinInfo other_pin_info = null; - for (int j = i + 1; j < pin_info_arr.length; ++j) - { - if (pin_info_arr[j].pin.get_changed_to() == curr_pin_info.pin) - { + for (int j = i + 1; j < pin_info_arr.length; ++j) { + if (pin_info_arr[j].pin.get_changed_to() == curr_pin_info.pin) { other_pin_info = pin_info_arr[j]; } } - if (other_pin_info == null) - { + if (other_pin_info == null) { System.out.println("SessuinToEagle.process_swapped_pins: other_pin_info not found"); return false; } @@ -671,21 +574,20 @@ private boolean process_swapped_pins(int p_component_no) throws java.io.IOExcept } return true; } - - private void write_pin_swap( net.freerouting.board.Pin p_pin_1, net.freerouting.board.Pin p_pin_2) throws java.io.IOException - { + + private void write_pin_swap(net.freerouting.board.Pin p_pin_1, net.freerouting.board.Pin p_pin_2) throws java.io.IOException { int layer_no = Math.max(p_pin_1.first_layer(), p_pin_2.first_layer()); String layer_name = board.layer_structure.arr[layer_no].name; - + this.out_file.write("CHANGE LAYER "); this.out_file.write(layer_name); this.out_file.write(";\n"); - - double [] location_1 = + + double[] location_1 = this.board.communication.coordinate_transform.board_to_dsn(p_pin_1.get_center().to_float()); - double [] location_2 = + double[] location_2 = this.board.communication.coordinate_transform.board_to_dsn(p_pin_2.get_center().to_float()); - + this.out_file.write("PINSWAP "); this.out_file.write(" ("); Double curr_coor = location_1[0]; @@ -701,38 +603,14 @@ private void write_pin_swap( net.freerouting.board.Pin p_pin_1, net.freerouting. this.out_file.write(curr_coor.toString()); this.out_file.write(");\n"); } - - - - /** The function for scanning the session file */ - private final Scanner scanner; - - /** The generated Eagle script file. */ - private final java.io.OutputStreamWriter out_file; - - /** Some information is read from the board, because it is not contained in the speccctra session file. */ - private final net.freerouting.board.BasicBoard board; - - /** The layer structure in specctra format */ - private final LayerStructure specctra_layer_structure; - - private final net.freerouting.board.Unit unit; - - /** The scale factor for transforming coordinates from the session file to Eagle */ - private final double session_file_scale_denominator; - - /** The scale factor for transforming coordinates from the board to Eagle */ - private final double board_scale_factor; - - private static class PinInfo - { - PinInfo(net.freerouting.board.Pin p_pin) - { + + private static class PinInfo { + final net.freerouting.board.Pin pin; + net.freerouting.board.Pin curr_changed_to; + PinInfo(net.freerouting.board.Pin p_pin) { pin = p_pin; curr_changed_to = p_pin; } - final net.freerouting.board.Pin pin; - net.freerouting.board.Pin curr_changed_to; } } diff --git a/src/main/java/net/freerouting/designformats/specctra/Shape.java b/src/main/java/net/freerouting/designformats/specctra/Shape.java index 12b04be0..0f824b06 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Shape.java +++ b/src/main/java/net/freerouting/designformats/specctra/Shape.java @@ -19,76 +19,56 @@ */ package net.freerouting.designformats.specctra; +import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.geometry.planar.PolylineShape; + import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import net.freerouting.geometry.planar.PolylineShape; -import net.freerouting.datastructures.IndentFileWriter; -import net.freerouting.datastructures.IdentifierType; - /** * Describes a shape in a Specctra dsn file. * - * @author alfons + * @author alfons */ -public abstract class Shape -{ +public abstract class Shape { - /** - * Writes a shape scope to a Specctra dsn file. - */ - public abstract void write_scope(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException; + public final Layer layer; - /** - * Writes a shape scope to a Specctra session file. - * In a session file all coordinates must be integer. - */ - public abstract void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException; + protected Shape(Layer p_layer) { + layer = p_layer; + } /** * Reads shape scope from a Specctra dsn file. * If p_layer_structure == null, only Layer.PCB and Layer.Signal are expected, no induvidual layers. */ - public static final Shape read_scope(Scanner p_scanner, LayerStructure p_layer_structure) - { + public static final Shape read_scope(Scanner p_scanner, LayerStructure p_layer_structure) { Shape result = null; - try - { + try { Object next_token = p_scanner.next_token(); - if (next_token == Keyword.OPEN_BRACKET) - { + if (next_token == Keyword.OPEN_BRACKET) { // overread the open bracket next_token = p_scanner.next_token(); } - if (next_token == Keyword.RECTANGLE) - { + if (next_token == Keyword.RECTANGLE) { result = Shape.read_rectangle_scope(p_scanner, p_layer_structure); - } - else if (next_token == Keyword.POLYGON) - { + } else if (next_token == Keyword.POLYGON) { result = Shape.read_polygon_scope(p_scanner, p_layer_structure); - } - else if (next_token == Keyword.CIRCLE) - { + } else if (next_token == Keyword.CIRCLE) { result = Shape.read_circle_scope(p_scanner, p_layer_structure); - } - else if (next_token == Keyword.POLYGON_PATH) - { + } else if (next_token == Keyword.POLYGON_PATH) { result = Shape.read_polygon_path_scope(p_scanner, p_layer_structure); - } - else - { + } else { // not a shape scope, skip it. ScopeKeyword.skip_scope(p_scanner); } - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Shape.read_scope: IO error scanning file"); System.out.println(e); return result; @@ -99,35 +79,25 @@ else if (next_token == Keyword.POLYGON_PATH) /** * Reads an object of type PolylinePath from the dsn-file. */ - public static PolylinePath read_polyline_path_scope(Scanner p_scanner, LayerStructure p_layer_structure) - { - try - { + public static PolylinePath read_polyline_path_scope(Scanner p_scanner, LayerStructure p_layer_structure) { + try { Layer layer = null; Object next_token = p_scanner.next_token(); - if (next_token == Keyword.PCB_SCOPE) - { + if (next_token == Keyword.PCB_SCOPE) { layer = Layer.PCB; - } - else if (next_token == Keyword.SIGNAL) - { + } else if (next_token == Keyword.SIGNAL) { layer = Layer.SIGNAL; - } - else - { - if (p_layer_structure == null) - { + } else { + if (p_layer_structure == null) { System.out.println("PolylinePath.read_scope: only layer types pcb or signal expected"); return null; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("PolylinePath.read_scope: layer name string expected"); return null; } int layer_no = p_layer_structure.get_no((String) next_token); - if (layer_no < 0 || layer_no >= p_layer_structure.arr.length) - { + if (layer_no < 0 || layer_no >= p_layer_structure.arr.length) { System.out.print("Shape.read_polyline_path_scope: layer name "); System.out.print((String) next_token); System.out.println(" not found in layer structure "); @@ -138,59 +108,43 @@ else if (next_token == Keyword.SIGNAL) Collection corner_list = new LinkedList(); // read the width and the corners of the path - for (;;) - { + for (; ; ) { next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } corner_list.add(next_token); } - if (corner_list.size() < 5) - { + if (corner_list.size() < 5) { System.out.println("PolylinePath.read_scope: to few numbers in scope"); return null; } Iterator it = corner_list.iterator(); double width = 0; Object next_object = it.next(); - if (next_object instanceof Double) - { + if (next_object instanceof Double) { width = ((Double) next_object).doubleValue(); - } - else if (next_object instanceof Integer) - { + } else if (next_object instanceof Integer) { width = ((Integer) next_object).intValue(); - } - else - { + } else { System.out.println("PolylinePath.read_scope: number expected"); return null; } double[] corner_arr = new double[corner_list.size() - 1]; - for (int i = 0; i < corner_arr.length; ++i) - { + for (int i = 0; i < corner_arr.length; ++i) { next_object = it.next(); - if (next_object instanceof Double) - { + if (next_object instanceof Double) { corner_arr[i] = ((Double) next_object).doubleValue(); - } - else if (next_object instanceof Integer) - { + } else if (next_object instanceof Integer) { corner_arr[i] = ((Integer) next_object).intValue(); - } - else - { + } else { System.out.println("Shape.read_polygon_path_scope: number expected"); return null; } } return new PolylinePath(layer, width, corner_arr); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("PolylinePath.read_scope: IO error scanning file"); System.out.println(e); return null; @@ -203,97 +157,73 @@ else if (next_object instanceof Integer) * The other shapes in the shape_list are holes (windows). */ public static final ReadAreaScopeResult read_area_scope(Scanner p_scanner, - LayerStructure p_layer_structure, boolean p_skip_window_scopes) - { + LayerStructure p_layer_structure, boolean p_skip_window_scopes) { Collection shape_list = new LinkedList(); String clearance_class_name = null; String area_name = null; boolean result_ok = true; Object next_token = null; - try - { + try { next_token = p_scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Shape.read_area_scope: IO error scanning file"); return null; } - if (next_token instanceof String) - { + if (next_token instanceof String) { String curr_name = (String) next_token; - if (!curr_name.isEmpty()) - { + if (!curr_name.isEmpty()) { area_name = curr_name; } } Shape curr_shape = Shape.read_scope(p_scanner, p_layer_structure); - if (curr_shape == null) - { + if (curr_shape == null) { result_ok = false; } shape_list.add(curr_shape); next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = p_scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Shape.read_area_scope: IO error scanning file"); return null; } - if (next_token == null) - { + if (next_token == null) { System.out.println("Shape.read_area_scope: unexpected end of file"); return null; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - if (prev_token == Keyword.OPEN_BRACKET) - { + if (prev_token == Keyword.OPEN_BRACKET) { // a new scope is expected - if (next_token == Keyword.WINDOW && !p_skip_window_scopes) - { + if (next_token == Keyword.WINDOW && !p_skip_window_scopes) { Shape hole_shape = Shape.read_scope(p_scanner, p_layer_structure); shape_list.add(hole_shape); // overread closing bracket - try - { + try { next_token = p_scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Shape.read_area_scope: IO error scanning file"); return null; } - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Shape.read_area_scope: closed bracket expected"); return null; } - } - else if (next_token == Keyword.CLEARANCE_CLASS) - { + } else if (next_token == Keyword.CLEARANCE_CLASS) { clearance_class_name = DsnFile.read_string_scope(p_scanner); - } - else - { + } else { // skip unknown scope ScopeKeyword.skip_scope(p_scanner); } } } - if (!result_ok) - { + if (!result_ok) { return null; } return new ReadAreaScopeResult(area_name, shape_list, clearance_class_name); @@ -303,59 +233,40 @@ else if (next_token == Keyword.CLEARANCE_CLASS) * Reads a rectangle scope from a Specctra dsn file. * If p_layer_structure == null, only Layer.PCB and Layer.Signal are expected, no induvidual layers. */ - public static Rectangle read_rectangle_scope(Scanner p_scanner, LayerStructure p_layer_structure) - { - try - { + public static Rectangle read_rectangle_scope(Scanner p_scanner, LayerStructure p_layer_structure) { + try { Layer rect_layer = null; double rect_coor[] = new double[4]; Object next_token = p_scanner.next_token(); - if (next_token == Keyword.PCB_SCOPE) - { + if (next_token == Keyword.PCB_SCOPE) { rect_layer = Layer.PCB; - } - else if (next_token == Keyword.SIGNAL) - { + } else if (next_token == Keyword.SIGNAL) { rect_layer = Layer.SIGNAL; - } - else if (p_layer_structure != null) - { - if (!(next_token instanceof String)) - { + } else if (p_layer_structure != null) { + if (!(next_token instanceof String)) { System.out.println("Shape.read_rectangle_scope: layer name string expected"); return null; } String layer_name = (String) next_token; int layer_no = p_layer_structure.get_no(layer_name); - if (layer_no < 0 || layer_no >= p_layer_structure.arr.length) - { + if (layer_no < 0 || layer_no >= p_layer_structure.arr.length) { System.out.println("Shape.read_rectangle_scope: layer name " + layer_name + " not found in layer structure "); - } - else - { + } else { rect_layer = p_layer_structure.arr[layer_no]; } - } - else - { + } else { rect_layer = Layer.SIGNAL; } // fill the the rectangle - for (int i = 0; i < 4; ++i) - { + for (int i = 0; i < 4; ++i) { next_token = p_scanner.next_token(); - if (next_token instanceof Double) - { + if (next_token instanceof Double) { rect_coor[i] = ((Double) next_token).doubleValue(); - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { rect_coor[i] = ((Integer) next_token).intValue(); - } - else - { + } else { System.out.println("Shape.read_rectangle_scope: number expected"); return null; } @@ -363,19 +274,15 @@ else if (next_token instanceof Integer) // overread the closing bracket next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Shape.read_rectangle_scope ) expected"); return null; } - if (rect_layer == null) - { + if (rect_layer == null) { return null; } return new Rectangle(rect_layer, rect_coor); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Shape.read_rectangle_scope: IO error scanning file"); System.out.println(e); return null; @@ -386,43 +293,31 @@ else if (next_token instanceof Integer) * Reads a closed polygon scope from a Specctra dsn file. * If p_layer_structure == null, only Layer.PCB and Layer.Signal are expected, no induvidual layers. */ - public static Polygon read_polygon_scope(Scanner p_scanner, LayerStructure p_layer_structure) - { - try - { + public static Polygon read_polygon_scope(Scanner p_scanner, LayerStructure p_layer_structure) { + try { Layer polygon_layer = null; boolean layer_ok = true; Object next_token = p_scanner.next_token(); - if (next_token == Keyword.PCB_SCOPE) - { + if (next_token == Keyword.PCB_SCOPE) { polygon_layer = Layer.PCB; - } - else if (next_token == Keyword.SIGNAL) - { + } else if (next_token == Keyword.SIGNAL) { polygon_layer = Layer.SIGNAL; - } - else - { - if (p_layer_structure == null) - { + } else { + if (p_layer_structure == null) { System.out.println("Shape.read_polygon_scope: only layer types pcb or signal expected"); return null; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Shape.read_polygon_scope: layer name string expected"); return null; } int layer_no = p_layer_structure.get_no((String) next_token); - if (layer_no < 0 || layer_no >= p_layer_structure.arr.length) - { + if (layer_no < 0 || layer_no >= p_layer_structure.arr.length) { System.out.print("Shape.read_polygon_scope: layer name "); System.out.print((String) next_token); System.out.println(" not found in layer structure "); layer_ok = false; - } - else - { + } else { polygon_layer = p_layer_structure.arr[layer_no]; } } @@ -433,54 +328,41 @@ else if (next_token == Keyword.SIGNAL) Collection coor_list = new LinkedList(); // read the coordinates of the polygon - for (;;) - { + for (; ; ) { next_token = p_scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { System.out.println("Shape.read_polygon_scope: unexpected end of file"); return null; } - if (next_token == Keyword.OPEN_BRACKET) - { + if (next_token == Keyword.OPEN_BRACKET) { // unknown scope ScopeKeyword.skip_scope(p_scanner); next_token = p_scanner.next_token(); } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } coor_list.add(next_token); } - if (!layer_ok) - { + if (!layer_ok) { return null; } double[] coor_arr = new double[coor_list.size()]; Iterator it = coor_list.iterator(); - for (int i = 0; i < coor_arr.length; ++i) - { + for (int i = 0; i < coor_arr.length; ++i) { Object next_object = it.next(); - if (next_object instanceof Double) - { + if (next_object instanceof Double) { coor_arr[i] = ((Double) next_object).doubleValue(); - } - else if (next_object instanceof Integer) - { + } else if (next_object instanceof Integer) { coor_arr[i] = ((Integer) next_object).intValue(); - } - else - { + } else { System.out.println("Shape.read_polygon_scope: number expected"); return null; } } return new Polygon(polygon_layer, coor_arr); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Rectangle.read_scope: IO error scanning file"); System.out.println(e); return null; @@ -490,85 +372,62 @@ else if (next_object instanceof Integer) /** * Reads a circle scope from a Specctra dsn file. */ - public static Circle read_circle_scope(Scanner p_scanner, LayerStructure p_layer_structure) - { - try - { + public static Circle read_circle_scope(Scanner p_scanner, LayerStructure p_layer_structure) { + try { Layer circle_layer = null; boolean layer_ok = true; double circle_coor[] = new double[3]; Object next_token = p_scanner.next_token(); - if (next_token == Keyword.PCB_SCOPE) - { + if (next_token == Keyword.PCB_SCOPE) { circle_layer = Layer.PCB; - } - else if (next_token == Keyword.SIGNAL) - { + } else if (next_token == Keyword.SIGNAL) { circle_layer = Layer.SIGNAL; - } - else - { - if (p_layer_structure == null) - { + } else { + if (p_layer_structure == null) { System.out.println("Shape.read_circle_scope: p_layer_structure != null expected"); return null; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Shape.read_circle_scope: string for layer_name expected"); return null; } int layer_no = p_layer_structure.get_no((String) next_token); - if (layer_no < 0 || layer_no >= p_layer_structure.arr.length) - { + if (layer_no < 0 || layer_no >= p_layer_structure.arr.length) { System.out.print("Shape.read_circle_scope: layer with name "); System.out.print((String) next_token); System.out.println(" not found in layer stracture "); layer_ok = false; - } - else - { + } else { circle_layer = p_layer_structure.arr[layer_no]; } } // fill the the the coordinates int curr_index = 0; - for (;;) - { + for (; ; ) { next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (curr_index > 2) - { + if (curr_index > 2) { System.out.println("Shape.read_circle_scope: closed bracket expected"); return null; } - if (next_token instanceof Double) - { + if (next_token instanceof Double) { circle_coor[curr_index] = ((Double) next_token).doubleValue(); - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { circle_coor[curr_index] = ((Integer) next_token).intValue(); - } - else - { + } else { System.out.println("Shape.read_circle_scope: number expected"); return null; } ++curr_index; } - if (!layer_ok) - { + if (!layer_ok) { return null; } return new Circle(circle_layer, circle_coor); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Shape.read_rectangle_scope: IO error scanning file"); System.out.println(e); return null; @@ -578,112 +437,82 @@ else if (next_token instanceof Integer) /** * Reads an object of type Path from the dsn-file. */ - public static PolygonPath read_polygon_path_scope(Scanner p_scanner, LayerStructure p_layer_structure) - { - try - { + public static PolygonPath read_polygon_path_scope(Scanner p_scanner, LayerStructure p_layer_structure) { + try { Layer layer = null; boolean layer_ok = true; Object next_token = p_scanner.next_token(); - if (next_token == Keyword.PCB_SCOPE) - { + if (next_token == Keyword.PCB_SCOPE) { layer = Layer.PCB; - } - else if (next_token == Keyword.SIGNAL) - { + } else if (next_token == Keyword.SIGNAL) { layer = Layer.SIGNAL; - } - else - { - if (p_layer_structure == null) - { + } else { + if (p_layer_structure == null) { System.out.println("Shape.read_polygon_path_scope: only layer types pcb or signal expected"); return null; } - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Path.read_scope: layer name string expected"); return null; } int layer_no = p_layer_structure.get_no((String) next_token); - if (layer_no < 0 || layer_no >= p_layer_structure.arr.length) - { + if (layer_no < 0 || layer_no >= p_layer_structure.arr.length) { System.out.print("Shape.read_polygon_path_scope: layer with name "); System.out.print((String) next_token); System.out.println(" not found in layer structure "); layer_ok = false; - } - else - { + } else { layer = p_layer_structure.arr[layer_no]; } } Collection corner_list = new LinkedList(); // read the width and the corners of the path - for (;;) - { + for (; ; ) { next_token = p_scanner.next_token(); - if (next_token == Keyword.OPEN_BRACKET) - { + if (next_token == Keyword.OPEN_BRACKET) { // unknown scope ScopeKeyword.skip_scope(p_scanner); next_token = p_scanner.next_token(); } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } corner_list.add(next_token); } - if (corner_list.size() < 5) - { + if (corner_list.size() < 5) { System.out.println("Shape.read_polygon_path_scope: to few numbers in scope"); return null; } - if (!layer_ok) - { + if (!layer_ok) { return null; } Iterator it = corner_list.iterator(); double width = 0; Object next_object = it.next(); - if (next_object instanceof Double) - { + if (next_object instanceof Double) { width = ((Double) next_object).doubleValue(); - } - else if (next_object instanceof Integer) - { + } else if (next_object instanceof Integer) { width = ((Integer) next_object).intValue(); - } - else - { + } else { System.out.println("Shape.read_polygon_path_scope: number expected"); return null; } double[] coordinate_arr = new double[corner_list.size() - 1]; - for (int i = 0; i < coordinate_arr.length; ++i) - { + for (int i = 0; i < coordinate_arr.length; ++i) { next_object = it.next(); - if (next_object instanceof Double) - { + if (next_object instanceof Double) { coordinate_arr[i] = ((Double) next_object).doubleValue(); - } - else if (next_object instanceof Integer) - { + } else if (next_object instanceof Integer) { coordinate_arr[i] = ((Integer) next_object).intValue(); - } - else - { + } else { System.out.println("Shape.read_polygon_path_scope: number expected"); return null; } } return new PolygonPath(layer, width, coordinate_arr); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Shape.read_polygon_path_scope: IO error scanning file"); System.out.println(e); return null; @@ -695,11 +524,9 @@ else if (next_object instanceof Integer) * The first shape in the Collection p_area is the border, * the other shapes are holes of the area. */ - public static net.freerouting.geometry.planar.Area transform_area_to_board(Collection p_area, CoordinateTransform p_coordinate_transform) - { + public static net.freerouting.geometry.planar.Area transform_area_to_board(Collection p_area, CoordinateTransform p_coordinate_transform) { int hole_count = p_area.size() - 1; - if (hole_count <= -1) - { + if (hole_count <= -1) { System.out.println("Shape.transform_area_to_board: p_area.size() > 0 expected"); return null; } @@ -707,25 +534,19 @@ public static net.freerouting.geometry.planar.Area transform_area_to_board(Colle Shape boundary = it.next(); net.freerouting.geometry.planar.Shape boundary_shape = boundary.transform_to_board(p_coordinate_transform); net.freerouting.geometry.planar.Area result; - if (hole_count == 0) - { + if (hole_count == 0) { result = boundary_shape; - } - else - { + } else { // Area with holes - if (!(boundary_shape instanceof net.freerouting.geometry.planar.PolylineShape)) - { + if (!(boundary_shape instanceof net.freerouting.geometry.planar.PolylineShape)) { System.out.println("Shape.transform_area_to_board: PolylineShape expected"); return null; } PolylineShape border = (PolylineShape) boundary_shape; PolylineShape[] holes = new PolylineShape[hole_count]; - for (int i = 0; i < holes.length; ++i) - { + for (int i = 0; i < holes.length; ++i) { net.freerouting.geometry.planar.Shape hole_shape = it.next().transform_to_board(p_coordinate_transform); - if (!(hole_shape instanceof PolylineShape)) - { + if (!(hole_shape instanceof PolylineShape)) { System.out.println("Shape.transform_area_to_board: PolylineShape expected"); return null; } @@ -741,11 +562,9 @@ public static net.freerouting.geometry.planar.Area transform_area_to_board(Colle * The first shape in the Collection p_area is the border, * the other shapes are holes of the area. */ - public static net.freerouting.geometry.planar.Area transform_area_to_board_rel(Collection p_area, CoordinateTransform p_coordinate_transform) - { + public static net.freerouting.geometry.planar.Area transform_area_to_board_rel(Collection p_area, CoordinateTransform p_coordinate_transform) { int hole_count = p_area.size() - 1; - if (hole_count <= -1) - { + if (hole_count <= -1) { System.out.println("Shape.transform_area_to_board_rel: p_area.size() > 0 expected"); return null; } @@ -753,25 +572,19 @@ public static net.freerouting.geometry.planar.Area transform_area_to_board_rel(C Shape boundary = it.next(); net.freerouting.geometry.planar.Shape boundary_shape = boundary.transform_to_board_rel(p_coordinate_transform); net.freerouting.geometry.planar.Area result; - if (hole_count == 0) - { + if (hole_count == 0) { result = boundary_shape; - } - else - { + } else { // Area with holes - if (!(boundary_shape instanceof net.freerouting.geometry.planar.PolylineShape)) - { + if (!(boundary_shape instanceof net.freerouting.geometry.planar.PolylineShape)) { System.out.println("Shape.transform_area_to_board_rel: PolylineShape expected"); return null; } PolylineShape border = (PolylineShape) boundary_shape; PolylineShape[] holes = new PolylineShape[hole_count]; - for (int i = 0; i < holes.length; ++i) - { + for (int i = 0; i < holes.length; ++i) { net.freerouting.geometry.planar.Shape hole_shape = it.next().transform_to_board_rel(p_coordinate_transform); - if (!(hole_shape instanceof PolylineShape)) - { + if (!(hole_shape instanceof PolylineShape)) { System.out.println("Shape.transform_area_to_board: PolylineShape expected"); return null; } @@ -782,8 +595,18 @@ public static net.freerouting.geometry.planar.Area transform_area_to_board_rel(C return result; } - public void write_hole_scope(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException - { + /** + * Writes a shape scope to a Specctra dsn file. + */ + public abstract void write_scope(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException; + + /** + * Writes a shape scope to a Specctra session file. + * In a session file all coordinates must be integer. + */ + public abstract void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException; + + public void write_hole_scope(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.start_scope(); p_file.write("window"); this.write_scope(p_file, p_identifier_type); @@ -805,27 +628,19 @@ public void write_hole_scope(IndentFileWriter p_file, IdentifierType p_identifie */ public abstract net.freerouting.geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform); - protected Shape(Layer p_layer) - { - layer = p_layer; - } - public final Layer layer; - /** * Contains the result of the function read_area_scope. * area_name or clearance_class_name may be null, which means they are not provided. */ - static class ReadAreaScopeResult - { + static class ReadAreaScopeResult { - private ReadAreaScopeResult(String p_area_name, Collection p_shape_list, String p_clearance_class_name) - { + final Collection shape_list; + final String clearance_class_name; + String area_name; // may be generated later on, if area_name is null. + private ReadAreaScopeResult(String p_area_name, Collection p_shape_list, String p_clearance_class_name) { area_name = p_area_name; shape_list = p_shape_list; clearance_class_name = p_clearance_class_name; } - String area_name; // may be generated later on, if area_name is null. - final Collection shape_list; - final String clearance_class_name; } } diff --git a/src/main/java/net/freerouting/designformats/specctra/SpecctraFileScanner.java b/src/main/java/net/freerouting/designformats/specctra/SpecctraFileScanner.java index 455b5c00..800d80a0 100644 --- a/src/main/java/net/freerouting/designformats/specctra/SpecctraFileScanner.java +++ b/src/main/java/net/freerouting/designformats/specctra/SpecctraFileScanner.java @@ -1,6 +1,7 @@ /* The following code was generated by JFlex 1.4.1 on 16.10.08 09:27 */ package net.freerouting.designformats.specctra; + @SuppressWarnings("all") /** @@ -11,1449 +12,1597 @@ */ class SpecctraFileScanner implements Scanner { - /** This character denotes the end of file */ - public static final int YYEOF = -1; - - /** initial size of the lookahead buffer */ - private static final int ZZ_BUFFERSIZE = 16384; - - /** lexical states */ - public static final int COMPONENT_NAME = 5; - public static final int IGNORE_QUOTE = 7; - public static final int YYINITIAL = 0; - public static final int SPEC_CHAR = 6; - public static final int LAYER_NAME = 4; - public static final int STRING2 = 2; - public static final int STRING1 = 1; - public static final int NAME = 3; - - /** - * Translates characters to character classes - */ - private static final String ZZ_CMAP_PACKED = - "\11\0\1\3\1\2\1\0\1\3\1\1\21\0\1\16\1\3\1\16"+ - "\1\11\1\6\1\16\1\16\1\16\1\12\1\53\1\54\1\5\1\20"+ - "\1\16\1\17\1\14\1\4\1\21\11\10\1\16\1\16\1\16\1\16"+ - "\1\16\1\16\1\16\1\23\1\24\1\32\1\42\1\22\1\41\1\35"+ - "\1\43\1\33\1\7\1\44\1\27\1\46\1\36\1\26\1\37\1\52"+ - "\1\40\1\25\1\31\1\30\1\34\1\51\1\47\1\45\1\50\1\16"+ - "\1\15\1\16\1\16\1\13\1\0\1\23\1\24\1\32\1\42\1\22"+ - "\1\41\1\35\1\43\1\33\1\7\1\44\1\27\1\46\1\36\1\26"+ - "\1\37\1\52\1\40\1\25\1\31\1\30\1\34\1\51\1\47\1\45"+ - "\1\50\3\0\1\16\42\0\136\16\1\16\122\0\2\16\14\0\2\16"+ - "\26\0\1\16\4\0\2\16\22\0\2\16\u0133\0\1\16\25\0\1\16"+ - "\u1d36\0\1\16\1\16\3\0\1\16\1\16\1\16\1\0\1\16\1\16"+ - "\1\16\1\0\1\16\1\16\1\16\3\0\1\16\11\0\1\16\10\0"+ - "\1\16\1\16\161\0\1\16\165\0\1\16\udedd\0"; - - /** - * Translates characters to character classes - */ - private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); - - /** - * Translates DFA states to action switch labels. - */ - private static final int [] ZZ_ACTION = zzUnpackAction(); - - private static final String ZZ_ACTION_PACKED_0 = - "\7\0\1\1\1\2\2\3\3\4\1\5\1\6\1\7"+ - "\1\2\1\5\22\4\1\10\1\11\1\12\1\13\1\14"+ - "\1\12\1\1\1\15\1\16\3\1\2\4\3\0\1\17"+ - "\16\4\1\20\45\4\2\1\1\0\1\4\2\17\1\0"+ - "\1\17\22\4\1\21\16\4\1\22\1\4\1\23\13\4"+ - "\1\24\1\25\11\4\1\26\10\4\1\1\1\27\1\0"+ - "\6\4\1\30\6\4\1\31\14\4\1\32\2\4\1\33"+ - "\2\4\1\34\3\4\1\35\2\4\1\36\2\4\1\37"+ - "\5\4\1\40\4\4\1\41\2\4\1\42\2\4\1\43"+ - "\11\4\1\44\3\4\1\1\14\4\1\45\1\46\2\4"+ - "\1\47\1\4\1\50\11\4\1\51\1\52\2\4\1\53"+ - "\20\4\1\54\1\55\1\56\6\4\1\57\3\4\1\60"+ - "\7\4\1\61\1\4\1\1\2\4\1\62\1\63\6\4"+ - "\1\64\3\4\1\65\15\4\1\34\10\4\1\66\1\4"+ - "\1\67\15\4\1\70\1\71\1\72\2\4\1\73\4\4"+ - "\1\74\1\4\1\75\1\4\1\76\4\4\1\77\6\4"+ - "\1\100\3\4\1\101\1\4\1\102\1\103\1\4\1\104"+ - "\3\4\1\105\1\106\6\4\1\107\6\4\1\40\17\4"+ - "\1\110\2\4\1\111\2\4\1\112\12\4\1\113\3\4"+ - "\1\114\2\4\1\115\5\4\1\116\1\4\1\117\14\4"+ - "\1\120\4\4\1\121\3\4\1\122\4\4\1\123\1\4"+ - "\1\124\1\33\1\51\2\4\1\125\5\4\1\126\3\4"+ - "\1\127\4\4\1\42\14\4\1\130\1\4\1\131\3\4"+ - "\1\132\11\4\1\133\1\4\1\134\2\4\1\135\1\4"+ - "\1\136\7\4\1\137\2\4\1\140\1\141\1\4\1\142"+ - "\20\4\1\143\1\144\3\4\1\145\5\4\1\146\1\4"+ - "\1\147\1\150\3\4\1\151\4\4\1\152\1\153\1\154"+ - "\1\155\23\4\1\156\1\4\1\157\11\4\1\160\1\161"+ - "\2\4\1\162\3\4\1\163\3\4\1\164\5\4\1\165"+ - "\6\4\1\166\20\4\1\167\7\4\1\170"; - - private static int [] zzUnpackAction() { - int [] result = new int[712]; - int offset = 0; - offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAction(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); + /** + * This character denotes the end of file + */ + public static final int YYEOF = -1; + /** + * lexical states + */ + public static final int COMPONENT_NAME = 5; + public static final int IGNORE_QUOTE = 7; + public static final int YYINITIAL = 0; + public static final int SPEC_CHAR = 6; + public static final int LAYER_NAME = 4; + public static final int STRING2 = 2; + public static final int STRING1 = 1; + public static final int NAME = 3; + /** + * initial size of the lookahead buffer + */ + private static final int ZZ_BUFFERSIZE = 16384; + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\0\1\3\1\2\1\0\1\3\1\1\21\0\1\16\1\3\1\16" + + "\1\11\1\6\1\16\1\16\1\16\1\12\1\53\1\54\1\5\1\20" + + "\1\16\1\17\1\14\1\4\1\21\11\10\1\16\1\16\1\16\1\16" + + "\1\16\1\16\1\16\1\23\1\24\1\32\1\42\1\22\1\41\1\35" + + "\1\43\1\33\1\7\1\44\1\27\1\46\1\36\1\26\1\37\1\52" + + "\1\40\1\25\1\31\1\30\1\34\1\51\1\47\1\45\1\50\1\16" + + "\1\15\1\16\1\16\1\13\1\0\1\23\1\24\1\32\1\42\1\22" + + "\1\41\1\35\1\43\1\33\1\7\1\44\1\27\1\46\1\36\1\26" + + "\1\37\1\52\1\40\1\25\1\31\1\30\1\34\1\51\1\47\1\45" + + "\1\50\3\0\1\16\42\0\136\16\1\16\122\0\2\16\14\0\2\16" + + "\26\0\1\16\4\0\2\16\22\0\2\16\u0133\0\1\16\25\0\1\16" + + "\u1d36\0\1\16\1\16\3\0\1\16\1\16\1\16\1\0\1\16\1\16" + + "\1\16\1\0\1\16\1\16\1\16\3\0\1\16\11\0\1\16\10\0" + + "\1\16\1\16\161\0\1\16\165\0\1\16\udedd\0"; + + /** + * Translates characters to character classes + */ + private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + private static final String ZZ_ACTION_PACKED_0 = + "\7\0\1\1\1\2\2\3\3\4\1\5\1\6\1\7" + + "\1\2\1\5\22\4\1\10\1\11\1\12\1\13\1\14" + + "\1\12\1\1\1\15\1\16\3\1\2\4\3\0\1\17" + + "\16\4\1\20\45\4\2\1\1\0\1\4\2\17\1\0" + + "\1\17\22\4\1\21\16\4\1\22\1\4\1\23\13\4" + + "\1\24\1\25\11\4\1\26\10\4\1\1\1\27\1\0" + + "\6\4\1\30\6\4\1\31\14\4\1\32\2\4\1\33" + + "\2\4\1\34\3\4\1\35\2\4\1\36\2\4\1\37" + + "\5\4\1\40\4\4\1\41\2\4\1\42\2\4\1\43" + + "\11\4\1\44\3\4\1\1\14\4\1\45\1\46\2\4" + + "\1\47\1\4\1\50\11\4\1\51\1\52\2\4\1\53" + + "\20\4\1\54\1\55\1\56\6\4\1\57\3\4\1\60" + + "\7\4\1\61\1\4\1\1\2\4\1\62\1\63\6\4" + + "\1\64\3\4\1\65\15\4\1\34\10\4\1\66\1\4" + + "\1\67\15\4\1\70\1\71\1\72\2\4\1\73\4\4" + + "\1\74\1\4\1\75\1\4\1\76\4\4\1\77\6\4" + + "\1\100\3\4\1\101\1\4\1\102\1\103\1\4\1\104" + + "\3\4\1\105\1\106\6\4\1\107\6\4\1\40\17\4" + + "\1\110\2\4\1\111\2\4\1\112\12\4\1\113\3\4" + + "\1\114\2\4\1\115\5\4\1\116\1\4\1\117\14\4" + + "\1\120\4\4\1\121\3\4\1\122\4\4\1\123\1\4" + + "\1\124\1\33\1\51\2\4\1\125\5\4\1\126\3\4" + + "\1\127\4\4\1\42\14\4\1\130\1\4\1\131\3\4" + + "\1\132\11\4\1\133\1\4\1\134\2\4\1\135\1\4" + + "\1\136\7\4\1\137\2\4\1\140\1\141\1\4\1\142" + + "\20\4\1\143\1\144\3\4\1\145\5\4\1\146\1\4" + + "\1\147\1\150\3\4\1\151\4\4\1\152\1\153\1\154" + + "\1\155\23\4\1\156\1\4\1\157\11\4\1\160\1\161" + + "\2\4\1\162\3\4\1\163\3\4\1\164\5\4\1\165" + + "\6\4\1\166\20\4\1\167\7\4\1\170"; + /** + * Translates DFA states to action switch labels. + */ + private static final int[] ZZ_ACTION = zzUnpackAction(); + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\55\0\132\0\207\0\264\0\341\0\u010e\0\u013b" + + "\0\u0168\0\u0195\0\u0168\0\u01c2\0\u01ef\0\u021c\0\u0249\0\u0168" + + "\0\u0168\0\u0276\0\u02a3\0\u02d0\0\u02fd\0\u032a\0\u0357\0\u0384" + + "\0\u03b1\0\u03de\0\u040b\0\u0438\0\u0465\0\u0492\0\u04bf\0\u04ec" + + "\0\u0519\0\u0546\0\u0573\0\u05a0\0\u05cd\0\u0168\0\u0168\0\u05fa" + + "\0\u0168\0\u0168\0\u0627\0\u0654\0\u0168\0\u0168\0\u0681\0\u06ae" + + "\0\u06db\0\u0168\0\u0708\0\u0735\0\u0762\0\u078f\0\u02a3\0\u07bc" + + "\0\u07e9\0\u0816\0\u0843\0\u0870\0\u089d\0\u08ca\0\u08f7\0\u0924" + + "\0\u0951\0\u097e\0\u09ab\0\u09d8\0\u0a05\0\u01ef\0\u0a32\0\u0a5f" + + "\0\u0a8c\0\u0ab9\0\u0ae6\0\u0b13\0\u0b40\0\u0b6d\0\u0b9a\0\u0bc7" + + "\0\u0bf4\0\u0c21\0\u0c4e\0\u0c7b\0\u0ca8\0\u0cd5\0\u0d02\0\u0d2f" + + "\0\u0d5c\0\u0d89\0\u0db6\0\u0de3\0\u0e10\0\u0e3d\0\u0e6a\0\u0e97" + + "\0\u0ec4\0\u0ef1\0\u0f1e\0\u0f4b\0\u0f78\0\u0fa5\0\u0fd2\0\u0fff" + + "\0\u102c\0\u1059\0\u1086\0\u10b3\0\u10e0\0\u110d\0\u113a\0\u1167" + + "\0\u1194\0\u11c1\0\u0168\0\u11ee\0\u121b\0\u1248\0\u1275\0\u12a2" + + "\0\u12cf\0\u12fc\0\u1329\0\u1356\0\u1383\0\u13b0\0\u13dd\0\u140a" + + "\0\u1437\0\u1464\0\u1491\0\u14be\0\u14eb\0\u01ef\0\u1518\0\u1545" + + "\0\u1572\0\u159f\0\u15cc\0\u15f9\0\u1626\0\u1653\0\u1680\0\u16ad" + + "\0\u16da\0\u1707\0\u1734\0\u1761\0\u178e\0\u17bb\0\u17e8\0\u1815" + + "\0\u1842\0\u186f\0\u189c\0\u18c9\0\u18f6\0\u1923\0\u1950\0\u197d" + + "\0\u19aa\0\u19d7\0\u01ef\0\u1a04\0\u1a31\0\u1a5e\0\u1a8b\0\u1ab8" + + "\0\u1ae5\0\u1b12\0\u1b3f\0\u1b6c\0\u1b99\0\u01ef\0\u1bc6\0\u1bf3" + + "\0\u1c20\0\u1c4d\0\u1c7a\0\u1ca7\0\u1cd4\0\u1d01\0\u1d2e\0\u0654" + + "\0\u1d5b\0\u1d88\0\u1db5\0\u1de2\0\u1e0f\0\u1e3c\0\u1e69\0\u01ef" + + "\0\u1e96\0\u1ec3\0\u1ef0\0\u1f1d\0\u1f4a\0\u1f77\0\u01ef\0\u1fa4" + + "\0\u1fd1\0\u1ffe\0\u202b\0\u2058\0\u2085\0\u20b2\0\u20df\0\u210c" + + "\0\u2139\0\u2166\0\u2193\0\u01ef\0\u21c0\0\u21ed\0\u221a\0\u2247" + + "\0\u2274\0\u22a1\0\u22ce\0\u22fb\0\u2328\0\u01ef\0\u2355\0\u2382" + + "\0\u01ef\0\u23af\0\u23dc\0\u01ef\0\u2409\0\u2436\0\u2463\0\u2490" + + "\0\u24bd\0\u24ea\0\u2517\0\u2544\0\u2571\0\u259e\0\u01ef\0\u25cb" + + "\0\u25f8\0\u2625\0\u2652\0\u267f\0\u26ac\0\u26d9\0\u2706\0\u2733" + + "\0\u2760\0\u278d\0\u27ba\0\u27e7\0\u2814\0\u2841\0\u286e\0\u289b" + + "\0\u28c8\0\u28f5\0\u2922\0\u294f\0\u297c\0\u29a9\0\u29d6\0\u2a03" + + "\0\u2a30\0\u2a5d\0\u2a8a\0\u2ab7\0\u2ae4\0\u2b11\0\u2b3e\0\u01ef" + + "\0\u01ef\0\u2b6b\0\u2b98\0\u01ef\0\u2bc5\0\u2bf2\0\u2c1f\0\u2c4c" + + "\0\u2c79\0\u2ca6\0\u2cd3\0\u2d00\0\u2d2d\0\u2d5a\0\u2d87\0\u2db4" + + "\0\u2de1\0\u2e0e\0\u2e3b\0\u01ef\0\u2e68\0\u2e95\0\u2ec2\0\u2eef" + + "\0\u2f1c\0\u2f49\0\u2f76\0\u2fa3\0\u2fd0\0\u2ffd\0\u302a\0\u3057" + + "\0\u3084\0\u30b1\0\u30de\0\u310b\0\u01ef\0\u3138\0\u3165\0\u3192" + + "\0\u31bf\0\u31ec\0\u3219\0\u3246\0\u3273\0\u01ef\0\u32a0\0\u32cd" + + "\0\u32fa\0\u01ef\0\u3327\0\u3354\0\u3381\0\u33ae\0\u33db\0\u3408" + + "\0\u3435\0\u01ef\0\u3462\0\u348f\0\u34bc\0\u34e9\0\u01ef\0\u01ef" + + "\0\u3516\0\u3543\0\u3570\0\u359d\0\u35ca\0\u35f7\0\u01ef\0\u3624" + + "\0\u3651\0\u367e\0\u01ef\0\u36ab\0\u36d8\0\u3705\0\u3732\0\u375f" + + "\0\u378c\0\u37b9\0\u37e6\0\u3813\0\u3840\0\u386d\0\u389a\0\u38c7" + + "\0\u01ef\0\u38f4\0\u3921\0\u394e\0\u397b\0\u39a8\0\u39d5\0\u3a02" + + "\0\u3a2f\0\u01ef\0\u3a5c\0\u01ef\0\u3a89\0\u3ab6\0\u3ae3\0\u3b10" + + "\0\u3b3d\0\u3b6a\0\u3b97\0\u3bc4\0\u3bf1\0\u3c1e\0\u3c4b\0\u3c78" + + "\0\u3ca5\0\u01ef\0\u3cd2\0\u01ef\0\u3cff\0\u3d2c\0\u01ef\0\u3d59" + + "\0\u3d86\0\u3db3\0\u3de0\0\u01ef\0\u3e0d\0\u01ef\0\u3e3a\0\u0654" + + "\0\u3e67\0\u3e94\0\u3ec1\0\u3eee\0\u01ef\0\u3f1b\0\u3f48\0\u3f75" + + "\0\u3fa2\0\u3fcf\0\u3ffc\0\u01ef\0\u4029\0\u4056\0\u4083\0\u01ef" + + "\0\u40b0\0\u01ef\0\u01ef\0\u40dd\0\u01ef\0\u410a\0\u4137\0\u4164" + + "\0\u01ef\0\u01ef\0\u4191\0\u41be\0\u41eb\0\u4218\0\u4245\0\u4272" + + "\0\u429f\0\u42cc\0\u42f9\0\u4326\0\u4353\0\u4380\0\u43ad\0\u01ef" + + "\0\u43da\0\u4407\0\u4434\0\u4461\0\u448e\0\u44bb\0\u44e8\0\u4515" + + "\0\u4542\0\u456f\0\u459c\0\u45c9\0\u45f6\0\u4623\0\u4650\0\u01ef" + + "\0\u467d\0\u46aa\0\u01ef\0\u46d7\0\u4704\0\u01ef\0\u4731\0\u475e" + + "\0\u478b\0\u47b8\0\u47e5\0\u4812\0\u483f\0\u486c\0\u4899\0\u48c6" + + "\0\u01ef\0\u48f3\0\u4920\0\u494d\0\u01ef\0\u497a\0\u49a7\0\u01ef" + + "\0\u49d4\0\u4a01\0\u4a2e\0\u4a5b\0\u4a88\0\u01ef\0\u4ab5\0\u01ef" + + "\0\u4ae2\0\u4b0f\0\u4b3c\0\u4b69\0\u4b96\0\u4bc3\0\u4bf0\0\u4c1d" + + "\0\u4c4a\0\u4c77\0\u4ca4\0\u4cd1\0\u01ef\0\u4cfe\0\u4d2b\0\u4d58" + + "\0\u4d85\0\u4db2\0\u4ddf\0\u4e0c\0\u4e39\0\u01ef\0\u4e66\0\u4e93" + + "\0\u4ec0\0\u4eed\0\u01ef\0\u4f1a\0\u01ef\0\u01ef\0\u4f47\0\u4f74" + + "\0\u4fa1\0\u01ef\0\u4fce\0\u4ffb\0\u5028\0\u5055\0\u5082\0\u01ef" + + "\0\u50af\0\u50dc\0\u5109\0\u01ef\0\u5136\0\u5163\0\u5190\0\u51bd" + + "\0\u01ef\0\u51ea\0\u5217\0\u5244\0\u5271\0\u529e\0\u52cb\0\u52f8" + + "\0\u5325\0\u5352\0\u537f\0\u53ac\0\u53d9\0\u01ef\0\u5406\0\u01ef" + + "\0\u5433\0\u5460\0\u548d\0\u01ef\0\u54ba\0\u54e7\0\u5514\0\u5541" + + "\0\u556e\0\u559b\0\u55c8\0\u55f5\0\u5622\0\u01ef\0\u564f\0\u01ef" + + "\0\u567c\0\u56a9\0\u01ef\0\u56d6\0\u01ef\0\u5703\0\u5730\0\u575d" + + "\0\u578a\0\u57b7\0\u57e4\0\u5811\0\u01ef\0\u583e\0\u586b\0\u01ef" + + "\0\u01ef\0\u5898\0\u01ef\0\u58c5\0\u58f2\0\u591f\0\u594c\0\u5979" + + "\0\u59a6\0\u59d3\0\u5a00\0\u5a2d\0\u5a5a\0\u5a87\0\u5ab4\0\u5ae1" + + "\0\u5b0e\0\u5b3b\0\u5b68\0\u01ef\0\u5b95\0\u5bc2\0\u5bef\0\u5c1c" + + "\0\u01ef\0\u5c49\0\u5c76\0\u5ca3\0\u5cd0\0\u5cfd\0\u01ef\0\u5d2a" + + "\0\u01ef\0\u01ef\0\u5d57\0\u5d84\0\u5db1\0\u01ef\0\u5dde\0\u5e0b" + + "\0\u5e38\0\u5e65\0\u01ef\0\u01ef\0\u01ef\0\u01ef\0\u5e92\0\u5ebf" + + "\0\u5eec\0\u5f19\0\u5f46\0\u5f73\0\u5fa0\0\u5fcd\0\u5ffa\0\u6027" + + "\0\u6054\0\u6081\0\u60ae\0\u60db\0\u6108\0\u6135\0\u6162\0\u618f" + + "\0\u61bc\0\u01ef\0\u61e9\0\u01ef\0\u6216\0\u6243\0\u6270\0\u629d" + + "\0\u62ca\0\u62f7\0\u6324\0\u6351\0\u637e\0\u01ef\0\u01ef\0\u63ab" + + "\0\u63d8\0\u01ef\0\u6405\0\u6432\0\u645f\0\u01ef\0\u648c\0\u64b9" + + "\0\u64e6\0\u6513\0\u6540\0\u656d\0\u659a\0\u65c7\0\u65f4\0\u01ef" + + "\0\u6621\0\u664e\0\u667b\0\u66a8\0\u66d5\0\u6702\0\u01ef\0\u672f" + + "\0\u675c\0\u6789\0\u67b6\0\u67e3\0\u6810\0\u683d\0\u686a\0\u6897" + + "\0\u68c4\0\u68f1\0\u691e\0\u694b\0\u6978\0\u69a5\0\u69d2\0\u01ef" + + "\0\u69ff\0\u6a2c\0\u6a59\0\u6a86\0\u6ab3\0\u6ae0\0\u6b0d\0\u01ef"; + /** + * Translates a state to a row index in the transition table + */ + private static final int[] ZZ_ROWMAP = zzUnpackRowMap(); + private static final String ZZ_TRANS_PACKED_0 = + "\1\11\1\12\2\13\1\14\1\15\1\16\1\15\1\17" + + "\1\20\1\21\4\15\2\22\1\23\1\15\1\24\1\25" + + "\1\26\1\27\1\30\1\31\1\32\1\33\1\34\1\35" + + "\1\36\1\37\1\40\1\41\1\42\1\15\1\43\1\44" + + "\4\15\1\45\1\15\1\46\1\47\11\50\1\51\3\50" + + "\1\52\37\50\12\53\1\51\2\53\1\52\37\53\1\11" + + "\1\12\2\13\5\54\1\20\1\21\40\54\1\55\1\56" + + "\1\11\1\12\2\13\5\54\1\20\1\21\12\54\1\57" + + "\11\54\1\60\13\54\1\55\1\56\1\11\1\12\2\13" + + "\5\61\1\20\1\21\4\61\1\11\33\61\1\55\1\56" + + "\4\11\3\62\4\11\6\62\35\11\1\12\2\13\47\54" + + "\1\55\1\56\57\0\1\13\56\0\1\15\1\63\45\15" + + "\6\0\47\15\2\0\1\64\1\12\1\13\1\64\47\16" + + "\2\64\10\0\1\17\3\0\1\65\4\0\1\17\1\66" + + "\42\0\1\17\10\0\1\23\43\0\1\67\3\0\1\65" + + "\4\0\1\67\1\66\36\0\20\15\1\70\3\15\1\71" + + "\1\72\1\73\2\15\1\74\15\15\6\0\17\15\1\75" + + "\2\15\1\76\24\15\6\0\16\15\1\77\6\15\1\100" + + "\1\15\1\101\2\15\1\102\1\103\3\15\1\104\7\15" + + "\6\0\24\15\1\105\5\15\1\106\1\15\1\107\1\110" + + "\11\15\6\0\16\15\1\111\1\112\2\15\1\113\4\15" + + "\1\114\17\15\6\0\21\15\1\115\25\15\6\0\41\15" + + "\1\116\5\15\6\0\22\15\1\117\1\120\3\15\1\121" + + "\17\15\6\0\42\15\1\122\4\15\6\0\16\15\1\123" + + "\10\15\1\124\17\15\6\0\16\15\1\125\30\15\6\0" + + "\16\15\1\126\3\15\1\127\4\15\1\130\17\15\6\0" + + "\17\15\1\131\2\15\1\132\1\133\1\134\1\15\1\135" + + "\1\136\4\15\1\137\12\15\6\0\16\15\1\140\3\15" + + "\1\141\1\15\1\142\22\15\6\0\17\15\1\143\2\15" + + "\1\144\1\145\3\15\1\146\4\15\1\147\12\15\6\0" + + "\22\15\1\150\24\15\6\0\16\15\1\151\30\15\6\0" + + "\27\15\1\152\4\15\1\153\12\15\2\0\11\50\1\0" + + "\3\50\1\0\37\50\12\53\1\0\2\53\1\0\37\53" + + "\4\0\47\54\6\0\27\54\1\154\17\54\6\0\26\54" + + "\1\155\20\54\6\0\13\61\1\0\33\61\2\0\4\156" + + "\1\157\1\15\45\157\2\156\1\64\1\12\1\13\52\64" + + "\10\0\1\160\10\0\1\160\43\0\1\161\6\0\2\162" + + "\1\163\37\0\21\15\1\164\25\15\6\0\25\15\1\165" + + "\21\15\6\0\25\15\1\166\21\15\6\0\25\15\1\167" + + "\21\15\6\0\17\15\1\170\27\15\6\0\26\15\1\171" + + "\20\15\6\0\24\15\1\172\22\15\6\0\21\15\1\173" + + "\25\15\6\0\17\15\1\174\14\15\1\175\12\15\6\0" + + "\31\15\1\176\4\15\1\177\10\15\6\0\17\15\1\200" + + "\27\15\6\0\17\15\1\201\27\15\6\0\17\15\1\202" + + "\2\15\1\203\24\15\6\0\25\15\1\204\21\15\6\0" + + "\36\15\1\205\10\15\6\0\35\15\1\206\11\15\6\0" + + "\32\15\1\207\14\15\6\0\41\15\1\210\5\15\6\0" + + "\26\15\1\211\2\15\1\212\15\15\6\0\20\15\1\213" + + "\26\15\6\0\16\15\1\214\30\15\6\0\33\15\1\215" + + "\13\15\6\0\32\15\1\216\7\15\1\217\4\15\6\0" + + "\16\15\1\220\1\221\27\15\6\0\34\15\1\222\12\15" + + "\6\0\17\15\1\223\27\15\6\0\34\15\1\224\12\15" + + "\6\0\17\15\1\225\27\15\6\0\32\15\1\226\14\15" + + "\6\0\25\15\1\227\21\15\6\0\32\15\1\230\1\15" + + "\1\231\12\15\6\0\32\15\1\232\14\15\6\0\25\15" + + "\1\233\6\15\1\234\1\15\1\235\10\15\6\0\21\15" + + "\1\236\1\15\1\237\21\15\1\240\1\15\6\0\17\15" + + "\1\241\27\15\6\0\23\15\1\242\23\15\6\0\20\15" + + "\1\243\26\15\6\0\32\15\1\244\14\15\6\0\16\15" + + "\1\245\30\15\6\0\21\15\1\246\4\15\1\247\20\15" + + "\6\0\24\15\1\250\1\251\21\15\6\0\23\15\1\252" + + "\23\15\6\0\32\15\1\253\14\15\6\0\34\15\1\254" + + "\12\15\6\0\27\15\1\255\17\15\6\0\43\15\1\256" + + "\3\15\6\0\22\15\1\257\24\15\6\0\21\15\1\260" + + "\12\15\1\261\12\15\6\0\16\15\1\262\30\15\6\0" + + "\32\15\1\263\1\15\1\264\1\15\1\265\10\15\6\0" + + "\27\15\1\266\17\15\6\0\31\54\1\267\15\54\6\0" + + "\20\54\1\270\26\54\2\0\5\156\1\271\53\156\1\157" + + "\1\272\45\157\2\156\10\0\1\160\10\0\1\160\1\66" + + "\42\0\1\161\10\0\1\161\43\0\1\161\10\0\1\163" + + "\37\0\22\15\1\273\24\15\6\0\22\15\1\274\24\15" + + "\6\0\17\15\1\275\27\15\6\0\27\15\1\276\17\15" + + "\6\0\27\15\1\277\17\15\6\0\40\15\1\300\6\15" + + "\6\0\32\15\1\301\14\15\6\0\21\15\1\302\25\15" + + "\6\0\34\15\1\303\12\15\6\0\24\15\1\304\2\15" + + "\1\305\17\15\6\0\32\15\1\306\14\15\6\0\16\15" + + "\1\307\30\15\6\0\33\15\1\310\13\15\6\0\34\15" + + "\1\311\12\15\6\0\33\15\1\312\13\15\6\0\30\15" + + "\1\313\16\15\6\0\23\15\1\314\23\15\6\0\16\15" + + "\1\315\30\15\6\0\31\15\1\316\15\15\6\0\16\15" + + "\1\317\30\15\6\0\40\15\1\320\6\15\6\0\27\15" + + "\1\321\17\15\6\0\34\15\1\322\12\15\6\0\7\15" + + "\1\323\37\15\6\0\16\15\1\324\30\15\6\0\21\15" + + "\1\325\3\15\1\326\21\15\6\0\33\15\1\327\13\15" + + "\6\0\17\15\1\330\27\15\6\0\21\15\1\331\25\15" + + "\6\0\26\15\1\332\20\15\6\0\31\15\1\333\15\15" + + "\6\0\25\15\1\334\21\15\6\0\7\15\1\335\11\15" + + "\1\336\25\15\6\0\16\15\1\337\30\15\6\0\45\15" + + "\1\340\1\15\6\0\16\15\1\341\30\15\6\0\42\15" + + "\1\342\4\15\6\0\16\15\1\343\30\15\6\0\37\15" + + "\1\344\7\15\6\0\21\15\1\345\3\15\1\346\21\15" + + "\6\0\21\15\1\347\25\15\6\0\25\15\1\350\1\15" + + "\1\351\17\15\6\0\41\15\1\352\5\15\6\0\16\15" + + "\1\353\30\15\6\0\26\15\1\354\3\15\1\355\14\15" + + "\6\0\23\15\1\356\23\15\6\0\21\15\1\357\25\15" + + "\6\0\35\15\1\360\11\15\6\0\22\15\1\361\24\15" + + "\6\0\25\15\1\362\21\15\6\0\25\15\1\363\21\15" + + "\6\0\17\15\1\364\27\15\6\0\16\15\1\365\30\15" + + "\6\0\22\15\1\366\24\15\6\0\25\15\1\367\21\15" + + "\6\0\33\15\1\370\13\15\6\0\32\15\1\371\7\15" + + "\1\372\4\15\6\0\25\15\1\373\21\15\6\0\27\15" + + "\1\374\17\15\6\0\33\15\1\375\13\15\6\0\36\15" + + "\1\376\10\15\6\0\16\15\1\377\10\15\1\u0100\17\15" + + "\6\0\25\15\1\u0101\21\15\6\0\25\15\1\u0102\21\15" + + "\6\0\32\54\1\u0103\14\54\2\0\4\156\1\13\1\271" + + "\53\156\1\15\1\272\45\157\2\156\4\0\23\15\1\u0104" + + "\23\15\6\0\34\15\1\u0105\12\15\6\0\26\15\1\u0106" + + "\20\15\6\0\30\15\1\u0107\16\15\6\0\32\15\1\u0108" + + "\14\15\6\0\36\15\1\u0109\10\15\6\0\27\15\1\u010a" + + "\17\15\6\0\25\15\1\u010b\21\15\6\0\26\15\1\u010c" + + "\20\15\6\0\32\15\1\u010d\14\15\6\0\17\15\1\u010e" + + "\27\15\6\0\7\15\1\u010f\37\15\6\0\16\15\1\u0110" + + "\30\15\6\0\16\15\1\u0111\30\15\6\0\16\15\1\u0112" + + "\30\15\6\0\27\15\1\u0113\17\15\6\0\34\15\1\u0114" + + "\12\15\6\0\25\15\1\u0115\21\15\6\0\34\15\1\u0116" + + "\12\15\6\0\7\15\1\u0117\37\15\6\0\26\15\1\u0118" + + "\20\15\6\0\17\15\1\u0119\27\15\6\0\23\15\1\u011a" + + "\4\15\1\u011b\1\15\1\u011c\14\15\6\0\25\15\1\u011d" + + "\21\15\6\0\34\15\1\u011e\12\15\6\0\22\15\1\u011f" + + "\24\15\6\0\34\15\1\u0120\12\15\6\0\21\15\1\u0121" + + "\25\15\6\0\23\15\1\u0122\1\u0123\22\15\6\0\16\15" + + "\1\u0124\30\15\6\0\27\15\1\u0125\17\15\6\0\17\15" + + "\1\u0126\6\15\1\u0127\5\15\1\u0128\3\15\1\u0129\6\15" + + "\6\0\34\15\1\u012a\12\15\6\0\22\15\1\u012b\24\15" + + "\6\0\17\15\1\u012c\27\15\6\0\25\15\1\u012d\21\15" + + "\6\0\16\15\1\u012e\30\15\6\0\7\15\1\u012f\37\15" + + "\6\0\25\15\1\u0130\21\15\6\0\34\15\1\u0131\12\15" + + "\6\0\25\15\1\u0132\21\15\6\0\23\15\1\u0133\5\15" + + "\1\u0134\15\15\6\0\34\15\1\u0135\12\15\6\0\16\15" + + "\1\u0136\30\15\6\0\16\15\1\u0137\30\15\6\0\7\15" + + "\1\u0138\37\15\6\0\16\15\1\u0139\30\15\6\0\23\15" + + "\1\u013a\23\15\6\0\17\15\1\u013b\27\15\6\0\16\15" + + "\1\u013c\30\15\6\0\25\15\1\u013d\21\15\6\0\21\15" + + "\1\u013e\25\15\6\0\24\15\1\u013f\22\15\6\0\41\15" + + "\1\u0140\5\15\6\0\7\15\1\u0141\37\15\6\0\25\15" + + "\1\u0142\21\15\6\0\25\15\1\u0143\21\15\6\0\7\15" + + "\1\u0144\37\15\6\0\44\15\1\u0145\2\15\6\0\22\15" + + "\1\u0146\24\15\6\0\22\15\1\u0147\24\15\6\0\7\15" + + "\1\u0148\37\15\6\0\32\15\1\u0149\14\15\6\0\37\15" + + "\1\u014a\7\15\6\0\16\15\1\u014b\30\15\6\0\17\54" + + "\1\u014c\27\54\6\0\24\15\1\u014d\22\15\6\0\22\15" + + "\1\u014e\24\15\6\0\37\15\1\u014f\7\15\6\0\16\15" + + "\1\u0150\30\15\6\0\21\15\1\u0151\25\15\6\0\17\15" + + "\1\u0152\27\15\6\0\22\15\1\u0153\24\15\6\0\7\15" + + "\1\u0154\37\15\6\0\25\15\1\u0155\21\15\6\0\31\15" + + "\1\u0156\15\15\6\0\23\15\1\u0157\23\15\6\0\17\15" + + "\1\u0158\27\15\6\0\7\15\1\u0159\37\15\6\0\32\15" + + "\1\u015a\14\15\6\0\37\15\1\u015b\7\15\6\0\7\15" + + "\1\u015c\37\15\6\0\25\15\1\u015d\21\15\6\0\17\15" + + "\1\u015e\27\15\6\0\34\15\1\u015f\12\15\6\0\17\15" + + "\1\u0160\27\15\6\0\27\15\1\u0161\17\15\6\0\16\15" + + "\1\u0162\30\15\6\0\17\15\1\u0163\27\15\6\0\22\15" + + "\1\u0164\24\15\6\0\32\15\1\u0165\14\15\6\0\17\15" + + "\1\u0166\27\15\6\0\7\15\1\u0167\6\15\1\u0168\30\15" + + "\6\0\16\15\1\u0169\30\15\6\0\27\15\1\u016a\17\15" + + "\6\0\26\15\1\u016b\20\15\6\0\25\15\1\u016c\21\15" + + "\6\0\22\15\1\u016d\24\15\6\0\24\15\1\u016e\22\15" + + "\6\0\16\15\1\u016f\30\15\6\0\17\15\1\u0170\27\15" + + "\6\0\34\15\1\u0171\12\15\6\0\23\15\1\u0172\23\15" + + "\6\0\41\15\1\u0173\5\15\6\0\34\15\1\u0174\12\15" + + "\6\0\23\15\1\u0175\23\15\6\0\17\15\1\u0176\27\15" + + "\6\0\22\15\1\u0177\24\15\6\0\27\15\1\u0178\17\15" + + "\6\0\27\15\1\u0179\17\15\6\0\22\15\1\u017a\24\15" + + "\6\0\7\15\1\u017b\32\15\1\u017c\4\15\6\0\7\15" + + "\1\u017d\37\15\6\0\25\15\1\u017e\21\15\6\0\34\15" + + "\1\u017f\12\15\6\0\24\15\1\u0180\22\15\6\0\32\15" + + "\1\u0181\14\15\6\0\21\15\1\u0182\25\15\6\0\16\15" + + "\1\u0183\30\15\6\0\25\15\1\u0184\21\15\6\0\35\15" + + "\1\u0185\11\15\6\0\21\15\1\u0186\25\15\6\0\22\15" + + "\1\u0187\24\15\6\0\26\15\1\u0188\1\15\1\u0189\16\15" + + "\6\0\22\15\1\u018a\24\15\6\0\24\15\1\u018b\22\15" + + "\6\0\45\15\1\u018c\1\15\6\0\40\15\1\u018d\6\15" + + "\6\0\31\15\1\u018e\15\15\6\0\7\15\1\u018f\37\15" + + "\6\0\23\54\1\u0190\23\54\6\0\25\15\1\u0191\21\15" + + "\6\0\24\15\1\u0192\22\15\6\0\25\15\1\u0193\21\15" + + "\6\0\34\15\1\u0194\12\15\6\0\32\15\1\u0195\14\15" + + "\6\0\33\15\1\u0196\1\u0197\12\15\6\0\24\15\1\u0198" + + "\22\15\6\0\7\15\1\u0199\37\15\6\0\32\15\1\u019a" + + "\14\15\6\0\35\15\1\u019b\11\15\6\0\16\15\1\u019c" + + "\30\15\6\0\34\15\1\u019d\12\15\6\0\41\15\1\u019e" + + "\5\15\6\0\23\15\1\u019f\23\15\6\0\41\15\1\u01a0" + + "\5\15\6\0\41\15\1\u01a1\5\15\6\0\17\15\1\u01a2" + + "\27\15\6\0\25\15\1\u01a3\21\15\6\0\32\15\1\u01a4" + + "\14\15\6\0\23\15\1\u01a5\23\15\6\0\16\15\1\u01a6" + + "\30\15\6\0\32\15\1\u01a7\14\15\6\0\26\15\1\u01a8" + + "\20\15\6\0\21\15\1\u01a9\25\15\6\0\25\15\1\u01aa" + + "\21\15\6\0\17\15\1\u01ab\27\15\6\0\7\15\1\u01ac" + + "\37\15\6\0\21\15\1\u01ad\25\15\6\0\23\15\1\u01ae" + + "\23\15\6\0\16\15\1\u01af\30\15\6\0\25\15\1\u01b0" + + "\21\15\6\0\40\15\1\u01b1\6\15\6\0\7\15\1\u01b2" + + "\37\15\6\0\27\15\1\u01b3\17\15\6\0\26\15\1\u01b4" + + "\20\15\6\0\24\15\1\u01b5\22\15\6\0\22\15\1\u01b6" + + "\24\15\6\0\32\15\1\u01b7\14\15\6\0\32\15\1\u01b8" + + "\14\15\6\0\26\15\1\u01b9\11\15\1\u01ba\6\15\6\0" + + "\16\15\1\u01bb\30\15\6\0\30\15\1\u01bc\16\15\6\0" + + "\27\15\1\u01bd\17\15\6\0\16\15\1\u01be\15\15\1\u01bf" + + "\12\15\6\0\25\15\1\u01c0\21\15\6\0\31\15\1\u01c1" + + "\15\15\6\0\7\15\1\u01c2\37\15\6\0\27\15\1\u01c3" + + "\17\15\6\0\25\15\1\u01c4\21\15\6\0\17\15\1\u01c5" + + "\27\15\6\0\16\15\1\u01c6\30\15\6\0\32\15\1\u01c7" + + "\14\15\6\0\25\15\1\u01c8\21\15\6\0\16\15\1\u01c9" + + "\30\15\6\0\34\15\1\u01ca\12\15\6\0\16\15\1\u01cb" + + "\30\15\6\0\25\15\1\u01cc\21\15\6\0\7\15\1\u01cd" + + "\37\15\6\0\41\15\1\u01ce\5\15\6\0\17\15\1\u01cf" + + "\27\15\6\0\27\15\1\u01d0\17\15\6\0\34\15\1\u01d1" + + "\12\15\6\0\46\15\1\u01d2\6\0\31\15\1\u01d3\15\15" + + "\6\0\27\15\1\u01d4\17\15\6\0\24\15\1\u01d5\22\15" + + "\6\0\33\15\1\u01d6\13\15\6\0\7\15\1\u01d7\37\15" + + "\6\0\16\15\1\u01d8\30\15\6\0\25\15\1\u01d9\21\15" + + "\6\0\32\15\1\u01da\14\15\6\0\26\15\1\u01db\20\15" + + "\6\0\23\15\1\u01dc\23\15\6\0\23\15\1\u01dd\23\15" + + "\6\0\21\15\1\u01de\25\15\6\0\25\15\1\u01df\21\15" + + "\6\0\16\15\1\u01e0\30\15\6\0\33\15\1\u01e1\13\15" + + "\6\0\16\15\1\u01e2\30\15\6\0\7\15\1\u01e3\37\15" + + "\6\0\36\15\1\u01e4\10\15\6\0\20\15\1\u01e5\26\15" + + "\6\0\40\15\1\u01e6\6\15\6\0\25\15\1\u01e7\21\15" + + "\6\0\32\15\1\u01e8\14\15\6\0\16\15\1\u01e9\30\15" + + "\6\0\22\15\1\u01ea\24\15\6\0\16\15\1\u01eb\30\15" + + "\6\0\32\15\1\u01ec\14\15\6\0\27\15\1\u01ed\17\15" + + "\6\0\31\15\1\u01ee\15\15\6\0\36\15\1\u01ef\10\15" + + "\6\0\16\15\1\u01be\30\15\6\0\27\15\1\u01f0\17\15" + + "\6\0\23\15\1\u01f1\23\15\6\0\35\15\1\u01f2\11\15" + + "\6\0\30\15\1\u01f3\16\15\6\0\41\15\1\u01f4\5\15" + + "\6\0\36\15\1\u01f5\10\15\6\0\34\15\1\u01f6\12\15" + + "\6\0\25\15\1\u01f7\21\15\6\0\16\15\1\u01f8\30\15" + + "\6\0\16\15\1\u01f9\30\15\6\0\16\15\1\u01fa\30\15" + + "\6\0\33\15\1\u01fb\13\15\6\0\21\15\1\u01fc\25\15" + + "\6\0\33\15\1\u01fd\13\15\6\0\16\15\1\u01fe\30\15" + + "\6\0\24\15\1\u01ff\22\15\6\0\23\15\1\u0200\23\15" + + "\6\0\43\15\1\u0201\3\15\6\0\23\15\1\u0202\23\15" + + "\6\0\16\15\1\u0203\30\15\6\0\33\15\1\u0204\13\15" + + "\6\0\34\15\1\u0205\12\15\6\0\25\15\1\u0206\21\15" + + "\6\0\16\15\1\u0207\30\15\6\0\17\15\1\u0208\27\15" + + "\6\0\42\15\1\u0209\4\15\6\0\21\15\1\u020a\25\15" + + "\6\0\22\15\1\u020b\24\15\6\0\36\15\1\u020c\10\15" + + "\6\0\22\15\1\u020d\24\15\6\0\16\15\1\u020e\30\15" + + "\6\0\34\15\1\u020f\12\15\6\0\16\15\1\u0210\30\15" + + "\6\0\7\15\1\u0211\37\15\6\0\32\15\1\u0212\14\15" + + "\6\0\16\15\1\u0213\30\15\6\0\25\15\1\u0214\21\15" + + "\6\0\17\15\1\u0215\27\15\6\0\37\15\1\u0216\7\15" + + "\6\0\7\15\1\u0217\37\15\6\0\22\15\1\u0218\24\15" + + "\6\0\16\15\1\u0219\30\15\6\0\27\15\1\u021a\17\15" + + "\6\0\16\15\1\u021b\30\15\6\0\23\15\1\u021c\23\15" + + "\6\0\21\15\1\u021d\25\15\6\0\17\15\1\u021e\27\15" + + "\6\0\33\15\1\u021f\13\15\6\0\21\15\1\u0220\25\15" + + "\6\0\7\15\1\u0221\37\15\6\0\34\15\1\u0222\12\15" + + "\6\0\21\15\1\u0223\25\15\6\0\24\15\1\u0224\22\15" + + "\6\0\22\15\1\u0225\24\15\6\0\16\15\1\u0226\30\15" + + "\6\0\16\15\1\u0227\30\15\6\0\16\15\1\u0228\30\15" + + "\6\0\17\15\1\u0229\27\15\6\0\7\15\1\u022a\37\15" + + "\6\0\21\15\1\u022b\25\15\6\0\36\15\1\u022c\10\15" + + "\6\0\24\15\1\u022d\22\15\6\0\7\15\1\u022e\37\15" + + "\6\0\24\15\1\u022f\22\15\6\0\31\15\1\u0230\15\15" + + "\6\0\17\15\1\u0231\27\15\6\0\33\15\1\u0232\13\15" + + "\6\0\25\15\1\u0233\21\15\6\0\33\15\1\u0234\13\15" + + "\6\0\7\15\1\u0235\37\15\6\0\25\15\1\u0236\21\15" + + "\6\0\36\15\1\u0237\10\15\6\0\32\15\1\u0238\14\15" + + "\6\0\34\15\1\u0239\12\15\6\0\7\15\1\u023a\37\15" + + "\6\0\16\15\1\u023b\30\15\6\0\27\15\1\u023c\17\15" + + "\6\0\23\15\1\u023d\23\15\6\0\22\15\1\u023e\24\15" + + "\6\0\22\15\1\u023f\24\15\6\0\21\15\1\u0240\25\15" + + "\6\0\16\15\1\u0241\30\15\6\0\7\15\1\u0242\37\15" + + "\6\0\33\15\1\u0243\13\15\6\0\25\15\1\u0244\21\15" + + "\6\0\36\15\1\u0245\10\15\6\0\34\15\1\u0246\12\15" + + "\6\0\26\15\1\u0247\20\15\6\0\21\15\1\u0248\25\15" + + "\6\0\25\15\1\u0249\21\15\6\0\20\15\1\u024a\26\15" + + "\6\0\25\15\1\u024b\21\15\6\0\34\15\1\u024c\12\15" + + "\6\0\34\15\1\u024d\12\15\6\0\17\15\1\u024e\27\15" + + "\6\0\34\15\1\u024f\12\15\6\0\22\15\1\u0250\24\15" + + "\6\0\26\15\1\u0251\20\15\6\0\27\15\1\u0252\17\15" + + "\6\0\21\15\1\u0253\25\15\6\0\36\15\1\u0254\10\15" + + "\6\0\22\15\1\u0255\24\15\6\0\24\15\1\u0256\22\15" + + "\6\0\23\15\1\u0257\23\15\6\0\16\15\1\u0258\30\15" + + "\6\0\35\15\1\u0259\11\15\6\0\32\15\1\u025a\14\15" + + "\6\0\7\15\1\u025b\37\15\6\0\16\15\1\u025c\30\15" + + "\6\0\25\15\1\u025d\21\15\6\0\23\15\1\u025e\23\15" + + "\6\0\41\15\1\u025f\5\15\6\0\16\15\1\u0260\30\15" + + "\6\0\41\15\1\u0261\5\15\6\0\25\15\1\u0262\21\15" + + "\6\0\22\15\1\u0263\24\15\6\0\24\15\1\u0264\22\15" + + "\6\0\22\15\1\u0265\24\15\6\0\34\15\1\u0266\12\15" + + "\6\0\25\15\1\u0267\21\15\6\0\16\15\1\u0268\30\15" + + "\6\0\32\15\1\u0269\14\15\6\0\25\15\1\u026a\21\15" + + "\6\0\24\15\1\u026b\22\15\6\0\25\15\1\u026c\21\15" + + "\6\0\16\15\1\u026d\30\15\6\0\22\15\1\u026e\24\15" + + "\6\0\26\15\1\u026f\20\15\6\0\7\15\1\u0270\37\15" + + "\6\0\17\15\1\u0271\27\15\6\0\7\15\1\u0272\37\15" + + "\6\0\16\15\1\u0273\30\15\6\0\37\15\1\u0274\7\15" + + "\6\0\23\15\1\u0275\23\15\6\0\25\15\1\u0276\21\15" + + "\6\0\21\15\1\u0277\25\15\6\0\16\15\1\u0278\30\15" + + "\6\0\31\15\1\u0279\15\15\6\0\25\15\1\u027a\21\15" + + "\6\0\25\15\1\u027b\21\15\6\0\34\15\1\u027c\12\15" + + "\6\0\22\15\1\u027d\24\15\6\0\42\15\1\u027e\4\15" + + "\6\0\21\15\1\u027f\25\15\6\0\35\15\1\u0280\11\15" + + "\6\0\25\15\1\u0281\21\15\6\0\26\15\1\u0282\20\15" + + "\6\0\34\15\1\u0283\12\15\6\0\27\15\1\u0284\17\15" + + "\6\0\27\15\1\u0285\17\15\6\0\16\15\1\u0286\15\15" + + "\1\u0287\12\15\6\0\21\15\1\u0288\25\15\6\0\17\15" + + "\1\u0289\27\15\6\0\21\15\1\u028a\25\15\6\0\34\15" + + "\1\u028b\12\15\6\0\21\15\1\u028c\25\15\6\0\25\15" + + "\1\u028d\21\15\6\0\16\15\1\u028e\30\15\6\0\22\15" + + "\1\u028f\24\15\6\0\32\15\1\u0290\14\15\6\0\36\15" + + "\1\u0291\10\15\6\0\16\15\1\u0286\30\15\6\0\25\15" + + "\1\u0292\21\15\6\0\33\15\1\u0293\13\15\6\0\16\15" + + "\1\u0294\30\15\6\0\27\15\1\u0295\17\15\6\0\16\15" + + "\1\u0296\30\15\6\0\32\15\1\u0297\14\15\6\0\31\15" + + "\1\u0298\15\15\6\0\7\15\1\u0299\37\15\6\0\21\15" + + "\1\u029a\25\15\6\0\33\15\1\u029b\13\15\6\0\16\15" + + "\1\u029c\30\15\6\0\22\15\1\u029d\24\15\6\0\21\15" + + "\1\u029e\25\15\6\0\36\15\1\u029f\10\15\6\0\27\15" + + "\1\u02a0\17\15\6\0\34\15\1\u02a1\12\15\6\0\32\15" + + "\1\u02a2\14\15\6\0\27\15\1\u02a3\17\15\6\0\32\15" + + "\1\u02a4\14\15\6\0\22\15\1\u02a5\24\15\6\0\7\15" + + "\1\u02a6\37\15\6\0\34\15\1\u02a7\12\15\6\0\31\15" + + "\1\u02a8\15\15\6\0\24\15\1\u02a9\22\15\6\0\25\15" + + "\1\u02aa\21\15\6\0\16\15\1\u02ab\30\15\6\0\25\15" + + "\1\u02ac\21\15\6\0\34\15\1\u02ad\12\15\6\0\26\15" + + "\1\u02ae\20\15\6\0\16\15\1\u02af\30\15\6\0\17\15" + + "\1\u02b0\27\15\6\0\25\15\1\u02b1\21\15\6\0\26\15" + + "\1\u02b2\20\15\6\0\27\15\1\u02b3\17\15\6\0\16\15" + + "\1\u02b4\30\15\6\0\22\15\1\u02b5\24\15\6\0\7\15" + + "\1\u02b6\37\15\6\0\32\15\1\u02b7\14\15\6\0\26\15" + + "\1\u02b8\20\15\6\0\7\15\1\u02b9\37\15\6\0\22\15" + + "\1\u02ba\24\15\6\0\25\15\1\u02bb\21\15\6\0\21\15" + + "\1\u02bc\25\15\6\0\34\15\1\u02bd\12\15\6\0\25\15" + + "\1\u02be\21\15\6\0\17\15\1\u02bf\27\15\6\0\21\15" + + "\1\u02c0\25\15\6\0\26\15\1\u02c1\20\15\6\0\16\15" + + "\1\u02c2\30\15\6\0\7\15\1\u02c3\37\15\6\0\26\15" + + "\1\u02c4\20\15\6\0\22\15\1\u02c5\24\15\6\0\21\15" + + "\1\u02c6\25\15\6\0\25\15\1\u02c7\21\15\6\0\21\15" + + "\1\u02c8\25\15\2\0"; + /** + * The transition table of the DFA + */ + private static final int[] ZZ_TRANS = zzUnpackTrans(); + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\7\0\1\1\1\11\1\1\1\11\4\1\2\11\24\1" + + "\2\11\1\1\2\11\2\1\2\11\3\1\1\11\1\1" + + "\3\0\67\1\1\0\3\1\1\0\1\11\105\1\1\0" + + "\u020f\1"; + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState + */ + private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute(); + /* user code: */ + StringBuffer string = new StringBuffer(); + /** + * the input device + */ + private java.io.Reader zzReader; + /** + * the current state of the DFA + */ + private int zzState; + /** + * the current lexical state + */ + private int zzLexicalState = YYINITIAL; + /** + * this buffer contains the current text to be matched and is + * the source of the yytext() string + */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + /** + * the textposition at the last accepting state + */ + private int zzMarkedPos; + /** + * the textposition at the last state to be included in yytext + */ + private int zzPushbackPos; + /** + * the current text position in the buffer + */ + private int zzCurrentPos; + /** + * startRead marks the beginning of the yytext() string in the buffer + */ + private int zzStartRead; + /** + * endRead marks the last character in the buffer, that has been read + * from input + */ + private int zzEndRead; + /** + * number of newlines encountered up to the start of the matched text + */ + private int yyline; + /** + * the number of characters up to the start of the matched text + */ + private int yychar; + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + /** + * zzAtEOF == true <=> the scanner is at the EOF + */ + private boolean zzAtEOF; + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + SpecctraFileScanner(java.io.Reader in) { + this.zzReader = in; } - return j; - } - - /** - * Translates a state to a row index in the transition table - */ - private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); - - private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\55\0\132\0\207\0\264\0\341\0\u010e\0\u013b"+ - "\0\u0168\0\u0195\0\u0168\0\u01c2\0\u01ef\0\u021c\0\u0249\0\u0168"+ - "\0\u0168\0\u0276\0\u02a3\0\u02d0\0\u02fd\0\u032a\0\u0357\0\u0384"+ - "\0\u03b1\0\u03de\0\u040b\0\u0438\0\u0465\0\u0492\0\u04bf\0\u04ec"+ - "\0\u0519\0\u0546\0\u0573\0\u05a0\0\u05cd\0\u0168\0\u0168\0\u05fa"+ - "\0\u0168\0\u0168\0\u0627\0\u0654\0\u0168\0\u0168\0\u0681\0\u06ae"+ - "\0\u06db\0\u0168\0\u0708\0\u0735\0\u0762\0\u078f\0\u02a3\0\u07bc"+ - "\0\u07e9\0\u0816\0\u0843\0\u0870\0\u089d\0\u08ca\0\u08f7\0\u0924"+ - "\0\u0951\0\u097e\0\u09ab\0\u09d8\0\u0a05\0\u01ef\0\u0a32\0\u0a5f"+ - "\0\u0a8c\0\u0ab9\0\u0ae6\0\u0b13\0\u0b40\0\u0b6d\0\u0b9a\0\u0bc7"+ - "\0\u0bf4\0\u0c21\0\u0c4e\0\u0c7b\0\u0ca8\0\u0cd5\0\u0d02\0\u0d2f"+ - "\0\u0d5c\0\u0d89\0\u0db6\0\u0de3\0\u0e10\0\u0e3d\0\u0e6a\0\u0e97"+ - "\0\u0ec4\0\u0ef1\0\u0f1e\0\u0f4b\0\u0f78\0\u0fa5\0\u0fd2\0\u0fff"+ - "\0\u102c\0\u1059\0\u1086\0\u10b3\0\u10e0\0\u110d\0\u113a\0\u1167"+ - "\0\u1194\0\u11c1\0\u0168\0\u11ee\0\u121b\0\u1248\0\u1275\0\u12a2"+ - "\0\u12cf\0\u12fc\0\u1329\0\u1356\0\u1383\0\u13b0\0\u13dd\0\u140a"+ - "\0\u1437\0\u1464\0\u1491\0\u14be\0\u14eb\0\u01ef\0\u1518\0\u1545"+ - "\0\u1572\0\u159f\0\u15cc\0\u15f9\0\u1626\0\u1653\0\u1680\0\u16ad"+ - "\0\u16da\0\u1707\0\u1734\0\u1761\0\u178e\0\u17bb\0\u17e8\0\u1815"+ - "\0\u1842\0\u186f\0\u189c\0\u18c9\0\u18f6\0\u1923\0\u1950\0\u197d"+ - "\0\u19aa\0\u19d7\0\u01ef\0\u1a04\0\u1a31\0\u1a5e\0\u1a8b\0\u1ab8"+ - "\0\u1ae5\0\u1b12\0\u1b3f\0\u1b6c\0\u1b99\0\u01ef\0\u1bc6\0\u1bf3"+ - "\0\u1c20\0\u1c4d\0\u1c7a\0\u1ca7\0\u1cd4\0\u1d01\0\u1d2e\0\u0654"+ - "\0\u1d5b\0\u1d88\0\u1db5\0\u1de2\0\u1e0f\0\u1e3c\0\u1e69\0\u01ef"+ - "\0\u1e96\0\u1ec3\0\u1ef0\0\u1f1d\0\u1f4a\0\u1f77\0\u01ef\0\u1fa4"+ - "\0\u1fd1\0\u1ffe\0\u202b\0\u2058\0\u2085\0\u20b2\0\u20df\0\u210c"+ - "\0\u2139\0\u2166\0\u2193\0\u01ef\0\u21c0\0\u21ed\0\u221a\0\u2247"+ - "\0\u2274\0\u22a1\0\u22ce\0\u22fb\0\u2328\0\u01ef\0\u2355\0\u2382"+ - "\0\u01ef\0\u23af\0\u23dc\0\u01ef\0\u2409\0\u2436\0\u2463\0\u2490"+ - "\0\u24bd\0\u24ea\0\u2517\0\u2544\0\u2571\0\u259e\0\u01ef\0\u25cb"+ - "\0\u25f8\0\u2625\0\u2652\0\u267f\0\u26ac\0\u26d9\0\u2706\0\u2733"+ - "\0\u2760\0\u278d\0\u27ba\0\u27e7\0\u2814\0\u2841\0\u286e\0\u289b"+ - "\0\u28c8\0\u28f5\0\u2922\0\u294f\0\u297c\0\u29a9\0\u29d6\0\u2a03"+ - "\0\u2a30\0\u2a5d\0\u2a8a\0\u2ab7\0\u2ae4\0\u2b11\0\u2b3e\0\u01ef"+ - "\0\u01ef\0\u2b6b\0\u2b98\0\u01ef\0\u2bc5\0\u2bf2\0\u2c1f\0\u2c4c"+ - "\0\u2c79\0\u2ca6\0\u2cd3\0\u2d00\0\u2d2d\0\u2d5a\0\u2d87\0\u2db4"+ - "\0\u2de1\0\u2e0e\0\u2e3b\0\u01ef\0\u2e68\0\u2e95\0\u2ec2\0\u2eef"+ - "\0\u2f1c\0\u2f49\0\u2f76\0\u2fa3\0\u2fd0\0\u2ffd\0\u302a\0\u3057"+ - "\0\u3084\0\u30b1\0\u30de\0\u310b\0\u01ef\0\u3138\0\u3165\0\u3192"+ - "\0\u31bf\0\u31ec\0\u3219\0\u3246\0\u3273\0\u01ef\0\u32a0\0\u32cd"+ - "\0\u32fa\0\u01ef\0\u3327\0\u3354\0\u3381\0\u33ae\0\u33db\0\u3408"+ - "\0\u3435\0\u01ef\0\u3462\0\u348f\0\u34bc\0\u34e9\0\u01ef\0\u01ef"+ - "\0\u3516\0\u3543\0\u3570\0\u359d\0\u35ca\0\u35f7\0\u01ef\0\u3624"+ - "\0\u3651\0\u367e\0\u01ef\0\u36ab\0\u36d8\0\u3705\0\u3732\0\u375f"+ - "\0\u378c\0\u37b9\0\u37e6\0\u3813\0\u3840\0\u386d\0\u389a\0\u38c7"+ - "\0\u01ef\0\u38f4\0\u3921\0\u394e\0\u397b\0\u39a8\0\u39d5\0\u3a02"+ - "\0\u3a2f\0\u01ef\0\u3a5c\0\u01ef\0\u3a89\0\u3ab6\0\u3ae3\0\u3b10"+ - "\0\u3b3d\0\u3b6a\0\u3b97\0\u3bc4\0\u3bf1\0\u3c1e\0\u3c4b\0\u3c78"+ - "\0\u3ca5\0\u01ef\0\u3cd2\0\u01ef\0\u3cff\0\u3d2c\0\u01ef\0\u3d59"+ - "\0\u3d86\0\u3db3\0\u3de0\0\u01ef\0\u3e0d\0\u01ef\0\u3e3a\0\u0654"+ - "\0\u3e67\0\u3e94\0\u3ec1\0\u3eee\0\u01ef\0\u3f1b\0\u3f48\0\u3f75"+ - "\0\u3fa2\0\u3fcf\0\u3ffc\0\u01ef\0\u4029\0\u4056\0\u4083\0\u01ef"+ - "\0\u40b0\0\u01ef\0\u01ef\0\u40dd\0\u01ef\0\u410a\0\u4137\0\u4164"+ - "\0\u01ef\0\u01ef\0\u4191\0\u41be\0\u41eb\0\u4218\0\u4245\0\u4272"+ - "\0\u429f\0\u42cc\0\u42f9\0\u4326\0\u4353\0\u4380\0\u43ad\0\u01ef"+ - "\0\u43da\0\u4407\0\u4434\0\u4461\0\u448e\0\u44bb\0\u44e8\0\u4515"+ - "\0\u4542\0\u456f\0\u459c\0\u45c9\0\u45f6\0\u4623\0\u4650\0\u01ef"+ - "\0\u467d\0\u46aa\0\u01ef\0\u46d7\0\u4704\0\u01ef\0\u4731\0\u475e"+ - "\0\u478b\0\u47b8\0\u47e5\0\u4812\0\u483f\0\u486c\0\u4899\0\u48c6"+ - "\0\u01ef\0\u48f3\0\u4920\0\u494d\0\u01ef\0\u497a\0\u49a7\0\u01ef"+ - "\0\u49d4\0\u4a01\0\u4a2e\0\u4a5b\0\u4a88\0\u01ef\0\u4ab5\0\u01ef"+ - "\0\u4ae2\0\u4b0f\0\u4b3c\0\u4b69\0\u4b96\0\u4bc3\0\u4bf0\0\u4c1d"+ - "\0\u4c4a\0\u4c77\0\u4ca4\0\u4cd1\0\u01ef\0\u4cfe\0\u4d2b\0\u4d58"+ - "\0\u4d85\0\u4db2\0\u4ddf\0\u4e0c\0\u4e39\0\u01ef\0\u4e66\0\u4e93"+ - "\0\u4ec0\0\u4eed\0\u01ef\0\u4f1a\0\u01ef\0\u01ef\0\u4f47\0\u4f74"+ - "\0\u4fa1\0\u01ef\0\u4fce\0\u4ffb\0\u5028\0\u5055\0\u5082\0\u01ef"+ - "\0\u50af\0\u50dc\0\u5109\0\u01ef\0\u5136\0\u5163\0\u5190\0\u51bd"+ - "\0\u01ef\0\u51ea\0\u5217\0\u5244\0\u5271\0\u529e\0\u52cb\0\u52f8"+ - "\0\u5325\0\u5352\0\u537f\0\u53ac\0\u53d9\0\u01ef\0\u5406\0\u01ef"+ - "\0\u5433\0\u5460\0\u548d\0\u01ef\0\u54ba\0\u54e7\0\u5514\0\u5541"+ - "\0\u556e\0\u559b\0\u55c8\0\u55f5\0\u5622\0\u01ef\0\u564f\0\u01ef"+ - "\0\u567c\0\u56a9\0\u01ef\0\u56d6\0\u01ef\0\u5703\0\u5730\0\u575d"+ - "\0\u578a\0\u57b7\0\u57e4\0\u5811\0\u01ef\0\u583e\0\u586b\0\u01ef"+ - "\0\u01ef\0\u5898\0\u01ef\0\u58c5\0\u58f2\0\u591f\0\u594c\0\u5979"+ - "\0\u59a6\0\u59d3\0\u5a00\0\u5a2d\0\u5a5a\0\u5a87\0\u5ab4\0\u5ae1"+ - "\0\u5b0e\0\u5b3b\0\u5b68\0\u01ef\0\u5b95\0\u5bc2\0\u5bef\0\u5c1c"+ - "\0\u01ef\0\u5c49\0\u5c76\0\u5ca3\0\u5cd0\0\u5cfd\0\u01ef\0\u5d2a"+ - "\0\u01ef\0\u01ef\0\u5d57\0\u5d84\0\u5db1\0\u01ef\0\u5dde\0\u5e0b"+ - "\0\u5e38\0\u5e65\0\u01ef\0\u01ef\0\u01ef\0\u01ef\0\u5e92\0\u5ebf"+ - "\0\u5eec\0\u5f19\0\u5f46\0\u5f73\0\u5fa0\0\u5fcd\0\u5ffa\0\u6027"+ - "\0\u6054\0\u6081\0\u60ae\0\u60db\0\u6108\0\u6135\0\u6162\0\u618f"+ - "\0\u61bc\0\u01ef\0\u61e9\0\u01ef\0\u6216\0\u6243\0\u6270\0\u629d"+ - "\0\u62ca\0\u62f7\0\u6324\0\u6351\0\u637e\0\u01ef\0\u01ef\0\u63ab"+ - "\0\u63d8\0\u01ef\0\u6405\0\u6432\0\u645f\0\u01ef\0\u648c\0\u64b9"+ - "\0\u64e6\0\u6513\0\u6540\0\u656d\0\u659a\0\u65c7\0\u65f4\0\u01ef"+ - "\0\u6621\0\u664e\0\u667b\0\u66a8\0\u66d5\0\u6702\0\u01ef\0\u672f"+ - "\0\u675c\0\u6789\0\u67b6\0\u67e3\0\u6810\0\u683d\0\u686a\0\u6897"+ - "\0\u68c4\0\u68f1\0\u691e\0\u694b\0\u6978\0\u69a5\0\u69d2\0\u01ef"+ - "\0\u69ff\0\u6a2c\0\u6a59\0\u6a86\0\u6ab3\0\u6ae0\0\u6b0d\0\u01ef"; - - private static int [] zzUnpackRowMap() { - int [] result = new int[712]; - int offset = 0; - offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackRowMap(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int high = packed.charAt(i++) << 16; - result[j++] = high | packed.charAt(i++); + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + SpecctraFileScanner(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); } - return j; - } - - /** - * The transition table of the DFA - */ - private static final int [] ZZ_TRANS = zzUnpackTrans(); - private static final String ZZ_TRANS_PACKED_0 = - "\1\11\1\12\2\13\1\14\1\15\1\16\1\15\1\17"+ - "\1\20\1\21\4\15\2\22\1\23\1\15\1\24\1\25"+ - "\1\26\1\27\1\30\1\31\1\32\1\33\1\34\1\35"+ - "\1\36\1\37\1\40\1\41\1\42\1\15\1\43\1\44"+ - "\4\15\1\45\1\15\1\46\1\47\11\50\1\51\3\50"+ - "\1\52\37\50\12\53\1\51\2\53\1\52\37\53\1\11"+ - "\1\12\2\13\5\54\1\20\1\21\40\54\1\55\1\56"+ - "\1\11\1\12\2\13\5\54\1\20\1\21\12\54\1\57"+ - "\11\54\1\60\13\54\1\55\1\56\1\11\1\12\2\13"+ - "\5\61\1\20\1\21\4\61\1\11\33\61\1\55\1\56"+ - "\4\11\3\62\4\11\6\62\35\11\1\12\2\13\47\54"+ - "\1\55\1\56\57\0\1\13\56\0\1\15\1\63\45\15"+ - "\6\0\47\15\2\0\1\64\1\12\1\13\1\64\47\16"+ - "\2\64\10\0\1\17\3\0\1\65\4\0\1\17\1\66"+ - "\42\0\1\17\10\0\1\23\43\0\1\67\3\0\1\65"+ - "\4\0\1\67\1\66\36\0\20\15\1\70\3\15\1\71"+ - "\1\72\1\73\2\15\1\74\15\15\6\0\17\15\1\75"+ - "\2\15\1\76\24\15\6\0\16\15\1\77\6\15\1\100"+ - "\1\15\1\101\2\15\1\102\1\103\3\15\1\104\7\15"+ - "\6\0\24\15\1\105\5\15\1\106\1\15\1\107\1\110"+ - "\11\15\6\0\16\15\1\111\1\112\2\15\1\113\4\15"+ - "\1\114\17\15\6\0\21\15\1\115\25\15\6\0\41\15"+ - "\1\116\5\15\6\0\22\15\1\117\1\120\3\15\1\121"+ - "\17\15\6\0\42\15\1\122\4\15\6\0\16\15\1\123"+ - "\10\15\1\124\17\15\6\0\16\15\1\125\30\15\6\0"+ - "\16\15\1\126\3\15\1\127\4\15\1\130\17\15\6\0"+ - "\17\15\1\131\2\15\1\132\1\133\1\134\1\15\1\135"+ - "\1\136\4\15\1\137\12\15\6\0\16\15\1\140\3\15"+ - "\1\141\1\15\1\142\22\15\6\0\17\15\1\143\2\15"+ - "\1\144\1\145\3\15\1\146\4\15\1\147\12\15\6\0"+ - "\22\15\1\150\24\15\6\0\16\15\1\151\30\15\6\0"+ - "\27\15\1\152\4\15\1\153\12\15\2\0\11\50\1\0"+ - "\3\50\1\0\37\50\12\53\1\0\2\53\1\0\37\53"+ - "\4\0\47\54\6\0\27\54\1\154\17\54\6\0\26\54"+ - "\1\155\20\54\6\0\13\61\1\0\33\61\2\0\4\156"+ - "\1\157\1\15\45\157\2\156\1\64\1\12\1\13\52\64"+ - "\10\0\1\160\10\0\1\160\43\0\1\161\6\0\2\162"+ - "\1\163\37\0\21\15\1\164\25\15\6\0\25\15\1\165"+ - "\21\15\6\0\25\15\1\166\21\15\6\0\25\15\1\167"+ - "\21\15\6\0\17\15\1\170\27\15\6\0\26\15\1\171"+ - "\20\15\6\0\24\15\1\172\22\15\6\0\21\15\1\173"+ - "\25\15\6\0\17\15\1\174\14\15\1\175\12\15\6\0"+ - "\31\15\1\176\4\15\1\177\10\15\6\0\17\15\1\200"+ - "\27\15\6\0\17\15\1\201\27\15\6\0\17\15\1\202"+ - "\2\15\1\203\24\15\6\0\25\15\1\204\21\15\6\0"+ - "\36\15\1\205\10\15\6\0\35\15\1\206\11\15\6\0"+ - "\32\15\1\207\14\15\6\0\41\15\1\210\5\15\6\0"+ - "\26\15\1\211\2\15\1\212\15\15\6\0\20\15\1\213"+ - "\26\15\6\0\16\15\1\214\30\15\6\0\33\15\1\215"+ - "\13\15\6\0\32\15\1\216\7\15\1\217\4\15\6\0"+ - "\16\15\1\220\1\221\27\15\6\0\34\15\1\222\12\15"+ - "\6\0\17\15\1\223\27\15\6\0\34\15\1\224\12\15"+ - "\6\0\17\15\1\225\27\15\6\0\32\15\1\226\14\15"+ - "\6\0\25\15\1\227\21\15\6\0\32\15\1\230\1\15"+ - "\1\231\12\15\6\0\32\15\1\232\14\15\6\0\25\15"+ - "\1\233\6\15\1\234\1\15\1\235\10\15\6\0\21\15"+ - "\1\236\1\15\1\237\21\15\1\240\1\15\6\0\17\15"+ - "\1\241\27\15\6\0\23\15\1\242\23\15\6\0\20\15"+ - "\1\243\26\15\6\0\32\15\1\244\14\15\6\0\16\15"+ - "\1\245\30\15\6\0\21\15\1\246\4\15\1\247\20\15"+ - "\6\0\24\15\1\250\1\251\21\15\6\0\23\15\1\252"+ - "\23\15\6\0\32\15\1\253\14\15\6\0\34\15\1\254"+ - "\12\15\6\0\27\15\1\255\17\15\6\0\43\15\1\256"+ - "\3\15\6\0\22\15\1\257\24\15\6\0\21\15\1\260"+ - "\12\15\1\261\12\15\6\0\16\15\1\262\30\15\6\0"+ - "\32\15\1\263\1\15\1\264\1\15\1\265\10\15\6\0"+ - "\27\15\1\266\17\15\6\0\31\54\1\267\15\54\6\0"+ - "\20\54\1\270\26\54\2\0\5\156\1\271\53\156\1\157"+ - "\1\272\45\157\2\156\10\0\1\160\10\0\1\160\1\66"+ - "\42\0\1\161\10\0\1\161\43\0\1\161\10\0\1\163"+ - "\37\0\22\15\1\273\24\15\6\0\22\15\1\274\24\15"+ - "\6\0\17\15\1\275\27\15\6\0\27\15\1\276\17\15"+ - "\6\0\27\15\1\277\17\15\6\0\40\15\1\300\6\15"+ - "\6\0\32\15\1\301\14\15\6\0\21\15\1\302\25\15"+ - "\6\0\34\15\1\303\12\15\6\0\24\15\1\304\2\15"+ - "\1\305\17\15\6\0\32\15\1\306\14\15\6\0\16\15"+ - "\1\307\30\15\6\0\33\15\1\310\13\15\6\0\34\15"+ - "\1\311\12\15\6\0\33\15\1\312\13\15\6\0\30\15"+ - "\1\313\16\15\6\0\23\15\1\314\23\15\6\0\16\15"+ - "\1\315\30\15\6\0\31\15\1\316\15\15\6\0\16\15"+ - "\1\317\30\15\6\0\40\15\1\320\6\15\6\0\27\15"+ - "\1\321\17\15\6\0\34\15\1\322\12\15\6\0\7\15"+ - "\1\323\37\15\6\0\16\15\1\324\30\15\6\0\21\15"+ - "\1\325\3\15\1\326\21\15\6\0\33\15\1\327\13\15"+ - "\6\0\17\15\1\330\27\15\6\0\21\15\1\331\25\15"+ - "\6\0\26\15\1\332\20\15\6\0\31\15\1\333\15\15"+ - "\6\0\25\15\1\334\21\15\6\0\7\15\1\335\11\15"+ - "\1\336\25\15\6\0\16\15\1\337\30\15\6\0\45\15"+ - "\1\340\1\15\6\0\16\15\1\341\30\15\6\0\42\15"+ - "\1\342\4\15\6\0\16\15\1\343\30\15\6\0\37\15"+ - "\1\344\7\15\6\0\21\15\1\345\3\15\1\346\21\15"+ - "\6\0\21\15\1\347\25\15\6\0\25\15\1\350\1\15"+ - "\1\351\17\15\6\0\41\15\1\352\5\15\6\0\16\15"+ - "\1\353\30\15\6\0\26\15\1\354\3\15\1\355\14\15"+ - "\6\0\23\15\1\356\23\15\6\0\21\15\1\357\25\15"+ - "\6\0\35\15\1\360\11\15\6\0\22\15\1\361\24\15"+ - "\6\0\25\15\1\362\21\15\6\0\25\15\1\363\21\15"+ - "\6\0\17\15\1\364\27\15\6\0\16\15\1\365\30\15"+ - "\6\0\22\15\1\366\24\15\6\0\25\15\1\367\21\15"+ - "\6\0\33\15\1\370\13\15\6\0\32\15\1\371\7\15"+ - "\1\372\4\15\6\0\25\15\1\373\21\15\6\0\27\15"+ - "\1\374\17\15\6\0\33\15\1\375\13\15\6\0\36\15"+ - "\1\376\10\15\6\0\16\15\1\377\10\15\1\u0100\17\15"+ - "\6\0\25\15\1\u0101\21\15\6\0\25\15\1\u0102\21\15"+ - "\6\0\32\54\1\u0103\14\54\2\0\4\156\1\13\1\271"+ - "\53\156\1\15\1\272\45\157\2\156\4\0\23\15\1\u0104"+ - "\23\15\6\0\34\15\1\u0105\12\15\6\0\26\15\1\u0106"+ - "\20\15\6\0\30\15\1\u0107\16\15\6\0\32\15\1\u0108"+ - "\14\15\6\0\36\15\1\u0109\10\15\6\0\27\15\1\u010a"+ - "\17\15\6\0\25\15\1\u010b\21\15\6\0\26\15\1\u010c"+ - "\20\15\6\0\32\15\1\u010d\14\15\6\0\17\15\1\u010e"+ - "\27\15\6\0\7\15\1\u010f\37\15\6\0\16\15\1\u0110"+ - "\30\15\6\0\16\15\1\u0111\30\15\6\0\16\15\1\u0112"+ - "\30\15\6\0\27\15\1\u0113\17\15\6\0\34\15\1\u0114"+ - "\12\15\6\0\25\15\1\u0115\21\15\6\0\34\15\1\u0116"+ - "\12\15\6\0\7\15\1\u0117\37\15\6\0\26\15\1\u0118"+ - "\20\15\6\0\17\15\1\u0119\27\15\6\0\23\15\1\u011a"+ - "\4\15\1\u011b\1\15\1\u011c\14\15\6\0\25\15\1\u011d"+ - "\21\15\6\0\34\15\1\u011e\12\15\6\0\22\15\1\u011f"+ - "\24\15\6\0\34\15\1\u0120\12\15\6\0\21\15\1\u0121"+ - "\25\15\6\0\23\15\1\u0122\1\u0123\22\15\6\0\16\15"+ - "\1\u0124\30\15\6\0\27\15\1\u0125\17\15\6\0\17\15"+ - "\1\u0126\6\15\1\u0127\5\15\1\u0128\3\15\1\u0129\6\15"+ - "\6\0\34\15\1\u012a\12\15\6\0\22\15\1\u012b\24\15"+ - "\6\0\17\15\1\u012c\27\15\6\0\25\15\1\u012d\21\15"+ - "\6\0\16\15\1\u012e\30\15\6\0\7\15\1\u012f\37\15"+ - "\6\0\25\15\1\u0130\21\15\6\0\34\15\1\u0131\12\15"+ - "\6\0\25\15\1\u0132\21\15\6\0\23\15\1\u0133\5\15"+ - "\1\u0134\15\15\6\0\34\15\1\u0135\12\15\6\0\16\15"+ - "\1\u0136\30\15\6\0\16\15\1\u0137\30\15\6\0\7\15"+ - "\1\u0138\37\15\6\0\16\15\1\u0139\30\15\6\0\23\15"+ - "\1\u013a\23\15\6\0\17\15\1\u013b\27\15\6\0\16\15"+ - "\1\u013c\30\15\6\0\25\15\1\u013d\21\15\6\0\21\15"+ - "\1\u013e\25\15\6\0\24\15\1\u013f\22\15\6\0\41\15"+ - "\1\u0140\5\15\6\0\7\15\1\u0141\37\15\6\0\25\15"+ - "\1\u0142\21\15\6\0\25\15\1\u0143\21\15\6\0\7\15"+ - "\1\u0144\37\15\6\0\44\15\1\u0145\2\15\6\0\22\15"+ - "\1\u0146\24\15\6\0\22\15\1\u0147\24\15\6\0\7\15"+ - "\1\u0148\37\15\6\0\32\15\1\u0149\14\15\6\0\37\15"+ - "\1\u014a\7\15\6\0\16\15\1\u014b\30\15\6\0\17\54"+ - "\1\u014c\27\54\6\0\24\15\1\u014d\22\15\6\0\22\15"+ - "\1\u014e\24\15\6\0\37\15\1\u014f\7\15\6\0\16\15"+ - "\1\u0150\30\15\6\0\21\15\1\u0151\25\15\6\0\17\15"+ - "\1\u0152\27\15\6\0\22\15\1\u0153\24\15\6\0\7\15"+ - "\1\u0154\37\15\6\0\25\15\1\u0155\21\15\6\0\31\15"+ - "\1\u0156\15\15\6\0\23\15\1\u0157\23\15\6\0\17\15"+ - "\1\u0158\27\15\6\0\7\15\1\u0159\37\15\6\0\32\15"+ - "\1\u015a\14\15\6\0\37\15\1\u015b\7\15\6\0\7\15"+ - "\1\u015c\37\15\6\0\25\15\1\u015d\21\15\6\0\17\15"+ - "\1\u015e\27\15\6\0\34\15\1\u015f\12\15\6\0\17\15"+ - "\1\u0160\27\15\6\0\27\15\1\u0161\17\15\6\0\16\15"+ - "\1\u0162\30\15\6\0\17\15\1\u0163\27\15\6\0\22\15"+ - "\1\u0164\24\15\6\0\32\15\1\u0165\14\15\6\0\17\15"+ - "\1\u0166\27\15\6\0\7\15\1\u0167\6\15\1\u0168\30\15"+ - "\6\0\16\15\1\u0169\30\15\6\0\27\15\1\u016a\17\15"+ - "\6\0\26\15\1\u016b\20\15\6\0\25\15\1\u016c\21\15"+ - "\6\0\22\15\1\u016d\24\15\6\0\24\15\1\u016e\22\15"+ - "\6\0\16\15\1\u016f\30\15\6\0\17\15\1\u0170\27\15"+ - "\6\0\34\15\1\u0171\12\15\6\0\23\15\1\u0172\23\15"+ - "\6\0\41\15\1\u0173\5\15\6\0\34\15\1\u0174\12\15"+ - "\6\0\23\15\1\u0175\23\15\6\0\17\15\1\u0176\27\15"+ - "\6\0\22\15\1\u0177\24\15\6\0\27\15\1\u0178\17\15"+ - "\6\0\27\15\1\u0179\17\15\6\0\22\15\1\u017a\24\15"+ - "\6\0\7\15\1\u017b\32\15\1\u017c\4\15\6\0\7\15"+ - "\1\u017d\37\15\6\0\25\15\1\u017e\21\15\6\0\34\15"+ - "\1\u017f\12\15\6\0\24\15\1\u0180\22\15\6\0\32\15"+ - "\1\u0181\14\15\6\0\21\15\1\u0182\25\15\6\0\16\15"+ - "\1\u0183\30\15\6\0\25\15\1\u0184\21\15\6\0\35\15"+ - "\1\u0185\11\15\6\0\21\15\1\u0186\25\15\6\0\22\15"+ - "\1\u0187\24\15\6\0\26\15\1\u0188\1\15\1\u0189\16\15"+ - "\6\0\22\15\1\u018a\24\15\6\0\24\15\1\u018b\22\15"+ - "\6\0\45\15\1\u018c\1\15\6\0\40\15\1\u018d\6\15"+ - "\6\0\31\15\1\u018e\15\15\6\0\7\15\1\u018f\37\15"+ - "\6\0\23\54\1\u0190\23\54\6\0\25\15\1\u0191\21\15"+ - "\6\0\24\15\1\u0192\22\15\6\0\25\15\1\u0193\21\15"+ - "\6\0\34\15\1\u0194\12\15\6\0\32\15\1\u0195\14\15"+ - "\6\0\33\15\1\u0196\1\u0197\12\15\6\0\24\15\1\u0198"+ - "\22\15\6\0\7\15\1\u0199\37\15\6\0\32\15\1\u019a"+ - "\14\15\6\0\35\15\1\u019b\11\15\6\0\16\15\1\u019c"+ - "\30\15\6\0\34\15\1\u019d\12\15\6\0\41\15\1\u019e"+ - "\5\15\6\0\23\15\1\u019f\23\15\6\0\41\15\1\u01a0"+ - "\5\15\6\0\41\15\1\u01a1\5\15\6\0\17\15\1\u01a2"+ - "\27\15\6\0\25\15\1\u01a3\21\15\6\0\32\15\1\u01a4"+ - "\14\15\6\0\23\15\1\u01a5\23\15\6\0\16\15\1\u01a6"+ - "\30\15\6\0\32\15\1\u01a7\14\15\6\0\26\15\1\u01a8"+ - "\20\15\6\0\21\15\1\u01a9\25\15\6\0\25\15\1\u01aa"+ - "\21\15\6\0\17\15\1\u01ab\27\15\6\0\7\15\1\u01ac"+ - "\37\15\6\0\21\15\1\u01ad\25\15\6\0\23\15\1\u01ae"+ - "\23\15\6\0\16\15\1\u01af\30\15\6\0\25\15\1\u01b0"+ - "\21\15\6\0\40\15\1\u01b1\6\15\6\0\7\15\1\u01b2"+ - "\37\15\6\0\27\15\1\u01b3\17\15\6\0\26\15\1\u01b4"+ - "\20\15\6\0\24\15\1\u01b5\22\15\6\0\22\15\1\u01b6"+ - "\24\15\6\0\32\15\1\u01b7\14\15\6\0\32\15\1\u01b8"+ - "\14\15\6\0\26\15\1\u01b9\11\15\1\u01ba\6\15\6\0"+ - "\16\15\1\u01bb\30\15\6\0\30\15\1\u01bc\16\15\6\0"+ - "\27\15\1\u01bd\17\15\6\0\16\15\1\u01be\15\15\1\u01bf"+ - "\12\15\6\0\25\15\1\u01c0\21\15\6\0\31\15\1\u01c1"+ - "\15\15\6\0\7\15\1\u01c2\37\15\6\0\27\15\1\u01c3"+ - "\17\15\6\0\25\15\1\u01c4\21\15\6\0\17\15\1\u01c5"+ - "\27\15\6\0\16\15\1\u01c6\30\15\6\0\32\15\1\u01c7"+ - "\14\15\6\0\25\15\1\u01c8\21\15\6\0\16\15\1\u01c9"+ - "\30\15\6\0\34\15\1\u01ca\12\15\6\0\16\15\1\u01cb"+ - "\30\15\6\0\25\15\1\u01cc\21\15\6\0\7\15\1\u01cd"+ - "\37\15\6\0\41\15\1\u01ce\5\15\6\0\17\15\1\u01cf"+ - "\27\15\6\0\27\15\1\u01d0\17\15\6\0\34\15\1\u01d1"+ - "\12\15\6\0\46\15\1\u01d2\6\0\31\15\1\u01d3\15\15"+ - "\6\0\27\15\1\u01d4\17\15\6\0\24\15\1\u01d5\22\15"+ - "\6\0\33\15\1\u01d6\13\15\6\0\7\15\1\u01d7\37\15"+ - "\6\0\16\15\1\u01d8\30\15\6\0\25\15\1\u01d9\21\15"+ - "\6\0\32\15\1\u01da\14\15\6\0\26\15\1\u01db\20\15"+ - "\6\0\23\15\1\u01dc\23\15\6\0\23\15\1\u01dd\23\15"+ - "\6\0\21\15\1\u01de\25\15\6\0\25\15\1\u01df\21\15"+ - "\6\0\16\15\1\u01e0\30\15\6\0\33\15\1\u01e1\13\15"+ - "\6\0\16\15\1\u01e2\30\15\6\0\7\15\1\u01e3\37\15"+ - "\6\0\36\15\1\u01e4\10\15\6\0\20\15\1\u01e5\26\15"+ - "\6\0\40\15\1\u01e6\6\15\6\0\25\15\1\u01e7\21\15"+ - "\6\0\32\15\1\u01e8\14\15\6\0\16\15\1\u01e9\30\15"+ - "\6\0\22\15\1\u01ea\24\15\6\0\16\15\1\u01eb\30\15"+ - "\6\0\32\15\1\u01ec\14\15\6\0\27\15\1\u01ed\17\15"+ - "\6\0\31\15\1\u01ee\15\15\6\0\36\15\1\u01ef\10\15"+ - "\6\0\16\15\1\u01be\30\15\6\0\27\15\1\u01f0\17\15"+ - "\6\0\23\15\1\u01f1\23\15\6\0\35\15\1\u01f2\11\15"+ - "\6\0\30\15\1\u01f3\16\15\6\0\41\15\1\u01f4\5\15"+ - "\6\0\36\15\1\u01f5\10\15\6\0\34\15\1\u01f6\12\15"+ - "\6\0\25\15\1\u01f7\21\15\6\0\16\15\1\u01f8\30\15"+ - "\6\0\16\15\1\u01f9\30\15\6\0\16\15\1\u01fa\30\15"+ - "\6\0\33\15\1\u01fb\13\15\6\0\21\15\1\u01fc\25\15"+ - "\6\0\33\15\1\u01fd\13\15\6\0\16\15\1\u01fe\30\15"+ - "\6\0\24\15\1\u01ff\22\15\6\0\23\15\1\u0200\23\15"+ - "\6\0\43\15\1\u0201\3\15\6\0\23\15\1\u0202\23\15"+ - "\6\0\16\15\1\u0203\30\15\6\0\33\15\1\u0204\13\15"+ - "\6\0\34\15\1\u0205\12\15\6\0\25\15\1\u0206\21\15"+ - "\6\0\16\15\1\u0207\30\15\6\0\17\15\1\u0208\27\15"+ - "\6\0\42\15\1\u0209\4\15\6\0\21\15\1\u020a\25\15"+ - "\6\0\22\15\1\u020b\24\15\6\0\36\15\1\u020c\10\15"+ - "\6\0\22\15\1\u020d\24\15\6\0\16\15\1\u020e\30\15"+ - "\6\0\34\15\1\u020f\12\15\6\0\16\15\1\u0210\30\15"+ - "\6\0\7\15\1\u0211\37\15\6\0\32\15\1\u0212\14\15"+ - "\6\0\16\15\1\u0213\30\15\6\0\25\15\1\u0214\21\15"+ - "\6\0\17\15\1\u0215\27\15\6\0\37\15\1\u0216\7\15"+ - "\6\0\7\15\1\u0217\37\15\6\0\22\15\1\u0218\24\15"+ - "\6\0\16\15\1\u0219\30\15\6\0\27\15\1\u021a\17\15"+ - "\6\0\16\15\1\u021b\30\15\6\0\23\15\1\u021c\23\15"+ - "\6\0\21\15\1\u021d\25\15\6\0\17\15\1\u021e\27\15"+ - "\6\0\33\15\1\u021f\13\15\6\0\21\15\1\u0220\25\15"+ - "\6\0\7\15\1\u0221\37\15\6\0\34\15\1\u0222\12\15"+ - "\6\0\21\15\1\u0223\25\15\6\0\24\15\1\u0224\22\15"+ - "\6\0\22\15\1\u0225\24\15\6\0\16\15\1\u0226\30\15"+ - "\6\0\16\15\1\u0227\30\15\6\0\16\15\1\u0228\30\15"+ - "\6\0\17\15\1\u0229\27\15\6\0\7\15\1\u022a\37\15"+ - "\6\0\21\15\1\u022b\25\15\6\0\36\15\1\u022c\10\15"+ - "\6\0\24\15\1\u022d\22\15\6\0\7\15\1\u022e\37\15"+ - "\6\0\24\15\1\u022f\22\15\6\0\31\15\1\u0230\15\15"+ - "\6\0\17\15\1\u0231\27\15\6\0\33\15\1\u0232\13\15"+ - "\6\0\25\15\1\u0233\21\15\6\0\33\15\1\u0234\13\15"+ - "\6\0\7\15\1\u0235\37\15\6\0\25\15\1\u0236\21\15"+ - "\6\0\36\15\1\u0237\10\15\6\0\32\15\1\u0238\14\15"+ - "\6\0\34\15\1\u0239\12\15\6\0\7\15\1\u023a\37\15"+ - "\6\0\16\15\1\u023b\30\15\6\0\27\15\1\u023c\17\15"+ - "\6\0\23\15\1\u023d\23\15\6\0\22\15\1\u023e\24\15"+ - "\6\0\22\15\1\u023f\24\15\6\0\21\15\1\u0240\25\15"+ - "\6\0\16\15\1\u0241\30\15\6\0\7\15\1\u0242\37\15"+ - "\6\0\33\15\1\u0243\13\15\6\0\25\15\1\u0244\21\15"+ - "\6\0\36\15\1\u0245\10\15\6\0\34\15\1\u0246\12\15"+ - "\6\0\26\15\1\u0247\20\15\6\0\21\15\1\u0248\25\15"+ - "\6\0\25\15\1\u0249\21\15\6\0\20\15\1\u024a\26\15"+ - "\6\0\25\15\1\u024b\21\15\6\0\34\15\1\u024c\12\15"+ - "\6\0\34\15\1\u024d\12\15\6\0\17\15\1\u024e\27\15"+ - "\6\0\34\15\1\u024f\12\15\6\0\22\15\1\u0250\24\15"+ - "\6\0\26\15\1\u0251\20\15\6\0\27\15\1\u0252\17\15"+ - "\6\0\21\15\1\u0253\25\15\6\0\36\15\1\u0254\10\15"+ - "\6\0\22\15\1\u0255\24\15\6\0\24\15\1\u0256\22\15"+ - "\6\0\23\15\1\u0257\23\15\6\0\16\15\1\u0258\30\15"+ - "\6\0\35\15\1\u0259\11\15\6\0\32\15\1\u025a\14\15"+ - "\6\0\7\15\1\u025b\37\15\6\0\16\15\1\u025c\30\15"+ - "\6\0\25\15\1\u025d\21\15\6\0\23\15\1\u025e\23\15"+ - "\6\0\41\15\1\u025f\5\15\6\0\16\15\1\u0260\30\15"+ - "\6\0\41\15\1\u0261\5\15\6\0\25\15\1\u0262\21\15"+ - "\6\0\22\15\1\u0263\24\15\6\0\24\15\1\u0264\22\15"+ - "\6\0\22\15\1\u0265\24\15\6\0\34\15\1\u0266\12\15"+ - "\6\0\25\15\1\u0267\21\15\6\0\16\15\1\u0268\30\15"+ - "\6\0\32\15\1\u0269\14\15\6\0\25\15\1\u026a\21\15"+ - "\6\0\24\15\1\u026b\22\15\6\0\25\15\1\u026c\21\15"+ - "\6\0\16\15\1\u026d\30\15\6\0\22\15\1\u026e\24\15"+ - "\6\0\26\15\1\u026f\20\15\6\0\7\15\1\u0270\37\15"+ - "\6\0\17\15\1\u0271\27\15\6\0\7\15\1\u0272\37\15"+ - "\6\0\16\15\1\u0273\30\15\6\0\37\15\1\u0274\7\15"+ - "\6\0\23\15\1\u0275\23\15\6\0\25\15\1\u0276\21\15"+ - "\6\0\21\15\1\u0277\25\15\6\0\16\15\1\u0278\30\15"+ - "\6\0\31\15\1\u0279\15\15\6\0\25\15\1\u027a\21\15"+ - "\6\0\25\15\1\u027b\21\15\6\0\34\15\1\u027c\12\15"+ - "\6\0\22\15\1\u027d\24\15\6\0\42\15\1\u027e\4\15"+ - "\6\0\21\15\1\u027f\25\15\6\0\35\15\1\u0280\11\15"+ - "\6\0\25\15\1\u0281\21\15\6\0\26\15\1\u0282\20\15"+ - "\6\0\34\15\1\u0283\12\15\6\0\27\15\1\u0284\17\15"+ - "\6\0\27\15\1\u0285\17\15\6\0\16\15\1\u0286\15\15"+ - "\1\u0287\12\15\6\0\21\15\1\u0288\25\15\6\0\17\15"+ - "\1\u0289\27\15\6\0\21\15\1\u028a\25\15\6\0\34\15"+ - "\1\u028b\12\15\6\0\21\15\1\u028c\25\15\6\0\25\15"+ - "\1\u028d\21\15\6\0\16\15\1\u028e\30\15\6\0\22\15"+ - "\1\u028f\24\15\6\0\32\15\1\u0290\14\15\6\0\36\15"+ - "\1\u0291\10\15\6\0\16\15\1\u0286\30\15\6\0\25\15"+ - "\1\u0292\21\15\6\0\33\15\1\u0293\13\15\6\0\16\15"+ - "\1\u0294\30\15\6\0\27\15\1\u0295\17\15\6\0\16\15"+ - "\1\u0296\30\15\6\0\32\15\1\u0297\14\15\6\0\31\15"+ - "\1\u0298\15\15\6\0\7\15\1\u0299\37\15\6\0\21\15"+ - "\1\u029a\25\15\6\0\33\15\1\u029b\13\15\6\0\16\15"+ - "\1\u029c\30\15\6\0\22\15\1\u029d\24\15\6\0\21\15"+ - "\1\u029e\25\15\6\0\36\15\1\u029f\10\15\6\0\27\15"+ - "\1\u02a0\17\15\6\0\34\15\1\u02a1\12\15\6\0\32\15"+ - "\1\u02a2\14\15\6\0\27\15\1\u02a3\17\15\6\0\32\15"+ - "\1\u02a4\14\15\6\0\22\15\1\u02a5\24\15\6\0\7\15"+ - "\1\u02a6\37\15\6\0\34\15\1\u02a7\12\15\6\0\31\15"+ - "\1\u02a8\15\15\6\0\24\15\1\u02a9\22\15\6\0\25\15"+ - "\1\u02aa\21\15\6\0\16\15\1\u02ab\30\15\6\0\25\15"+ - "\1\u02ac\21\15\6\0\34\15\1\u02ad\12\15\6\0\26\15"+ - "\1\u02ae\20\15\6\0\16\15\1\u02af\30\15\6\0\17\15"+ - "\1\u02b0\27\15\6\0\25\15\1\u02b1\21\15\6\0\26\15"+ - "\1\u02b2\20\15\6\0\27\15\1\u02b3\17\15\6\0\16\15"+ - "\1\u02b4\30\15\6\0\22\15\1\u02b5\24\15\6\0\7\15"+ - "\1\u02b6\37\15\6\0\32\15\1\u02b7\14\15\6\0\26\15"+ - "\1\u02b8\20\15\6\0\7\15\1\u02b9\37\15\6\0\22\15"+ - "\1\u02ba\24\15\6\0\25\15\1\u02bb\21\15\6\0\21\15"+ - "\1\u02bc\25\15\6\0\34\15\1\u02bd\12\15\6\0\25\15"+ - "\1\u02be\21\15\6\0\17\15\1\u02bf\27\15\6\0\21\15"+ - "\1\u02c0\25\15\6\0\26\15\1\u02c1\20\15\6\0\16\15"+ - "\1\u02c2\30\15\6\0\7\15\1\u02c3\37\15\6\0\26\15"+ - "\1\u02c4\20\15\6\0\22\15\1\u02c5\24\15\6\0\21\15"+ - "\1\u02c6\25\15\6\0\25\15\1\u02c7\21\15\6\0\21\15"+ - "\1\u02c8\25\15\2\0"; - - private static int [] zzUnpackTrans() { - int [] result = new int[27450]; - int offset = 0; - offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackTrans(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - value--; - do result[j++] = value; while (--count > 0); + private static int[] zzUnpackAction() { + int[] result = new int[712]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; } - return j; - } - - - /* error codes */ - private static final int ZZ_UNKNOWN_ERROR = 0; - private static final int ZZ_NO_MATCH = 1; - private static final int ZZ_PUSHBACK_2BIG = 2; - /* error messages for the codes above */ - private static final String ZZ_ERROR_MSG[] = { - "Unkown internal scanner error", - "Error: could not match input", - "Error: pushback value was too large" - }; - - /** - * ZZ_ATTRIBUTE[aState] contains the attributes of state aState - */ - private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); - - private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\7\0\1\1\1\11\1\1\1\11\4\1\2\11\24\1"+ - "\2\11\1\1\2\11\2\1\2\11\3\1\1\11\1\1"+ - "\3\0\67\1\1\0\3\1\1\0\1\11\105\1\1\0"+ - "\u020f\1"; - - private static int [] zzUnpackAttribute() { - int [] result = new int[712]; - int offset = 0; - offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAttribute(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); + private static int zzUnpackAction(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; } - return j; - } - - /** the input device */ - private java.io.Reader zzReader; - - /** the current state of the DFA */ - private int zzState; - - /** the current lexical state */ - private int zzLexicalState = YYINITIAL; - - /** this buffer contains the current text to be matched and is - the source of the yytext() string */ - private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; - /** the textposition at the last accepting state */ - private int zzMarkedPos; - - /** the textposition at the last state to be included in yytext */ - private int zzPushbackPos; - - /** the current text position in the buffer */ - private int zzCurrentPos; - - /** startRead marks the beginning of the yytext() string in the buffer */ - private int zzStartRead; - - /** endRead marks the last character in the buffer, that has been read - from input */ - private int zzEndRead; - - /** number of newlines encountered up to the start of the matched text */ - private int yyline; - - /** the number of characters up to the start of the matched text */ - private int yychar; - - /** - * the number of characters from the last newline up to the start of the - * matched text - */ - private int yycolumn; - - /** - * zzAtBOL == true <=> the scanner is currently at the beginning of a line - */ - private boolean zzAtBOL = true; + private static int[] zzUnpackRowMap() { + int[] result = new int[712]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } - /** zzAtEOF == true <=> the scanner is at the EOF */ - private boolean zzAtEOF; + private static int zzUnpackRowMap(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } - /* user code: */ - StringBuffer string = new StringBuffer(); + private static int[] zzUnpackTrans() { + int[] result = new int[27450]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + private static int zzUnpackTrans(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } - /** - * Creates a new scanner - * There is also a java.io.InputStream version of this constructor. - * - * @param in the java.io.Reader to read input from. - */ - SpecctraFileScanner(java.io.Reader in) { - this.zzReader = in; - } + private static int[] zzUnpackAttribute() { + int[] result = new int[712]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } - /** - * Creates a new scanner. - * There is also java.io.Reader version of this constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - SpecctraFileScanner(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } + private static int zzUnpackAttribute(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table - */ - private static char [] zzUnpackCMap(String packed) { - char [] map = new char[0x10000]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 274) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do map[j++] = value; while (--count > 0); + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char[] zzUnpackCMap(String packed) { + char[] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 274) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; } - return map; - } - /** - * Refills the input buffer. - * - * @return false, iff there was new input. - * - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean zzRefill() throws java.io.IOException { + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * @throws java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { /* first: make room (if you can) */ - if (zzStartRead > 0) { - System.arraycopy(zzBuffer, zzStartRead, - zzBuffer, 0, - zzEndRead-zzStartRead); + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead - zzStartRead); /* translate stored positions */ - zzEndRead-= zzStartRead; - zzCurrentPos-= zzStartRead; - zzMarkedPos-= zzStartRead; - zzPushbackPos-= zzStartRead; - zzStartRead = 0; - } + zzEndRead -= zzStartRead; + zzCurrentPos -= zzStartRead; + zzMarkedPos -= zzStartRead; + zzPushbackPos -= zzStartRead; + zzStartRead = 0; + } /* is the buffer big enough? */ - if (zzCurrentPos >= zzBuffer.length) { + if (zzCurrentPos >= zzBuffer.length) { /* if not: blow it up */ - char newBuffer[] = new char[zzCurrentPos*2]; - System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); - zzBuffer = newBuffer; - } + char newBuffer[] = new char[zzCurrentPos * 2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } /* finally: fill the buffer with new input */ - int numRead = zzReader.read(zzBuffer, zzEndRead, - zzBuffer.length-zzEndRead); - - if (numRead < 0) { - return true; - } - else { - zzEndRead+= numRead; - return false; + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length - zzEndRead); + + if (numRead < 0) { + return true; + } else { + zzEndRead += numRead; + return false; + } } - } - - - /** - * Closes the input stream. - */ - public final void yyclose() throws java.io.IOException { - zzAtEOF = true; /* indicate end of file */ - zzEndRead = zzStartRead; /* invalidate buffer */ - - if (zzReader != null) - zzReader.close(); - } - /** - * Resets the scanner to read from a new input stream. - * Does not close the old reader. - * - * All internal variables are reset, the old input stream - * cannot be reused (internal buffer is discarded and lost). - * Lexical state is set to ZZ_INITIAL. - * - * @param reader the new input stream - */ - public final void yyreset(java.io.Reader reader) { - zzReader = reader; - zzAtBOL = true; - zzAtEOF = false; - zzEndRead = zzStartRead = 0; - zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; - yyline = yychar = yycolumn = 0; - zzLexicalState = YYINITIAL; - } + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ - - /** - * Returns the current lexical state. - */ - public final int yystate() { - return zzLexicalState; - } - - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - public final void yybegin(int newState) { - zzLexicalState = newState; - } + if (zzReader != null) + zzReader.close(); + } - /** - * Returns the text matched by the current regular expression. - */ - public final String yytext() { - return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); - } + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + *

+ * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to ZZ_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + } - /** - * Returns the character at position pos from the - * matched text. - * - * It is equivalent to yytext().charAt(pos), but faster - * - * @param pos the position of the character to fetch. - * A value from 0 to yylength()-1. - * - * @return the character at position pos - */ - public final char yycharat(int pos) { - return zzBuffer[zzStartRead+pos]; - } + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } - /** - * Returns the length of the matched text region. - */ - public final int yylength() { - return zzMarkedPos-zzStartRead; - } + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } - /** - * Reports an error that occured while scanning. - * - * In a wellformed scanner (no or only correct usage of - * yypushback(int) and a match-all fallback rule) this method - * will only be called with things that "Can't Possibly Happen". - * If this method is called, something is seriously wrong - * (e.g. a JFlex bug producing a faulty scanner etc.). - * - * Usual syntax/scanner level error handling should be done - * in error fallback rules. - * - * @param errorCode the code of the errormessage to display - */ - private void zzScanError(int errorCode) { - String message; - try { - message = ZZ_ERROR_MSG[errorCode]; - } - catch (ArrayIndexOutOfBoundsException e) { - message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); } - throw new Error(message); - } + /** + * Returns the character at position pos from the + * matched text. + *

+ * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead + pos]; + } - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. - * This number must not be greater than yylength()! - */ - public void yypushback(int number) { - if ( number > yylength() ) - zzScanError(ZZ_PUSHBACK_2BIG); - zzMarkedPos -= number; - } + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos - zzStartRead; + } - /** - * Resumes scanning until the next regular expression is matched, - * the end of input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception java.io.IOException if any I/O-Error occurs - */ - public Object next_token() throws java.io.IOException { - int zzInput; - int zzAction; + /** + * Reports an error that occured while scanning. + *

+ * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + *

+ * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } - // cached fields: - int zzCurrentPosL; - int zzMarkedPosL; - int zzEndReadL = zzEndRead; - char [] zzBufferL = zzBuffer; - char [] zzCMapL = ZZ_CMAP; + throw new Error(message); + } - int [] zzTransL = ZZ_TRANS; - int [] zzRowMapL = ZZ_ROWMAP; - int [] zzAttrL = ZZ_ATTRIBUTE; - while (true) { - zzMarkedPosL = zzMarkedPos; + /** + * Pushes the specified amount of characters back into the input stream. + *

+ * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if (number > yylength()) + zzScanError(ZZ_PUSHBACK_2BIG); - zzAction = -1; + zzMarkedPos -= number; + } - zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; - - zzState = zzLexicalState; + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @throws java.io.IOException if any I/O-Error occurs + */ + public Object next_token() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char[] zzBufferL = zzBuffer; + char[] zzCMapL = ZZ_CMAP; + + int[] zzTransL = ZZ_TRANS; + int[] zzRowMapL = ZZ_ROWMAP; + int[] zzAttrL = ZZ_ATTRIBUTE; - zzForAction: { while (true) { - - if (zzCurrentPosL < zzEndReadL) - zzInput = zzBufferL[zzCurrentPosL++]; - else if (zzAtEOF) { - zzInput = YYEOF; - break zzForAction; - } - else { - // store back cached positions - zzCurrentPos = zzCurrentPosL; - zzMarkedPos = zzMarkedPosL; - boolean eof = zzRefill(); - // get translated positions and possibly new buffer - zzCurrentPosL = zzCurrentPos; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - zzEndReadL = zzEndRead; - if (eof) { - zzInput = YYEOF; - break zzForAction; - } - else { - zzInput = zzBufferL[zzCurrentPosL++]; + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = zzLexicalState; + + + zzForAction: + { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[zzRowMapL[zzState] + zzCMapL[zzInput]]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ((zzAttributes & 1) == 1) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ((zzAttributes & 8) == 8) break zzForAction; + } + + } } - } - int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; - if (zzNext == -1) break zzForAction; - zzState = zzNext; - - int zzAttributes = zzAttrL[zzState]; - if ( (zzAttributes & 1) == 1 ) { - zzAction = zzState; - zzMarkedPosL = zzCurrentPosL; - if ( (zzAttributes & 8) == 8 ) break zzForAction; - } + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 18: { + yybegin(NAME); + return Keyword.VIA; + } + case 121: + break; + case 24: { + return Keyword.BACK; + } + case 122: + break; + case 31: { + yybegin(LAYER_NAME); + return Keyword.POLYGON_PATH; + } + case 123: + break; + case 71: { + return Keyword.NETWORK_SCOPE; + } + case 124: + break; + case 56: { + return Keyword.ROUTES; + } + case 125: + break; + case 93: { + return Keyword.FLIP_STYLE; + } + case 126: + break; + case 108: { + return Keyword.PLACE_CONTROL; + } + case 127: + break; + case 32: { + yybegin(LAYER_NAME); + return Keyword.POLYGON; + } + case 128: + break; + case 78: { + yybegin(NAME); + return Keyword.PADSTACK; + } + case 129: + break; + case 110: { + yybegin(NAME); + return Keyword.CLEARANCE_CLASS; + } + case 130: + break; + case 115: { + return Keyword.AUTOROUTE_SETTINGS; + } + case 131: + break; + case 13: { + yybegin(YYINITIAL); + return Keyword.OPEN_BRACKET; + } + case 132: + break; + case 105: { + return Keyword.START_PASS_NO; + } + case 133: + break; + case 23: { + yybegin(YYINITIAL); + return Keyword.PCB_SCOPE; + } + case 134: + break; + case 34: { + yybegin(LAYER_NAME); + return Keyword.RECTANGLE; + } + case 135: + break; + case 82: { + return Keyword.STRUCTURE_SCOPE; + } + case 136: + break; + case 27: { + yybegin(NAME); + return Keyword.COMPONENT_SCOPE; + } + case 137: + break; + case 43: { + yybegin(NAME); + return Keyword.IMAGE; + } + case 138: + break; + case 112: { + return Keyword.FORTYFIVE_DEGREE; + } + case 139: + break; + case 60: { + return Keyword.WINDOW; + } + case 140: + break; + case 76: { + return Keyword.VERTICAL; + } + case 141: + break; + case 20: { + return Keyword.PCB_SCOPE; + } + case 142: + break; + case 37: { + return Keyword.SPARE; + } + case 143: + break; + case 21: { + return Keyword.PIN; + } + case 144: + break; + case 35: { + return Keyword.RULE; + } + case 145: + break; + case 29: { + return Keyword.VIAS; + } + case 146: + break; + case 16: { + return Keyword.ON; + } + case 147: + break; + case 63: { + return Keyword.SESSION; + } + case 148: + break; + case 74: { + return Keyword.BOUNDARY; + } + case 149: + break; + case 88: { + return Keyword.SNAP_ANGLE; + } + case 150: + break; + case 113: { + return Keyword.WRITE_RESOLUTION; + } + case 151: + break; + case 54: { + return Keyword.NORMAL; + } + case 152: + break; + case 8: { + return Keyword.OPEN_BRACKET; + } + case 153: + break; + case 22: { + return Keyword.FIX; + } + case 154: + break; + case 89: { + yybegin(NAME); + return Keyword.LAYER_RULE; + } + case 155: + break; + case 86: { + return Keyword.POSTROUTE; + } + case 156: + break; + case 14: { + yybegin(YYINITIAL); + return Keyword.CLOSED_BRACKET; + } + case 157: + break; + case 9: { + return Keyword.CLOSED_BRACKET; + } + case 158: + break; + case 90: { + return Keyword.VIA_AT_SMD; + } + case 159: + break; + case 28: { + yybegin(LAYER_NAME); + return Keyword.CIRCLE; + } + case 160: + break; + case 50: { + return Keyword.ATTACH; + } + case 161: + break; + case 92: { + return Keyword.RESOLUTION_SCOPE; + } + case 162: + break; + case 77: { + return Keyword.VIA_RULE; + } + case 163: + break; + case 70: { + return Keyword.CIRCUIT; + } + case 164: + break; + case 87: { + return Keyword.PLACEMENT_SCOPE; + } + case 165: + break; + case 36: { + yybegin(NAME); + return Keyword.WIRE; + } + case 166: + break; + case 116: { + return Keyword.PREFERRED_DIRECTION; + } + case 167: + break; + case 40: { + yybegin(NAME); + return Keyword.LAYER; + } + case 168: + break; + case 69: { + return Keyword.CLASSES; + } + case 169: + break; + case 61: { + return Keyword.WIRING_SCOPE; + } + case 170: + break; + case 103: { + yybegin(NAME); + return Keyword.HOST_VERSION; + } + case 171: + break; + case 4: { + return yytext(); + } + case 172: + break; + case 73: { + return Keyword.ABSOLUTE; + } + case 173: + break; + case 58: { + return Keyword.FANOUT; + } + case 174: + break; + case 79: { + return Keyword.POSITION; + } + case 175: + break; + case 47: { + return Keyword.RULES; + } + case 176: + break; + case 57: { + return Keyword.ROTATE; + } + case 177: + break; + case 7: { + string.setLength(0); + yybegin(STRING2); + } + case 178: + break; + case 84: { + yybegin(NAME); + return Keyword.USE_LAYER; + } + case 179: + break; + case 80: { + yybegin(NAME); + return Keyword.HOST_CAD; + } + case 180: + break; + case 64: { + return Keyword.OUTLINE; + } + case 181: + break; + case 45: { + yybegin(NAME); + return Keyword.PLACE; + } + case 182: + break; + case 6: { + string.setLength(0); + yybegin(STRING1); + } + case 183: + break; + case 99: { + yybegin(IGNORE_QUOTE); + return Keyword.STRING_QUOTE; + } + case 184: + break; + case 39: { + return Keyword.ORDER; + } + case 185: + break; + case 17: { + return Keyword.OFF; + } + case 186: + break; + case 81: { + return Keyword.AUTOROUTE; + } + case 187: + break; + case 52: { + return Keyword.SIGNAL; + } + case 188: + break; + case 107: { + yybegin(LAYER_NAME); + return Keyword.POLYLINE_PATH; + } + case 189: + break; + case 68: { + return Keyword.CONTROL; + } + case 190: + break; + case 46: { + yybegin(NAME); + return Keyword.PLANE_SCOPE; + } + case 191: + break; + case 1: { + yybegin(YYINITIAL); + return yytext(); + } + case 192: + break; + case 100: { + yybegin(NAME); + return Keyword.LOGICAL_PART; + } + case 193: + break; + case 83: { + return Keyword.LOCK_TYPE; + } + case 194: + break; + case 109: { + yybegin(NAME); + return Keyword.PLACE_KEEPOUT; + } + case 195: + break; + case 49: { + return Keyword.WIDTH; + } + case 196: + break; + case 106: { + return Keyword.NINETY_DEGREE; + } + case 197: + break; + case 67: { + yybegin(NAME); + return Keyword.USE_NET; + } + case 198: + break; + case 118: { + return Keyword.GENERATED_BY_FREEROUTE; + } + case 199: + break; + case 101: { + return Keyword.PART_LIBRARY_SCOPE; + } + case 200: + break; + case 85: { + return Keyword.VIA_COSTS; + } + case 201: + break; + case 102: { + return Keyword.ROTATE_FIRST; + } + case 202: + break; + case 75: { + return Keyword.CONSTANT; + } + case 203: + break; + case 12: { + string.append('\\'); + } + case 204: + break; + case 15: { + return new Double(yytext()); + } + case 205: + break; + case 42: { + yybegin(NAME); + return Keyword.CLASS; + } + case 206: + break; + case 91: { + return Keyword.PULL_TIGHT; + } + case 207: + break; + case 30: { + return Keyword.NONE; + } + case 208: + break; + case 120: { + return Keyword.AGAINST_PREFERRED_DIRECTION_TRACE_COSTS; + } + case 209: + break; + case 114: { + return Keyword.START_RIPUP_COSTS; + } + case 210: + break; + case 53: { + return Keyword.LENGTH; + } + case 211: + break; + case 38: { + return Keyword.SHAPE; + } + case 212: + break; + case 59: { + return Keyword.FROMTO; + } + case 213: + break; + case 44: { + return Keyword.POWER; + } + case 214: + break; + case 94: { + return Keyword.HORIZONTAL; + } + case 215: + break; + case 26: { + return Keyword.TYPE; + } + case 216: + break; + case 51: { + return Keyword.ACTIVE; + } + case 217: + break; + case 48: { + return Keyword.FRONT; + } + case 218: + break; + case 11: { + yybegin(YYINITIAL); + return string.toString(); + } + case 219: + break; + case 19: { + yybegin(NAME); + return Keyword.NET; + } + case 220: + break; + case 96: { + return Keyword.CLASS_CLASS; + } + case 221: + break; + case 66: { + yybegin(NAME); + return Keyword.USE_VIA; + } + case 222: + break; + case 65: { + return Keyword.LIBRARY_SCOPE; + } + case 223: + break; + case 3: { /* ignore */ + } + case 224: + break; + case 117: { + yybegin(NAME); + return Keyword.LOGICAL_PART_MAPPING; + } + case 225: + break; + case 111: { + return Keyword.PLANE_VIA_COSTS; + } + case 226: + break; + case 72: { + yybegin(NAME); + return Keyword.KEEPOUT; + } + case 227: + break; + case 98: { + return Keyword.NETWORK_OUT; + } + case 228: + break; + case 55: { + return Keyword.PARSER_SCOPE; + } + case 229: + break; + case 10: { + string.append(yytext()); + } + case 230: + break; + case 2: { + throw new Error("Illegal character <" + + yytext() + ">"); + } + case 231: + break; + case 95: { + return Keyword.SHOVE_FIXED; + } + case 232: + break; + case 104: { + return Keyword.KEEPOUT; + } + case 233: + break; + case 33: { + return Keyword.PINS; + } + case 234: + break; + case 119: { + return Keyword.PREFERRED_DIRECTION_TRACE_COSTS; + } + case 235: + break; + case 5: { + return new Integer(yytext()); + } + case 236: + break; + case 25: { + return Keyword.SIDE; + } + case 237: + break; + case 41: { + return Keyword.CLEARANCE; + } + case 238: + break; + case 97: { + yybegin(NAME); + return Keyword.VIA_KEEPOUT; + } + case 239: + break; + case 62: { + yybegin(YYINITIAL); + return Keyword.SIGNAL; + } + case 240: + break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + return null; + } else { + zzScanError(ZZ_NO_MATCH); + } + } } - } - - // store back cached position - zzMarkedPos = zzMarkedPosL; - - switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 18: - { yybegin(NAME); return Keyword.VIA; - } - case 121: break; - case 24: - { return Keyword.BACK; - } - case 122: break; - case 31: - { yybegin(LAYER_NAME); return Keyword.POLYGON_PATH; - } - case 123: break; - case 71: - { return Keyword.NETWORK_SCOPE; - } - case 124: break; - case 56: - { return Keyword.ROUTES; - } - case 125: break; - case 93: - { return Keyword.FLIP_STYLE; - } - case 126: break; - case 108: - { return Keyword.PLACE_CONTROL; - } - case 127: break; - case 32: - { yybegin(LAYER_NAME); return Keyword.POLYGON; - } - case 128: break; - case 78: - { yybegin(NAME); return Keyword.PADSTACK; - } - case 129: break; - case 110: - { yybegin(NAME); return Keyword.CLEARANCE_CLASS; - } - case 130: break; - case 115: - { return Keyword.AUTOROUTE_SETTINGS; - } - case 131: break; - case 13: - { yybegin(YYINITIAL); return Keyword.OPEN_BRACKET; - } - case 132: break; - case 105: - { return Keyword.START_PASS_NO; - } - case 133: break; - case 23: - { yybegin(YYINITIAL); return Keyword.PCB_SCOPE; - } - case 134: break; - case 34: - { yybegin(LAYER_NAME); return Keyword.RECTANGLE; - } - case 135: break; - case 82: - { return Keyword.STRUCTURE_SCOPE; - } - case 136: break; - case 27: - { yybegin(NAME); return Keyword.COMPONENT_SCOPE; - } - case 137: break; - case 43: - { yybegin(NAME); return Keyword.IMAGE; - } - case 138: break; - case 112: - { return Keyword.FORTYFIVE_DEGREE; - } - case 139: break; - case 60: - { return Keyword.WINDOW; - } - case 140: break; - case 76: - { return Keyword.VERTICAL; - } - case 141: break; - case 20: - { return Keyword.PCB_SCOPE; - } - case 142: break; - case 37: - { return Keyword.SPARE; - } - case 143: break; - case 21: - { return Keyword.PIN; - } - case 144: break; - case 35: - { return Keyword.RULE; - } - case 145: break; - case 29: - { return Keyword.VIAS; - } - case 146: break; - case 16: - { return Keyword.ON; - } - case 147: break; - case 63: - { return Keyword.SESSION; - } - case 148: break; - case 74: - { return Keyword.BOUNDARY; - } - case 149: break; - case 88: - { return Keyword.SNAP_ANGLE; - } - case 150: break; - case 113: - { return Keyword.WRITE_RESOLUTION; - } - case 151: break; - case 54: - { return Keyword.NORMAL; - } - case 152: break; - case 8: - { return Keyword.OPEN_BRACKET; - } - case 153: break; - case 22: - { return Keyword.FIX; - } - case 154: break; - case 89: - { yybegin(NAME); return Keyword.LAYER_RULE; - } - case 155: break; - case 86: - { return Keyword.POSTROUTE; - } - case 156: break; - case 14: - { yybegin(YYINITIAL); return Keyword.CLOSED_BRACKET; - } - case 157: break; - case 9: - { return Keyword.CLOSED_BRACKET; - } - case 158: break; - case 90: - { return Keyword.VIA_AT_SMD; - } - case 159: break; - case 28: - { yybegin(LAYER_NAME); return Keyword.CIRCLE; - } - case 160: break; - case 50: - { return Keyword.ATTACH; - } - case 161: break; - case 92: - { return Keyword.RESOLUTION_SCOPE; - } - case 162: break; - case 77: - { return Keyword.VIA_RULE; - } - case 163: break; - case 70: - { return Keyword.CIRCUIT; - } - case 164: break; - case 87: - { return Keyword.PLACEMENT_SCOPE; - } - case 165: break; - case 36: - { yybegin(NAME); return Keyword.WIRE; - } - case 166: break; - case 116: - { return Keyword.PREFERRED_DIRECTION; - } - case 167: break; - case 40: - { yybegin(NAME); return Keyword.LAYER; - } - case 168: break; - case 69: - { return Keyword.CLASSES; - } - case 169: break; - case 61: - { return Keyword.WIRING_SCOPE; - } - case 170: break; - case 103: - { yybegin(NAME); return Keyword.HOST_VERSION; - } - case 171: break; - case 4: - { return yytext(); - } - case 172: break; - case 73: - { return Keyword.ABSOLUTE; - } - case 173: break; - case 58: - { return Keyword.FANOUT; - } - case 174: break; - case 79: - { return Keyword.POSITION; - } - case 175: break; - case 47: - { return Keyword.RULES; - } - case 176: break; - case 57: - { return Keyword.ROTATE; - } - case 177: break; - case 7: - { string.setLength(0); yybegin(STRING2); - } - case 178: break; - case 84: - { yybegin(NAME); return Keyword.USE_LAYER; - } - case 179: break; - case 80: - { yybegin(NAME); return Keyword.HOST_CAD; - } - case 180: break; - case 64: - { return Keyword.OUTLINE; - } - case 181: break; - case 45: - { yybegin(NAME); return Keyword.PLACE; - } - case 182: break; - case 6: - { string.setLength(0); yybegin(STRING1); - } - case 183: break; - case 99: - { yybegin(IGNORE_QUOTE); return Keyword.STRING_QUOTE; - } - case 184: break; - case 39: - { return Keyword.ORDER; - } - case 185: break; - case 17: - { return Keyword.OFF; - } - case 186: break; - case 81: - { return Keyword.AUTOROUTE; - } - case 187: break; - case 52: - { return Keyword.SIGNAL; - } - case 188: break; - case 107: - { yybegin(LAYER_NAME); return Keyword.POLYLINE_PATH; - } - case 189: break; - case 68: - { return Keyword.CONTROL; - } - case 190: break; - case 46: - { yybegin(NAME); return Keyword.PLANE_SCOPE; - } - case 191: break; - case 1: - { yybegin(YYINITIAL); return yytext(); - } - case 192: break; - case 100: - { yybegin(NAME); return Keyword.LOGICAL_PART; - } - case 193: break; - case 83: - { return Keyword.LOCK_TYPE; - } - case 194: break; - case 109: - { yybegin(NAME); return Keyword.PLACE_KEEPOUT; - } - case 195: break; - case 49: - { return Keyword.WIDTH; - } - case 196: break; - case 106: - { return Keyword.NINETY_DEGREE; - } - case 197: break; - case 67: - { yybegin(NAME); return Keyword.USE_NET; - } - case 198: break; - case 118: - { return Keyword.GENERATED_BY_FREEROUTE; - } - case 199: break; - case 101: - { return Keyword.PART_LIBRARY_SCOPE; - } - case 200: break; - case 85: - { return Keyword.VIA_COSTS; - } - case 201: break; - case 102: - { return Keyword.ROTATE_FIRST; - } - case 202: break; - case 75: - { return Keyword.CONSTANT; - } - case 203: break; - case 12: - { string.append('\\'); - } - case 204: break; - case 15: - { return new Double(yytext()); - } - case 205: break; - case 42: - { yybegin(NAME); return Keyword.CLASS; - } - case 206: break; - case 91: - { return Keyword.PULL_TIGHT; - } - case 207: break; - case 30: - { return Keyword.NONE; - } - case 208: break; - case 120: - { return Keyword.AGAINST_PREFERRED_DIRECTION_TRACE_COSTS; - } - case 209: break; - case 114: - { return Keyword.START_RIPUP_COSTS; - } - case 210: break; - case 53: - { return Keyword.LENGTH; - } - case 211: break; - case 38: - { return Keyword.SHAPE; - } - case 212: break; - case 59: - { return Keyword.FROMTO; - } - case 213: break; - case 44: - { return Keyword.POWER; - } - case 214: break; - case 94: - { return Keyword.HORIZONTAL; - } - case 215: break; - case 26: - { return Keyword.TYPE; - } - case 216: break; - case 51: - { return Keyword.ACTIVE; - } - case 217: break; - case 48: - { return Keyword.FRONT; - } - case 218: break; - case 11: - { yybegin(YYINITIAL); return string.toString(); - } - case 219: break; - case 19: - { yybegin(NAME); return Keyword.NET; - } - case 220: break; - case 96: - { return Keyword.CLASS_CLASS; - } - case 221: break; - case 66: - { yybegin(NAME); return Keyword.USE_VIA; - } - case 222: break; - case 65: - { return Keyword.LIBRARY_SCOPE; - } - case 223: break; - case 3: - { /* ignore */ - } - case 224: break; - case 117: - { yybegin(NAME); return Keyword.LOGICAL_PART_MAPPING; - } - case 225: break; - case 111: - { return Keyword.PLANE_VIA_COSTS; - } - case 226: break; - case 72: - { yybegin(NAME); return Keyword.KEEPOUT; - } - case 227: break; - case 98: - { return Keyword.NETWORK_OUT; - } - case 228: break; - case 55: - { return Keyword.PARSER_SCOPE; - } - case 229: break; - case 10: - { string.append( yytext() ); - } - case 230: break; - case 2: - { throw new Error("Illegal character <"+ - yytext()+">"); - } - case 231: break; - case 95: - { return Keyword.SHOVE_FIXED; - } - case 232: break; - case 104: - { return Keyword.KEEPOUT; - } - case 233: break; - case 33: - { return Keyword.PINS; - } - case 234: break; - case 119: - { return Keyword.PREFERRED_DIRECTION_TRACE_COSTS; - } - case 235: break; - case 5: - { return new Integer(yytext()); - } - case 236: break; - case 25: - { return Keyword.SIDE; - } - case 237: break; - case 41: - { return Keyword.CLEARANCE; - } - case 238: break; - case 97: - { yybegin(NAME); return Keyword.VIA_KEEPOUT; - } - case 239: break; - case 62: - { yybegin(YYINITIAL); return Keyword.SIGNAL; - } - case 240: break; - default: - if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { - zzAtEOF = true; - return null; - } - else { - zzScanError(ZZ_NO_MATCH); - } - } } - } } diff --git a/src/main/java/net/freerouting/designformats/specctra/Structure.java b/src/main/java/net/freerouting/designformats/specctra/Structure.java index 2beb65f6..3724e139 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Structure.java +++ b/src/main/java/net/freerouting/designformats/specctra/Structure.java @@ -19,280 +19,38 @@ */ package net.freerouting.designformats.specctra; +import net.freerouting.board.FixedState; +import net.freerouting.board.TestLevel; +import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; +import net.freerouting.datastructures.UndoableObjects; +import net.freerouting.datastructures.UndoableObjects.Storable; import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.Point; import net.freerouting.geometry.planar.PolylineShape; import net.freerouting.geometry.planar.TileShape; -import net.freerouting.geometry.planar.Point; +import net.freerouting.rules.BoardRules; +import net.freerouting.rules.DefaultItemClearanceClasses.ItemClass; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import net.freerouting.datastructures.UndoableObjects; - -import net.freerouting.rules.BoardRules; -import net.freerouting.rules.DefaultItemClearanceClasses.ItemClass; - -import net.freerouting.datastructures.IndentFileWriter; -import net.freerouting.datastructures.IdentifierType; -import net.freerouting.datastructures.UndoableObjects.Storable; - -import net.freerouting.board.FixedState; -import net.freerouting.board.TestLevel; - /** * Class for reading and writing structure scopes from dsn-files. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -class Structure extends ScopeKeyword -{ +class Structure extends ScopeKeyword { - /** Creates a new instance of Structure */ - public Structure() - { + /** + * Creates a new instance of Structure + */ + public Structure() { super("structure"); } - public boolean read_scope(ReadScopeParameter p_par) - { - BoardConstructionInfo board_construction_info = new BoardConstructionInfo(); - - - // If true, components on the back side are rotated before mirroring - // The correct location is the scope PlaceControl, but Electra writes it here. - boolean flip_style_rotate_first = false; - - Collection keepout_list = new LinkedList(); - Collection via_keepout_list = new LinkedList(); - Collection place_keepout_list = new LinkedList(); - - Object next_token = null; - for (;;) - { - Object prev_token = next_token; - try - { - next_token = p_par.scanner.next_token(); - } - catch (java.io.IOException e) - { - System.out.println("Structure.read_scope: IO error scanning file"); - System.out.println(e); - return false; - } - if (next_token == null) - { - System.out.println("Structure.read_scope: unexpected end of file"); - return false; - } - if (next_token == CLOSED_BRACKET) - { - // end of scope - break; - } - boolean read_ok = true; - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.BOUNDARY) - { - read_boundary_scope(p_par.scanner, board_construction_info); - } - else if (next_token == Keyword.LAYER) - { - read_ok = read_layer_scope(p_par.scanner, board_construction_info, p_par.string_quote); - if (p_par.layer_structure != null) - { - // correct the layer_structure because another layer isr read - p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); - } - } - else if (next_token == Keyword.VIA) - { - p_par.via_padstack_names = read_via_padstacks(p_par.scanner); - } - else if (next_token == Keyword.RULE) - { - board_construction_info.default_rules.addAll(Rule.read_scope(p_par.scanner)); - } - else if (next_token == Keyword.KEEPOUT) - { - if (p_par.layer_structure == null) - { - p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); - } - keepout_list.add(Shape.read_area_scope(p_par.scanner, p_par.layer_structure, false)); - } - else if (next_token == Keyword.VIA_KEEPOUT) - { - if (p_par.layer_structure == null) - { - p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); - } - via_keepout_list.add(Shape.read_area_scope(p_par.scanner, p_par.layer_structure, false)); - } - else if (next_token == Keyword.PLACE_KEEPOUT) - { - if (p_par.layer_structure == null) - { - p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); - } - place_keepout_list.add(Shape.read_area_scope(p_par.scanner, p_par.layer_structure, false)); - } - else if (next_token == Keyword.PLANE_SCOPE) - { - if (p_par.layer_structure == null) - { - p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); - } - Keyword.PLANE_SCOPE.read_scope(p_par); - } - else if (next_token == Keyword.AUTOROUTE_SETTINGS) - { - if (p_par.layer_structure == null) - { - p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); - p_par.autoroute_settings = AutorouteSettings.read_scope(p_par.scanner, p_par.layer_structure); - } - } - else if (next_token == Keyword.CONTROL) - { - read_ok = read_control_scope(p_par); - } - else if (next_token == Keyword.FLIP_STYLE) - { - flip_style_rotate_first = PlaceControl.read_flip_style_rotate_first(p_par.scanner); - } - else if (next_token == Keyword.SNAP_ANGLE) - { - - net.freerouting.board.AngleRestriction snap_angle = read_snap_angle(p_par.scanner); - if (snap_angle != null) - { - p_par.snap_angle = snap_angle; - } - } - else - { - skip_scope(p_par.scanner); - } - } - if (!read_ok) - { - return false; - } - } - - boolean result = true; - if (p_par.board_handling.get_routing_board() == null) - { - result = create_board(p_par, board_construction_info); - } - net.freerouting.board.RoutingBoard board = p_par.board_handling.get_routing_board(); - if (board == null) - { - return false; - } - if (flip_style_rotate_first) - { - board.components.set_flip_style_rotate_first(true); - } - FixedState fixed_state; - if (board.get_test_level() == TestLevel.RELEASE_VERSION) - { - fixed_state = FixedState.SYSTEM_FIXED; - } - else - { - fixed_state = FixedState.USER_FIXED; - } - // insert the keepouts - for (Shape.ReadAreaScopeResult curr_area : keepout_list) - { - if (!insert_keepout(curr_area, p_par, KeepoutType.keepout, fixed_state)) - { - return false; - } - } - - for (Shape.ReadAreaScopeResult curr_area : via_keepout_list) - { - if (!insert_keepout(curr_area, p_par, KeepoutType.via_keepout, FixedState.SYSTEM_FIXED)) - { - return false; - } - } - - for (Shape.ReadAreaScopeResult curr_area : place_keepout_list) - { - if (!insert_keepout(curr_area, p_par, KeepoutType.place_keepout, FixedState.SYSTEM_FIXED)) - { - return false; - } - } - - // insert the planes. - Iterator it = p_par.plane_list.iterator(); - while (it.hasNext()) - { - ReadScopeParameter.PlaneInfo plane_info = it.next(); - Net.Id net_id = new Net.Id(plane_info.net_name, 1); - if (!p_par.netlist.contains(net_id)) - { - Net new_net = p_par.netlist.add_net(net_id); - if (new_net != null) - { - board.rules.nets.add(new_net.id.name, new_net.id.subnet_number, true); - } - } - net.freerouting.rules.Net curr_net = board.rules.nets.get(plane_info.net_name, 1); - if (curr_net == null) - { - System.out.println("Plane.read_scope: net not found"); - continue; - } - net.freerouting.geometry.planar.Area plane_area = - Shape.transform_area_to_board(plane_info.area.shape_list, p_par.coordinate_transform); - Layer curr_layer = (plane_info.area.shape_list.iterator().next()).layer; - if (curr_layer.no >= 0) - { - int clearance_class_no; - if (plane_info.area.clearance_class_name != null) - { - clearance_class_no = board.rules.clearance_matrix.get_no(plane_info.area.clearance_class_name); - if (clearance_class_no < 0) - { - System.out.println("Structure.read_scope: clearance class not found"); - clearance_class_no = BoardRules.clearance_class_none(); - } - } - else - { - clearance_class_no = curr_net.get_class().default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.AREA); - } - int[] net_numbers = new int[1]; - net_numbers[0] = curr_net.net_number; - board.insert_conduction_area(plane_area, curr_layer.no, net_numbers, clearance_class_no, - false, FixedState.SYSTEM_FIXED); - } - else - { - System.out.println("Plane.read_scope: unexpected layer name"); - return false; - } - } - insert_missing_power_planes(board_construction_info.layer_info, p_par.netlist, board); - - p_par.board_handling.initialize_manual_trace_half_widths(); - if (p_par.autoroute_settings != null) - { - p_par.board_handling.settings.autoroute_settings = p_par.autoroute_settings; - } - return result; - } - - public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException - { + public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("structure"); // write the bounding box @@ -306,28 +64,23 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep // lookup the outline in the board Storable curr_ob = null; Iterator it = p_par.board.item_list.start_read_object(); - for (;;) - { + for (; ; ) { curr_ob = p_par.board.item_list.read_object(it); - if (curr_ob == null) - { + if (curr_ob == null) { break; } - if (curr_ob instanceof net.freerouting.board.BoardOutline) - { + if (curr_ob instanceof net.freerouting.board.BoardOutline) { break; } } - if (curr_ob == null) - { + if (curr_ob == null) { System.out.println("Structure.write_scope; outline not found"); return; } net.freerouting.board.BoardOutline outline = (net.freerouting.board.BoardOutline) curr_ob; // write the outline - for (int i = 0; i < outline.shape_count(); ++i) - { + for (int i = 0; i < outline.shape_count(); ++i) { Shape outline_shape = p_par.coordinate_transform.board_to_dsn(outline.get_shape(i), Layer.SIGNAL); p_par.file.start_scope(); p_par.file.write("boundary"); @@ -351,25 +104,20 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep // write the keepouts it = p_par.board.item_list.start_read_object(); - for (;;) - { + for (; ; ) { curr_ob = p_par.board.item_list.read_object(it); - if (curr_ob == null) - { + if (curr_ob == null) { break; } - if (!(curr_ob instanceof net.freerouting.board.ObstacleArea)) - { + if (!(curr_ob instanceof net.freerouting.board.ObstacleArea)) { continue; } net.freerouting.board.ObstacleArea curr_keepout = (net.freerouting.board.ObstacleArea) curr_ob; - if (curr_keepout.get_component_no() != 0) - { + if (curr_keepout.get_component_no() != 0) { // keepouts belonging to a component are not written individually. continue; } - if (curr_keepout instanceof net.freerouting.board.ConductionArea) - { + if (curr_keepout instanceof net.freerouting.board.ConductionArea) { // conduction area will be written later. continue; } @@ -378,20 +126,16 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep // write the conduction areas it = p_par.board.item_list.start_read_object(); - for (;;) - { + for (; ; ) { curr_ob = p_par.board.item_list.read_object(it); - if (curr_ob == null) - { + if (curr_ob == null) { break; } - if (!(curr_ob instanceof net.freerouting.board.ConductionArea)) - { + if (!(curr_ob instanceof net.freerouting.board.ConductionArea)) { continue; } net.freerouting.board.ConductionArea curr_area = (net.freerouting.board.ConductionArea) curr_ob; - if (p_par.board.layer_structure.arr[curr_area.get_layer()].is_signal) - { + if (p_par.board.layer_structure.arr[curr_area.get_layer()].is_signal) { // These conduction areas are written in the wiring scope. continue; } @@ -400,14 +144,12 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep p_par.file.end_scope(); } - static void write_default_rules(WriteScopeParameter p_par) throws java.io.IOException - { + static void write_default_rules(WriteScopeParameter p_par) throws java.io.IOException { // write the default rule using 0 as default layer. Rule.write_default_rule(p_par, 0); // write the layer structure - for (int i = 0; i < p_par.board.layer_structure.arr.length; ++i) - { + for (int i = 0; i < p_par.board.layer_structure.arr.length; ++i) { boolean write_layer_rule = p_par.board.rules.get_default_net_class().get_trace_half_width(i) != p_par.board.rules.get_default_net_class().get_trace_half_width(0) || !clearance_equals(p_par.board.rules.clearance_matrix, i, 0); Layer.write_scope(p_par, i, write_layer_rule); @@ -415,240 +157,177 @@ static void write_default_rules(WriteScopeParameter p_par) throws java.io.IOExce } private static void write_via_padstacks(net.freerouting.library.BoardLibrary p_library, IndentFileWriter p_file, - IdentifierType p_identifier_type) throws java.io.IOException - { + IdentifierType p_identifier_type) throws java.io.IOException { p_file.new_line(); p_file.write("(via"); - for (int i = 0; i < p_library.via_padstack_count(); ++i) - { + for (int i = 0; i < p_library.via_padstack_count(); ++i) { net.freerouting.library.Padstack curr_padstack = p_library.get_via_padstack(i); - if (curr_padstack != null) - { + if (curr_padstack != null) { p_file.write(" "); p_identifier_type.write(curr_padstack.name, p_file); - } - else - { + } else { System.out.println("Structure.write_via_padstacks: padstack is null"); } } p_file.write(")"); } - private static void write_control_scope(net.freerouting.rules.BoardRules p_rules, IndentFileWriter p_file) throws java.io.IOException - { + private static void write_control_scope(net.freerouting.rules.BoardRules p_rules, IndentFileWriter p_file) throws java.io.IOException { p_file.start_scope(); p_file.write("control"); p_file.new_line(); p_file.write("(via_at_smd "); boolean via_at_smd_allowed = false; - for (int i = 0; i < p_rules.via_infos.count(); ++i) - { - if (p_rules.via_infos.get(i).attach_smd_allowed()) - { + for (int i = 0; i < p_rules.via_infos.count(); ++i) { + if (p_rules.via_infos.get(i).attach_smd_allowed()) { via_at_smd_allowed = true; break; } } - if (via_at_smd_allowed) - { + if (via_at_smd_allowed) { p_file.write("on)"); - } - else - { + } else { p_file.write("off)"); } p_file.end_scope(); } - private static void write_keepout_scope(WriteScopeParameter p_par, net.freerouting.board.ObstacleArea p_keepout) throws java.io.IOException - { + private static void write_keepout_scope(WriteScopeParameter p_par, net.freerouting.board.ObstacleArea p_keepout) throws java.io.IOException { net.freerouting.geometry.planar.Area keepout_area = p_keepout.get_area(); int layer_no = p_keepout.get_layer(); net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[layer_no]; Layer keepout_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal); net.freerouting.geometry.planar.Shape boundary_shape; net.freerouting.geometry.planar.Shape[] holes; - if (keepout_area instanceof net.freerouting.geometry.planar.Shape) - { + if (keepout_area instanceof net.freerouting.geometry.planar.Shape) { boundary_shape = (net.freerouting.geometry.planar.Shape) keepout_area; holes = new net.freerouting.geometry.planar.Shape[0]; - } - else - { + } else { boundary_shape = keepout_area.get_border(); holes = keepout_area.get_holes(); } p_par.file.start_scope(); - if (p_keepout instanceof net.freerouting.board.ViaObstacleArea) - { + if (p_keepout instanceof net.freerouting.board.ViaObstacleArea) { p_par.file.write("via_keepout"); - } - else - { + } else { p_par.file.write("keepout"); } Shape dsn_shape = p_par.coordinate_transform.board_to_dsn(boundary_shape, keepout_layer); - if (dsn_shape != null) - { + if (dsn_shape != null) { dsn_shape.write_scope(p_par.file, p_par.identifier_type); } - for (int i = 0; i < holes.length; ++i) - { + for (int i = 0; i < holes.length; ++i) { Shape dsn_hole = p_par.coordinate_transform.board_to_dsn(holes[i], keepout_layer); dsn_hole.write_hole_scope(p_par.file, p_par.identifier_type); } - if (p_keepout.clearance_class_no() > 0) - { + if (p_keepout.clearance_class_no() > 0) { Rule.write_item_clearance_class(p_par.board.rules.clearance_matrix.get_name(p_keepout.clearance_class_no()), p_par.file, p_par.identifier_type); } p_par.file.end_scope(); } - private static boolean read_boundary_scope(Scanner p_scanner, BoardConstructionInfo p_board_construction_info) - { + private static boolean read_boundary_scope(Scanner p_scanner, BoardConstructionInfo p_board_construction_info) { Shape curr_shape = Shape.read_scope(p_scanner, null); // overread the closing bracket. - try - { + try { Object prev_token = null; - for (;;) - { + for (; ; ) { Object next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.CLEARANCE_CLASS) - { + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.CLEARANCE_CLASS) { p_board_construction_info.outline_clearance_class_name = DsnFile.read_string_scope(p_scanner); } } prev_token = next_token; } - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Structure.read_boundary_scope: IO error scanning file"); return false; } - if (curr_shape == null) - { + if (curr_shape == null) { System.out.println("Structure.read_boundary_scope: shape is null"); return true; } - if (curr_shape.layer == Layer.PCB) - { - if (p_board_construction_info.bounding_shape == null) - { + if (curr_shape.layer == Layer.PCB) { + if (p_board_construction_info.bounding_shape == null) { p_board_construction_info.bounding_shape = curr_shape; - } - else - { + } else { System.out.println("Structure.read_boundary_scope: exact 1 bounding_shape expected"); } - } - else if (curr_shape.layer == Layer.SIGNAL) - { + } else if (curr_shape.layer == Layer.SIGNAL) { p_board_construction_info.outline_shapes.add(curr_shape); - } - else - { + } else { System.out.println("Structure.read_boundary_scope: unexpected layer"); } return true; } - static boolean read_layer_scope(Scanner p_scanner, BoardConstructionInfo p_board_construction_info, String p_string_quote) - { - try - { + static boolean read_layer_scope(Scanner p_scanner, BoardConstructionInfo p_board_construction_info, String p_string_quote) { + try { boolean layer_ok = true; boolean is_signal = true; Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Structure.read_layer_scope: String expected"); return false; } Collection net_names = new LinkedList(); String layer_string = (String) next_token; next_token = p_scanner.next_token(); - while (next_token != Keyword.CLOSED_BRACKET) - { - if (next_token != Keyword.OPEN_BRACKET) - { + while (next_token != Keyword.CLOSED_BRACKET) { + if (next_token != Keyword.OPEN_BRACKET) { System.out.println("Structure.read_layer_scope: ( expected"); return false; } next_token = p_scanner.next_token(); - if (next_token == Keyword.TYPE) - { + if (next_token == Keyword.TYPE) { next_token = p_scanner.next_token(); - if (next_token == Keyword.POWER) - { + if (next_token == Keyword.POWER) { is_signal = false; - } - else if (next_token != Keyword.SIGNAL) - { + } else if (next_token != Keyword.SIGNAL) { System.out.print("Structure.read_layer_scope: unknown layer type "); - if (next_token instanceof String) - { + if (next_token instanceof String) { System.out.print((String) next_token); } System.out.println(); layer_ok = false; } next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Structure.read_layer_scope: ) expected"); return false; } - } - else if (next_token == Keyword.RULE) - { + } else if (next_token == Keyword.RULE) { Collection curr_rules = Rule.read_scope(p_scanner); p_board_construction_info.layer_dependent_rules.add(new LayerRule(layer_string, curr_rules)); - } - else if (next_token == Keyword.USE_NET) - { - for (;;) - { + } else if (next_token == Keyword.USE_NET) { + for (; ; ) { p_scanner.yybegin(SpecctraFileScanner.NAME); next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (next_token instanceof String) - { + if (next_token instanceof String) { net_names.add((String) next_token); - } - else - { + } else { System.out.println("Structure.read_layer_scope: string expected"); } } - } - else - { + } else { skip_scope(p_scanner); } next_token = p_scanner.next_token(); } - if (layer_ok) - { + if (layer_ok) { Layer curr_layer = new Layer(layer_string, p_board_construction_info.found_layer_count, is_signal, net_names); p_board_construction_info.layer_info.add(curr_layer); ++p_board_construction_info.found_layer_count; } - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Layer.read_scope: IO error scanning file"); System.out.println(e); return false; @@ -657,37 +336,25 @@ else if (next_token == Keyword.USE_NET) } - static Collection read_via_padstacks(Scanner p_scanner) - { - try - { + static Collection read_via_padstacks(Scanner p_scanner) { + try { Collection normal_vias = new LinkedList(); Collection spare_vias = new LinkedList(); - for (;;) - { + for (; ; ) { Object next_token = p_scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (next_token == Keyword.OPEN_BRACKET) - { + if (next_token == Keyword.OPEN_BRACKET) { next_token = p_scanner.next_token(); - if (next_token == Keyword.SPARE) - { + if (next_token == Keyword.SPARE) { spare_vias = read_via_padstacks(p_scanner); - } - else - { + } else { skip_scope(p_scanner); } - } - else if (next_token instanceof String) - { + } else if (next_token instanceof String) { normal_vias.add((String) next_token); - } - else - { + } else { System.out.println("Structure.read_via_padstack: String expected"); return null; } @@ -695,47 +362,34 @@ else if (next_token instanceof String) // add the spare vias to the end of the list normal_vias.addAll(spare_vias); return normal_vias; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Structure.read_via_padstack: IO error scanning file"); return null; } } - private static boolean read_control_scope(ReadScopeParameter p_par) - { + private static boolean read_control_scope(ReadScopeParameter p_par) { Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = p_par.scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Structure.read_control_scope: IO error scanning file"); return false; } - if (next_token == null) - { + if (next_token == null) { System.out.println("Structure.read_control_scope: unexpected end of file"); return false; } - if (next_token == CLOSED_BRACKET) - { + if (next_token == CLOSED_BRACKET) { // end of scope break; } - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.VIA_AT_SMD) - { + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.VIA_AT_SMD) { p_par.via_at_smd_allowed = DsnFile.read_on_off_scope(p_par.scanner); - } - else - { + } else { skip_scope(p_par.scanner); } } @@ -743,238 +397,81 @@ private static boolean read_control_scope(ReadScopeParameter p_par) return true; } - static net.freerouting.board.AngleRestriction read_snap_angle(Scanner p_scanner) - { - try - { + static net.freerouting.board.AngleRestriction read_snap_angle(Scanner p_scanner) { + try { Object next_token = p_scanner.next_token(); net.freerouting.board.AngleRestriction snap_angle; - if (next_token == Keyword.NINETY_DEGREE) - { + if (next_token == Keyword.NINETY_DEGREE) { snap_angle = net.freerouting.board.AngleRestriction.NINETY_DEGREE; - } - else if (next_token == Keyword.FORTYFIVE_DEGREE) - { + } else if (next_token == Keyword.FORTYFIVE_DEGREE) { snap_angle = net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE; - } - else if (next_token == Keyword.NONE) - { + } else if (next_token == Keyword.NONE) { snap_angle = net.freerouting.board.AngleRestriction.NONE; - } - else - { + } else { System.out.println("Structure.read_snap_angle_scope: unexpected token"); return null; } next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Structure.read_selection_layer_scop: closing bracket expected"); return null; } return snap_angle; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Structure.read_snap_angl: IO error scanning file"); return null; } } - static void write_snap_angle(IndentFileWriter p_file, net.freerouting.board.AngleRestriction p_angle_restriction) throws java.io.IOException - { + static void write_snap_angle(IndentFileWriter p_file, net.freerouting.board.AngleRestriction p_angle_restriction) throws java.io.IOException { p_file.start_scope(); p_file.write("snap_angle "); p_file.new_line(); - if (p_angle_restriction == net.freerouting.board.AngleRestriction.NINETY_DEGREE) - { + if (p_angle_restriction == net.freerouting.board.AngleRestriction.NINETY_DEGREE) { p_file.write("ninety_degree"); - } - else if (p_angle_restriction == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (p_angle_restriction == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE) { p_file.write("fortyfive_degree"); - } - else - { + } else { p_file.write("none"); } p_file.end_scope(); } - private boolean create_board(ReadScopeParameter p_par, BoardConstructionInfo p_board_construction_info) - { - int layer_count = p_board_construction_info.layer_info.size(); - if (layer_count == 0) - { - System.out.println("Structure.create_board: layers missing in structure scope"); - return false; - } - if (p_board_construction_info.bounding_shape == null) - { - // happens if the boundary shape with layer pcb is missing - if (p_board_construction_info.outline_shapes.isEmpty()) - { - System.out.println("Structure.create_board: outline missing"); - p_par.board_outline_ok = false; - return false; + private static void insert_missing_power_planes(Collection p_layer_info, + NetList p_netlist, net.freerouting.board.BasicBoard p_board) { + Collection conduction_areas = p_board.get_conduction_areas(); + for (Layer curr_layer : p_layer_info) { + if (curr_layer.is_signal) { + continue; } - Iterator it = p_board_construction_info.outline_shapes.iterator(); - - Rectangle bounding_box = it.next().bounding_box(); - while (it.hasNext()) - { - bounding_box = bounding_box.union(it.next().bounding_box()); - } - p_board_construction_info.bounding_shape = bounding_box; - } - Rectangle bounding_box = p_board_construction_info.bounding_shape.bounding_box(); - net.freerouting.board.Layer[] board_layer_arr = new net.freerouting.board.Layer[layer_count]; - Iterator it = p_board_construction_info.layer_info.iterator(); - for (int i = 0; i < layer_count; ++i) - { - Layer curr_layer = it.next(); - if (curr_layer.no < 0 || curr_layer.no >= layer_count) - { - System.out.println("Structure.create_board: illegal layer number"); - return false; - } - board_layer_arr[i] = new net.freerouting.board.Layer(curr_layer.name, curr_layer.is_signal); - } - net.freerouting.board.LayerStructure board_layer_structure = new net.freerouting.board.LayerStructure(board_layer_arr); - p_par.layer_structure = new LayerStructure(p_board_construction_info.layer_info); - - // Calculate an appropritate scaling between dsn coordinates and board coordinates. - int scale_factor = Math.max(p_par.resolution, 1); - - double max_coor = 0; - for (int i = 0; i < 4; ++i) - { - max_coor = Math.max(max_coor, Math.abs(bounding_box.coor[i] * p_par.resolution)); - } - if (max_coor == 0) - { - p_par.board_outline_ok = false; - return false; - } - // make scalefactor smaller, if there is a danger of integer overflow. - while (5 * max_coor >= net.freerouting.geometry.planar.Limits.CRIT_INT) - { - scale_factor /= 10; - max_coor /= 10; - } - - p_par.coordinate_transform = new CoordinateTransform(scale_factor, 0, 0); - - IntBox bounds = (IntBox) bounding_box.transform_to_board(p_par.coordinate_transform); - bounds = bounds.offset(1000); - - Collection board_outline_shapes = new LinkedList(); - for (Shape curr_shape : p_board_construction_info.outline_shapes) - { - if (curr_shape instanceof PolygonPath) - { - PolygonPath curr_path = (PolygonPath) curr_shape; - if (curr_path.width != 0) - { - // set the width to 0, because the offset function used in transform_to_board is not implemented - // for shapes, which are not convex. - curr_shape = new PolygonPath(curr_path.layer, 0, curr_path.coordinate_arr); - } - } - PolylineShape curr_board_shape = (PolylineShape) curr_shape.transform_to_board(p_par.coordinate_transform); - if (curr_board_shape.dimension() > 0) - { - board_outline_shapes.add(curr_board_shape); - } - } - if (board_outline_shapes.isEmpty()) - { - // construct an outline from the bounding_shape, if the outline is missing. - PolylineShape curr_board_shape = (PolylineShape) p_board_construction_info.bounding_shape.transform_to_board(p_par.coordinate_transform); - board_outline_shapes.add(curr_board_shape); - } - Collection hole_shapes = separate_holes(board_outline_shapes); - net.freerouting.rules.ClearanceMatrix clearance_matrix = net.freerouting.rules.ClearanceMatrix.get_default_instance(board_layer_structure, 0); - net.freerouting.rules.BoardRules board_rules = new net.freerouting.rules.BoardRules(board_layer_structure, clearance_matrix); - net.freerouting.board.Communication.SpecctraParserInfo specctra_parser_info = - new net.freerouting.board.Communication.SpecctraParserInfo(p_par.string_quote, p_par.host_cad, - p_par.host_version, p_par.constants, p_par.write_resolution, p_par.dsn_file_generated_by_host); - net.freerouting.board.Communication board_communication = - new net.freerouting.board.Communication(p_par.unit, p_par.resolution, specctra_parser_info, - p_par.coordinate_transform, p_par.item_id_no_generator, p_par.observers); - - PolylineShape[] outline_shape_arr = new PolylineShape[board_outline_shapes.size()]; - Iterator it2 = board_outline_shapes.iterator(); - for (int i = 0; i < outline_shape_arr.length; ++i) - { - outline_shape_arr[i] = it2.next(); - } - update_board_rules(p_par, p_board_construction_info, board_rules); - board_rules.set_trace_angle_restriction(p_par.snap_angle); - p_par.board_handling.create_board(bounds, board_layer_structure, outline_shape_arr, - p_board_construction_info.outline_clearance_class_name, board_rules, - board_communication, p_par.test_level); - - net.freerouting.board.BasicBoard board = p_par.board_handling.get_routing_board(); - - // Insert the holes in the board outline as keepouts. - for (PolylineShape curr_outline_hole : hole_shapes) - { - for (int i = 0; i < board_layer_structure.arr.length; ++i) - { - board.insert_obstacle(curr_outline_hole, i, 0, FixedState.SYSTEM_FIXED); - } - } - - return true; - } - // Check, if a conduction area is inserted on each plane, - // and insert evtl. a conduction area - - private static void insert_missing_power_planes(Collection p_layer_info, - NetList p_netlist, net.freerouting.board.BasicBoard p_board) - { - Collection conduction_areas = p_board.get_conduction_areas(); - for (Layer curr_layer : p_layer_info) - { - if (curr_layer.is_signal) - { - continue; - } - boolean conduction_area_found = false; - for (net.freerouting.board.ConductionArea curr_conduction_area : conduction_areas) - { - if (curr_conduction_area.get_layer() == curr_layer.no) - { - conduction_area_found = true; - break; - } - } - if (!conduction_area_found && !curr_layer.net_names.isEmpty()) - { - String curr_net_name = curr_layer.net_names.iterator().next(); - Net.Id curr_net_id = new Net.Id(curr_net_name, 1); - if (!p_netlist.contains(curr_net_id)) - { - Net new_net = p_netlist.add_net(curr_net_id); - if (new_net != null) - { - p_board.rules.nets.add(new_net.id.name, new_net.id.subnet_number, true); - } - } - net.freerouting.rules.Net curr_net = p_board.rules.nets.get(curr_net_id.name, curr_net_id.subnet_number); - { - if (curr_net == null) - { - System.out.println("Structure.insert_missing_power_planes: net not found"); - continue; - } - } - int[] net_numbers = new int[1]; - net_numbers[0] = curr_net.net_number; - p_board.insert_conduction_area(p_board.bounding_box, curr_layer.no, net_numbers, BoardRules.clearance_class_none(), - false, FixedState.SYSTEM_FIXED); + boolean conduction_area_found = false; + for (net.freerouting.board.ConductionArea curr_conduction_area : conduction_areas) { + if (curr_conduction_area.get_layer() == curr_layer.no) { + conduction_area_found = true; + break; + } + } + if (!conduction_area_found && !curr_layer.net_names.isEmpty()) { + String curr_net_name = curr_layer.net_names.iterator().next(); + Net.Id curr_net_id = new Net.Id(curr_net_name, 1); + if (!p_netlist.contains(curr_net_id)) { + Net new_net = p_netlist.add_net(curr_net_id); + if (new_net != null) { + p_board.rules.nets.add(new_net.id.name, new_net.id.subnet_number, true); + } + } + net.freerouting.rules.Net curr_net = p_board.rules.nets.get(curr_net_id.name, curr_net_id.subnet_number); + { + if (curr_net == null) { + System.out.println("Structure.insert_missing_power_planes: net not found"); + continue; + } + } + int[] net_numbers = new int[1]; + net_numbers[0] = curr_net.net_number; + p_board.insert_conduction_area(p_board.bounding_box, curr_layer.no, net_numbers, BoardRules.clearance_class_none(), + false, FixedState.SYSTEM_FIXED); } } } @@ -983,105 +480,86 @@ private static void insert_missing_power_planes(Collection p_layer_info, * Calculates shapes in p_outline_shapes, which are holes in the outline and returns * them in the result list. */ - private static Collection separate_holes(Collection p_outline_shapes) - { + private static Collection separate_holes(Collection p_outline_shapes) { OutlineShape shape_arr[] = new OutlineShape[p_outline_shapes.size()]; Iterator it = p_outline_shapes.iterator(); - for (int i = 0; i < shape_arr.length; ++i) - { + for (int i = 0; i < shape_arr.length; ++i) { shape_arr[i] = new OutlineShape(it.next()); } - for (int i = 0; i < shape_arr.length; ++i) - { + for (int i = 0; i < shape_arr.length; ++i) { OutlineShape curr_shape = shape_arr[i]; - for (int j = 0; j < shape_arr.length; ++j) - { + for (int j = 0; j < shape_arr.length; ++j) { // check if shape_arr[j] may be contained in shape_arr[i] OutlineShape other_shape = shape_arr[j]; - if (i == j || other_shape.is_hole) - { + if (i == j || other_shape.is_hole) { continue; } - if (!other_shape.bounding_box.contains(curr_shape.bounding_box)) - { + if (!other_shape.bounding_box.contains(curr_shape.bounding_box)) { continue; } curr_shape.is_hole = other_shape.contains_all_corners(curr_shape); } } Collection hole_list = new LinkedList(); - for (int i = 0; i < shape_arr.length; ++i) - { - if (shape_arr[i].is_hole) - { + for (int i = 0; i < shape_arr.length; ++i) { + if (shape_arr[i].is_hole) { p_outline_shapes.remove(shape_arr[i].shape); hole_list.add(shape_arr[i].shape); } } return hole_list; } + // Check, if a conduction area is inserted on each plane, + // and insert evtl. a conduction area /** * Updates the board rules from the rules read from the dsn file. */ private static void update_board_rules(ReadScopeParameter p_par, - BoardConstructionInfo p_board_construction_info, BoardRules p_board_rules) - { + BoardConstructionInfo p_board_construction_info, BoardRules p_board_rules) { boolean smd_to_turn_gap_found = false; // update the clearance matrix Iterator it = p_board_construction_info.default_rules.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Rule curr_ob = it.next(); - if (curr_ob instanceof Rule.ClearanceRule) - { + if (curr_ob instanceof Rule.ClearanceRule) { Rule.ClearanceRule curr_rule = (Rule.ClearanceRule) curr_ob; - if (set_clearance_rule(curr_rule, -1, p_par.coordinate_transform, p_board_rules, p_par.string_quote)) - { + if (set_clearance_rule(curr_rule, -1, p_par.coordinate_transform, p_board_rules, p_par.string_quote)) { smd_to_turn_gap_found = true; } } } // update width rules it = p_board_construction_info.default_rules.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Object curr_ob = it.next(); - if (curr_ob instanceof Rule.WidthRule) - { + if (curr_ob instanceof Rule.WidthRule) { double wire_width = ((Rule.WidthRule) curr_ob).value; int trace_halfwidth = (int) Math.round(p_par.coordinate_transform.dsn_to_board(wire_width) / 2); p_board_rules.set_default_trace_half_widths(trace_halfwidth); } } Iterator it3 = p_board_construction_info.layer_dependent_rules.iterator(); - while (it3.hasNext()) - { + while (it3.hasNext()) { LayerRule layer_rule = it3.next(); int layer_no = p_par.layer_structure.get_no(layer_rule.layer_name); - if (layer_no < 0) - { + if (layer_no < 0) { continue; } Iterator it2 = layer_rule.rule.iterator(); - while (it2.hasNext()) - { + while (it2.hasNext()) { Rule curr_ob = it2.next(); - if (curr_ob instanceof Rule.WidthRule) - { + if (curr_ob instanceof Rule.WidthRule) { double wire_width = ((Rule.WidthRule) curr_ob).value; int trace_halfwidth = (int) Math.round(p_par.coordinate_transform.dsn_to_board(wire_width) / 2); p_board_rules.set_default_trace_half_width(layer_no, trace_halfwidth); - } - else if (curr_ob instanceof Rule.ClearanceRule) - { + } else if (curr_ob instanceof Rule.ClearanceRule) { Rule.ClearanceRule curr_rule = (Rule.ClearanceRule) curr_ob; set_clearance_rule(curr_rule, layer_no, p_par.coordinate_transform, p_board_rules, p_par.string_quote); } } } - if (!smd_to_turn_gap_found) - { + if (!smd_to_turn_gap_found) { p_board_rules.set_pin_edge_to_turn_dist(p_board_rules.get_min_trace_half_width()); } } @@ -1092,107 +570,79 @@ else if (curr_ob instanceof Rule.ClearanceRule) * Returns true, if the string smd_to_turn_gap was found. */ static boolean set_clearance_rule(Rule.ClearanceRule p_rule, int p_layer_no, - CoordinateTransform p_coordinate_transform, BoardRules p_board_rules, String p_string_quote) - { + CoordinateTransform p_coordinate_transform, BoardRules p_board_rules, String p_string_quote) { boolean result = false; int curr_clearance = (int) Math.round(p_coordinate_transform.dsn_to_board(p_rule.value)); - if (p_rule.clearance_class_pairs.isEmpty()) - { - if (p_layer_no < 0) - { + if (p_rule.clearance_class_pairs.isEmpty()) { + if (p_layer_no < 0) { p_board_rules.clearance_matrix.set_default_value(curr_clearance); - } - else - { + } else { p_board_rules.clearance_matrix.set_default_value(p_layer_no, curr_clearance); } return result; } - if (contains_wire_clearance_pair(p_rule.clearance_class_pairs)) - { + if (contains_wire_clearance_pair(p_rule.clearance_class_pairs)) { create_default_clearance_classes(p_board_rules); } Iterator it = p_rule.clearance_class_pairs.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { String curr_string = it.next(); - if (curr_string.equalsIgnoreCase("smd_to_turn_gap")) - { + if (curr_string.equalsIgnoreCase("smd_to_turn_gap")) { p_board_rules.set_pin_edge_to_turn_dist(curr_clearance); result = true; continue; } String[] curr_pair; - if (curr_string.startsWith(p_string_quote)) - { + if (curr_string.startsWith(p_string_quote)) { // split at the second occurance of p_string_quote curr_string = curr_string.substring(p_string_quote.length()); curr_pair = curr_string.split(p_string_quote, 2); - if (curr_pair.length != 2 || !curr_pair[1].startsWith("_")) - { + if (curr_pair.length != 2 || !curr_pair[1].startsWith("_")) { System.out.println("Structure.set_clearance_rule: '_' exprcted"); continue; } curr_pair[1] = curr_pair[1].substring(1); - } - else - { + } else { curr_pair = curr_string.split("_", 2); - if (curr_pair.length != 2) - { + if (curr_pair.length != 2) { // pairs with more than 1 underline like smd_via_same_net are not implemented continue; } } - if (curr_pair[1].startsWith(p_string_quote) && curr_pair[1].endsWith(p_string_quote)) - { + if (curr_pair[1].startsWith(p_string_quote) && curr_pair[1].endsWith(p_string_quote)) { // remove the quotes curr_pair[1] = curr_pair[1].substring(1, curr_pair[1].length() - 1); - } - else - { + } else { String[] tmp_pair = curr_pair[1].split("_", 2); - if (tmp_pair.length != 1) - { + if (tmp_pair.length != 1) { // pairs with more than 1 underline like smd_via_same_net are not implemented continue; } } int first_class_no; - if (curr_pair[0].equals("wire")) - { + if (curr_pair[0].equals("wire")) { first_class_no = 1; // default class - } - else - { + } else { first_class_no = p_board_rules.clearance_matrix.get_no(curr_pair[0]); } - if (first_class_no < 0) - { + if (first_class_no < 0) { first_class_no = append_clearance_class(p_board_rules, curr_pair[0]); } int second_class_no; - if (curr_pair[1].equals("wire")) - { + if (curr_pair[1].equals("wire")) { second_class_no = 1; // default class - } - else - { + } else { second_class_no = p_board_rules.clearance_matrix.get_no(curr_pair[1]); } - if (second_class_no < 0) - { + if (second_class_no < 0) { second_class_no = append_clearance_class(p_board_rules, curr_pair[1]); } - if (p_layer_no < 0) - { + if (p_layer_no < 0) { p_board_rules.clearance_matrix.set_value(first_class_no, second_class_no, curr_clearance); p_board_rules.clearance_matrix.set_value(second_class_no, first_class_no, curr_clearance); - } - else - { + } else { p_board_rules.clearance_matrix.set_value(first_class_no, second_class_no, p_layer_no, curr_clearance); p_board_rules.clearance_matrix.set_value(second_class_no, first_class_no, p_layer_no, curr_clearance); } @@ -1200,45 +650,33 @@ static boolean set_clearance_rule(Rule.ClearanceRule p_rule, int p_layer_no, return result; } - static boolean contains_wire_clearance_pair(Collection p_clearance_pairs) - { - for (String curr_pair : p_clearance_pairs) - { - if (curr_pair.startsWith("wire_") || curr_pair.endsWith("_wire")) - { + static boolean contains_wire_clearance_pair(Collection p_clearance_pairs) { + for (String curr_pair : p_clearance_pairs) { + if (curr_pair.startsWith("wire_") || curr_pair.endsWith("_wire")) { return true; } } return false; } - static private void create_default_clearance_classes(BoardRules p_board_rules) - { + static private void create_default_clearance_classes(BoardRules p_board_rules) { append_clearance_class(p_board_rules, "via"); append_clearance_class(p_board_rules, "smd"); append_clearance_class(p_board_rules, "pin"); append_clearance_class(p_board_rules, "area"); } - static private int append_clearance_class(BoardRules p_board_rules, String p_name) - { + static private int append_clearance_class(BoardRules p_board_rules, String p_name) { p_board_rules.clearance_matrix.append_class(p_name); int result = p_board_rules.clearance_matrix.get_no(p_name); net.freerouting.rules.NetClass default_net_class = p_board_rules.get_default_net_class(); - if (p_name.equals("via")) - { + if (p_name.equals("via")) { default_net_class.default_item_clearance_classes.set(ItemClass.VIA, result); - } - else if (p_name.equals("pin")) - { + } else if (p_name.equals("pin")) { default_net_class.default_item_clearance_classes.set(ItemClass.PIN, result); - } - else if (p_name.equals("smd")) - { + } else if (p_name.equals("smd")) { default_net_class.default_item_clearance_classes.set(ItemClass.SMD, result); - } - else if (p_name.equals("area")) - { + } else if (p_name.equals("area")) { default_net_class.default_item_clearance_classes.set(ItemClass.AREA, result); } return result; @@ -1247,18 +685,13 @@ else if (p_name.equals("area")) /** * Returns true, if all clearance values on the 2 input layers are equal. */ - private static boolean clearance_equals(net.freerouting.rules.ClearanceMatrix p_cl_matrix, int p_layer_1, int p_layer_2) - { - if (p_layer_1 == p_layer_2) - { + private static boolean clearance_equals(net.freerouting.rules.ClearanceMatrix p_cl_matrix, int p_layer_1, int p_layer_2) { + if (p_layer_1 == p_layer_2) { return true; } - for (int i = 1; i < p_cl_matrix.get_class_count(); ++i) - { - for (int j = i; j < p_cl_matrix.get_class_count(); ++j) - { - if (p_cl_matrix.value(i, j, p_layer_1) != p_cl_matrix.value(i, j, p_layer_2)) - { + for (int i = 1; i < p_cl_matrix.get_class_count(); ++i) { + for (int j = i; j < p_cl_matrix.get_class_count(); ++j) { + if (p_cl_matrix.value(i, j, p_layer_1) != p_cl_matrix.value(i, j, p_layer_2)) { return false; } } @@ -1266,38 +699,28 @@ private static boolean clearance_equals(net.freerouting.rules.ClearanceMatrix p_ return true; } - private static boolean insert_keepout(Shape.ReadAreaScopeResult p_area, ReadScopeParameter p_par, KeepoutType p_keepout_type, FixedState p_fixed_state) - { + private static boolean insert_keepout(Shape.ReadAreaScopeResult p_area, ReadScopeParameter p_par, KeepoutType p_keepout_type, FixedState p_fixed_state) { net.freerouting.geometry.planar.Area keepout_area = Shape.transform_area_to_board(p_area.shape_list, p_par.coordinate_transform); - if (keepout_area.dimension() < 2) - { + if (keepout_area.dimension() < 2) { System.out.println("Structure.insert_keepout: keepout is not an area"); return true; } net.freerouting.board.BasicBoard board = p_par.board_handling.get_routing_board(); - if (board == null) - { + if (board == null) { System.out.println("Structure.insert_keepout: board not initialized"); return false; } Layer curr_layer = (p_area.shape_list.iterator().next()).layer; - if (curr_layer == Layer.SIGNAL) - { - for (int i = 0; i < board.get_layer_count(); ++i) - { - if (p_par.layer_structure.arr[i].is_signal) - { + if (curr_layer == Layer.SIGNAL) { + for (int i = 0; i < board.get_layer_count(); ++i) { + if (p_par.layer_structure.arr[i].is_signal) { insert_keepout(board, keepout_area, i, p_area.clearance_class_name, p_keepout_type, p_fixed_state); } } - } - else if (curr_layer.no >= 0) - { + } else if (curr_layer.no >= 0) { insert_keepout(board, keepout_area, curr_layer.no, p_area.clearance_class_name, p_keepout_type, p_fixed_state); - } - else - { + } else { System.out.println("Structure.insert_keepout: unknown layer name"); return false; } @@ -1306,45 +729,315 @@ else if (curr_layer.no >= 0) } private static void insert_keepout(net.freerouting.board.BasicBoard p_board, net.freerouting.geometry.planar.Area p_area, int p_layer, - String p_clearance_class_name, KeepoutType p_keepout_type, FixedState p_fixed_state) - { + String p_clearance_class_name, KeepoutType p_keepout_type, FixedState p_fixed_state) { int clearance_class_no; - if (p_clearance_class_name == null) - { + if (p_clearance_class_name == null) { clearance_class_no = p_board.rules.get_default_net_class().default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.AREA); - } - else - { + } else { clearance_class_no = p_board.rules.clearance_matrix.get_no(p_clearance_class_name); - if (clearance_class_no < 0) - { + if (clearance_class_no < 0) { System.out.println("Keepout.insert_leepout: clearance class not found"); clearance_class_no = BoardRules.clearance_class_none(); } } - if (p_keepout_type == KeepoutType.via_keepout) - { + if (p_keepout_type == KeepoutType.via_keepout) { p_board.insert_via_obstacle(p_area, p_layer, clearance_class_no, p_fixed_state); - } - else if (p_keepout_type == KeepoutType.place_keepout) - { + } else if (p_keepout_type == KeepoutType.place_keepout) { p_board.insert_component_obstacle(p_area, p_layer, clearance_class_no, p_fixed_state); - } - else - { + } else { p_board.insert_obstacle(p_area, p_layer, clearance_class_no, p_fixed_state); } } - enum KeepoutType - { + public boolean read_scope(ReadScopeParameter p_par) { + BoardConstructionInfo board_construction_info = new BoardConstructionInfo(); + + + // If true, components on the back side are rotated before mirroring + // The correct location is the scope PlaceControl, but Electra writes it here. + boolean flip_style_rotate_first = false; + + Collection keepout_list = new LinkedList(); + Collection via_keepout_list = new LinkedList(); + Collection place_keepout_list = new LinkedList(); + + Object next_token = null; + for (; ; ) { + Object prev_token = next_token; + try { + next_token = p_par.scanner.next_token(); + } catch (java.io.IOException e) { + System.out.println("Structure.read_scope: IO error scanning file"); + System.out.println(e); + return false; + } + if (next_token == null) { + System.out.println("Structure.read_scope: unexpected end of file"); + return false; + } + if (next_token == CLOSED_BRACKET) { + // end of scope + break; + } + boolean read_ok = true; + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.BOUNDARY) { + read_boundary_scope(p_par.scanner, board_construction_info); + } else if (next_token == Keyword.LAYER) { + read_ok = read_layer_scope(p_par.scanner, board_construction_info, p_par.string_quote); + if (p_par.layer_structure != null) { + // correct the layer_structure because another layer isr read + p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); + } + } else if (next_token == Keyword.VIA) { + p_par.via_padstack_names = read_via_padstacks(p_par.scanner); + } else if (next_token == Keyword.RULE) { + board_construction_info.default_rules.addAll(Rule.read_scope(p_par.scanner)); + } else if (next_token == Keyword.KEEPOUT) { + if (p_par.layer_structure == null) { + p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); + } + keepout_list.add(Shape.read_area_scope(p_par.scanner, p_par.layer_structure, false)); + } else if (next_token == Keyword.VIA_KEEPOUT) { + if (p_par.layer_structure == null) { + p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); + } + via_keepout_list.add(Shape.read_area_scope(p_par.scanner, p_par.layer_structure, false)); + } else if (next_token == Keyword.PLACE_KEEPOUT) { + if (p_par.layer_structure == null) { + p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); + } + place_keepout_list.add(Shape.read_area_scope(p_par.scanner, p_par.layer_structure, false)); + } else if (next_token == Keyword.PLANE_SCOPE) { + if (p_par.layer_structure == null) { + p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); + } + Keyword.PLANE_SCOPE.read_scope(p_par); + } else if (next_token == Keyword.AUTOROUTE_SETTINGS) { + if (p_par.layer_structure == null) { + p_par.layer_structure = new LayerStructure(board_construction_info.layer_info); + p_par.autoroute_settings = AutorouteSettings.read_scope(p_par.scanner, p_par.layer_structure); + } + } else if (next_token == Keyword.CONTROL) { + read_ok = read_control_scope(p_par); + } else if (next_token == Keyword.FLIP_STYLE) { + flip_style_rotate_first = PlaceControl.read_flip_style_rotate_first(p_par.scanner); + } else if (next_token == Keyword.SNAP_ANGLE) { + + net.freerouting.board.AngleRestriction snap_angle = read_snap_angle(p_par.scanner); + if (snap_angle != null) { + p_par.snap_angle = snap_angle; + } + } else { + skip_scope(p_par.scanner); + } + } + if (!read_ok) { + return false; + } + } + + boolean result = true; + if (p_par.board_handling.get_routing_board() == null) { + result = create_board(p_par, board_construction_info); + } + net.freerouting.board.RoutingBoard board = p_par.board_handling.get_routing_board(); + if (board == null) { + return false; + } + if (flip_style_rotate_first) { + board.components.set_flip_style_rotate_first(true); + } + FixedState fixed_state; + if (board.get_test_level() == TestLevel.RELEASE_VERSION) { + fixed_state = FixedState.SYSTEM_FIXED; + } else { + fixed_state = FixedState.USER_FIXED; + } + // insert the keepouts + for (Shape.ReadAreaScopeResult curr_area : keepout_list) { + if (!insert_keepout(curr_area, p_par, KeepoutType.keepout, fixed_state)) { + return false; + } + } + + for (Shape.ReadAreaScopeResult curr_area : via_keepout_list) { + if (!insert_keepout(curr_area, p_par, KeepoutType.via_keepout, FixedState.SYSTEM_FIXED)) { + return false; + } + } + + for (Shape.ReadAreaScopeResult curr_area : place_keepout_list) { + if (!insert_keepout(curr_area, p_par, KeepoutType.place_keepout, FixedState.SYSTEM_FIXED)) { + return false; + } + } + + // insert the planes. + Iterator it = p_par.plane_list.iterator(); + while (it.hasNext()) { + ReadScopeParameter.PlaneInfo plane_info = it.next(); + Net.Id net_id = new Net.Id(plane_info.net_name, 1); + if (!p_par.netlist.contains(net_id)) { + Net new_net = p_par.netlist.add_net(net_id); + if (new_net != null) { + board.rules.nets.add(new_net.id.name, new_net.id.subnet_number, true); + } + } + net.freerouting.rules.Net curr_net = board.rules.nets.get(plane_info.net_name, 1); + if (curr_net == null) { + System.out.println("Plane.read_scope: net not found"); + continue; + } + net.freerouting.geometry.planar.Area plane_area = + Shape.transform_area_to_board(plane_info.area.shape_list, p_par.coordinate_transform); + Layer curr_layer = (plane_info.area.shape_list.iterator().next()).layer; + if (curr_layer.no >= 0) { + int clearance_class_no; + if (plane_info.area.clearance_class_name != null) { + clearance_class_no = board.rules.clearance_matrix.get_no(plane_info.area.clearance_class_name); + if (clearance_class_no < 0) { + System.out.println("Structure.read_scope: clearance class not found"); + clearance_class_no = BoardRules.clearance_class_none(); + } + } else { + clearance_class_no = curr_net.get_class().default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.AREA); + } + int[] net_numbers = new int[1]; + net_numbers[0] = curr_net.net_number; + board.insert_conduction_area(plane_area, curr_layer.no, net_numbers, clearance_class_no, + false, FixedState.SYSTEM_FIXED); + } else { + System.out.println("Plane.read_scope: unexpected layer name"); + return false; + } + } + insert_missing_power_planes(board_construction_info.layer_info, p_par.netlist, board); + + p_par.board_handling.initialize_manual_trace_half_widths(); + if (p_par.autoroute_settings != null) { + p_par.board_handling.settings.autoroute_settings = p_par.autoroute_settings; + } + return result; + } + + private boolean create_board(ReadScopeParameter p_par, BoardConstructionInfo p_board_construction_info) { + int layer_count = p_board_construction_info.layer_info.size(); + if (layer_count == 0) { + System.out.println("Structure.create_board: layers missing in structure scope"); + return false; + } + if (p_board_construction_info.bounding_shape == null) { + // happens if the boundary shape with layer pcb is missing + if (p_board_construction_info.outline_shapes.isEmpty()) { + System.out.println("Structure.create_board: outline missing"); + p_par.board_outline_ok = false; + return false; + } + Iterator it = p_board_construction_info.outline_shapes.iterator(); + + Rectangle bounding_box = it.next().bounding_box(); + while (it.hasNext()) { + bounding_box = bounding_box.union(it.next().bounding_box()); + } + p_board_construction_info.bounding_shape = bounding_box; + } + Rectangle bounding_box = p_board_construction_info.bounding_shape.bounding_box(); + net.freerouting.board.Layer[] board_layer_arr = new net.freerouting.board.Layer[layer_count]; + Iterator it = p_board_construction_info.layer_info.iterator(); + for (int i = 0; i < layer_count; ++i) { + Layer curr_layer = it.next(); + if (curr_layer.no < 0 || curr_layer.no >= layer_count) { + System.out.println("Structure.create_board: illegal layer number"); + return false; + } + board_layer_arr[i] = new net.freerouting.board.Layer(curr_layer.name, curr_layer.is_signal); + } + net.freerouting.board.LayerStructure board_layer_structure = new net.freerouting.board.LayerStructure(board_layer_arr); + p_par.layer_structure = new LayerStructure(p_board_construction_info.layer_info); + + // Calculate an appropritate scaling between dsn coordinates and board coordinates. + int scale_factor = Math.max(p_par.resolution, 1); + + double max_coor = 0; + for (int i = 0; i < 4; ++i) { + max_coor = Math.max(max_coor, Math.abs(bounding_box.coor[i] * p_par.resolution)); + } + if (max_coor == 0) { + p_par.board_outline_ok = false; + return false; + } + // make scalefactor smaller, if there is a danger of integer overflow. + while (5 * max_coor >= net.freerouting.geometry.planar.Limits.CRIT_INT) { + scale_factor /= 10; + max_coor /= 10; + } + + p_par.coordinate_transform = new CoordinateTransform(scale_factor, 0, 0); + + IntBox bounds = (IntBox) bounding_box.transform_to_board(p_par.coordinate_transform); + bounds = bounds.offset(1000); + + Collection board_outline_shapes = new LinkedList(); + for (Shape curr_shape : p_board_construction_info.outline_shapes) { + if (curr_shape instanceof PolygonPath) { + PolygonPath curr_path = (PolygonPath) curr_shape; + if (curr_path.width != 0) { + // set the width to 0, because the offset function used in transform_to_board is not implemented + // for shapes, which are not convex. + curr_shape = new PolygonPath(curr_path.layer, 0, curr_path.coordinate_arr); + } + } + PolylineShape curr_board_shape = (PolylineShape) curr_shape.transform_to_board(p_par.coordinate_transform); + if (curr_board_shape.dimension() > 0) { + board_outline_shapes.add(curr_board_shape); + } + } + if (board_outline_shapes.isEmpty()) { + // construct an outline from the bounding_shape, if the outline is missing. + PolylineShape curr_board_shape = (PolylineShape) p_board_construction_info.bounding_shape.transform_to_board(p_par.coordinate_transform); + board_outline_shapes.add(curr_board_shape); + } + Collection hole_shapes = separate_holes(board_outline_shapes); + net.freerouting.rules.ClearanceMatrix clearance_matrix = net.freerouting.rules.ClearanceMatrix.get_default_instance(board_layer_structure, 0); + net.freerouting.rules.BoardRules board_rules = new net.freerouting.rules.BoardRules(board_layer_structure, clearance_matrix); + net.freerouting.board.Communication.SpecctraParserInfo specctra_parser_info = + new net.freerouting.board.Communication.SpecctraParserInfo(p_par.string_quote, p_par.host_cad, + p_par.host_version, p_par.constants, p_par.write_resolution, p_par.dsn_file_generated_by_host); + net.freerouting.board.Communication board_communication = + new net.freerouting.board.Communication(p_par.unit, p_par.resolution, specctra_parser_info, + p_par.coordinate_transform, p_par.item_id_no_generator, p_par.observers); + + PolylineShape[] outline_shape_arr = new PolylineShape[board_outline_shapes.size()]; + Iterator it2 = board_outline_shapes.iterator(); + for (int i = 0; i < outline_shape_arr.length; ++i) { + outline_shape_arr[i] = it2.next(); + } + update_board_rules(p_par, p_board_construction_info, board_rules); + board_rules.set_trace_angle_restriction(p_par.snap_angle); + p_par.board_handling.create_board(bounds, board_layer_structure, outline_shape_arr, + p_board_construction_info.outline_clearance_class_name, board_rules, + board_communication, p_par.test_level); + + net.freerouting.board.BasicBoard board = p_par.board_handling.get_routing_board(); + + // Insert the holes in the board outline as keepouts. + for (PolylineShape curr_outline_hole : hole_shapes) { + for (int i = 0; i < board_layer_structure.arr.length; ++i) { + board.insert_obstacle(curr_outline_hole, i, 0, FixedState.SYSTEM_FIXED); + } + } + + return true; + } + + enum KeepoutType { keepout, via_keepout, place_keepout } - private static class BoardConstructionInfo - { + private static class BoardConstructionInfo { Collection layer_info = new LinkedList(); Shape bounding_shape; @@ -1355,26 +1048,26 @@ private static class BoardConstructionInfo Collection layer_dependent_rules = new LinkedList(); } - private static class LayerRule - { + private static class LayerRule { - LayerRule(String p_layer_name, Collection p_rule) - { + final String layer_name; + final Collection rule; + LayerRule(String p_layer_name, Collection p_rule) { layer_name = p_layer_name; rule = p_rule; } - final String layer_name; - final Collection rule; } /** * Used to seperate the holes in the outline. */ - private static class OutlineShape - { + private static class OutlineShape { - public OutlineShape(PolylineShape p_shape) - { + final PolylineShape shape; + final IntBox bounding_box; + final TileShape[] convex_shapes; + boolean is_hole; + public OutlineShape(PolylineShape p_shape) { shape = p_shape; bounding_box = p_shape.bounding_box(); convex_shapes = p_shape.split_to_convex(); @@ -1384,36 +1077,26 @@ public OutlineShape(PolylineShape p_shape) /** * Returns true, if this shape contains all corners of p_other_shape. */ - private boolean contains_all_corners(OutlineShape p_other_shape) - { - if (this.convex_shapes == null) - { + private boolean contains_all_corners(OutlineShape p_other_shape) { + if (this.convex_shapes == null) { // calculation of the convex shapes failed return false; } int corner_count = p_other_shape.shape.border_line_count(); - for (int i = 0; i < corner_count; ++i) - { + for (int i = 0; i < corner_count; ++i) { Point curr_corner = p_other_shape.shape.corner(i); boolean is_contained = false; - for (int j = 0; j < this.convex_shapes.length; ++j) - { - if (this.convex_shapes[j].contains(curr_corner)) - { + for (int j = 0; j < this.convex_shapes.length; ++j) { + if (this.convex_shapes[j].contains(curr_corner)) { is_contained = true; break; } } - if (!is_contained) - { + if (!is_contained) { return false; } } return true; } - final PolylineShape shape; - final IntBox bounding_box; - final TileShape[] convex_shapes; - boolean is_hole; } } diff --git a/src/main/java/net/freerouting/designformats/specctra/Wiring.java b/src/main/java/net/freerouting/designformats/specctra/Wiring.java index dede6bb4..ea676b33 100644 --- a/src/main/java/net/freerouting/designformats/specctra/Wiring.java +++ b/src/main/java/net/freerouting/designformats/specctra/Wiring.java @@ -20,130 +20,55 @@ package net.freerouting.designformats.specctra; -import java.util.Collection; -import java.util.LinkedList; -import java.util.Iterator; - +import net.freerouting.board.*; +import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; import net.freerouting.datastructures.UndoableObjects; +import net.freerouting.geometry.planar.*; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Polyline; - -import net.freerouting.board.RoutingBoard; -import net.freerouting.board.Item; -import net.freerouting.board.Via; -import net.freerouting.board.Trace; -import net.freerouting.board.PolylineTrace; -import net.freerouting.board.FixedState; -import net.freerouting.board.ItemSelectionFilter; - -import net.freerouting.datastructures.IndentFileWriter; -import net.freerouting.datastructures.IdentifierType; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; /** * Class for reading and writing wiring scopes from dsn-files. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -class Wiring extends ScopeKeyword -{ - - /** Creates a new instance of Wiring */ - public Wiring() - { +class Wiring extends ScopeKeyword { + + /** + * Creates a new instance of Wiring + */ + public Wiring() { super("wiring"); } - - public boolean read_scope(ReadScopeParameter p_par) - { - Object next_token = null; - for (;;) - { - Object prev_token = next_token; - try - { - next_token = p_par.scanner.next_token(); - } - catch (java.io.IOException e) - { - System.out.println("Wiring.read_scope: IO error scanning file"); - return false; - } - if (next_token == null) - { - System.out.println("Wiring.read_scope: unexpected end of file"); - return false; - } - if (next_token == CLOSED_BRACKET) - { - // end of scope - break; - } - boolean read_ok = true; - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.WIRE) - { - read_wire_scope(p_par); - } - else if (next_token == Keyword.VIA) - { - read_ok = read_via_scope(p_par); - } - else - { - skip_scope(p_par.scanner); - } - } - if (!read_ok) - { - return false; - } - } - RoutingBoard board = p_par.board_handling.get_routing_board(); - for (int i = 1; i <= board.rules.nets.max_net_no(); ++i) - { - board.normalize_traces(i); - } - return true; - } - - public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException - { + + public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException { p_par.file.start_scope(); p_par.file.write("wiring"); // write the wires Collection board_wires = p_par.board.get_traces(); Iterator it = board_wires.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { write_wire_scope(p_par, it.next()); } Collection board_vias = p_par.board.get_vias(); - for (Via curr_via : board_vias) - { + for (Via curr_via : board_vias) { write_via_scope(p_par, curr_via); } // write the conduction areas Iterator it2 = p_par.board.item_list.start_read_object(); - for(;;) - { + for (; ; ) { Object curr_ob = p_par.board.item_list.read_object(it2); - if (curr_ob == null) - { + if (curr_ob == null) { break; } - if (!(curr_ob instanceof net.freerouting.board.ConductionArea)) - { + if (!(curr_ob instanceof net.freerouting.board.ConductionArea)) { continue; } net.freerouting.board.ConductionArea curr_area = (net.freerouting.board.ConductionArea) curr_ob; - if (!(p_par.board.layer_structure.arr [curr_area.get_layer()].is_signal)) - { + if (!(p_par.board.layer_structure.arr[curr_area.get_layer()].is_signal)) { // This conduction areas arw written in the structure scope. continue; } @@ -151,34 +76,28 @@ public static void write_scope(WriteScopeParameter p_par) throws java.io.IOExcep } p_par.file.end_scope(); } - - private static void write_via_scope(WriteScopeParameter p_par, Via p_via) throws java.io.IOException - { + + private static void write_via_scope(WriteScopeParameter p_par, Via p_via) throws java.io.IOException { net.freerouting.library.Padstack via_padstack = p_via.get_padstack(); FloatPoint via_location = p_via.get_center().to_float(); - double [] via_coor = p_par.coordinate_transform.board_to_dsn(via_location); + double[] via_coor = p_par.coordinate_transform.board_to_dsn(via_location); int net_no; net.freerouting.rules.Net via_net; - if (p_via.net_count() > 0) - { + if (p_via.net_count() > 0) { net_no = p_via.get_net_no(0); via_net = p_par.board.rules.nets.get(net_no); - } - else - { + } else { net_no = 0; via_net = null; } p_par.file.start_scope(); p_par.file.write("via "); p_par.identifier_type.write(via_padstack.name, p_par.file); - for (int i = 0; i < via_coor.length; ++i) - { + for (int i = 0; i < via_coor.length; ++i) { p_par.file.write(" "); p_par.file.write((new Double(via_coor[i])).toString()); } - if (via_net != null) - { + if (via_net != null) { write_net(via_net, p_par.file, p_par.identifier_type); } Rule.write_item_clearance_class(p_par.board.rules.clearance_matrix.get_name(p_via.clearance_class_no()), @@ -186,11 +105,9 @@ private static void write_via_scope(WriteScopeParameter p_par, Via p_via) throws write_fixed_state(p_par.file, p_via.get_fixed_state()); p_par.file.end_scope(); } - - private static void write_wire_scope(WriteScopeParameter p_par, Trace p_wire) throws java.io.IOException - { - if (!(p_wire instanceof PolylineTrace)) - { + + private static void write_wire_scope(WriteScopeParameter p_par, Trace p_wire) throws java.io.IOException { + if (!(p_wire instanceof PolylineTrace)) { System.out.println("Wiring.write_wire_scope: trace type not yet implemented"); return; } @@ -200,33 +117,27 @@ private static void write_wire_scope(WriteScopeParameter p_par, Trace p_wire) th Layer curr_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal); double wire_width = p_par.coordinate_transform.board_to_dsn(2 * curr_wire.get_half_width()); net.freerouting.rules.Net wire_net = null; - if (curr_wire.net_count() > 0) - { + if (curr_wire.net_count() > 0) { wire_net = p_par.board.rules.nets.get(curr_wire.get_net_no(0)); } - if (wire_net == null) - { + if (wire_net == null) { System.out.println("Wiring.write_wire_scope: net not found"); return; } p_par.file.start_scope(); p_par.file.write("wire"); - - if(p_par.compat_mode) - { + + if (p_par.compat_mode) { Point[] corner_arr = curr_wire.polyline().corner_arr(); - FloatPoint[] float_corner_arr = new FloatPoint [corner_arr.length]; - for (int i = 0; i < corner_arr.length; ++i) - { + FloatPoint[] float_corner_arr = new FloatPoint[corner_arr.length]; + for (int i = 0; i < corner_arr.length; ++i) { float_corner_arr[i] = corner_arr[i].to_float(); } - double [] coors = p_par.coordinate_transform.board_to_dsn(float_corner_arr); + double[] coors = p_par.coordinate_transform.board_to_dsn(float_corner_arr); PolygonPath curr_path = new PolygonPath(curr_layer, wire_width, coors); curr_path.write_scope(p_par.file, p_par.identifier_type); - } - else - { - double [] coors = p_par.coordinate_transform.board_to_dsn(curr_wire.polyline().arr); + } else { + double[] coors = p_par.coordinate_transform.board_to_dsn(curr_wire.polyline().arr); PolylinePath curr_path = new PolylinePath(curr_layer, wire_width, coors); curr_path.write_scope(p_par.file, p_par.identifier_type); } @@ -236,41 +147,34 @@ private static void write_wire_scope(WriteScopeParameter p_par, Trace p_wire) th write_fixed_state(p_par.file, curr_wire.get_fixed_state()); p_par.file.end_scope(); } - - private static void write_conduction_area_scope(WriteScopeParameter p_par, net.freerouting.board.ConductionArea p_conduction_area) throws java.io.IOException - { + + private static void write_conduction_area_scope(WriteScopeParameter p_par, net.freerouting.board.ConductionArea p_conduction_area) throws java.io.IOException { int net_count = p_conduction_area.net_count(); - if (net_count <= 0 || net_count > 1) - { + if (net_count <= 0 || net_count > 1) { System.out.println("Plane.write_scope: unexpected net count"); return; } net.freerouting.rules.Net curr_net = p_par.board.rules.nets.get(p_conduction_area.get_net_no(0)); net.freerouting.geometry.planar.Area curr_area = p_conduction_area.get_area(); int layer_no = p_conduction_area.get_layer(); - net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[ layer_no]; + net.freerouting.board.Layer board_layer = p_par.board.layer_structure.arr[layer_no]; Layer conduction_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal); net.freerouting.geometry.planar.Shape boundary_shape; - net.freerouting.geometry.planar.Shape [] holes; - if (curr_area instanceof net.freerouting.geometry.planar.Shape) - { + net.freerouting.geometry.planar.Shape[] holes; + if (curr_area instanceof net.freerouting.geometry.planar.Shape) { boundary_shape = (net.freerouting.geometry.planar.Shape) curr_area; - holes = new net.freerouting.geometry.planar.Shape [0]; - } - else - { + holes = new net.freerouting.geometry.planar.Shape[0]; + } else { boundary_shape = curr_area.get_border(); holes = curr_area.get_holes(); } p_par.file.start_scope(); p_par.file.write("wire "); Shape dsn_shape = p_par.coordinate_transform.board_to_dsn(boundary_shape, conduction_layer); - if (dsn_shape != null) - { + if (dsn_shape != null) { dsn_shape.write_scope(p_par.file, p_par.identifier_type); } - for (int i = 0; i < holes.length; ++i) - { + for (int i = 0; i < holes.length; ++i) { Shape dsn_hole = p_par.coordinate_transform.board_to_dsn(holes[i], conduction_layer); dsn_hole.write_hole_scope(p_par.file, p_par.identifier_type); } @@ -279,39 +183,151 @@ private static void write_conduction_area_scope(WriteScopeParameter p_par, net.f p_par.file, p_par.identifier_type); p_par.file.end_scope(); } - - static private void write_net(net.freerouting.rules.Net p_net, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException - { + + static private void write_net(net.freerouting.rules.Net p_net, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException { p_file.new_line(); p_file.write("("); Net.write_net_id(p_net, p_file, p_identifier_type); p_file.write(")"); } - - static private void write_fixed_state(IndentFileWriter p_file, FixedState p_fixed_state) throws java.io.IOException - { - if (p_fixed_state == FixedState.UNFIXED) - { + + static private void write_fixed_state(IndentFileWriter p_file, FixedState p_fixed_state) throws java.io.IOException { + if (p_fixed_state == FixedState.UNFIXED) { return; } p_file.new_line(); p_file.write("(type "); - if (p_fixed_state == FixedState.SHOVE_FIXED) - { + if (p_fixed_state == FixedState.SHOVE_FIXED) { p_file.write("shove_fixed)"); - } - else if (p_fixed_state == FixedState.SYSTEM_FIXED) - { + } else if (p_fixed_state == FixedState.SYSTEM_FIXED) { p_file.write("fix)"); - } - else - { + } else { p_file.write("protect)"); } } - - private Item read_wire_scope(ReadScopeParameter p_par) - { + + private static Collection get_subnets(Net.Id p_net_id, net.freerouting.rules.BoardRules p_rules) { + Collection found_nets = new LinkedList(); + if (p_net_id != null) { + if (p_net_id.subnet_number > 0) { + net.freerouting.rules.Net found_net = p_rules.nets.get(p_net_id.name, p_net_id.subnet_number); + if (found_net != null) { + found_nets.add(found_net); + } + } else { + found_nets = p_rules.nets.get(p_net_id.name); + } + } + return found_nets; + } + + private static boolean via_exists(IntPoint p_location, net.freerouting.library.Padstack p_padstack, + int[] p_net_no_arr, net.freerouting.board.BasicBoard p_board) { + ItemSelectionFilter filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.VIAS); + int from_layer = p_padstack.from_layer(); + int to_layer = p_padstack.to_layer(); + Collection picked_items = p_board.pick_items(p_location, p_padstack.from_layer(), filter); + for (Item curr_item : picked_items) { + Via curr_via = (Via) curr_item; + if (curr_via.nets_equal(p_net_no_arr) && curr_via.get_center().equals(p_location) + && curr_via.first_layer() == from_layer && curr_via.last_layer() == to_layer) { + return true; + } + } + return false; + } + + static net.freerouting.board.FixedState calc_fixed(Scanner p_scanner) { + try { + net.freerouting.board.FixedState result = net.freerouting.board.FixedState.UNFIXED; + Object next_token = p_scanner.next_token(); + if (next_token == Keyword.SHOVE_FIXED) { + result = net.freerouting.board.FixedState.SHOVE_FIXED; + } else if (next_token == Keyword.FIX) { + result = net.freerouting.board.FixedState.SYSTEM_FIXED; + } else if (next_token != Keyword.NORMAL) { + result = net.freerouting.board.FixedState.USER_FIXED; + } + next_token = p_scanner.next_token(); + if (next_token != Keyword.CLOSED_BRACKET) { + System.out.println("Wiring.is_fixed: ) expected"); + return net.freerouting.board.FixedState.UNFIXED; + } + return result; + } catch (java.io.IOException e) { + System.out.println("Wiring.is_fixed: IO error scanning file"); + return net.freerouting.board.FixedState.UNFIXED; + } + } + + /** + * Reads a net_id. The subnet_number of the net_id will be 0, if no subneet_number was found. + */ + private static Net.Id read_net_id(Scanner p_scanner) { + try { + int subnet_number = 0; + p_scanner.yybegin(SpecctraFileScanner.NAME); + Object next_token = p_scanner.next_token(); + if (!(next_token instanceof String)) { + System.out.println("Wiring:read_net_id: String expected"); + return null; + } + String net_name = (String) next_token; + next_token = p_scanner.next_token(); + if (next_token instanceof Integer) { + subnet_number = (Integer) next_token; + next_token = p_scanner.next_token(); + } + if (next_token != Keyword.CLOSED_BRACKET) { + System.out.println("Wiring.read_net_id: closing bracket expected"); + } + return new Net.Id(net_name, subnet_number); + } catch (java.io.IOException e) { + System.out.println("DsnFile.read_string_scope: IO error scanning file"); + return null; + } + } + + public boolean read_scope(ReadScopeParameter p_par) { + Object next_token = null; + for (; ; ) { + Object prev_token = next_token; + try { + next_token = p_par.scanner.next_token(); + } catch (java.io.IOException e) { + System.out.println("Wiring.read_scope: IO error scanning file"); + return false; + } + if (next_token == null) { + System.out.println("Wiring.read_scope: unexpected end of file"); + return false; + } + if (next_token == CLOSED_BRACKET) { + // end of scope + break; + } + boolean read_ok = true; + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.WIRE) { + read_wire_scope(p_par); + } else if (next_token == Keyword.VIA) { + read_ok = read_via_scope(p_par); + } else { + skip_scope(p_par.scanner); + } + } + if (!read_ok) { + return false; + } + } + RoutingBoard board = p_par.board_handling.get_routing_board(); + for (int i = 1; i <= board.rules.nets.max_net_no(); ++i) { + board.normalize_traces(i); + } + return true; + } + + private Item read_wire_scope(ReadScopeParameter p_par) { Net.Id net_id = null; String clearance_class_name = null; net.freerouting.board.FixedState fixed = net.freerouting.board.FixedState.UNFIXED; @@ -319,146 +335,104 @@ private Item read_wire_scope(ReadScopeParameter p_par) Shape border_shape = null; // Used, if a conduction area is read. Collection hole_list = new LinkedList(); Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; - try - { + try { next_token = p_par.scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Wiring.read_wire_scope: IO error scanning file"); return null; } - if (next_token == null) - { + if (next_token == null) { System.out.println("Wiring.read_wire_scope: unexpected end of file"); return null; } - if (next_token == CLOSED_BRACKET) - { + if (next_token == CLOSED_BRACKET) { // end of scope break; } - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.POLYGON_PATH) - { + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.POLYGON_PATH) { path = Shape.read_polygon_path_scope(p_par.scanner, p_par.layer_structure); - } - else if (next_token == Keyword.POLYLINE_PATH) - { + } else if (next_token == Keyword.POLYLINE_PATH) { path = Shape.read_polyline_path_scope(p_par.scanner, p_par.layer_structure); - } - else if (next_token == Keyword.RECTANGLE) - { - + } else if (next_token == Keyword.RECTANGLE) { + border_shape = Shape.read_rectangle_scope(p_par.scanner, p_par.layer_structure); - } - else if (next_token == Keyword.POLYGON) - { - + } else if (next_token == Keyword.POLYGON) { + border_shape = Shape.read_polygon_scope(p_par.scanner, p_par.layer_structure); - } - else if (next_token == Keyword.CIRCLE) - { - + } else if (next_token == Keyword.CIRCLE) { + border_shape = Shape.read_circle_scope(p_par.scanner, p_par.layer_structure); - } - else if (next_token == Keyword.WINDOW) - { + } else if (next_token == Keyword.WINDOW) { Shape hole_shape = Shape.read_scope(p_par.scanner, p_par.layer_structure); hole_list.add(hole_shape); // overread the closing bracket - try - { + try { next_token = p_par.scanner.next_token(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Wiring.read_wire_scope: IO error scanning file"); return null; } - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("Wiring.read_wire_scope: closing bracket expected"); return null; } - } - else if (next_token == Keyword.NET) - { + } else if (next_token == Keyword.NET) { net_id = read_net_id(p_par.scanner); - } - else if (next_token == Keyword.CLEARANCE_CLASS) - { + } else if (next_token == Keyword.CLEARANCE_CLASS) { clearance_class_name = DsnFile.read_string_scope(p_par.scanner); - } - else if (next_token == Keyword.TYPE) - { + } else if (next_token == Keyword.TYPE) { fixed = calc_fixed(p_par.scanner); - } - else - { + } else { skip_scope(p_par.scanner); } } } - if (path == null && border_shape == null) - { + if (path == null && border_shape == null) { System.out.println("Wiring.read_wire_scope: shape missing"); return null; } RoutingBoard board = p_par.board_handling.get_routing_board(); - + net.freerouting.rules.NetClass net_class = board.rules.get_default_net_class(); Collection found_nets = get_subnets(net_id, board.rules); int[] net_no_arr = new int[found_nets.size()]; int curr_index = 0; - for (net.freerouting.rules.Net curr_net : found_nets) - { + for (net.freerouting.rules.Net curr_net : found_nets) { net_no_arr[curr_index] = curr_net.net_number; net_class = curr_net.get_class(); ++curr_index; } int clearance_class_no = -1; - if (clearance_class_name != null) - { + if (clearance_class_name != null) { clearance_class_no = board.rules.clearance_matrix.get_no(clearance_class_name); } int layer_no; int half_width; - if (path != null) - { + if (path != null) { layer_no = path.layer.no; half_width = (int) Math.round(p_par.coordinate_transform.dsn_to_board(path.width / 2)); - } - else - { + } else { layer_no = border_shape.layer.no; half_width = 0; } - if (layer_no < 0 || layer_no >= board.get_layer_count()) - { + if (layer_no < 0 || layer_no >= board.get_layer_count()) { System.out.print("Wiring.read_wire_scope: unexpected layer "); - if (path != null) - { + if (path != null) { System.out.println(path.layer.name); - } - else - { + } else { System.out.println(border_shape.layer.name); } return null; } - + IntBox bounding_box = board.get_bounding_box(); - + Item result = null; - if (border_shape != null) - { - if (clearance_class_no < 0) - { + if (border_shape != null) { + if (clearance_class_no < 0) { clearance_class_no = net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.AREA); } @@ -469,23 +443,18 @@ else if (next_token == Keyword.TYPE) Shape.transform_area_to_board(area, p_par.coordinate_transform); result = board.insert_conduction_area(conduction_area, layer_no, net_no_arr, clearance_class_no, false, fixed); - } - else if (path instanceof PolygonPath) - { - if (clearance_class_no < 0) - { + } else if (path instanceof PolygonPath) { + if (clearance_class_no < 0) { clearance_class_no = net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.TRACE); } - IntPoint [] corner_arr = new IntPoint[path.coordinate_arr.length / 2]; - double [] curr_point = new double [2]; - for (int i = 0; i < corner_arr.length; ++i) - { + IntPoint[] corner_arr = new IntPoint[path.coordinate_arr.length / 2]; + double[] curr_point = new double[2]; + for (int i = 0; i < corner_arr.length; ++i) { curr_point[0] = path.coordinate_arr[2 * i]; curr_point[1] = path.coordinate_arr[2 * i + 1]; - FloatPoint curr_corner = p_par.coordinate_transform.dsn_to_board(curr_point); - if (!bounding_box.contains(curr_corner)) - { + FloatPoint curr_corner = p_par.coordinate_transform.dsn_to_board(curr_point); + if (!bounding_box.contains(curr_corner)) { System.out.println("Wiring.read_wire_scope: wire corner outside board"); return null; } @@ -494,293 +463,143 @@ else if (path instanceof PolygonPath) Polyline trace_polyline = new Polyline(corner_arr); // Traces are not yet normalized here because cycles may be removed premature. result = board.insert_trace_without_cleaning(trace_polyline, layer_no, half_width, net_no_arr, clearance_class_no, fixed); - } - else if (path instanceof PolylinePath) - { - if (clearance_class_no < 0) - { + } else if (path instanceof PolylinePath) { + if (clearance_class_no < 0) { clearance_class_no = net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.TRACE); } - Line [] line_arr = new Line[path.coordinate_arr.length / 4]; - double [] curr_point = new double [2]; - for (int i = 0; i < line_arr.length; ++i) - { + Line[] line_arr = new Line[path.coordinate_arr.length / 4]; + double[] curr_point = new double[2]; + for (int i = 0; i < line_arr.length; ++i) { curr_point[0] = path.coordinate_arr[4 * i]; curr_point[1] = path.coordinate_arr[4 * i + 1]; - FloatPoint curr_a = p_par.coordinate_transform.dsn_to_board(curr_point); + FloatPoint curr_a = p_par.coordinate_transform.dsn_to_board(curr_point); curr_point[0] = path.coordinate_arr[4 * i + 2]; curr_point[1] = path.coordinate_arr[4 * i + 3]; - FloatPoint curr_b = p_par.coordinate_transform.dsn_to_board(curr_point); + FloatPoint curr_b = p_par.coordinate_transform.dsn_to_board(curr_point); line_arr[i] = new Line(curr_a.round(), curr_b.round()); } Polyline trace_polyline = new Polyline(line_arr); result = board.insert_trace_without_cleaning(trace_polyline, layer_no, half_width, net_no_arr, clearance_class_no, fixed); - } - else - { + } else { System.out.println("Wiring.read_wire_scope: unexpected Path subclass"); return null; } - if (result != null && result.net_count() == 0) - { + if (result != null && result.net_count() == 0) { try_correct_net(result); } return result; } - + /** * Maybe trace of type turret without net in Mentor design. * Try to assig the net by calculating the overlaps. */ - private void try_correct_net(Item p_item) - { - if (!(p_item instanceof Trace)) - { + private void try_correct_net(Item p_item) { + if (!(p_item instanceof Trace)) { return; } Trace curr_trace = (Trace) p_item; java.util.Set contacts = curr_trace.get_normal_contacts(curr_trace.first_corner(), true); contacts.addAll(curr_trace.get_normal_contacts(curr_trace.last_corner(), true)); int corrected_net_no = 0; - for (Item curr_contact : contacts) - { - if (curr_contact.net_count() == 1) - { + for (Item curr_contact : contacts) { + if (curr_contact.net_count() == 1) { corrected_net_no = curr_contact.get_net_no(0); break; } } - if (corrected_net_no != 0) - { + if (corrected_net_no != 0) { p_item.assign_net_no(corrected_net_no); } } - - private static Collection get_subnets(Net.Id p_net_id, net.freerouting.rules.BoardRules p_rules) - { - Collection found_nets = new LinkedList(); - if (p_net_id != null) - { - if (p_net_id.subnet_number > 0) - { - net.freerouting.rules.Net found_net = p_rules.nets.get(p_net_id.name, p_net_id.subnet_number); - if (found_net != null) - { - found_nets.add(found_net); - } - } - else - { - found_nets = p_rules.nets.get(p_net_id.name); - } - } - return found_nets; - } - - private boolean read_via_scope(ReadScopeParameter p_par) - { - try - { + + private boolean read_via_scope(ReadScopeParameter p_par) { + try { net.freerouting.board.FixedState fixed = net.freerouting.board.FixedState.UNFIXED; // read the padstack name Object next_token = p_par.scanner.next_token(); - if (!(next_token instanceof String)) - { + if (!(next_token instanceof String)) { System.out.println("Wiring.read_via_scope: padstack name expected"); return false; } String padstack_name = (String) next_token; // read the location - double []location = new double [2]; - for (int i = 0; i < 2; ++i) - { + double[] location = new double[2]; + for (int i = 0; i < 2; ++i) { next_token = p_par.scanner.next_token(); - if (next_token instanceof Double) - { + if (next_token instanceof Double) { location[i] = ((Double) next_token).doubleValue(); - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { location[i] = ((Integer) next_token).intValue(); - } - else - { + } else { System.out.println("Wiring.read_via_scope: number expected"); return false; } } Net.Id net_id = null; String clearance_class_name = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = p_par.scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { System.out.println("Wiring.read_via_scope: unexpected end of file"); return false; } - if (next_token == CLOSED_BRACKET) - { + if (next_token == CLOSED_BRACKET) { // end of scope break; } - if (prev_token == OPEN_BRACKET) - { - if (next_token == Keyword.NET) - { + if (prev_token == OPEN_BRACKET) { + if (next_token == Keyword.NET) { net_id = read_net_id(p_par.scanner); - } - else if (next_token == Keyword.CLEARANCE_CLASS) - { + } else if (next_token == Keyword.CLEARANCE_CLASS) { clearance_class_name = DsnFile.read_string_scope(p_par.scanner); - } - else if (next_token == Keyword.TYPE) - { + } else if (next_token == Keyword.TYPE) { fixed = calc_fixed(p_par.scanner); - } - else - { + } else { skip_scope(p_par.scanner); } } } RoutingBoard board = p_par.board_handling.get_routing_board(); net.freerouting.library.Padstack curr_padstack = board.library.padstacks.get(padstack_name); - if (curr_padstack == null) - { + if (curr_padstack == null) { System.out.println("Wiring.read_via_scope: via padstack not found"); return false; } net.freerouting.rules.NetClass net_class = board.rules.get_default_net_class(); Collection found_nets = get_subnets(net_id, board.rules); - if (net_id != null && found_nets.isEmpty()) - { + if (net_id != null && found_nets.isEmpty()) { System.out.print("Wiring.read_via_scope: net with name "); System.out.print(net_id.name); System.out.println(" not found"); } int[] net_no_arr = new int[found_nets.size()]; int curr_index = 0; - for (net.freerouting.rules.Net curr_net : found_nets) - { + for (net.freerouting.rules.Net curr_net : found_nets) { net_no_arr[curr_index] = curr_net.net_number; net_class = curr_net.get_class(); } int clearance_class_no = -1; - if (clearance_class_name != null) - { + if (clearance_class_name != null) { clearance_class_no = board.rules.clearance_matrix.get_no(clearance_class_name); } - if (clearance_class_no < 0) - { - clearance_class_no = net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.VIA); + if (clearance_class_no < 0) { + clearance_class_no = net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.VIA); } IntPoint board_location = p_par.coordinate_transform.dsn_to_board(location).round(); - if (via_exists(board_location, curr_padstack, net_no_arr, board)) - { + if (via_exists(board_location, curr_padstack, net_no_arr, board)) { System.out.print("Multiple via skipped at ("); System.out.println(board_location.x + ", " + board_location.y + ")"); - } - else - { + } else { boolean attach_allowed = p_par.via_at_smd_allowed && curr_padstack.attach_allowed; board.insert_via(curr_padstack, board_location, net_no_arr, clearance_class_no, fixed, attach_allowed); } return true; - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("Wiring.read_via_scope: IO error scanning file"); return false; } } - - private static boolean via_exists(IntPoint p_location, net.freerouting.library.Padstack p_padstack, - int[] p_net_no_arr, net.freerouting.board.BasicBoard p_board) - { - ItemSelectionFilter filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.VIAS); - int from_layer = p_padstack.from_layer(); - int to_layer = p_padstack.to_layer(); - Collection picked_items = p_board.pick_items(p_location, p_padstack.from_layer(), filter); - for (Item curr_item : picked_items) - { - Via curr_via = (Via) curr_item; - if (curr_via.nets_equal(p_net_no_arr) && curr_via.get_center().equals(p_location) - && curr_via.first_layer() == from_layer && curr_via.last_layer() == to_layer) - { - return true; - } - } - return false; - } - - static net.freerouting.board.FixedState calc_fixed(Scanner p_scanner) - { - try - { - net.freerouting.board.FixedState result = net.freerouting.board.FixedState.UNFIXED; - Object next_token = p_scanner.next_token(); - if (next_token == Keyword.SHOVE_FIXED) - { - result = net.freerouting.board.FixedState.SHOVE_FIXED; - } - else if (next_token == Keyword.FIX) - { - result = net.freerouting.board.FixedState.SYSTEM_FIXED; - } - else if (next_token != Keyword.NORMAL) - { - result = net.freerouting.board.FixedState.USER_FIXED; - } - next_token = p_scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { - System.out.println("Wiring.is_fixed: ) expected"); - return net.freerouting.board.FixedState.UNFIXED; - } - return result; - } - catch (java.io.IOException e) - { - System.out.println("Wiring.is_fixed: IO error scanning file"); - return net.freerouting.board.FixedState.UNFIXED; - } - } - - /** - * Reads a net_id. The subnet_number of the net_id will be 0, if no subneet_number was found. - */ - private static Net.Id read_net_id(Scanner p_scanner) - { - try - { - int subnet_number = 0; - p_scanner.yybegin(SpecctraFileScanner.NAME); - Object next_token = p_scanner.next_token(); - if (!(next_token instanceof String)) - { - System.out.println("Wiring:read_net_id: String expected"); - return null; - } - String net_name = (String) next_token; - next_token = p_scanner.next_token(); - if (next_token instanceof Integer) - { - subnet_number = (Integer) next_token; - next_token = p_scanner.next_token(); - } - if (next_token != Keyword.CLOSED_BRACKET) - { - System.out.println("Wiring.read_net_id: closing bracket expected"); - } - return new Net.Id(net_name, subnet_number); - } - catch (java.io.IOException e) - { - System.out.println("DsnFile.read_string_scope: IO error scanning file"); - return null; - } - } } diff --git a/src/main/java/net/freerouting/designformats/specctra/WriteScopeParameter.java b/src/main/java/net/freerouting/designformats/specctra/WriteScopeParameter.java index 5fcd56cc..863e1e38 100644 --- a/src/main/java/net/freerouting/designformats/specctra/WriteScopeParameter.java +++ b/src/main/java/net/freerouting/designformats/specctra/WriteScopeParameter.java @@ -21,26 +21,30 @@ package net.freerouting.designformats.specctra; import net.freerouting.board.BasicBoard; -import net.freerouting.datastructures.IndentFileWriter; import net.freerouting.datastructures.IdentifierType; +import net.freerouting.datastructures.IndentFileWriter; /** * Default parameter type used while writing a Specctra dsn-file. * - * @author alfons + * @author alfons */ -public class WriteScopeParameter -{ - - /** - * Creates a new instance of WriteScopeParameter. +public class WriteScopeParameter { + + final BasicBoard board; + final net.freerouting.interactive.AutorouteSettings autoroute_settings; + final IndentFileWriter file; + final CoordinateTransform coordinate_transform; + final boolean compat_mode; + final IdentifierType identifier_type; + /** + * Creates a new instance of WriteScopeParameter. * If p_compat_mode is true, only standard speecctra dsb scopes are written, so that any * host system with an specctra interface can read them. */ WriteScopeParameter(BasicBoard p_board, net.freerouting.interactive.AutorouteSettings p_autoroute_settings, - IndentFileWriter p_file, String p_string_quote, CoordinateTransform p_coordinate_transform, - boolean p_compat_mode) - { + IndentFileWriter p_file, String p_string_quote, CoordinateTransform p_coordinate_transform, + boolean p_compat_mode) { board = p_board; autoroute_settings = p_autoroute_settings; file = p_file; @@ -49,11 +53,4 @@ public class WriteScopeParameter String[] reserved_chars = {"(", ")", " ", ";", "-", "_"}; identifier_type = new IdentifierType(reserved_chars, p_string_quote); } - - final BasicBoard board; - final net.freerouting.interactive.AutorouteSettings autoroute_settings; - final IndentFileWriter file; - final CoordinateTransform coordinate_transform; - final boolean compat_mode; - final IdentifierType identifier_type; } diff --git a/src/main/java/net/freerouting/designformats/specctra/package.html b/src/main/java/net/freerouting/designformats/specctra/package.html index edaee0ba..562626c0 100644 --- a/src/main/java/net/freerouting/designformats/specctra/package.html +++ b/src/main/java/net/freerouting/designformats/specctra/package.html @@ -1,5 +1,6 @@ -java.text package - Contains classes for reading and writing board designs in the Specctra dsn text format. - \ No newline at end of file +Contains classes for reading and writing board designs in the Specctra dsn text format. + + \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/Area.java b/src/main/java/net/freerouting/geometry/planar/Area.java index 315efcc4..5a76852f 100644 --- a/src/main/java/net/freerouting/geometry/planar/Area.java +++ b/src/main/java/net/freerouting/geometry/planar/Area.java @@ -27,19 +27,18 @@ * * @author Alfons Wirtz */ -public interface Area -{ +public interface Area { /** * returns true, if the area is empty */ boolean is_empty(); - - + + /** * returns true, if the area is contained in a sufficiently large box */ boolean is_bounded(); - + /** * returns 2, if the area contains 2 dimensional shapes , * 1, if it contains curves, @@ -47,37 +46,37 @@ public interface Area * -1, if it is empty. */ int dimension(); - - + + /** * Checks, if this area is completely contained in p_box. */ boolean is_contained_in(IntBox p_box); - + /** * returns the border shape of this area */ Shape get_border(); - + /** * Returns the array of holes, of this area. */ Shape[] get_holes(); - + /** * Returns the smallest surrounding box of the area. * If the area is not bounded, some coordinates of the resulting * box may be equal Integer.MAX_VALUE */ IntBox bounding_box(); - + /** * Returns the smallest surrounding octagon of the area. * If the area is not bounded, some coordinates of the resulting * octagon may be equal Integer.MAX_VALUE */ IntOctagon bounding_octagon(); - + /** * Returns true, if p_point is contained in this area, * but not inside a hole. @@ -85,51 +84,51 @@ public interface Area * because of numerical inacurracy. */ boolean contains(FloatPoint p_point); - + /** * Returns true, if p_point is inside or on the border * of this area, but not inside a hole. */ boolean contains(Point p_point); - + /** * Calculates an approximation of the nearest point of the shape * to p_from_point */ FloatPoint nearest_point_approx(FloatPoint p_ftom_point); - + /** * Turns this area by p_factor times 90 degree around p_pole. */ Area turn_90_degree(int p_factor, IntPoint p_pole); - + /** * Rotates the area around p_pole by p_angle. * The result may be not exact. - */ + */ Area rotate_approx(double p_angle, FloatPoint p_pole); - + /** * Returns the affine translation of the area by p_vector */ Area translate_by(Vector p_vector); - + /** * Mirrors this area at the horizontal line through p_pole. */ Area mirror_horizontal(IntPoint p_pole); - - + + /** * Mirrors this area at the vertical line through p_pole. */ - Area mirror_vertical (IntPoint p_pole); - + Area mirror_vertical(IntPoint p_pole); + /** * Returns an approximation of the corners of this area. */ FloatPoint[] corner_approx_arr(); - + /** * Returns a division of this area into convex pieces. */ diff --git a/src/main/java/net/freerouting/geometry/planar/BigIntDirection.java b/src/main/java/net/freerouting/geometry/planar/BigIntDirection.java index c3f6c70a..342c7fc7 100644 --- a/src/main/java/net/freerouting/geometry/planar/BigIntDirection.java +++ b/src/main/java/net/freerouting/geometry/planar/BigIntDirection.java @@ -19,63 +19,54 @@ */ package net.freerouting.geometry.planar; + import java.math.BigInteger; /** - * * Implements the abstract class Direction as a tuple * of infinite precision integers. * - * * @author Alfons Wirtz */ -public class BigIntDirection extends Direction implements java.io.Serializable -{ - public boolean is_orthogonal() - { - return (x.signum() == 0 || y.signum() == 0); - } - - public boolean is_diagonal() - { - return x.abs().equals(y.abs()); - } - - public Vector get_vector() - { - return new RationalVector(x, y, BigInteger.ONE); - } - - public Direction turn_45_degree(int p_factor) - { - System.out.println("BigIntDirection: turn_45_degree not yet implemented"); - return this; - } - - public Direction opposite() - { - return new BigIntDirection(x.negate(), y.negate()); - } - +public class BigIntDirection extends Direction implements java.io.Serializable { final BigInteger x; final BigInteger y; - - BigIntDirection(BigInteger p_x, BigInteger p_y) - { + + BigIntDirection(BigInteger p_x, BigInteger p_y) { x = p_x; y = p_y; } - + /** * creates a BigIntDirection from an IntDirection */ - BigIntDirection(IntDirection p_dir) - { + BigIntDirection(IntDirection p_dir) { x = BigInteger.valueOf(p_dir.x); y = BigInteger.valueOf(p_dir.y); } - + + public boolean is_orthogonal() { + return (x.signum() == 0 || y.signum() == 0); + } + + public boolean is_diagonal() { + return x.abs().equals(y.abs()); + } + + public Vector get_vector() { + return new RationalVector(x, y, BigInteger.ONE); + } + + public Direction turn_45_degree(int p_factor) { + System.out.println("BigIntDirection: turn_45_degree not yet implemented"); + return this; + } + + public Direction opposite() { + return new BigIntDirection(x.negate(), y.negate()); + } + /** * Implements the Comparable interface. * Returns 1, if this direction has a strict bigger angle with @@ -84,70 +75,55 @@ public Direction opposite() * and -1 otherwise. * Throws an exception, if p_other_direction is not a Direction. */ - public int compareTo(Direction p_other_direction) - { + public int compareTo(Direction p_other_direction) { return -p_other_direction.compareTo(this); } - - int compareTo(IntDirection p_other) - { + + int compareTo(IntDirection p_other) { BigIntDirection other = new BigIntDirection(p_other); return compareTo(other); } - - int compareTo(BigIntDirection p_other) - { + + int compareTo(BigIntDirection p_other) { int x1 = x.signum(); int y1 = y.signum(); int x2 = p_other.x.signum(); int y2 = p_other.y.signum(); - if (y1 > 0) - { - if (y2 < 0) - { - return -1 ; + if (y1 > 0) { + if (y2 < 0) { + return -1; } - if (y2 == 0) - { - if (x2 > 0) - { - return 1 ; + if (y2 == 0) { + if (x2 > 0) { + return 1; } - return -1 ; + return -1; } - } - else if (y1 < 0) - { - if (y2 >= 0) - { - return 1 ; + } else if (y1 < 0) { + if (y2 >= 0) { + return 1; } - } - else // y1 == 0 + } else // y1 == 0 { - if (x1 > 0) - { - if (y2 != 0 || x2 < 0) - { - return -1 ; + if (x1 > 0) { + if (y2 != 0 || x2 < 0) { + return -1; } - return 0 ; + return 0; } // x1 < 0 - if (y2 > 0 || y2 == 0 && x2 > 0) - { - return 1 ; + if (y2 > 0 || y2 == 0 && x2 > 0) { + return 1; } - if (y2 < 0) - { - return -1 ; + if (y2 < 0) { + return -1; } return 0; } - + // now this direction and p_other are located in the same // open horizontal half plane - + BigInteger tmp_1 = y.multiply(p_other.x); BigInteger tmp_2 = x.multiply(p_other.y); BigInteger determinant = tmp_1.subtract(tmp_2); diff --git a/src/main/java/net/freerouting/geometry/planar/Circle.java b/src/main/java/net/freerouting/geometry/planar/Circle.java index a74bc5da..3ffc073d 100644 --- a/src/main/java/net/freerouting/geometry/planar/Circle.java +++ b/src/main/java/net/freerouting/geometry/planar/Circle.java @@ -23,130 +23,112 @@ /** * Discribes functionality of a circle shape in the plane. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Circle implements ConvexShape, java.io.Serializable -{ - - /** Creates a new instance of Circle */ - public Circle(IntPoint p_center, int p_radius) - { +public class Circle implements ConvexShape, java.io.Serializable { + + public final IntPoint center; + public final int radius; + + /** + * Creates a new instance of Circle + */ + public Circle(IntPoint p_center, int p_radius) { center = p_center; - if (p_radius < 0) - { + if (p_radius < 0) { System.out.println("Circle: unexpected negative radius"); radius = -p_radius; - } - else - { + } else { radius = p_radius; } } - - public boolean is_empty() - { + + public boolean is_empty() { return false; } - - public boolean is_bounded() - { + + public boolean is_bounded() { return true; } - - public int dimension() - { - if (radius == 0) - { + + public int dimension() { + if (radius == 0) { // circle is reduced to a point return 0; } return 2; } - - public double circumference() - { - return 2.0 * Math.PI * radius; + + public double circumference() { + return 2.0 * Math.PI * radius; } - - public double area() - { - return ( Math.PI * radius) * radius; + + public double area() { + return (Math.PI * radius) * radius; } - - public FloatPoint centre_of_gravity() - { + + public FloatPoint centre_of_gravity() { return center.to_float(); } - - public boolean is_outside(Point p_point) - { + + public boolean is_outside(Point p_point) { FloatPoint fp = p_point.to_float(); return fp.distance_square(center.to_float()) > (double) radius * radius; } - - public boolean contains(Point p_point) - { + + public boolean contains(Point p_point) { return !is_outside(p_point); } - - public boolean contains_inside(Point p_point) - { + + public boolean contains_inside(Point p_point) { FloatPoint fp = p_point.to_float(); return fp.distance_square(center.to_float()) < (double) radius * radius; } - - public boolean contains_on_border(Point p_point) - { + + public boolean contains_on_border(Point p_point) { FloatPoint fp = p_point.to_float(); return fp.distance_square(center.to_float()) == (double) radius * radius; } - - public boolean contains(FloatPoint p_point) - { + + public boolean contains(FloatPoint p_point) { return p_point.distance_square(center.to_float()) <= (double) radius * radius; } - - public double distance(FloatPoint p_point) - { + + public double distance(FloatPoint p_point) { double d = p_point.distance(center.to_float()) - radius; return Math.max(d, 0.0); } - - public double smallest_radius() - { + + public double smallest_radius() { return radius; } - - public IntBox bounding_box() - { + + public IntBox bounding_box() { int llx = center.x - radius; int urx = center.x + radius; int lly = center.y - radius; int ury = center.y + radius; return new IntBox(llx, lly, urx, ury); } - - - public IntOctagon bounding_octagon() - { + + public IntOctagon bounding_octagon() { int lx = center.x - radius; int rx = center.x + radius; int ly = center.y - radius; int uy = center.y + radius; - + final double sqrt2_minus_1 = Math.sqrt(2) - 1; final int ceil_corner_value = (int) Math.ceil(sqrt2_minus_1 * radius); final int floor_corner_value = (int) Math.floor(sqrt2_minus_1 * radius); - + int ulx = lx - (center.y + floor_corner_value); int lrx = rx - (center.y - ceil_corner_value); int llx = lx + (center.y - floor_corner_value); int urx = rx + (center.y + ceil_corner_value); - return new IntOctagon(lx, ly, rx, uy, ulx, lrx, llx, urx); + return new IntOctagon(lx, ly, rx, uy, ulx, lrx, llx, urx); } - - public TileShape bounding_tile() - { + + public TileShape bounding_tile() { return bounding_octagon(); // the following caused problems with the spring_over algorithm in routing. /* if (this.precalculated_bounding_tile == null) @@ -155,30 +137,24 @@ public TileShape bounding_tile() } return this.precalculated_bounding_tile; */ } - + /** * Creates a bounding tile shape around this circle, so that the length of the * line segments of the tile is at most p_max_segment_length. */ - public TileShape bounding_tile(int p_max_segment_length) - { + public TileShape bounding_tile(int p_max_segment_length) { int quadrant_division_count = this.radius / p_max_segment_length + 1; - if (quadrant_division_count <= 2) - { + if (quadrant_division_count <= 2) { return this.bounding_octagon(); } - Line [] tangent_line_arr = new Line [quadrant_division_count * 4]; - for (int i = 0; i < quadrant_division_count; ++i) - { + Line[] tangent_line_arr = new Line[quadrant_division_count * 4]; + for (int i = 0; i < quadrant_division_count; ++i) { // calculate the tangential points in the first quadrant Vector border_delta; - if (i == 0) - { + if (i == 0) { border_delta = new IntVector(this.radius, 0); - } - else - { - double curr_angle = i * Math.PI / (2.0 * quadrant_division_count); + } else { + double curr_angle = i * Math.PI / (2.0 * quadrant_division_count); int curr_x = (int) Math.ceil(Math.sin(curr_angle) * this.radius); int curr_y = (int) Math.ceil(Math.cos(curr_angle) * this.radius); border_delta = new IntVector(curr_x, curr_y); @@ -187,204 +163,166 @@ public TileShape bounding_tile(int p_max_segment_length) Point curr_b = curr_a.turn_90_degree(1, this.center); Direction curr_dir = Direction.get_instance(curr_b.difference_by(this.center)); Line curr_tangent = new Line(curr_a, curr_dir); - tangent_line_arr [quadrant_division_count + i] = curr_tangent; - tangent_line_arr [2 * quadrant_division_count + i] = curr_tangent.turn_90_degree(1, this.center); - tangent_line_arr [3 * quadrant_division_count + i] = curr_tangent.turn_90_degree(2, this.center); - tangent_line_arr [i] = curr_tangent.turn_90_degree(3, this.center); + tangent_line_arr[quadrant_division_count + i] = curr_tangent; + tangent_line_arr[2 * quadrant_division_count + i] = curr_tangent.turn_90_degree(1, this.center); + tangent_line_arr[3 * quadrant_division_count + i] = curr_tangent.turn_90_degree(2, this.center); + tangent_line_arr[i] = curr_tangent.turn_90_degree(3, this.center); } return TileShape.get_instance(tangent_line_arr); } - - public boolean is_contained_in(IntBox p_box) - { - if (p_box.ll.x > center.x - radius) - { + + public boolean is_contained_in(IntBox p_box) { + if (p_box.ll.x > center.x - radius) { return false; } - if (p_box.ll.y > center.y - radius) - { + if (p_box.ll.y > center.y - radius) { return false; } - if (p_box.ur.x < center.x + radius) - { + if (p_box.ur.x < center.x + radius) { return false; } - if (p_box.ur.y < center.y + radius) - { + if (p_box.ur.y < center.y + radius) { return false; } return true; } - - public Circle turn_90_degree(int p_factor, IntPoint p_pole) - { + + public Circle turn_90_degree(int p_factor, IntPoint p_pole) { IntPoint new_center = (IntPoint) center.turn_90_degree(p_factor, p_pole); return new Circle(new_center, radius); } - - public Circle rotate_approx(double p_angle, FloatPoint p_pole) - { + + public Circle rotate_approx(double p_angle, FloatPoint p_pole) { IntPoint new_center = center.to_float().rotate(p_angle, p_pole).round(); return new Circle(new_center, radius); } - - - public Circle mirror_vertical(IntPoint p_pole) - { + + public Circle mirror_vertical(IntPoint p_pole) { IntPoint new_center = (IntPoint) center.mirror_vertical(p_pole); return new Circle(new_center, radius); } - - public Circle mirror_horizontal(IntPoint p_pole) - { + + public Circle mirror_horizontal(IntPoint p_pole) { IntPoint new_center = (IntPoint) center.mirror_horizontal(p_pole); return new Circle(new_center, radius); } - - public double max_width() - { + + public double max_width() { return 2 * this.radius; } - - public double min_width() - { + + public double min_width() { return 2 * this.radius; } - - public RegularTileShape bounding_shape(ShapeBoundingDirections p_dirs) - { + + public RegularTileShape bounding_shape(ShapeBoundingDirections p_dirs) { return p_dirs.bounds(this); } - - public Circle offset(double p_offset) - { + + public Circle offset(double p_offset) { double new_radius = this.radius + p_offset; int r = (int) Math.round(new_radius); return new Circle(this.center, r); } - - public Circle shrink(double p_offset) - { + + public Circle shrink(double p_offset) { double new_radius = this.radius - p_offset; - int r = Math.max((int)Math.round(new_radius), 1); + int r = Math.max((int) Math.round(new_radius), 1); return new Circle(this.center, r); } - - public Circle translate_by(Vector p_vector) - { - if (p_vector.equals(Vector.ZERO)) - { + + public Circle translate_by(Vector p_vector) { + if (p_vector.equals(Vector.ZERO)) { return this; } - if (!(p_vector instanceof IntVector)) - { + if (!(p_vector instanceof IntVector)) { System.out.println("Circle.translate_by only implemented for IntVectors till now"); return this; } IntPoint new_center = (IntPoint) center.translate_by(p_vector); return new Circle(new_center, radius); } - - - public FloatPoint nearest_point_approx(FloatPoint p_point) - { + + public FloatPoint nearest_point_approx(FloatPoint p_point) { System.out.println("Circle.nearest_point_approx not yet implemented"); return null; } - - public double border_distance(FloatPoint p_point) - { + + public double border_distance(FloatPoint p_point) { double d = p_point.distance(center.to_float()) - radius; return Math.abs(d); } - - public Circle enlarge(double p_offset) - { - if (p_offset == 0) - { + + public Circle enlarge(double p_offset) { + if (p_offset == 0) { return this; } - int new_radius = radius + (int)Math.round(p_offset); + int new_radius = radius + (int) Math.round(p_offset); return new Circle(center, new_radius); } - - public boolean intersects(Shape p_other) - { + + public boolean intersects(Shape p_other) { return p_other.intersects(this); } - - public Polyline[] cutout(Polyline p_polyline) - { + + public Polyline[] cutout(Polyline p_polyline) { System.out.println("Circle.cutout not yet implemented"); return null; } - - public boolean intersects(Circle p_other) - { + + public boolean intersects(Circle p_other) { double d_square = radius + p_other.radius; d_square *= d_square; return center.distance_square(p_other.center) <= d_square; } - public boolean intersects(IntBox p_box) - { + + public boolean intersects(IntBox p_box) { return p_box.distance(center.to_float()) <= radius; } - - public boolean intersects(IntOctagon p_oct) - { + + public boolean intersects(IntOctagon p_oct) { return p_oct.distance(center.to_float()) <= radius; } - - public boolean intersects(Simplex p_simplex) - { + + public boolean intersects(Simplex p_simplex) { return p_simplex.distance(center.to_float()) <= radius; } - - public TileShape[] split_to_convex() - { + + public TileShape[] split_to_convex() { TileShape[] result = new TileShape[1]; result[0] = this.bounding_tile(); return result; } - - public Circle get_border() - { + + public Circle get_border() { return this; } - - public Shape[] get_holes() - { + + public Shape[] get_holes() { return new Shape[0]; } - - public FloatPoint[] corner_approx_arr() - { + + public FloatPoint[] corner_approx_arr() { return new FloatPoint[0]; } - - public String toString() - { + + public String toString() { return to_string(java.util.Locale.ENGLISH); } - - public String to_string(java.util.Locale p_locale) - { + + public String to_string(java.util.Locale p_locale) { String result = "Circle: "; - if (!(center.equals(Point.ZERO))) - { + if (!(center.equals(Point.ZERO))) { String center_string = "center " + center.toString(); result += center_string; } - java.text.NumberFormat nf = java.text.NumberFormat.getInstance(p_locale); + java.text.NumberFormat nf = java.text.NumberFormat.getInstance(p_locale); String radius_string = "radius " + nf.format(radius); result += radius_string; return result; } - - public final IntPoint center; - public final int radius; - + // private TileShape precalculated_bounding_tile = null; - + // private static final int c_max_approximation_segment_length = 10000; } diff --git a/src/main/java/net/freerouting/geometry/planar/ConvexShape.java b/src/main/java/net/freerouting/geometry/planar/ConvexShape.java index 63f687a5..b74314e1 100644 --- a/src/main/java/net/freerouting/geometry/planar/ConvexShape.java +++ b/src/main/java/net/freerouting/geometry/planar/ConvexShape.java @@ -24,29 +24,28 @@ * A shape is defined as convex, if for each line segment with both endpoints * contained in the shape the whole segment is contained completely in the shape. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public interface ConvexShape extends Shape -{ - +public interface ConvexShape extends Shape { + /** * Calculates the offset shape by p_distance. * If p_distance > 0, the shape will be enlarged, else the result * shape will be smaller. */ ConvexShape offset(double p_distance); - + /** * Shrinks the shape by p_offset. * The result shape will not be empty. */ ConvexShape shrink(double p_offset); - + /** * Returns the maximum diameter of the shape. */ double max_width(); - + /** * Returns the minimum diameter of the shape. */ diff --git a/src/main/java/net/freerouting/geometry/planar/Direction.java b/src/main/java/net/freerouting/geometry/planar/Direction.java index 589f2da0..e9be1339 100644 --- a/src/main/java/net/freerouting/geometry/planar/Direction.java +++ b/src/main/java/net/freerouting/geometry/planar/Direction.java @@ -19,10 +19,10 @@ */ package net.freerouting.geometry.planar; + import net.freerouting.datastructures.Signum; /** - * * Abstract class defining functionality of directions * in the plane. A Direction is an equivalence class of * vectors. Two vectors define the same object of class @@ -34,14 +34,13 @@ * @author Alfons Wirtz */ -public abstract class Direction implements Comparable, java.io.Serializable -{ - public static final IntDirection NULL = new IntDirection(0,0); - +public abstract class Direction implements Comparable, java.io.Serializable { + public static final IntDirection NULL = new IntDirection(0, 0); + /** * the direction to the east */ - public static final IntDirection RIGHT = new IntDirection(1, 0); + public static final IntDirection RIGHT = new IntDirection(1, 0); /** * the direction to the northeast */ @@ -49,206 +48,184 @@ public abstract class Direction implements Comparable, java.io.Seria /** * the direction to the north */ - public static final IntDirection UP = new IntDirection(0, 1); + public static final IntDirection UP = new IntDirection(0, 1); /** * the direction to the northwest */ - public static final IntDirection UP45 = new IntDirection(-1, 1); + public static final IntDirection UP45 = new IntDirection(-1, 1); /** * the direction to the west */ - public static final IntDirection LEFT = new IntDirection(-1, 0); + public static final IntDirection LEFT = new IntDirection(-1, 0); /** * the direction to the southwest */ - public static final IntDirection LEFT45 = new IntDirection(-1, -1); + public static final IntDirection LEFT45 = new IntDirection(-1, -1); /** * the direction to the south */ - public static final IntDirection DOWN = new IntDirection(0, -1); + public static final IntDirection DOWN = new IntDirection(0, -1); /** * the direction to the southeast */ - public static final IntDirection DOWN45 = new IntDirection(1, -1); - + public static final IntDirection DOWN45 = new IntDirection(1, -1); + /** * creates a Direction from the input Vector */ - public static Direction get_instance( Vector p_vector ) - { + public static Direction get_instance(Vector p_vector) { return p_vector.to_normalized_direction(); } - + /** * Calculates the direction from p_from to p_to. * If p_from and p_to are equal, null is returned. */ - public static Direction get_instance( Point p_from, Point p_to ) - { - if ( p_from.equals(p_to) ) - { + public static Direction get_instance(Point p_from, Point p_to) { + if (p_from.equals(p_to)) { return null; } - return get_instance(p_to.difference_by( p_from )); + return get_instance(p_to.difference_by(p_from)); } - + /** * Creates a Direction whose angle with the x-axis is nearly equal to p_angle */ - public static Direction get_instance_approx( double p_angle ) - { + public static Direction get_instance_approx(double p_angle) { final double scale_factor = 10000; - int x = (int)Math.round(Math.cos(p_angle) * scale_factor); - int y = (int)Math.round(Math.sin(p_angle) * scale_factor); + int x = (int) Math.round(Math.cos(p_angle) * scale_factor); + int y = (int) Math.round(Math.sin(p_angle) * scale_factor); return get_instance(new IntVector(x, y)); } - + /** * return any Vector pointing into this direction */ public abstract Vector get_vector(); - + /** * returns true, if the direction is horizontal or vertical */ public abstract boolean is_orthogonal(); - + /** * returns true, if the direction is diagonal */ public abstract boolean is_diagonal(); - + /** * returns true, if the direction is orthogonal or diagonal */ - public boolean is_multiple_of_45_degree() - { - return ( is_orthogonal() || is_diagonal() ) ; + public boolean is_multiple_of_45_degree() { + return (is_orthogonal() || is_diagonal()); } - + /** * turns the direction by p_factor times 45 degree */ public abstract Direction turn_45_degree(int p_factor); - + /** * returns the opposite direction of this direction */ public abstract Direction opposite(); - + /** * Returns true, if p_ob is a Direction and * this Direction and p_ob point into the same direction */ - public final boolean equals( Direction p_other ) - { - if ( this == p_other ) - { + public final boolean equals(Direction p_other) { + if (this == p_other) { return true; } - if ( p_other == null ) - { + if (p_other == null) { return false; } - - if (this.side_of(p_other) != Side.COLLINEAR) - { + + if (this.side_of(p_other) != Side.COLLINEAR) { return false; } // check, that dir and other_dir do not point into opposite directions Vector this_vector = get_vector(); - Vector other_vector = p_other.get_vector() ; + Vector other_vector = p_other.get_vector(); return this_vector.projection(other_vector) == Signum.POSITIVE; } - + /** * Let L be the line from the Zero Vector to p_other.get_vector(). * The function returns - * Side.ON_THE_LEFT, if this.get_vector() is on the left of L - * Side.ON_THE_RIGHT, if this.get_vector() is on the right of L - * and Side.COLLINEAR, if this.get_vector() is collinear with L. + * Side.ON_THE_LEFT, if this.get_vector() is on the left of L + * Side.ON_THE_RIGHT, if this.get_vector() is on the right of L + * and Side.COLLINEAR, if this.get_vector() is collinear with L. */ - public Side side_of(Direction p_other) - { + public Side side_of(Direction p_other) { return this.get_vector().side_of(p_other.get_vector()); } - + /** * The function returns - * Signum.POSITIVE, if the scalar product of of a vector representing - * this direction and a vector representing p_other is > 0, - * Signum.NEGATIVE, if the scalar product is < 0, - * and Signum.ZERO, if the scalar product is equal 0. + * Signum.POSITIVE, if the scalar product of of a vector representing + * this direction and a vector representing p_other is > 0, + * Signum.NEGATIVE, if the scalar product is < 0, + * and Signum.ZERO, if the scalar product is equal 0. */ - public Signum projection(Direction p_other) - { + public Signum projection(Direction p_other) { return this.get_vector().projection(p_other.get_vector()); } - + /** * calculates an approximation of the direction in the middle of * this direction and p_other */ - public Direction middle_approx(Direction p_other) - { + public Direction middle_approx(Direction p_other) { FloatPoint v1 = get_vector().to_float(); FloatPoint v2 = p_other.get_vector().to_float(); double length1 = v1.size(); double length2 = v2.size(); - double x = v1.x / length1 + v2.x /length2; - double y = v1.y / length1 + v2.y /length2; + double x = v1.x / length1 + v2.x / length2; + double y = v1.y / length1 + v2.y / length2; final double scale_factor = 1000; - Vector vm = new IntVector((int)Math.round(x * scale_factor), - (int)Math.round(y * scale_factor)); + Vector vm = new IntVector((int) Math.round(x * scale_factor), + (int) Math.round(y * scale_factor)); return Direction.get_instance(vm); } - - + + /** * Returns 1, if the angle between p_1 and this direction is bigger * the angle between p_2 and this direction, * 0, if p_1 is equal to p_2, * and -1 otherwise. */ - public int compare_from(Direction p_1, Direction p_2) - { + public int compare_from(Direction p_1, Direction p_2) { int result; - if (p_1.compareTo(this) >= 0) - { - if (p_2.compareTo(this) >= 0) - { + if (p_1.compareTo(this) >= 0) { + if (p_2.compareTo(this) >= 0) { result = p_1.compareTo(p_2); - } - else - { + } else { result = -1; } - } - else - { - if (p_2.compareTo(this) >= 0) - { + } else { + if (p_2.compareTo(this) >= 0) { result = 1; - } - else - { - result = p_1.compareTo(p_2); + } else { + result = p_1.compareTo(p_2); } } return result; } - + /** * Returns an approximation of the signed angle corresponding to this dierection. */ - public double angle_approx() - { + public double angle_approx() { return this.get_vector().angle_approx(); } - + // auxiliary functions needed because the virtual function mechanism // does not work in parameter position - + abstract int compareTo(IntDirection p_other); + abstract int compareTo(BigIntDirection p_other); - + } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/Ellipse.java b/src/main/java/net/freerouting/geometry/planar/Ellipse.java index fd38e2d5..4cc7bc6c 100644 --- a/src/main/java/net/freerouting/geometry/planar/Ellipse.java +++ b/src/main/java/net/freerouting/geometry/planar/Ellipse.java @@ -27,41 +27,36 @@ * * @author Alfons Wirtz */ -public class Ellipse implements java.io.Serializable -{ - - /** Creates a new instance of Ellipse */ - public Ellipse(FloatPoint p_center, double p_rotation, double p_radius_1, double p_radius_2) - { +public class Ellipse implements java.io.Serializable { + + public final FloatPoint center; + /** + * Rotation of the ellipse in radian normed to 0 <= rotation < pi + */ + public final double rotation; + public final double bigger_radius; + public final double smaller_radius; + /** + * Creates a new instance of Ellipse + */ + public Ellipse(FloatPoint p_center, double p_rotation, double p_radius_1, double p_radius_2) { this.center = p_center; double curr_rotation; - if (p_radius_1 >= p_radius_2) - { + if (p_radius_1 >= p_radius_2) { this.bigger_radius = p_radius_1; this.smaller_radius = p_radius_2; curr_rotation = p_rotation; - } - else - { + } else { this.bigger_radius = p_radius_2; this.smaller_radius = p_radius_1; curr_rotation = p_rotation + 0.5 * Math.PI; } - while (curr_rotation >= Math.PI) - { + while (curr_rotation >= Math.PI) { curr_rotation -= Math.PI; } - while (curr_rotation < 0) - { + while (curr_rotation < 0) { curr_rotation += Math.PI; } this.rotation = curr_rotation; } - - public final FloatPoint center; - - /** Rotation of the ellipse in radian normed to 0 <= rotation < pi */ - public final double rotation; - public final double bigger_radius; - public final double smaller_radius; } diff --git a/src/main/java/net/freerouting/geometry/planar/FloatLine.java b/src/main/java/net/freerouting/geometry/planar/FloatLine.java index 69ab068f..421d2464 100644 --- a/src/main/java/net/freerouting/geometry/planar/FloatLine.java +++ b/src/main/java/net/freerouting/geometry/planar/FloatLine.java @@ -26,47 +26,43 @@ * For that reason collinearity for example is not defined for FloatLines. * If exactnesss is needed, use the class Line instead. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class FloatLine -{ - +public class FloatLine { + + public final FloatPoint a; + public final FloatPoint b; + /** * Creates a line from two FloatPoints. */ - public FloatLine(FloatPoint p_a, FloatPoint p_b) - { - if (p_a == null || p_b == null) - { + public FloatLine(FloatPoint p_a, FloatPoint p_b) { + if (p_a == null || p_b == null) { System.out.println("FloatLine: Parameter is null"); } a = p_a; b = p_b; } - + /** * Returns the FloatLine with swapped end points. */ - public FloatLine opposite() - { + public FloatLine opposite() { return new FloatLine(this.b, this.a); } - - public FloatLine adjust_direction(FloatLine p_other) - { - if (this.b.side_of(this.a, p_other.a )== p_other.b.side_of(this.a, p_other.a )) - { + + public FloatLine adjust_direction(FloatLine p_other) { + if (this.b.side_of(this.a, p_other.a) == p_other.b.side_of(this.a, p_other.a)) { return this; } return this.opposite(); } - + /** * Calculates the intersection of this line with p_other. * Returns null, if the lines are parallel. */ - public FloatPoint intersection(FloatLine p_other) - { + public FloatPoint intersection(FloatLine p_other) { double d1x = this.b.x - this.a.x; double d1y = this.b.y - this.a.y; double d2x = p_other.b.x - p_other.a.x; @@ -76,35 +72,30 @@ public FloatPoint intersection(FloatLine p_other) double det = d2x * d1y - d2y * d1x; double is_x; double is_y; - if(det == 0) - { + if (det == 0) { return null; } is_x = (d2x * det_1 - d1x * det_2) / det; is_y = (d2y * det_1 - d1y * det_2) / det; return new FloatPoint(is_x, is_y); } - + /** * translates the line perpendicular at about p_dist. * If p_dist > 0, the line will be translated to the left, else to the right */ - public FloatLine translate(double p_dist) - { + public FloatLine translate(double p_dist) { double dx = b.x - a.x; double dy = b.y - a.y; double dxdx = dx * dx; double dydy = dy * dy; double lenght = Math.sqrt(dxdx + dydy); FloatPoint new_a; - if (dxdx <= dydy) - { + if (dxdx <= dydy) { // translate along the x axis double rel_x = (p_dist * lenght) / dy; new_a = new FloatPoint(this.a.x - rel_x, this.a.y); - } - else - { + } else { // translate along the y axis double rel_y = (p_dist * lenght) / dx; new_a = new FloatPoint(this.a.x, this.a.y + rel_y); @@ -112,219 +103,180 @@ public FloatLine translate(double p_dist) FloatPoint new_b = new FloatPoint(new_a.x + dx, new_a.y + dy); return new FloatLine(new_a, new_b); } - + /** * Returns the signed distance of this line from p_point. * The result will be positive, if the line is on the left of p_point, * else negative. */ - public double signed_distance(FloatPoint p_point) - { + public double signed_distance(FloatPoint p_point) { double dx = this.b.x - this.a.x; double dy = this.b.y - this.a.y; double det = dy * (p_point.x - this.a.x) - - dx * (p_point.y - this.a.y); + dx * (p_point.y - this.a.y); // area of the parallelogramm spanned by the 3 points double length = Math.sqrt(dx * dx + dy * dy); return det / length; } - + /** * Returns an approximation of the perpensicular projection * of p_point onto this line. */ - public FloatPoint perpendicular_projection(FloatPoint p_point) - { - + public FloatPoint perpendicular_projection(FloatPoint p_point) { + double dx = b.x - a.x; double dy = b.y - a.y; - if (dx == 0 && dy == 0) - { + if (dx == 0 && dy == 0) { return this.a; } - + double dxdx = dx * dx; double dydy = dy * dy; double dxdy = dx * dy; double denominator = dxdx + dydy; - double det = a.x * b.y - b.x * a.y; - + double det = a.x * b.y - b.x * a.y; + double x = (p_point.x * dxdx + p_point.y * dxdy + det * dy) / denominator; double y = (p_point.x * dxdy + p_point.y * dydy - det * dx) / denominator; - + return new FloatPoint(x, y); } - + /** * Returns the distance of p_point to the nearest point of this line * betweem this.a and this.b. */ - public double segment_distance(FloatPoint p_point) - { + public double segment_distance(FloatPoint p_point) { FloatPoint projection = perpendicular_projection(p_point); double result; - if (projection.is_contained_in_box(this.a, this.b, 0.01)) - { + if (projection.is_contained_in_box(this.a, this.b, 0.01)) { result = p_point.distance(projection); - } - else - { + } else { result = Math.min(p_point.distance(a), p_point.distance(b)); } return result; } - + /** * Returns the perpendicular projection of p_line_segment onto this oriented line segment, * Returns null, if the projection is empty. */ - public FloatLine segment_projection(FloatLine p_line_segment) - { - if (this.b.scalar_product(this.a, p_line_segment.a) < 0) - { + public FloatLine segment_projection(FloatLine p_line_segment) { + if (this.b.scalar_product(this.a, p_line_segment.a) < 0) { return null; } - if (this.a.scalar_product(this.b, p_line_segment.b) < 0) - { + if (this.a.scalar_product(this.b, p_line_segment.b) < 0) { return null; } FloatPoint projected_a; - if (this.a.scalar_product(this.b, p_line_segment.a) < 0) - { + if (this.a.scalar_product(this.b, p_line_segment.a) < 0) { projected_a = this.a; - } - else - { - projected_a = this.perpendicular_projection(p_line_segment.a); - if (Math.abs(projected_a.x) >= Limits.CRIT_INT || Math.abs(projected_a.y) >= Limits.CRIT_INT) - { + } else { + projected_a = this.perpendicular_projection(p_line_segment.a); + if (Math.abs(projected_a.x) >= Limits.CRIT_INT || Math.abs(projected_a.y) >= Limits.CRIT_INT) { return null; } } FloatPoint projected_b; - if (this.b.scalar_product(this.a, p_line_segment.b) < 0) - { + if (this.b.scalar_product(this.a, p_line_segment.b) < 0) { projected_b = this.b; + } else { + projected_b = this.perpendicular_projection(p_line_segment.b); } - else - { - projected_b = this.perpendicular_projection(p_line_segment.b); - } - if (Math.abs(projected_b.x) >= Limits.CRIT_INT || Math.abs(projected_b.y) >= Limits.CRIT_INT) - { + if (Math.abs(projected_b.x) >= Limits.CRIT_INT || Math.abs(projected_b.y) >= Limits.CRIT_INT) { return null; } return new FloatLine(projected_a, projected_b); } - + /** * Returns the projection of p_line_segment onto this oriented line segment * by moving p_line_segment perpendicular into the direction of this line segmant * Returns null, if the projection is empty or p_line_segment.a == p_line_segment.b */ - public FloatLine segment_projection_2(FloatLine p_line_segment) - { - if (p_line_segment.a.scalar_product(p_line_segment.b, this.b) <= 0) - { + public FloatLine segment_projection_2(FloatLine p_line_segment) { + if (p_line_segment.a.scalar_product(p_line_segment.b, this.b) <= 0) { return null; } - if ( p_line_segment.b.scalar_product(p_line_segment.a, this.a) <= 0) - { + if (p_line_segment.b.scalar_product(p_line_segment.a, this.a) <= 0) { return null; } FloatPoint projected_a; - if (p_line_segment.a.scalar_product(p_line_segment.b, this.a) < 0) - { + if (p_line_segment.a.scalar_product(p_line_segment.b, this.a) < 0) { FloatLine curr_perpendicular_line = new FloatLine(p_line_segment.a, p_line_segment.b.turn_90_degree(1, p_line_segment.a)); projected_a = curr_perpendicular_line.intersection(this); - if (projected_a == null || Math.abs(projected_a.x) >= Limits.CRIT_INT || Math.abs(projected_a.y) >= Limits.CRIT_INT) - { + if (projected_a == null || Math.abs(projected_a.x) >= Limits.CRIT_INT || Math.abs(projected_a.y) >= Limits.CRIT_INT) { return null; } - } - else - { + } else { projected_a = this.a; } - + FloatPoint projected_b; - - if (p_line_segment.b.scalar_product(p_line_segment.a, this.b) < 0) - { + + if (p_line_segment.b.scalar_product(p_line_segment.a, this.b) < 0) { FloatLine curr_perpendicular_line = new FloatLine(p_line_segment.b, p_line_segment.a.turn_90_degree(1, p_line_segment.b)); projected_b = curr_perpendicular_line.intersection(this); - if (projected_b == null || Math.abs(projected_b.x) >= Limits.CRIT_INT || Math.abs(projected_b.y) >= Limits.CRIT_INT) - { + if (projected_b == null || Math.abs(projected_b.x) >= Limits.CRIT_INT || Math.abs(projected_b.y) >= Limits.CRIT_INT) { return null; } - } - else - { + } else { projected_b = this.b; } return new FloatLine(projected_a, projected_b); } - + /** * Shrinks this line on both sides by p_value. * The result will contain at least the gravity point of the line. */ - public FloatLine shrink_segment(double p_offset) - { + public FloatLine shrink_segment(double p_offset) { double dx = b.x - a.x; double dy = b.y - a.y; - if (dx == 0 && dy == 0) - { + if (dx == 0 && dy == 0) { return this; } double length = Math.sqrt(dx * dx + dy * dy); - double offset = Math.min(p_offset, length/2); + double offset = Math.min(p_offset, length / 2); FloatPoint new_a = new FloatPoint(a.x + (dx * offset) / length, a.y + (dy * offset) / length); double new_length = length - offset; FloatPoint new_b = new FloatPoint(a.x + (dx * new_length) / length, a.y + (dy * new_length) / length); return new FloatLine(new_a, new_b); } - + /** * Calculates the nearest point on this line to p_from_point between * this.a and this.b. */ - public FloatPoint nearest_segment_point(FloatPoint p_from_point) - { + public FloatPoint nearest_segment_point(FloatPoint p_from_point) { FloatPoint projection = this.perpendicular_projection(p_from_point); - if (projection.is_contained_in_box(this.a, this.b, 0.01)) - { + if (projection.is_contained_in_box(this.a, this.b, 0.01)) { return projection; } // Now the projection is outside the line segment. FloatPoint result; - if (p_from_point.distance_square(this.a) <= p_from_point.distance_square(this.b)) - { + if (p_from_point.distance_square(this.a) <= p_from_point.distance_square(this.b)) { result = this.a; - } - else - { + } else { result = this.b; } return result; } - + /** * Divides this line segment into p_count line segments of nearly equal length. * and at most p_max_section_length. */ - public FloatLine[] divide_segment_into_sections(int p_count) - { - if (p_count == 0) - { + public FloatLine[] divide_segment_into_sections(int p_count) { + if (p_count == 0) { return new FloatLine[0]; } - if (p_count == 1) - { - FloatLine [] result = new FloatLine[1]; + if (p_count == 1) { + FloatLine[] result = new FloatLine[1]; result[0] = this; return result; } @@ -334,18 +286,14 @@ public FloatLine[] divide_segment_into_sections(int p_count) double dx = b.x - a.x; double dy = b.y - a.y; FloatPoint curr_a = this.a; - for (int i = 0; i < p_count; ++i) - { + for (int i = 0; i < p_count; ++i) { FloatPoint curr_b; - if (i == p_count - 1) - { + if (i == p_count - 1) { curr_b = this.b; - } - else - { + } else { double curr_b_dist = (i + 1) * section_length; - double curr_b_x = a.x + (dx * curr_b_dist)/line_length; - double curr_b_y = a.y + (dy * curr_b_dist)/line_length; + double curr_b_x = a.x + (dx * curr_b_dist) / line_length; + double curr_b_y = a.y + (dy * curr_b_dist) / line_length; curr_b = new FloatPoint(curr_b_x, curr_b_y); } result[i] = new FloatLine(curr_a, curr_b); @@ -353,7 +301,4 @@ public FloatLine[] divide_segment_into_sections(int p_count) } return result; } - - public final FloatPoint a; - public final FloatPoint b; } diff --git a/src/main/java/net/freerouting/geometry/planar/FloatPoint.java b/src/main/java/net/freerouting/geometry/planar/FloatPoint.java index 901af5f4..c01f853e 100644 --- a/src/main/java/net/freerouting/geometry/planar/FloatPoint.java +++ b/src/main/java/net/freerouting/geometry/planar/FloatPoint.java @@ -21,75 +21,106 @@ package net.freerouting.geometry.planar; /** - * * Implements a point in the plane as a touple of double's. * Because arithmetic calculations with double's are in general not * exact, FloatPoint is not derived from the abstract class Point. * - * * @author Alfons Wirtz */ -public class FloatPoint implements java.io.Serializable -{ - - public static final FloatPoint ZERO = new FloatPoint(0,0); - +public class FloatPoint implements java.io.Serializable { + + public static final FloatPoint ZERO = new FloatPoint(0, 0); + /** + * the x coordinate of this point + */ + public final double x; + /** + * the y coordinate of this point + */ + public final double y; + /** * creates an instance of class FloatPoint from two double's, */ - public FloatPoint(double p_x, double p_y) - { + public FloatPoint(double p_x, double p_y) { x = p_x; y = p_y; } - - public FloatPoint(IntPoint p_pt) - { - x = p_pt.x ; - y = p_pt.y ; + + public FloatPoint(IntPoint p_pt) { + x = p_pt.x; + y = p_pt.y; } - + + /** + * Calculates the smallest IntOctagon containing all the input points + */ + public static IntOctagon bounding_octagon(FloatPoint[] p_point_arr) { + double lx = Integer.MAX_VALUE; + double ly = Integer.MAX_VALUE; + double rx = Integer.MIN_VALUE; + double uy = Integer.MIN_VALUE; + double ulx = Integer.MAX_VALUE; + double lrx = Integer.MIN_VALUE; + double llx = Integer.MAX_VALUE; + double urx = Integer.MIN_VALUE; + for (int i = 0; i < p_point_arr.length; ++i) { + FloatPoint curr = p_point_arr[i]; + lx = Math.min(lx, curr.x); + ly = Math.min(ly, curr.y); + rx = Math.max(rx, curr.x); + uy = Math.max(uy, curr.y); + double tmp = curr.x - curr.y; + ulx = Math.min(ulx, tmp); + lrx = Math.max(lrx, tmp); + tmp = curr.x + curr.y; + llx = Math.min(llx, tmp); + urx = Math.max(urx, tmp); + } + IntOctagon surrounding_octagon = new + IntOctagon((int) Math.floor(lx), (int) Math.floor(ly), + (int) Math.ceil(rx), (int) Math.ceil(uy), + (int) Math.floor(ulx), (int) Math.ceil(lrx), + (int) Math.floor(llx), (int) Math.ceil(urx)); + return surrounding_octagon; + } + /** * returns the square of the distance from this point to the zero point */ - public final double size_square() - { + public final double size_square() { return x * x + y * y; } - + /** * returns the distance from this point to the zero point */ - public final double size() - { + public final double size() { return Math.sqrt(size_square()); } - + /** * returns the square of the distance from this Point to the Point p_other */ - public final double distance_square(FloatPoint p_other) - { + public final double distance_square(FloatPoint p_other) { double dx = p_other.x - x; double dy = p_other.y - y; return dx * dx + dy * dy; } - + /** * returns the distance from this point to the point p_other */ - public final double distance(FloatPoint p_other) - { + public final double distance(FloatPoint p_other) { return Math.sqrt(distance_square(p_other)); } - + /** * Computes the weighted distance to p_other. */ - public double weighted_distance(FloatPoint p_other, double p_horizontal_weight, double p_vertical_weight) - { + public double weighted_distance(FloatPoint p_other, double p_horizontal_weight, double p_vertical_weight) { double delta_x = this.x - p_other.x; double delta_y = this.y - p_other.y; delta_x *= p_horizontal_weight; @@ -97,174 +128,137 @@ public double weighted_distance(FloatPoint p_other, double p_horizontal_weight, double result = Math.sqrt(delta_x * delta_x + delta_y * delta_y); return result; } - + /** * rounds the coordinates from an object of class Point_double to * an object of class IntPoint */ - public IntPoint round() - { - return new IntPoint((int)Math.round(x), (int)Math.round(y)); + public IntPoint round() { + return new IntPoint((int) Math.round(x), (int) Math.round(y)); } - + /** * Rounds this point, so that if this point is on the right side * of any directed line with direction p_dir, the result * point will also be on the right side. */ - public IntPoint round_to_the_right(Direction p_dir) - { + public IntPoint round_to_the_right(Direction p_dir) { FloatPoint dir = p_dir.get_vector().to_float(); int rounded_x; - - if (dir.y > 0) - { + + if (dir.y > 0) { rounded_x = (int) Math.ceil(x); - } - else if (dir.y < 0) - { + } else if (dir.y < 0) { rounded_x = (int) Math.floor(x); - } - else - { + } else { rounded_x = (int) Math.round(x); } - + int rounded_y; - - if (dir.x > 0) - { + + if (dir.x > 0) { rounded_y = (int) Math.floor(y); - } - else if (dir.x < 0) - { + } else if (dir.x < 0) { rounded_y = (int) Math.ceil(y); - } - else - { + } else { rounded_y = (int) Math.round(y); } return new IntPoint(rounded_x, rounded_y); } - + /** * Round this Point so the x coordinate of the result will be a multiple of p_horizontal_grid * and the y coordinate a multiple of p_vertical_grid. */ - public IntPoint round_to_grid(int p_horizontal_grid, int p_vertical_grid) - { + public IntPoint round_to_grid(int p_horizontal_grid, int p_vertical_grid) { double rounded_x; - if (p_horizontal_grid > 0) - { - rounded_x = Math.rint(this.x / p_horizontal_grid) * p_horizontal_grid; - } - else - { + if (p_horizontal_grid > 0) { + rounded_x = Math.rint(this.x / p_horizontal_grid) * p_horizontal_grid; + } else { rounded_x = this.x; } double rounded_y; - if (p_vertical_grid > 0) - { - rounded_y = Math.rint(this.y / p_vertical_grid) * p_vertical_grid; - } - else - { + if (p_vertical_grid > 0) { + rounded_y = Math.rint(this.y / p_vertical_grid) * p_vertical_grid; + } else { rounded_y = this.y; } - return new IntPoint((int) rounded_x, (int) rounded_y ); + return new IntPoint((int) rounded_x, (int) rounded_y); } - + /** * Rounds this point, so that if this point is on the left side * of any directed line with direction p_dir, the result * point will also be on the left side. */ - public IntPoint round_to_the_left(Direction p_dir) - { + public IntPoint round_to_the_left(Direction p_dir) { FloatPoint dir = p_dir.get_vector().to_float(); int rounded_x; - - if (dir.y > 0) - { + + if (dir.y > 0) { rounded_x = (int) Math.floor(x); - } - else if (dir.y < 0) - { + } else if (dir.y < 0) { rounded_x = (int) Math.ceil(x); - } - else - { + } else { rounded_x = (int) Math.round(x); } - + int rounded_y; - - if (dir.x > 0) - { + + if (dir.x > 0) { rounded_y = (int) Math.ceil(y); - } - else if (dir.x < 0) - { + } else if (dir.x < 0) { rounded_y = (int) Math.floor(y); - } - else - { + } else { rounded_y = (int) Math.round(y); } return new IntPoint(rounded_x, rounded_y); } - + /** * Adds the coordinates of this FloatPoint and p_other. */ - public FloatPoint add(FloatPoint p_other) - { + public FloatPoint add(FloatPoint p_other) { return new FloatPoint(this.x + p_other.x, this.y + p_other.y); } - + /** * Substracts the coordinates of p_other from this FloatPoint. */ - public FloatPoint substract(FloatPoint p_other) - { + public FloatPoint substract(FloatPoint p_other) { return new FloatPoint(this.x - p_other.x, this.y - p_other.y); } - + /** * Returns an approximation of the perpendicular projection * of this point onto p_line */ - public FloatPoint projection_approx(Line p_line) - { + public FloatPoint projection_approx(Line p_line) { FloatLine line = new FloatLine(p_line.a.to_float(), p_line.b.to_float()); return line.perpendicular_projection(this); } - + /** * Calculates the scalar prodct of (p_1 - this). with (p_2 - this). */ - public double scalar_product(FloatPoint p_1, FloatPoint p_2) - { - if (p_1 == null || p_2 == null) - { + public double scalar_product(FloatPoint p_1, FloatPoint p_2) { + if (p_1 == null || p_2 == null) { System.out.println("FloatPoint.scalar_product: parameter point is null"); return 0; } - double dx_1 = p_1.x - this.x; - double dx_2 = p_2.x - this.x; - double dy_1 = p_1.y - this.y; - double dy_2 = p_2.y - this.y; + double dx_1 = p_1.x - this.x; + double dx_2 = p_2.x - this.x; + double dy_1 = p_1.y - this.y; + double dy_2 = p_2.y - this.y; return (dx_1 * dx_2 + dy_1 * dy_2); } - + /** * Approximates a FloatPoint on the line from zero to this point * with distance p_new_length from zero. */ - public FloatPoint change_size(double p_new_size) - { - if (x == 0 && y == 0) - { + public FloatPoint change_size(double p_new_size) { + if (x == 0 && y == 0) { // the size of the zero point cannot be changed return this; } @@ -273,17 +267,15 @@ public FloatPoint change_size(double p_new_size) double new_y = (y * p_new_size) / length; return new FloatPoint(new_x, new_y); } - + /** * Approximates a FloatPoint on the line from this point to p_to_point * with distance p_new_length from this point. */ - public FloatPoint change_length(FloatPoint p_to_point, double p_new_length) - { + public FloatPoint change_length(FloatPoint p_to_point, double p_new_length) { double dx = p_to_point.x - this.x; double dy = p_to_point.y - this.y; - if (dx == 0 && dy == 0) - { + if (dx == 0 && dy == 0) { System.out.println("IntPoint.change_length: Points are equal"); return p_to_point; } @@ -292,29 +284,26 @@ public FloatPoint change_length(FloatPoint p_to_point, double p_new_length) double new_y = this.y + (dy * p_new_length) / length; return new FloatPoint(new_x, new_y); } - + /** * Returns the middle point between this point and p_to_point. */ - public FloatPoint middle_point(FloatPoint p_to_point) - { - if (p_to_point == this) - { + public FloatPoint middle_point(FloatPoint p_to_point) { + if (p_to_point == this) { return this; } double middle_x = 0.5 * (this.x + p_to_point.x); double middle_y = 0.5 * (this.y + p_to_point.y); return new FloatPoint(middle_x, middle_y); } - + /** * The function returns * Side.ON_THE_LEFT, if this Point is on the left of the line from p_1 to p_2; * and Side.ON_THE_RIGHT, if this Point is on the right of the line from p_1 to p_2. * Collinearity is not defined, becouse numerical calculations ar not exact for FloatPoints. */ - public Side side_of(FloatPoint p_1, FloatPoint p_2) - { + public Side side_of(FloatPoint p_1, FloatPoint p_2) { double d21_x = p_2.x - p_1.x; double d21_y = p_2.y - p_1.y; double d01_x = this.x - p_1.x; @@ -322,14 +311,12 @@ public Side side_of(FloatPoint p_1, FloatPoint p_2) double determinant = d21_x * d01_y - d21_y * d01_x; return Side.of(determinant); } - + /** - * Rotates this FloatPoints by p_angle ( in radian ) around the p_pole. + * Rotates this FloatPoints by p_angle ( in radian ) around the p_pole. */ - public FloatPoint rotate(double p_angle, FloatPoint p_pole) - { - if (p_angle == 0) - { + public FloatPoint rotate(double p_angle, FloatPoint p_pole) { + if (p_angle == 0) { return this; } double dx = x - p_pole.x; @@ -340,103 +327,90 @@ public FloatPoint rotate(double p_angle, FloatPoint p_pole) double new_dy = dx * sin_angle + dy * cos_angle; return new FloatPoint(p_pole.x + new_dx, p_pole.y + new_dy); } - + /** * Turns this FloatPoint by p_factor times 90 degree around ZERO. */ - public FloatPoint turn_90_degree(int p_factor) - { + public FloatPoint turn_90_degree(int p_factor) { int n = p_factor; - while (n < 0) - { + while (n < 0) { n += 4; } - while (n >= 4) - { + while (n >= 4) { n -= 4; } - double new_x ; - double new_y ; - switch (n) - { + double new_x; + double new_y; + switch (n) { case 0: // 0 degree new_x = x; new_y = y; break; case 1: // 90 degree - new_x = -y ; - new_y = x ; + new_x = -y; + new_y = x; break; case 2: // 180 degree - new_x = -x ; - new_y = -y ; + new_x = -x; + new_y = -y; break; case 3: // 270 degree - new_x = y ; - new_y = -x ; + new_x = y; + new_y = -x; break; default: - new_x = 0 ; - new_y = 0 ; + new_x = 0; + new_y = 0; } return new FloatPoint(new_x, new_y); } - + /** * Turns this FloatPoint by p_factor times 90 degree around p_pole. */ - public FloatPoint turn_90_degree(int p_factor, FloatPoint p_pole) - { + public FloatPoint turn_90_degree(int p_factor, FloatPoint p_pole) { FloatPoint v = this.substract(p_pole); v = v.turn_90_degree(p_factor); return p_pole.add(v); } + /** * Checks, if this point is contained in the box spanned by p_1 and p_2 with the input tolerance. */ - public boolean is_contained_in_box(FloatPoint p_1, FloatPoint p_2, double p_tolerance) - { + public boolean is_contained_in_box(FloatPoint p_1, FloatPoint p_2, double p_tolerance) { double min_x; double max_x; - if (p_1.x < p_2.x) - { + if (p_1.x < p_2.x) { min_x = p_1.x; max_x = p_2.x; - } - else - { + } else { min_x = p_2.x; max_x = p_1.x; } - if (this.x < min_x - p_tolerance || this.x > max_x + p_tolerance) - { + if (this.x < min_x - p_tolerance || this.x > max_x + p_tolerance) { return false; } double min_y; double max_y; - if (p_1.y < p_2.y) - { + if (p_1.y < p_2.y) { min_y = p_1.y; max_y = p_2.y; - } - else - { + } else { min_y = p_2.y; max_y = p_1.y; } return (this.y >= min_y - p_tolerance && this.y <= max_y + p_tolerance); } - + /** * Creates the smallest IntBox containing this point. */ - public IntBox bounding_box() - { - IntPoint lower_left = new IntPoint((int)Math.floor(this.x),(int)Math.floor(this.y)); - IntPoint upper_right = new IntPoint((int)Math.ceil(this.x),(int)Math.ceil(this.y)); + public IntBox bounding_box() { + IntPoint lower_left = new IntPoint((int) Math.floor(this.x), (int) Math.floor(this.y)); + IntPoint upper_right = new IntPoint((int) Math.ceil(this.x), (int) Math.ceil(this.y)); return new IntBox(lower_left, upper_right); } - + /** * Calculates the touching points of the tangents from this point to a circle * around p_to_point with radius p_distance. @@ -446,32 +420,28 @@ public IntBox bounding_box() * equation. The polar line is the line through the 2 tangential points * of the circle looked at from from this point and * has the equation - * (this.x - p_to_point.x) * (x - p_to_point.x) - * + (this.y - p_to_point.y) * (y - p_to_point.y) = p_distance **2 + * (this.x - p_to_point.x) * (x - p_to_point.x) + * + (this.y - p_to_point.y) * (y - p_to_point.y) = p_distance **2 */ - public FloatPoint[] tangential_points(FloatPoint p_to_point, double p_distance) - { + public FloatPoint[] tangential_points(FloatPoint p_to_point, double p_distance) { // turn the situation 90 degree if the x difference is smaller // than the y difference for better numerical stability - + double dx = Math.abs(this.x - p_to_point.x); double dy = Math.abs(this.y - p_to_point.y); boolean situation_turned = (dy > dx); FloatPoint pole; FloatPoint circle_center; - - if (situation_turned) - { + + if (situation_turned) { // turn the situation by 90 degree pole = new FloatPoint(-this.y, this.x); circle_center = new FloatPoint(-p_to_point.y, p_to_point.x); - } - else - { + } else { pole = this; circle_center = p_to_point; } - + dx = pole.x - circle_center.x; dy = pole.y - circle_center.y; double dx_square = dx * dx; @@ -479,175 +449,110 @@ public FloatPoint[] tangential_points(FloatPoint p_to_point, double p_distance) double dist_square = dx_square + dy_square; double radius_square = p_distance * p_distance; double discriminant = radius_square * dy_square - (radius_square - dx_square) * dist_square; - - if (discriminant <= 0) - { + + if (discriminant <= 0) { // pole is inside the circle. return new FloatPoint[0]; } double square_root = Math.sqrt(discriminant); - + FloatPoint[] result = new FloatPoint[2]; - - double a1 = radius_square * dy; - double dy1 = (a1 + p_distance * square_root) / dist_square; - double dy2 = (a1 - p_distance * square_root) / dist_square; - + + double a1 = radius_square * dy; + double dy1 = (a1 + p_distance * square_root) / dist_square; + double dy2 = (a1 - p_distance * square_root) / dist_square; + double first_point_y = dy1 + circle_center.y; double first_point_x = (radius_square - dy * dy1) / dx + circle_center.x; double second_point_y = dy2 + circle_center.y; double second_point_x = (radius_square - dy * dy2) / dx + circle_center.x; - - if (situation_turned) - { + + if (situation_turned) { // turn the result by 270 degree result[0] = new FloatPoint(first_point_y, -first_point_x); result[1] = new FloatPoint(second_point_y, -second_point_x); - } - else - { + } else { result[0] = new FloatPoint(first_point_x, first_point_y); result[1] = new FloatPoint(second_point_x, second_point_y); } return result; } - + /** * Calculates the left tangential point of the line from this point * to a circle around p_to_point with radius p_distance. * Returns null, if this point is inside this circle. */ - public FloatPoint left_tangential_point(FloatPoint p_to_point, double p_distance) - { - if (p_to_point == null) - { + public FloatPoint left_tangential_point(FloatPoint p_to_point, double p_distance) { + if (p_to_point == null) { return null; } FloatPoint[] tangent_points = tangential_points(p_to_point, p_distance); - if (tangent_points.length < 2) - { + if (tangent_points.length < 2) { return null; } FloatPoint result; - if (p_to_point.side_of(this, tangent_points[0]) == Side.ON_THE_RIGHT) - { + if (p_to_point.side_of(this, tangent_points[0]) == Side.ON_THE_RIGHT) { result = tangent_points[0]; - } - else - { + } else { result = tangent_points[1]; } return result; } - + /** * Calculates the right tangential point of the line from this point * to a circle around p_to_point with radius p_distance. * Returns null, if this point is inside this circle. */ - public FloatPoint right_tangential_point(FloatPoint p_to_point, double p_distance) - { - if (p_to_point == null) - { + public FloatPoint right_tangential_point(FloatPoint p_to_point, double p_distance) { + if (p_to_point == null) { return null; } FloatPoint[] tangent_points = tangential_points(p_to_point, p_distance); - if (tangent_points.length < 2) - { + if (tangent_points.length < 2) { return null; } FloatPoint result; - if (p_to_point.side_of(this, tangent_points[0]) == Side.ON_THE_LEFT) - { + if (p_to_point.side_of(this, tangent_points[0]) == Side.ON_THE_LEFT) { result = tangent_points[0]; - } - else - { + } else { result = tangent_points[1]; } return result; } - + /** * Calculates the center of the circle through this point, p_1 and p_2 * by calculating the intersection of the two lines perpendicular to and passing through * the midpoints of the lines (this, p_1) and (p_1, p_2). */ - public FloatPoint circle_center(FloatPoint p_1, FloatPoint p_2) - { - double slope_1 = (p_1.y - this.y)/(p_1.x - this.x); - double slope_2 = (p_2.y - p_1.y)/(p_2.x - p_1.x); + public FloatPoint circle_center(FloatPoint p_1, FloatPoint p_2) { + double slope_1 = (p_1.y - this.y) / (p_1.x - this.x); + double slope_2 = (p_2.y - p_1.y) / (p_2.x - p_1.x); double x_center = - (slope_1 * slope_2 * (this.y -p_2.y) + slope_2 * (this.x + p_1.x) - slope_1 *(p_1.x + p_2.x)) - /(2 * (slope_2 - slope_1)); - double y_center = (0.5 * (this.x + p_1.x) - x_center)/slope_1 + 0.5 * (this.y + p_1.y); + (slope_1 * slope_2 * (this.y - p_2.y) + slope_2 * (this.x + p_1.x) - slope_1 * (p_1.x + p_2.x)) + / (2 * (slope_2 - slope_1)); + double y_center = (0.5 * (this.x + p_1.x) - x_center) / slope_1 + 0.5 * (this.y + p_1.y); return new FloatPoint(x_center, y_center); } - + /** * Returns true, if this point is contained in the circle through p_1, p_2 and p_3. */ - public boolean inside_circle(FloatPoint p_1, FloatPoint p_2, FloatPoint p_3) - { - FloatPoint center = p_1.circle_center(p_2, p_3); + public boolean inside_circle(FloatPoint p_1, FloatPoint p_2, FloatPoint p_3) { + FloatPoint center = p_1.circle_center(p_2, p_3); double radius_square = center.distance_square(p_1); return (this.distance_square(center) < radius_square - 1); // - 1 is a tolerance for numerical stability. } - - public String to_string(java.util.Locale p_locale) - { - java.text.NumberFormat nf = java.text.NumberFormat.getInstance(p_locale); + + public String to_string(java.util.Locale p_locale) { + java.text.NumberFormat nf = java.text.NumberFormat.getInstance(p_locale); nf.setMaximumFractionDigits(4); return (" (" + nf.format(x) + " , " + nf.format(y) + ") "); } - - public String toString() - { + + public String toString() { return to_string(java.util.Locale.ENGLISH); } - - /** - * Calculates the smallest IntOctagon containing all the input points - */ - public static IntOctagon bounding_octagon(FloatPoint [] p_point_arr) - { - double lx = Integer.MAX_VALUE; - double ly = Integer.MAX_VALUE; - double rx = Integer.MIN_VALUE; - double uy = Integer.MIN_VALUE; - double ulx = Integer.MAX_VALUE; - double lrx = Integer.MIN_VALUE; - double llx = Integer.MAX_VALUE; - double urx = Integer.MIN_VALUE; - for (int i = 0; i < p_point_arr.length; ++i) - { - FloatPoint curr = p_point_arr[i]; - lx = Math.min(lx, curr.x); - ly = Math.min(ly, curr.y); - rx = Math.max(rx, curr.x); - uy = Math.max(uy, curr.y); - double tmp = curr.x - curr.y; - ulx = Math.min(ulx, tmp); - lrx = Math.max(lrx, tmp); - tmp = curr.x + curr.y; - llx = Math.min(llx, tmp); - urx = Math.max(urx, tmp); - } - IntOctagon surrounding_octagon = new - IntOctagon((int)Math.floor(lx), (int)Math.floor(ly), - (int)Math.ceil(rx), (int)Math.ceil(uy), - (int)Math.floor(ulx), (int)Math.ceil(lrx), - (int)Math.floor(llx), (int)Math.ceil(urx)); - return surrounding_octagon; - } - - /** - * the x coordinate of this point - */ - public final double x; - - /** - * the y coordinate of this point - */ - public final double y; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeBoundingDirections.java b/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeBoundingDirections.java index fc3f2b29..483cf6cf 100644 --- a/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeBoundingDirections.java +++ b/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeBoundingDirections.java @@ -17,60 +17,50 @@ package net.freerouting.geometry.planar; /** - * * Implements the abstract class ShapeBoundingDirections as * the 8 directions, which are multiples of 45 degree. * The class is a singleton with the only instanciation INSTANCE. * * @author Alfons Wirtz */ -public class FortyfiveDegreeBoundingDirections implements ShapeBoundingDirections -{ +public class FortyfiveDegreeBoundingDirections implements ShapeBoundingDirections { /** * the one and only instantiation */ public static final FortyfiveDegreeBoundingDirections - INSTANCE = new FortyfiveDegreeBoundingDirections(); + INSTANCE = new FortyfiveDegreeBoundingDirections(); - public int count() - { + /** + * prevent instantiation + */ + private FortyfiveDegreeBoundingDirections() { + } + + public int count() { return 8; } - public RegularTileShape bounds (ConvexShape p_shape) - { + public RegularTileShape bounds(ConvexShape p_shape) { return p_shape.bounding_shape(this); } - public RegularTileShape bounds (IntBox p_box) - { + public RegularTileShape bounds(IntBox p_box) { return p_box.to_IntOctagon(); } - public RegularTileShape bounds (IntOctagon p_oct) - { + public RegularTileShape bounds(IntOctagon p_oct) { return p_oct; } - public RegularTileShape bounds (Simplex p_simplex) - { + public RegularTileShape bounds(Simplex p_simplex) { return p_simplex.bounding_octagon(); } - - public RegularTileShape bounds (Circle p_circle) - { + + public RegularTileShape bounds(Circle p_circle) { return p_circle.bounding_octagon(); } - - public RegularTileShape bounds (PolygonShape p_polygon) - { - return p_polygon.bounding_octagon(); - } - /** - * prevent instantiation - */ - private FortyfiveDegreeBoundingDirections() - { + public RegularTileShape bounds(PolygonShape p_polygon) { + return p_polygon.bounding_octagon(); } } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeDirection.java b/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeDirection.java index 7bf8281d..a9b4d44d 100644 --- a/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeDirection.java +++ b/src/main/java/net/freerouting/geometry/planar/FortyfiveDegreeDirection.java @@ -20,6 +20,7 @@ */ package net.freerouting.geometry.planar; + @SuppressWarnings("all") // Eclipse regards get_direction() as unused /** @@ -27,61 +28,44 @@ * * @author alfons */ -public enum FortyfiveDegreeDirection -{ - RIGHT - { - public IntDirection get_direction() - { +public enum FortyfiveDegreeDirection { + RIGHT { + public IntDirection get_direction() { return Direction.RIGHT; } }, - RIGHT45 - { - public IntDirection get_direction() - { + RIGHT45 { + public IntDirection get_direction() { return Direction.RIGHT45; } }, - UP - { - public IntDirection get_direction() - { + UP { + public IntDirection get_direction() { return Direction.UP; } }, - UP45 - { - public IntDirection get_direction() - { + UP45 { + public IntDirection get_direction() { return Direction.UP45; } }, - LEFT - { - public IntDirection get_direction() - { + LEFT { + public IntDirection get_direction() { return Direction.LEFT; } }, - LEFT45 - { - public IntDirection get_direction() - { + LEFT45 { + public IntDirection get_direction() { return Direction.LEFT45; } }, - DOWN - { - public IntDirection get_direction() - { + DOWN { + public IntDirection get_direction() { return Direction.DOWN; } }, - DOWN45 - { - public IntDirection get_direction() - { + DOWN45 { + public IntDirection get_direction() { return Direction.DOWN45; } } diff --git a/src/main/java/net/freerouting/geometry/planar/IntBox.java b/src/main/java/net/freerouting/geometry/planar/IntBox.java index 87b5d6c0..f5859f10 100644 --- a/src/main/java/net/freerouting/geometry/planar/IntBox.java +++ b/src/main/java/net/freerouting/geometry/planar/IntBox.java @@ -21,158 +21,139 @@ package net.freerouting.geometry.planar; /** - * * Implements functionality of orthogonal rectangles in the plane * with integer coordinates. * - * * @author Alfons Wirtz */ -public class IntBox extends RegularTileShape implements java.io.Serializable -{ +public class IntBox extends RegularTileShape implements java.io.Serializable { /** * Standard implementataion of an empty box. */ public static final IntBox EMPTY = new IntBox(Limits.CRIT_INT, Limits.CRIT_INT, -Limits.CRIT_INT, -Limits.CRIT_INT); - + /** + * coordinates of the lower left corner + */ + public final IntPoint ll; + /** + * coordinates of the upper right corner + */ + public final IntPoint ur; + /** * Creates an IntBox from its lower left and upper right corners. */ - public IntBox(IntPoint p_ll, IntPoint p_ur) - { + public IntBox(IntPoint p_ll, IntPoint p_ur) { ll = p_ll; ur = p_ur; } - + + /** * creates an IntBox from the coordinates of its lower left and * upper right corners. */ - public IntBox(int p_ll_x, int p_ll_y, int p_ur_x, int p_ur_y) - { + public IntBox(int p_ll_x, int p_ll_y, int p_ur_x, int p_ur_y) { ll = new IntPoint(p_ll_x, p_ll_y); ur = new IntPoint(p_ur_x, p_ur_y); } - - public boolean is_IntOctagon() - { + + public boolean is_IntOctagon() { return true; } - - + /** * Returns true, if the box is empty */ - public boolean is_empty() - { + public boolean is_empty() { return (ll.x > ur.x || ll.y > ur.y); } - - public int border_line_count() - { + + public int border_line_count() { return 4; } - + /** * returns the horizontal extension of the box. */ - public int width() - { + public int width() { return (ur.x - ll.x); } - + /** * Returns the vertical extension of the box. */ - public int height() - { - return (ur.y - ll.y) ; + public int height() { + return (ur.y - ll.y); } - - public double max_width() - { + + public double max_width() { return Math.max(ur.x - ll.x, ur.y - ll.y); } - - public double min_width() - { + + public double min_width() { return Math.min(ur.x - ll.x, ur.y - ll.y); } - - public double area() - { - return ((double)(ur.x - ll.x))* ((double) (ur.y - ll.y)); + + public double area() { + return ((double) (ur.x - ll.x)) * ((double) (ur.y - ll.y)); } - - public double circumference() - { + + public double circumference() { return 2 * ((ur.x - ll.x) + (ur.y - ll.y)); } - - public IntPoint corner(int p_no) - { - if (p_no == 0) - { + + public IntPoint corner(int p_no) { + if (p_no == 0) { return ll; } - if (p_no == 1) - { + if (p_no == 1) { return new IntPoint(ur.x, ll.y); } - if (p_no == 2) - { + if (p_no == 2) { return ur; } - if (p_no == 3) - { + if (p_no == 3) { return new IntPoint(ll.x, ur.y); } throw new IllegalArgumentException("IntBox.corner: p_no out of range"); } - - public int dimension() - { - if (is_empty()) - { + + public int dimension() { + if (is_empty()) { return -1; } - if (ll.equals(ur)) - { + if (ll.equals(ur)) { return 0; } - if (ur.x == ll.x || ll.y == ur.y) - { + if (ur.x == ll.x || ll.y == ur.y) { return 1; } return 2; } - + /** * Chechs, if p_point is located in the interiour of this box. */ - public boolean contains_inside(IntPoint p_point) - { - return p_point.x > this.ll.x && p_point.x < this.ur.x - && p_point.y > this.ll.y && p_point.y < this.ur.y; - } - - public boolean is_IntBox() - { + public boolean contains_inside(IntPoint p_point) { + return p_point.x > this.ll.x && p_point.x < this.ur.x + && p_point.y > this.ll.y && p_point.y < this.ur.y; + } + + public boolean is_IntBox() { return true; } - - public TileShape simplify() - { + + public TileShape simplify() { return this; } - + /** * Calculates the nearest point of this box to p_from_point. */ - public FloatPoint nearest_point(FloatPoint p_from_point) - { + public FloatPoint nearest_point(FloatPoint p_from_point) { double x; if (p_from_point.x <= ll.x) x = ll.x; @@ -180,7 +161,7 @@ else if (p_from_point.x >= ur.x) x = ur.x; else x = p_from_point.x; - + double y; if (p_from_point.y <= ll.y) y = ll.y; @@ -188,119 +169,100 @@ else if (p_from_point.y >= ur.y) y = ur.y; else y = p_from_point.y; - - return new FloatPoint(x,y); + + return new FloatPoint(x, y); } - + /** * Calculates the sorted p_max_result_points nearest points on the border of this box. * p_point is assumed to be located in the interiour of this nox. * The funtion is only imoplemented for p_max_result_points <= 2; */ - public IntPoint[] nearest_border_projections(IntPoint p_point, int p_max_result_points) - { - if (p_max_result_points <= 0) - { + public IntPoint[] nearest_border_projections(IntPoint p_point, int p_max_result_points) { + if (p_max_result_points <= 0) { return new IntPoint[0]; } p_max_result_points = Math.min(p_max_result_points, 2); - IntPoint [] result = new IntPoint[p_max_result_points]; - - int lower_x_diff = p_point.x - ll.x; - int upper_x_diff = ur.x - p_point.x; - int lower_y_diff = p_point.y - ll.y; - int upper_y_diff = ur.y - p_point.y; - - int min_diff; - int second_min_diff; - + IntPoint[] result = new IntPoint[p_max_result_points]; + + int lower_x_diff = p_point.x - ll.x; + int upper_x_diff = ur.x - p_point.x; + int lower_y_diff = p_point.y - ll.y; + int upper_y_diff = ur.y - p_point.y; + + int min_diff; + int second_min_diff; + int nearest_projection_x = p_point.x; int nearest_projection_y = p_point.y; int second_nearest_projection_x = p_point.x; int second_nearest_projection_y = p_point.y; - if (lower_x_diff <= upper_x_diff) - { + if (lower_x_diff <= upper_x_diff) { min_diff = lower_x_diff; second_min_diff = upper_x_diff; nearest_projection_x = ll.x; second_nearest_projection_x = ur.x; - } - else - { + } else { min_diff = upper_x_diff; second_min_diff = lower_x_diff; nearest_projection_x = ur.x; second_nearest_projection_x = ll.x; } - if (lower_y_diff < min_diff) - { + if (lower_y_diff < min_diff) { second_min_diff = min_diff; min_diff = lower_y_diff; second_nearest_projection_x = nearest_projection_x; second_nearest_projection_y = nearest_projection_y; nearest_projection_x = p_point.x; nearest_projection_y = ll.y; - } - else if (lower_y_diff < second_min_diff) - { + } else if (lower_y_diff < second_min_diff) { second_min_diff = lower_y_diff; second_nearest_projection_x = p_point.x; second_nearest_projection_y = ll.y; } - if (upper_y_diff < min_diff) - { + if (upper_y_diff < min_diff) { second_min_diff = min_diff; min_diff = upper_y_diff; second_nearest_projection_x = nearest_projection_x; second_nearest_projection_y = nearest_projection_y; nearest_projection_x = p_point.x; nearest_projection_y = ur.y; - } - else if (upper_y_diff < second_min_diff) - { + } else if (upper_y_diff < second_min_diff) { second_min_diff = upper_y_diff; second_nearest_projection_x = p_point.x; second_nearest_projection_y = ur.y; } result[0] = new IntPoint(nearest_projection_x, nearest_projection_y); - if (result.length > 1) - { + if (result.length > 1) { result[1] = new IntPoint(second_nearest_projection_x, second_nearest_projection_y); } - + return result; } - + /** * Calculates distance of this box to p_from_point. */ - public double distance(FloatPoint p_from_point) - { + public double distance(FloatPoint p_from_point) { return p_from_point.distance(nearest_point(p_from_point)); } - + /** * Computes the weighted distance to the box p_other. */ - public double weighted_distance(IntBox p_other, double p_horizontal_weight, double p_vertical_weight) - { + public double weighted_distance(IntBox p_other, double p_horizontal_weight, double p_vertical_weight) { double result; - + double max_ll_x = Math.max(this.ll.x, p_other.ll.x); double max_ll_y = Math.max(this.ll.y, p_other.ll.y); double min_ur_x = Math.min(this.ur.x, p_other.ur.x); double min_ur_y = Math.min(this.ur.y, p_other.ur.y); - - if (min_ur_x >= max_ll_x) - { + + if (min_ur_x >= max_ll_x) { result = Math.max(p_vertical_weight * (max_ll_y - min_ur_y), 0); - } - else if (min_ur_y >= max_ll_y) - { + } else if (min_ur_y >= max_ll_y) { result = Math.max(p_horizontal_weight * (max_ll_x - min_ur_x), 0); - } - else - { + } else { double delta_x = max_ll_x - min_ur_x; double delta_y = max_ll_y - min_ur_y; delta_x *= p_horizontal_weight; @@ -309,65 +271,53 @@ else if (min_ur_y >= max_ll_y) } return result; } - - public IntBox bounding_box() - { + + public IntBox bounding_box() { return this; } - - public IntOctagon bounding_octagon() - { + + public IntOctagon bounding_octagon() { return to_IntOctagon(); } - - public boolean is_bounded() - { + + public boolean is_bounded() { return true; } - - public IntBox bounding_tile() - { + + public IntBox bounding_tile() { return this; } - - public boolean corner_is_bounded(int p_no) - { + + public boolean corner_is_bounded(int p_no) { return true; } - - public RegularTileShape union(RegularTileShape p_other) - { + + public RegularTileShape union(RegularTileShape p_other) { return p_other.union(this); } - - public IntBox union(IntBox p_other) - { + + public IntBox union(IntBox p_other) { int llx = Math.min(ll.x, p_other.ll.x); int lly = Math.min(ll.y, p_other.ll.y); int urx = Math.max(ur.x, p_other.ur.x); int ury = Math.max(ur.y, p_other.ur.y); return new IntBox(llx, lly, urx, ury); } - + /** * Returns the intersection of this box with an IntBox. */ - public IntBox intersection(IntBox p_other) - { - if (p_other.ll.x > ur.x) - { + public IntBox intersection(IntBox p_other) { + if (p_other.ll.x > ur.x) { return EMPTY; } - if (p_other.ll.y > ur.y) - { + if (p_other.ll.y > ur.y) { return EMPTY; } - if (ll.x > p_other.ur.x) - { + if (ll.x > p_other.ur.x) { return EMPTY; } - if (ll.y > p_other.ur.y) - { + if (ll.y > p_other.ur.y) { return EMPTY; } int llx = Math.max(ll.x, p_other.ll.x); @@ -376,33 +326,27 @@ public IntBox intersection(IntBox p_other) int ury = Math.min(ur.y, p_other.ur.y); return new IntBox(llx, lly, urx, ury); } - + /** * returns the intersection of this box with a ConvexShape */ - public TileShape intersection(TileShape p_other) - { + public TileShape intersection(TileShape p_other) { return p_other.intersection(this); } - - - IntOctagon intersection(IntOctagon p_other) - { + + IntOctagon intersection(IntOctagon p_other) { return p_other.intersection(this.to_IntOctagon()); } - - Simplex intersection(Simplex p_other) - { + + Simplex intersection(Simplex p_other) { return p_other.intersection(this.to_Simplex()); } - - public boolean intersects(Shape p_other) - { + + public boolean intersects(Shape p_other) { return p_other.intersects(this); } - - public boolean intersects(IntBox p_other) - { + + public boolean intersects(IntBox p_other) { if (p_other.ll.x > this.ur.x) return false; if (p_other.ll.y > this.ur.y) @@ -413,12 +357,11 @@ public boolean intersects(IntBox p_other) return false; return true; } - + /** * Returns true, if this box intersects with p_other and the intersection is 2-dimensional. */ - public boolean overlaps(IntBox p_other) - { + public boolean overlaps(IntBox p_other) { if (p_other.ll.x >= this.ur.x) return false; if (p_other.ll.y >= this.ur.y) @@ -429,61 +372,53 @@ public boolean overlaps(IntBox p_other) return false; return true; } - - public boolean contains(RegularTileShape p_other) - { + + public boolean contains(RegularTileShape p_other) { return p_other.is_contained_in(this); } - - public RegularTileShape bounding_shape(ShapeBoundingDirections p_dirs) - { + + public RegularTileShape bounding_shape(ShapeBoundingDirections p_dirs) { return p_dirs.bounds(this); } - + /** * Enlarges the box by p_offset. * Contrary to the offset() method the result is an IntOctagon, not an IntBox. */ - public IntOctagon enlarge(double p_offset) - { + public IntOctagon enlarge(double p_offset) { return bounding_octagon().offset(p_offset); } - - public IntBox translate_by(Vector p_rel_coor) - { + + public IntBox translate_by(Vector p_rel_coor) { // This function is at the moment only implemented for Vectors // with integer coordinates. // The general implementation is still missing. - - if (p_rel_coor.equals(Vector.ZERO)) - { + + if (p_rel_coor.equals(Vector.ZERO)) { return this; } - IntPoint new_ll = (IntPoint)ll.translate_by(p_rel_coor); - IntPoint new_ur = (IntPoint)ur.translate_by(p_rel_coor); + IntPoint new_ll = (IntPoint) ll.translate_by(p_rel_coor); + IntPoint new_ur = (IntPoint) ur.translate_by(p_rel_coor); return new IntBox(new_ll, new_ur); } - - public IntBox turn_90_degree(int p_factor, IntPoint p_pole) - { + + public IntBox turn_90_degree(int p_factor, IntPoint p_pole) { IntPoint p1 = (IntPoint) ll.turn_90_degree(p_factor, p_pole); IntPoint p2 = (IntPoint) ur.turn_90_degree(p_factor, p_pole); - + int llx = Math.min(p1.x, p2.x); int lly = Math.min(p1.y, p2.y); int urx = Math.max(p1.x, p2.x); int ury = Math.max(p1.y, p2.y); - return new IntBox(llx,lly,urx,ury); + return new IntBox(llx, lly, urx, ury); } - - public Line border_line(int p_no) - { + + public Line border_line(int p_no) { int a_x; int a_y; int b_x; int b_y; - switch (p_no) - { + switch (p_no) { case 0: // lower boundary line a_x = 0; @@ -518,200 +453,158 @@ public Line border_line(int p_no) } return new Line(a_x, a_y, b_x, b_y); } - - public int border_line_index(Line p_line) - { + + public int border_line_index(Line p_line) { System.out.println("edge_index_of_line not yet implemented for IntBoxes"); return -1; } - + /** * Returns the box offseted by p_dist. * If p_dist > 0, the offset is to the outside, * else to the inside. */ - public IntBox offset(double p_dist) - { - if (p_dist == 0 || is_empty()) - { + public IntBox offset(double p_dist) { + if (p_dist == 0 || is_empty()) { return this; } - int dist = (int)Math.round(p_dist); + int dist = (int) Math.round(p_dist); IntPoint lower_left = new IntPoint(ll.x - dist, ll.y - dist); IntPoint upper_right = new IntPoint(ur.x + dist, ur.y + dist); return new IntBox(lower_left, upper_right); } - + /** * Returns the box, where the horizontal boundary is offseted by p_dist. * If p_dist > 0, the offset is to the outside, * else to the inside. */ - public IntBox horizontal_offset(double p_dist) - { - if (p_dist == 0 || is_empty()) - { + public IntBox horizontal_offset(double p_dist) { + if (p_dist == 0 || is_empty()) { return this; } - int dist = (int)Math.round(p_dist); + int dist = (int) Math.round(p_dist); IntPoint lower_left = new IntPoint(ll.x - dist, ll.y); IntPoint upper_right = new IntPoint(ur.x + dist, ur.y); return new IntBox(lower_left, upper_right); } - + /** * Returns the box, where the vertical boundary is offseted by p_dist. * If p_dist > 0, the offset is to the outside, * else to the inside. */ - public IntBox vertical_offset(double p_dist) - { - if (p_dist == 0 || is_empty()) - { + public IntBox vertical_offset(double p_dist) { + if (p_dist == 0 || is_empty()) { return this; } - int dist = (int)Math.round(p_dist); + int dist = (int) Math.round(p_dist); IntPoint lower_left = new IntPoint(ll.x, ll.y - dist); IntPoint upper_right = new IntPoint(ur.x, ur.y + dist); return new IntBox(lower_left, upper_right); } - + /** * Shrinks the width and height of the box by the input width. * The box will not vanish completely. */ - public IntBox shrink(int p_width) - { + public IntBox shrink(int p_width) { int ll_x; int ur_x; - if (2 * p_width <= this.ur.x - this.ll.x) - { + if (2 * p_width <= this.ur.x - this.ll.x) { ll_x = this.ll.x + p_width; ur_x = this.ur.x - p_width; - } - else - { + } else { ll_x = (this.ll.x + this.ur.x) / 2; ur_x = ll_x; } int ll_y; int ur_y; - if (2 * p_width <= this.ur.y - this.ll.y) - { + if (2 * p_width <= this.ur.y - this.ll.y) { ll_y = this.ll.y + p_width; ur_y = this.ur.y - p_width; - } - else - { + } else { ll_y = (this.ll.y + this.ur.y) / 2; ur_y = ll_y; } return new IntBox(ll_x, ll_y, ur_x, ur_y); } - - public Side compare(RegularTileShape p_other, int p_edge_no) - { + + public Side compare(RegularTileShape p_other, int p_edge_no) { Side result = p_other.compare(this, p_edge_no); return result.negate(); } - - public Side compare(IntBox p_other, int p_edge_no) - { + + public Side compare(IntBox p_other, int p_edge_no) { Side result; - switch (p_edge_no) - { + switch (p_edge_no) { case 0: // compare the lower edge line - if (ll.y > p_other.ll.y) - { + if (ll.y > p_other.ll.y) { result = Side.ON_THE_LEFT; - } - else if (ll.y < p_other.ll.y) - { + } else if (ll.y < p_other.ll.y) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; - + case 1: // compare the right edge line - if (ur.x < p_other.ur.x) - { + if (ur.x < p_other.ur.x) { result = Side.ON_THE_LEFT; - } - else if (ur.x > p_other.ur.x) - { + } else if (ur.x > p_other.ur.x) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; - + case 2: // compare the upper edge line - if (ur.y < p_other.ur.y) - { + if (ur.y < p_other.ur.y) { result = Side.ON_THE_LEFT; - } - else if (ur.y > p_other.ur.y) - { + } else if (ur.y > p_other.ur.y) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; - + case 3: // compare the left edge line - if (ll.x > p_other.ll.x) - { + if (ll.x > p_other.ll.x) { result = Side.ON_THE_LEFT; - } - else if (ll.x < p_other.ll.x) - { + } else if (ll.x < p_other.ll.x) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; default: throw new IllegalArgumentException ("IntBox.compare: p_edge_no out of range"); - + } return result; } - + /** * Returns an object of class IntOctagon defining the same shape */ - public IntOctagon to_IntOctagon() - { + public IntOctagon to_IntOctagon() { return new IntOctagon(ll.x, ll.y, ur.x, ur.y, ll.x - ur.y, ur.x - ll.y, ll.x + ll.y, ur.x + ur.y); } - + /** * Returns an object of class Simplex defining the same shape */ - public Simplex to_Simplex() - { + public Simplex to_Simplex() { Line[] line_arr; - if (is_empty()) - { + if (is_empty()) { line_arr = new Line[0]; - } - else - { + } else { line_arr = new Line[4]; line_arr[0] = Line.get_instance(ll, IntDirection.RIGHT); line_arr[1] = Line.get_instance(ur, IntDirection.UP); @@ -720,176 +613,133 @@ public Simplex to_Simplex() } return new Simplex(line_arr); } - - public boolean is_contained_in( IntBox p_other) - { - if (is_empty() || this == p_other) - { + + public boolean is_contained_in(IntBox p_other) { + if (is_empty() || this == p_other) { return true; } if (ll.x < p_other.ll.x || ll.y < p_other.ll.y - || ur.x > p_other.ur.x || ur.y > p_other.ur.y) - { + || ur.x > p_other.ur.x || ur.y > p_other.ur.y) { return false; } return true; } - + /** * Return true, if p_other is contained in the interiour of this box. */ - public boolean contains_in_interiour(IntBox p_other) - { - if (p_other.is_empty()) - { + public boolean contains_in_interiour(IntBox p_other) { + if (p_other.is_empty()) { return true; } if (p_other.ll.x <= ll.x || p_other.ll.y <= ll.y - || p_other.ur.x >= ur.x || p_other.ur.y >= ur.y) - { + || p_other.ur.x >= ur.x || p_other.ur.y >= ur.y) { return false; } return true; } - + /** * Calculates the part of p_from_box, which has minimal distance * to this box. */ - public IntBox nearest_part(IntBox p_from_box) - { + public IntBox nearest_part(IntBox p_from_box) { int ll_x; - - if (p_from_box.ll.x >= this.ll.x) - { + + if (p_from_box.ll.x >= this.ll.x) { ll_x = p_from_box.ll.x; - } - else if (p_from_box.ur.x >= this.ll.x) - { + } else if (p_from_box.ur.x >= this.ll.x) { ll_x = this.ll.x; - } - else - { + } else { ll_x = p_from_box.ur.x; } - + int ur_x; - - if (p_from_box.ur.x <= this.ur.x) - { + + if (p_from_box.ur.x <= this.ur.x) { ur_x = p_from_box.ur.x; - } - else if (p_from_box.ll.x <= this.ur.x) - { + } else if (p_from_box.ll.x <= this.ur.x) { ur_x = this.ur.x; - } - else - { + } else { ur_x = p_from_box.ll.x; } - + int ll_y; - - if (p_from_box.ll.y >= this.ll.y) - { + + if (p_from_box.ll.y >= this.ll.y) { ll_y = p_from_box.ll.y; - } - else if (p_from_box.ur.y >= this.ll.y) - { + } else if (p_from_box.ur.y >= this.ll.y) { ll_y = this.ll.y; - } - else - { + } else { ll_y = p_from_box.ur.y; } - + int ur_y; - - if (p_from_box.ur.y <= this.ur.y) - { + + if (p_from_box.ur.y <= this.ur.y) { ur_y = p_from_box.ur.y; - } - else if (p_from_box.ll.y <= this.ur.y) - { + } else if (p_from_box.ll.y <= this.ur.y) { ur_y = this.ur.y; - } - else - { + } else { ur_y = p_from_box.ll.y; } return new IntBox(ll_x, ll_y, ur_x, ur_y); } - - public boolean is_contained_in( IntOctagon p_other) - { + + public boolean is_contained_in(IntOctagon p_other) { return p_other.contains(to_IntOctagon()); } - - public boolean intersects( IntOctagon p_other) - { + + public boolean intersects(IntOctagon p_other) { return p_other.intersects(to_IntOctagon()); } - - public boolean intersects( Simplex p_other) - { + + public boolean intersects(Simplex p_other) { return p_other.intersects(to_Simplex()); } - - public boolean intersects( Circle p_other) - { + + public boolean intersects(Circle p_other) { return p_other.intersects(this); } - - public IntOctagon union( IntOctagon p_other) - { + + public IntOctagon union(IntOctagon p_other) { return p_other.union(to_IntOctagon()); } - - public Side compare(IntOctagon p_other, int p_edge_no) - { + + public Side compare(IntOctagon p_other, int p_edge_no) { return to_IntOctagon().compare(p_other, p_edge_no); } - + /** * Divides this box into sections with width and height at most p_max_section_width * of about equal size. */ - public IntBox[] divide_into_sections(double p_max_section_width) - { - if (p_max_section_width <= 0) - { + public IntBox[] divide_into_sections(double p_max_section_width) { + if (p_max_section_width <= 0) { return new IntBox[0]; } double length = this.ur.x - this.ll.x; double height = this.ur.y - this.ll.y; - int x_count = (int) Math.ceil(length / p_max_section_width); + int x_count = (int) Math.ceil(length / p_max_section_width); int y_count = (int) Math.ceil(height / p_max_section_width); int section_length_x = (int) Math.ceil(length / x_count); int section_length_y = (int) Math.ceil(height / y_count); - IntBox [] result = new IntBox[x_count * y_count]; + IntBox[] result = new IntBox[x_count * y_count]; int curr_index = 0; - for (int j = 0; j < y_count; ++j) - { + for (int j = 0; j < y_count; ++j) { int curr_lly = this.ll.y + j * section_length_y; int curr_ury; - if (j == (y_count - 1)) - { + if (j == (y_count - 1)) { curr_ury = this.ur.y; - } - else - { + } else { curr_ury = curr_lly + section_length_y; } - for (int i = 0; i < x_count; ++i) - { + for (int i = 0; i < x_count; ++i) { int curr_llx = this.ll.x + i * section_length_x; int curr_urx; - if (i == (x_count - 1)) - { + if (i == (x_count - 1)) { curr_urx = this.ur.x; - } - else - { + } else { curr_urx = curr_llx + section_length_x; } result[curr_index] = new IntBox(curr_llx, curr_lly, curr_urx, curr_ury); @@ -898,70 +748,62 @@ public IntBox[] divide_into_sections(double p_max_section_width) } return result; } - - public TileShape[] cutout(TileShape p_shape) - { + + public TileShape[] cutout(TileShape p_shape) { TileShape[] tmp_result = p_shape.cutout_from(this); TileShape[] result = new TileShape[tmp_result.length]; - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = tmp_result[i].simplify(); } return result; } - - IntBox[] cutout_from(IntBox p_d) - { + + IntBox[] cutout_from(IntBox p_d) { IntBox c = this.intersection(p_d); - if (this.is_empty() || c.dimension() < this.dimension()) - { + if (this.is_empty() || c.dimension() < this.dimension()) { // there is only an overlap at the border IntBox[] result = new IntBox[1]; result[0] = p_d; return result; } - + IntBox[] result = new IntBox[4]; - + result[0] = new IntBox(p_d.ll.x, p_d.ll.y, c.ur.x, c.ll.y); - + result[1] = new IntBox(p_d.ll.x, c.ll.y, c.ll.x, p_d.ur.y); - + result[2] = new IntBox(c.ur.x, p_d.ll.y, p_d.ur.x, c.ur.y); - + result[3] = new IntBox(c.ll.x, c.ur.y, p_d.ur.x, p_d.ur.y); - + // now the division will be optimised, so that the cumulative // circumference will be minimal. - + IntBox b = null; - - if (c.ll.x - p_d.ll.x > c.ll.y - p_d.ll.y) - { + + if (c.ll.x - p_d.ll.x > c.ll.y - p_d.ll.y) { // switch left dividing line to lower b = result[0]; result[0] = new IntBox(c.ll.x, b.ll.y, b.ur.x, b.ur.y); b = result[1]; result[1] = new IntBox(b.ll.x, p_d.ll.y, b.ur.x, b.ur.y); } - if (p_d.ur.y - c.ur.y > c.ll.x - p_d.ll.x) - { + if (p_d.ur.y - c.ur.y > c.ll.x - p_d.ll.x) { // switch upper dividing line to the left b = result[1]; - result[1]= new IntBox(b.ll.x, b.ll.y, b.ur.x, c.ur.y); + result[1] = new IntBox(b.ll.x, b.ll.y, b.ur.x, c.ur.y); b = result[3]; result[3] = new IntBox(p_d.ll.x, b.ll.y, b.ur.x, b.ur.y); } - if (p_d.ur.x - c.ur.x > p_d.ur.y - c.ur.y) - { + if (p_d.ur.x - c.ur.x > p_d.ur.y - c.ur.y) { // switch right dividing line to upper b = result[2]; result[2] = new IntBox(b.ll.x, b.ll.y, b.ur.x, p_d.ur.y); b = result[3]; result[3] = new IntBox(b.ll.x, b.ll.y, c.ur.x, b.ur.y); } - if (c.ll.y - p_d.ll.y > p_d.ur.x - c.ur.x) - { + if (c.ll.y - p_d.ll.y > p_d.ur.x - c.ur.x) { // switch lower dividing line to the left b = result[0]; result[0] = new IntBox(b.ll.x, b.ll.y, p_d.ur.x, b.ur.y); @@ -970,24 +812,12 @@ IntBox[] cutout_from(IntBox p_d) } return result; } - - Simplex[] cutout_from(Simplex p_simplex) - { + + Simplex[] cutout_from(Simplex p_simplex) { return this.to_Simplex().cutout_from(p_simplex); } - - IntOctagon[] cutout_from(IntOctagon p_oct) - { + + IntOctagon[] cutout_from(IntOctagon p_oct) { return this.to_IntOctagon().cutout_from(p_oct); } - - /** - * coordinates of the lower left corner - */ - public final IntPoint ll; - - /** - * coordinates of the upper right corner - */ - public final IntPoint ur; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/IntDirection.java b/src/main/java/net/freerouting/geometry/planar/IntDirection.java index 875c3663..3417be4c 100644 --- a/src/main/java/net/freerouting/geometry/planar/IntDirection.java +++ b/src/main/java/net/freerouting/geometry/planar/IntDirection.java @@ -19,154 +19,131 @@ */ package net.freerouting.geometry.planar; + import net.freerouting.datastructures.Signum; /** - * * Implements an abstract class Direction as an equivalence class of IntVector's. * - * * @author Alfons Wirtz */ -public class IntDirection extends Direction implements java.io.Serializable -{ - - - public boolean is_orthogonal() - { - return ( x == 0 || y == 0 ) ; - } - - public boolean is_diagonal() - { - return ( Math.abs(x) == Math.abs(y) ) ; - } - - public Vector get_vector() - { - return new IntVector(x,y); - } - - IntDirection(int p_x, int p_y) - { +public class IntDirection extends Direction implements java.io.Serializable { + + + public final int x; + public final int y; + + IntDirection(int p_x, int p_y) { x = p_x; y = p_y; } - - IntDirection(IntVector p_vector) - { + + IntDirection(IntVector p_vector) { x = p_vector.x; y = p_vector.y; } - - - - int compareTo( IntDirection p_other ) - { - if (y > 0) - { - if (p_other.y < 0) - { - return -1 ; + + public boolean is_orthogonal() { + return (x == 0 || y == 0); + } + + public boolean is_diagonal() { + return (Math.abs(x) == Math.abs(y)); + } + + public Vector get_vector() { + return new IntVector(x, y); + } + + int compareTo(IntDirection p_other) { + if (y > 0) { + if (p_other.y < 0) { + return -1; } - if (p_other.y == 0) - { - if (p_other.x > 0) - { - return 1 ; + if (p_other.y == 0) { + if (p_other.x > 0) { + return 1; } - return -1 ; + return -1; } - } - else if (y < 0) - { - if (p_other.y >= 0) - { - return 1 ; + } else if (y < 0) { + if (p_other.y >= 0) { + return 1; } - } - else // y == 0 + } else // y == 0 { - if (x > 0) - { - if (p_other.y != 0 || p_other.x < 0) - { - return -1 ; + if (x > 0) { + if (p_other.y != 0 || p_other.x < 0) { + return -1; } - return 0 ; + return 0; } // x < 0 - if (p_other.y > 0 || p_other.y == 0 && p_other.x > 0) - { - return 1 ; + if (p_other.y > 0 || p_other.y == 0 && p_other.x > 0) { + return 1; } - if (p_other.y < 0) - { - return -1 ; + if (p_other.y < 0) { + return -1; } return 0; } - + // now this direction and p_other are located in the same // open horizontal half plane - + double determinant = (double) p_other.x * y - (double) p_other.y * x; return Signum.as_int(determinant); } - - public Direction opposite() - { + + public Direction opposite() { return new IntDirection(-x, -y); } - - public Direction turn_45_degree(int p_factor) - { - int n = p_factor % 8 ; - int new_x ; - int new_y ; - switch (n) - { + + public Direction turn_45_degree(int p_factor) { + int n = p_factor % 8; + int new_x; + int new_y; + switch (n) { case 0: // 0 degree new_x = x; new_y = y; break; case 1: // 45 degree - new_x = x - y ; - new_y = x + y ; + new_x = x - y; + new_y = x + y; break; case 2: // 90 degree - new_x = -y ; - new_y = x ; + new_x = -y; + new_y = x; break; case 3: // 135 degree - new_x = -x - y ; - new_y = x - y ; + new_x = -x - y; + new_y = x - y; break; case 4: // 180 degree - new_x = -x ; - new_y = -y ; + new_x = -x; + new_y = -y; break; case 5: // 225 degree - new_x = y - x ; - new_y = -x - y ; + new_x = y - x; + new_y = -x - y; break; case 6: // 270 degree - new_x = y ; - new_y = -x ; + new_x = y; + new_y = -x; break; case 7: // 315 degree - new_x = x + y ; - new_y = y - x ; + new_x = x + y; + new_y = y - x; break; default: - new_x = 0 ; - new_y = 0 ; + new_x = 0; + new_y = 0; } - return new IntDirection(new_x, new_y) ; + return new IntDirection(new_x, new_y); } - - + /** * Implements the Comparable interface. * Returns 1, if this direction has a strict bigger angle with @@ -175,21 +152,15 @@ public Direction turn_45_degree(int p_factor) * and -1 otherwise. * Throws an exception, if p_other_direction is not a Direction. */ - public int compareTo(Direction p_other_direction) - { + public int compareTo(Direction p_other_direction) { return -p_other_direction.compareTo(this); } - - int compareTo(BigIntDirection p_other) - { + + int compareTo(BigIntDirection p_other) { return -(p_other.compareTo(this)); } - - final double determinant(IntDirection p_other) - { - return (double)x * p_other.y - (double)y * p_other.x; - } - - public final int x; - public final int y; + + final double determinant(IntDirection p_other) { + return (double) x * p_other.y - (double) y * p_other.x; + } } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/IntOctagon.java b/src/main/java/net/freerouting/geometry/planar/IntOctagon.java index 4e8d5353..681b7af5 100644 --- a/src/main/java/net/freerouting/geometry/planar/IntOctagon.java +++ b/src/main/java/net/freerouting/geometry/planar/IntOctagon.java @@ -17,23 +17,57 @@ package net.freerouting.geometry.planar; /** - * * Implements functionality for convex shapes, whose borderline directions are * multiples of 45 degree and defined with integer coordinates. * * @author Alfons Wirtz */ -public class IntOctagon extends RegularTileShape implements java.io.Serializable -{ +public class IntOctagon extends RegularTileShape implements java.io.Serializable { /** * Reusable instance of an empty octagon. */ public static final IntOctagon EMPTY = new IntOctagon(Limits.CRIT_INT, Limits.CRIT_INT, -Limits.CRIT_INT, - -Limits.CRIT_INT, Limits.CRIT_INT, -Limits.CRIT_INT, - Limits.CRIT_INT, -Limits.CRIT_INT); - + -Limits.CRIT_INT, Limits.CRIT_INT, -Limits.CRIT_INT, + Limits.CRIT_INT, -Limits.CRIT_INT); + /** + * x coordinate of the left border line + */ + public final int lx; + /** + * y coordinate of the lower border line + */ + public final int ly; + /** + * x coordinate of the right border line + */ + public final int rx; + /** + * y coordinate of the upper border line + */ + public final int uy; + /** + * x axis intersection of the upper left border line + */ + public final int ulx; + /** + * x axis intersection of the lower right border line + */ + public final int lrx; + /** + * x axis intersection of the lower left border line + */ + public final int llx; + /** + * x axis intersection of the upper right border line + */ + public final int urx; + /** + * Result of to_simplex() memorized for performance reasons. + */ + private Simplex precalculated_to_simplex = null; + /** * Creates an IntOctagon from 8 integer values. * p_lx is the smallest x value of the shape. @@ -50,8 +84,7 @@ public class IntOctagon extends RegularTileShape implements java.io.Serializable * with the x axis. */ public IntOctagon(int p_lx, int p_ly, int p_rx, int p_uy, - int p_ulx, int p_lrx, int p_llx, int p_urx) - { + int p_ulx, int p_lrx, int p_llx, int p_urx) { lx = p_lx; ly = p_ly; rx = p_rx; @@ -61,72 +94,56 @@ public IntOctagon(int p_lx, int p_ly, int p_rx, int p_uy, llx = p_llx; urx = p_urx; } - - public boolean is_empty() - { + + public boolean is_empty() { return this == EMPTY; } - - public boolean is_IntOctagon() - { + + public boolean is_IntOctagon() { return true; } - - public boolean is_bounded() - { + + public boolean is_bounded() { return true; } - - public boolean corner_is_bounded(int p_no) - { + + public boolean corner_is_bounded(int p_no) { return true; } - - public IntBox bounding_box() - { + + public IntBox bounding_box() { return new IntBox(lx, ly, rx, uy); } - - public IntOctagon bounding_octagon() - { + + public IntOctagon bounding_octagon() { return this; } - - public IntOctagon bounding_tile() - { + + public IntOctagon bounding_tile() { return this; } - - public int dimension() - { - if (this == EMPTY) - { + + public int dimension() { + if (this == EMPTY) { return -1; } int result; - - if (rx > lx && uy > ly && lrx > ulx && urx > llx) - { + + if (rx > lx && uy > ly && lrx > ulx && urx > llx) { result = 2; - } - else if (rx == lx && uy == ly) - { + } else if (rx == lx && uy == ly) { result = 0; - } - else - { + } else { result = 1; } return result; } - - public IntPoint corner(int p_no) - { - + + public IntPoint corner(int p_no) { + int x; int y; - switch (p_no) - { + switch (p_no) { case 0: x = llx - ly; y = ly; @@ -163,17 +180,15 @@ public IntPoint corner(int p_no) throw new IllegalArgumentException ("IntOctagon.corner: p_no out of range"); } - return new IntPoint(x,y); + return new IntPoint(x, y); } - + /** * Additional to the function corner() for performance reasons to avoid allocation of an IntPoint. */ - public int corner_y(int p_no) - { + public int corner_y(int p_no) { int y; - switch (p_no) - { + switch (p_no) { case 0: y = ly; break; @@ -204,16 +219,14 @@ public int corner_y(int p_no) } return y; } - + /** * Additional to the function corner() for performance reasons to avoid allocation of an IntPoint. */ - public int corner_x(int p_no) - { - + public int corner_x(int p_no) { + int x; - switch (p_no) - { + switch (p_no) { case 0: x = llx - ly; break; @@ -244,40 +257,36 @@ public int corner_x(int p_no) } return x; } - - public double area() - { - + + public double area() { + // calculate half of the absolute value of // x0 (y1 - y7) + x1 (y2 - y0) + x2 (y3 - y1) + ...+ x7( y0 - y6) // where xi, yi are the coordinates of the i-th corner of this Octagon. - + // Overwrites the same implementation in TileShape for performence // reasons to avoid Point allocation. - + double result = (double) (llx - ly) * (double) (ly - llx + lx); result += (double) (lrx + ly) * (double) (rx - lrx - ly); - result += (double) rx * (double) (urx - 2 * rx - ly + uy + lrx); + result += (double) rx * (double) (urx - 2 * rx - ly + uy + lrx); result += (double) (urx - uy) * (double) (uy - urx + rx); result += (double) (ulx + uy) * (double) (lx - ulx - uy); - result += (double) lx * (double) (llx - 2 * lx - uy + ly + ulx); - - return 0.5 * Math.abs(result); + result += (double) lx * (double) (llx - 2 * lx - uy + ly + ulx); + + return 0.5 * Math.abs(result); } - - public int border_line_count() - { + + public int border_line_count() { return 8; } - - public Line border_line(int p_no) - { + + public Line border_line(int p_no) { int a_x; int a_y; int b_x; int b_y; - switch (p_no) - { + switch (p_no) { case 0: // lower boundary line a_x = 0; @@ -340,15 +349,13 @@ public Line border_line(int p_no) } return new Line(a_x, a_y, b_x, b_y); } - - public IntOctagon translate_by(Vector p_rel_coor) - { + + public IntOctagon translate_by(Vector p_rel_coor) { // This function is at the moment only implemented for Vectors // with integer coordinates. // The general implementation is still missing. - - if (p_rel_coor.equals(Vector.ZERO)) - { + + if (p_rel_coor.equals(Vector.ZERO)) { return this; } IntVector rel_coor = (IntVector) p_rel_coor; @@ -356,62 +363,52 @@ public IntOctagon translate_by(Vector p_rel_coor) ulx + rel_coor.x - rel_coor.y, lrx + rel_coor.x - rel_coor.y, llx + rel_coor.x + rel_coor.y, urx + rel_coor.x + rel_coor.y); } - - public double max_width() - { + + public double max_width() { double width_1 = Math.max(rx - lx, uy - ly); double width2 = Math.max(urx - llx, lrx - ulx); - double result = Math.max(width_1, width2/ Limits.sqrt2); + double result = Math.max(width_1, width2 / Limits.sqrt2); return result; } - - public double min_width() - { + + public double min_width() { double width_1 = Math.min(rx - lx, uy - ly); double width2 = Math.min(urx - llx, lrx - ulx); - double result = Math.min(width_1, width2/ Limits.sqrt2); + double result = Math.min(width_1, width2 / Limits.sqrt2); return result; } - - public IntOctagon offset(double p_distance) - { + + public IntOctagon offset(double p_distance) { int width = (int) Math.round(p_distance); - if (width == 0) - { + if (width == 0) { return this; } - int dia_width = (int) Math.round(Limits.sqrt2 * p_distance); + int dia_width = (int) Math.round(Limits.sqrt2 * p_distance); IntOctagon result = new IntOctagon(lx - width, ly - width, rx + width, uy + width, - ulx - dia_width, lrx + dia_width, - llx - dia_width, urx + dia_width); + ulx - dia_width, lrx + dia_width, + llx - dia_width, urx + dia_width); return result.normalize(); } - - public IntOctagon enlarge(double p_offset) - { + + public IntOctagon enlarge(double p_offset) { return offset(p_offset); } - - public boolean contains(RegularTileShape p_other) - { + + public boolean contains(RegularTileShape p_other) { return p_other.is_contained_in(this); } - - public RegularTileShape union(RegularTileShape p_other) - { + + public RegularTileShape union(RegularTileShape p_other) { return p_other.union(this); } - - public TileShape intersection(TileShape p_other) - { + + public TileShape intersection(TileShape p_other) { return p_other.intersection(this); } - - public IntOctagon normalize() - { - if (lx > rx || ly > uy || llx > urx || ulx > lrx) - { + + public IntOctagon normalize() { + if (lx > rx || ly > uy || llx > urx || ulx > lrx) { return EMPTY; } int new_lx = lx; @@ -422,179 +419,172 @@ public IntOctagon normalize() int new_ulx = ulx; int new_lrx = lrx; int new_urx = urx; - + if (new_lx < new_llx - new_uy) - // the point new_lx, new_uy is the the lower left border line of - // this octagon - // change new_lx , that the the lower left border line runs through - // this point + // the point new_lx, new_uy is the the lower left border line of + // this octagon + // change new_lx , that the the lower left border line runs through + // this point { new_lx = new_llx - new_uy; } - + if (new_lx < new_ulx + new_ly) - // the point new_lx, new_ly is above the the upper left border line of - // this octagon - // change new_lx , that the the upper left border line runs through - // this point + // the point new_lx, new_ly is above the the upper left border line of + // this octagon + // change new_lx , that the the upper left border line runs through + // this point { new_lx = new_ulx + new_ly; } - + if (new_rx > new_urx - new_ly) - // the point new_rx, new_ly is above the the upper right border line of - // this octagon - // change new_rx , that the the upper right border line runs through - // this point + // the point new_rx, new_ly is above the the upper right border line of + // this octagon + // change new_rx , that the the upper right border line runs through + // this point { new_rx = new_urx - new_ly; } - + if (new_rx > new_lrx + new_uy) - // the point new_rx, new_uy is below the the lower right border line of - // this octagon - // change rx , that the the lower right border line runs through - // this point - + // the point new_rx, new_uy is below the the lower right border line of + // this octagon + // change rx , that the the lower right border line runs through + // this point + { new_rx = new_lrx + new_uy; } - + if (new_ly < new_lx - new_lrx) - // the point lx, ly is below the lower right border line of this - // octagon - // change ly, so that the lower right border line runs through - // this point + // the point lx, ly is below the lower right border line of this + // octagon + // change ly, so that the lower right border line runs through + // this point { new_ly = new_lx - new_lrx; } - + if (new_ly < new_llx - new_rx) - // the point rx, ly is below the lower left border line of - // this octagon. - // change ly, so that the lower left border line runs through - // this point + // the point rx, ly is below the lower left border line of + // this octagon. + // change ly, so that the lower left border line runs through + // this point { new_ly = new_llx - new_rx; } - + if (new_uy > new_urx - new_lx) - // the point lx, uy is above the upper right border line of - // this octagon. - // Change the uy, so that the upper right border line runs through - // this point. + // the point lx, uy is above the upper right border line of + // this octagon. + // Change the uy, so that the upper right border line runs through + // this point. { new_uy = new_urx - new_lx; } - + if (new_uy > new_rx - new_ulx) - // the point rx, uy is above the upper left border line of - // this octagon. - // Change the uy, so that the upper left border line runs through - // this point. + // the point rx, uy is above the upper left border line of + // this octagon. + // Change the uy, so that the upper left border line runs through + // this point. { new_uy = new_rx - new_ulx; } - + if (new_llx - new_lx < new_ly) - // The point lx, ly is above the lower left border line of - // this octagon. - // Change the lower left line, so that it runs through this point. + // The point lx, ly is above the lower left border line of + // this octagon. + // Change the lower left line, so that it runs through this point. { new_llx = new_lx + new_ly; } - + if (new_rx - new_lrx < new_ly) - // the point rx, ly is above the lower right border line of - // this octagon. - // Change the lower right line, so that it runs through this point. + // the point rx, ly is above the lower right border line of + // this octagon. + // Change the lower right line, so that it runs through this point. { new_lrx = new_rx - new_ly; } - + if (new_urx - new_rx > new_uy) - // the point rx, uy is below the upper right border line of p_oct. - // Change the upper right line, so that it runs through this point. + // the point rx, uy is below the upper right border line of p_oct. + // Change the upper right line, so that it runs through this point. { new_urx = new_uy + new_rx; } - + if (new_lx - new_ulx > new_uy) - // the point lx, uy is below the upper left border line of - // this octagon. - // Change the upper left line, so that it runs through this point. + // the point lx, uy is below the upper left border line of + // this octagon. + // Change the upper left line, so that it runs through this point. { new_ulx = new_lx - new_uy; } - - int diag_upper_y = (int)Math.ceil((new_urx - new_ulx) / 2.0); - + + int diag_upper_y = (int) Math.ceil((new_urx - new_ulx) / 2.0); + if (new_uy > diag_upper_y) - // the intersection of the upper right and the upper left border - // line is below new_uy. Adjust new_uy to diag_upper_y. + // the intersection of the upper right and the upper left border + // line is below new_uy. Adjust new_uy to diag_upper_y. { new_uy = diag_upper_y; } - - int diag_lower_y = (int)Math.floor((new_llx - new_lrx) / 2.0); - + + int diag_lower_y = (int) Math.floor((new_llx - new_lrx) / 2.0); + if (new_ly < diag_lower_y) - // the intersection of the lower right and the lower left border - // line is above new_ly. Adjust new_ly to diag_lower_y. + // the intersection of the lower right and the lower left border + // line is above new_ly. Adjust new_ly to diag_lower_y. { new_ly = diag_lower_y; } - - int diag_right_x = (int)Math.ceil((new_urx + new_lrx)/ 2.0); - + + int diag_right_x = (int) Math.ceil((new_urx + new_lrx) / 2.0); + if (new_rx > diag_right_x) - // the intersection of the upper right and the lower right border - // line is to the left of right x. Adjust new_rx to diag_right_x. + // the intersection of the upper right and the lower right border + // line is to the left of right x. Adjust new_rx to diag_right_x. { new_rx = diag_right_x; } - - int diag_left_x = (int)Math.floor((new_llx + new_ulx) / 2.0); - + + int diag_left_x = (int) Math.floor((new_llx + new_ulx) / 2.0); + if (new_lx < diag_left_x) - // the intersection of the lower left and the upper left border - // line is to the right of left x. Ajust new_lx to diag_left_x. + // the intersection of the lower left and the upper left border + // line is to the right of left x. Ajust new_lx to diag_left_x. { new_lx = diag_left_x; } if (new_lx > new_rx || new_ly > new_uy || new_llx > new_urx - || new_ulx > new_lrx) - { + || new_ulx > new_lrx) { return EMPTY; } return new IntOctagon(new_lx, new_ly, new_rx, new_uy, new_ulx, new_lrx, new_llx, new_urx); } - + /** * Checks, if this IntOctagon is normalized. */ - public boolean is_normalized() - { + public boolean is_normalized() { IntOctagon on = this.normalize(); boolean result = lx == on.lx && ly == on.ly && rx == on.rx && uy == on.uy && - llx == on.llx && lrx == on.lrx && ulx == on.ulx && urx == on.urx; + llx == on.llx && lrx == on.lrx && ulx == on.ulx && urx == on.urx; return result; } - - - public Simplex to_Simplex() - { - if (is_empty()) - { + + public Simplex to_Simplex() { + if (is_empty()) { return Simplex.EMPTY; } - if (precalculated_to_simplex == null) - { - Line [] line_arr = new Line[8]; - for (int i = 0; i < 8; ++i) - { + if (precalculated_to_simplex == null) { + Line[] line_arr = new Line[8]; + for (int i = 0; i < 8; ++i) { line_arr[i] = border_line(i); } Simplex curr_simplex = new Simplex(line_arr); @@ -602,572 +592,424 @@ public Simplex to_Simplex() } return precalculated_to_simplex; } - - public RegularTileShape bounding_shape(ShapeBoundingDirections p_dirs) - { + + public RegularTileShape bounding_shape(ShapeBoundingDirections p_dirs) { return p_dirs.bounds(this); } - - public boolean intersects(Shape p_other) - { + + public boolean intersects(Shape p_other) { return p_other.intersects(this); } - + /** * Returns true, if p_point is contained in this octagon. * Because of the parameter type FloatPoint, the function may not * be exact close to the border. */ - public boolean contains(FloatPoint p_point) - { - if (lx > p_point.x || ly > p_point.y - || rx < p_point.x || uy < p_point.y) - { + public boolean contains(FloatPoint p_point) { + if (lx > p_point.x || ly > p_point.y + || rx < p_point.x || uy < p_point.y) { return false; } double tmp_1 = p_point.x - p_point.y; double tmp_2 = p_point.x + p_point.y; - if (ulx > tmp_1 || lrx < tmp_1 || llx > tmp_2 || urx < tmp_2) - { + if (ulx > tmp_1 || lrx < tmp_1 || llx > tmp_2 || urx < tmp_2) { return false; } return true; } - + /** * Calculates the side of the point (p_x, p_y) of the border line with index p_border_line_no. * The border lines are located in counterclock sense around this octagon. */ - public Side side_of_border_line(int p_x, int p_y, int p_border_line_no) - { - + public Side side_of_border_line(int p_x, int p_y, int p_border_line_no) { + int tmp; - if (p_border_line_no == 0) - { + if (p_border_line_no == 0) { tmp = this.ly - p_y; - } - else if (p_border_line_no == 2) - { + } else if (p_border_line_no == 2) { tmp = p_x - this.rx; - } - else if (p_border_line_no == 4) - { + } else if (p_border_line_no == 4) { tmp = p_y - this.uy; - } - else if (p_border_line_no == 6) - { + } else if (p_border_line_no == 6) { tmp = this.lx - p_x; - } - else if (p_border_line_no == 1) - { + } else if (p_border_line_no == 1) { tmp = p_x - p_y - this.lrx; - } - else if (p_border_line_no == 3) - { + } else if (p_border_line_no == 3) { tmp = p_x + p_y - this.urx; - } - else if (p_border_line_no == 5) - { + } else if (p_border_line_no == 5) { tmp = this.ulx + p_y - p_x; - } - else if (p_border_line_no == 7) - { + } else if (p_border_line_no == 7) { tmp = this.llx - p_x - p_y; - } - else - { + } else { System.out.println("IntOctagon.side_of_border_line: p_border_line_no out of range"); tmp = 0; } Side result; - if (tmp < 0) - { + if (tmp < 0) { result = Side.ON_THE_LEFT; - } - else if (tmp > 0) - { + } else if (tmp > 0) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } return result; } - - Simplex intersection(Simplex p_other) - { + + Simplex intersection(Simplex p_other) { return p_other.intersection(this); } - - - public IntOctagon intersection(IntOctagon p_other) - { + + public IntOctagon intersection(IntOctagon p_other) { IntOctagon result = new IntOctagon(Math.max(lx, p_other.lx), Math.max(ly, p_other.ly), - Math.min(rx, p_other.rx), Math.min(uy, p_other.uy), - Math.max(ulx, p_other.ulx), Math.min(lrx, p_other.lrx), - Math.max(llx, p_other.llx), Math.min(urx, p_other.urx)); + Math.min(rx, p_other.rx), Math.min(uy, p_other.uy), + Math.max(ulx, p_other.ulx), Math.min(lrx, p_other.lrx), + Math.max(llx, p_other.llx), Math.min(urx, p_other.urx)); return result.normalize(); } - - IntOctagon intersection(IntBox p_other) - { + + IntOctagon intersection(IntBox p_other) { return intersection(p_other.to_IntOctagon()); } - + /** * checkes if this (normalized) octagon is contained in p_box */ - public boolean is_contained_in(IntBox p_box) - { + public boolean is_contained_in(IntBox p_box) { return (lx >= p_box.ll.x && ly >= p_box.ll.y && - rx <= p_box.ur.x && uy <=p_box.ur.y); + rx <= p_box.ur.x && uy <= p_box.ur.y); } - - public boolean is_contained_in(IntOctagon p_other) - { + + public boolean is_contained_in(IntOctagon p_other) { boolean result = lx >= p_other.lx && ly >= p_other.ly && rx <= p_other.rx && uy <= p_other.uy && llx >= p_other.llx && ulx >= p_other.ulx && lrx <= p_other.lrx && urx <= p_other.urx; - + return result; } - - public IntOctagon union(IntOctagon p_other) - { + + public IntOctagon union(IntOctagon p_other) { IntOctagon result = new IntOctagon(Math.min(lx, p_other.lx), Math.min(ly, p_other.ly), - Math.max(rx, p_other.rx), Math.max(uy, p_other.uy), - Math.min(ulx, p_other.ulx), Math.max(lrx, p_other.lrx), - Math.min(llx, p_other.llx), Math.max(urx, p_other.urx)); + Math.max(rx, p_other.rx), Math.max(uy, p_other.uy), + Math.min(ulx, p_other.ulx), Math.max(lrx, p_other.lrx), + Math.min(llx, p_other.llx), Math.max(urx, p_other.urx)); return result; } - - public boolean intersects(IntBox p_other) - { + + public boolean intersects(IntBox p_other) { return intersects(p_other.to_IntOctagon()); } - + /** * checks, if two normalized Octagons intersect. */ - public boolean intersects(IntOctagon p_other) - { + public boolean intersects(IntOctagon p_other) { int is_lx; int is_rx; - if (p_other.lx > this.lx) - { + if (p_other.lx > this.lx) { is_lx = p_other.lx; + } else { + is_lx = this.lx; } - else - { - is_lx = this.lx; - } - if (p_other.rx < this.rx) - { + if (p_other.rx < this.rx) { is_rx = p_other.rx; + } else { + is_rx = this.rx; } - else - { - is_rx = this.rx; - } - if (is_lx > is_rx) - { + if (is_lx > is_rx) { return false; } - + int is_ly; int is_uy; - if (p_other.ly > this.ly) - { + if (p_other.ly > this.ly) { is_ly = p_other.ly; + } else { + is_ly = this.ly; } - else - { - is_ly = this.ly; - } - if (p_other.uy < this.uy) - { + if (p_other.uy < this.uy) { is_uy = p_other.uy; + } else { + is_uy = this.uy; } - else - { - is_uy = this.uy; - } - if (is_ly > is_uy) - { + if (is_ly > is_uy) { return false; } - + int is_llx; int is_urx; - if (p_other.llx > this.llx) - { + if (p_other.llx > this.llx) { is_llx = p_other.llx; + } else { + is_llx = this.llx; } - else - { - is_llx = this.llx; - } - if (p_other.urx < this.urx) - { + if (p_other.urx < this.urx) { is_urx = p_other.urx; + } else { + is_urx = this.urx; } - else - { - is_urx = this.urx; - } - if (is_llx > is_urx) - { + if (is_llx > is_urx) { return false; } - + int is_ulx; int is_lrx; - if (p_other.ulx > this.ulx) - { + if (p_other.ulx > this.ulx) { is_ulx = p_other.ulx; + } else { + is_ulx = this.ulx; } - else - { - is_ulx = this.ulx; - } - if (p_other.lrx < this.lrx) - { + if (p_other.lrx < this.lrx) { is_lrx = p_other.lrx; + } else { + is_lrx = this.lrx; } - else - { - is_lrx = this.lrx; - } - if (is_ulx > is_lrx) - { + if (is_ulx > is_lrx) { return false; } return true; } - + /** * Returns true, if this octagon intersects with p_other and the intersection is 2-dimensional. */ - public boolean overlaps(IntOctagon p_other) - { + public boolean overlaps(IntOctagon p_other) { int is_lx; int is_rx; - if (p_other.lx > this.lx) - { + if (p_other.lx > this.lx) { is_lx = p_other.lx; + } else { + is_lx = this.lx; } - else - { - is_lx = this.lx; - } - if (p_other.rx < this.rx) - { + if (p_other.rx < this.rx) { is_rx = p_other.rx; + } else { + is_rx = this.rx; } - else - { - is_rx = this.rx; - } - if (is_lx >= is_rx) - { + if (is_lx >= is_rx) { return false; } - + int is_ly; int is_uy; - if (p_other.ly > this.ly) - { + if (p_other.ly > this.ly) { is_ly = p_other.ly; + } else { + is_ly = this.ly; } - else - { - is_ly = this.ly; - } - if (p_other.uy < this.uy) - { + if (p_other.uy < this.uy) { is_uy = p_other.uy; + } else { + is_uy = this.uy; } - else - { - is_uy = this.uy; - } - if (is_ly >= is_uy) - { + if (is_ly >= is_uy) { return false; } - + int is_llx; int is_urx; - if (p_other.llx > this.llx) - { + if (p_other.llx > this.llx) { is_llx = p_other.llx; + } else { + is_llx = this.llx; } - else - { - is_llx = this.llx; - } - if (p_other.urx < this.urx) - { + if (p_other.urx < this.urx) { is_urx = p_other.urx; + } else { + is_urx = this.urx; } - else - { - is_urx = this.urx; - } - if (is_llx >= is_urx) - { + if (is_llx >= is_urx) { return false; } - + int is_ulx; int is_lrx; - if (p_other.ulx > this.ulx) - { + if (p_other.ulx > this.ulx) { is_ulx = p_other.ulx; + } else { + is_ulx = this.ulx; } - else - { - is_ulx = this.ulx; - } - if (p_other.lrx < this.lrx) - { + if (p_other.lrx < this.lrx) { is_lrx = p_other.lrx; + } else { + is_lrx = this.lrx; } - else - { - is_lrx = this.lrx; - } - if (is_ulx >= is_lrx) - { + if (is_ulx >= is_lrx) { return false; } return true; } - - public boolean intersects(Simplex p_other) - { + + public boolean intersects(Simplex p_other) { return p_other.intersects(this); } - - public boolean intersects(Circle p_other) - { + + public boolean intersects(Circle p_other) { return p_other.intersects(this); } - - - public IntOctagon union(IntBox p_other) - { + + public IntOctagon union(IntBox p_other) { return union(p_other.to_IntOctagon()); } - + /** * computes the x value of the left boundary of this Octagon at p_y */ - public int left_x_value(int p_y) - { + public int left_x_value(int p_y) { int result = Math.max(lx, ulx + p_y); return Math.max(result, llx - p_y); } - + /** * computes the x value of the right boundary of this Octagon at p_y */ - public int right_x_value(int p_y) - { + public int right_x_value(int p_y) { int result = Math.min(rx, urx - p_y); return Math.min(result, lrx + p_y); } - + /** * computes the y value of the lower boundary of this Octagon at p_x */ - public int lower_y_value(int p_x) - { + public int lower_y_value(int p_x) { int result = Math.max(ly, llx - p_x); return Math.max(result, p_x - lrx); } - + /** * computes the y value of the upper boundary of this Octagon at p_x */ - public int upper_y_value(int p_x) - { + public int upper_y_value(int p_x) { int result = Math.min(uy, p_x - ulx); return Math.min(result, urx - p_x); } - - public Side compare(RegularTileShape p_other, int p_edge_no) - { + + public Side compare(RegularTileShape p_other, int p_edge_no) { Side result = p_other.compare(this, p_edge_no); return result.negate(); } - - public Side compare(IntOctagon p_other, int p_edge_no) - { + + public Side compare(IntOctagon p_other, int p_edge_no) { Side result; - switch (p_edge_no) - { + switch (p_edge_no) { case 0: // compare the lower edge line - if (ly > p_other.ly) - { + if (ly > p_other.ly) { result = Side.ON_THE_LEFT; - } - else if (ly < p_other.ly) - { + } else if (ly < p_other.ly) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; - + case 1: // compare the lower right edge line - if (lrx < p_other.lrx) - { + if (lrx < p_other.lrx) { result = Side.ON_THE_LEFT; - } - else if (lrx > p_other.lrx) - { + } else if (lrx > p_other.lrx) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; - + case 2: // compare the right edge line - if (rx < p_other.rx) - { + if (rx < p_other.rx) { result = Side.ON_THE_LEFT; - } - else if (rx > p_other.rx) - { + } else if (rx > p_other.rx) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; - - + + case 3: // compare the upper right edge line - if (urx < p_other.urx) - { + if (urx < p_other.urx) { result = Side.ON_THE_LEFT; - } - else if (urx > p_other.urx) - { + } else if (urx > p_other.urx) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; - + case 4: // compare the upper edge line - if (uy < p_other.uy) - { + if (uy < p_other.uy) { result = Side.ON_THE_LEFT; - } - else if (uy > p_other.uy) - { + } else if (uy > p_other.uy) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; - - + + case 5: // compare the upper left edge line - if (ulx > p_other.ulx) - { + if (ulx > p_other.ulx) { result = Side.ON_THE_LEFT; - } - else if (ulx < p_other.ulx) - { + } else if (ulx < p_other.ulx) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; - + case 6: // compare the left edge line - if (lx > p_other.lx) - { + if (lx > p_other.lx) { result = Side.ON_THE_LEFT; - } - else if (lx < p_other.lx) - { + } else if (lx < p_other.lx) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; - + case 7: // compare the lower left edge line - if (llx > p_other.llx) - { + if (llx > p_other.llx) { result = Side.ON_THE_LEFT; - } - else if (llx < p_other.llx) - { + } else if (llx < p_other.llx) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } break; default: throw new IllegalArgumentException ("IntBox.compare: p_edge_no out of range"); - + } return result; } - - public Side compare(IntBox p_other, int p_edge_no) - { + + public Side compare(IntBox p_other, int p_edge_no) { return compare(p_other.to_IntOctagon(), p_edge_no); } - - public int border_line_index(Line p_line) - { + + public int border_line_index(Line p_line) { System.out.println("edge_index_of_line not yet implemented for octagons"); return -1; } + /** * Calculates the border point of this octagon from p_point into the 45 degree direction p_dir. * If this border point is not an IntPoint, the nearest outside IntPoint of the octagon is returned. */ - public IntPoint border_point(IntPoint p_point, FortyfiveDegreeDirection p_dir) - { + public IntPoint border_point(IntPoint p_point, FortyfiveDegreeDirection p_dir) { int result_x; int result_y; - switch (p_dir) - { + switch (p_dir) { case RIGHT: result_x = Math.min(rx, urx - p_point.y); result_x = Math.min(result_x, lrx + p_point.y); @@ -1195,13 +1037,13 @@ public IntPoint border_point(IntPoint p_point, FortyfiveDegreeDirection p_dir) result_y = p_point.y - p_point.x + result_x; break; case UP45: - result_x = (int)(Math.floor(0.5 * (p_point.x + p_point.y + ulx))); + result_x = (int) (Math.floor(0.5 * (p_point.x + p_point.y + ulx))); result_x = Math.max(result_x, lx); result_x = Math.max(result_x, p_point.x + p_point.y - uy); result_y = p_point.y + p_point.x - result_x; break; case LEFT45: - result_x = (int)(Math.floor(0.5 * (p_point.x - p_point.y + llx))); + result_x = (int) (Math.floor(0.5 * (p_point.x - p_point.y + llx))); result_x = Math.max(result_x, lx); result_x = Math.max(result_x, p_point.x - p_point.y + ly); result_y = p_point.y - p_point.x + result_x; @@ -1219,36 +1061,29 @@ public IntPoint border_point(IntPoint p_point, FortyfiveDegreeDirection p_dir) } return new IntPoint(result_x, result_y); } - + /** * Calculates the sorted p_max_result_points nearest points on the * border of this octagon in the 45-degree directions. * p_point is assumed to be located in the interiour of this octagon. */ - public IntPoint[] nearest_border_projections(IntPoint p_point, int p_max_result_points) - { - if (!this.contains(p_point) || p_max_result_points <= 0) - { + public IntPoint[] nearest_border_projections(IntPoint p_point, int p_max_result_points) { + if (!this.contains(p_point) || p_max_result_points <= 0) { return new IntPoint[0]; } p_max_result_points = Math.min(p_max_result_points, 8); - IntPoint [] result = new IntPoint[p_max_result_points]; - double [] min_dist = new double [p_max_result_points]; - for (int i = 0; i < p_max_result_points; ++i) - { + IntPoint[] result = new IntPoint[p_max_result_points]; + double[] min_dist = new double[p_max_result_points]; + for (int i = 0; i < p_max_result_points; ++i) { min_dist[i] = Double.MAX_VALUE; } FloatPoint inside_point = p_point.to_float(); - for (FortyfiveDegreeDirection curr_dir : FortyfiveDegreeDirection.values()) - { + for (FortyfiveDegreeDirection curr_dir : FortyfiveDegreeDirection.values()) { IntPoint curr_border_point = border_point(p_point, curr_dir); double curr_dist = inside_point.distance_square(curr_border_point.to_float()); - for (int i = 0; i < p_max_result_points; ++i) - { - if (curr_dist < min_dist[i]) - { - for (int k = p_max_result_points - 1; k > i; --k) - { + for (int i = 0; i < p_max_result_points; ++i) { + if (curr_dist < min_dist[i]) { + for (int k = p_max_result_points - 1; k > i; --k) { min_dist[k] = min_dist[k - 1]; result[k] = result[k - 1]; } @@ -1260,155 +1095,100 @@ public IntPoint[] nearest_border_projections(IntPoint p_point, int p_max_result_ } return result; } - - Side border_line_side_of( FloatPoint p_point, int p_line_no, double p_tolerance) - { + + Side border_line_side_of(FloatPoint p_point, int p_line_no, double p_tolerance) { Side result; - if (p_line_no == 0) - { - if (p_point.y > this.ly + p_tolerance) - { - result = Side.ON_THE_RIGHT; - } - else if (p_point.y < this.ly - p_tolerance) - { - result = Side.ON_THE_LEFT; - } - else - { + if (p_line_no == 0) { + if (p_point.y > this.ly + p_tolerance) { + result = Side.ON_THE_RIGHT; + } else if (p_point.y < this.ly - p_tolerance) { + result = Side.ON_THE_LEFT; + } else { result = Side.COLLINEAR; } - } - else if (p_line_no == 2) - { - if (p_point.x < this.rx - p_tolerance) - { - result = Side.ON_THE_RIGHT; - } - else if (p_point.x > this.rx + p_tolerance) - { - result = Side.ON_THE_LEFT; - } - else - { + } else if (p_line_no == 2) { + if (p_point.x < this.rx - p_tolerance) { + result = Side.ON_THE_RIGHT; + } else if (p_point.x > this.rx + p_tolerance) { + result = Side.ON_THE_LEFT; + } else { result = Side.COLLINEAR; } - } - else if (p_line_no == 4) - { - if (p_point.y < this.uy - p_tolerance) - { - result = Side.ON_THE_RIGHT; - } - else if (p_point.y > this.uy + p_tolerance ) - { - result = Side.ON_THE_LEFT; - } - else - { + } else if (p_line_no == 4) { + if (p_point.y < this.uy - p_tolerance) { + result = Side.ON_THE_RIGHT; + } else if (p_point.y > this.uy + p_tolerance) { + result = Side.ON_THE_LEFT; + } else { result = Side.COLLINEAR; } - } - else if (p_line_no == 6) - { - if (p_point.x > this.lx + p_tolerance ) - { - result = Side.ON_THE_RIGHT; - } - else if (p_point.x < this.lx - p_tolerance ) - { - result = Side.ON_THE_LEFT; - } - else - { + } else if (p_line_no == 6) { + if (p_point.x > this.lx + p_tolerance) { + result = Side.ON_THE_RIGHT; + } else if (p_point.x < this.lx - p_tolerance) { + result = Side.ON_THE_LEFT; + } else { result = Side.COLLINEAR; } - } - else if (p_line_no == 1) - { + } else if (p_line_no == 1) { double tmp = p_point.y - p_point.x + lrx; if (tmp > p_tolerance) - // the p_point is above the the lower right border line of this octagon - { - result = Side.ON_THE_RIGHT; - } - else if (tmp < -p_tolerance) - // the p_point is below the the lower right border line of this octagon + // the p_point is above the the lower right border line of this octagon { - result = Side.ON_THE_LEFT; - } - else + result = Side.ON_THE_RIGHT; + } else if (tmp < -p_tolerance) + // the p_point is below the the lower right border line of this octagon { + result = Side.ON_THE_LEFT; + } else { result = Side.COLLINEAR; } - } - else if (p_line_no == 3) - { + } else if (p_line_no == 3) { double tmp = p_point.x + p_point.y - urx; - if (tmp < -p_tolerance) - { + if (tmp < -p_tolerance) { // the p_point is below the the upper right border line of this octagon - result = Side.ON_THE_RIGHT; - } - else if (tmp > p_tolerance) - { + result = Side.ON_THE_RIGHT; + } else if (tmp > p_tolerance) { // the p_point is above the the upper right border line of this octagon - result = Side.ON_THE_LEFT; - } - else - { + result = Side.ON_THE_LEFT; + } else { result = Side.COLLINEAR; } - } - else if (p_line_no == 5) - { + } else if (p_line_no == 5) { double tmp = p_point.y - p_point.x + ulx; if (tmp < -p_tolerance) - // the p_point is below the the upper left border line of this octagon + // the p_point is below the the upper left border line of this octagon { - result = Side.ON_THE_RIGHT; - } - else if (tmp > p_tolerance) - // the p_point is above the the upper left border line of this octagon - { - result = Side.ON_THE_LEFT; - } - else + result = Side.ON_THE_RIGHT; + } else if (tmp > p_tolerance) + // the p_point is above the the upper left border line of this octagon { + result = Side.ON_THE_LEFT; + } else { result = Side.COLLINEAR; } - } - else if (p_line_no == 7) - { + } else if (p_line_no == 7) { double tmp = p_point.x + p_point.y - llx; - if (tmp > p_tolerance) - { + if (tmp > p_tolerance) { // the p_point is above the the lower left border line of this octagon - result = Side.ON_THE_RIGHT; - } - else if (tmp < -p_tolerance) - { + result = Side.ON_THE_RIGHT; + } else if (tmp < -p_tolerance) { // the p_point is below the the lower left border line of this octagon - result = Side.ON_THE_LEFT; - } - else - { + result = Side.ON_THE_LEFT; + } else { result = Side.COLLINEAR; } - } - else - { + } else { System.out.println("IntOctagon.border_line_side_of: p_line_no out of range"); result = Side.COLLINEAR; } return result; } - + /** * Checks, if this octagon can be converted to an IntBox. */ - public boolean is_IntBox() - { + public boolean is_IntBox() { if (llx != lx + ly) return false; if (lrx != rx - ly) @@ -1418,259 +1198,240 @@ public boolean is_IntBox() if (ulx != lx - uy) return false; return true; - + } - - public TileShape simplify() - { - if (this.is_IntBox()) - { + + public TileShape simplify() { + if (this.is_IntBox()) { return this.bounding_box(); } return this; } - - public TileShape[] cutout(TileShape p_shape) - { + + public TileShape[] cutout(TileShape p_shape) { return p_shape.cutout_from(this); } - + /** * Divide p_d minus this octagon into 8 convex pieces, * from which 4 have cut off a corner. */ - IntOctagon[] cutout_from(IntBox p_d) - { + IntOctagon[] cutout_from(IntBox p_d) { IntOctagon c = this.intersection(p_d); - - if (this.is_empty() || c.dimension() < this.dimension()) - { + + if (this.is_empty() || c.dimension() < this.dimension()) { // there is only an overlap at the border - IntOctagon [] result = new IntOctagon[1]; + IntOctagon[] result = new IntOctagon[1]; result[0] = p_d.to_IntOctagon(); return result; } - - IntBox [] boxes = new IntBox[4]; - + + IntBox[] boxes = new IntBox[4]; + // construct left box - + boxes[0] = new IntBox(p_d.ll.x, c.llx - c.lx, c.lx, c.lx - c.ulx); - + // construct right box - + boxes[1] = new IntBox(c.rx, c.rx - c.lrx, p_d.ur.x, c.urx - c.rx); - + // construct lower box - + boxes[2] = new IntBox(c.llx - c.ly, p_d.ll.y, c.lrx + c.ly, c.ly); - + // construct upper box - + boxes[3] = new IntBox(c.ulx + c.uy, c.uy, c.urx - c.uy, p_d.ur.y); - + IntOctagon[] octagons = new IntOctagon[4]; - + // construct upper left octagon - + IntOctagon curr_oct = new IntOctagon(p_d.ll.x, boxes[0].ur.y, boxes[3].ll.x, p_d.ur.y, -Limits.CRIT_INT, c.ulx, -Limits.CRIT_INT, Limits.CRIT_INT); octagons[0] = curr_oct.normalize(); - + // construct lower left octagon - + curr_oct = new IntOctagon(p_d.ll.x, p_d.ll.y, boxes[2].ll.x, boxes[0].ll.y, -Limits.CRIT_INT, Limits.CRIT_INT, -Limits.CRIT_INT, c.llx); octagons[1] = curr_oct.normalize(); - + // construct lower right octagon - + curr_oct = new IntOctagon(boxes[2].ur.x, p_d.ll.y, p_d.ur.x, boxes[1].ll.y, c.lrx, Limits.CRIT_INT, -Limits.CRIT_INT, Limits.CRIT_INT); octagons[2] = curr_oct.normalize(); - + // construct upper right octagon - + curr_oct = new IntOctagon(boxes[3].ur.x, boxes[1].ur.y, p_d.ur.x, p_d.ur.y, -Limits.CRIT_INT, Limits.CRIT_INT, c.urx, Limits.CRIT_INT); octagons[3] = curr_oct.normalize(); - + // optimise the result to minimum cumulative circumference - + IntBox b = boxes[0]; IntOctagon o = octagons[0]; - if (b.ur.x - b.ll.x > o.uy - o.ly) - { + if (b.ur.x - b.ll.x > o.uy - o.ly) { // switch the horizontal upper left divide line to vertical - + boxes[0] = new IntBox(b.ll.x, b.ll.y, b.ur.x, o.uy); curr_oct = new IntOctagon(b.ur.x, o.ly, o.rx, o.uy, o.ulx, o.lrx, o.llx, o.urx); octagons[0] = curr_oct.normalize(); } - + b = boxes[3]; - o = octagons[0]; - if (b.ur.y - b.ll.y > o.rx - o.lx) - { + o = octagons[0]; + if (b.ur.y - b.ll.y > o.rx - o.lx) { // switch the vertical upper left divide line to horizontal - + boxes[3] = new IntBox(o.lx, b.ll.y, b.ur.x, b.ur.y); curr_oct = new IntOctagon(o.lx, o.ly, o.rx, b.ll.y, o.ulx, o.lrx, o.llx, o.urx); octagons[0] = curr_oct.normalize(); } b = boxes[3]; o = octagons[3]; - if (b.ur.y - b.ll.y > o.rx - o.lx) - { + if (b.ur.y - b.ll.y > o.rx - o.lx) { // switch the vertical upper right divide line to horizontal - + boxes[3] = new IntBox(b.ll.x, b.ll.y, o.rx, b.ur.y); curr_oct = new IntOctagon(o.lx, o.ly, o.rx, o.uy, o.ulx, o.lrx, o.llx, o.urx); octagons[3] = curr_oct.normalize(); } b = boxes[1]; o = octagons[3]; - if (b.ur.x - b.ll.x > o.uy - o.ly) - { + if (b.ur.x - b.ll.x > o.uy - o.ly) { // switch the horizontal upper right divide line to vertical - + boxes[1] = new IntBox(b.ll.x, b.ll.y, b.ur.x, o.uy); curr_oct = new IntOctagon(o.lx, o.ly, b.ll.x, o.uy, o.ulx, o.lrx, o.llx, o.urx); octagons[3] = curr_oct.normalize(); } b = boxes[1]; o = octagons[2]; - if (b.ur.x - b.ll.x > o.uy - o.ly) - { + if (b.ur.x - b.ll.x > o.uy - o.ly) { // switch the horizontal lower right divide line to vertical - + boxes[1] = new IntBox(b.ll.x, o.ly, b.ur.x, b.ur.y); curr_oct = new IntOctagon(o.lx, o.ly, b.ll.x, o.uy, o.ulx, o.lrx, o.llx, o.urx); octagons[2] = curr_oct.normalize(); } b = boxes[2]; o = octagons[2]; - if (b.ur.y - b.ll.y > o.rx - o.lx) - { + if (b.ur.y - b.ll.y > o.rx - o.lx) { // switch the vertical lower right divide line to horizontal - + boxes[2] = new IntBox(b.ll.x, b.ll.y, o.rx, b.ur.y); curr_oct = new IntOctagon(o.lx, b.ur.y, o.rx, o.uy, o.ulx, o.lrx, o.llx, o.urx); octagons[2] = curr_oct.normalize(); } b = boxes[2]; o = octagons[1]; - if (b.ur.y - b.ll.y > o.rx - o.lx) - { + if (b.ur.y - b.ll.y > o.rx - o.lx) { // switch the vertical lower left divide line to horizontal - + boxes[2] = new IntBox(o.lx, b.ll.y, b.ur.x, b.ur.y); curr_oct = new IntOctagon(o.lx, b.ur.y, o.rx, o.uy, o.ulx, o.lrx, o.llx, o.urx); octagons[1] = curr_oct.normalize(); } b = boxes[0]; o = octagons[1]; - if (b.ur.x - b.ll.x > o.uy - o.ly) - { + if (b.ur.x - b.ll.x > o.uy - o.ly) { // switch the horizontal lower left divide line to vertical boxes[0] = new IntBox(b.ll.x, o.ly, b.ur.x, b.ur.y); curr_oct = new IntOctagon(b.ur.x, o.ly, o.rx, o.uy, o.ulx, o.lrx, o.llx, o.urx); octagons[1] = curr_oct.normalize(); } - + IntOctagon[] result = new IntOctagon[8]; - + // add the 4 boxes to the result - for (int i = 0; i < 4; ++i) - { + for (int i = 0; i < 4; ++i) { result[i] = boxes[i].to_IntOctagon(); } - + // add the 4 octagons to the result - for (int i = 0; i < 4; ++i) - { + for (int i = 0; i < 4; ++i) { result[4 + i] = octagons[i]; } return result; } - + /** * Divide p_divide_octagon minus cut_octagon into 8 convex * pieces without sharp angles. */ - IntOctagon[] cutout_from(IntOctagon p_d) - { + IntOctagon[] cutout_from(IntOctagon p_d) { IntOctagon c = this.intersection(p_d); - - if (this.is_empty() || c.dimension() < this.dimension()) - { + + if (this.is_empty() || c.dimension() < this.dimension()) { // there is only an overlap at the border - IntOctagon [] result = new IntOctagon[1]; + IntOctagon[] result = new IntOctagon[1]; result[0] = p_d; return result; } - - IntOctagon [] result = new IntOctagon[8]; - + + IntOctagon[] result = new IntOctagon[8]; + int tmp = c.llx - c.lx; - + result[0] = new IntOctagon(p_d.lx, tmp, c.lx, c.lx - c.ulx, p_d.ulx, p_d.lrx, p_d.llx, p_d.urx); - + int tmp2 = c.llx - c.ly; - + result[1] = new IntOctagon(p_d.lx, p_d.ly, tmp2, tmp, p_d.ulx, p_d.lrx, p_d.llx, c.llx); - + tmp = c.lrx + c.ly; - + result[2] = new IntOctagon(tmp2, p_d.ly, tmp, c.ly, p_d.ulx, p_d.lrx, p_d.llx, p_d.urx); - + tmp2 = c.rx - c.lrx; - + result[3] = new IntOctagon(tmp, p_d.ly, p_d.rx, tmp2, c.lrx, p_d.lrx, p_d.llx, p_d.urx); - + tmp = c.urx - c.rx; - + result[4] = new IntOctagon(c.rx, tmp2, p_d.rx, tmp, p_d.ulx, p_d.lrx, p_d.llx, p_d.urx); - + tmp2 = c.urx - c.uy; - + result[5] = new IntOctagon(tmp2, tmp, p_d.rx, p_d.uy, p_d.ulx, p_d.lrx, c.urx, p_d.urx); - + tmp = c.ulx + c.uy; - + result[6] = new IntOctagon(tmp, c.uy, tmp2, p_d.uy, p_d.ulx, p_d.lrx, p_d.llx, p_d.urx); - + tmp2 = c.lx - c.ulx; - + result[7] = new IntOctagon(p_d.lx, tmp2, tmp, p_d.uy, p_d.ulx, c.ulx, p_d.llx, p_d.urx); - - for (int i = 0; i < 8; ++i) - { + + for (int i = 0; i < 8; ++i) { result[i] = result[i].normalize(); } - + IntOctagon curr_1 = result[0]; IntOctagon curr_2 = result[7]; - + if (!(curr_1.is_empty() || curr_2.is_empty()) && curr_1.rx - curr_1.left_x_value(curr_1.uy) - > curr_2.upper_y_value(curr_1.rx) - curr_2.ly) - { + > curr_2.upper_y_value(curr_1.rx) - curr_2.ly) { // switch the horizontal upper left divide line to vertical curr_1 = new IntOctagon(Math.min(curr_1.lx, curr_2.lx), curr_1.ly, - curr_1.rx, curr_2.uy, curr_2.ulx, curr_1.lrx,curr_1.llx, curr_2.urx); - + curr_1.rx, curr_2.uy, curr_2.ulx, curr_1.lrx, curr_1.llx, curr_2.urx); + curr_2 = new IntOctagon(curr_1.rx, curr_2.ly, curr_2.rx, curr_2.uy, curr_2.ulx, curr_2.lrx, curr_2.llx, curr_2.urx); - + result[0] = curr_1.normalize(); result[7] = curr_2.normalize(); } @@ -1678,15 +1439,15 @@ IntOctagon[] cutout_from(IntOctagon p_d) curr_2 = result[6]; if (!(curr_1.is_empty() || curr_2.is_empty()) && curr_2.upper_y_value(curr_1.rx) - curr_2.ly - > curr_1.rx - curr_1.left_x_value(curr_2.ly)) - // switch the vertical upper left divide line to horizontal + > curr_1.rx - curr_1.left_x_value(curr_2.ly)) + // switch the vertical upper left divide line to horizontal { curr_2 = new IntOctagon(curr_1.lx, curr_2.ly, curr_2.rx, Math.max(curr_2.uy, curr_1.uy), curr_1.ulx, curr_2.lrx, curr_1.llx, curr_2.urx); - + curr_1 = new IntOctagon(curr_1.lx, curr_1.ly, curr_1.rx, curr_2.ly, curr_1.ulx, curr_1.lrx, curr_1.llx, curr_1.urx); - + result[7] = curr_1.normalize(); result[6] = curr_2.normalize(); } @@ -1694,15 +1455,15 @@ IntOctagon[] cutout_from(IntOctagon p_d) curr_2 = result[5]; if (!(curr_1.is_empty() || curr_2.is_empty()) && curr_2.upper_y_value(curr_1.rx) - curr_1.ly - > curr_2.right_x_value(curr_1.ly) - curr_2.lx) - // switch the vertical upper right divide line to horizontal + > curr_2.right_x_value(curr_1.ly) - curr_2.lx) + // switch the vertical upper right divide line to horizontal { curr_1 = new IntOctagon(curr_1.lx, curr_1.ly, curr_2.rx, Math.max(curr_2.uy, curr_1.uy), curr_1.ulx, curr_2.lrx, curr_1.llx, curr_2.urx); - + curr_2 = new IntOctagon(curr_2.lx, curr_2.ly, curr_2.rx, curr_1.ly, curr_2.ulx, curr_2.lrx, curr_2.llx, curr_2.urx); - + result[6] = curr_1.normalize(); result[5] = curr_2.normalize(); } @@ -1710,15 +1471,15 @@ IntOctagon[] cutout_from(IntOctagon p_d) curr_2 = result[4]; if (!(curr_1.is_empty() || curr_2.is_empty()) && curr_2.right_x_value(curr_2.uy) - curr_2.lx - > curr_1.upper_y_value(curr_2.lx) - curr_2.uy) - // switch the horizontal upper right divide line to vertical + > curr_1.upper_y_value(curr_2.lx) - curr_2.uy) + // switch the horizontal upper right divide line to vertical { curr_2 = new IntOctagon(curr_2.lx, curr_2.ly, Math.max(curr_2.rx, curr_1.rx), - curr_1.uy, curr_1.ulx, curr_2.lrx, curr_2.llx, curr_1.urx); - + curr_1.uy, curr_1.ulx, curr_2.lrx, curr_2.llx, curr_1.urx); + curr_1 = new IntOctagon(curr_1.lx, curr_1.ly, curr_2.lx, curr_1.uy, curr_1.ulx, curr_1.lrx, curr_1.llx, curr_1.urx); - + result[5] = curr_1.normalize(); result[4] = curr_2.normalize(); } @@ -1726,125 +1487,78 @@ IntOctagon[] cutout_from(IntOctagon p_d) curr_2 = result[3]; if (!(curr_1.is_empty() || curr_2.is_empty()) && curr_1.right_x_value(curr_1.ly) - curr_1.lx - > curr_1.ly - curr_2.lower_y_value(curr_1.lx)) - // switch the horizontal lower right divide line to vertical + > curr_1.ly - curr_2.lower_y_value(curr_1.lx)) + // switch the horizontal lower right divide line to vertical { curr_1 = new IntOctagon(curr_1.lx, curr_2.ly, Math.max(curr_2.rx, curr_1.rx), curr_1.uy, curr_1.ulx, curr_2.lrx, curr_2.llx, curr_1.urx); - + curr_2 = new IntOctagon(curr_2.lx, curr_2.ly, curr_1.lx, curr_2.uy, curr_2.ulx, curr_2.lrx, curr_2.llx, curr_2.urx); - + result[4] = curr_1.normalize(); result[3] = curr_2.normalize(); } - + curr_1 = result[3]; curr_2 = result[2]; - + if (!(curr_1.is_empty() || curr_2.is_empty()) && curr_2.uy - curr_2.lower_y_value(curr_2.rx) - > curr_1.right_x_value(curr_2.uy) - curr_2.rx) - // switch the vertical lower right divide line to horizontal + > curr_1.right_x_value(curr_2.uy) - curr_2.rx) + // switch the vertical lower right divide line to horizontal { curr_2 = new IntOctagon(curr_2.lx, Math.min(curr_1.ly, curr_2.ly), curr_1.rx, curr_2.uy, curr_2.ulx, curr_1.lrx, curr_2.llx, curr_1.urx); - + curr_1 = new IntOctagon(curr_1.lx, curr_2.uy, curr_1.rx, curr_1.uy, curr_1.ulx, curr_1.lrx, curr_1.llx, curr_1.urx); - + result[3] = curr_1.normalize(); result[2] = curr_2.normalize(); } - + curr_1 = result[2]; curr_2 = result[1]; - + if (!(curr_1.is_empty() || curr_2.is_empty()) && curr_1.uy - curr_1.lower_y_value(curr_1.lx) - > curr_1.lx - curr_2.left_x_value(curr_1.uy)) - // switch the vertical lower left divide line to horizontal + > curr_1.lx - curr_2.left_x_value(curr_1.uy)) + // switch the vertical lower left divide line to horizontal { curr_1 = new IntOctagon(curr_2.lx, Math.min(curr_1.ly, curr_2.ly), curr_1.rx, curr_1.uy, curr_2.ulx, curr_1.lrx, curr_2.llx, curr_1.urx); - + curr_2 = new IntOctagon(curr_2.lx, curr_1.uy, curr_2.rx, curr_2.uy, curr_2.ulx, curr_2.lrx, curr_2.llx, curr_2.urx); - + result[2] = curr_1.normalize(); result[1] = curr_2.normalize(); } - + curr_1 = result[1]; curr_2 = result[0]; - + if (!(curr_1.is_empty() || curr_2.is_empty()) && curr_2.rx - curr_2.left_x_value(curr_2.ly) - > curr_2.ly - curr_1.lower_y_value(curr_2.rx)) - // switch the horizontal lower left divide line to vertical + > curr_2.ly - curr_1.lower_y_value(curr_2.rx)) + // switch the horizontal lower left divide line to vertical { curr_2 = new IntOctagon(Math.min(curr_2.lx, curr_1.lx), curr_1.ly, curr_2.rx, curr_2.uy, curr_2.ulx, curr_1.lrx, curr_1.llx, curr_2.urx); - + curr_1 = new IntOctagon(curr_2.rx, curr_1.ly, curr_1.rx, curr_1.uy, curr_1.ulx, curr_1.lrx, curr_1.llx, curr_1.urx); - + result[1] = curr_1.normalize(); result[0] = curr_2.normalize(); } - + return result; } - - - Simplex[] cutout_from(Simplex p_simplex) - { + + Simplex[] cutout_from(Simplex p_simplex) { return this.to_Simplex().cutout_from(p_simplex); } - - /** - * x coordinate of the left border line - */ - public final int lx; - - /** - * y coordinate of the lower border line - */ - public final int ly; - - /** - * x coordinate of the right border line - */ - public final int rx; - - /** - * y coordinate of the upper border line - */ - public final int uy; - - /** - * x axis intersection of the upper left border line - */ - public final int ulx; - - /** - * x axis intersection of the lower right border line - */ - public final int lrx; - - /** - * x axis intersection of the lower left border line - */ - public final int llx; - - /** - * x axis intersection of the upper right border line - */ - public final int urx; - - /** - * Result of to_simplex() memorized for performance reasons. - */ - private Simplex precalculated_to_simplex = null; - + } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/IntPoint.java b/src/main/java/net/freerouting/geometry/planar/IntPoint.java index 2f432312..504d1472 100644 --- a/src/main/java/net/freerouting/geometry/planar/IntPoint.java +++ b/src/main/java/net/freerouting/geometry/planar/IntPoint.java @@ -26,177 +26,158 @@ * Implementation of the abstract class Point * as a tuple of integers. * - * * @author Alfons Wirtz */ -public class IntPoint extends Point implements java.io.Serializable -{ - +public class IntPoint extends Point implements java.io.Serializable { + + /** + * the x coordinate of this point + */ + public final int x; + /** + * the y coordinate of this point + */ + public final int y; + /** * create an IntPoint from two integer coordinates */ - public IntPoint(int p_x, int p_y) - { - if (Math.abs(p_x) > Limits.CRIT_INT || Math.abs(p_y) > Limits.CRIT_INT) - { + public IntPoint(int p_x, int p_y) { + if (Math.abs(p_x) > Limits.CRIT_INT || Math.abs(p_y) > Limits.CRIT_INT) { System.out.println("Warning in IntPoint: p_x or p_y to big"); } x = p_x; y = p_y; } - + /** * Returns true, if this IntPoint is equal to p_ob */ - public final boolean equals( Object p_ob ) - { - if ( this == p_ob ) - { + public final boolean equals(Object p_ob) { + if (this == p_ob) { return true; } - if ( p_ob == null ) - { + if (p_ob == null) { return false; } - if ( getClass() != p_ob.getClass() ) - { - return false ; + if (getClass() != p_ob.getClass()) { + return false; } - IntPoint other = (IntPoint)p_ob ; - return ( x == other.x && y == other.y ) ; + IntPoint other = (IntPoint) p_ob; + return (x == other.x && y == other.y); } - - public boolean is_infinite() - { + + public boolean is_infinite() { return false; } - - public IntBox surrounding_box() - { + + public IntBox surrounding_box() { return new IntBox(this, this); } - - public IntOctagon surrounding_octagon() - { + + public IntOctagon surrounding_octagon() { int tmp_1 = x - y; int tmp_2 = x + y; - + return new IntOctagon(x, y, x, y, tmp_1, tmp_1, tmp_2, tmp_2); } - - public boolean is_contained_in(IntBox p_box) - { + + public boolean is_contained_in(IntBox p_box) { return x >= p_box.ll.x && y >= p_box.ll.y && x <= p_box.ur.x && y <= p_box.ur.y; } - + /** * returns the translation of this point by p_vector */ - public final Point translate_by( Vector p_vector ) - { - if (p_vector.equals(Vector.ZERO)) - { + public final Point translate_by(Vector p_vector) { + if (p_vector.equals(Vector.ZERO)) { return this; } - return p_vector.add_to(this) ; + return p_vector.add_to(this); } - - Point translate_by( IntVector p_vector ) - { - return ( new IntPoint( x + p_vector.x, y + p_vector.y ) ) ; + + Point translate_by(IntVector p_vector) { + return (new IntPoint(x + p_vector.x, y + p_vector.y)); } - - Point translate_by( RationalVector p_vector ) - { + + Point translate_by(RationalVector p_vector) { return p_vector.add_to(this); } - - + /** * returns the difference vector of this point and p_other */ - public Vector difference_by(Point p_other) - { - Vector tmp = p_other.difference_by(this); + public Vector difference_by(Point p_other) { + Vector tmp = p_other.difference_by(this); return tmp.negate(); } - - Vector difference_by(RationalPoint p_other) - { + + Vector difference_by(RationalPoint p_other) { Vector tmp = p_other.difference_by(this); return tmp.negate(); } - - IntVector difference_by(IntPoint p_other) - { + + IntVector difference_by(IntPoint p_other) { return new IntVector(x - p_other.x, y - p_other.y); } - - public Side side_of(Line p_line) - { + + public Side side_of(Line p_line) { Vector v1 = difference_by(p_line.a); Vector v2 = p_line.b.difference_by(p_line.a); return v1.side_of(v2); } - + /** * converts this point to a FloatPoint. */ - public FloatPoint to_float() - { + public FloatPoint to_float() { return new FloatPoint(x, y); } - + /** * returns the determinant of the vectors (x, y) and (p_other.x, p_other.y) */ - public final long determinant(IntPoint p_other) - { - return (long)x * p_other.y - (long)y * p_other.x; + public final long determinant(IntPoint p_other) { + return (long) x * p_other.y - (long) y * p_other.x; } - - - public Point perpendicular_projection(Line p_line) - { + + public Point perpendicular_projection(Line p_line) { // this function is at the moment only implemented for lines // consisting of IntPoints. // The general implementation is still missing. - IntVector v = (IntVector)p_line.b.difference_by(p_line.a); - BigInteger vxvx = BigInteger.valueOf((long)v.x * v.x); - BigInteger vyvy = BigInteger.valueOf((long)v.y * v.y); + IntVector v = (IntVector) p_line.b.difference_by(p_line.a); + BigInteger vxvx = BigInteger.valueOf((long) v.x * v.x); + BigInteger vyvy = BigInteger.valueOf((long) v.y * v.y); BigInteger vxvy = BigInteger.valueOf((long) v.x * v.y); BigInteger denominator = vxvx.add(vyvy); BigInteger det = - BigInteger.valueOf(((IntPoint)p_line.a).determinant((IntPoint)p_line.b)); + BigInteger.valueOf(((IntPoint) p_line.a).determinant((IntPoint) p_line.b)); BigInteger point_x = BigInteger.valueOf(x); BigInteger point_y = BigInteger.valueOf(y); - + BigInteger tmp1 = vxvx.multiply(point_x); BigInteger tmp2 = vxvy.multiply(point_y); tmp1 = tmp1.add(tmp2); tmp2 = det.multiply(BigInteger.valueOf(v.y)); BigInteger proj_x = tmp1.add(tmp2); - + tmp1 = vxvy.multiply(point_x); tmp2 = vyvy.multiply(point_y); tmp1 = tmp1.add(tmp2); tmp2 = det.multiply(BigInteger.valueOf(v.x)); BigInteger proj_y = tmp1.subtract(tmp2); - + int signum = denominator.signum(); - if (signum != 0) - { - if (signum < 0) - { + if (signum != 0) { + if (signum < 0) { denominator = denominator.negate(); proj_x = proj_x.negate(); proj_y = proj_y.negate(); } if ((proj_x.mod(denominator)).signum() == 0 && - (proj_y.mod(denominator)).signum() == 0) - { + (proj_y.mod(denominator)).signum() == 0) { proj_x = proj_x.divide(denominator); proj_y = proj_y.divide(denominator); return new IntPoint(proj_x.intValue(), proj_y.intValue()); @@ -204,109 +185,92 @@ public Point perpendicular_projection(Line p_line) } return new RationalPoint(proj_x, proj_y, denominator); } - + /** * Returns the signed area of the parallelogramm spanned by the vectors * p_2 - p_1 and this - p_1 */ - public double signed_area( IntPoint p_1, IntPoint p_2 ) - { - IntVector d21 = (IntVector) p_2.difference_by(p_1) ; - IntVector d01 = (IntVector) this.difference_by(p_1) ; - return d21.determinant(d01) ; + public double signed_area(IntPoint p_1, IntPoint p_2) { + IntVector d21 = (IntVector) p_2.difference_by(p_1); + IntVector d01 = (IntVector) this.difference_by(p_1); + return d21.determinant(d01); } - + /** * calculates the square of the distance between this point and p_to_point */ - public double distance_square(IntPoint p_to_point) - { + public double distance_square(IntPoint p_to_point) { double dx = p_to_point.x - this.x; double dy = p_to_point.y - this.y; return dx * dx + dy * dy; } - + /** * calculates the distance between this point and p_to_point */ - public double distance(IntPoint p_to_point) - { + public double distance(IntPoint p_to_point) { return Math.sqrt(distance_square(p_to_point)); } - + /** * Calculates the nearest point to this point on the horizontal or * vertical line through p_other (Snaps this point to on ortogonal line * through p_other). */ - public IntPoint orthogonal_projection(IntPoint p_other) - { + public IntPoint orthogonal_projection(IntPoint p_other) { IntPoint result; - int horizontal_distance = Math.abs(this.x -p_other.x); - int vertical_distance = Math.abs(this.y -p_other.y); - if (horizontal_distance <= vertical_distance) - { + int horizontal_distance = Math.abs(this.x - p_other.x); + int vertical_distance = Math.abs(this.y - p_other.y); + if (horizontal_distance <= vertical_distance) { // projection onto the vertical line through p_other result = new IntPoint(p_other.x, this.y); - } - else - { + } else { // projection onto the horizontal line through p_other result = new IntPoint(this.x, p_other.y); } return result; } - + /** * Calculates the nearest point to this point on an orthogonal or * diagonal line through p_other (Snaps this point to on 45 degree line * through p_other). */ - public IntPoint fortyfive_degree_projection(IntPoint p_other) - { - int dx = this.x -p_other.x; - int dy = this.y -p_other.y; + public IntPoint fortyfive_degree_projection(IntPoint p_other) { + int dx = this.x - p_other.x; + int dy = this.y - p_other.y; double[] dist_arr = new double[4]; dist_arr[0] = Math.abs(dx); dist_arr[1] = Math.abs(dy); - double diagonal_1 = ((double)dy - (double)dx) / 2; - double diagonal_2 = ((double)dy + (double)dx) / 2; + double diagonal_1 = ((double) dy - (double) dx) / 2; + double diagonal_2 = ((double) dy + (double) dx) / 2; dist_arr[2] = Math.abs(diagonal_1); dist_arr[3] = Math.abs(diagonal_2); double min_dist = dist_arr[0]; - for (int i = 1; i < 4; ++i) - { - if (dist_arr[i] < min_dist) - { + for (int i = 1; i < 4; ++i) { + if (dist_arr[i] < min_dist) { min_dist = dist_arr[i]; } } IntPoint result; - if (min_dist == dist_arr[0]) - { + if (min_dist == dist_arr[0]) { // projection onto the vertical line through p_other result = new IntPoint(p_other.x, this.y); - } - else if (min_dist == dist_arr[1]) - { + } else if (min_dist == dist_arr[1]) { // projection onto the horizontal line through p_other result = new IntPoint(this.x, p_other.y); - } - else if (min_dist == dist_arr[2]) - { + } else if (min_dist == dist_arr[2]) { // projection onto the right diagonal line through p_other - int diagonal_value = (int)diagonal_2; + int diagonal_value = (int) diagonal_2; result = new IntPoint(p_other.x + diagonal_value, p_other.y + diagonal_value); - } - else - { + } else { // projection onto the left diagonal line through p_other - int diagonal_value = (int)diagonal_1; + int diagonal_value = (int) diagonal_1; result = new IntPoint(p_other.x - diagonal_value, p_other.y + diagonal_value); } return result; } - + /** * Calculates a corner point p so that the lines through this point and p and from * p to p_to_point are multiples of 45 degree, and that the angle at p will be @@ -315,110 +279,68 @@ else if (min_dist == dist_arr[2]) * Returns null, if the line from this point to p_to_point is already a multiple * of 45 degree. */ - public IntPoint fortyfive_degree_corner( IntPoint p_to_point, boolean p_left_turn) - { + public IntPoint fortyfive_degree_corner(IntPoint p_to_point, boolean p_left_turn) { int dx = p_to_point.x - this.x; int dy = p_to_point.y - this.y; IntPoint result; - + // handle the 8 sections between the 45 degree lines - - if (dy > 0 && dy < dx) - { - if (p_left_turn) - { + + if (dy > 0 && dy < dx) { + if (p_left_turn) { result = new IntPoint(p_to_point.x - dy, this.y); - } - else - { + } else { result = new IntPoint(this.x + dy, p_to_point.y); } - } - else if (dx > 0 && dy > dx) - { - if (p_left_turn) - { + } else if (dx > 0 && dy > dx) { + if (p_left_turn) { result = new IntPoint(p_to_point.x, this.y + dx); - } - else - { + } else { result = new IntPoint(this.x, p_to_point.y - dx); } - } - else if (dx < 0 && dy > -dx) - { - if (p_left_turn) - { + } else if (dx < 0 && dy > -dx) { + if (p_left_turn) { result = new IntPoint(this.x, p_to_point.y + dx); - } - else - { + } else { result = new IntPoint(p_to_point.x, this.y - dx); } - } - else if (dy > 0 && dy < -dx) - { - if (p_left_turn) - { + } else if (dy > 0 && dy < -dx) { + if (p_left_turn) { result = new IntPoint(this.x - dy, p_to_point.y); - } - else - { + } else { result = new IntPoint(p_to_point.x + dy, this.y); } - } - else if (dy < 0 && dy > dx) - { - if (p_left_turn) - { + } else if (dy < 0 && dy > dx) { + if (p_left_turn) { result = new IntPoint(p_to_point.x - dy, this.y); - } - else - { + } else { result = new IntPoint(this.x + dy, p_to_point.y); } - } - else if (dx < 0 && dy < dx) - { - if (p_left_turn) - { + } else if (dx < 0 && dy < dx) { + if (p_left_turn) { result = new IntPoint(p_to_point.x, this.y + dx); - } - else - { + } else { result = new IntPoint(this.x, p_to_point.y - dx); } - } - else if (dx > 0 && dy < -dx) - { - if (p_left_turn) - { + } else if (dx > 0 && dy < -dx) { + if (p_left_turn) { result = new IntPoint(this.x, p_to_point.y + dx); - } - else - { + } else { result = new IntPoint(p_to_point.x, this.y - dx); } - } - else if (dy < 0 && dy > -dx) - { - if (p_left_turn) - { + } else if (dy < 0 && dy > -dx) { + if (p_left_turn) { result = new IntPoint(this.x - dy, p_to_point.y); - } - else - { + } else { result = new IntPoint(p_to_point.x + dy, this.y); } - } - else - { + } else { // the line from this point to p_to_point is already a multiple of 45 degree result = null; } return result; } - + /** * Calculates a corner point p so that the lines through this point and p and from * p to p_to_point are hprizontal or vertical, and that the angle at p will be @@ -426,109 +348,70 @@ else if (dy < 0 && dy > -dx) * from this point to p, else on the right. * Returns null, if the line from this point to p_to_point is already orthogonal. */ - public IntPoint ninety_degree_corner( IntPoint p_to_point, boolean p_left_turn) - { + public IntPoint ninety_degree_corner(IntPoint p_to_point, boolean p_left_turn) { int dx = p_to_point.x - this.x; int dy = p_to_point.y - this.y; IntPoint result; - + // handle the 4 quadrants - - if (dx > 0 && dy > 0 || dx < 0 && dy < 0) - { - if (p_left_turn) - { + + if (dx > 0 && dy > 0 || dx < 0 && dy < 0) { + if (p_left_turn) { result = new IntPoint(p_to_point.x, this.y); - } - else - { + } else { result = new IntPoint(this.x, p_to_point.y); } - } - else if (dx < 0 && dy > 0 || dx > 0 && dy < 0) - { - if (p_left_turn) - { + } else if (dx < 0 && dy > 0 || dx > 0 && dy < 0) { + if (p_left_turn) { result = new IntPoint(this.x, p_to_point.y); - } - else - { + } else { result = new IntPoint(p_to_point.x, this.y); } - } - else - { + } else { //the line from this point to p_to_point is already orthogonal result = null; } return result; } - - public int compare_x(Point p_other) - { + + public int compare_x(Point p_other) { return -p_other.compare_x(this); } - - public int compare_y(Point p_other) - { + + public int compare_y(Point p_other) { return -p_other.compare_y(this); } - - - int compare_x(IntPoint p_other) - { + + int compare_x(IntPoint p_other) { int result; - if (this.x > p_other.x) - { + if (this.x > p_other.x) { result = 1; - } - else if (this.x == p_other.x) - { + } else if (this.x == p_other.x) { result = 0; - } - else - { + } else { result = -1; } return result; } - - int compare_y(IntPoint p_other) - { + + int compare_y(IntPoint p_other) { int result; - if (this.y > p_other.y) - { + if (this.y > p_other.y) { result = 1; - } - else if (this.y == p_other.y) - { + } else if (this.y == p_other.y) { result = 0; - } - else - { + } else { result = -1; } return result; } - - int compare_x(RationalPoint p_other) - { + + int compare_x(RationalPoint p_other) { return -p_other.compare_x(this); } - - int compare_y(RationalPoint p_other) - { + + int compare_y(RationalPoint p_other) { return -p_other.compare_y(this); } - - /** - * the x coordinate of this point - */ - public final int x; - - /** - * the y coordinate of this point - */ - public final int y; } diff --git a/src/main/java/net/freerouting/geometry/planar/IntVector.java b/src/main/java/net/freerouting/geometry/planar/IntVector.java index 7fa2ed4c..abc175d0 100644 --- a/src/main/java/net/freerouting/geometry/planar/IntVector.java +++ b/src/main/java/net/freerouting/geometry/planar/IntVector.java @@ -19,275 +19,231 @@ */ package net.freerouting.geometry.planar; + import net.freerouting.datastructures.BigIntAux; import net.freerouting.datastructures.Signum; /** - * * Implementation of the interface Vector via a tuple of integers * * @author Alfons Wirtz */ -public class IntVector extends Vector implements java.io.Serializable -{ - +public class IntVector extends Vector implements java.io.Serializable { + + /** + * the x coordinate of this vector + */ + public final int x; + /** + * the y coordinate of this vector + */ + public final int y; + /** * creates an IntVector from two integer coordinates */ - public IntVector(int p_x, int p_y) - { + public IntVector(int p_x, int p_y) { // range check ommitet for performance reasons x = p_x; y = p_y; } - + /** * returns true, if this IntVector is equal to p_ob */ - public final boolean equals( Object p_ob ) - { - if ( this == p_ob ) - { + public final boolean equals(Object p_ob) { + if (this == p_ob) { return true; } - if ( p_ob == null ) - { + if (p_ob == null) { return false; } - if ( getClass() != p_ob.getClass() ) - { - return false ; + if (getClass() != p_ob.getClass()) { + return false; } - IntVector other = (IntVector)p_ob ; - return ( x == other.x && y == other.y ) ; + IntVector other = (IntVector) p_ob; + return (x == other.x && y == other.y); } - + /** * returns true, if both coordinates of this vector are 0 */ - public final boolean is_zero() - { + public final boolean is_zero() { return x == 0 && y == 0; } - + /** * returns the Vector such that this plus this.minus() is zero */ - public Vector negate() - { + public Vector negate() { return new IntVector(-x, -y); } - - public boolean is_orthogonal() - { - return ( x == 0 || y == 0 ) ; + + public boolean is_orthogonal() { + return (x == 0 || y == 0); } - - public boolean is_diagonal() - { - return ( Math.abs(x) == Math.abs(y) ) ; + + public boolean is_diagonal() { + return (Math.abs(x) == Math.abs(y)); } - + /** * Calculates the determinant of the matrix consisting of this * Vector and p_other. */ - public final long determinant(IntVector p_other) - { - return (long)x * p_other.y - (long)y * p_other.x; + public final long determinant(IntVector p_other) { + return (long) x * p_other.y - (long) y * p_other.x; } - - public Vector turn_90_degree(int p_factor) - { + + public Vector turn_90_degree(int p_factor) { int n = p_factor; - while (n < 0) - { + while (n < 0) { n += 4; } - while (n >= 4) - { + while (n >= 4) { n -= 4; } - int new_x ; - int new_y ; - switch (n) - { + int new_x; + int new_y; + switch (n) { case 0: // 0 degree new_x = x; new_y = y; break; case 1: // 90 degree - new_x = -y ; - new_y = x ; + new_x = -y; + new_y = x; break; case 2: // 180 degree - new_x = -x ; - new_y = -y ; + new_x = -x; + new_y = -y; break; case 3: // 270 degree - new_x = y ; - new_y = -x ; + new_x = y; + new_y = -x; break; default: - new_x = 0 ; - new_y = 0 ; + new_x = 0; + new_y = 0; } - return new IntVector(new_x, new_y) ; + return new IntVector(new_x, new_y); } - - - public Vector mirror_at_y_axis() - { + + public Vector mirror_at_y_axis() { return new IntVector(-this.x, this.y); } - - public Vector mirror_at_x_axis() - { + + public Vector mirror_at_x_axis() { return new IntVector(this.x, -this.y); } - + /** * adds p_other to this vector */ - public final Vector add( Vector p_other) - { + public final Vector add(Vector p_other) { return p_other.add(this); } - - final Vector add( IntVector p_other) - { + + final Vector add(IntVector p_other) { return new IntVector(x + p_other.x, y + p_other.y); } - - final Vector add( RationalVector p_other) - { + + final Vector add(RationalVector p_other) { return p_other.add(this); } - + /** * returns the Point, which results from adding this vector to p_point */ - final Point add_to(IntPoint p_point) - { + final Point add_to(IntPoint p_point) { return new IntPoint(p_point.x + x, p_point.y + y); } - - final Point add_to(RationalPoint p_point) - { + + final Point add_to(RationalPoint p_point) { return p_point.translate_by(this); } - - - + /** * Let L be the line from the Zero Vector to p_other. * The function returns - * Side.ON_THE_LEFT, if this Vector is on the left of L - * Side.ON_THE_RIGHT, if this Vector is on the right of L - * and Side.COLLINEAR, if this Vector is collinear with L. + * Side.ON_THE_LEFT, if this Vector is on the left of L + * Side.ON_THE_RIGHT, if this Vector is on the right of L + * and Side.COLLINEAR, if this Vector is collinear with L. */ - public Side side_of(Vector p_other) - { + public Side side_of(Vector p_other) { Side tmp = p_other.side_of(this); return tmp.negate(); } - - Side side_of(IntVector p_other) - { + + Side side_of(IntVector p_other) { double determinant = (double) p_other.x * y - (double) p_other.y * x; return Side.of(determinant); } - - Side side_of(RationalVector p_other) - { + + Side side_of(RationalVector p_other) { Side tmp = p_other.side_of(this); return tmp.negate(); } - + /** * The function returns - * Signum.POSITIVE, if the scalar product of this vector and p_other > 0, - * Signum.NEGATIVE, if the scalar product Vector is < 0, - * and Signum.ZERO, if the scalar product is equal 0. + * Signum.POSITIVE, if the scalar product of this vector and p_other > 0, + * Signum.NEGATIVE, if the scalar product Vector is < 0, + * and Signum.ZERO, if the scalar product is equal 0. */ - public Signum projection(Vector p_other) - { + public Signum projection(Vector p_other) { return p_other.projection(this); } - - public double scalar_product(Vector p_other) - { + + public double scalar_product(Vector p_other) { return p_other.scalar_product(this); } - - - + /** * converts this vector to a PointFloat. */ - public FloatPoint to_float() - { + public FloatPoint to_float() { return new FloatPoint(x, y); } - - public Vector change_length_approx(double p_length) - { + + public Vector change_length_approx(double p_length) { FloatPoint new_point = this.to_float().change_size(p_length); return new_point.round().difference_by(Point.ZERO); } - - Direction to_normalized_direction() - { + + Direction to_normalized_direction() { int dx = x; int dy = y; - + int gcd = BigIntAux.binaryGcd(Math.abs(dx), Math.abs(dy)); - if (gcd > 1) - { + if (gcd > 1) { dx /= gcd; dy /= gcd; } return new IntDirection(dx, dy); } - - + /** * The function returns - * Signum.POSITIVE, if the scalar product of this vector and p_other > 0, - * Signum.NEGATIVE, if the scalar product Vector is < 0, - * and Signum.ZERO, if the scalar product is equal 0. + * Signum.POSITIVE, if the scalar product of this vector and p_other > 0, + * Signum.NEGATIVE, if the scalar product Vector is < 0, + * and Signum.ZERO, if the scalar product is equal 0. */ - Signum projection(IntVector p_other) - { + Signum projection(IntVector p_other) { double tmp = (double) x * p_other.x + (double) y * p_other.y; return Signum.of(tmp); } - - double scalar_product(IntVector p_other) - { + + double scalar_product(IntVector p_other) { return (double) x * p_other.x + (double) y * p_other.y; } - - double scalar_product(RationalVector p_other) - { + + double scalar_product(RationalVector p_other) { return p_other.scalar_product(this); } - - - Signum projection(RationalVector p_other) - { + + Signum projection(RationalVector p_other) { return p_other.projection(this); } - - - /** - * the x coordinate of this vector - */ - public final int x; - - /** - * the y coordinate of this vector - */ - public final int y; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/Limits.java b/src/main/java/net/freerouting/geometry/planar/Limits.java index 5c3e6546..948e5ae2 100644 --- a/src/main/java/net/freerouting/geometry/planar/Limits.java +++ b/src/main/java/net/freerouting/geometry/planar/Limits.java @@ -15,25 +15,23 @@ */ package net.freerouting.geometry.planar; + import java.math.BigInteger; /** - * * Some numerical limits and values are stored here. * - * @author Alfons Wirtz */ -public class Limits -{ +public class Limits { /** * An upper bound (2^25) so that the product of two integers with absolut * value at most CRIT_COOR is contained in the mantissa of a double with * some space left for addition. */ - public static final int CRIT_INT = 33554432; + public static final int CRIT_INT = 33554432; /** * the biggest double value ( 2 ^53) , so that all integers smaller than diff --git a/src/main/java/net/freerouting/geometry/planar/Line.java b/src/main/java/net/freerouting/geometry/planar/Line.java index 997a2505..559473e7 100644 --- a/src/main/java/net/freerouting/geometry/planar/Line.java +++ b/src/main/java/net/freerouting/geometry/planar/Line.java @@ -16,193 +16,168 @@ package net.freerouting.geometry.planar; -import java.math.BigInteger; - import net.freerouting.datastructures.Signum; +import java.math.BigInteger; + /** - * * Implements functionality for lines in the plane. * * @author Alfons Wirtz */ -public class Line implements Comparable, java.io.Serializable -{ - +public class Line implements Comparable, java.io.Serializable { + + public final Point a; + public final Point b; + transient private Direction dir; // should only be accessed from get_direction(). + /** * creates a directed Line from two Points */ - public Line(Point p_a, Point p_b) - { + public Line(Point p_a, Point p_b) { a = p_a; b = p_b; dir = null; - if (!(a instanceof IntPoint && b instanceof IntPoint)) - { + if (!(a instanceof IntPoint && b instanceof IntPoint)) { System.out.println("Line(p_a, p_b) only implemented for IntPoints till now"); } } - + /** * creates a directed Line from four integer Coordinates */ - public Line(int p_a_x, int p_a_y, int p_b_x, int p_b_y) - { + public Line(int p_a_x, int p_a_y, int p_b_x, int p_b_y) { a = new IntPoint(p_a_x, p_a_y); b = new IntPoint(p_b_x, p_b_y); dir = null; } - + /** * creates a directed Line from a Point and a Direction */ - public Line(Point p_a, Direction p_dir) - { + public Line(Point p_a, Direction p_dir) { a = p_a; b = p_a.translate_by(p_dir.get_vector()); dir = p_dir; - if (!(a instanceof IntPoint && b instanceof IntPoint)) - { + if (!(a instanceof IntPoint && b instanceof IntPoint)) { System.out.println("Line(p_a, p_dir) only implemented for IntPoints till now"); } } - + /** * create a directed line from an IntPoint and an IntDirection */ - public static Line get_instance(Point p_a, Direction p_dir) - { + public static Line get_instance(Point p_a, Direction p_dir) { Point b = p_a.translate_by(p_dir.get_vector()); return new Line(p_a, b); } - + /** * returns true, if this and p_ob define the same line */ - public final boolean equals( Object p_ob ) - { - if ( this == p_ob ) - { + public final boolean equals(Object p_ob) { + if (this == p_ob) { return true; } - if ( p_ob == null ) - { + if (p_ob == null) { return false; } - if (!(p_ob instanceof Line)) - { + if (!(p_ob instanceof Line)) { return false; } - Line other = (Line)p_ob ; - if (side_of(other.a) != Side.COLLINEAR) - { + Line other = (Line) p_ob; + if (side_of(other.a) != Side.COLLINEAR) { return false; } return direction().equals(other.direction()); } - + /** * Returns true, if this and p_other define the same line. * Is designed for good performance, but * works only for lines consisting of IntPoints. */ - public final boolean fast_equals(Line p_other) - { - IntPoint this_a = (IntPoint)a; - IntPoint this_b = (IntPoint)b; - IntPoint other_a = (IntPoint)p_other.a; + public final boolean fast_equals(Line p_other) { + IntPoint this_a = (IntPoint) a; + IntPoint this_b = (IntPoint) b; + IntPoint other_a = (IntPoint) p_other.a; double dx1 = other_a.x - this_a.x; double dy1 = other_a.y - this_a.y; double dx2 = this_b.x - this_a.x; double dy2 = this_b.y - this_a.y; double det = dx1 * dy2 - dx2 * dy1; - if (det != 0) - { + if (det != 0) { return false; } return direction().equals(p_other.direction()); } - - + /** * get the direction of this directed line */ - public Direction direction() - { - if (dir == null) - { + public Direction direction() { + if (dir == null) { Vector d = b.difference_by(a); dir = Direction.get_instance(d); } return dir; } - + /** * The function returns - * Side.ON_THE_LEFT, if this Line is on the left of p_point, - * Side.ON_THE_RIGHT, if this Line is on the right of p_point - * and Side.COLLINEAR, if this Line contains p_point. + * Side.ON_THE_LEFT, if this Line is on the left of p_point, + * Side.ON_THE_RIGHT, if this Line is on the right of p_point + * and Side.COLLINEAR, if this Line contains p_point. */ - public Side side_of(Point p_point) - { + public Side side_of(Point p_point) { Side result = p_point.side_of(this); return result.negate(); } - - + /** * Returns Side.COLLINEAR, if p_point is on the line with tolerance p_tolerance. * Otherwise Side.ON_THE_LEFT, if this line is on the left of p_point, * or Side.ON_THE_RIGHT, if this line is on the right of p_point, */ - public Side side_of(FloatPoint p_point, double p_tolerance) - { + public Side side_of(FloatPoint p_point, double p_tolerance) { // only implemented for IntPoint lines for performance reasons - IntPoint this_a = (IntPoint)a; - IntPoint this_b = (IntPoint)b; + IntPoint this_a = (IntPoint) a; + IntPoint this_b = (IntPoint) b; double det = (this_b.y - this_a.y) * (p_point.x - this_a.x) - - (this_b.x - this_a.x) * (p_point.y - this_a.y); + (this_b.x - this_a.x) * (p_point.y - this_a.y); Side result; - if (det - p_tolerance > 0) - { + if (det - p_tolerance > 0) { result = Side.ON_THE_LEFT; - } - else if (det + p_tolerance < 0) - { + } else if (det + p_tolerance < 0) { result = Side.ON_THE_RIGHT; - } - else - { + } else { result = Side.COLLINEAR; } - + return result; } - + /** * returns Side.ON_THE_LEFT, if this line is on the left of p_point, - * Side.ON_THE_RIGHT, if this line is on the right of p_point, - * Side.COLLINEAR otherwise. + * Side.ON_THE_RIGHT, if this line is on the right of p_point, + * Side.COLLINEAR otherwise. */ - public Side side_of(FloatPoint p_point) - { + public Side side_of(FloatPoint p_point) { return side_of(p_point, 0); } - + /** * Returns Side.ON_THE_LEFT, if this line is on the left of the intersection * of p_1 and p_2, Side.ON_THE_RIGHT, if this line is on the right of the intersection, - * and Side.COLLINEAR, if all 3 lines intersect in exacly 1 point. + * and Side.COLLINEAR, if all 3 lines intersect in exacly 1 point. */ - public Side side_of_intersection(Line p_1, Line p_2) - { - + public Side side_of_intersection(Line p_1, Line p_2) { + FloatPoint intersection_approx = p_1.intersection_approx(p_2); Side result = this.side_of(intersection_approx, 1.0); - if (result == Side.COLLINEAR) - { + if (result == Side.COLLINEAR) { // Previous calculation was with FloatPoints and a tolerance // for performance reasons. Make an exact check for // collinearity now with class Point instead of FloatPoint. @@ -211,162 +186,149 @@ public Side side_of_intersection(Line p_1, Line p_2) } return result; } - + /** * Looks, if all interiour points of p_tile are on the right side of this line. */ - public boolean is_on_the_left(TileShape p_tile) - { - for ( int i = 0; i < p_tile.border_line_count(); ++i) - { - if (this.side_of(p_tile.corner(i)) == Side.ON_THE_RIGHT) - { + public boolean is_on_the_left(TileShape p_tile) { + for (int i = 0; i < p_tile.border_line_count(); ++i) { + if (this.side_of(p_tile.corner(i)) == Side.ON_THE_RIGHT) { return false; } } return true; } - + /** * Looks, if all interiour points of p_tile are on the left side of this line. */ - public boolean is_on_the_right(TileShape p_tile) - { - for ( int i = 0; i < p_tile.border_line_count(); ++i) - { - if (this.side_of(p_tile.corner(i)) == Side.ON_THE_LEFT) - { + public boolean is_on_the_right(TileShape p_tile) { + for (int i = 0; i < p_tile.border_line_count(); ++i) { + if (this.side_of(p_tile.corner(i)) == Side.ON_THE_LEFT) { return false; } } return true; } - + /** * Returns the signed distance of this line from p_point. * The result will be positive, if the line is on the left of p_point, * else negative. */ - public double signed_distance(FloatPoint p_point) - { + public double signed_distance(FloatPoint p_point) { // only implemented for IntPoint lines for performance reasons - IntPoint this_a = (IntPoint)a; - IntPoint this_b = (IntPoint)b; + IntPoint this_a = (IntPoint) a; + IntPoint this_b = (IntPoint) b; double dx = this_b.x - this_a.x; double dy = this_b.y - this_a.y; double det = dy * (p_point.x - this_a.x) - - dx * (p_point.y - this_a.y); + dx * (p_point.y - this_a.y); // area of the parallelogramm spanned by the 3 points double length = Math.sqrt(dx * dx + dy * dy); return det / length; } - + /** * returns true, if the 2 lines defins the same set of points, but may * have opposite directions */ - public boolean overlaps(Line p_other) - { + public boolean overlaps(Line p_other) { return side_of(p_other.a) == Side.COLLINEAR && side_of(p_other.b) == Side.COLLINEAR; } - + /** * Returns the line defining the same set of points, but * with opposite direction */ - public Line opposite() - { + public Line opposite() { return new Line(b, a); } - + /** * Returns the intersection point of the 2 lines. * If the lines are parallel result.is_infinite() will be true. */ - public Point intersection(Line p_other) - { + public Point intersection(Line p_other) { // this function is at the moment only implemented for lines // consisting of IntPoints. // The general implementation is still missing. - IntVector delta_1 = (IntVector)b.difference_by(a); - IntVector delta_2 = (IntVector)p_other.b.difference_by(p_other.a); + IntVector delta_1 = (IntVector) b.difference_by(a); + IntVector delta_2 = (IntVector) p_other.b.difference_by(p_other.a); // Separate handling for orthogonal and 45 degree lines for better perpormance - if (delta_1.x == 0 ) // this line is vertical + if (delta_1.x == 0) // this line is vertical { if (delta_2.y == 0) // other line is horizontal { - return new IntPoint(((IntPoint)this.a).x, ((IntPoint)p_other.a).y); + return new IntPoint(((IntPoint) this.a).x, ((IntPoint) p_other.a).y); } if (delta_2.x == delta_2.y) // other line is right diagonal { - int this_x = ((IntPoint)this.a).x; + int this_x = ((IntPoint) this.a).x; IntPoint other_a = (IntPoint) p_other.a; return new IntPoint(this_x, other_a.y + this_x - other_a.x); } if (delta_2.x == -delta_2.y) // other line is left diagonal { - int this_x = ((IntPoint)this.a).x; + int this_x = ((IntPoint) this.a).x; IntPoint other_a = (IntPoint) p_other.a; return new IntPoint(this_x, other_a.y + other_a.x - this_x); } - } - else if (delta_1.y == 0) // this line is horizontal + } else if (delta_1.y == 0) // this line is horizontal { if (delta_2.x == 0) // other line is vertical { - return new IntPoint(((IntPoint)p_other.a).x, ((IntPoint)this.a).y); + return new IntPoint(((IntPoint) p_other.a).x, ((IntPoint) this.a).y); } if (delta_2.x == delta_2.y) // other line is right diagonal { - int this_y = ((IntPoint)this.a).y; + int this_y = ((IntPoint) this.a).y; IntPoint other_a = (IntPoint) p_other.a; return new IntPoint(other_a.x + this_y - other_a.y, this_y); } if (delta_2.x == -delta_2.y) // other line is left diagonal { - int this_y = ((IntPoint)this.a).y; + int this_y = ((IntPoint) this.a).y; IntPoint other_a = (IntPoint) p_other.a; return new IntPoint(other_a.x + other_a.y - this_y, this_y); } - } - else if (delta_1.x == delta_1.y) // this line is right diagonal + } else if (delta_1.x == delta_1.y) // this line is right diagonal { if (delta_2.x == 0) // other line is vertical { - int other_x = ((IntPoint)p_other.a).x; + int other_x = ((IntPoint) p_other.a).x; IntPoint this_a = (IntPoint) this.a; return new IntPoint(other_x, this_a.y + other_x - this_a.x); } if (delta_2.y == 0) // other line is horizontal { - int other_y = ((IntPoint)p_other.a).y; + int other_y = ((IntPoint) p_other.a).y; IntPoint this_a = (IntPoint) this.a; return new IntPoint(this_a.x + other_y - this_a.y, other_y); } - } - else if (delta_1.x == -delta_1.y) // this line is left diagonal + } else if (delta_1.x == -delta_1.y) // this line is left diagonal { if (delta_2.x == 0) // other line is vertical { - int other_x = ((IntPoint)p_other.a).x; + int other_x = ((IntPoint) p_other.a).x; IntPoint this_a = (IntPoint) this.a; return new IntPoint(other_x, this_a.y + this_a.x - other_x); } if (delta_2.y == 0) // other line is horizontal { - int other_y = ((IntPoint)p_other.a).y; + int other_y = ((IntPoint) p_other.a).y; IntPoint this_a = (IntPoint) this.a; return new IntPoint(this_a.x + this_a.y - other_y, other_y); } } - + BigInteger det_1 = - BigInteger.valueOf(((IntPoint)a).determinant((IntPoint)b)); + BigInteger.valueOf(((IntPoint) a).determinant((IntPoint) b)); BigInteger det_2 = - BigInteger.valueOf(((IntPoint)p_other.a).determinant((IntPoint)p_other.b)); - BigInteger det = BigInteger.valueOf(delta_2.determinant(delta_1)); + BigInteger.valueOf(((IntPoint) p_other.a).determinant((IntPoint) p_other.b)); + BigInteger det = BigInteger.valueOf(delta_2.determinant(delta_1)); BigInteger tmp_1 = det_1.multiply(BigInteger.valueOf(delta_2.x)); BigInteger tmp_2 = det_2.multiply(BigInteger.valueOf(delta_1.x)); BigInteger is_x = tmp_1.subtract(tmp_2); @@ -374,21 +336,17 @@ else if (delta_1.x == -delta_1.y) // this line is left diagonal tmp_2 = det_2.multiply(BigInteger.valueOf(delta_1.y)); BigInteger is_y = tmp_1.subtract(tmp_2); int signum = det.signum(); - if (signum != 0) - { - if (signum < 0) - { + if (signum != 0) { + if (signum < 0) { det = det.negate(); is_x = is_x.negate(); is_y = is_y.negate(); } - if ((is_x.mod(det)).signum() == 0 && (is_y.mod(det)).signum() == 0) - { + if ((is_x.mod(det)).signum() == 0 && (is_y.mod(det)).signum() == 0) { is_x = is_x.divide(det); is_y = is_y.divide(det); if (Math.abs(is_x.doubleValue()) <= Limits.CRIT_INT - && Math.abs(is_y.doubleValue()) <= Limits.CRIT_INT) - { + && Math.abs(is_y.doubleValue()) <= Limits.CRIT_INT) { return new IntPoint(is_x.intValue(), is_y.intValue()); } det = BigInteger.ONE; @@ -396,15 +354,14 @@ else if (delta_1.x == -delta_1.y) // this line is left diagonal } return new RationalPoint(is_x, is_y, det); } - + /** * Returns an approximation of the intersection of the 2 lines by a * FloatPoint. If the lines are parallel the result coordinates will be * Integer.MAX_VALUE. Useful in situations ehere performance is * more important than accuracy. */ - public FloatPoint intersection_approx(Line p_other) - { + public FloatPoint intersection_approx(Line p_other) { // this function is at the moment only implemented for lines // consisting of IntPoints. // The general implementation is still missing. @@ -416,140 +373,121 @@ public FloatPoint intersection_approx(Line p_other) double d1y = this_b.y - this_a.y; double d2x = other_b.x - other_a.x; double d2y = other_b.y - other_a.y; - double det_1 = (double)this_a.x * this_b.y - (double)this_a.y * this_b.x; - double det_2 = (double)other_a.x * other_b.y - (double)other_a.y * other_b.x; + double det_1 = (double) this_a.x * this_b.y - (double) this_a.y * this_b.x; + double det_2 = (double) other_a.x * other_b.y - (double) other_a.y * other_b.x; double det = d2x * d1y - d2y * d1x; double is_x; double is_y; - if(det == 0) - { + if (det == 0) { is_x = Integer.MAX_VALUE; is_y = Integer.MAX_VALUE; - } - else - { + } else { is_x = (d2x * det_1 - d1x * det_2) / det; is_y = (d2y * det_1 - d1y * det_2) / det; } return new FloatPoint(is_x, is_y); } - + /** * returns the perpendicular projection of p_point onto this line */ - public Point perpendicular_projection(Point p_point) - { + public Point perpendicular_projection(Point p_point) { return p_point.perpendicular_projection(this); } - + /** * translates the line perpendicular at about p_dist. * If p_dist > 0, the line will be translated to the left, else to the right */ - public Line translate(double p_dist) - { + public Line translate(double p_dist) { // this function is at the moment only implemented for lines // consisting of IntPoints. // The general implementation is still missing. IntPoint ai = (IntPoint) a; - IntVector v = (IntVector)direction().get_vector(); - double vxvx = (double)v.x * v.x; - double vyvy = (double)v.y * v.y; + IntVector v = (IntVector) direction().get_vector(); + double vxvx = (double) v.x * v.x; + double vyvy = (double) v.y * v.y; double lenght = Math.sqrt(vxvx + vyvy); IntPoint new_a; - if (vxvx <= vyvy) - { + if (vxvx <= vyvy) { // translate along the x axis int rel_x = (int) Math.round((p_dist * lenght) / v.y); new_a = new IntPoint(ai.x - rel_x, ai.y); - } - else - { + } else { // translate along the y axis int rel_y = (int) Math.round((p_dist * lenght) / v.x); new_a = new IntPoint(ai.x, ai.y + rel_y); } return Line.get_instance(new_a, direction()); } - + /** * translates the line by p_vector */ - public Line translate_by(Vector p_vector) - { - if (p_vector.equals(Vector.ZERO)) - { + public Line translate_by(Vector p_vector) { + if (p_vector.equals(Vector.ZERO)) { return this; } Point new_a = a.translate_by(p_vector); Point new_b = b.translate_by(p_vector); return new Line(new_a, new_b); } - - + /** * returns true, if the line is axis_parallel */ - public boolean is_orthogonal() - { + public boolean is_orthogonal() { return direction().is_orthogonal(); } - + /** * returns true, if this line is diagonal */ - public boolean is_diagonal() - { + public boolean is_diagonal() { return direction().is_diagonal(); } - + /** * returns true, if the direction of this line is a multiple of 45 degree */ - public boolean is_multiple_of_45_degree() - { + public boolean is_multiple_of_45_degree() { return direction().is_multiple_of_45_degree(); } - + /** * checks, if this Line and p_other are parallel */ - public boolean is_parallel(Line p_other) - { + public boolean is_parallel(Line p_other) { return this.direction().side_of(p_other.direction()) == Side.COLLINEAR; } - + /** * checks, if this Line and p_other are perpendicular */ - public boolean is_perpendicular(Line p_other) - { + public boolean is_perpendicular(Line p_other) { Vector v1 = direction().get_vector(); Vector v2 = p_other.direction().get_vector(); return v1.projection(v2) == Signum.ZERO; } - + /** * returns true, if this and p_ob define the same line */ - public boolean is_equal_or_opposite(Line p_other ) - { - - return(side_of(p_other.a) == Side.COLLINEAR && + public boolean is_equal_or_opposite(Line p_other) { + + return (side_of(p_other.a) == Side.COLLINEAR && side_of(p_other.b) == Side.COLLINEAR); } - - + /** * calculates the cosinus of the angle between this line and p_other */ - public double cos_angle( Line p_other) - { + public double cos_angle(Line p_other) { Vector v1 = b.difference_by(a); Vector v2 = p_other.b.difference_by(p_other.a); return v1.cos_angle(v2); } - + /** * A line l_1 is defined bigger than a line l_2, if the direction of l_1 * is bigger than the direction of l_2. @@ -558,8 +496,7 @@ public double cos_angle( Line p_other) * Fast implementation only for lines consisting of IntPoints * because of critical performance */ - public int compareTo(Line p_other) - { + public int compareTo(Line p_other) { IntPoint this_a = (IntPoint) a; IntPoint this_b = (IntPoint) b; IntPoint other_a = (IntPoint) p_other.a; @@ -568,164 +505,137 @@ public int compareTo(Line p_other) int dy1 = this_b.y - this_a.y; int dx2 = other_b.x - other_a.x; int dy2 = other_b.y - other_a.y; - if (dy1 > 0) - { - if (dy2 < 0) - { - return -1 ; + if (dy1 > 0) { + if (dy2 < 0) { + return -1; } - if (dy2 == 0) - { - if (dx2 > 0) - { - return 1 ; + if (dy2 == 0) { + if (dx2 > 0) { + return 1; } - return -1 ; + return -1; } - } - else if (dy1 < 0) - { - if (dy2 >= 0) - { - return 1 ; + } else if (dy1 < 0) { + if (dy2 >= 0) { + return 1; } - } - else // dy1 == 0 + } else // dy1 == 0 { - if (dx1 > 0) - { - if (dy2 != 0 || dx2 < 0) - { - return -1 ; + if (dx1 > 0) { + if (dy2 != 0 || dx2 < 0) { + return -1; } - return 0 ; + return 0; } // dx1 < 0 - if (dy2 > 0 || dy2 == 0 && dx2 > 0) - { - return 1 ; + if (dy2 > 0 || dy2 == 0 && dx2 > 0) { + return 1; } - if (dy2 < 0) - { - return -1 ; + if (dy2 < 0) { + return -1; } return 0; } - + // now this direction and p_other are located in the same // open horizontal half plane - + double determinant = (double) dx2 * dy1 - (double) dy2 * dx1; return Signum.as_int(determinant); } - + /** * Calculates an approximation of the function value of this line at p_x, * if the line is not vertical. */ - public double function_value_approx(double p_x) - { + public double function_value_approx(double p_x) { FloatPoint p1 = a.to_float(); FloatPoint p2 = b.to_float(); double dx = p2.x - p1.x; - if (dx == 0) - { + if (dx == 0) { System.out.println("function_value_approx: line is vertical"); return 0; } double dy = p2.y - p1.y; - double det = p1.x * p2.y - p2.x * p1.y; - double result = (dy * p_x - det) /dx; + double det = p1.x * p2.y - p2.x * p1.y; + double result = (dy * p_x - det) / dx; return result; } - + /** * Calculates an approximation of the function value in y of this line at p_y, * if the line is not horizontal. */ - public double function_in_y_value_approx(double p_y) - { + public double function_in_y_value_approx(double p_y) { FloatPoint p1 = a.to_float(); FloatPoint p2 = b.to_float(); double dy = p2.y - p1.y; - if (dy == 0) - { + if (dy == 0) { System.out.println("function_in_y_value_approx: line is horizontal"); return 0; } double dx = p2.x - p1.x; - double det = p1.x * p2.y - p2.x * p1.y; - double result = (dx * p_y + det) /dy; + double det = p1.x * p2.y - p2.x * p1.y; + double result = (dx * p_y + det) / dy; return result; } - + /** * Calculates the direction from p_from_point to the nearest point on * this line to p_fro_point. * Returns null, if p_from_point is contained in this line. */ - public Direction perpendicular_direction(Point p_from_point) - { + public Direction perpendicular_direction(Point p_from_point) { Side line_side = this.side_of(p_from_point); - if (line_side == Side.COLLINEAR) - { + if (line_side == Side.COLLINEAR) { return null; } Direction dir1 = this.direction().turn_45_degree(2); Direction dir2 = this.direction().turn_45_degree(6); - + Point check_point_1 = p_from_point.translate_by(dir1.get_vector()); - if (this.side_of(check_point_1) != line_side) - { + if (this.side_of(check_point_1) != line_side) { return dir1; } Point check_point_2 = p_from_point.translate_by(dir2.get_vector()); - if (this.side_of(check_point_2) != line_side) - { + if (this.side_of(check_point_2) != line_side) { return dir2; } FloatPoint nearest_line_point = p_from_point.to_float().projection_approx(this); Direction result; if (nearest_line_point.distance_square(check_point_1.to_float()) <= - nearest_line_point.distance_square(check_point_2.to_float())) - { + nearest_line_point.distance_square(check_point_2.to_float())) { result = dir1; - } - else - { + } else { result = dir2; } return result; } - + /** * Turns this line by p_factor times 90 degree around p_pole. */ - public Line turn_90_degree(int p_factor, IntPoint p_pole) - { + public Line turn_90_degree(int p_factor, IntPoint p_pole) { Point new_a = a.turn_90_degree(p_factor, p_pole); Point new_b = b.turn_90_degree(p_factor, p_pole); return new Line(new_a, new_b); } - - /** Mirrors this line at the vertical line through p_pole */ - public Line mirror_vertical(IntPoint p_pole) - { + + /** + * Mirrors this line at the vertical line through p_pole + */ + public Line mirror_vertical(IntPoint p_pole) { Point new_a = b.mirror_vertical(p_pole); Point new_b = a.mirror_vertical(p_pole); return new Line(new_a, new_b); } - - /** Mirrors this line at the horizontal line through p_pole */ - public Line mirror_horizontal(IntPoint p_pole) - { + + /** + * Mirrors this line at the horizontal line through p_pole + */ + public Line mirror_horizontal(IntPoint p_pole) { Point new_a = b.mirror_horizontal(p_pole); Point new_b = a.mirror_horizontal(p_pole); return new Line(new_a, new_b); } - - - public final Point a; - public final Point b; - transient private Direction dir; // should only be accessed from get_direction(). } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/LineSegment.java b/src/main/java/net/freerouting/geometry/planar/LineSegment.java index d14e78a0..150a13af 100644 --- a/src/main/java/net/freerouting/geometry/planar/LineSegment.java +++ b/src/main/java/net/freerouting/geometry/planar/LineSegment.java @@ -23,11 +23,15 @@ * Line is, that a Line is infinite and a * LineSegment has a start and an endpoint. * - * * @author Alfons Wirtz */ -public class LineSegment implements java.io.Serializable -{ +public class LineSegment implements java.io.Serializable { + + private final Line start; + private final Line middle; + private final Line end; + transient private Point precalculated_start_point = null; + transient private Point precalculated_end_point = null; /** * Creates a line segment from the 3 input lines. @@ -35,8 +39,7 @@ public class LineSegment implements java.io.Serializable * and ends at the intersection of p_middle_line and p_end_line. * p_start_line and p_end_line must not be parallel to p_middle_line. */ - public LineSegment(Line p_start_line, Line p_middle_line, Line p_end_line) - { + public LineSegment(Line p_start_line, Line p_middle_line, Line p_end_line) { start = p_start_line; middle = p_middle_line; end = p_end_line; @@ -46,10 +49,8 @@ public LineSegment(Line p_start_line, Line p_middle_line, Line p_end_line) * creates the p_no-th line segment of p_polyline * for p_no between 1 and p_polyline.line_count - 2. */ - public LineSegment(Polyline p_polyline, int p_no) - { - if (p_no <= 0 || p_no >= p_polyline.arr.length - 1) - { + public LineSegment(Polyline p_polyline, int p_no) { + if (p_no <= 0 || p_no >= p_polyline.arr.length - 1) { System.out.println("LineSegment from Polyline: p_no out of range"); start = null; middle = null; @@ -65,32 +66,24 @@ public LineSegment(Polyline p_polyline, int p_no) * Creates the p_no-th line segment of p_shape * for p_no between 0 and p_shape.line_count - 1. */ - public LineSegment(PolylineShape p_shape, int p_no) - { + public LineSegment(PolylineShape p_shape, int p_no) { int line_count = p_shape.border_line_count(); - if (p_no < 0 || p_no >= line_count) - { + if (p_no < 0 || p_no >= line_count) { System.out.println("LineSegment from TileShape: p_no out of range"); start = null; middle = null; end = null; return; } - if (p_no == 0) - { + if (p_no == 0) { start = p_shape.border_line(line_count - 1); - } - else - { + } else { start = p_shape.border_line(p_no - 1); } middle = p_shape.border_line(p_no); - if (p_no == line_count - 1) - { + if (p_no == line_count - 1) { end = p_shape.border_line(0); - } - else - { + } else { end = p_shape.border_line(p_no + 1); } } @@ -98,10 +91,8 @@ public LineSegment(PolylineShape p_shape, int p_no) /** * Returns the intersection of the first 2 lines of this segment */ - public Point start_point() - { - if (precalculated_start_point == null) - { + public Point start_point() { + if (precalculated_start_point == null) { precalculated_start_point = middle.intersection(start); } return precalculated_start_point; @@ -110,10 +101,8 @@ public Point start_point() /** * Returns the intersection of the last 2 lines of this segment */ - public Point end_point() - { - if (precalculated_end_point == null) - { + public Point end_point() { + if (precalculated_end_point == null) { precalculated_end_point = middle.intersection(end); } return precalculated_end_point; @@ -122,15 +111,11 @@ public Point end_point() /** * Returns an approximation of the intersection of the first 2 lines of this segment */ - public FloatPoint start_point_approx() - { + public FloatPoint start_point_approx() { FloatPoint result; - if (precalculated_start_point != null) - { + if (precalculated_start_point != null) { result = precalculated_start_point.to_float(); - } - else - { + } else { result = this.start.intersection_approx(this.middle); } return result; @@ -139,15 +124,11 @@ public FloatPoint start_point_approx() /** * Returns an approximation of the intersection of the last 2 lines of this segment */ - public FloatPoint end_point_approx() - { + public FloatPoint end_point_approx() { FloatPoint result; - if (precalculated_end_point != null) - { + if (precalculated_end_point != null) { result = precalculated_end_point.to_float(); - } - else - { + } else { result = this.end.intersection_approx(this.middle); } return result; @@ -156,40 +137,35 @@ public FloatPoint end_point_approx() /** * Returns the (infinite) line of this segment. */ - public Line get_line() - { + public Line get_line() { return middle; } /** * Returns the start closing line of this segment. */ - public Line get_start_closing_line() - { + public Line get_start_closing_line() { return start; } /** * Returns the end closing line of this segment. */ - public Line get_end_closing_line() - { + public Line get_end_closing_line() { return end; } /** * Returns the line segment with tje opposite direction. */ - public LineSegment opposite() - { + public LineSegment opposite() { return new LineSegment(end.opposite(), middle.opposite(), start.opposite()); } /** * Transforms this LinsSegment into a polyline of lenght 3. */ - public Polyline to_polyline() - { + public Polyline to_polyline() { Line[] lines = new Line[3]; lines[0] = start; lines[1] = middle; @@ -201,25 +177,18 @@ public Polyline to_polyline() * Creates a 1 dimensional simplex rom this line segment, which * has the same shape as the line sgment. */ - public Simplex to_simplex() - { + public Simplex to_simplex() { Line[] line_arr = new Line[4]; - if (this.end_point().side_of(this.start) == Side.ON_THE_RIGHT) - { + if (this.end_point().side_of(this.start) == Side.ON_THE_RIGHT) { line_arr[0] = this.start.opposite(); - } - else - { + } else { line_arr[0] = this.start; } line_arr[1] = this.middle; line_arr[2] = this.middle.opposite(); - if (this.start_point().side_of(this.end) == Side.ON_THE_RIGHT) - { + if (this.start_point().side_of(this.end) == Side.ON_THE_RIGHT) { line_arr[3] = this.end.opposite(); - } - else - { + } else { line_arr[3] = this.end; } Simplex result = Simplex.get_instance(line_arr); @@ -229,15 +198,12 @@ public Simplex to_simplex() /** * Checks if p_point is contained in this line segment */ - public boolean contains(Point p_point) - { - if (!(p_point instanceof IntPoint)) - { + public boolean contains(Point p_point) { + if (!(p_point instanceof IntPoint)) { System.out.println("LineSegments.contains currently only implementet for IntPoints"); return false; } - if (middle.side_of(p_point) != Side.COLLINEAR) - { + if (middle.side_of(p_point) != Side.COLLINEAR) { return false; } // create a perpendicular line at p_point and check, that the two @@ -246,8 +212,7 @@ public boolean contains(Point p_point) Line perpendicular_line = new Line(p_point, perpendicular_direction); Side start_point_side = perpendicular_line.side_of(this.start_point()); Side end_point_side = perpendicular_line.side_of(this.end_point()); - if (start_point_side != Side.COLLINEAR && end_point_side != Side.COLLINEAR && start_point_side == end_point_side) - { + if (start_point_side != Side.COLLINEAR && end_point_side != Side.COLLINEAR && start_point_side == end_point_side) { return false; } return true; @@ -256,8 +221,7 @@ public boolean contains(Point p_point) /** * calculates the smallest surrounding box of this line segmant */ - public IntBox bounding_box() - { + public IntBox bounding_box() { FloatPoint start_corner = middle.intersection_approx(start); FloatPoint end_corner = middle.intersection_approx(end); double llx = Math.min(start_corner.x, end_corner.x); @@ -272,8 +236,7 @@ public IntBox bounding_box() /** * calculates the smallest surrounding octagon of this line segmant */ - public IntOctagon bounding_octagon() - { + public IntOctagon bounding_octagon() { FloatPoint start_corner = middle.intersection_approx(start); FloatPoint end_corner = middle.intersection_approx(end); double lx = Math.floor(Math.min(start_corner.x, end_corner.x)); @@ -297,8 +260,7 @@ public IntOctagon bounding_octagon() * Creates a new line segment with the same start and middle line and an end line, * so that the length of the new line segment is about p_new_length. */ - public LineSegment change_length_approx(double p_new_length) - { + public LineSegment change_length_approx(double p_new_length) { FloatPoint new_end_point = start_point_approx().change_length(end_point_approx(), p_new_length); Direction perpendicular_direction = this.middle.direction().turn_45_degree(2); @@ -320,39 +282,31 @@ public LineSegment change_length_approx(double p_new_length) * The result is not symmetric in this and p_other, because intersecting lines * and not the intersection points are returned. */ - public Line[] intersection(LineSegment p_other) - { - if (!this.bounding_box().intersects(p_other.bounding_box())) - { + public Line[] intersection(LineSegment p_other) { + if (!this.bounding_box().intersects(p_other.bounding_box())) { return new Line[0]; } Side start_point_side = start_point().side_of(p_other.middle); Side end_point_side = end_point().side_of(p_other.middle); - if (start_point_side == Side.COLLINEAR && end_point_side == Side.COLLINEAR) - { + if (start_point_side == Side.COLLINEAR && end_point_side == Side.COLLINEAR) { // there may be an overlap LineSegment this_sorted = this.sort_endpoints_in_x_y(); LineSegment other_sorted = p_other.sort_endpoints_in_x_y(); LineSegment left_line; LineSegment right_line; - if (this_sorted.start_point().compare_x_y(other_sorted.start_point()) <= 0) - { + if (this_sorted.start_point().compare_x_y(other_sorted.start_point()) <= 0) { left_line = this_sorted; right_line = other_sorted; - } - else - { + } else { left_line = other_sorted; right_line = this_sorted; } int cmp = left_line.end_point().compare_x_y(right_line.start_point()); - if (cmp < 0) - { + if (cmp < 0) { // end point of the left line is to the lsft of the start point of the right line return new Line[0]; } - if (cmp == 0) - { + if (cmp == 0) { // end point of the left line is equal to the start point of the right line Line[] result = new Line[1]; result[0] = left_line.end; @@ -361,19 +315,15 @@ public Line[] intersection(LineSegment p_other) // now there is a real overlap Line[] result = new Line[2]; result[0] = right_line.start; - if (right_line.end_point().compare_x_y(left_line.end_point()) >= 0) - { + if (right_line.end_point().compare_x_y(left_line.end_point()) >= 0) { result[1] = left_line.end; - } - else - { + } else { result[1] = right_line.end; } return result; } if (start_point_side == end_point_side || - p_other.start_point().side_of(this.middle) == p_other.end_point().side_of(this.middle)) - { + p_other.start_point().side_of(this.middle) == p_other.end_point().side_of(this.middle)) { return new Line[0]; // no intersection possible } // now both start points and both end points are on different sides of the middle @@ -386,8 +336,7 @@ public Line[] intersection(LineSegment p_other) /** * Checks if this LineSegment and p_other contain a commen point */ - public boolean intersects(LineSegment p_other) - { + public boolean intersects(LineSegment p_other) { Line[] intersections = this.intersection(p_other); return intersections.length > 0; } @@ -396,29 +345,25 @@ public boolean intersects(LineSegment p_other) * Checks if this LineSegment and p_other contain a common LineSegment, * which is not reduced to a point. */ - public boolean overlaps(LineSegment p_other) - { + public boolean overlaps(LineSegment p_other) { Line[] intersections = this.intersection(p_other); return intersections.length > 1; } /** * Constructs an approximation of this line segment by orthogonal stairs with integer coordinates. - * The length of the stairs will be at most p_stair_width. - * If p_to_the_right, the stairs will be to the right of this line segment, else to the left. + * The length of the stairs will be at most p_stair_width. + * If p_to_the_right, the stairs will be to the right of this line segment, else to the left. */ - public IntPoint[] stair_approximation(double p_width, boolean p_to_the_right) - { + public IntPoint[] stair_approximation(double p_width, boolean p_to_the_right) { IntPoint start_point = this.start_point().to_float().round(); IntPoint end_point = this.end_point().to_float().round(); - if (start_point.equals(end_point)) - { + if (start_point.equals(end_point)) { return new IntPoint[0]; } - if (start_point.x == end_point.x || start_point.y == end_point.y) - { + if (start_point.x == end_point.x || start_point.y == end_point.y) { IntPoint[] result = new IntPoint[2]; result[0] = start_point; result[1] = end_point; @@ -436,21 +381,16 @@ public IntPoint[] stair_approximation(double p_width, boolean p_to_the_right) int stair_count; - if (function_of_x) - { + if (function_of_x) { stair_width = (int) Math.round(((p_width * (double) abs_dx) / (double) abs_dy)); stair_count = (abs_dx - 1) / stair_width + 1; - if (end_point.x < start_point.x) - { + if (end_point.x < start_point.x) { stair_width = -stair_width; } - } - else - { + } else { stair_width = (int) Math.round((p_width * (double) abs_dy) / (double) abs_dx); stair_count = (abs_dy - 1) / stair_width + 1; - if (end_point.y < start_point.y) - { + if (end_point.y < start_point.y) { stair_width = -stair_width; } } @@ -463,27 +403,20 @@ public IntPoint[] stair_approximation(double p_width, boolean p_to_the_right) int prev_line_point_x = start_point.x; int prev_line_point_y = start_point.y; - for (int i = 1; i < stair_count; ++i) - { + for (int i = 1; i < stair_count; ++i) { int curr_line_point_x; int curr_line_point_y; - if (function_of_x) - { + if (function_of_x) { curr_line_point_x = start_point.x + i * stair_width; curr_line_point_y = (int) Math.round(this.get_line().function_value_approx(curr_line_point_x)); - } - else - { + } else { curr_line_point_y = start_point.y + i * stair_width; curr_line_point_x = (int) Math.round(this.get_line().function_in_y_value_approx(curr_line_point_y)); } ++curr_index; - if (change_x_first) - { + if (change_x_first) { result[curr_index] = new IntPoint(curr_line_point_x, prev_line_point_y); - } - else - { + } else { result[curr_index] = new IntPoint(prev_line_point_x, curr_line_point_y); } ++curr_index; @@ -492,12 +425,9 @@ public IntPoint[] stair_approximation(double p_width, boolean p_to_the_right) prev_line_point_y = curr_line_point_y; } ++curr_index; - if (change_x_first) - { + if (change_x_first) { result[curr_index] = new IntPoint(end_point.x, prev_line_point_y); - } - else - { + } else { result[curr_index] = new IntPoint(prev_line_point_x, end_point.y); } ++curr_index; @@ -507,21 +437,18 @@ public IntPoint[] stair_approximation(double p_width, boolean p_to_the_right) /** * Constructs an approximation of this line segment by 45 degree stairs with integer coordinates. - * The length of the stairs will be at most p_stair_width. - * If p_to_the_right, the stairs will be to the right of this line segment, else to the left. + * The length of the stairs will be at most p_stair_width. + * If p_to_the_right, the stairs will be to the right of this line segment, else to the left. */ - public IntPoint[] stair_approximation_45(double p_width, boolean p_to_the_right) - { + public IntPoint[] stair_approximation_45(double p_width, boolean p_to_the_right) { IntPoint start_point = this.start_point().to_float().round(); IntPoint end_point = this.end_point().to_float().round(); - if (start_point.equals(end_point)) - { + if (start_point.equals(end_point)) { return new IntPoint[0]; } IntVector delta = end_point.difference_by(start_point); - if (delta.is_multiple_of_45_degree()) - { + if (delta.is_multiple_of_45_degree()) { IntPoint[] result = new IntPoint[2]; result[0] = start_point; result[1] = end_point; @@ -533,21 +460,16 @@ public IntPoint[] stair_approximation_45(double p_width, boolean p_to_the_right) double det = (double) delta.x * (double) delta.y; int stair_width; int stair_count; - if (function_of_x) - { + if (function_of_x) { stair_width = (int) Math.round((p_width * (double) abs_delta.x) / (double) abs_delta.y); stair_count = (abs_delta.x - 1) / stair_width + 1; - if (end_point.x < start_point.x) - { + if (end_point.x < start_point.x) { stair_width = -stair_width; } - } - else - { + } else { stair_width = (int) Math.round((p_width * (double) abs_delta.y) / (double) abs_delta.x); stair_count = (abs_delta.y - 1) / stair_width + 1; - if (end_point.y < start_point.y) - { + if (end_point.y < start_point.y) { stair_width = -stair_width; } @@ -556,64 +478,50 @@ public IntPoint[] stair_approximation_45(double p_width, boolean p_to_the_right) result[0] = start_point; IntPoint prev_line_point = start_point; int curr_index = 0; - for (int i = 1; i <= stair_count; ++i) - { + for (int i = 1; i <= stair_count; ++i) { IntPoint curr_line_point; int curr_x; int curr_y; - if (i == stair_count) - { + if (i == stair_count) { curr_line_point = end_point; - } - else - { - if (function_of_x) - { + } else { + if (function_of_x) { curr_x = start_point.x + i * stair_width; curr_y = (int) Math.round(this.get_line().function_value_approx(curr_x)); - } - else - { + } else { curr_y = start_point.y + i * stair_width; curr_x = (int) Math.round(this.get_line().function_value_approx(curr_y)); } curr_line_point = new IntPoint(curr_x, curr_y); } - if (function_of_x) - { + if (function_of_x) { boolean diagonal_first = p_to_the_right && det < 0 || !p_to_the_right && det > 0; - if (diagonal_first) - { + if (diagonal_first) { curr_x = prev_line_point.x + Signum.as_int(stair_width) * Math.abs(curr_line_point.y - prev_line_point.y); curr_y = curr_line_point.y; - } - else + } else // horizontal first { curr_x = curr_line_point.x - Signum.as_int(stair_width) * Math.abs(curr_line_point.y - prev_line_point.y); curr_y = prev_line_point.y; } - } - else + } else // function of y { - boolean diagonal_first = p_to_the_right && det > 0 || !p_to_the_right && det < 0; + boolean diagonal_first = p_to_the_right && det > 0 || !p_to_the_right && det < 0; - if (diagonal_first) - { + if (diagonal_first) { curr_x = curr_line_point.x; curr_y = prev_line_point.y + Signum.as_int(stair_width) * Math.abs(curr_line_point.x - prev_line_point.x); - } - else - { + } else { curr_x = prev_line_point.x; curr_y = curr_line_point.y - Signum.as_int(stair_width) * Math.abs(curr_line_point.x - prev_line_point.x); } } ++curr_index; - result[curr_index] = new IntPoint (curr_x, curr_y); + result[curr_index] = new IntPoint(curr_x, curr_y); ++curr_index; result[curr_index] = curr_line_point; prev_line_point = curr_line_point; @@ -630,11 +538,9 @@ public IntPoint[] stair_approximation_45(double p_width, boolean p_to_the_right) * With 2 intersections the intersection which is nearest to the start * point of the line segment comes first. */ - public int[] border_intersections(TileShape p_shape) - { + public int[] border_intersections(TileShape p_shape) { int[] empty_result = new int[0]; - if (!this.bounding_box().intersects(p_shape.bounding_box())) - { + if (!this.bounding_box().intersects(p_shape.bounding_box())) { return empty_result; } @@ -648,87 +554,69 @@ public int[] border_intersections(TileShape p_shape) Point line_end = this.end_point(); for (int edge_line_no = 0; edge_line_no < - edge_count; ++edge_line_no) - { + edge_count; ++edge_line_no) { Line next_line; - if (edge_line_no == edge_count - 1) - { + if (edge_line_no == edge_count - 1) { next_line = p_shape.border_line(0); - } - else - { + } else { next_line = p_shape.border_line(edge_line_no + 1); } Side start_point_side = curr_line.side_of(line_start); Side end_point_side = curr_line.side_of(line_end); if (start_point_side == Side.ON_THE_LEFT && - end_point_side == Side.ON_THE_LEFT) - { + end_point_side == Side.ON_THE_LEFT) { // both endpoints are outside the border_line, // no intersection possible return empty_result; } - if (start_point_side == Side.COLLINEAR) - { + if (start_point_side == Side.COLLINEAR) { // the start is on curr_line, check that the end point is inside // the halfplane, because touches count only, if the interiour // is entered - if (end_point_side != Side.ON_THE_RIGHT) - { + if (end_point_side != Side.ON_THE_RIGHT) { return empty_result; } } - if (end_point_side == Side.COLLINEAR) - { + if (end_point_side == Side.COLLINEAR) { // the end is on curr_line, check that the start point is inside // the halfplane, because touches count only, if the interiour // is entered - if (start_point_side != Side.ON_THE_RIGHT) - { + if (start_point_side != Side.ON_THE_RIGHT) { return empty_result; } } if (start_point_side != Side.ON_THE_RIGHT || - end_point_side != Side.ON_THE_RIGHT) - { + end_point_side != Side.ON_THE_RIGHT) { // not both points are inside the halplane defined by curr_line Point is = this.middle.intersection(curr_line); Side prev_line_side_of_is = prev_line.side_of(is); Side next_line_side_of_is = next_line.side_of(is); if (prev_line_side_of_is != Side.ON_THE_LEFT && - next_line_side_of_is != Side.ON_THE_LEFT) - { + next_line_side_of_is != Side.ON_THE_LEFT) { // this line segment intersects curr_line between the // previous and the next corner of p_simplex - if (prev_line_side_of_is == Side.COLLINEAR) - { + if (prev_line_side_of_is == Side.COLLINEAR) { // this line segment goes through the previous // corner of p_simplex. Check, that the intersection // isn't merely a touch. Point prev_prev_corner; - if (edge_line_no == 0) - { + if (edge_line_no == 0) { prev_prev_corner = p_shape.corner(edge_count - 1); - } - else - { + } else { prev_prev_corner = p_shape.corner(edge_line_no - 1); } Point next_corner; - if (edge_line_no == edge_count - 1) - { + if (edge_line_no == edge_count - 1) { next_corner = p_shape.corner(0); - } - else - { + } else { next_corner = p_shape.corner(edge_line_no + 1); } // check, that prev_prev_corner and next_corner @@ -739,30 +627,23 @@ public int[] border_intersections(TileShape p_shape) this.middle.side_of(next_corner); if (prev_prev_corner_side == Side.COLLINEAR || next_corner_side == Side.COLLINEAR || - prev_prev_corner_side == next_corner_side) - { + prev_prev_corner_side == next_corner_side) { return empty_result; } } - if (next_line_side_of_is == Side.COLLINEAR) - { + if (next_line_side_of_is == Side.COLLINEAR) { // this line segment goes through the next // corner of p_simplex. Check, that the intersection // isn't merely a touch. Point prev_corner = p_shape.corner(edge_line_no); Point next_next_corner; - if (edge_line_no == edge_count - 2) - { + if (edge_line_no == edge_count - 2) { next_next_corner = p_shape.corner(0); - } - else if (edge_line_no == edge_count - 1) - { + } else if (edge_line_no == edge_count - 1) { next_next_corner = p_shape.corner(1); - } - else - { + } else { next_next_corner = p_shape.corner(edge_line_no + 2); } // check, that prev_corner and next_next_corner @@ -773,38 +654,29 @@ else if (edge_line_no == edge_count - 1) this.middle.side_of(next_next_corner); if (prev_corner_side == Side.COLLINEAR || next_next_corner_side == Side.COLLINEAR || - prev_corner_side == next_next_corner_side) - { + prev_corner_side == next_next_corner_side) { return empty_result; } } boolean intersection_already_handeled = false; for (int i = 0; i < - intersection_count; ++i) - { - if (is.equals(intersection[i])) - { + intersection_count; ++i) { + if (is.equals(intersection[i])) { intersection_already_handeled = true; break; } - - } - if (!intersection_already_handeled) - { - if (intersection_count < result.length) - { + if (!intersection_already_handeled) { + if (intersection_count < result.length) { // a new intersection is found result[intersection_count] = edge_line_no; intersection[intersection_count] = is; ++intersection_count; - } - else - { + } else { System.out.println("border_intersections: intersection_count to big!"); } @@ -817,13 +689,11 @@ else if (edge_line_no == edge_count - 1) next_line; } - if (intersection_count == 0) - { + if (intersection_count == 0) { return empty_result; } - if (intersection_count == 2) - { + if (intersection_count == 2) { // assure the correct order FloatPoint is0 = intersection[0].to_float(); FloatPoint is1 = intersection[1].to_float(); @@ -839,8 +709,7 @@ else if (edge_line_no == edge_count - 1) return result; } - if (intersection_count != 1) - { + if (intersection_count != 1) { System.out.println( "LineSegment.border_intersections: intersection_count 1 expected"); } @@ -854,27 +723,18 @@ else if (edge_line_no == edge_count - 1) * Inverts the direction of this.middle, if start_point() has a bigger * x coordinate than end_point(), or an equal x coordinate and a bigger y coordinate. */ - public LineSegment sort_endpoints_in_x_y() - { + public LineSegment sort_endpoints_in_x_y() { boolean swap_endlines = (start_point().compare_x_y(end_point()) > 0); LineSegment result; - if (swap_endlines) - { + if (swap_endlines) { result = new LineSegment(this.end, this.middle, this.start); result.precalculated_start_point = this.precalculated_end_point; result.precalculated_end_point = this.precalculated_start_point; - } - else - { + } else { result = this; } return result; } - private final Line start; - private final Line middle; - private final Line end; - transient private Point precalculated_start_point = null; - transient private Point precalculated_end_point = null; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/OrthogonalBoundingDirections.java b/src/main/java/net/freerouting/geometry/planar/OrthogonalBoundingDirections.java index dd3c7575..f835d874 100644 --- a/src/main/java/net/freerouting/geometry/planar/OrthogonalBoundingDirections.java +++ b/src/main/java/net/freerouting/geometry/planar/OrthogonalBoundingDirections.java @@ -17,61 +17,50 @@ package net.freerouting.geometry.planar; /** - * * Implements the abstract class ShapeDirections as * the 4 orthogonal directions. * The class is a singleton with the only instanciation INSTANCE. * - * @author Alfons Wirtz */ -public class OrthogonalBoundingDirections implements ShapeBoundingDirections -{ +public class OrthogonalBoundingDirections implements ShapeBoundingDirections { /** * the one and only instantiation */ public static final OrthogonalBoundingDirections - INSTANCE = new OrthogonalBoundingDirections(); + INSTANCE = new OrthogonalBoundingDirections(); + + /** + * prevent instantiation + */ + private OrthogonalBoundingDirections() { + } - public int count() - { + public int count() { return 4; } - public RegularTileShape bounds (ConvexShape p_shape) - { + public RegularTileShape bounds(ConvexShape p_shape) { return p_shape.bounding_shape(this); } - public RegularTileShape bounds (IntBox p_box) - { + public RegularTileShape bounds(IntBox p_box) { return p_box; } - - public RegularTileShape bounds (IntOctagon p_oct) - { + + public RegularTileShape bounds(IntOctagon p_oct) { return p_oct.bounding_box(); } - public RegularTileShape bounds (Simplex p_simplex) - { + public RegularTileShape bounds(Simplex p_simplex) { return p_simplex.bounding_box(); } - - public RegularTileShape bounds (Circle p_circle) - { + + public RegularTileShape bounds(Circle p_circle) { return p_circle.bounding_box(); } - - public RegularTileShape bounds (PolygonShape p_polygon) - { - return p_polygon.bounding_box(); - } - /** - * prevent instantiation - */ - private OrthogonalBoundingDirections() - { + public RegularTileShape bounds(PolygonShape p_polygon) { + return p_polygon.bounding_box(); } } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/Point.java b/src/main/java/net/freerouting/geometry/planar/Point.java index e6f4eb1c..4394e98b 100644 --- a/src/main/java/net/freerouting/geometry/planar/Point.java +++ b/src/main/java/net/freerouting/geometry/planar/Point.java @@ -28,212 +28,194 @@ * @author Alfons Wirtz */ -public abstract class Point implements java.io.Serializable -{ - - /** - * returns the translation of this point by p_vector - */ - public abstract Point translate_by(Vector p_vector ); - - /** - * returns the difference vector of this point and p_other - */ - public abstract Vector difference_by(Point p_other); - - - /** - * approximates the coordinates of this point by float coordinates - */ - public abstract FloatPoint to_float(); - - /** - * returns true, if this Point is a RationalPoint with denominator z = 0. - */ - public abstract boolean is_infinite(); - - /** - * creates the smallest Box with integer coordinates containing this point. - */ - public abstract IntBox surrounding_box(); - - - /** - * creates the smallest Octagon with integer coordinates containing this point. - */ - public abstract IntOctagon surrounding_octagon(); - - /** - * Returns true, if this point lies in the interiour or on the border - * of p_box. - */ - public abstract boolean is_contained_in( IntBox p_box); - - - public abstract Side side_of(Line p_line); - - /** - * returns the nearest point to this point on p_line - */ - public abstract Point perpendicular_projection(Line p_line); - +public abstract class Point implements java.io.Serializable { + /** * Standard implementation of the zero point . */ public static final IntPoint ZERO = new IntPoint(0, 0); - + /** * creates an IntPoint from p_x and p_y. If p_x or p_y is to big for * an IntPoint, a RationalPoint is created. */ - public static Point get_instance(int p_x, int p_y) - { + public static Point get_instance(int p_x, int p_y) { IntPoint result = new IntPoint(p_x, p_y); - if ( Math.abs(p_x) > Limits.CRIT_INT || - Math.abs(p_x) > Limits.CRIT_INT ) - { + if (Math.abs(p_x) > Limits.CRIT_INT || + Math.abs(p_x) > Limits.CRIT_INT) { return new RationalPoint(result); } return result; } - + /** * factory method for creating a Point from 3 BigIntegers */ public static Point get_instance(BigInteger p_x, BigInteger p_y, - BigInteger p_z) - { - if (p_z.signum() < 0) - { + BigInteger p_z) { + if (p_z.signum() < 0) { // the dominator z of a RationalPoint is expected to be positive p_x = p_x.negate(); p_y = p_y.negate(); p_z = p_z.negate(); - + } - if ((p_x.mod(p_z)).signum() == 0 && (p_x.mod(p_z)).signum() == 0) - { + if ((p_x.mod(p_z)).signum() == 0 && (p_x.mod(p_z)).signum() == 0) { // p_x and p_y can be divided by p_z p_x = p_x.divide(p_z); p_y = p_y.divide(p_z); p_z = BigInteger.ONE; } - if (p_z.equals(BigInteger.ONE)) - { - if ( (p_x.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0 && - (p_y.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0 ) - { + if (p_z.equals(BigInteger.ONE)) { + if ((p_x.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0 && + (p_y.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0) { // the Point fits into an IntPoint return new IntPoint(p_x.intValue(), p_y.intValue()); } } return new RationalPoint(p_x, p_y, p_z); } - + + /** + * returns the translation of this point by p_vector + */ + public abstract Point translate_by(Vector p_vector); + + /** + * returns the difference vector of this point and p_other + */ + public abstract Vector difference_by(Point p_other); + + /** + * approximates the coordinates of this point by float coordinates + */ + public abstract FloatPoint to_float(); + + /** + * returns true, if this Point is a RationalPoint with denominator z = 0. + */ + public abstract boolean is_infinite(); + + /** + * creates the smallest Box with integer coordinates containing this point. + */ + public abstract IntBox surrounding_box(); + + /** + * creates the smallest Octagon with integer coordinates containing this point. + */ + public abstract IntOctagon surrounding_octagon(); + + /** + * Returns true, if this point lies in the interiour or on the border + * of p_box. + */ + public abstract boolean is_contained_in(IntBox p_box); + + public abstract Side side_of(Line p_line); + + /** + * returns the nearest point to this point on p_line + */ + public abstract Point perpendicular_projection(Line p_line); + /** * The function returns - * Side.ON_THE_LEFT, if this Point is on the left of the line from p_1 to p_2; - * Side.ON_THE_RIGHT, if this Point is on the right of the line from p_1 to p_2; - * and Side.COLLINEAR, if this Point is collinear with p_1 and p_2. + * Side.ON_THE_LEFT, if this Point is on the left of the line from p_1 to p_2; + * Side.ON_THE_RIGHT, if this Point is on the right of the line from p_1 to p_2; + * and Side.COLLINEAR, if this Point is collinear with p_1 and p_2. */ - public Side side_of(Point p_1, Point p_2) - { + public Side side_of(Point p_1, Point p_2) { Vector v1 = difference_by(p_1); Vector v2 = p_2.difference_by(p_1); return v1.side_of(v2); } - + /** * Calculates the perpendicular direction froma this point * to p_line. Returns Direction.NULL, if this point lies on p_line. */ - public Direction perpendicular_direction(Line p_line) - { + public Direction perpendicular_direction(Line p_line) { Side side = this.side_of(p_line); - if (side == Side.COLLINEAR) - { + if (side == Side.COLLINEAR) { return Direction.NULL; } Direction result; - if (side == Side.ON_THE_RIGHT) - { + if (side == Side.ON_THE_RIGHT) { result = p_line.direction().turn_45_degree(2); - } - else - { + } else { result = p_line.direction().turn_45_degree(6); } return result; } - + /** * Returns 1, if this Point has a strict bigger x coordinate than p_other, * 0, if the x cooordinates are equal, and -1 otherwise. */ public abstract int compare_x(Point p_other); - + /** * Returns 1, if this Point has a strict bigger y coordinate than p_other, * 0, if the y cooordinates are equal, and -1 otherwise. */ public abstract int compare_y(Point p_other); - + /** * The function returns compare_x (p_other), if the result is not 0. * Otherwise it returns compare_y (p_other). */ - public int compare_x_y(Point p_other) - { + public int compare_x_y(Point p_other) { int result = compare_x(p_other); - if (result == 0) - { + if (result == 0) { result = compare_y(p_other); } return result; } - + /** * Turns this point by p_factor times 90 degree around p_pole. */ - public Point turn_90_degree(int p_factor, Point p_pole) - { + public Point turn_90_degree(int p_factor, Point p_pole) { Vector v = this.difference_by(p_pole); v = v.turn_90_degree(p_factor); return p_pole.translate_by(v); } - + /** * Mirrors this point at the vertical line through p_pole. */ - public Point mirror_vertical(Point p_pole) - { + public Point mirror_vertical(Point p_pole) { Vector v = this.difference_by(p_pole); - v = v. mirror_at_y_axis(); + v = v.mirror_at_y_axis(); return p_pole.translate_by(v); } - + /** * Mirrors this point at the horizontal line through p_pole. */ - public Point mirror_horizontal(Point p_pole) - { + public Point mirror_horizontal(Point p_pole) { Vector v = this.difference_by(p_pole); - v = v. mirror_at_x_axis(); + v = v.mirror_at_x_axis(); return p_pole.translate_by(v); - } - + } + // auxiliary functions needed because the virtual function mechanism // does not work in parameter position - - abstract Point translate_by(IntVector p_vector ); - abstract Point translate_by(RationalVector p_vector ); - + + abstract Point translate_by(IntVector p_vector); + + abstract Point translate_by(RationalVector p_vector); + abstract Vector difference_by(IntPoint p_other); + abstract Vector difference_by(RationalPoint p_other); - + abstract int compare_x(IntPoint p_other); + abstract int compare_x(RationalPoint p_other); - + abstract int compare_y(IntPoint p_other); + abstract int compare_y(RationalPoint p_other); } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/Polygon.java b/src/main/java/net/freerouting/geometry/planar/Polygon.java index ee6e586f..0c6b7ab6 100644 --- a/src/main/java/net/freerouting/geometry/planar/Polygon.java +++ b/src/main/java/net/freerouting/geometry/planar/Polygon.java @@ -21,7 +21,6 @@ import java.util.LinkedList; /** - * * A Polygon is a list of points in the plane, where no 2 consecutive * points may be equal and no 3 consecutive points collinear. * @@ -29,49 +28,41 @@ */ -public class Polygon implements java.io.Serializable -{ +public class Polygon implements java.io.Serializable { + private final Collection corners; + /** * Creates a polygon from p_point_arr. * Multiple points and points, which are collinear with its previous * and next point will be removed. */ - public Polygon(Point [] p_point_arr) - { + public Polygon(Point[] p_point_arr) { corners = new LinkedList(); - if (p_point_arr.length == 0) - { + if (p_point_arr.length == 0) { return; } - for (int i = 0; i < p_point_arr.length; ++i) - { + for (int i = 0; i < p_point_arr.length; ++i) { corners.add(p_point_arr[i]); } boolean corner_removed = true; - while (corner_removed) - { + while (corner_removed) { corner_removed = false; // remove multiple points - if (corners.isEmpty()) - { - return; + if (corners.isEmpty()) { + return; } Iterator i = corners.iterator(); Point curr_ob = i.next(); - while(i.hasNext()) - { - Point next_ob = i.next(); - if(next_ob.equals(curr_ob)) - { - i.remove(); - corner_removed = true; - } - else - { - curr_ob = next_ob; - } + while (i.hasNext()) { + Point next_ob = i.next(); + if (next_ob.equals(curr_ob)) { + i.remove(); + corner_removed = true; + } else { + curr_ob = next_ob; + } } // remove points which are collinear with the previous @@ -79,25 +70,22 @@ public Polygon(Point [] p_point_arr) i = corners.iterator(); Point prev = i.next(); Iterator prev_i = corners.iterator(); - if (!i.hasNext()) - { - continue; + if (!i.hasNext()) { + continue; } - Point curr = i.next(); + Point curr = i.next(); prev_i.next(); - while(i.hasNext()) - { + while (i.hasNext()) { Point next = i.next(); - prev_i.next(); + prev_i.next(); - if(curr.side_of(prev, next) == Side.COLLINEAR) - { - prev_i.remove(); - corner_removed = true; - break; - } - prev = curr; - curr = next; + if (curr.side_of(prev, next) == Side.COLLINEAR) { + prev_i.remove(); + corner_removed = true; + break; + } + prev = curr; + curr = next; } } } @@ -105,77 +93,62 @@ public Polygon(Point [] p_point_arr) /** * returns the array of corners of this polygon */ - public Point[] corner_array() - { + public Point[] corner_array() { int corner_count = corners.size(); Point[] result = new Point[corner_count]; Iterator it = corners.iterator(); - for (int i = 0; i < corner_count; ++i) - { + for (int i = 0; i < corner_count; ++i) { result[i] = it.next(); } return result; } - - /** + + /** * Reverts the order of the corners of this polygon. */ - public Polygon revert_corners() - { - Point [] corner_arr = corner_array(); - Point [] reverse_corner_arr = new Point[corner_arr.length]; - for (int i = 0; i < corner_arr.length; ++i) - { - reverse_corner_arr[i] = corner_arr [corner_arr.length - i - 1]; + public Polygon revert_corners() { + Point[] corner_arr = corner_array(); + Point[] reverse_corner_arr = new Point[corner_arr.length]; + for (int i = 0; i < corner_arr.length; ++i) { + reverse_corner_arr[i] = corner_arr[corner_arr.length - i - 1]; } return new Polygon(reverse_corner_arr); } + /** * Returns the winding number of this polygon, treated as closed. * It will be > 0, if the corners are in countercock sense, * and < 0, if the corners are in clockwise sense. */ - public int winding_number_after_closing() - { - Point [] corner_arr = corner_array(); - if (corner_arr.length < 2) - { + public int winding_number_after_closing() { + Point[] corner_arr = corner_array(); + if (corner_arr.length < 2) { return 0; } Vector first_side_vector = corner_arr[1].difference_by(corner_arr[0]); Vector prev_side_vector = first_side_vector; int corner_count = corner_arr.length; // Skip the last corner, if it is equal to the first corner. - if (corner_arr[0].equals(corner_arr[corner_count - 1])) - { + if (corner_arr[0].equals(corner_arr[corner_count - 1])) { --corner_count; } double angle_sum = 0; - for (int i = 1; i <= corner_count; ++i) - { + for (int i = 1; i <= corner_count; ++i) { Vector next_side_vector; - if (i == corner_count - 1) - { + if (i == corner_count - 1) { next_side_vector = corner_arr[0].difference_by(corner_arr[i]); - } - else if (i == corner_count) - { + } else if (i == corner_count) { next_side_vector = first_side_vector; + } else { + next_side_vector = corner_arr[i + 1].difference_by(corner_arr[i]); } - else - { - next_side_vector = corner_arr[i + 1].difference_by(corner_arr[i]); - } - angle_sum += prev_side_vector.angle_approx(next_side_vector); + angle_sum += prev_side_vector.angle_approx(next_side_vector); prev_side_vector = next_side_vector; } angle_sum /= 2.0 * Math.PI; - if (Math.abs(angle_sum) < 0.5) - { - System.out.println ("Polygon.winding_number_after_closing: winding number != 0 expected"); + if (Math.abs(angle_sum) < 0.5) { + System.out.println("Polygon.winding_number_after_closing: winding number != 0 expected"); } return (int) Math.round(angle_sum); } - - private final Collection corners; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/PolygonShape.java b/src/main/java/net/freerouting/geometry/planar/PolygonShape.java index 679ddf48..637184df 100644 --- a/src/main/java/net/freerouting/geometry/planar/PolygonShape.java +++ b/src/main/java/net/freerouting/geometry/planar/PolygonShape.java @@ -30,285 +30,247 @@ * The corners are normalysed, so that the corner with the lowest y-value comes first. * In case of equal y-value the corner with the lowest x-value comes first. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class PolygonShape extends PolylineShape -{ - - /** Creates a new instance of PolygonShape */ - public PolygonShape(Polygon p_polygon) - { +public class PolygonShape extends PolylineShape { + + static private int seed = 99; + static private java.util.Random random_generator = new java.util.Random(seed); + public final Point[] corners; + /** + * the following fields are for storing precalculated data + */ + transient private IntBox precalculated_bounding_box = null; + transient private IntOctagon precalculated_bounding_octagon = null; + transient private TileShape[] precalculated_convex_pieces = null; + + /** + * Creates a new instance of PolygonShape + */ + public PolygonShape(Polygon p_polygon) { Polygon curr_polygon = p_polygon; - if (p_polygon.winding_number_after_closing() < 0) - { + if (p_polygon.winding_number_after_closing() < 0) { // the the corners of the polygon are in clockwise sense curr_polygon = p_polygon.revert_corners(); } - Point [] curr_corners = curr_polygon.corner_array(); + Point[] curr_corners = curr_polygon.corner_array(); int last_corner_no = curr_corners.length - 1; - - if (last_corner_no > 0) - { - if (curr_corners[0].equals(curr_corners[last_corner_no])) - { + + if (last_corner_no > 0) { + if (curr_corners[0].equals(curr_corners[last_corner_no])) { // skip last point --last_corner_no; } } - + boolean last_point_collinear = false; - - if (last_corner_no >= 2) - { + + if (last_corner_no >= 2) { last_point_collinear = curr_corners[last_corner_no].side_of(curr_corners[last_corner_no - 1], curr_corners[0]) - == Side.COLLINEAR; + == Side.COLLINEAR; } - if (last_point_collinear) - { + if (last_point_collinear) { // skip last point --last_corner_no; } - + int first_corner_no = 0; boolean first_point_collinear = false; - - if (last_corner_no - first_corner_no >= 2) - { + + if (last_corner_no - first_corner_no >= 2) { first_point_collinear = curr_corners[0].side_of(curr_corners[1], curr_corners[last_corner_no]) - == Side.COLLINEAR; + == Side.COLLINEAR; } - - if (first_point_collinear) - { + + if (first_point_collinear) { // skip first point ++first_corner_no; } // search the point with the lowest y and then with the lowest x int start_corner_no = first_corner_no; FloatPoint start_corner = curr_corners[start_corner_no].to_float(); - for (int i = start_corner_no + 1; i <= last_corner_no; ++i) - { + for (int i = start_corner_no + 1; i <= last_corner_no; ++i) { FloatPoint curr_corner = curr_corners[i].to_float(); if (curr_corner.y < start_corner.y || - curr_corner.y == start_corner.y && curr_corner.x < start_corner.x) - { + curr_corner.y == start_corner.y && curr_corner.x < start_corner.x) { start_corner_no = i; start_corner = curr_corner; } } - int new_corner_count = last_corner_no - first_corner_no + 1; + int new_corner_count = last_corner_no - first_corner_no + 1; Point[] result = new Point[new_corner_count]; int curr_corner_no = 0; - for (int i = start_corner_no; i <= last_corner_no; ++i) - { + for (int i = start_corner_no; i <= last_corner_no; ++i) { result[curr_corner_no] = curr_corners[i]; ++curr_corner_no; } - for (int i = first_corner_no; i < start_corner_no; ++i) - { + for (int i = first_corner_no; i < start_corner_no; ++i) { result[curr_corner_no] = curr_corners[i]; ++curr_corner_no; } corners = result; } - - - public PolygonShape(Point[] p_corner_arr) - { + + public PolygonShape(Point[] p_corner_arr) { this(new Polygon(p_corner_arr)); } - - - public Point corner(int p_no) - { - if (p_no < 0 || p_no >= corners.length) - { + + public Point corner(int p_no) { + if (p_no < 0 || p_no >= corners.length) { System.out.println("PolygonShape.corner: p_no out of range"); return null; } return corners[p_no]; } - - public int border_line_count() - { + + public int border_line_count() { return corners.length; } - - public boolean corner_is_bounded(int p_no) - { + + public boolean corner_is_bounded(int p_no) { return true; } - - public boolean intersects(Shape p_shape) - { + + public boolean intersects(Shape p_shape) { return p_shape.intersects(this); } - - public boolean intersects(Circle p_circle) - { + + public boolean intersects(Circle p_circle) { TileShape[] convex_pieces = split_to_convex(); - for (int i = 0; i < convex_pieces.length; ++i) - { + for (int i = 0; i < convex_pieces.length; ++i) { if (convex_pieces[i].intersects(p_circle)) return true; } return false; } - - public boolean intersects(Simplex p_simplex) - { + + public boolean intersects(Simplex p_simplex) { TileShape[] convex_pieces = split_to_convex(); - for (int i = 0; i < convex_pieces.length; ++i) - { + for (int i = 0; i < convex_pieces.length; ++i) { if (convex_pieces[i].intersects(p_simplex)) return true; } return false; } - - public boolean intersects(IntOctagon p_oct) - { + + public boolean intersects(IntOctagon p_oct) { TileShape[] convex_pieces = split_to_convex(); - for (int i = 0; i < convex_pieces.length; ++i) - { + for (int i = 0; i < convex_pieces.length; ++i) { if (convex_pieces[i].intersects(p_oct)) return true; } return false; } - - public boolean intersects(IntBox p_box) - { + + public boolean intersects(IntBox p_box) { TileShape[] convex_pieces = split_to_convex(); - for (int i = 0; i < convex_pieces.length; ++i) - { + for (int i = 0; i < convex_pieces.length; ++i) { if (convex_pieces[i].intersects(p_box)) return true; } return false; } - - public Polyline[] cutout(Polyline p_polyline) - { + + public Polyline[] cutout(Polyline p_polyline) { System.out.println("PolygonShape.cutout not yet implemented"); return null; } - - public PolygonShape enlarge(double p_offset) - { - if (p_offset == 0) - { + + public PolygonShape enlarge(double p_offset) { + if (p_offset == 0) { return this; } System.out.println("PolygonShape.enlarge not yet implemented"); return null; } - - public double border_distance(FloatPoint p_point) - { + + public double border_distance(FloatPoint p_point) { System.out.println("PolygonShape.border_distance not yet implemented"); return 0; } - - public double smallest_radius() - { + + public double smallest_radius() { return border_distance(centre_of_gravity()); } - - public boolean contains(FloatPoint p_point) - { + + public boolean contains(FloatPoint p_point) { TileShape[] convex_pieces = split_to_convex(); - for (int i = 0; i < convex_pieces.length; ++i) - { + for (int i = 0; i < convex_pieces.length; ++i) { if (convex_pieces[i].contains(p_point)) return true; } return false; } - - public boolean contains_inside(Point p_point) - { - if (contains_on_border(p_point)) - { + + public boolean contains_inside(Point p_point) { + if (contains_on_border(p_point)) { return false; } return !is_outside(p_point); } - - public boolean is_outside(Point p_point) - { + + public boolean is_outside(Point p_point) { TileShape[] convex_pieces = split_to_convex(); - for (int i = 0; i < convex_pieces.length; ++i) - { + for (int i = 0; i < convex_pieces.length; ++i) { if (!convex_pieces[i].is_outside(p_point)) return false; } return true; } - - public boolean contains(Point p_point) - { + + public boolean contains(Point p_point) { return !is_outside(p_point); } - - public boolean contains_on_border(Point p_point) - { + + public boolean contains_on_border(Point p_point) { //System.out.println("PolygonShape.contains_on_edge not yet implemented"); return false; } - - public double distance(FloatPoint p_point) - { + + public double distance(FloatPoint p_point) { System.out.println("PolygonShape.distance not yet implemented"); return 0; } - public PolygonShape translate_by(Vector p_vector) - { - if (p_vector.equals(Vector.ZERO)) - { + + public PolygonShape translate_by(Vector p_vector) { + if (p_vector.equals(Vector.ZERO)) { return this; } Point[] new_corners = new Point[corners.length]; - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { new_corners[i] = corners[i].translate_by(p_vector); } return new PolygonShape(new_corners); } - - public RegularTileShape bounding_shape(ShapeBoundingDirections p_dirs) - { + + public RegularTileShape bounding_shape(ShapeBoundingDirections p_dirs) { return p_dirs.bounds(this); } - - public IntBox bounding_box() - { - if (precalculated_bounding_box == null) - { + + public IntBox bounding_box() { + if (precalculated_bounding_box == null) { double llx = Integer.MAX_VALUE; double lly = Integer.MAX_VALUE; double urx = Integer.MIN_VALUE; double ury = Integer.MIN_VALUE; - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { FloatPoint curr = corners[i].to_float(); llx = Math.min(llx, curr.x); lly = Math.min(lly, curr.y); urx = Math.max(urx, curr.x); ury = Math.max(ury, curr.y); } - IntPoint lower_left = new IntPoint((int)Math.floor(llx),(int)Math.floor(lly)); - IntPoint upper_right = new IntPoint((int)Math.ceil(urx),(int)Math.ceil(ury)); + IntPoint lower_left = new IntPoint((int) Math.floor(llx), (int) Math.floor(lly)); + IntPoint upper_right = new IntPoint((int) Math.ceil(urx), (int) Math.ceil(ury)); precalculated_bounding_box = new IntBox(lower_left, upper_right); } return precalculated_bounding_box; } - public IntOctagon bounding_octagon() - { - if (precalculated_bounding_octagon == null) - { + + public IntOctagon bounding_octagon() { + if (precalculated_bounding_octagon == null) { double lx = Integer.MAX_VALUE; double ly = Integer.MAX_VALUE; double rx = Integer.MIN_VALUE; @@ -317,45 +279,42 @@ public IntOctagon bounding_octagon() double lrx = Integer.MIN_VALUE; double llx = Integer.MAX_VALUE; double urx = Integer.MIN_VALUE; - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { FloatPoint curr = corners[i].to_float(); lx = Math.min(lx, curr.x); ly = Math.min(ly, curr.y); rx = Math.max(rx, curr.x); uy = Math.max(uy, curr.y); - + double tmp = curr.x - curr.y; ulx = Math.min(ulx, tmp); lrx = Math.max(lrx, tmp); - + tmp = curr.x + curr.y; llx = Math.min(llx, tmp); urx = Math.max(urx, tmp); } precalculated_bounding_octagon = new - IntOctagon((int)Math.floor(lx), (int)Math.floor(ly), - (int)Math.ceil(rx), (int)Math.ceil(uy), - (int)Math.floor(ulx), (int)Math.ceil(lrx), - (int)Math.floor(llx), (int)Math.ceil(urx)); + IntOctagon((int) Math.floor(lx), (int) Math.floor(ly), + (int) Math.ceil(rx), (int) Math.ceil(uy), + (int) Math.floor(ulx), (int) Math.ceil(lrx), + (int) Math.floor(llx), (int) Math.ceil(urx)); } return precalculated_bounding_octagon; } - + /** * Checks, if every line segment between 2 points of the shape is contained * completely in the shape. */ - public boolean is_comvex() - { + public boolean is_comvex() { if (corners.length <= 2) return true; Point prev_point = corners[corners.length - 1]; Point curr_point = corners[0]; Point next_point = corners[1]; - - for (int ind = 0; ind < corners.length; ++ind) - { + + for (int ind = 0; ind < corners.length; ++ind) { if (next_point.side_of(prev_point, curr_point) == Side.ON_THE_RIGHT) return false; prev_point = curr_point; @@ -366,53 +325,44 @@ public boolean is_comvex() next_point = corners[ind + 2]; } // check, if the sum of the interior angles is at most 2 * pi - + Line first_line = new Line(corners[corners.length - 1], corners[0]); Line curr_line = new Line(corners[0], corners[1]); - IntDirection first_direction = (IntDirection)first_line.direction(); - IntDirection curr_direction = (IntDirection)curr_line.direction(); + IntDirection first_direction = (IntDirection) first_line.direction(); + IntDirection curr_direction = (IntDirection) curr_line.direction(); double last_det = first_direction.determinant(curr_direction); - - for (int ind2 = 2; ind2 < corners.length; ++ind2) - { + + for (int ind2 = 2; ind2 < corners.length; ++ind2) { curr_line = new Line(curr_line.b, corners[ind2]); - curr_direction = (IntDirection)curr_line.direction(); + curr_direction = (IntDirection) curr_line.direction(); double curr_det = first_direction.determinant(curr_direction); if (last_det <= 0 && curr_det > 0) return false; last_det = curr_det; } - + return true; } - - public PolygonShape convex_hull() - { + + public PolygonShape convex_hull() { if (corners.length <= 2) return this; Point prev_point = corners[corners.length - 1]; Point curr_point = corners[0]; Point next_point; - for (int ind = 0; ind < corners.length; ++ind) - { - if (ind == corners.length - 1) - { + for (int ind = 0; ind < corners.length; ++ind) { + if (ind == corners.length - 1) { next_point = corners[0]; - } - else - { + } else { next_point = corners[ind + 1]; } - if (next_point.side_of(prev_point, curr_point) != Side.ON_THE_LEFT) - { + if (next_point.side_of(prev_point, curr_point) != Side.ON_THE_LEFT) { //skip curr_point; Point[] new_corners = new Point[corners.length - 1]; - for (int i = 0; i < ind; ++i) - { + for (int i = 0; i < ind; ++i) { new_corners[i] = corners[i]; } - for (int i = ind; i < new_corners.length; ++i) - { + for (int i = ind; i < new_corners.length; ++i) { new_corners[i] = corners[i + 1]; } PolygonShape result = new PolygonShape(new_corners); @@ -423,36 +373,31 @@ public PolygonShape convex_hull() } return this; } - - public TileShape bounding_tile() - { + + public TileShape bounding_tile() { PolygonShape hull = convex_hull(); Line[] bounding_lines = new Line[hull.corners.length]; - for (int i = 0; i < bounding_lines.length - 1; ++i) - { + for (int i = 0; i < bounding_lines.length - 1; ++i) { bounding_lines[i] = new Line(hull.corners[i], hull.corners[i + 1]); } bounding_lines[bounding_lines.length - 1] = new Line(hull.corners[hull.corners.length - 1], hull.corners[0]); return TileShape.get_instance(bounding_lines); } - - public double area() - { - - if (dimension() <= 2) - { + + public double area() { + + if (dimension() <= 2) { return 0; } // calculate half of the absolute value of // x0 (y1 - yn-1) + x1 (y2 - y0) + x2 (y3 - y1) + ...+ xn-1( y0 - yn-2) // where xi, yi are the coordinates of the i-th corner of this polygon. - + double result = 0; FloatPoint prev_corner = corners[corners.length - 2].to_float(); FloatPoint curr_corner = corners[corners.length - 1].to_float(); - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { FloatPoint next_corner = corners[i].to_float(); result += curr_corner.x * (next_corner.y - prev_corner.y); prev_corner = curr_corner; @@ -461,9 +406,8 @@ public double area() result = 0.5 * Math.abs(result); return result; } - - public int dimension() - { + + public int dimension() { if (corners.length == 0) return -1; if (corners.length == 1) @@ -472,155 +416,130 @@ public int dimension() return 1; return 2; } - - public boolean is_bounded() - { + + public boolean is_bounded() { return true; } - - public boolean is_empty() - { + + public boolean is_empty() { return corners.length == 0; } - - public Line border_line(int p_no) - { - if (p_no < 0 || p_no >= corners.length) - { + + public Line border_line(int p_no) { + if (p_no < 0 || p_no >= corners.length) { System.out.println("PolygonShape.edge_line: p_no out of range"); return null; } Point next_corner; - if (p_no == corners.length - 1) - { + if (p_no == corners.length - 1) { next_corner = corners[0]; - } - else - { + } else { next_corner = corners[p_no + 1]; } return new Line(corners[p_no], next_corner); } - - public FloatPoint nearest_point_approx(FloatPoint p_from_point) - { + + public FloatPoint nearest_point_approx(FloatPoint p_from_point) { double min_dist = Double.MAX_VALUE; FloatPoint result = null; TileShape[] convex_shapes = split_to_convex(); - for (int i = 0; i < convex_shapes.length; ++i) - { + for (int i = 0; i < convex_shapes.length; ++i) { FloatPoint curr_nearest_point = convex_shapes[i].nearest_point_approx(p_from_point); double curr_dist = curr_nearest_point.distance_square(p_from_point); - if (curr_dist < min_dist) - { + if (curr_dist < min_dist) { min_dist = curr_dist; result = curr_nearest_point; } } return result; } - - public PolygonShape turn_90_degree(int p_factor, IntPoint p_pole) - { + + public PolygonShape turn_90_degree(int p_factor, IntPoint p_pole) { Point[] new_corners = new Point[corners.length]; - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { new_corners[i] = corners[i].turn_90_degree(p_factor, p_pole); } return new PolygonShape(new_corners); } - - public PolygonShape rotate_approx(double p_angle, FloatPoint p_pole) - { - if (p_angle == 0) - { + + public PolygonShape rotate_approx(double p_angle, FloatPoint p_pole) { + if (p_angle == 0) { return this; } Point[] new_corners = new Point[corners.length]; - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { new_corners[i] = corners[i].to_float().rotate(p_angle, p_pole).round(); } return new PolygonShape(new_corners); } - - public PolygonShape mirror_vertical(IntPoint p_pole) - { + + public PolygonShape mirror_vertical(IntPoint p_pole) { Point[] new_corners = new Point[corners.length]; - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { new_corners[i] = corners[i].mirror_vertical(p_pole); } return new PolygonShape(new_corners); } - - public PolygonShape mirror_horizontal(IntPoint p_pole) - { + + public PolygonShape mirror_horizontal(IntPoint p_pole) { Point[] new_corners = new Point[corners.length]; - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { new_corners[i] = corners[i].mirror_horizontal(p_pole); } return new PolygonShape(new_corners); } - + /** * Splits this polygon shape into convex pieces. * The result is not exact, because rounded intersections of lines are * used in the result pieces. It can be made exact, if Polylines are returned * instead of Polygons, so that no intersection points are needed in the result. */ - public TileShape[] split_to_convex() - { + public TileShape[] split_to_convex() { if (this.precalculated_convex_pieces == null) - // not yet precalculated + // not yet precalculated { // use a fixed seed to get reproducable result random_generator.setSeed(seed); Collection convex_pieces = split_to_convex_recu(); - if(convex_pieces == null) - { + if (convex_pieces == null) { // split failed, maybe the polygon has selfontersections return null; } precalculated_convex_pieces = new TileShape[convex_pieces.size()]; Iterator it = convex_pieces.iterator(); - for (int i = 0; i < precalculated_convex_pieces.length; ++i) - { + for (int i = 0; i < precalculated_convex_pieces.length; ++i) { PolygonShape curr_piece = it.next(); precalculated_convex_pieces[i] = TileShape.get_instance(curr_piece.corners); } } return this.precalculated_convex_pieces; } - + /** * Crivate recursive part of split_to_convex. * Returns a collection of polygon shape pieces. */ - private Collection split_to_convex_recu() - { + private Collection split_to_convex_recu() { // start with a hashed corner and search the first concave corner - int start_corner_no = random_generator.nextInt(corners.length); + int start_corner_no = random_generator.nextInt(corners.length); Point curr_corner = corners[start_corner_no]; Point prev_corner; if (start_corner_no != 0) prev_corner = corners[start_corner_no - 1]; else prev_corner = corners[corners.length - 1]; - + Point next_corner = null; - + // search for the next concave corner from here int concave_corner_no = -1; - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { if (start_corner_no < corners.length - 1) next_corner = corners[start_corner_no + 1]; else next_corner = corners[0]; - if (next_corner.side_of(prev_corner, curr_corner) == Side.ON_THE_RIGHT) - { + if (next_corner.side_of(prev_corner, curr_corner) == Side.ON_THE_RIGHT) { // concave corner found concave_corner_no = start_corner_no; break; @@ -630,36 +549,33 @@ private Collection split_to_convex_recu() start_corner_no = (start_corner_no + 1) % corners.length; } Collection result = new LinkedList(); - if (concave_corner_no < 0) - { + if (concave_corner_no < 0) { // no concave corner found, this shape is already convex result.add(this); return result; } DivisionPoint d = new DivisionPoint(concave_corner_no); - if (d.projection == null) - { + if (d.projection == null) { // projection not found, maybe polygon has selfintersections return null; } - + // construct the result pieces from p_polygon and the division point int corner_count = d.corner_no_after_projection - concave_corner_no; - + if (corner_count < 0) corner_count += corners.length; ++corner_count; Point[] first_arr = new Point[corner_count]; int corner_ind = concave_corner_no; - - for (int i = 0; i < corner_count - 1; ++i) - { + + for (int i = 0; i < corner_count - 1; ++i) { first_arr[i] = corners[corner_ind]; corner_ind = (corner_ind + 1) % corners.length; } first_arr[corner_count - 1] = d.projection.round(); PolygonShape first_piece = new PolygonShape(first_arr); - + corner_count = concave_corner_no - d.corner_no_after_projection; if (corner_count < 0) corner_count += corners.length; @@ -667,8 +583,7 @@ private Collection split_to_convex_recu() Point[] last_arr = new Point[corner_count]; last_arr[0] = d.projection.round(); corner_ind = d.corner_no_after_projection; - for (int i = 1; i < corner_count; ++i) - { + for (int i = 1; i < corner_count; ++i) { last_arr[i] = corners[corner_ind]; corner_ind = (corner_ind + 1) % corners.length; } @@ -683,142 +598,120 @@ private Collection split_to_convex_recu() result.addAll(c2); return result; } - - - public final Point[] corners; - - /** - * the following fields are for storing precalculated data - */ - transient private IntBox precalculated_bounding_box = null; - transient private IntOctagon precalculated_bounding_octagon = null; - transient private TileShape[] precalculated_convex_pieces = null; - static private int seed = 99; - static private java.util.Random random_generator = new java.util.Random(seed); - - private class DivisionPoint - { - /** At a concave corner of the closed polygon, a minimal axis parallel + + private class DivisionPoint { + final int corner_no_after_projection; + final FloatPoint projection; + /** + * At a concave corner of the closed polygon, a minimal axis parallel * division line is constructed, to divide the closed polygon into two. */ - DivisionPoint(int p_concave_corner_no) - { + DivisionPoint(int p_concave_corner_no) { FloatPoint concave_corner = corners[p_concave_corner_no].to_float(); FloatPoint before_concave_corner; - + if (p_concave_corner_no != 0) - before_concave_corner = corners[p_concave_corner_no - 1].to_float(); + before_concave_corner = corners[p_concave_corner_no - 1].to_float(); else before_concave_corner = corners[corners.length - 1].to_float(); - + FloatPoint after_concave_corner; - + if (p_concave_corner_no == corners.length - 1) after_concave_corner = corners[0].to_float(); else - after_concave_corner = corners [p_concave_corner_no + 1].to_float(); - + after_concave_corner = corners[p_concave_corner_no + 1].to_float(); + boolean search_right = before_concave_corner.y > concave_corner.y || concave_corner.y > after_concave_corner.y; - + boolean search_left = before_concave_corner.y < concave_corner.y || concave_corner.y < after_concave_corner.y; - + boolean search_up = before_concave_corner.x < concave_corner.x || concave_corner.x < after_concave_corner.x; - + boolean search_down = before_concave_corner.x > concave_corner.x || concave_corner.x > after_concave_corner.x; - + double min_projection_dist = Integer.MAX_VALUE; FloatPoint min_projection = null; int corner_no_after_min_projection = 0; - + int corner_no_after_curr_projection = (p_concave_corner_no + 2) % corners.length; - + Point corner_before_curr_projection; if (corner_no_after_curr_projection != 0) corner_before_curr_projection = corners[corner_no_after_curr_projection - 1]; else corner_before_curr_projection = corners[corners.length - 1]; FloatPoint corner_before_projection_approx = corner_before_curr_projection.to_float(); - + double curr_dist; int loop_end = corners.length - 2; - - for (int i = 0; i < loop_end; ++i) - { + + for (int i = 0; i < loop_end; ++i) { Point corner_after_curr_projection = corners[corner_no_after_curr_projection]; FloatPoint corner_after_projection_approx = corner_after_curr_projection.to_float(); if (corner_before_projection_approx.y != corner_after_projection_approx.y) - // try a horizontal division + // try a horizontal division { double min_y; double max_y; - - if (corner_after_projection_approx.y > corner_before_projection_approx.y) - { + + if (corner_after_projection_approx.y > corner_before_projection_approx.y) { min_y = corner_before_projection_approx.y; max_y = corner_after_projection_approx.y; - } - else - { + } else { min_y = corner_after_projection_approx.y; max_y = corner_before_projection_approx.y; } - - if (concave_corner.y >= min_y && concave_corner.y <= max_y) - { + + if (concave_corner.y >= min_y && concave_corner.y <= max_y) { Line curr_line = new Line(corner_before_curr_projection, corner_after_curr_projection); double x_intersect = curr_line.function_in_y_value_approx(concave_corner.y); curr_dist = Math.abs(x_intersect - concave_corner.x); // Make shure, that the new shape will not be concave at the projection point. // That might happen, if the boundary curve runs back in itself. - boolean projection_ok = curr_dist < min_projection_dist && + boolean projection_ok = curr_dist < min_projection_dist && (search_right && x_intersect > concave_corner.x && - concave_corner.y <= corner_after_projection_approx.y - || search_left && x_intersect < concave_corner.x && - concave_corner.y >= corner_after_projection_approx.y); - if (projection_ok) - { + concave_corner.y <= corner_after_projection_approx.y + || search_left && x_intersect < concave_corner.x && + concave_corner.y >= corner_after_projection_approx.y); + if (projection_ok) { min_projection_dist = curr_dist; corner_no_after_min_projection = corner_no_after_curr_projection; min_projection = new FloatPoint(x_intersect, concave_corner.y); } } } - + if (corner_before_projection_approx.x != corner_after_projection_approx.x) - // try a vertical division + // try a vertical division { double min_x; double max_x; - if (corner_after_projection_approx.x > corner_before_projection_approx.x) - { + if (corner_after_projection_approx.x > corner_before_projection_approx.x) { min_x = corner_before_projection_approx.x; max_x = corner_after_projection_approx.x; - } - else - { + } else { min_x = corner_after_projection_approx.x; max_x = corner_before_projection_approx.x; } - if (concave_corner.x >= min_x && concave_corner.x <= max_x) - { + if (concave_corner.x >= min_x && concave_corner.x <= max_x) { Line curr_line = new Line(corner_before_curr_projection, corner_after_curr_projection); double y_intersect = curr_line.function_value_approx(concave_corner.x); curr_dist = Math.abs(y_intersect - concave_corner.y); // make shure, that the new shape will be convex at the projection point - boolean projection_ok = curr_dist < min_projection_dist && + boolean projection_ok = curr_dist < min_projection_dist && (search_up && y_intersect > concave_corner.y && - concave_corner.x >= corner_after_projection_approx.x - || search_down && y_intersect < concave_corner.y - && concave_corner.x <= corner_after_projection_approx.x); - - if (projection_ok) - { + concave_corner.x >= corner_after_projection_approx.x + || search_down && y_intersect < concave_corner.y + && concave_corner.x <= corner_after_projection_approx.x); + + if (projection_ok) { min_projection_dist = curr_dist; corner_no_after_min_projection = corner_no_after_curr_projection; min_projection = new FloatPoint(concave_corner.x, y_intersect); @@ -827,25 +720,18 @@ private class DivisionPoint } corner_before_curr_projection = corner_after_curr_projection; corner_before_projection_approx = corner_after_projection_approx; - if (corner_no_after_curr_projection == corners.length - 1) - { + if (corner_no_after_curr_projection == corners.length - 1) { corner_no_after_curr_projection = 0; - } - else - { + } else { ++corner_no_after_curr_projection; } } - if (min_projection_dist == Integer.MAX_VALUE ) - { + if (min_projection_dist == Integer.MAX_VALUE) { System.out.println("PolygonShape.DivisionPoint: projection not found"); } - + projection = min_projection; corner_no_after_projection = corner_no_after_min_projection; } - - final int corner_no_after_projection; - final FloatPoint projection; } } diff --git a/src/main/java/net/freerouting/geometry/planar/Polyline.java b/src/main/java/net/freerouting/geometry/planar/Polyline.java index 8d5d4968..d0cdc383 100644 --- a/src/main/java/net/freerouting/geometry/planar/Polyline.java +++ b/src/main/java/net/freerouting/geometry/planar/Polyline.java @@ -21,7 +21,6 @@ import java.util.LinkedList; /** - * * A Polyline is a sequence of lines, where no 2 consecutive * lines may be parallel. A Polyline of n lines defines a Polygon of * n-1 intersection points of consecutive lines. @@ -32,416 +31,435 @@ * of polygons with infinite precision rational coordinates * because of its better performance in geometric calculations. * - * * @author Alfons Wirtz */ -public class Polyline implements java.io.Serializable -{ +public class Polyline implements java.io.Serializable { + private static final boolean USE_BOUNDING_OCTAGON_FOR_OFFSET_SHAPES = true; + /** + * the array of lines of this Polyline. + */ + public final Line[] arr; + transient private FloatPoint[] precalculated_float_corners = null; + transient private Point[] precalculated_corners = null; + transient private IntBox precalculated_bounding_box = null; + /** * creates a polyline of length p_polygon.corner_count + 1 from p_polygon, * so that the i-th corner of p_polygon will be the intersection of * the i-th and the i+1-th lines of the new created p_polyline * for 0 <= i < p_point_arr.length. p_polygon must have at least 2 corners */ - public Polyline(Polygon p_polygon) - { + public Polyline(Polygon p_polygon) { Point[] point_arr = p_polygon.corner_array(); - if (point_arr.length < 2) - { + if (point_arr.length < 2) { System.out.println("Polyline: must contain at least 2 different points"); arr = new Line[0]; return; } - arr = new Line [point_arr.length + 1]; - for (int i = 1; i < point_arr.length; ++i) - { + arr = new Line[point_arr.length + 1]; + for (int i = 1; i < point_arr.length; ++i) { arr[i] = new Line(point_arr[i - 1], point_arr[i]); } // construct perpendicular lines at the start and at the end to represent // the first and the last point of point_arr as intersection of lines. - + Direction dir = Direction.get_instance(point_arr[0], point_arr[1]); - arr [0] = Line.get_instance(point_arr[0], dir.turn_45_degree(2)); - + arr[0] = Line.get_instance(point_arr[0], dir.turn_45_degree(2)); + dir = Direction.get_instance(point_arr[point_arr.length - 1], point_arr[point_arr.length - 2]); arr[point_arr.length] = Line.get_instance(point_arr[point_arr.length - 1], dir.turn_45_degree(2)); } - - public Polyline(Point[] p_points) - { + + public Polyline(Point[] p_points) { this(new Polygon(p_points)); } - + /** * creates a polyline consisting of 3 lines */ - public Polyline(Point p_from_corner, Point p_to_corner) - { - if (p_from_corner.equals(p_to_corner)) - { - arr = new Line [0]; + public Polyline(Point p_from_corner, Point p_to_corner) { + if (p_from_corner.equals(p_to_corner)) { + arr = new Line[0]; return; } - arr = new Line [3]; + arr = new Line[3]; Direction dir = Direction.get_instance(p_from_corner, p_to_corner); - arr [0] = Line.get_instance(p_from_corner, dir.turn_45_degree(2)); + arr[0] = Line.get_instance(p_from_corner, dir.turn_45_degree(2)); arr[1] = new Line(p_from_corner, p_to_corner); dir = Direction.get_instance(p_from_corner, p_to_corner); - arr [2] = Line.get_instance(p_to_corner, dir.turn_45_degree(2)); + arr[2] = Line.get_instance(p_to_corner, dir.turn_45_degree(2)); } - + /** * Creates a polyline from an array of lines. * Lines, which are parallel to the previous line are skipped. * The directed lines are normalized, so that they intersect * the previous line before the next line */ - public Polyline(Line[] p_line_arr) - { - Line [] lines = remove_consecutive_parallel_lines(p_line_arr); + public Polyline(Line[] p_line_arr) { + Line[] lines = remove_consecutive_parallel_lines(p_line_arr); lines = remove_overlaps(lines); - if (lines.length < 3 ) - { + if (lines.length < 3) { arr = new Line[0]; return; } - precalculated_float_corners = new FloatPoint [lines.length - 1]; - + precalculated_float_corners = new FloatPoint[lines.length - 1]; + // turn evtl the direction of the lines that they point always // from the previous corner to the next corner - for (int i = 1; i < lines.length - 1; ++i) - { + for (int i = 1; i < lines.length - 1; ++i) { precalculated_float_corners[i] = lines[i].intersection_approx(lines[i + 1]); Side side_of_line = lines[i - 1].side_of(precalculated_float_corners[i]); - if (side_of_line != Side.COLLINEAR) - { + if (side_of_line != Side.COLLINEAR) { Direction d0 = lines[i - 1].direction(); Direction d1 = lines[i].direction(); Side side1 = d0.side_of(d1); - if (side1 != side_of_line) - { + if (side1 != side_of_line) { lines[i] = lines[i].opposite(); } } } arr = lines; } - + + private static Line[] remove_consecutive_parallel_lines(Line[] p_line_arr) { + if (p_line_arr.length < 3) { + // polyline must have at least 3 lines + return p_line_arr; + } + Line[] tmp_arr = new Line[p_line_arr.length]; + int new_length = 0; + tmp_arr[0] = p_line_arr[0]; + for (int i = 1; i < p_line_arr.length; ++i) { + // skip multiple lines + if (!tmp_arr[new_length].is_parallel(p_line_arr[i])) { + ++new_length; + tmp_arr[new_length] = p_line_arr[i]; + } + } + ++new_length; + if (new_length == p_line_arr.length) { + // nothing skipped + return p_line_arr; + } + // at least 1 line is skipped, adjust the array + if (new_length < 3) { + return new Line[0]; + } + Line[] result = new Line[new_length]; + System.arraycopy(tmp_arr, 0, result, 0, new_length); + return result; + } + + /** + * checks if previous and next line are equal or opposite and + * removes the resulting overlap + */ + private static Line[] remove_overlaps(Line[] p_line_arr) { + if (p_line_arr.length < 4) { + return p_line_arr; + } + int new_length = 0; + Line[] tmp_arr = new Line[p_line_arr.length]; + tmp_arr[0] = p_line_arr[0]; + if (!p_line_arr[0].is_equal_or_opposite(p_line_arr[2])) { + ++new_length; + } + // else skip the first line + tmp_arr[new_length] = p_line_arr[1]; + ++new_length; + for (int i = 2; i < p_line_arr.length - 2; ++i) { + if (tmp_arr[new_length - 1].is_equal_or_opposite(p_line_arr[i + 1])) { + // skip 2 lines + --new_length; + } else { + tmp_arr[new_length] = p_line_arr[i]; + ++new_length; + } + } + tmp_arr[new_length] = p_line_arr[p_line_arr.length - 2]; + ++new_length; + if (!p_line_arr[p_line_arr.length - 1].is_equal_or_opposite(tmp_arr[new_length - 2])) { + tmp_arr[new_length] = p_line_arr[p_line_arr.length - 1]; + ++new_length; + } + // else skip the last line + if (new_length == p_line_arr.length) { + // nothing skipped + return p_line_arr; + } + // at least 1 line is skipped, adjust the array + if (new_length < 3) { + return new Line[0]; + } + Line[] result = new Line[new_length]; + System.arraycopy(tmp_arr, 0, result, 0, new_length); + return result; + } + /** * Returns the number of lines minus 1 */ - public int corner_count() - { + public int corner_count() { return arr.length - 1; } - - public boolean is_empty() - { + + public boolean is_empty() { return arr.length < 3; } - + /** * Checks, if this polyline is empty or if all corner points are equal. */ - public boolean is_point() - { - if ( arr.length < 3) - { + public boolean is_point() { + if (arr.length < 3) { return true; } Point first_corner = this.corner(0); - for (int i = 1; i < arr.length - 1; ++i) - { - if (!(this.corner(i).equals(first_corner))) - { + for (int i = 1; i < arr.length - 1; ++i) { + if (!(this.corner(i).equals(first_corner))) { return false; } } return true; } - + /** * checks, if all lines of this polyline are orthogonal */ - public boolean is_orthogonal() - { - for (int i = 0; i < arr.length; ++i) - { - if (!arr[i].is_orthogonal()) - { + public boolean is_orthogonal() { + for (int i = 0; i < arr.length; ++i) { + if (!arr[i].is_orthogonal()) { return false; } } return true; } - + /** * checks, if all lines of this polyline are multiples of 45 degree */ - public boolean is_multiple_of_45_degree() - { - for (int i = 0; i < arr.length; ++i) - { - if (!arr[i].is_multiple_of_45_degree()) - { + public boolean is_multiple_of_45_degree() { + for (int i = 0; i < arr.length; ++i) { + if (!arr[i].is_multiple_of_45_degree()) { return false; } } return true; } - + /** * returns the intersection of the first line with the second line */ - public Point first_corner() - { + public Point first_corner() { return corner(0); } - + /** * returns the intersection of the last line with the line before * the last line */ - public Point last_corner() - { + public Point last_corner() { return corner(arr.length - 2); } - + /** * returns the array of the intersection of two consecutive lines * approximated by FloatPoint's. */ - public Point [] corner_arr() - { - if (arr.length < 2) - { + public Point[] corner_arr() { + if (arr.length < 2) { return new Point[0]; } if (precalculated_corners == null) - // corner array is not yet allocated + // corner array is not yet allocated { precalculated_corners = new Point[arr.length - 1]; } - for (int i = 0; i < precalculated_corners.length; ++i) - { - if (precalculated_corners[i] == null) - { + for (int i = 0; i < precalculated_corners.length; ++i) { + if (precalculated_corners[i] == null) { precalculated_corners[i] = arr[i].intersection(arr[i + 1]); } } return precalculated_corners; } - + /** * returns the array of the intersection of two consecutive lines * approximated by FloatPoint's. */ - public FloatPoint [] corner_approx_arr() - { - if (arr.length < 2) - { + public FloatPoint[] corner_approx_arr() { + if (arr.length < 2) { return new FloatPoint[0]; } if (precalculated_float_corners == null) - // corner array is not yet allocated + // corner array is not yet allocated { precalculated_float_corners = new FloatPoint[arr.length - 1]; } - for (int i = 0; i < precalculated_float_corners.length; ++i) - { - if (precalculated_float_corners[i] == null) - { + for (int i = 0; i < precalculated_float_corners.length; ++i) { + if (precalculated_float_corners[i] == null) { precalculated_float_corners[i] = arr[i].intersection_approx(arr[i + 1]); } } return precalculated_float_corners; } - + /** * Returns an approximation of the intersection of the p_no-th with * the (p_no - 1)-th line by a FloatPoint. */ - public FloatPoint corner_approx(int p_no) - { + public FloatPoint corner_approx(int p_no) { int no; - if (p_no < 0) - { + if (p_no < 0) { System.out.println("Polyline.corner_approx: p_no is < 0"); no = 0; - } - else if (p_no >= arr.length - 1) - { + } else if (p_no >= arr.length - 1) { System.out.println("Polyline.corner_approx: p_no must be less than arr.length - 1"); no = arr.length - 2; - } - else - { - no = p_no; + } else { + no = p_no; } if (precalculated_float_corners == null) - // corner array is not yet allocated + // corner array is not yet allocated { precalculated_float_corners = new FloatPoint[arr.length - 1]; - for (int i = 0; i < precalculated_float_corners.length; ++i) - { + for (int i = 0; i < precalculated_float_corners.length; ++i) { precalculated_float_corners[i] = null; } } - if (precalculated_float_corners [no] == null) - // corner is not yet calculated + if (precalculated_float_corners[no] == null) + // corner is not yet calculated { precalculated_float_corners[no] = arr[no].intersection_approx(arr[no + 1]); } - return precalculated_float_corners [no]; + return precalculated_float_corners[no]; } - + /** * Returns the intersection of the p_no-th with the (p_no - 1)-th edge line. */ - public Point corner(int p_no) - { - if (arr.length < 2) - { + public Point corner(int p_no) { + if (arr.length < 2) { System.out.println("Polyline.corner: arr.length is < 2"); return null; } int no; - if (p_no < 0) - { + if (p_no < 0) { System.out.println("Polyline.corner: p_no is < 0"); no = 0; - } - else if (p_no >= arr.length - 1) - { + } else if (p_no >= arr.length - 1) { System.out.println("Polyline.corner: p_no must be less than arr.length - 1"); no = arr.length - 2; - } - else - { - no = p_no; + } else { + no = p_no; } if (precalculated_corners == null) - // corner array is not yet allocated + // corner array is not yet allocated { precalculated_corners = new Point[arr.length - 1]; - for (int i = 0; i < precalculated_corners.length; ++i) - { + for (int i = 0; i < precalculated_corners.length; ++i) { precalculated_corners[i] = null; } } - if (precalculated_corners [no] == null) - // corner is not yet calculated + if (precalculated_corners[no] == null) + // corner is not yet calculated { precalculated_corners[no] = arr[no].intersection(arr[no + 1]); } - return precalculated_corners [no]; + return precalculated_corners[no]; } - + /** * return the polyline with the reversed order of lines */ - public Polyline reverse() - { - Line [] reversed_lines = new Line[arr.length]; - for (int i = 0; i < arr.length; ++i) - { + public Polyline reverse() { + Line[] reversed_lines = new Line[arr.length]; + for (int i = 0; i < arr.length; ++i) { reversed_lines[i] = arr[arr.length - i - 1].opposite(); } return new Polyline(reversed_lines); } - + /** * Calculates the length of this polyline from p_from_corner * to p_to_corner. */ - public double length_approx(int p_from_corner, int p_to_corner) - { + public double length_approx(int p_from_corner, int p_to_corner) { int from_corner = Math.max(p_from_corner, 0); int to_corner = Math.min(p_to_corner, arr.length - 2); double result = 0; - for (int i = from_corner; i < to_corner; ++i) - { + for (int i = from_corner; i < to_corner; ++i) { result += this.corner_approx(i + 1).distance(this.corner_approx(i)); } return result; } - + /** * Calculates the cumulative distance between consecutive corners of * this polyline. */ - public double length_approx() - { + public double length_approx() { return length_approx(0, arr.length - 2); } - + /** * calculates for each line a shape around this line * where the right and left edge lines have the distance p_half_width * from the center line * Returns an array of convex shapes of length line_count - 2 */ - public TileShape[] offset_shapes(int p_half_width) - { - return offset_shapes(p_half_width, 0, arr.length -1); + public TileShape[] offset_shapes(int p_half_width) { + return offset_shapes(p_half_width, 0, arr.length - 1); } - + /** * calculates for each line between p_from_no and p_to_no a shape around * this line, where the right and left edge lines have the distance p_half_width * from the center line */ public TileShape[] offset_shapes(int p_half_width, - int p_from_no, int p_to_no) - { + int p_from_no, int p_to_no) { int from_no = Math.max(p_from_no, 0); - int to_no = Math.min(p_to_no, arr.length -1); - int shape_count = Math.max(to_no - from_no -1, 0); + int to_no = Math.min(p_to_no, arr.length - 1); + int shape_count = Math.max(to_no - from_no - 1, 0); TileShape[] shape_arr = new TileShape[shape_count]; - if (shape_count == 0) - { + if (shape_count == 0) { return shape_arr; } Vector prev_dir = arr[from_no].direction().get_vector(); Vector curr_dir = arr[from_no + 1].direction().get_vector(); - for (int i = from_no + 1; i < to_no; ++i) - { + for (int i = from_no + 1; i < to_no; ++i) { Vector next_dir = arr[i + 1].direction().get_vector(); - + Line[] lines = new Line[4]; - + lines[0] = arr[i].translate(-p_half_width); // current center line translated to the right - + // create the front line of the offset shape - Side next_dir_from_curr_dir = next_dir.side_of(curr_dir); + Side next_dir_from_curr_dir = next_dir.side_of(curr_dir); // left turn from curr_line to next_line - if (next_dir_from_curr_dir == Side.ON_THE_LEFT) - { + if (next_dir_from_curr_dir == Side.ON_THE_LEFT) { lines[1] = arr[i + 1].translate(-p_half_width); // next right line - } - else - { + } else { lines[1] = arr[i + 1].opposite().translate(-p_half_width); // next left line in opposite direction } - + lines[2] = arr[i].opposite().translate(-p_half_width); // current left line in opposite direction - + // create the back line of the offset shape - Side curr_dir_from_prev_dir = curr_dir.side_of(prev_dir); + Side curr_dir_from_prev_dir = curr_dir.side_of(prev_dir); // left turn from prev_line to curr_line - if (curr_dir_from_prev_dir == Side.ON_THE_LEFT) - { + if (curr_dir_from_prev_dir == Side.ON_THE_LEFT) { lines[3] = arr[i - 1].translate(-p_half_width); // previous line translated to the right - } - else - { + } else { lines[3] = arr[i - 1].opposite().translate(-p_half_width); // previous left line in opposite direction } @@ -449,12 +467,9 @@ public TileShape[] offset_shapes(int p_half_width, FloatPoint corner_to_check = null; Line curr_line = lines[1]; Line check_line = null; - if (next_dir_from_curr_dir == Side.ON_THE_LEFT) - { + if (next_dir_from_curr_dir == Side.ON_THE_LEFT) { check_line = lines[2]; - } - else - { + } else { check_line = lines[0]; } FloatPoint check_distance_corner = corner_approx(i); @@ -462,15 +477,12 @@ public TileShape[] offset_shapes(int p_half_width, Collection cut_dog_ear_lines = new LinkedList(); Vector tmp_curr_dir = next_dir; boolean direction_changed = false; - for (int j = i + 2; j < arr.length - 1; ++j) - { + for (int j = i + 2; j < arr.length - 1; ++j) { if (corner_approx(j - 1).distance_square(check_distance_corner) - > check_dist_square) - { + > check_dist_square) { break; } - if (!direction_changed) - { + if (!direction_changed) { corner_to_check = curr_line.intersection_approx(check_line); } Vector tmp_next_dir = arr[j].direction().get_vector(); @@ -478,21 +490,17 @@ public TileShape[] offset_shapes(int p_half_width, Side tmp_next_dir_from_tmp_curr_dir = tmp_next_dir.side_of(tmp_curr_dir); direction_changed = tmp_next_dir_from_tmp_curr_dir != next_dir_from_curr_dir; - if (!direction_changed) - { - if (tmp_next_dir_from_tmp_curr_dir == Side.ON_THE_LEFT) - { + if (!direction_changed) { + if (tmp_next_dir_from_tmp_curr_dir == Side.ON_THE_LEFT) { next_border_line = arr[j].translate(-p_half_width); - } - else - { + } else { next_border_line = arr[j].opposite().translate(-p_half_width); } - + if (next_border_line.side_of(corner_to_check) == Side.ON_THE_LEFT && next_border_line.side_of(this.corner(i)) == Side.ON_THE_RIGHT && next_border_line.side_of(this.corner(i - 1)) == Side.ON_THE_RIGHT) - // an outstanding corner + // an outstanding corner { cut_dog_ear_lines.add(next_border_line); } @@ -502,26 +510,20 @@ public TileShape[] offset_shapes(int p_half_width, } // cut off outstanding corners with previous shapes check_distance_corner = corner_approx(i - 1); - if (curr_dir_from_prev_dir == Side.ON_THE_LEFT) - { + if (curr_dir_from_prev_dir == Side.ON_THE_LEFT) { check_line = lines[2]; - } - else - { + } else { check_line = lines[0]; } - curr_line = lines [3]; + curr_line = lines[3]; tmp_curr_dir = prev_dir; direction_changed = false; - for (int j = i - 2; j >= 1; --j) - { + for (int j = i - 2; j >= 1; --j) { if (corner_approx(j).distance_square(check_distance_corner) - > check_dist_square) - { + > check_dist_square) { break; } - if (!direction_changed) - { + if (!direction_changed) { corner_to_check = curr_line.intersection_approx(check_line); } Vector tmp_prev_dir = arr[j].direction().get_vector(); @@ -529,20 +531,16 @@ public TileShape[] offset_shapes(int p_half_width, Side tmp_curr_dir_from_tmp_prev_dir = tmp_curr_dir.side_of(tmp_prev_dir); direction_changed = tmp_curr_dir_from_tmp_prev_dir != curr_dir_from_prev_dir; - if (!direction_changed) - { - if (tmp_curr_dir.side_of(tmp_prev_dir) == Side.ON_THE_LEFT) - { + if (!direction_changed) { + if (tmp_curr_dir.side_of(tmp_prev_dir) == Side.ON_THE_LEFT) { prev_border_line = arr[j].translate(-p_half_width); - } - else - { + } else { prev_border_line = arr[j].opposite().translate(-p_half_width); } if (prev_border_line.side_of(corner_to_check) == Side.ON_THE_LEFT && prev_border_line.side_of(this.corner(i)) == Side.ON_THE_RIGHT && prev_border_line.side_of(this.corner(i - 1)) == Side.ON_THE_RIGHT) - // an outstanding corner + // an outstanding corner { cut_dog_ear_lines.add(prev_border_line); } @@ -552,187 +550,166 @@ public TileShape[] offset_shapes(int p_half_width, } TileShape s1 = TileShape.get_instance(lines); int cut_line_count = cut_dog_ear_lines.size(); - if (cut_line_count > 0) - { + if (cut_line_count > 0) { Line[] cut_lines = new Line[cut_line_count]; Iterator it = cut_dog_ear_lines.iterator(); - for (int j = 0; j < cut_line_count; ++j) - { + for (int j = 0; j < cut_line_count; ++j) { cut_lines[j] = it.next(); } - s1 = s1.intersection(TileShape.get_instance(cut_lines)); + s1 = s1.intersection(TileShape.get_instance(cut_lines)); } int curr_shape_no = i - from_no - 1; TileShape bounding_shape; if (USE_BOUNDING_OCTAGON_FOR_OFFSET_SHAPES) - // intersect with the bounding octagon + // intersect with the bounding octagon { - IntOctagon surr_oct = bounding_octagon(i-1, i); + IntOctagon surr_oct = bounding_octagon(i - 1, i); bounding_shape = surr_oct.offset(p_half_width); - - } - else - // intersect with the bounding box + + } else + // intersect with the bounding box { - IntBox surr_box = bounding_box(i-1, i); + IntBox surr_box = bounding_box(i - 1, i); IntBox offset_box = surr_box.offset(p_half_width); bounding_shape = offset_box.to_Simplex(); } shape_arr[curr_shape_no] = bounding_shape.intersection_with_simplify(s1); - if (shape_arr[curr_shape_no].is_empty()) - { + if (shape_arr[curr_shape_no].is_empty()) { System.out.println("offset_shapes: shape is empty"); } - + prev_dir = curr_dir; curr_dir = next_dir; - + } return shape_arr; } - + /** * Calculates for the p_no-th line segment a shape around this line * where the right and left edge lines have the distance p_half_width * from the center line. 0 <= p_no <= arr.length - 3 */ - public TileShape offset_shape(int p_half_width, int p_no) - { - if (p_no < 0 || p_no > arr.length - 3) - { + public TileShape offset_shape(int p_half_width, int p_no) { + if (p_no < 0 || p_no > arr.length - 3) { System.out.println("Polyline.offset_shape: p_no out of range"); return null; } TileShape[] result = offset_shapes(p_half_width, p_no, p_no + 2); return result[0]; } - + /** * Calculates for the p_no-th line segment a box shape around this line * where the border lines have the distance p_half_width * from the center line. 0 <= p_no <= arr.length - 3 */ - public IntBox offset_box(int p_half_width, int p_no) - { + public IntBox offset_box(int p_half_width, int p_no) { LineSegment curr_line_segment = new LineSegment(this, p_no + 1); IntBox result = curr_line_segment.bounding_box().offset(p_half_width); return result; } - + /** * Returns the by p_vector translated polyline */ - public Polyline translate_by(Vector p_vector) - { - if (p_vector.equals(Vector.ZERO)) - { + public Polyline translate_by(Vector p_vector) { + if (p_vector.equals(Vector.ZERO)) { return this; } - Line [] new_arr = new Line[arr.length]; - for (int i = 0; i < new_arr.length; ++i) - { + Line[] new_arr = new Line[arr.length]; + for (int i = 0; i < new_arr.length; ++i) { new_arr[i] = arr[i].translate_by(p_vector); } return new Polyline(new_arr); } - + /** * Returns the polyline turned by p_factor times 90 degree around p_pole. */ - public Polyline turn_90_degree(int p_factor, IntPoint p_pole) - { - Line [] new_arr = new Line[arr.length]; - for (int i = 0; i < new_arr.length; ++i) - { + public Polyline turn_90_degree(int p_factor, IntPoint p_pole) { + Line[] new_arr = new Line[arr.length]; + for (int i = 0; i < new_arr.length; ++i) { new_arr[i] = arr[i].turn_90_degree(p_factor, p_pole); } return new Polyline(new_arr); } - - public Polyline rotate_approx(double p_angle, FloatPoint p_pole) - { - if (p_angle == 0) - { + + public Polyline rotate_approx(double p_angle, FloatPoint p_pole) { + if (p_angle == 0) { return this; } - IntPoint [] new_corners = new IntPoint[this.corner_count()]; - for (int i = 0; i < new_corners.length; ++i) - { - + IntPoint[] new_corners = new IntPoint[this.corner_count()]; + for (int i = 0; i < new_corners.length; ++i) { + new_corners[i] = this.corner_approx(i).rotate(p_angle, p_pole).round(); } return new Polyline(new_corners); } - - /** Mirrors this polyline at the vertical line through p_pole */ - public Polyline mirror_vertical(IntPoint p_pole) - { - Line [] new_arr = new Line[arr.length]; - for (int i = 0; i < new_arr.length; ++i) - { + + /** + * Mirrors this polyline at the vertical line through p_pole + */ + public Polyline mirror_vertical(IntPoint p_pole) { + Line[] new_arr = new Line[arr.length]; + for (int i = 0; i < new_arr.length; ++i) { new_arr[i] = arr[i].mirror_vertical(p_pole); } return new Polyline(new_arr); } - - /** Mirrors this polyline at the horizontal line through p_pole */ - public Polyline mirror_horizontal(IntPoint p_pole) - { - Line [] new_arr = new Line[arr.length]; - for (int i = 0; i < new_arr.length; ++i) - { + + /** + * Mirrors this polyline at the horizontal line through p_pole + */ + public Polyline mirror_horizontal(IntPoint p_pole) { + Line[] new_arr = new Line[arr.length]; + for (int i = 0; i < new_arr.length; ++i) { new_arr[i] = arr[i].mirror_horizontal(p_pole); } return new Polyline(new_arr); } - - + /** * Returns the smallest box containing the intersection points * from index p_from_corner_no to index p_to_corner_no * of the lines of this polyline */ - public IntBox bounding_box(int p_from_corner_no, int p_to_corner_no) - { + public IntBox bounding_box(int p_from_corner_no, int p_to_corner_no) { int from_corner_no = Math.max(p_from_corner_no, 0); int to_corner_no = Math.min(p_to_corner_no, arr.length - 2); double llx = Integer.MAX_VALUE; double lly = llx; double urx = Integer.MIN_VALUE; double ury = urx; - for (int i = from_corner_no; i <= to_corner_no; ++i) - { + for (int i = from_corner_no; i <= to_corner_no; ++i) { FloatPoint curr_corner = corner_approx(i); llx = Math.min(llx, curr_corner.x); lly = Math.min(lly, curr_corner.y); urx = Math.max(urx, curr_corner.x); ury = Math.max(ury, curr_corner.y); } - IntPoint lower_left = new IntPoint((int)Math.floor(llx), (int)Math.floor(lly)); - IntPoint upper_right = new IntPoint((int)Math.ceil(urx), (int)Math.ceil(ury)); - return new IntBox(lower_left, upper_right); + IntPoint lower_left = new IntPoint((int) Math.floor(llx), (int) Math.floor(lly)); + IntPoint upper_right = new IntPoint((int) Math.ceil(urx), (int) Math.ceil(ury)); + return new IntBox(lower_left, upper_right); } - + /** * Returns the smallest box containing the intersection points * of the lines of this polyline */ - public IntBox bounding_box() - { - if (precalculated_bounding_box == null) - { + public IntBox bounding_box() { + if (precalculated_bounding_box == null) { precalculated_bounding_box = bounding_box(0, corner_count() - 1); } return precalculated_bounding_box; } - + /** * Returns the smallest octagon containing the intersection points * from index p_from_corner_no to index p_to_corner_no * of the lines of this polyline */ - public IntOctagon bounding_octagon(int p_from_corner_no, int p_to_corner_no) - { + public IntOctagon bounding_octagon(int p_from_corner_no, int p_to_corner_no) { int from_corner_no = Math.max(p_from_corner_no, 0); int to_corner_no = Math.min(p_to_corner_no, arr.length - 2); double lx = Integer.MAX_VALUE; @@ -743,8 +720,7 @@ public IntOctagon bounding_octagon(int p_from_corner_no, int p_to_corner_no) double lrx = Integer.MIN_VALUE; double llx = Integer.MAX_VALUE; double urx = Integer.MIN_VALUE; - for (int i = from_corner_no; i <= to_corner_no; ++i) - { + for (int i = from_corner_no; i <= to_corner_no; ++i) { FloatPoint curr = corner_approx(i); lx = Math.min(lx, curr.x); ly = Math.min(ly, curr.y); @@ -758,44 +734,38 @@ public IntOctagon bounding_octagon(int p_from_corner_no, int p_to_corner_no) urx = Math.max(urx, tmp); } IntOctagon surrounding_octagon = new - IntOctagon((int)Math.floor(lx), (int)Math.floor(ly), - (int)Math.ceil(rx), (int)Math.ceil(uy), - (int)Math.floor(ulx), (int)Math.ceil(lrx), - (int)Math.floor(llx), (int)Math.ceil(urx)); + IntOctagon((int) Math.floor(lx), (int) Math.floor(ly), + (int) Math.ceil(rx), (int) Math.ceil(uy), + (int) Math.floor(ulx), (int) Math.ceil(lrx), + (int) Math.floor(llx), (int) Math.ceil(urx)); return surrounding_octagon; } - + /** * Calculates an aproximation of the nearest point on this * polyline to p_from_point. */ - public FloatPoint nearest_point_approx(FloatPoint p_from_point) - { + public FloatPoint nearest_point_approx(FloatPoint p_from_point) { double min_distance = Double.MAX_VALUE; FloatPoint nearest_point = null; // calculate the nearest corner point FloatPoint[] corners = corner_approx_arr(); - for (int i = 0; i < corners.length; ++i) - { + for (int i = 0; i < corners.length; ++i) { double curr_distance = corners[i].distance(p_from_point); - if (curr_distance < min_distance) - { + if (curr_distance < min_distance) { min_distance = curr_distance; nearest_point = corners[i]; } } final double c_tolerance = 1; - for (int i = 1; i < arr.length - 1; ++i) - { + for (int i = 1; i < arr.length - 1; ++i) { FloatPoint projection = p_from_point.projection_approx(arr[i]); double curr_distance = projection.distance(p_from_point); - if (curr_distance < min_distance) - { + if (curr_distance < min_distance) { // look, if the projection is inside the segment double segment_length = corners[i].distance(corners[i - 1]); if (projection.distance(corners[i]) + projection.distance(corners[i - 1]) - < segment_length + c_tolerance) - { + < segment_length + c_tolerance) { min_distance = curr_distance; nearest_point = projection; } @@ -803,17 +773,16 @@ public FloatPoint nearest_point_approx(FloatPoint p_from_point) } return nearest_point; } - + /** * Calculates the distance of p_from_point to the the nearest point * on this polyline */ - public double distance(FloatPoint p_from_point) - { + public double distance(FloatPoint p_from_point) { double result = p_from_point.distance(nearest_point_approx(p_from_point)); return result; } - + /** * Combines the two polylines, if they have a common end corner. * The order of lines in this polyline will be preserved. @@ -824,85 +793,59 @@ public double distance(FloatPoint p_from_point) * If there is something to combine at the end of this polyline, * this polyline is inserted in front of p_other. */ - public Polyline combine(Polyline p_other) - { + public Polyline combine(Polyline p_other) { if (p_other == null || arr.length < 3 - || p_other.arr.length < 3) - { + || p_other.arr.length < 3) { return this; } boolean combine_at_start; boolean combine_other_at_start; - if (first_corner().equals(p_other.first_corner())) - { + if (first_corner().equals(p_other.first_corner())) { combine_at_start = true; combine_other_at_start = true; - } - else if (first_corner().equals(p_other.last_corner())) - { + } else if (first_corner().equals(p_other.last_corner())) { combine_at_start = true; combine_other_at_start = false; - } - else if (last_corner().equals(p_other.first_corner())) - { + } else if (last_corner().equals(p_other.first_corner())) { combine_at_start = false; combine_other_at_start = true; - } - else if (last_corner().equals(p_other.last_corner())) - { + } else if (last_corner().equals(p_other.last_corner())) { combine_at_start = false; combine_other_at_start = false; - } - else - { + } else { return this; // no common endpoint } - Line [] line_arr = new Line [arr.length + p_other.arr.length - 2]; - if (combine_at_start) - { + Line[] line_arr = new Line[arr.length + p_other.arr.length - 2]; + if (combine_at_start) { // insert the lines of p_other in front - if (combine_other_at_start) - { + if (combine_other_at_start) { // insert in reverse order, skip the first line of p_other - for (int i = 0; i < p_other.arr.length - 1; ++i) - { + for (int i = 0; i < p_other.arr.length - 1; ++i) { line_arr[i] = p_other.arr[p_other.arr.length - i - 1].opposite(); } - } - else - { + } else { // skip the last line of p_other - for (int i = 0; i < p_other.arr.length - 1; ++i) - { + for (int i = 0; i < p_other.arr.length - 1; ++i) { line_arr[i] = p_other.arr[i]; } } // append the lines of this polyline, skip the first line - for (int i = 1; i < arr.length; ++i) - { + for (int i = 1; i < arr.length; ++i) { line_arr[p_other.arr.length + i - 2] = arr[i]; } - } - else - { + } else { // insert the lines of this polyline in front, skip the last line - for (int i = 0; i < arr.length - 1; ++i) - { + for (int i = 0; i < arr.length - 1; ++i) { line_arr[i] = arr[i]; } - if (combine_other_at_start) - { + if (combine_other_at_start) { // skip the first line of p_other - for (int i = 1; i < p_other.arr.length; ++i) - { + for (int i = 1; i < p_other.arr.length; ++i) { line_arr[arr.length + i - 2] = p_other.arr[i]; } - } - else - { + } else { // insert in reverse order, skip the last line of p_other - for (int i = 1; i < p_other.arr.length; ++i) - { + for (int i = 1; i < p_other.arr.length; ++i) { line_arr[arr.length + i - 2] = p_other.arr[p_other.arr.length - i - 1].opposite(); } @@ -910,7 +853,7 @@ else if (last_corner().equals(p_other.last_corner())) } return new Polyline(line_arr); } - + /** * Splits this polyline at the line with number p_line_no * into two by inserting p_endline as concluding line of the first split piece @@ -920,92 +863,76 @@ else if (last_corner().equals(p_other.last_corner())) * p_line_no must be bigger than 0 and less then arr.length - 1. * Returns null, if nothing was split. */ - public Polyline[] split(int p_line_no, Line p_end_line) - { - if (p_line_no < 1 || p_line_no > arr.length - 2) - { + public Polyline[] split(int p_line_no, Line p_end_line) { + if (p_line_no < 1 || p_line_no > arr.length - 2) { System.out.println("Polyline.split: p_line_no out of range"); return null; } - if (this.arr[p_line_no].is_parallel(p_end_line)) - { + if (this.arr[p_line_no].is_parallel(p_end_line)) { return null; } Point new_end_corner = this.arr[p_line_no].intersection(p_end_line); if (p_line_no <= 1 && new_end_corner.equals(this.first_corner()) || - p_line_no >= arr.length - 2 && new_end_corner.equals(this.last_corner())) - { + p_line_no >= arr.length - 2 && new_end_corner.equals(this.last_corner())) { // No split, if p_end_line does not intersect, but touches // only tnis Polyline at an end point. return null; } Line[] first_piece; - if (this.corner(p_line_no - 1).equals(new_end_corner)) - { + if (this.corner(p_line_no - 1).equals(new_end_corner)) { // skip line segment of length 0 at the end of the first piece - first_piece = new Line [p_line_no + 1]; - System.arraycopy(arr, 0, first_piece, 0, first_piece.length); - - } - else - { - first_piece = new Line [p_line_no + 2]; - System.arraycopy(arr, 0, first_piece, 0, p_line_no + 1); + first_piece = new Line[p_line_no + 1]; + System.arraycopy(arr, 0, first_piece, 0, first_piece.length); + + } else { + first_piece = new Line[p_line_no + 2]; + System.arraycopy(arr, 0, first_piece, 0, p_line_no + 1); first_piece[p_line_no + 1] = p_end_line; } Line[] second_piece; - if (this.corner(p_line_no).equals(new_end_corner)) - { + if (this.corner(p_line_no).equals(new_end_corner)) { // skip line segment of length 0 at the beginning of the second piece - second_piece = new Line [arr.length - p_line_no]; - System.arraycopy(this.arr, p_line_no,second_piece, 0, second_piece.length); - - } - else - { - second_piece = new Line [arr.length - p_line_no + 1]; + second_piece = new Line[arr.length - p_line_no]; + System.arraycopy(this.arr, p_line_no, second_piece, 0, second_piece.length); + + } else { + second_piece = new Line[arr.length - p_line_no + 1]; second_piece[0] = p_end_line; - System.arraycopy(this.arr, p_line_no, second_piece, 1, second_piece.length - 1); + System.arraycopy(this.arr, p_line_no, second_piece, 1, second_piece.length - 1); } - Polyline [] result = new Polyline[2]; + Polyline[] result = new Polyline[2]; result[0] = new Polyline(first_piece); result[1] = new Polyline(second_piece); - if (result[0].is_point() || result[1].is_point()) - { + if (result[0].is_point() || result[1].is_point()) { return null; } return result; } - + /** * create a new Polyline by skipping the lines of this Polyline * from p_from_no to p_to_no */ - public Polyline skip_lines(int p_from_no, int p_to_no) - { - if (p_from_no < 0 || p_to_no > arr.length - 1 || p_from_no > p_to_no) - { + public Polyline skip_lines(int p_from_no, int p_to_no) { + if (p_from_no < 0 || p_to_no > arr.length - 1 || p_from_no > p_to_no) { return this; } - Line [] new_lines = new Line [arr.length - (p_to_no - p_from_no + 1)]; + Line[] new_lines = new Line[arr.length - (p_to_no - p_from_no + 1)]; System.arraycopy(arr, 0, new_lines, 0, p_from_no); System.arraycopy(arr, p_to_no + 1, new_lines, p_from_no, new_lines.length - p_from_no); return new Polyline(new_lines); } - - public boolean contains(Point p_point) - { - for (int i = 1; i < arr.length - 1; ++i) - { + + public boolean contains(Point p_point) { + for (int i = 1; i < arr.length - 1; ++i) { LineSegment curr_segment = new LineSegment(this, i); - if (curr_segment.contains(p_point)) - { + if (curr_segment.contains(p_point)) { return true; } } return false; } - + /** * Creates a perpendicular line segment from p_from_point onto the nearest * line segment of this polyline to p_from_side. @@ -1013,31 +940,26 @@ public boolean contains(Point p_point) * segment inside its segment bounds or if p_from_point is contained in * this polyline. */ - public LineSegment projection_line(Point p_from_point) - { + public LineSegment projection_line(Point p_from_point) { FloatPoint from_point = p_from_point.to_float(); double min_distance = Double.MAX_VALUE; Line result_line = null; Line nearest_line = null; - for (int i = 1; i < arr.length - 1; ++i) - { + for (int i = 1; i < arr.length - 1; ++i) { FloatPoint projection = from_point.projection_approx(arr[i]); double curr_distance = projection.distance(from_point); - if (curr_distance < min_distance) - { + if (curr_distance < min_distance) { Direction direction_towards_line = this.arr[i].perpendicular_direction(p_from_point); - if (direction_towards_line == null) - { + if (direction_towards_line == null) { continue; } - Line curr_result_line = new Line(p_from_point, direction_towards_line); + Line curr_result_line = new Line(p_from_point, direction_towards_line); Point prev_corner = this.corner(i - 1); Point next_corner = this.corner(i); Side prev_corner_side = curr_result_line.side_of(prev_corner); Side next_corner_side = curr_result_line.side_of(next_corner); if (prev_corner_side != Side.COLLINEAR && next_corner_side != Side.COLLINEAR - && prev_corner_side == next_corner_side) - { + && prev_corner_side == next_corner_side) { // the projection point is outside the line segment continue; } @@ -1046,36 +968,32 @@ public LineSegment projection_line(Point p_from_point) result_line = curr_result_line; } } - if (nearest_line == null) - { + if (nearest_line == null) { return null; } Line start_line = new Line(p_from_point, nearest_line.direction()); LineSegment result = new LineSegment(start_line, result_line, nearest_line); return result; } - + /** * Shortens this polyline to p_new_line_count lines. Additioanally * the last line segment will be approximately shortened to p_new_length. * The last corner of the new polyline will be an IntPoint. */ - public Polyline shorten(int p_new_line_count, double p_last_segment_length) - { + public Polyline shorten(int p_new_line_count, double p_last_segment_length) { FloatPoint last_corner = this.corner_approx(p_new_line_count - 2); FloatPoint prev_last_corner = this.corner_approx(p_new_line_count - 3); IntPoint new_last_corner = prev_last_corner.change_length(last_corner, p_last_segment_length).round(); - if (new_last_corner.equals(this.corner(this.corner_count() - 2))) - { + if (new_last_corner.equals(this.corner(this.corner_count() - 2))) { // skip the last line - return skip_lines( p_new_line_count - 1, p_new_line_count - 1); + return skip_lines(p_new_line_count - 1, p_new_line_count - 1); } - Line[] new_lines = new Line [p_new_line_count]; + Line[] new_lines = new Line[p_new_line_count]; System.arraycopy(arr, 0, new_lines, 0, p_new_line_count - 2); // create the last 2 lines of the new polyline Point first_line_point = arr[p_new_line_count - 2].a; - if (first_line_point.equals(new_last_corner)) - { + if (first_line_point.equals(new_last_corner)) { first_line_point = arr[p_new_line_count - 2].b; } Line new_prev_last_line = new Line(first_line_point, new_last_corner); @@ -1084,107 +1002,4 @@ public Polyline shorten(int p_new_line_count, double p_last_segment_length) Line.get_instance(new_last_corner, new_prev_last_line.direction().turn_45_degree(6)); return new Polyline(new_lines); } - - - private static Line[] remove_consecutive_parallel_lines( Line [] p_line_arr) - { - if (p_line_arr.length < 3) - { - // polyline must have at least 3 lines - return p_line_arr; - } - Line [] tmp_arr = new Line [p_line_arr.length]; - int new_length = 0; - tmp_arr[0] = p_line_arr [0]; - for (int i = 1; i < p_line_arr.length; ++i) - { - // skip multiple lines - if (!tmp_arr[new_length].is_parallel(p_line_arr[i])) - { - ++new_length; - tmp_arr[new_length] = p_line_arr[i]; - } - } - ++new_length; - if (new_length == p_line_arr.length) - { - // nothing skipped - return p_line_arr; - } - // at least 1 line is skipped, adjust the array - if (new_length < 3) - { - return new Line[0]; - } - Line [] result = new Line[new_length]; - System.arraycopy(tmp_arr, 0, result, 0, new_length); - return result; - } - - /** - * checks if previous and next line are equal or opposite and - * removes the resulting overlap - */ - private static Line [] remove_overlaps(Line [] p_line_arr) - { - if (p_line_arr.length < 4) - { - return p_line_arr; - } - int new_length = 0; - Line [] tmp_arr = new Line [p_line_arr.length]; - tmp_arr[0] = p_line_arr[0]; - if (!p_line_arr[0].is_equal_or_opposite(p_line_arr[2])) - { - ++new_length; - } - // else skip the first line - tmp_arr[new_length] = p_line_arr[1]; - ++new_length; - for (int i = 2; i < p_line_arr.length - 2; ++i) - { - if (tmp_arr[new_length - 1].is_equal_or_opposite(p_line_arr [i + 1])) - { - // skip 2 lines - --new_length; - } - else - { - tmp_arr[new_length] = p_line_arr [i]; - ++new_length; - } - } - tmp_arr [new_length] = p_line_arr[p_line_arr.length - 2]; - ++new_length; - if (!p_line_arr[p_line_arr.length - 1].is_equal_or_opposite(tmp_arr[new_length - 2])) - { - tmp_arr[new_length] = p_line_arr[p_line_arr.length - 1]; - ++new_length; - } - // else skip the last line - if (new_length == p_line_arr.length) - { - // nothing skipped - return p_line_arr; - } - // at least 1 line is skipped, adjust the array - if (new_length < 3) - { - return new Line[0]; - } - Line [] result = new Line[new_length]; - System.arraycopy(tmp_arr, 0, result, 0, new_length); - return result; - } - - - /** - * the array of lines of this Polyline. - */ - public final Line[] arr; - - transient private FloatPoint[] precalculated_float_corners = null; - transient private Point[] precalculated_corners = null; - transient private IntBox precalculated_bounding_box = null; - private static final boolean USE_BOUNDING_OCTAGON_FOR_OFFSET_SHAPES = true; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/PolylineArea.java b/src/main/java/net/freerouting/geometry/planar/PolylineArea.java index 0777f761..89ea629f 100644 --- a/src/main/java/net/freerouting/geometry/planar/PolylineArea.java +++ b/src/main/java/net/freerouting/geometry/planar/PolylineArea.java @@ -27,101 +27,97 @@ * A PolylineArea is an Area, where the outside border curve and the hole borders * consist of straight lines. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class PolylineArea implements Area, java.io.Serializable -{ +public class PolylineArea implements Area, java.io.Serializable { - /** Creates a new instance of PolylineShapeWithHoles */ - public PolylineArea(PolylineShape p_border_shape, PolylineShape[] p_hole_arr) - { + final PolylineShape border_shape; + final PolylineShape[] hole_arr; + transient private TileShape[] precalculated_convex_pieces = null; + + /** + * Creates a new instance of PolylineShapeWithHoles + */ + public PolylineArea(PolylineShape p_border_shape, PolylineShape[] p_hole_arr) { border_shape = p_border_shape; hole_arr = p_hole_arr; } - public int dimension() - { + static private void cutout_hole_piece(TileShape p_divide_piece, TileShape p_hole_piece, + Collection p_result_pieces) { + TileShape[] result_pieces = p_divide_piece.cutout(p_hole_piece); + for (int i = 0; i < result_pieces.length; ++i) { + TileShape curr_piece = result_pieces[i]; + if (curr_piece.dimension() == 2) { + p_result_pieces.add(curr_piece); + } + } + } + + public int dimension() { return border_shape.dimension(); } - public boolean is_bounded() - { + public boolean is_bounded() { return border_shape.is_bounded(); } - public boolean is_empty() - { + public boolean is_empty() { return border_shape.is_empty(); } - public boolean is_contained_in(IntBox p_box) - { + public boolean is_contained_in(IntBox p_box) { return border_shape.is_contained_in(p_box); } - public PolylineShape get_border() - { + public PolylineShape get_border() { return border_shape; } - public PolylineShape[] get_holes() - { + public PolylineShape[] get_holes() { return hole_arr; } - public IntBox bounding_box() - { + public IntBox bounding_box() { return border_shape.bounding_box(); } - public IntOctagon bounding_octagon() - { + public IntOctagon bounding_octagon() { return border_shape.bounding_octagon(); } - public boolean contains(FloatPoint p_point) - { - if (!border_shape.contains(p_point)) - { + public boolean contains(FloatPoint p_point) { + if (!border_shape.contains(p_point)) { return false; } - for (int i = 0; i < hole_arr.length; ++i) - { - if (hole_arr[i].contains(p_point)) - { + for (int i = 0; i < hole_arr.length; ++i) { + if (hole_arr[i].contains(p_point)) { return false; } } return true; } - public boolean contains(Point p_point) - { - if (!border_shape.contains(p_point)) - { + public boolean contains(Point p_point) { + if (!border_shape.contains(p_point)) { return false; } - for (int i = 0; i < hole_arr.length; ++i) - { - if (hole_arr[i].contains_inside(p_point)) - { + for (int i = 0; i < hole_arr.length; ++i) { + if (hole_arr[i].contains_inside(p_point)) { return false; } } return true; } - public FloatPoint nearest_point_approx(FloatPoint p_from_point) - { + public FloatPoint nearest_point_approx(FloatPoint p_from_point) { double min_dist = Double.MAX_VALUE; FloatPoint result = null; TileShape[] convex_shapes = split_to_convex(); - for (int i = 0; i < convex_shapes.length; ++i) - { + for (int i = 0; i < convex_shapes.length; ++i) { FloatPoint curr_nearest_point = convex_shapes[i].nearest_point_approx(p_from_point); double curr_dist = curr_nearest_point.distance_square(p_from_point); - if (curr_dist < min_dist) - { + if (curr_dist < min_dist) { min_dist = curr_dist; result = curr_nearest_point; } @@ -129,34 +125,28 @@ public FloatPoint nearest_point_approx(FloatPoint p_from_point) return result; } - public PolylineArea translate_by(Vector p_vector) - { - if (p_vector.equals(Vector.ZERO)) - { + public PolylineArea translate_by(Vector p_vector) { + if (p_vector.equals(Vector.ZERO)) { return this; } PolylineShape translated_border = border_shape.translate_by(p_vector); PolylineShape[] translated_holes = new PolylineShape[hole_arr.length]; - for (int i = 0; i < hole_arr.length; ++i) - { + for (int i = 0; i < hole_arr.length; ++i) { translated_holes[i] = hole_arr[i].translate_by(p_vector); } return new PolylineArea(translated_border, translated_holes); } - public FloatPoint[] corner_approx_arr() - { + public FloatPoint[] corner_approx_arr() { int corner_count = border_shape.border_line_count(); - for (int i = 0; i < hole_arr.length; ++i) - { + for (int i = 0; i < hole_arr.length; ++i) { corner_count += hole_arr[i].border_line_count(); } FloatPoint[] result = new FloatPoint[corner_count]; FloatPoint[] curr_corner_arr = border_shape.corner_approx_arr(); System.arraycopy(curr_corner_arr, 0, result, 0, curr_corner_arr.length); int dest_pos = curr_corner_arr.length; - for (int i = 0; i < hole_arr.length; ++i) - { + for (int i = 0; i < hole_arr.length; ++i) { curr_corner_arr = hole_arr[i].corner_approx_arr(); System.arraycopy(curr_corner_arr, 0, result, dest_pos, curr_corner_arr.length); dest_pos += curr_corner_arr.length; @@ -170,8 +160,7 @@ public FloatPoint[] corner_approx_arr() * used in the result pieces. It can be made exact, if Polylines are returned * instead of Polygons, so that no intersection points are needed in the result. */ - public TileShape[] split_to_convex() - { + public TileShape[] split_to_convex() { return split_to_convex(null); } @@ -180,44 +169,34 @@ public TileShape[] split_to_convex() * The result is not exact, because rounded intersections of lines are * used in the result pieces. It can be made exact, if Polylines are returned * instead of Polygons, so that no intersection points are needed in the result. - * If p_stoppable_thread != null, this function can be interrupted. + * If p_stoppable_thread != null, this function can be interrupted. */ - public TileShape[] split_to_convex(net.freerouting.datastructures.Stoppable p_stoppable_thread) - { - if (precalculated_convex_pieces == null) - { + public TileShape[] split_to_convex(net.freerouting.datastructures.Stoppable p_stoppable_thread) { + if (precalculated_convex_pieces == null) { TileShape[] convex_border_pieces = border_shape.split_to_convex(); - if (convex_border_pieces == null) - { + if (convex_border_pieces == null) { // split failed return null; } Collection curr_piece_list = new LinkedList(); - for (int i = 0; i < convex_border_pieces.length; ++i) - { + for (int i = 0; i < convex_border_pieces.length; ++i) { curr_piece_list.add(convex_border_pieces[i]); } - for (int i = 0; i < hole_arr.length; ++i) - { - if (hole_arr[i].dimension() < 2) - { + for (int i = 0; i < hole_arr.length; ++i) { + if (hole_arr[i].dimension() < 2) { System.out.println("PolylineArea. split_to_convex: dimennsion 2 for hole expected"); continue; } TileShape[] convex_hole_pieces = hole_arr[i].split_to_convex(); - if (convex_hole_pieces == null) - { + if (convex_hole_pieces == null) { return null; } - for (int j = 0; j < convex_hole_pieces.length; ++j) - { + for (int j = 0; j < convex_hole_pieces.length; ++j) { TileShape curr_hole_piece = convex_hole_pieces[j]; Collection new_piece_list = new LinkedList(); Iterator it = curr_piece_list.iterator(); - while (it.hasNext()) - { - if (p_stoppable_thread != null && p_stoppable_thread.is_stop_requested()) - { + while (it.hasNext()) { + if (p_stoppable_thread != null && p_stoppable_thread.is_stop_requested()) { return null; } TileShape curr_divide_piece = it.next(); @@ -228,74 +207,48 @@ public TileShape[] split_to_convex(net.freerouting.datastructures.Stoppable p_st } precalculated_convex_pieces = new TileShape[curr_piece_list.size()]; Iterator it = curr_piece_list.iterator(); - for (int i = 0; i < precalculated_convex_pieces.length; ++i) - { + for (int i = 0; i < precalculated_convex_pieces.length; ++i) { precalculated_convex_pieces[i] = it.next(); } } return precalculated_convex_pieces; } - public PolylineArea turn_90_degree(int p_factor, IntPoint p_pole) - { + public PolylineArea turn_90_degree(int p_factor, IntPoint p_pole) { PolylineShape new_border = border_shape.turn_90_degree(p_factor, p_pole); PolylineShape[] new_hole_arr = new PolylineShape[hole_arr.length]; - for (int i = 0; i < new_hole_arr.length; ++i) - { + for (int i = 0; i < new_hole_arr.length; ++i) { new_hole_arr[i] = hole_arr[i].turn_90_degree(p_factor, p_pole); } return new PolylineArea(new_border, new_hole_arr); } - public PolylineArea rotate_approx(double p_angle, FloatPoint p_pole) - { + public PolylineArea rotate_approx(double p_angle, FloatPoint p_pole) { PolylineShape new_border = border_shape.rotate_approx(p_angle, p_pole); PolylineShape[] new_hole_arr = new PolylineShape[hole_arr.length]; - for (int i = 0; i < new_hole_arr.length; ++i) - { + for (int i = 0; i < new_hole_arr.length; ++i) { new_hole_arr[i] = hole_arr[i].rotate_approx(p_angle, p_pole); } return new PolylineArea(new_border, new_hole_arr); } - public PolylineArea mirror_vertical(IntPoint p_pole) - { + public PolylineArea mirror_vertical(IntPoint p_pole) { PolylineShape new_border = border_shape.mirror_vertical(p_pole); PolylineShape[] new_hole_arr = new PolylineShape[hole_arr.length]; - for (int i = 0; i < new_hole_arr.length; ++i) - { + for (int i = 0; i < new_hole_arr.length; ++i) { new_hole_arr[i] = hole_arr[i].mirror_vertical(p_pole); } return new PolylineArea(new_border, new_hole_arr); } - public PolylineArea mirror_horizontal(IntPoint p_pole) - { + public PolylineArea mirror_horizontal(IntPoint p_pole) { PolylineShape new_border = border_shape.mirror_horizontal(p_pole); PolylineShape[] new_hole_arr = new PolylineShape[hole_arr.length]; - for (int i = 0; i < new_hole_arr.length; ++i) - { + for (int i = 0; i < new_hole_arr.length; ++i) { new_hole_arr[i] = hole_arr[i].mirror_horizontal(p_pole); } return new PolylineArea(new_border, new_hole_arr); } - - static private void cutout_hole_piece(TileShape p_divide_piece, TileShape p_hole_piece, - Collection p_result_pieces) - { - TileShape[] result_pieces = p_divide_piece.cutout(p_hole_piece); - for (int i = 0; i < result_pieces.length; ++i) - { - TileShape curr_piece = result_pieces[i]; - if (curr_piece.dimension() == 2) - { - p_result_pieces.add(curr_piece); - } - } - } - final PolylineShape border_shape; - final PolylineShape[] hole_arr; - transient private TileShape[] precalculated_convex_pieces = null; } diff --git a/src/main/java/net/freerouting/geometry/planar/PolylineShape.java b/src/main/java/net/freerouting/geometry/planar/PolylineShape.java index 0355389b..7279f8ea 100644 --- a/src/main/java/net/freerouting/geometry/planar/PolylineShape.java +++ b/src/main/java/net/freerouting/geometry/planar/PolylineShape.java @@ -28,20 +28,19 @@ * Abstract class with functions for shapes, whose borders consist * ob straight lines. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public abstract class PolylineShape implements Shape, java.io.Serializable -{ +public abstract class PolylineShape implements Shape, java.io.Serializable { /** * returns true, if the the shape has no infinite part at this corner */ public abstract boolean corner_is_bounded(int p_no); - + /** * Returns the number of border lines of the shape */ public abstract int border_line_count(); - + /** * Returns the p_no-th corner of this shape for * p_no between 0 and border_line_count() - 1. @@ -52,133 +51,118 @@ public abstract class PolylineShape implements Shape, java.io.Serializable * Consecutive corners may be equal. */ public abstract Point corner(int p_no); - + /** * Turns this shape by p_factor times 90 degree around p_pole. */ public abstract PolylineShape turn_90_degree(int p_factor, IntPoint p_pole); - + /** * Rotates this shape around p_pole by p_angle. * The result may be not exact. */ public abstract PolylineShape rotate_approx(double p_angle, FloatPoint p_pole); - + /** * Mirrors this shape at the horizontal line through p_pole. */ public abstract PolylineShape mirror_horizontal(IntPoint p_pole); - - + + /** * Mirrors this shape at the vertical line through p_pole. */ public abstract PolylineShape mirror_vertical(IntPoint p_pole); - + /** * Returns the affine translation of the area by p_vector */ public abstract PolylineShape translate_by(Vector p_vector); - + /** * Return all unbounded cornersw of this shape. */ - public Point [] bounded_corners() - { + public Point[] bounded_corners() { int corner_count = this.border_line_count(); Collection result_list = new LinkedList(); - for (int i = 0; i < corner_count; ++i) - { - if (this.corner_is_bounded(i)) - { + for (int i = 0; i < corner_count; ++i) { + if (this.corner_is_bounded(i)) { result_list.add(this.corner(i)); } } Point[] result = new Point[result_list.size()]; Iterator it = result_list.iterator(); - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = it.next(); } return result; } - + /** * Returns an approximation of the p_no-th corner of this shape * for p_no between 0 and border_line_count() - 1. * If the shape is not bounded at this corner, the * coordinates of the result will be set to Integer.MAX_VALUE. */ - public FloatPoint corner_approx(int p_no) - { + public FloatPoint corner_approx(int p_no) { return corner(p_no).to_float(); } - - + + /** * Returns an approximation of the all corners of this shape. * If the shape is not bounded at a corner, the * coordinates will be set to Integer.MAX_VALUE. */ - public FloatPoint [] corner_approx_arr() - { + public FloatPoint[] corner_approx_arr() { int corner_count = this.border_line_count(); - FloatPoint [] result = new FloatPoint [corner_count]; - for (int i = 0; i < corner_count; ++i) - { + FloatPoint[] result = new FloatPoint[corner_count]; + for (int i = 0; i < corner_count; ++i) { result[i] = this.corner_approx(i); } return result; } - + /** * If p_point is equal to a corner of this shape, the number * of that corner is returned; -1 otherwise. */ - public int equals_corner(Point p_point) - { - for (int i = 0; i < border_line_count(); ++i) - { - if (p_point.equals(corner(i))) - { + public int equals_corner(Point p_point) { + for (int i = 0; i < border_line_count(); ++i) { + if (p_point.equals(corner(i))) { return i; } } return -1; } - + /** * Returns the cumulative border line length of the shape. * If the shape is unbounded, Integer.MAX_VALUE is returned. */ - public double circumference() - { - if (!is_bounded()) - { + public double circumference() { + if (!is_bounded()) { return Integer.MAX_VALUE; } int corner_count = border_line_count(); double result = 0; FloatPoint prev_corner = corner_approx(corner_count - 1); - for (int i = 0; i < corner_count; ++i) - { + for (int i = 0; i < corner_count; ++i) { FloatPoint curr_corner = corner_approx(i); result += curr_corner.distance(prev_corner); prev_corner = curr_corner; } return result; } - + /** * Returns the arithmetic middle of the corners of this shape */ - public FloatPoint centre_of_gravity() - { + public FloatPoint centre_of_gravity() { int corner_count = border_line_count(); double x = 0; double y = 0; - for (int i = 0; i < corner_count; ++i) - { + for (int i = 0; i < corner_count; ++i) { FloatPoint curr_point = corner_approx(i); x += curr_point.x; y += curr_point.y; @@ -187,197 +171,163 @@ public FloatPoint centre_of_gravity() y /= corner_count; return new FloatPoint(x, y); } - + /** * checks, if this shape is completely contained in p_box. */ - public boolean is_contained_in(IntBox p_box) - { + public boolean is_contained_in(IntBox p_box) { return p_box.contains(bounding_box()); } - + /** * Returns the index of the corner of the shape, so that all * other points of the shape are to the right of the line * from p_from_point to this corner */ - public int index_of_left_most_corner(FloatPoint p_from_point) - { + public int index_of_left_most_corner(FloatPoint p_from_point) { FloatPoint left_most_corner = corner_approx(0); int corner_count = border_line_count(); int result = 0; - for (int i = 1; i < corner_count; ++i) - { + for (int i = 1; i < corner_count; ++i) { FloatPoint curr_corner = corner_approx(i); - if (curr_corner.side_of(p_from_point, left_most_corner)== Side.ON_THE_LEFT) - { + if (curr_corner.side_of(p_from_point, left_most_corner) == Side.ON_THE_LEFT) { left_most_corner = curr_corner; result = i; } } return result; } - + /** * Returns the index of the corner of the shape, so that all * other points of the shape are to the left of the line * from p_from_point to this corner */ - public int index_of_right_most_corner(FloatPoint p_from_point) - { + public int index_of_right_most_corner(FloatPoint p_from_point) { FloatPoint right_most_corner = corner_approx(0); int corner_count = border_line_count(); int result = 0; - for (int i = 1; i < corner_count; ++i) - { + for (int i = 1; i < corner_count; ++i) { FloatPoint curr_corner = corner_approx(i); - if (curr_corner.side_of(p_from_point, right_most_corner) == Side.ON_THE_RIGHT) - { + if (curr_corner.side_of(p_from_point, right_most_corner) == Side.ON_THE_RIGHT) { right_most_corner = curr_corner; result = i; } } return result; } - + /** * Returns a FloatLine result, so that result.a is an approximation of * the left most corner of this shape when viewed from p_from_point, * and result.b is an approximation of the right most corner. */ - public FloatLine polar_line_segment(FloatPoint p_from_point) - { - if (this.is_empty()) - { - System.out.println("PolylineShape.polar_line_segment: shape is empty"); - return null; + public FloatLine polar_line_segment(FloatPoint p_from_point) { + if (this.is_empty()) { + System.out.println("PolylineShape.polar_line_segment: shape is empty"); + return null; } FloatPoint left_most_corner = corner_approx(0); FloatPoint right_most_corner = corner_approx(0); int corner_count = border_line_count(); - for (int i = 1; i < corner_count; ++i) - { + for (int i = 1; i < corner_count; ++i) { FloatPoint curr_corner = corner_approx(i); - if (curr_corner.side_of(p_from_point, right_most_corner) == Side.ON_THE_RIGHT) - { + if (curr_corner.side_of(p_from_point, right_most_corner) == Side.ON_THE_RIGHT) { right_most_corner = curr_corner; } - if (curr_corner.side_of(p_from_point, left_most_corner)== Side.ON_THE_LEFT) - { + if (curr_corner.side_of(p_from_point, left_most_corner) == Side.ON_THE_LEFT) { left_most_corner = curr_corner; } } return new FloatLine(left_most_corner, right_most_corner); } - + /** * Returns the p_no-th border line of this shape. */ public abstract Line border_line(int p_no); - + /** * Returns the previos border line or corner number of this shape. */ - public int prev_no(int p_no) - { + public int prev_no(int p_no) { int result; - if (p_no == 0) - { + if (p_no == 0) { result = border_line_count() - 1; - } - else - { + } else { result = p_no - 1; } return result; } - + /** * Returns the next border line or corner number of this shape. */ - public int next_no(int p_no) - { + public int next_no(int p_no) { int result; - if (p_no == border_line_count() - 1) - { + if (p_no == border_line_count() - 1) { result = 0; - } - else - { + } else { result = p_no + 1; } return result; } - - public PolylineShape get_border() - { + + public PolylineShape get_border() { return this; } - - public Shape[] get_holes() - { + + public Shape[] get_holes() { return new Shape[0]; } - - + + /** * Checks, if this shape and p_line have a common point. */ - public boolean intersects(Line p_line) - { + public boolean intersects(Line p_line) { Side side_of_first_corner = p_line.side_of(corner(0)); - if (side_of_first_corner == Side.COLLINEAR) - { + if (side_of_first_corner == Side.COLLINEAR) { return true; } - for (int i = 1; i < this.border_line_count(); ++i) - { - if (p_line.side_of(corner(i)) != side_of_first_corner) - { + for (int i = 1; i < this.border_line_count(); ++i) { + if (p_line.side_of(corner(i)) != side_of_first_corner) { return true; } } return false; } - + /** * Calculates the left most corner of this shape, when looked at from p_from_point. */ - public Point left_most_corner(Point p_from_point) - { - if (this.is_empty()) - { + public Point left_most_corner(Point p_from_point) { + if (this.is_empty()) { return p_from_point; } Point result = this.corner(0); int corner_count = this.border_line_count(); - for (int i = 1; i < corner_count; ++i) - { + for (int i = 1; i < corner_count; ++i) { Point curr_corner = this.corner(i); - if (curr_corner.side_of(p_from_point, result) == Side.ON_THE_LEFT) - { + if (curr_corner.side_of(p_from_point, result) == Side.ON_THE_LEFT) { result = curr_corner; } } return result; } - + /** * Calculates the left most corner of this shape, when looked at from p_from_point. */ - public Point right_most_corner(Point p_from_point) - { - if (this.is_empty()) - { + public Point right_most_corner(Point p_from_point) { + if (this.is_empty()) { return p_from_point; } Point result = this.corner(0); int corner_count = this.border_line_count(); - for (int i = 1; i < corner_count; ++i) - { + for (int i = 1; i < corner_count; ++i) { Point curr_corner = this.corner(i); - if (curr_corner.side_of(p_from_point, result) == Side.ON_THE_RIGHT) - { + if (curr_corner.side_of(p_from_point, result) == Side.ON_THE_RIGHT) { result = curr_corner; } } diff --git a/src/main/java/net/freerouting/geometry/planar/RationalPoint.java b/src/main/java/net/freerouting/geometry/planar/RationalPoint.java index 1a09ece5..96ab5b31 100644 --- a/src/main/java/net/freerouting/geometry/planar/RationalPoint.java +++ b/src/main/java/net/freerouting/geometry/planar/RationalPoint.java @@ -19,12 +19,12 @@ */ package net.freerouting.geometry.planar; -import java.math.BigInteger; import net.freerouting.datastructures.BigIntAux; +import java.math.BigInteger; + /** - * * Implementation of points in the projective plane represented by * 3 coordinates x, y, z, which are infinite precision integers. * Two projective points (x1, y1, z1) and (x2, y2 z2) are equal, @@ -41,66 +41,83 @@ * @author Alfons Wirtz */ -public class RationalPoint extends Point implements java.io.Serializable -{ - +public class RationalPoint extends Point implements java.io.Serializable { + + final BigInteger x; + final BigInteger y; + final BigInteger z; + + /** + * creates a RetionalPoint from 3 BigIntegers p_x, p_y and p_z. + * They represent the 2-dimensinal point with the + * rational number Tuple ( p_x / p_z , p_y / p_z). + * Throws IllegalArgumentException if denominator p_z is <= 0 + */ + RationalPoint(BigInteger p_x, BigInteger p_y, BigInteger p_z) { + x = p_x; + y = p_y; + z = p_z; + if (p_z.signum() < 0) { + throw new IllegalArgumentException + ("RationalPoint: p_z is expected to be >= 0"); + } + } + + /** + * creates a RetionalPoint from an IntPoint + */ + RationalPoint(IntPoint p_point) { + x = BigInteger.valueOf(p_point.x); + y = BigInteger.valueOf(p_point.y); + z = BigInteger.ONE; + } + /** * approximates the coordinates of this point by float coordinates */ - public FloatPoint to_float() - { + public FloatPoint to_float() { double xd = x.doubleValue(); double yd = y.doubleValue(); double zd = z.doubleValue(); - if (zd == 0) - { + if (zd == 0) { xd = Float.MAX_VALUE; yd = Float.MAX_VALUE; - } - else - { + } else { xd /= zd; yd /= zd; } - - return new FloatPoint( xd, yd); + + return new FloatPoint(xd, yd); } - + /** * returns true, if this RationalPoint is equal to p_ob */ - public final boolean equals( Object p_ob ) - { - if ( this == p_ob ) - { + public final boolean equals(Object p_ob) { + if (this == p_ob) { return true; } - if ( p_ob == null ) - { + if (p_ob == null) { return false; } - if ( getClass() != p_ob.getClass() ) - { - return false ; + if (getClass() != p_ob.getClass()) { + return false; } - RationalPoint other = (RationalPoint)p_ob; + RationalPoint other = (RationalPoint) p_ob; BigInteger det = BigIntAux.determinant(x, other.x, z, other.z); - if (det.signum() != 0) - { + if (det.signum() != 0) { return false; } det = BigIntAux.determinant(y, other.y, z, other.z); - + return (det.signum() == 0); } - - public boolean is_infinite() - { + + public boolean is_infinite() { return z.signum() == 0; } - - public IntBox surrounding_box() - { + + public IntBox surrounding_box() { FloatPoint fp = to_float(); int llx = (int) Math.floor(fp.x); int lly = (int) Math.floor(fp.y); @@ -108,75 +125,65 @@ public IntBox surrounding_box() int ury = (int) Math.ceil(fp.y); return new IntBox(llx, lly, urx, ury); } - - public IntOctagon surrounding_octagon() - { + + public IntOctagon surrounding_octagon() { FloatPoint fp = to_float(); int lx = (int) Math.floor(fp.x); int ly = (int) Math.floor(fp.y); int rx = (int) Math.ceil(fp.x); int uy = (int) Math.ceil(fp.y); - + double tmp = fp.x - fp.y; int ulx = (int) Math.floor(tmp); int lrx = (int) Math.ceil(tmp); - + tmp = fp.x + fp.y; int llx = (int) Math.floor(tmp); int urx = (int) Math.ceil(tmp); return new IntOctagon(lx, ly, rx, uy, ulx, lrx, llx, urx); } - - public boolean is_contained_in(IntBox p_box) - { + + public boolean is_contained_in(IntBox p_box) { BigInteger tmp = BigInteger.valueOf(p_box.ll.x).multiply(z); - if (x.compareTo(tmp) < 0) - { + if (x.compareTo(tmp) < 0) { return false; } tmp = BigInteger.valueOf(p_box.ll.y).multiply(z); - if (y.compareTo(tmp) < 0) - { + if (y.compareTo(tmp) < 0) { return false; } tmp = BigInteger.valueOf(p_box.ur.x).multiply(z); - if (x.compareTo(tmp) > 0) - { + if (x.compareTo(tmp) > 0) { return false; } tmp = BigInteger.valueOf(p_box.ur.y).multiply(z); - if (y.compareTo(tmp) > 0) - { + if (y.compareTo(tmp) > 0) { return false; } return true; } - + /** * returns the translation of this point by p_vector */ - public Point translate_by(Vector p_vector) - { - if (p_vector.equals(Vector.ZERO)) - { + public Point translate_by(Vector p_vector) { + if (p_vector.equals(Vector.ZERO)) { return this; } - return p_vector.add_to(this) ; + return p_vector.add_to(this); } - - Point translate_by(IntVector p_vector) - { + + Point translate_by(IntVector p_vector) { RationalVector vector = new RationalVector(p_vector); - return translate_by(vector); + return translate_by(vector); } - - Point translate_by(RationalVector p_vector) - { + + Point translate_by(RationalVector p_vector) { BigInteger v1[] = new BigInteger[3]; v1[0] = x; v1[1] = y; v1[2] = z; - + BigInteger v2[] = new BigInteger[3]; v2[0] = p_vector.x; v2[1] = p_vector.y; @@ -184,29 +191,26 @@ Point translate_by(RationalVector p_vector) BigInteger[] result = BigIntAux.add_rational_coordinates(v1, v2); return new RationalPoint(result[0], result[1], result[2]); } - + /** * returns the difference vector of this point and p_other */ - public Vector difference_by(Point p_other) - { - Vector tmp = p_other.difference_by(this); + public Vector difference_by(Point p_other) { + Vector tmp = p_other.difference_by(this); return tmp.negate(); } - - Vector difference_by(IntPoint p_other) - { + + Vector difference_by(IntPoint p_other) { RationalPoint other = new RationalPoint(p_other); return difference_by(other); } - - Vector difference_by(RationalPoint p_other) - { + + Vector difference_by(RationalPoint p_other) { BigInteger v1[] = new BigInteger[3]; v1[0] = x; v1[1] = y; v1[2] = z; - + BigInteger v2[] = new BigInteger[3]; v2[0] = p_other.x.negate(); v2[1] = p_other.y.negate(); @@ -214,71 +218,64 @@ Vector difference_by(RationalPoint p_other) BigInteger[] result = BigIntAux.add_rational_coordinates(v1, v2); return new RationalVector(result[0], result[1], result[2]); } - + /** * The function returns - * Side.ON_THE_LEFT, if this Point is on the left - * of the line from p_1 to p_2; - * Side.ON_THE_RIGHT, if this Point is on the right - * f the line from p_1 to p_2; - * and Side.COLLINEAR, if this Point is collinear with p_1 and p_2. + * Side.ON_THE_LEFT, if this Point is on the left + * of the line from p_1 to p_2; + * Side.ON_THE_RIGHT, if this Point is on the right + * f the line from p_1 to p_2; + * and Side.COLLINEAR, if this Point is collinear with p_1 and p_2. */ - public Side side_of(Point p_1, Point p_2) - { + public Side side_of(Point p_1, Point p_2) { Vector v1 = difference_by(p_1); Vector v2 = p_2.difference_by(p_1); return v1.side_of(v2); } - - public Side side_of(Line p_line) - { + + public Side side_of(Line p_line) { return side_of(p_line.a, p_line.b); } - - public Point perpendicular_projection(Line p_line) - { + + public Point perpendicular_projection(Line p_line) { // this function is at the moment only implemented for lines // consisting of IntPoints. // The general implementation is still missing. - IntVector v = (IntVector)p_line.b.difference_by(p_line.a); - BigInteger vxvx = BigInteger.valueOf((long)v.x * v.x); - BigInteger vyvy = BigInteger.valueOf((long)v.y * v.y); + IntVector v = (IntVector) p_line.b.difference_by(p_line.a); + BigInteger vxvx = BigInteger.valueOf((long) v.x * v.x); + BigInteger vyvy = BigInteger.valueOf((long) v.y * v.y); BigInteger vxvy = BigInteger.valueOf((long) v.x * v.y); BigInteger denominator = vxvx.add(vyvy); BigInteger det = - BigInteger.valueOf(((IntPoint)p_line.a).determinant((IntPoint)p_line.b)); - + BigInteger.valueOf(((IntPoint) p_line.a).determinant((IntPoint) p_line.b)); + BigInteger tmp1 = vxvx.multiply(x); BigInteger tmp2 = vxvy.multiply(y); tmp1 = tmp1.add(tmp2); tmp2 = det.multiply(BigInteger.valueOf(v.y)); tmp2 = tmp2.multiply(z); BigInteger proj_x = tmp1.add(tmp2); - + tmp1 = vxvy.multiply(x); tmp2 = vyvy.multiply(y); tmp1 = tmp1.add(tmp2); tmp2 = det.multiply(BigInteger.valueOf(v.x)); tmp2 = tmp2.multiply(z); BigInteger proj_y = tmp1.add(tmp2); - + int signum = denominator.signum(); - if (signum != 0) - { - if (signum < 0) - { + if (signum != 0) { + if (signum < 0) { denominator = denominator.negate(); proj_x = proj_x.negate(); proj_y = proj_y.negate(); } if ((proj_x.mod(denominator)).signum() == 0 && - (proj_y.mod(denominator)).signum() == 0) - { + (proj_y.mod(denominator)).signum() == 0) { proj_x = proj_x.divide(denominator); proj_y = proj_y.divide(denominator); if (proj_x.abs().compareTo(Limits.CRIT_INT_BIG) <= 0 - && proj_y.abs().compareTo(Limits.CRIT_INT_BIG) <= 0) - { + && proj_y.abs().compareTo(Limits.CRIT_INT_BIG) <= 0) { return new IntPoint(proj_x.intValue(), proj_y.intValue()); } denominator = BigInteger.ONE; @@ -286,78 +283,37 @@ public Point perpendicular_projection(Line p_line) } return new RationalPoint(proj_x, proj_y, denominator); } - - public int compare_x(Point p_other) - { + + public int compare_x(Point p_other) { return -p_other.compare_x(this); } - - - public int compare_y(Point p_other) - { + + public int compare_y(Point p_other) { return -p_other.compare_y(this); } - - int compare_x(RationalPoint p_other) - { + + int compare_x(RationalPoint p_other) { BigInteger tmp1 = this.x.multiply(p_other.z); BigInteger tmp2 = p_other.x.multiply(this.z); return tmp1.compareTo(tmp2); } - - int compare_y(RationalPoint p_other) - { + + int compare_y(RationalPoint p_other) { BigInteger tmp1 = this.y.multiply(p_other.z); BigInteger tmp2 = p_other.y.multiply(this.z); return tmp1.compareTo(tmp2); } - - int compare_x(IntPoint p_other) - { + + int compare_x(IntPoint p_other) { BigInteger tmp1 = this.z.multiply(BigInteger.valueOf(p_other.x)); return this.x.compareTo(tmp1); } - - int compare_y(IntPoint p_other) - { + + int compare_y(IntPoint p_other) { BigInteger tmp1 = this.z.multiply(BigInteger.valueOf(p_other.y)); return this.y.compareTo(tmp1); - - } - - /** - * creates a RetionalPoint from 3 BigIntegers p_x, p_y and p_z. - * They represent the 2-dimensinal point with the - * rational number Tuple ( p_x / p_z , p_y / p_z). - * Throws IllegalArgumentException if denominator p_z is <= 0 - */ - RationalPoint(BigInteger p_x, BigInteger p_y, BigInteger p_z) - { - x = p_x; - y = p_y; - z = p_z; - if (p_z.signum() < 0) - { - throw new IllegalArgumentException - ("RationalPoint: p_z is expected to be >= 0"); - } - } - - /** - * creates a RetionalPoint from an IntPoint - */ - RationalPoint(IntPoint p_point) - { - x = BigInteger.valueOf(p_point.x); - y = BigInteger.valueOf(p_point.y); - z = BigInteger.ONE; + } - - - - final BigInteger x; - final BigInteger y; - final BigInteger z; - - + + } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/RationalVector.java b/src/main/java/net/freerouting/geometry/planar/RationalVector.java index f93e42f7..569e640e 100644 --- a/src/main/java/net/freerouting/geometry/planar/RationalVector.java +++ b/src/main/java/net/freerouting/geometry/planar/RationalVector.java @@ -19,268 +19,236 @@ */ package net.freerouting.geometry.planar; -import java.math.BigInteger; import net.freerouting.datastructures.BigIntAux; import net.freerouting.datastructures.Signum; +import java.math.BigInteger; + /** - * * Analog RationalPoint, but implementing the functionality * of a Vector instead of the functionality of a Point. * * @author Alfons Wirtz */ -public class RationalVector extends Vector implements java.io.Serializable -{ +public class RationalVector extends Vector implements java.io.Serializable { + public final BigInteger x; + public final BigInteger y; + public final BigInteger z; + /** - * creates a RetionalVector from 3 BigIntegers p_x, p_y and p_z. - * They represent the 2-dimensional Vector with the - * rational number Tuple ( p_x / p_z , p_y / p_z). + * creates a RetionalVector from 3 BigIntegers p_x, p_y and p_z. + * They represent the 2-dimensional Vector with the + * rational number Tuple ( p_x / p_z , p_y / p_z). */ - public RationalVector(BigInteger p_x, BigInteger p_y, BigInteger p_z) - { - if (p_z.signum() >= 0) - { + public RationalVector(BigInteger p_x, BigInteger p_y, BigInteger p_z) { + if (p_z.signum() >= 0) { x = p_x; y = p_y; z = p_z; - - } - else - { + + } else { x = p_x.negate(); y = p_y.negate(); z = p_z.negate(); - } + } } - + /** * creates a RetionalVector from an IntVector */ - RationalVector(IntVector p_vector) - { + RationalVector(IntVector p_vector) { x = BigInteger.valueOf(p_vector.x); y = BigInteger.valueOf(p_vector.y); z = BigInteger.ONE; } - + /** * returns true, if the x and y coordinates of this vector are 0 */ - public final boolean is_zero() - { + public final boolean is_zero() { return x.signum() == 0 && y.signum() == 0; } - + /** * returns true, if this RationalVector is equal to p_ob */ - public final boolean equals( Object p_ob ) - { - if ( this == p_ob ) - { + public final boolean equals(Object p_ob) { + if (this == p_ob) { return true; } - if ( p_ob == null ) - { + if (p_ob == null) { return false; } - if ( getClass() != p_ob.getClass() ) - { - return false ; + if (getClass() != p_ob.getClass()) { + return false; } - RationalPoint other = (RationalPoint)p_ob; + RationalPoint other = (RationalPoint) p_ob; BigInteger det = BigIntAux.determinant(x, other.x, z, other.z); - if (det.signum() != 0) - { + if (det.signum() != 0) { return false; } det = BigIntAux.determinant(y, other.y, z, other.z); - + return (det.signum() == 0); } - + /** * returns the Vector such that this plus this.minus() is zero */ - public Vector negate() - { + public Vector negate() { return new RationalVector(x.negate(), y.negate(), z); } - + /** * adds p_other to this vector */ - public final Vector add( Vector p_other) - { + public final Vector add(Vector p_other) { return p_other.add(this); } - + /** * Let L be the line from the Zero Vector to p_other. * The function returns - * Side.ON_THE_LEFT, if this Vector is on the left of L - * Side.ON_THE_RIGHT, if this Vector is on the right of L - * and Side.COLLINEAR, if this Vector is collinear with L. + * Side.ON_THE_LEFT, if this Vector is on the left of L + * Side.ON_THE_RIGHT, if this Vector is on the right of L + * and Side.COLLINEAR, if this Vector is collinear with L. */ - public Side side_of(Vector p_other) - { + public Side side_of(Vector p_other) { Side tmp = p_other.side_of(this); return tmp.negate(); } - - public boolean is_orthogonal() - { + + public boolean is_orthogonal() { return (x.signum() == 0 || y.signum() == 0); } - - public boolean is_diagonal() - { + + public boolean is_diagonal() { return x.abs().equals(y.abs()); } - - + /** * The function returns - * Signum.POSITIVE, if the scalar product of this vector and p_other > 0, - * Signum.NEGATIVE, if the scalar product is < 0, - * and Signum.ZERO, if the scalar product is equal 0. + * Signum.POSITIVE, if the scalar product of this vector and p_other > 0, + * Signum.NEGATIVE, if the scalar product is < 0, + * and Signum.ZERO, if the scalar product is equal 0. */ - public Signum projection(Vector p_other) - { + public Signum projection(Vector p_other) { return p_other.projection(this); } - + /** * calculates the scalar product of this vector and p_other */ - public double scalar_product(Vector p_other) - { + public double scalar_product(Vector p_other) { return p_other.scalar_product(this); } - + /** * approximates the coordinates of this vector by float coordinates */ - public FloatPoint to_float() - { + public FloatPoint to_float() { double xd = x.doubleValue(); double yd = y.doubleValue(); double zd = z.doubleValue(); - return new FloatPoint( xd / zd, yd / zd); + return new FloatPoint(xd / zd, yd / zd); } - - public Vector change_length_approx(double p_lenght) - { + + public Vector change_length_approx(double p_lenght) { System.out.println("RationalVector: change_length_approx not yet implemented"); return this; } - - public Vector turn_90_degree(int p_factor) - { + + public Vector turn_90_degree(int p_factor) { int n = p_factor; - while (n < 0) - { + while (n < 0) { n += 4; } - while (n >= 4) - { + while (n >= 4) { n -= 4; } - BigInteger new_x ; - BigInteger new_y ; - switch (n) - { + BigInteger new_x; + BigInteger new_y; + switch (n) { case 0: // 0 degree new_x = x; new_y = y; break; case 1: // 90 degree new_x = y.negate(); - new_y = x ; + new_y = x; break; case 2: // 180 degree - new_x = x.negate() ; - new_y = y.negate() ; + new_x = x.negate(); + new_y = y.negate(); break; case 3: // 270 degree - new_x = y ; - new_y = x.negate() ; + new_x = y; + new_y = x.negate(); break; default: return this; } return new RationalVector(new_x, new_y, this.z); } - - public Vector mirror_at_y_axis() - { + + public Vector mirror_at_y_axis() { return new RationalVector(this.x.negate(), this.y, this.z); } - - public Vector mirror_at_x_axis() - { + + public Vector mirror_at_x_axis() { return new RationalVector(this.x, this.y.negate(), this.z); } - - Direction to_normalized_direction() - { + + Direction to_normalized_direction() { BigInteger dx = x; BigInteger dy = y; BigInteger gcd = dx.gcd(y); dx = dx.divide(gcd); dy = dy.divide(gcd); - if ( (dx.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0 && - (dy.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0 ) - { + if ((dx.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0 && + (dy.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0) { return new IntDirection(dx.intValue(), dy.intValue()); } return new BigIntDirection(dx, dy); } - - double scalar_product(IntVector p_other) - { + + double scalar_product(IntVector p_other) { Vector other = new RationalVector(p_other); return other.scalar_product(this); } - - double scalar_product(RationalVector p_other) - { + + double scalar_product(RationalVector p_other) { FloatPoint v1 = to_float(); FloatPoint v2 = p_other.to_float(); return v1.x * v2.x + v1.y * v2.y; } - - Signum projection(IntVector p_other) - { + + Signum projection(IntVector p_other) { Vector other = new RationalVector(p_other); return other.projection(this); } - - Signum projection(RationalVector p_other) - { + + Signum projection(RationalVector p_other) { BigInteger tmp1 = x.multiply(p_other.x); BigInteger tmp2 = y.multiply(p_other.y); BigInteger tmp3 = tmp1.add(tmp2); int result = tmp3.signum(); return Signum.of(result); } - - final Vector add(IntVector p_other) - { + + final Vector add(IntVector p_other) { RationalVector other = new RationalVector(p_other); return add(other); } - - final Vector add(RationalVector p_other) - { + + final Vector add(RationalVector p_other) { BigInteger v1[] = new BigInteger[3]; v1[0] = x; v1[1] = y; v1[2] = z; - + BigInteger v2[] = new BigInteger[3]; v2[0] = p_other.x; v2[1] = p_other.y; @@ -288,49 +256,40 @@ final Vector add(RationalVector p_other) BigInteger[] result = BigIntAux.add_rational_coordinates(v1, v2); return new RationalVector(result[0], result[1], result[2]); } - - Point add_to(IntPoint p_point) - { + + Point add_to(IntPoint p_point) { BigInteger new_x = z.multiply(BigInteger.valueOf(p_point.x)); new_x = new_x.add(x); - BigInteger new_y = z.multiply(BigInteger.valueOf(p_point.y)); + BigInteger new_y = z.multiply(BigInteger.valueOf(p_point.y)); new_y = new_y.add(y); return new RationalPoint(new_x, new_y, z); } - - Point add_to(RationalPoint p_point) - { + + Point add_to(RationalPoint p_point) { BigInteger v1[] = new BigInteger[3]; v1[0] = x; v1[1] = y; v1[2] = z; - + BigInteger v2[] = new BigInteger[3]; v2[0] = p_point.x; v2[1] = p_point.y; v2[2] = p_point.z; - + BigInteger[] result = BigIntAux.add_rational_coordinates(v1, v2); return new RationalPoint(result[0], result[1], result[2]); } - - Side side_of(IntVector p_other) - { + + Side side_of(IntVector p_other) { RationalVector other = new RationalVector(p_other); return side_of(other); } - - Side side_of(RationalVector p_other) - { + + Side side_of(RationalVector p_other) { BigInteger tmp_1 = y.multiply(p_other.x); BigInteger tmp_2 = x.multiply(p_other.y); BigInteger determinant = tmp_1.subtract(tmp_2); int signum = determinant.signum(); return Side.of(signum); } - - - public final BigInteger x; - public final BigInteger y; - public final BigInteger z; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/RegularTileShape.java b/src/main/java/net/freerouting/geometry/planar/RegularTileShape.java index d5a66ddc..8df1471a 100644 --- a/src/main/java/net/freerouting/geometry/planar/RegularTileShape.java +++ b/src/main/java/net/freerouting/geometry/planar/RegularTileShape.java @@ -21,15 +21,14 @@ package net.freerouting.geometry.planar; /** - * TileShapes whose border lines may have only directions out of - * a fixed set, as for example orthoganal directions, which - * define axis parallel box shapes. - * - * @author Alfons Wirtz + * TileShapes whose border lines may have only directions out of + * a fixed set, as for example orthoganal directions, which + * define axis parallel box shapes. + * + * @author Alfons Wirtz */ -public abstract class RegularTileShape extends TileShape -{ - +public abstract class RegularTileShape extends TileShape { + /** * Compares the edglines of index p_edge_no of this regular TileShape * and p_other. @@ -38,47 +37,52 @@ public abstract class RegularTileShape extends TileShape * and Side.ON_THE_RIGHT, if this edgeline is to the right of the edgeline * of p_other. */ - public abstract Side compare(RegularTileShape p_other, int p_edge_no); - - /** - * calculates the smallest RegularTileShape - * containing this shape and p_other. - */ - public abstract RegularTileShape union(RegularTileShape p_other); - - /** - * returns true, if p_other is completely contained in this shape - */ - public abstract boolean contains (RegularTileShape p_other); - + public abstract Side compare(RegularTileShape p_other, int p_edge_no); + + /** + * calculates the smallest RegularTileShape + * containing this shape and p_other. + */ + public abstract RegularTileShape union(RegularTileShape p_other); + + /** + * returns true, if p_other is completely contained in this shape + */ + public abstract boolean contains(RegularTileShape p_other); + /** * Auxiliary function to implement the same function with parameter * type RegularTileShape. */ - abstract Side compare(IntBox p_other, int p_edge_no); - /** + abstract Side compare(IntBox p_other, int p_edge_no); + + /** * Auxiliary function to implement the same function with parameter * type RegularTileShape. */ - abstract Side compare(IntOctagon p_other, int p_edge_no); - /** + abstract Side compare(IntOctagon p_other, int p_edge_no); + + /** * Auxiliary function to implement the same function with parameter * type RegularTileShape. */ - abstract RegularTileShape union(IntBox p_other); - /** + abstract RegularTileShape union(IntBox p_other); + + /** * Auxiliary function to implement the same function with parameter * type RegularTileShape. */ - abstract RegularTileShape union(IntOctagon p_other); - /** + abstract RegularTileShape union(IntOctagon p_other); + + /** * Auxiliary function to implement the same function with parameter * type RegularTileShape. */ - public abstract boolean is_contained_in (IntBox p_other); - /** + public abstract boolean is_contained_in(IntBox p_other); + + /** * Auxiliary function to implement the same function with parameter * type RegularTileShape. */ - abstract boolean is_contained_in (IntOctagon p_other); + abstract boolean is_contained_in(IntOctagon p_other); } diff --git a/src/main/java/net/freerouting/geometry/planar/Shape.java b/src/main/java/net/freerouting/geometry/planar/Shape.java index 6ac7dc07..59fa2865 100644 --- a/src/main/java/net/freerouting/geometry/planar/Shape.java +++ b/src/main/java/net/freerouting/geometry/planar/Shape.java @@ -24,75 +24,74 @@ * Interface describing functionality for connected 2-dimensional shapes in the plane. * A Shape object is expected to be simply connected, that means, it may not contain holes. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public interface Shape extends Area -{ - +public interface Shape extends Area { + /** * Returns the length of the border of this shape. * If the shape is unbounded, Integer.MAX_VALUE is returned. */ double circumference(); - + /** * Returns the content of the area of the shape. * If the shape is unbounded, Double.MAX_VALUE is returned. */ double area(); - + /** * Returns the gravity point of this shape */ FloatPoint centre_of_gravity(); - + /** * Returns true, if p_point is not contained in the inside or the * boundary of the shape */ boolean is_outside(Point p_point); - + /** * Returns true, if p_point is contained in this shape, * but not on the border. */ boolean contains_inside(Point p_point); - + /** * Returns true, if p_point lies exact on the boundary of the shape */ boolean contains_on_border(Point p_point); - + /** * Returns the distance between p_point and its nearest point * on the shape. 0, if p_point is contained in this shape */ double distance(FloatPoint p_point); - + /** * Return a bounding TileShape of this shape. */ TileShape bounding_tile(); - + /** * Returns the bounding RegularTileShape with the fixed directions p_dirs */ RegularTileShape bounding_shape(ShapeBoundingDirections p_dirs); - + /** * Returns the distance between p_point and its nearest point * on the border of the shape. */ - + double border_distance(FloatPoint p_point); - + /** * Returns the smallest distance from the centre of gravity to the border * of the shape. */ double smallest_radius(); - + /** * Returns the offset shape of this shape by offseting the * boundary by p_distance to the outside. @@ -100,35 +99,38 @@ public interface Shape extends Area * (For example an enlarged IntBox is an IntOctagon). */ Shape enlarge(double p_offset); - + /** * checks, if the this shape and p_other have an nonempty intersection. */ boolean intersects(Shape p_other); - + /** * Cuts out the parts of p_polyline in the interiour of this shape * and returns a list of the remaining pieces of p_polyline. * Pieces completely contained in the border of this shape * are not returned. */ - Polyline [] cutout(Polyline p_polyline); - + Polyline[] cutout(Polyline p_polyline); + /** * Auxiliary function to implement the same function with parameter * type Shape. */ boolean intersects(IntBox p_other); + /** * Auxiliary function to implement the same function with parameter * type Shape. */ boolean intersects(IntOctagon p_other); + /** * Auxiliary function to implement the same function with parameter * type Shape. */ boolean intersects(Simplex p_other); + /** * Auxiliary function to implement the same function with parameter * type Shape. diff --git a/src/main/java/net/freerouting/geometry/planar/ShapeBoundingDirections.java b/src/main/java/net/freerouting/geometry/planar/ShapeBoundingDirections.java index f49a9f66..01a6c8dc 100644 --- a/src/main/java/net/freerouting/geometry/planar/ShapeBoundingDirections.java +++ b/src/main/java/net/freerouting/geometry/planar/ShapeBoundingDirections.java @@ -17,14 +17,12 @@ package net.freerouting.geometry.planar; /** - * * Describing the functionality for the fixed directions of a RegularTileShape. * * @author Alfons Wirtz */ -public interface ShapeBoundingDirections -{ +public interface ShapeBoundingDirections { /** * Retuns the count of the fixed directions. */ @@ -42,21 +40,25 @@ public interface ShapeBoundingDirections * type ConvexShape. */ RegularTileShape bounds(IntBox p_box); + /** * Auxiliary function to implement the same function with parameter * type ConvexShape. */ RegularTileShape bounds(IntOctagon p_oct); + /** * Auxiliary function to implement the same function with parameter * type ConvexShape. */ RegularTileShape bounds(Simplex p_simplex); + /** * Auxiliary function to implement the same function with parameter * type ConvexShape. */ RegularTileShape bounds(Circle p_circle); + /** * Auxiliary function to implement the same function with parameter * type ConvexShape. diff --git a/src/main/java/net/freerouting/geometry/planar/Side.java b/src/main/java/net/freerouting/geometry/planar/Side.java index c723c1f8..c3009aa8 100644 --- a/src/main/java/net/freerouting/geometry/planar/Side.java +++ b/src/main/java/net/freerouting/geometry/planar/Side.java @@ -17,77 +17,58 @@ package net.freerouting.geometry.planar; /** - * * Implementation of an enum class Side with the three values * ON_THE_LEFT, ON_THE_RIGHT, COLLINEAR. * - * @author Alfons Wirtz */ -public class Side -{ - public static final Side ON_THE_LEFT = new Side ("on_the_left"); - public static final Side ON_THE_RIGHT = new Side ("on_the_right"); - public static final Side COLLINEAR = new Side ("collinear"); +public class Side { + public static final Side ON_THE_LEFT = new Side("on_the_left"); + public static final Side ON_THE_RIGHT = new Side("on_the_right"); + public static final Side COLLINEAR = new Side("collinear"); + private final String name; + + private Side(String p_name) { + name = p_name; + } + + /** + * returns ON_THE_LEFT, if p_value < 0, + * ON_THE_RIGHT, if p_value > 0 + * and COLLINEAR, if p_value == 0 + */ + static final Side of(double p_value) { + Side result; + if (p_value > 0) { + result = Side.ON_THE_LEFT; + } else if (p_value < 0) { + result = Side.ON_THE_RIGHT; + } else { + result = Side.COLLINEAR; + } + return result; + } /** * returns the string of this instance */ - public String to_string () - { + public String to_string() { return name; } /** * returns the opposite side of this side */ - public final Side negate() - { + public final Side negate() { Side result; - if (this == ON_THE_LEFT) - { + if (this == ON_THE_LEFT) { result = ON_THE_RIGHT; - } - else if (this == ON_THE_RIGHT) - { + } else if (this == ON_THE_RIGHT) { result = ON_THE_LEFT; - } - else - { + } else { result = this; } return result; } - - /** - * returns ON_THE_LEFT, if p_value < 0, - * ON_THE_RIGHT, if p_value > 0 - * and COLLINEAR, if p_value == 0 - */ - static final Side of(double p_value) - { - Side result; - if (p_value > 0) - { - result = Side.ON_THE_LEFT; - } - else if (p_value < 0) - { - result = Side.ON_THE_RIGHT; - } - else - { - result = Side.COLLINEAR; - } - return result; - } - - - private Side(String p_name) - { - name = p_name; - } - - private final String name; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/Simplex.java b/src/main/java/net/freerouting/geometry/planar/Simplex.java index d51d7cf6..e62d364a 100644 --- a/src/main/java/net/freerouting/geometry/planar/Simplex.java +++ b/src/main/java/net/freerouting/geometry/planar/Simplex.java @@ -21,7 +21,6 @@ import java.util.LinkedList; /** - * * Convex shape defined as intersection of half-planes. * A half-plane is defined as the positive side of a directed line. * @@ -29,25 +28,39 @@ */ -public class Simplex extends TileShape implements java.io.Serializable -{ - +public class Simplex extends TileShape implements java.io.Serializable { + /** * Standard implementation for an empty Simplex. */ - public static final Simplex EMPTY = new Simplex(new Line [0]); - + public static final Simplex EMPTY = new Simplex(new Line[0]); + private final Line[] arr; + /** + * the following fields are for storing precalculated data + */ + transient private Point[] precalculated_corners = null; + transient private FloatPoint[] precalculated_float_corners = null; + transient private IntBox precalculated_bounding_box = null; + transient private IntOctagon precalculated_bounding_octagon = null; + + /** + * Constructs a Simplex from the directed lines in p_line_arr. + * The simplex will not be normalized. + * To get a normalised simplex use TileShape.get_instance + */ + public Simplex(Line[] p_line_arr) { + arr = p_line_arr; + } + /** * creates a Simplex as intersection of the halfplanes defined * by an array of directed lines */ - public static Simplex get_instance(Line[] p_line_arr) - { - if (p_line_arr.length <= 0) - { + public static Simplex get_instance(Line[] p_line_arr) { + if (p_line_arr.length <= 0) { return Simplex.EMPTY; } - Line [] curr_arr = new Line[p_line_arr.length]; + Line[] curr_arr = new Line[p_line_arr.length]; System.arraycopy(p_line_arr, 0, curr_arr, 0, p_line_arr.length); // sort the lines in ascending direction java.util.Arrays.sort(curr_arr); @@ -55,221 +68,173 @@ public static Simplex get_instance(Line[] p_line_arr) Simplex result = curr_simplex.remove_redundant_lines(); return result; } - + /** * Return true, if this simplex is empty */ - public boolean is_empty() - { + public boolean is_empty() { return (arr.length == 0); } - + /** * Converts the physical instance of this shape to a simpler physical instance, if possible. * (For example a Simplex to an IntOctagon). */ - public TileShape simplify() - { + public TileShape simplify() { TileShape result = this; - if (this.is_empty()) - { + if (this.is_empty()) { result = Simplex.EMPTY; - } - else if (this.is_IntBox()) - { + } else if (this.is_IntBox()) { result = this.bounding_box(); - } - else if (this.is_IntOctagon()) - { + } else if (this.is_IntOctagon()) { result = this.to_IntOctagon(); } return result; } - + /** * Returns true, if the determinant of the direction of index * p_no -1 and the direction of index p_no is > 0 */ - public boolean corner_is_bounded(int p_no) - { + public boolean corner_is_bounded(int p_no) { int no; - if (p_no < 0) - { + if (p_no < 0) { System.out.println("corner: p_no is < 0"); no = 0; - } - else if (p_no >= arr.length) - { + } else if (p_no >= arr.length) { System.out.println("corner: p_index must be less than arr.length - 1"); no = arr.length - 1; + } else { + no = p_no; } - else - { - no = p_no; - } - if(arr.length == 1) - { + if (arr.length == 1) { return false; } int prev_no; - if (no == 0) - { + if (no == 0) { prev_no = arr.length - 1; - } - else - { + } else { prev_no = no - 1; } - IntVector prev_dir = (IntVector)arr[prev_no].direction().get_vector(); - IntVector curr_dir = (IntVector)arr[no].direction().get_vector(); + IntVector prev_dir = (IntVector) arr[prev_no].direction().get_vector(); + IntVector curr_dir = (IntVector) arr[no].direction().get_vector(); return (prev_dir.determinant(curr_dir) > 0); } - - + /** * Returns true, if the shape of this simplex is contained in a * sufficiently large box */ - public boolean is_bounded() - { - if (arr.length == 0) - { + public boolean is_bounded() { + if (arr.length == 0) { return true; } - if (arr.length < 3) - { + if (arr.length < 3) { return false; } - for (int i = 0; i < arr.length; ++i) - { - if (!corner_is_bounded(i)) - { + for (int i = 0; i < arr.length; ++i) { + if (!corner_is_bounded(i)) { return false; } } return true; } - + /** * Returns the number of edge lines defining this simplex */ - public int border_line_count() - { + public int border_line_count() { return arr.length; } - + /** * Returns the intersection of the p_no -1-th with the p_no-th line of this simplex. * If the simplex is not bounded at this corner, the * coordinates of the result will be set to Integer.MAX_VALUE. */ - public Point corner(int p_no) - { + public Point corner(int p_no) { int no; - if (p_no < 0) - { + if (p_no < 0) { System.out.println("Simplex.corner: p_no is < 0"); no = 0; - } - else if (p_no >= arr.length) - { + } else if (p_no >= arr.length) { System.out.println("Simplex.corner: p_no must be less than arr.length - 1"); no = arr.length - 1; - } - else - { - no = p_no; + } else { + no = p_no; } if (precalculated_corners == null) - // corner array is not yet allocated + // corner array is not yet allocated { precalculated_corners = new Point[arr.length]; } - if (precalculated_corners [no] == null) - // corner is not yet calculated + if (precalculated_corners[no] == null) + // corner is not yet calculated { Line prev; - if (no == 0) - { + if (no == 0) { prev = arr[arr.length - 1]; - } - else - { + } else { prev = arr[no - 1]; } precalculated_corners[no] = arr[no].intersection(prev); } - return precalculated_corners [no]; + return precalculated_corners[no]; } - + /** * Returns an approximation of the intersection of the p_no -1-th with the * p_no-th line of this simplex by a FloatPoint. * If the simplex is not bounded at this corner, the * coordinates of the result will be set to Integer.MAX_VALUE. */ - public FloatPoint corner_approx(int p_no) - { - if (arr.length <= 0) - { + public FloatPoint corner_approx(int p_no) { + if (arr.length <= 0) { return null; } int no; - if (p_no < 0) - { + if (p_no < 0) { System.out.println("Simplex.corner_approx: p_no is < 0"); no = 0; - } - else if (p_no >= arr.length) - { + } else if (p_no >= arr.length) { System.out.println("Simplex.corner_approx: p_no must be less than arr.length - 1"); no = arr.length - 1; - } - else - { - no = p_no; + } else { + no = p_no; } if (precalculated_float_corners == null) - // corner array is not yet allocated + // corner array is not yet allocated { precalculated_float_corners = new FloatPoint[arr.length]; } - if (precalculated_float_corners [no] == null) - // corner is not yet calculated + if (precalculated_float_corners[no] == null) + // corner is not yet calculated { Line prev; - if (no == 0) - { + if (no == 0) { prev = arr[arr.length - 1]; - } - else - { + } else { prev = arr[no - 1]; } precalculated_float_corners[no] = arr[no].intersection_approx(prev); } - return precalculated_float_corners [no]; + return precalculated_float_corners[no]; } - - public FloatPoint[] corner_approx_arr() - { + + public FloatPoint[] corner_approx_arr() { if (precalculated_float_corners == null) - // corner array is not yet allocated + // corner array is not yet allocated { precalculated_float_corners = new FloatPoint[arr.length]; } - for (int i = 0; i < precalculated_float_corners.length; ++i) - { - if (precalculated_float_corners [i] == null) - // corner is not yet calculated + for (int i = 0; i < precalculated_float_corners.length; ++i) { + if (precalculated_float_corners[i] == null) + // corner is not yet calculated { Line prev; - if (i == 0) - { + if (i == 0) { prev = arr[arr.length - 1]; - } - else - { + } else { prev = arr[i - 1]; } precalculated_float_corners[i] = arr[i].intersection_approx(prev); @@ -277,79 +242,62 @@ public FloatPoint[] corner_approx_arr() } return precalculated_float_corners; } - + /** * returns the p_no-th edge line of this simplex. * The edge lines are sorted in ascending direction. */ - public Line border_line(int p_no) - { - if (arr.length <= 0) - { + public Line border_line(int p_no) { + if (arr.length <= 0) { System.out.println("Simplex.edge_line : simplex is empty"); return null; } int no; - if (p_no < 0) - { + if (p_no < 0) { System.out.println("Simplex.edge_line : p_no is < 0"); no = 0; - } - else if (p_no >= arr.length) - { + } else if (p_no >= arr.length) { System.out.println("Simplex.edge_line: p_no must be less than arr.length - 1"); no = arr.length - 1; - } - else - { - no = p_no; + } else { + no = p_no; } return arr[no]; } - + /** * Returns the dimension of this simplex. * The result may be 2, 1, 0, or -1 (if the simplex is empty). */ - public int dimension() - { - if (arr.length == 0) - { + public int dimension() { + if (arr.length == 0) { return -1; } - if (arr.length > 4) - { + if (arr.length > 4) { return 2; } - if (arr.length == 1) - { + if (arr.length == 1) { // we have a half plane return 2; } - if (arr.length == 2) - { - if(arr[0].overlaps(arr[1])) - { + if (arr.length == 2) { + if (arr[0].overlaps(arr[1])) { return 1; } return 2; } - if (arr.length == 3) - { + if (arr.length == 3) { if (arr[0].overlaps(arr[1]) || arr[0].overlaps(arr[2]) - || arr[1].overlaps(arr[2])) - { + || arr[1].overlaps(arr[2])) { // simplex is 1 dimensional and unbounded at one side return 1; } Point intersection = arr[1].intersection(arr[2]); Side side_of_line0 = arr[0].side_of(intersection); - if(side_of_line0 == Side.ON_THE_RIGHT) - { + if (side_of_line0 == Side.ON_THE_RIGHT) { return 2; } - if (side_of_line0 == Side.ON_THE_LEFT) - { + if (side_of_line0 == Side.ON_THE_LEFT) { System.out.println("empty Simplex not normalized"); return -1; } @@ -360,143 +308,115 @@ public int dimension() // check if opposing lines are collinear boolean collinear_0_2 = arr[0].overlaps(arr[2]); boolean collinear_1_3 = arr[1].overlaps(arr[3]); - if (collinear_0_2 && collinear_1_3) - { + if (collinear_0_2 && collinear_1_3) { return 0; } - if (collinear_0_2 || collinear_1_3) - { + if (collinear_0_2 || collinear_1_3) { return 1; } return 2; } - - public double max_width() - { - if (!this.is_bounded()) - { + + public double max_width() { + if (!this.is_bounded()) { return Integer.MAX_VALUE; } double max_distance = Integer.MIN_VALUE; double max_distance_2 = Integer.MIN_VALUE; - FloatPoint gravity_point = this.centre_of_gravity(); - - for (int i = 0; i < border_line_count(); ++i) - { + FloatPoint gravity_point = this.centre_of_gravity(); + + for (int i = 0; i < border_line_count(); ++i) { double curr_distance = Math.abs(arr[i].signed_distance(gravity_point)); - - if (curr_distance > max_distance) - { + + if (curr_distance > max_distance) { max_distance_2 = max_distance; max_distance = curr_distance; - } - else if (curr_distance > max_distance_2) - { + } else if (curr_distance > max_distance_2) { max_distance_2 = curr_distance; } } return max_distance + max_distance_2; } - - public double min_width() - { - if (!this.is_bounded()) - { + + public double min_width() { + if (!this.is_bounded()) { return Integer.MAX_VALUE; } double min_distance = Integer.MAX_VALUE; double min_distance_2 = Integer.MAX_VALUE; - FloatPoint gravity_point = this.centre_of_gravity(); - - for (int i = 0; i < border_line_count(); ++i) - { + FloatPoint gravity_point = this.centre_of_gravity(); + + for (int i = 0; i < border_line_count(); ++i) { double curr_distance = Math.abs(arr[i].signed_distance(gravity_point)); - - if (curr_distance < min_distance) - { + + if (curr_distance < min_distance) { min_distance_2 = min_distance; min_distance = curr_distance; - } - else if (curr_distance < min_distance_2) - { + } else if (curr_distance < min_distance_2) { min_distance_2 = curr_distance; } } return min_distance + min_distance_2; } - - + /** * checks if this simplex can be converted into an IntBox */ - public boolean is_IntBox() - { - for (int i = 0; i < arr.length; ++i) - { + public boolean is_IntBox() { + for (int i = 0; i < arr.length; ++i) { Line curr_line = arr[i]; if (!(curr_line.a instanceof IntPoint && - curr_line.b instanceof IntPoint )) - { + curr_line.b instanceof IntPoint)) { return false; } - if (!curr_line.is_orthogonal()) - { + if (!curr_line.is_orthogonal()) { return false; } - if (!corner_is_bounded(i)) - { + if (!corner_is_bounded(i)) { return false; } } return true; } - + /** * checks if this simplex can be converted into an IntOctagon */ - public boolean is_IntOctagon() - { - for (int i = 0; i < arr.length; ++i) - { + public boolean is_IntOctagon() { + for (int i = 0; i < arr.length; ++i) { Line curr_line = arr[i]; if (!(curr_line.a instanceof IntPoint && - curr_line.b instanceof IntPoint )) - { + curr_line.b instanceof IntPoint)) { return false; } - if (!curr_line.is_multiple_of_45_degree()) - { + if (!curr_line.is_multiple_of_45_degree()) { return false; } - if (!corner_is_bounded(i)) - { + if (!corner_is_bounded(i)) { return false; } } return true; } - + /** * Converts this IntSimplex to an IntOctagon. * Returns null, if that is not possible, because not all lines * of this IntSimplex are 45 degree */ - public IntOctagon to_IntOctagon() - { + public IntOctagon to_IntOctagon() { // this function is at the moment only implemented for lines // consisting of IntPoints. // The general implementation is still missing. - if (!is_IntOctagon()) - { + if (!is_IntOctagon()) { return null; } - if (is_empty()) - { + if (is_empty()) { return IntOctagon.EMPTY; } - + // initialise to biggest octagon values - + int rx = Limits.CRIT_INT; int uy = Limits.CRIT_INT; int lrx = Limits.CRIT_INT; @@ -505,59 +425,43 @@ public IntOctagon to_IntOctagon() int ly = -Limits.CRIT_INT; int llx = -Limits.CRIT_INT; int ulx = -Limits.CRIT_INT; - for (int i = 0; i < arr.length; ++i) - { + for (int i = 0; i < arr.length; ++i) { Line curr_line = arr[i]; IntPoint a = (IntPoint) curr_line.a; IntPoint b = (IntPoint) curr_line.b; - if (a.y == b.y) - { - if (b.x >= a.x) - { + if (a.y == b.y) { + if (b.x >= a.x) { // lower boundary line ly = a.y; } - if (b.x <= a.x) - { + if (b.x <= a.x) { // upper boundary line uy = a.y; } } - if (a.x == b.x) - { - if (b.y >= a.y) - { + if (a.x == b.x) { + if (b.y >= a.y) { // right boundary line rx = a.x; } - if (b.y <= a.y) - { + if (b.y <= a.y) { // left boundary line lx = a.x; } } - if (a.y < b.y) - { - if (a.x < b.x) - { + if (a.y < b.y) { + if (a.x < b.x) { // lower right boundary line lrx = a.x - a.y; - } - else if (a.x > b.x) - { + } else if (a.x > b.x) { // upper right boundary line urx = a.x + a.y; } - } - else if (a.y > b.y) - { - if (a.x < b.x) - { + } else if (a.y > b.y) { + if (a.x < b.x) { // lower left boundary line llx = a.x + a.y; - } - else if (a.x > b.x) - { + } else if (a.x > b.x) { // upper left boundary line ulx = a.x - a.y; } @@ -566,67 +470,57 @@ else if (a.x > b.x) IntOctagon result = new IntOctagon(lx, ly, rx, uy, ulx, lrx, llx, urx); return result.normalize(); } - + /** * Returns the simplex, which results from translating * the lines of this simplex by p_vector */ - public Simplex translate_by(Vector p_vector) - { - if (p_vector.equals(Vector.ZERO)) - { + public Simplex translate_by(Vector p_vector) { + if (p_vector.equals(Vector.ZERO)) { return this; } Line[] new_arr = new Line[arr.length]; - for( int i = 0; i < arr.length; ++i) - { - new_arr [i] = arr[i].translate_by(p_vector); + for (int i = 0; i < arr.length; ++i) { + new_arr[i] = arr[i].translate_by(p_vector); } return new Simplex(new_arr); } - - + /** * Returns the smallest box with int coordinates containing * all corners of this simplex. * The coordinates of the result will be Integer.MAX_VALUE, * if the simplex is not bounded */ - public IntBox bounding_box() - { - if (arr.length == 0) - { + public IntBox bounding_box() { + if (arr.length == 0) { return IntBox.EMPTY; } - if (precalculated_bounding_box == null) - { + if (precalculated_bounding_box == null) { double llx = Integer.MAX_VALUE; double lly = Integer.MAX_VALUE; double urx = Integer.MIN_VALUE; double ury = Integer.MIN_VALUE; - for (int i = 0; i < arr.length; ++i) - { + for (int i = 0; i < arr.length; ++i) { FloatPoint curr = corner_approx(i); llx = Math.min(llx, curr.x); lly = Math.min(lly, curr.y); urx = Math.max(urx, curr.x); ury = Math.max(ury, curr.y); } - IntPoint lower_left = new IntPoint((int)Math.floor(llx),(int)Math.floor(lly)); - IntPoint upper_right = new IntPoint((int)Math.ceil(urx),(int)Math.ceil(ury)); + IntPoint lower_left = new IntPoint((int) Math.floor(llx), (int) Math.floor(lly)); + IntPoint upper_right = new IntPoint((int) Math.ceil(urx), (int) Math.ceil(ury)); precalculated_bounding_box = new IntBox(lower_left, upper_right); } return precalculated_bounding_box; } - + /** * Calculates a bounding octagon of the Simplex. * Returns null, if the Simplex is not bounded. */ - public IntOctagon bounding_octagon() - { - if (precalculated_bounding_octagon == null) - { + public IntOctagon bounding_octagon() { + if (precalculated_bounding_octagon == null) { double lx = Integer.MAX_VALUE; double ly = Integer.MAX_VALUE; double rx = Integer.MIN_VALUE; @@ -635,18 +529,17 @@ public IntOctagon bounding_octagon() double lrx = Integer.MIN_VALUE; double llx = Integer.MAX_VALUE; double urx = Integer.MIN_VALUE; - for (int i = 0; i < arr.length; ++i) - { + for (int i = 0; i < arr.length; ++i) { FloatPoint curr = corner_approx(i); lx = Math.min(lx, curr.x); ly = Math.min(ly, curr.y); rx = Math.max(rx, curr.x); uy = Math.max(uy, curr.y); - + double tmp = curr.x - curr.y; ulx = Math.min(ulx, tmp); lrx = Math.max(lrx, tmp); - + tmp = curr.x + curr.y; llx = Math.min(llx, tmp); urx = Math.max(urx, tmp); @@ -655,231 +548,185 @@ public IntOctagon bounding_octagon() || Math.max(rx, uy) > Limits.CRIT_INT || Math.min(ulx, llx) < -Limits.CRIT_INT || Math.max(lrx, urx) > Limits.CRIT_INT) - // result is not bounded + // result is not bounded { return null; } precalculated_bounding_octagon = new - IntOctagon((int)Math.floor(lx), (int)Math.floor(ly), - (int)Math.ceil(rx), (int)Math.ceil(uy), - (int)Math.floor(ulx), (int)Math.ceil(lrx), - (int)Math.floor(llx), (int)Math.ceil(urx)); + IntOctagon((int) Math.floor(lx), (int) Math.floor(ly), + (int) Math.ceil(rx), (int) Math.ceil(uy), + (int) Math.floor(ulx), (int) Math.ceil(lrx), + (int) Math.floor(llx), (int) Math.ceil(urx)); } return precalculated_bounding_octagon; } - - public Simplex bounding_tile() - { + + public Simplex bounding_tile() { return this; } - - public RegularTileShape bounding_shape(ShapeBoundingDirections p_dirs) - { + + public RegularTileShape bounding_shape(ShapeBoundingDirections p_dirs) { return p_dirs.bounds(this); } - - + /** * Returns the simplex offseted by p_with. * If p_width > 0, the offset is to the outer, else to the inner. */ - public Simplex offset(double p_width) - { - if (p_width == 0) - { + public Simplex offset(double p_width) { + if (p_width == 0) { return this; } Line[] new_arr = new Line[arr.length]; - for (int i = 0; i < arr.length; ++i) - { + for (int i = 0; i < arr.length; ++i) { new_arr[i] = arr[i].translate(-p_width); } Simplex offset_simplex = new Simplex(new_arr); - if (p_width < 0) - { + if (p_width < 0) { offset_simplex = offset_simplex.remove_redundant_lines(); } return offset_simplex; } - + /** * Returns this simplex enlarged by p_offset. * The result simplex is intersected with the * by p_offset enlarged bounding octagon of this simplex */ - public Simplex enlarge(double p_offset) - { - if (p_offset == 0) - { + public Simplex enlarge(double p_offset) { + if (p_offset == 0) { return this; } Simplex offset_simplex = offset(p_offset); IntOctagon bounding_oct = this.bounding_octagon(); - if (bounding_oct == null) - { + if (bounding_oct == null) { return Simplex.EMPTY; } IntOctagon offset_oct = bounding_oct.offset(p_offset); return offset_simplex.intersection(offset_oct.to_Simplex()); } - - - + /** * Returns the number of the rightmost corner seen from p_from_point * No other point of this simplex may be to the right * of the line from p_from_point to the result corner. */ - public int index_of_right_most_corner( Point p_from_point) - { + public int index_of_right_most_corner(Point p_from_point) { Point pole = p_from_point; Point right_most_corner = corner(0); int result = 0; - for (int i = 1; i < arr.length; ++i) - { + for (int i = 1; i < arr.length; ++i) { Point curr_corner = corner(i); - if (curr_corner.side_of(pole, right_most_corner) == Side.ON_THE_RIGHT) - { + if (curr_corner.side_of(pole, right_most_corner) == Side.ON_THE_RIGHT) { right_most_corner = curr_corner; result = i; } } return result; } - + /** * Returns the intersection of p_box with this simplex */ - public Simplex intersection(IntBox p_box) - { + public Simplex intersection(IntBox p_box) { return intersection(p_box.to_Simplex()); } - + /** * Returns the intersection of this simplex and p_other */ - public Simplex intersection(Simplex p_other) - { - if (this.is_empty() || p_other.is_empty()) - { + public Simplex intersection(Simplex p_other) { + if (this.is_empty() || p_other.is_empty()) { return EMPTY; } Line[] new_arr = new Line[arr.length + p_other.arr.length]; System.arraycopy(arr, 0, new_arr, 0, arr.length); System.arraycopy(p_other.arr, 0, new_arr, arr.length, p_other.arr.length); java.util.Arrays.sort(new_arr); - Simplex result = new Simplex( new_arr); + Simplex result = new Simplex(new_arr); return result.remove_redundant_lines(); } - + /** * Returns the intersection of this simplex and the shape p_other */ - public TileShape intersection(TileShape p_other) - { + public TileShape intersection(TileShape p_other) { TileShape result = p_other.intersection(this); return result; } - - public boolean intersects(Shape p_other) - { + public boolean intersects(Shape p_other) { return p_other.intersects(this); } - - public boolean intersects(Simplex p_other) - { + + public boolean intersects(Simplex p_other) { ConvexShape is = intersection(p_other); return !is.is_empty(); } - + /** * if p_line is a borderline of this simplex the number of that * edge is returned, otherwise -1 */ - public int border_line_index(Line p_line) - { - for (int i = 0; i < arr.length; ++i) - { - if (p_line.equals(arr[i])) - { + public int border_line_index(Line p_line) { + for (int i = 0; i < arr.length; ++i) { + if (p_line.equals(arr[i])) { return i; } } return -1; } - + /** * Enlarges the simplex by removing the edge line with index p_no. * The result simplex may get unbounded. */ - public Simplex remove_border_line( int p_no) - { - if (p_no < 0 || p_no >= arr.length) - { + public Simplex remove_border_line(int p_no) { + if (p_no < 0 || p_no >= arr.length) { return this; } - Line [] new_arr = new Line [this.arr.length - 1]; + Line[] new_arr = new Line[this.arr.length - 1]; System.arraycopy(this.arr, 0, new_arr, 0, p_no); System.arraycopy(this.arr, p_no + 1, new_arr, p_no, new_arr.length - p_no); return new Simplex(new_arr); } - - /** - * Constructs a Simplex from the directed lines in p_line_arr. - * The simplex will not be normalized. - * To get a normalised simplex use TileShape.get_instance - */ - public Simplex(Line[] p_line_arr) - { - arr = p_line_arr; - } - - public Simplex to_Simplex() - { + + public Simplex to_Simplex() { return this; } - - - Simplex intersection(IntOctagon p_other) - { + + Simplex intersection(IntOctagon p_other) { return intersection(p_other.to_Simplex()); } - - public TileShape[] cutout(TileShape p_shape) - { + + public TileShape[] cutout(TileShape p_shape) { return p_shape.cutout_from(this); } - + /** * cuts this simplex out of p_outer_simplex. * Divides the resulting shape into simplices along the minimal * distance lines from the vertices of the inner simplex to the outer * simplex; Returns the convex pieces constructed by this division. */ - public Simplex[] cutout_from(Simplex p_outer_simplex) - { - if(this.dimension() < 2) - { + public Simplex[] cutout_from(Simplex p_outer_simplex) { + if (this.dimension() < 2) { System.out.println("Simplex.cutout_from only implemented for 2-dim simplex"); return null; } Simplex inner_simplex = this.intersection(p_outer_simplex); - if (inner_simplex.dimension() < 2) - { + if (inner_simplex.dimension() < 2) { // nothing to cutout from p_outer_simplex Simplex[] result = new Simplex[1]; result[0] = p_outer_simplex; return result; } int inner_corner_count = inner_simplex.arr.length; - Line [][] division_line_arr = new Line[inner_corner_count][]; - for (int inner_corner_no = 0; inner_corner_no < inner_corner_count; ++inner_corner_no) - { + Line[][] division_line_arr = new Line[inner_corner_count][]; + for (int inner_corner_no = 0; inner_corner_no < inner_corner_count; ++inner_corner_no) { division_line_arr[inner_corner_no] = inner_simplex.calc_division_lines(inner_corner_no, p_outer_simplex); - if (division_line_arr[inner_corner_no] == null) - { + if (division_line_arr[inner_corner_no] == null) { System.out.println("Simplex.cutout_from: division line is null"); Simplex[] result = new Simplex[1]; result[0] = p_outer_simplex; @@ -889,47 +736,41 @@ public Simplex[] cutout_from(Simplex p_outer_simplex) boolean check_cross_first_line = false; Line prev_division_line = null; Line first_division_line = division_line_arr[0][0]; - IntDirection first_direction = (IntDirection)first_division_line.direction(); + IntDirection first_direction = (IntDirection) first_division_line.direction(); Collection result_list = new LinkedList(); - - for (int inner_corner_no = 0; inner_corner_no < inner_corner_count; ++inner_corner_no) - { + + for (int inner_corner_no = 0; inner_corner_no < inner_corner_count; ++inner_corner_no) { Line next_division_line; if (inner_corner_no == inner_simplex.arr.length - 1) next_division_line = division_line_arr[0][0]; else next_division_line = division_line_arr[inner_corner_no + 1][0]; Line[] curr_division_lines = division_line_arr[inner_corner_no]; - if (curr_division_lines.length == 2) - { + if (curr_division_lines.length == 2) { // 2 division lines are nessesary (sharp corner). // Construct an unbounded simplex from // curr_division_lines[1] and curr_division_lines[0] // and intersect it with the outer simplex - IntDirection curr_dir = (IntDirection)curr_division_lines[0].direction(); + IntDirection curr_dir = (IntDirection) curr_division_lines[0].direction(); boolean merge_prev_division_line = false; boolean merge_first_division_line = false; - if (prev_division_line != null) - { - IntDirection prev_dir = (IntDirection)prev_division_line.direction(); + if (prev_division_line != null) { + IntDirection prev_dir = (IntDirection) prev_division_line.direction(); if (curr_dir.determinant(prev_dir) > 0) - + { // the previous division line may intersect // curr_division_lines[0] inside p_divide_simplex merge_prev_division_line = true; } } - if (!check_cross_first_line) - { + if (!check_cross_first_line) { check_cross_first_line = (inner_corner_no > 0 && curr_dir.determinant(first_direction) > 0); } - if (check_cross_first_line) - { - IntDirection curr_dir2 = (IntDirection)curr_division_lines[1].direction(); - if (curr_dir2.determinant(first_direction) < 0) - { + if (check_cross_first_line) { + IntDirection curr_dir2 = (IntDirection) curr_division_lines[1].direction(); + if (curr_dir2.determinant(first_direction) < 0) { // The current piece has an intersection area with the first // piece. // Add a line to tmp_polyline to prevent this @@ -943,15 +784,13 @@ public Simplex[] cutout_from(Simplex p_outer_simplex) ++piece_line_count; Line[] piece_lines = new Line[piece_line_count]; piece_lines[0] = new Line(curr_division_lines[1].b, curr_division_lines[1].a); - piece_lines[1] = curr_division_lines[0]; + piece_lines[1] = curr_division_lines[0]; int curr_line_no = 1; - if (merge_prev_division_line) - { + if (merge_prev_division_line) { ++curr_line_no; piece_lines[curr_line_no] = prev_division_line; } - if (merge_first_division_line) - { + if (merge_first_division_line) { ++curr_line_no; piece_lines[curr_line_no] = new Line(first_division_line.b, first_division_line.a); @@ -964,35 +803,31 @@ public Simplex[] cutout_from(Simplex p_outer_simplex) // and intersect it with the outer simplex boolean merge_next_division_line = !next_division_line.b.equals(next_division_line.a); Line last_curr_division_line = curr_division_lines[curr_division_lines.length - 1]; - IntDirection last_curr_dir = (IntDirection)last_curr_division_line.direction(); + IntDirection last_curr_dir = (IntDirection) last_curr_division_line.direction(); boolean merge_last_curr_division_line = !last_curr_division_line.b.equals(last_curr_division_line.a); boolean merge_prev_division_line = false; boolean merge_first_division_line = false; - if (prev_division_line != null) - { - IntDirection prev_dir = (IntDirection)prev_division_line.direction(); + if (prev_division_line != null) { + IntDirection prev_dir = (IntDirection) prev_division_line.direction(); if (last_curr_dir.determinant(prev_dir) > 0) - + { // the previous division line may intersect // the last current division line inside p_divide_simplex merge_prev_division_line = true; } } - if (!check_cross_first_line) - { + if (!check_cross_first_line) { check_cross_first_line = inner_corner_no > 0 && last_curr_dir.determinant(first_direction) > 0 && last_curr_dir.get_vector().scalar_product(first_direction.get_vector()) < 0; // scalar_product checked to ignore backcrossing at // small inner_corner_no } - if (check_cross_first_line) - { - IntDirection next_dir = (IntDirection)next_division_line.direction(); - if(next_dir.determinant(first_direction) < 0) - { + if (check_cross_first_line) { + IntDirection next_dir = (IntDirection) next_division_line.direction(); + if (next_dir.determinant(first_direction) < 0) { // The current piece has an intersection area with the first piece. // Add a line to tmp_polyline to prevent this merge_first_division_line = true; @@ -1011,23 +846,19 @@ public Simplex[] cutout_from(Simplex p_outer_simplex) Line curr_line = inner_simplex.arr[inner_corner_no]; piece_lines[0] = new Line(curr_line.b, curr_line.a); int curr_line_no = 0; - if (merge_next_division_line) - { + if (merge_next_division_line) { ++curr_line_no; piece_lines[curr_line_no] = new Line(next_division_line.b, next_division_line.a); } - if (merge_last_curr_division_line) - { + if (merge_last_curr_division_line) { ++curr_line_no; piece_lines[curr_line_no] = last_curr_division_line; } - if (merge_prev_division_line) - { + if (merge_prev_division_line) { ++curr_line_no; piece_lines[curr_line_no] = prev_division_line; } - if (merge_first_division_line) - { + if (merge_first_division_line) { ++curr_line_no; piece_lines[curr_line_no] = new Line(first_division_line.b, first_division_line.a); @@ -1038,100 +869,86 @@ public Simplex[] cutout_from(Simplex p_outer_simplex) } Simplex[] result = new Simplex[result_list.size()]; Iterator it = result_list.iterator(); - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = it.next(); } return result; } - - Simplex[] cutout_from(IntOctagon p_oct) - { + + Simplex[] cutout_from(IntOctagon p_oct) { return cutout_from(p_oct.to_Simplex()); } - - Simplex[] cutout_from(IntBox p_box) - { + + Simplex[] cutout_from(IntBox p_box) { return cutout_from(p_box.to_Simplex()); } - + /** * Removes lines, which are redundant in the definition of the * shape of this simplex. * Assumes that the lines of this simplex are sorted. */ - Simplex remove_redundant_lines() - { - Line [] line_arr = new Line [arr.length]; + Simplex remove_redundant_lines() { + Line[] line_arr = new Line[arr.length]; // copy the sorted lines of arr into line_arr while skipping // multiple lines int new_length = 1; line_arr[0] = arr[0]; Line prev = line_arr[0]; - for (int i = 1; i < arr.length; ++i) - { - if (!arr[i].fast_equals(prev)) - { + for (int i = 1; i < arr.length; ++i) { + if (!arr[i].fast_equals(prev)) { line_arr[new_length] = arr[i]; prev = line_arr[new_length]; ++new_length; } } - - Side [] intersection_sides = new Side [new_length]; + + Side[] intersection_sides = new Side[new_length]; // precalculated array , on which side of this line the previous and the // next line do intersect - + boolean try_again = new_length > 2; int index_of_last_removed_line = new_length; - while(try_again) - { + while (try_again) { try_again = false; int prev_ind = new_length - 1; int next_ind; Line prev_line = line_arr[prev_ind]; Line curr_line = line_arr[0]; Line next_line; - for (int ind = 0; ind < new_length; ++ind) - { - if (ind == new_length - 1) - { + for (int ind = 0; ind < new_length; ++ind) { + if (ind == new_length - 1) { next_ind = 0; - } - else - { + } else { next_ind = ind + 1; } next_line = line_arr[next_ind]; - + boolean remove_line = false; IntDirection prev_dir = (IntDirection) prev_line.direction(); IntDirection next_dir = (IntDirection) next_line.direction(); double det = prev_dir.determinant(next_dir); if (det != 0) // prev_line and next_line are not parallel { - if (intersection_sides [ind] == null) - { + if (intersection_sides[ind] == null) { // intersection_sides [ind] not precalculated - intersection_sides [ind] = curr_line.side_of_intersection(prev_line, next_line); + intersection_sides[ind] = curr_line.side_of_intersection(prev_line, next_line); } - if(det > 0 ) - // direction of next_line is bigger than direction of prev_line + if (det > 0) + // direction of next_line is bigger than direction of prev_line { // if the intersection of prev_line and next_line // is on the left of curr_line, curr_line does not // contribute to the shape of the simplex remove_line = (intersection_sides[ind] != Side.ON_THE_LEFT); - } - else - // direction of next_line is smaller than direction of prev_line + } else + // direction of next_line is smaller than direction of prev_line { - - if (intersection_sides[ind] == Side.ON_THE_LEFT) - { + + if (intersection_sides[ind] == Side.ON_THE_LEFT) { IntDirection curr_dir = (IntDirection) curr_line.direction(); if (prev_dir.determinant(curr_dir) > 0) - // direction of curr_line is bigger than direction of prev_line + // direction of curr_line is bigger than direction of prev_line { // the halfplane defined by curr_line does not intersect // with the simplex defined by prev_line and nex_line, @@ -1142,118 +959,98 @@ Simplex remove_redundant_lines() } } } - } - else // prev_line and next_line are parallel + } else // prev_line and next_line are parallel { if (prev_line.side_of(next_line.a) == Side.ON_THE_LEFT) - // prev_line is to the left of next_line, - // the halfplanes defined by prev_line and next_line - // do not intersect + // prev_line is to the left of next_line, + // the halfplanes defined by prev_line and next_line + // do not intersect { new_length = 0; try_again = false; break; } } - if (remove_line) - { + if (remove_line) { try_again = true; --new_length; - for (int i = ind; i < new_length; ++i) - { - line_arr [i] = line_arr [i + 1]; - intersection_sides[i] = intersection_sides [i + 1]; + for (int i = ind; i < new_length; ++i) { + line_arr[i] = line_arr[i + 1]; + intersection_sides[i] = intersection_sides[i + 1]; } - - if (new_length < 3) - { + + if (new_length < 3) { try_again = false; break; } // reset 3 precalculated intersection_sides - if (ind == 0) - { + if (ind == 0) { prev_ind = new_length - 1; } - intersection_sides [prev_ind] = null; - if (ind >= new_length) - { + intersection_sides[prev_ind] = null; + if (ind >= new_length) { next_ind = 0; - } - else - { + } else { next_ind = ind; } - intersection_sides [next_ind] = null; + intersection_sides[next_ind] = null; --ind; index_of_last_removed_line = ind; - } - else - { + } else { prev_line = curr_line; prev_ind = ind; } curr_line = next_line; - if( !try_again && ind >= index_of_last_removed_line) - // tried all lines without removing one + if (!try_again && ind >= index_of_last_removed_line) + // tried all lines without removing one { break; } } } - - if (new_length == 2) - { - if (line_arr[0].is_parallel(line_arr[1])) - { - if(line_arr[0].direction().equals(line_arr[1].direction())) - // one of the two remaining lines is redundant + + if (new_length == 2) { + if (line_arr[0].is_parallel(line_arr[1])) { + if (line_arr[0].direction().equals(line_arr[1].direction())) + // one of the two remaining lines is redundant { - if (line_arr[1].side_of(line_arr[0].a) == Side.ON_THE_LEFT) - { + if (line_arr[1].side_of(line_arr[0].a) == Side.ON_THE_LEFT) { line_arr[0] = line_arr[1]; } --new_length; - } - else - // the two remaining lines have opposite direction - // the simplex may be empty + } else + // the two remaining lines have opposite direction + // the simplex may be empty { - if (line_arr[1].side_of(line_arr[0].a) == Side.ON_THE_LEFT) - { + if (line_arr[1].side_of(line_arr[0].a) == Side.ON_THE_LEFT) { new_length = 0; } } } } - if (new_length == arr.length) - { + if (new_length == arr.length) { return this; // nothing removed } - if (new_length == 0) - { + if (new_length == 0) { return Simplex.EMPTY; } - Line [] result = new Line [new_length]; + Line[] result = new Line[new_length]; System.arraycopy(line_arr, 0, result, 0, new_length); return new Simplex(result); } - - public boolean intersects(IntBox p_box) - { + + public boolean intersects(IntBox p_box) { return intersects(p_box.to_Simplex()); } - - public boolean intersects(IntOctagon p_octagon) - { + + public boolean intersects(IntOctagon p_octagon) { return intersects(p_octagon.to_Simplex()); } - - public boolean intersects(Circle p_circle) - { + + public boolean intersects(Circle p_circle) { return p_circle.intersects(this); } - + /** * For each corner of this inner simplex 1 or 2 perpendicular * projections onto lines of the outer simplex are constructed, @@ -1261,8 +1058,7 @@ public boolean intersects(Circle p_circle) * are convex. 2 projections may be nessesary at sharp angle corners. * Used in in the method cutout_from with parametertype Simplex. */ - private Line[] calc_division_lines(int p_inner_corner_no, Simplex p_outer_simplex) - { + private Line[] calc_division_lines(int p_inner_corner_no, Simplex p_outer_simplex) { Line curr_inner_line = this.arr[p_inner_corner_no]; Line prev_inner_line; if (p_inner_corner_no != 0) @@ -1270,25 +1066,23 @@ private Line[] calc_division_lines(int p_inner_corner_no, Simplex p_outer_simple else prev_inner_line = this.arr[arr.length - 1]; FloatPoint intersection = curr_inner_line.intersection_approx(prev_inner_line); - if (intersection.x >= Integer.MAX_VALUE) - { + if (intersection.x >= Integer.MAX_VALUE) { System.out.println("Simplex.calc_division_lines: intersection expexted"); return null; } IntPoint inner_corner = intersection.round(); double c_tolerance = 0.0001; - boolean is_exact = + boolean is_exact = Math.abs(inner_corner.x - intersection.x) < c_tolerance - && Math.abs(inner_corner.y - intersection.y) < c_tolerance; - - if (!is_exact) - { + && Math.abs(inner_corner.y - intersection.y) < c_tolerance; + + if (!is_exact) { // it is assumed, that the corners of the original inner simplex are // exact and the not exact corners come from the intersection of // the inner simplex with the outer simplex. // Because these corners lie on the border of the outer simplex, // no division is nessesary - Line [] result = new Line[1]; + Line[] result = new Line[1]; result[0] = prev_inner_line; return result; } @@ -1297,63 +1091,54 @@ private Line[] calc_division_lines(int p_inner_corner_no, Simplex p_outer_simple IntDirection prev_inner_dir = (IntDirection) prev_inner_line.direction().opposite(); IntDirection next_inner_dir = (IntDirection) curr_inner_line.direction(); int outer_line_no = 0; - - + + // search the first outer line, so that // the perpendicular projection of the inner corner onto this // line is visible from inner_corner to the left of prev_inner_line. - + double min_distance = Integer.MAX_VALUE; - - for (int ind = 0; ind < p_outer_simplex.arr.length; ++ind) - { + + for (int ind = 0; ind < p_outer_simplex.arr.length; ++ind) { Line outer_line = p_outer_simplex.arr[outer_line_no]; IntDirection curr_projection_dir = - (IntDirection)inner_corner.perpendicular_direction(outer_line); - if (curr_projection_dir == Direction.NULL) - { - Line [] result = new Line[1]; + (IntDirection) inner_corner.perpendicular_direction(outer_line); + if (curr_projection_dir == Direction.NULL) { + Line[] result = new Line[1]; result[0] = new Line(inner_corner, inner_corner); return result; } boolean projection_visible = prev_inner_dir.determinant(curr_projection_dir) >= 0; - if (projection_visible) - { + if (projection_visible) { double curr_distance = Math.abs(outer_line.signed_distance(inner_corner.to_float())); boolean second_division_necessary = curr_projection_dir.determinant(next_inner_dir) < 0; // may occor at a sharp angle IntDirection curr_second_projection_dir = curr_projection_dir; - - if (second_division_necessary) - { + + if (second_division_necessary) { // search the first projection_dir between curr_projection_dir // and next_inner_dir, that is visible from next_inner_line boolean second_projection_visible = false; int tmp_outer_line_no = outer_line_no; - while (!second_projection_visible) - { - if (tmp_outer_line_no == p_outer_simplex.arr.length - 1) - { + while (!second_projection_visible) { + if (tmp_outer_line_no == p_outer_simplex.arr.length - 1) { tmp_outer_line_no = 0; - } - else - { + } else { ++tmp_outer_line_no; } curr_second_projection_dir = - (IntDirection)inner_corner.perpendicular_direction( - p_outer_simplex.arr[tmp_outer_line_no]); - + (IntDirection) inner_corner.perpendicular_direction( + p_outer_simplex.arr[tmp_outer_line_no]); + if (curr_second_projection_dir == Direction.NULL) - // inner corner is on outer_line + // inner corner is on outer_line { - Line [] result = new Line[1]; + Line[] result = new Line[1]; result[0] = new Line(inner_corner, inner_corner); return result; } - if (curr_projection_dir.determinant(curr_second_projection_dir) < 0) - { + if (curr_projection_dir.determinant(curr_second_projection_dir) < 0) { // curr_second_projection_dir not found; // the angle between curr_projection_dir and // curr_second_projection_dir would be already bigger @@ -1361,58 +1146,40 @@ private Line[] calc_division_lines(int p_inner_corner_no, Simplex p_outer_simple curr_distance = Integer.MAX_VALUE; break; } - + second_projection_visible = curr_second_projection_dir.determinant(next_inner_dir) >= 0; } curr_distance += Math.abs(p_outer_simplex.arr[tmp_outer_line_no].signed_distance(inner_corner.to_float())); } - if (curr_distance < min_distance) - { + if (curr_distance < min_distance) { min_distance = curr_distance; first_projection_dir = curr_projection_dir; second_projection_dir = curr_second_projection_dir; } } - if (outer_line_no == p_outer_simplex.arr.length - 1) - { + if (outer_line_no == p_outer_simplex.arr.length - 1) { outer_line_no = 0; - } - else - { + } else { ++outer_line_no; - + } } - if (min_distance == Integer.MAX_VALUE) - { + if (min_distance == Integer.MAX_VALUE) { System.out.println("Simplex.calc_division_lines: division not found"); return null; } Line[] result; - if (first_projection_dir.equals(second_projection_dir)) - { + if (first_projection_dir.equals(second_projection_dir)) { result = new Line[1]; result[0] = new Line(inner_corner, first_projection_dir); - } - else - { + } else { result = new Line[2]; result[0] = new Line(inner_corner, first_projection_dir); result[1] = new Line(inner_corner, second_projection_dir); } return result; } - - private final Line[] arr; - - /** - * the following fields are for storing precalculated data - */ - transient private Point[] precalculated_corners = null; - transient private FloatPoint[] precalculated_float_corners = null; - transient private IntBox precalculated_bounding_box = null; - transient private IntOctagon precalculated_bounding_octagon = null; - + } diff --git a/src/main/java/net/freerouting/geometry/planar/TileShape.java b/src/main/java/net/freerouting/geometry/planar/TileShape.java index edeba9e1..32de2a3b 100644 --- a/src/main/java/net/freerouting/geometry/planar/TileShape.java +++ b/src/main/java/net/freerouting/geometry/planar/TileShape.java @@ -20,21 +20,18 @@ import java.util.LinkedList; /** - * * Abstract class defining functionality for convex shapes, whose * borders consists of straight lines. * * @author Alfons Wirtz */ -public abstract class TileShape extends PolylineShape implements ConvexShape, java.io.Serializable -{ +public abstract class TileShape extends PolylineShape implements ConvexShape, java.io.Serializable { /** * creates a Simplex as intersection of the halfplanes defined * by an array of directed lines */ - public static TileShape get_instance(Line[] p_line_arr) - { + public static TileShape get_instance(Line[] p_line_arr) { Simplex result = Simplex.get_instance(p_line_arr); return result.simplify(); } @@ -43,11 +40,9 @@ public static TileShape get_instance(Line[] p_line_arr) * Creates a TileShape from a Point array, who forms the corners of the shape * of a convex polygon. May work only for IntPoints. */ - public static TileShape get_instance(Point[] p_convex_polygon) - { + public static TileShape get_instance(Point[] p_convex_polygon) { Line[] line_arr = new Line[p_convex_polygon.length]; - for (int j = 0; j < line_arr.length - 1; ++j) - { + for (int j = 0; j < line_arr.length - 1; ++j) { line_arr[j] = new Line(p_convex_polygon[j], p_convex_polygon[j + 1]); } line_arr[line_arr.length - 1] = @@ -58,8 +53,7 @@ public static TileShape get_instance(Point[] p_convex_polygon) /** * creates a half_plane from a directed line */ - public static TileShape get_instance(Line p_line) - { + public static TileShape get_instance(Line p_line) { Line[] lines = new Line[1]; lines[0] = p_line; return Simplex.get_instance(lines); @@ -71,8 +65,7 @@ public static TileShape get_instance(Line p_line) */ public static IntOctagon get_instance(int p_lx, int p_ly, int p_rx, int p_uy, int p_ulx, int p_lrx, - int p_llx, int p_urx) - { + int p_llx, int p_urx) { IntOctagon oct = new IntOctagon(p_lx, p_ly, p_rx, p_uy, p_ulx, p_lrx, p_llx, p_urx); return oct.normalize(); @@ -84,8 +77,7 @@ public static IntOctagon get_instance(int p_lx, int p_ly, int p_rx, public static IntOctagon get_instance(int p_lower_left_x, int p_lower_left_y, int p_upper_right_x, - int p_upper_right_y) - { + int p_upper_right_y) { IntBox box = new IntBox(p_lower_left_x, p_lower_left_y, p_upper_right_x, p_upper_right_y); return box.to_IntOctagon(); @@ -94,8 +86,7 @@ public static IntOctagon get_instance(int p_lower_left_x, /** * creates the smallest IntOctagon containing p_point */ - public static IntBox get_instance(Point p_point) - { + public static IntBox get_instance(Point p_point) { return p_point.surrounding_box(); } @@ -103,8 +94,7 @@ public static IntBox get_instance(Point p_point) * Tries to simplify the result shape to a simpler shape. * Simplifying always in the intersection function may cause performance problems. */ - public TileShape intersection_with_simplify(TileShape p_other) - { + public TileShape intersection_with_simplify(TileShape p_other) { TileShape result = this.intersection(p_other); return result.simplify(); } @@ -152,15 +142,12 @@ public TileShape intersection_with_simplify(TileShape p_other) * Returns the content of the area of the shape. * If the shape is unbounded, Double.MAX_VALUE is returned. */ - public double area() - { - if (!is_bounded()) - { + public double area() { + if (!is_bounded()) { return Double.MAX_VALUE; } - if (dimension() < 2) - { + if (dimension() < 2) { return 0; } // calculate half of the absolute value of @@ -171,8 +158,7 @@ public double area() int corner_count = border_line_count(); FloatPoint prev_corner = corner_approx(corner_count - 2); FloatPoint curr_corner = corner_approx(corner_count - 1); - for (int i = 0; i < corner_count; ++i) - { + for (int i = 0; i < corner_count; ++i) { FloatPoint next_corner = corner_approx(i); result += curr_corner.x * (next_corner.y - prev_corner.y); prev_corner = curr_corner; @@ -186,25 +172,20 @@ public double area() * Returns true, if p_point is not contained in the inside or the * edge of the shape */ - public boolean is_outside(Point p_point) - { + public boolean is_outside(Point p_point) { int line_count = border_line_count(); - if (line_count == 0) - { + if (line_count == 0) { return true; } - for (int i = 0; i < line_count; ++i) - { - if (border_line(i).side_of(p_point) == Side.ON_THE_LEFT) - { + for (int i = 0; i < line_count; ++i) { + if (border_line(i).side_of(p_point) == Side.ON_THE_LEFT) { return true; } } return false; } - public boolean contains(Point p_point) - { + public boolean contains(Point p_point) { return !is_outside(p_point); } @@ -212,17 +193,13 @@ public boolean contains(Point p_point) * Returns true, if p_point is contained in this shape, * but not on an edge line */ - public boolean contains_inside(Point p_point) - { + public boolean contains_inside(Point p_point) { int line_count = border_line_count(); - if (line_count == 0) - { + if (line_count == 0) { return false; } - for (int i = 0; i < line_count; ++i) - { - if (border_line(i).side_of(p_point) != Side.ON_THE_RIGHT) - { + for (int i = 0; i < line_count; ++i) { + if (border_line(i).side_of(p_point) != Side.ON_THE_RIGHT) { return false; } } @@ -232,8 +209,7 @@ public boolean contains_inside(Point p_point) /** * Returns true, if p_point is contained in this shape. */ - public boolean contains(FloatPoint p_point) - { + public boolean contains(FloatPoint p_point) { return contains(p_point, 0); } @@ -242,17 +218,13 @@ public boolean contains(FloatPoint p_point) * p_tolerance is used when determing, if a point is on the left side of a border line. * It is used there in calculating a determinant and is not the distance of p_point to the border. */ - public boolean contains(FloatPoint p_point, double p_tolerance) - { + public boolean contains(FloatPoint p_point, double p_tolerance) { int line_count = border_line_count(); - if (line_count == 0) - { + if (line_count == 0) { return false; } - for (int i = 0; i < line_count; ++i) - { - if (border_line(i).side_of(p_point, p_tolerance) != Side.ON_THE_RIGHT) - { + for (int i = 0; i < line_count; ++i) { + if (border_line(i).side_of(p_point, p_tolerance) != Side.ON_THE_RIGHT) { return false; } } @@ -266,23 +238,17 @@ public boolean contains(FloatPoint p_point, double p_tolerance) * Otherwise the function returns Side.ON_THE_LEFT if p_point is outside of this shape, * and Side.ON_THE_RIGTH if p_point is inside this shape. */ - public Side side_of_border(FloatPoint p_point, double p_tolerance) - { + public Side side_of_border(FloatPoint p_point, double p_tolerance) { int line_count = border_line_count(); - if (line_count == 0) - { + if (line_count == 0) { return Side.COLLINEAR; } Side result = Side.ON_THE_RIGHT; // point is inside - for (int i = 0; i < line_count; ++i) - { + for (int i = 0; i < line_count; ++i) { Side curr_side = border_line(i).side_of(p_point, p_tolerance); - if (curr_side == Side.ON_THE_LEFT) - { + if (curr_side == Side.ON_THE_LEFT) { return Side.ON_THE_LEFT; // point is outside - } - else if (curr_side == Side.COLLINEAR) - { + } else if (curr_side == Side.COLLINEAR) { result = curr_side; } @@ -295,24 +261,19 @@ else if (curr_side == Side.COLLINEAR) * edge line segment containing p_point is returned, * otherwise -1 is returned. */ - public int contains_on_border_line_no(Point p_point) - { + public int contains_on_border_line_no(Point p_point) { int line_count = border_line_count(); - if (line_count == 0) - { + if (line_count == 0) { return -1; } int containing_line_no = -1; - for (int i = 0; i < line_count; ++i) - { + for (int i = 0; i < line_count; ++i) { Side side_of = border_line(i).side_of(p_point); - if (side_of == Side.ON_THE_LEFT) - { + if (side_of == Side.ON_THE_LEFT) { // p_point outside the convex shape return -1; } - if (side_of == Side.COLLINEAR) - { + if (side_of == Side.COLLINEAR) { containing_line_no = i; } } @@ -322,8 +283,7 @@ public int contains_on_border_line_no(Point p_point) /** * Returns true, if p_point lies exact on the boundary of the shape */ - public boolean contains_on_border(Point p_point) - { + public boolean contains_on_border(Point p_point) { return (contains_on_border_line_no(p_point) >= 0); } @@ -331,13 +291,10 @@ public boolean contains_on_border(Point p_point) * Returns true, if this shape contains p_other completely. * THere may be some numerical inaccurracy. */ - public boolean contains_approx(TileShape p_other) - { + public boolean contains_approx(TileShape p_other) { FloatPoint[] corners = p_other.corner_approx_arr(); - for (FloatPoint curr_corner : corners) - { - if (!this.contains(curr_corner)) - { + for (FloatPoint curr_corner : corners) { + if (!this.contains(curr_corner)) { return false; } } @@ -347,12 +304,9 @@ public boolean contains_approx(TileShape p_other) /** * Returns true, if this shape contains p_other completely. */ - public boolean contains(TileShape p_other) - { - for (int i = 0; i < p_other.border_line_count(); ++i) - { - if (!this.contains(p_other.corner(i))) - { + public boolean contains(TileShape p_other) { + for (int i = 0; i < p_other.border_line_count(); ++i) { + if (!this.contains(p_other.corner(i))) { return false; } } @@ -363,8 +317,7 @@ public boolean contains(TileShape p_other) * Returns the distance between p_point and its nearest point * on the shape. 0, if p_point is contained in this shape */ - public double distance(FloatPoint p_point) - { + public double distance(FloatPoint p_point) { FloatPoint nearest_point = nearest_point_approx(p_point); return nearest_point.distance(p_point); } @@ -373,14 +326,12 @@ public double distance(FloatPoint p_point) * Returns the distance between p_point and its nearest point * on the edge of the shape. */ - public double border_distance(FloatPoint p_point) - { + public double border_distance(FloatPoint p_point) { FloatPoint nearest_point = nearest_border_point_approx(p_point); return nearest_point.distance(p_point); } - public double smallest_radius() - { + public double smallest_radius() { return border_distance(centre_of_gravity()); } @@ -389,19 +340,15 @@ public double smallest_radius() * distance to p_from_point. p_from_point, if that point * is contained in this shape */ - public Point nearest_point(Point p_from_point) - { - if (!is_outside(p_from_point)) - { + public Point nearest_point(Point p_from_point) { + if (!is_outside(p_from_point)) { return p_from_point; } return nearest_border_point(p_from_point); } - public FloatPoint nearest_point_approx(FloatPoint p_from_point) - { - if (this.contains(p_from_point)) - { + public FloatPoint nearest_point_approx(FloatPoint p_from_point) { + if (this.contains(p_from_point)) { return p_from_point; } return nearest_border_point_approx(p_from_point); @@ -410,16 +357,13 @@ public FloatPoint nearest_point_approx(FloatPoint p_from_point) /** * Returns a nearest point to p_from_point on the edge of the shape */ - public Point nearest_border_point(Point p_from_point) - { + public Point nearest_border_point(Point p_from_point) { int line_count = border_line_count(); - if (line_count == 0) - { + if (line_count == 0) { return null; } FloatPoint from_point_f = p_from_point.to_float(); - if (line_count == 1) - { + if (line_count == 1) { return border_line(0).perpendicular_projection(p_from_point); } Point nearest_point = null; @@ -427,12 +371,10 @@ public Point nearest_border_point(Point p_from_point) int min_dist_ind = 0; // calculate the distance to the nearest corner first - for (int i = 0; i < line_count; ++i) - { + for (int i = 0; i < line_count; ++i) { FloatPoint curr_corner_f = corner_approx(i); double curr_dist = curr_corner_f.distance_square(from_point_f); - if (curr_dist < min_dist) - { + if (curr_dist < min_dist) { min_dist = curr_dist; min_dist_ind = i; } @@ -443,16 +385,13 @@ public Point nearest_border_point(Point p_from_point) int prev_ind = line_count - 2; int curr_ind = line_count - 1; - for (int next_ind = 0; next_ind < line_count; ++next_ind) - { + for (int next_ind = 0; next_ind < line_count; ++next_ind) { Point projection = border_line(curr_ind).perpendicular_projection(p_from_point); - if ((!corner_is_bounded(curr_ind) || border_line(prev_ind).side_of(projection) == Side.ON_THE_RIGHT) && (!corner_is_bounded(next_ind) || border_line(next_ind).side_of(projection) == Side.ON_THE_RIGHT)) - { + if ((!corner_is_bounded(curr_ind) || border_line(prev_ind).side_of(projection) == Side.ON_THE_RIGHT) && (!corner_is_bounded(next_ind) || border_line(next_ind).side_of(projection) == Side.ON_THE_RIGHT)) { FloatPoint projection_f = projection.to_float(); double curr_dist = projection_f.distance_square(from_point_f); - if (curr_dist < min_dist) - { + if (curr_dist < min_dist) { min_dist = curr_dist; nearest_point = projection; } @@ -467,11 +406,9 @@ public Point nearest_border_point(Point p_from_point) * Returns an approximation of the nearest point * to p_from_point on the border of the this shape */ - public FloatPoint nearest_border_point_approx(FloatPoint p_from_point) - { + public FloatPoint nearest_border_point_approx(FloatPoint p_from_point) { FloatPoint[] nearest_points = nearest_border_points_approx(p_from_point, 1); - if (nearest_points.length <= 0) - { + if (nearest_points.length <= 0) { return null; } return nearest_points[0]; @@ -483,50 +420,39 @@ public FloatPoint nearest_border_point_approx(FloatPoint p_from_point) * The result points must be located on different border lines and are * sorted in ascending order (the nearest point comes first). */ - public FloatPoint[] nearest_border_points_approx(FloatPoint p_from_point, int p_count) - { - if (p_count <= 0) - { + public FloatPoint[] nearest_border_points_approx(FloatPoint p_from_point, int p_count) { + if (p_count <= 0) { return new FloatPoint[0]; } int line_count = border_line_count(); int result_count = Math.min(p_count, line_count); - if (line_count == 0) - { + if (line_count == 0) { return new FloatPoint[0]; } - if (line_count == 1) - { + if (line_count == 1) { FloatPoint[] result = new FloatPoint[1]; result[0] = p_from_point.projection_approx(border_line(0)); return result; } - if (this.dimension() == 0) - { + if (this.dimension() == 0) { FloatPoint[] result = new FloatPoint[1]; result[0] = corner_approx(0); return result; } FloatPoint[] nearest_points = new FloatPoint[result_count]; double[] min_dists = new double[result_count]; - for (int i = 0; i < result_count; ++i) - { + for (int i = 0; i < result_count; ++i) { min_dists[i] = Double.MAX_VALUE; } // calculate the distances to the nearest corners first - for (int i = 0; i < line_count; ++i) - { - if (corner_is_bounded(i)) - { + for (int i = 0; i < line_count; ++i) { + if (corner_is_bounded(i)) { FloatPoint curr_corner = corner_approx(i); double curr_dist = curr_corner.distance_square(p_from_point); - for (int j = 0; j < result_count; ++j) - { - if (curr_dist < min_dists[j]) - { - for (int k = j + 1; k < result_count; ++k) - { + for (int j = 0; j < result_count; ++j) { + if (curr_dist < min_dists[j]) { + for (int k = j + 1; k < result_count; ++k) { min_dists[k] = min_dists[k - 1]; nearest_points[k] = nearest_points[k - 1]; } @@ -541,18 +467,13 @@ public FloatPoint[] nearest_border_points_approx(FloatPoint p_from_point, int p_ int prev_ind = line_count - 2; int curr_ind = line_count - 1; - for (int next_ind = 0; next_ind < line_count; ++next_ind) - { + for (int next_ind = 0; next_ind < line_count; ++next_ind) { FloatPoint projection = p_from_point.projection_approx(border_line(curr_ind)); - if ((!corner_is_bounded(curr_ind) || border_line(prev_ind).side_of(projection) == Side.ON_THE_RIGHT) && (!corner_is_bounded(next_ind) || border_line(next_ind).side_of(projection) == Side.ON_THE_RIGHT)) - { + if ((!corner_is_bounded(curr_ind) || border_line(prev_ind).side_of(projection) == Side.ON_THE_RIGHT) && (!corner_is_bounded(next_ind) || border_line(next_ind).side_of(projection) == Side.ON_THE_RIGHT)) { double curr_dist = projection.distance_square(p_from_point); - for (int j = 0; j < result_count; ++j) - { - if (curr_dist < min_dists[j]) - { - for (int k = j + 1; k < result_count; ++k) - { + for (int j = 0; j < result_count; ++j) { + if (curr_dist < min_dists[j]) { + for (int k = j + 1; k < result_count; ++k) { min_dists[k] = min_dists[k - 1]; nearest_points[k] = nearest_points[k - 1]; } @@ -572,17 +493,14 @@ public FloatPoint[] nearest_border_points_approx(FloatPoint p_from_point, int p_ * Returns the number of a nearest corner of the shape * to p_from_point */ - public int index_of_nearest_corner(Point p_from_point) - { + public int index_of_nearest_corner(Point p_from_point) { FloatPoint from_point_f = p_from_point.to_float(); int result = 0; int corner_count = border_line_count(); double min_dist = Double.MIN_VALUE; - for (int i = 0; i < corner_count; ++i) - { + for (int i = 0; i < corner_count; ++i) { double curr_dist = corner_approx(i).distance(from_point_f); - if (curr_dist < min_dist) - { + if (curr_dist < min_dist) { min_dist = curr_dist; result = i; } @@ -594,10 +512,8 @@ public int index_of_nearest_corner(Point p_from_point) * Returns a line segment consisting of an approximations of the corners with * index 0 and corner_count / 2. */ - public FloatLine diagonal_corner_segment() - { - if (this.is_empty()) - { + public FloatLine diagonal_corner_segment() { + if (this.is_empty()) { return null; } FloatPoint first_corner = this.corner_approx(0); @@ -610,11 +526,9 @@ public FloatLine diagonal_corner_segment() * of p_shape in the direction of different border lines of this shape. * These relative locations are sorted in ascending order (the shortest comes first). */ - public FloatPoint[] nearest_relative_outside_locations(TileShape p_shape, int p_count) - { + public FloatPoint[] nearest_relative_outside_locations(TileShape p_shape, int p_count) { int line_count = border_line_count(); - if (p_count <= 0 || line_count < 3 || !this.intersects(p_shape)) - { + if (p_count <= 0 || line_count < 3 || !this.intersects(p_shape)) { return new FloatPoint[0]; } @@ -622,8 +536,7 @@ public FloatPoint[] nearest_relative_outside_locations(TileShape p_shape, int p_ FloatPoint[] translate_coors = new FloatPoint[result_count]; double[] min_dists = new double[result_count]; - for (int i = 0; i < result_count; ++i) - { + for (int i = 0; i < result_count; ++i) { min_dists[i] = Double.MAX_VALUE; } @@ -631,31 +544,24 @@ public FloatPoint[] nearest_relative_outside_locations(TileShape p_shape, int p_ int other_line_count = p_shape.border_line_count(); - for (int next_ind = 0; next_ind < line_count; ++next_ind) - { + for (int next_ind = 0; next_ind < line_count; ++next_ind) { double curr_max_dist = 0; FloatPoint curr_translate_coor = FloatPoint.ZERO; - for (int corner_no = 0; corner_no < other_line_count; ++corner_no) - { + for (int corner_no = 0; corner_no < other_line_count; ++corner_no) { FloatPoint curr_corner = p_shape.corner_approx(corner_no); - if (border_line(curr_ind).side_of(curr_corner) == Side.ON_THE_RIGHT) - { + if (border_line(curr_ind).side_of(curr_corner) == Side.ON_THE_RIGHT) { FloatPoint projection = curr_corner.projection_approx(border_line(curr_ind)); double curr_dist = projection.distance_square(curr_corner); - if (curr_dist > curr_max_dist) - { + if (curr_dist > curr_max_dist) { curr_max_dist = curr_dist; curr_translate_coor = projection.substract(curr_corner); } } } - for (int j = 0; j < result_count; ++j) - { - if (curr_max_dist < min_dists[j]) - { - for (int k = j + 1; k < result_count; ++k) - { + for (int j = 0; j < result_count; ++j) { + if (curr_max_dist < min_dists[j]) { + for (int k = j + 1; k < result_count; ++k) { min_dists[k] = min_dists[k - 1]; translate_coors[k] = translate_coors[k - 1]; } @@ -669,11 +575,9 @@ public FloatPoint[] nearest_relative_outside_locations(TileShape p_shape, int p_ return translate_coors; } - public ConvexShape shrink(double p_offset) - { + public ConvexShape shrink(double p_offset) { ConvexShape result = this.offset(-p_offset); - if (result.is_empty()) - { + if (result.is_empty()) { IntBox centre_box = this.centre_of_gravity().bounding_box(); result = this.intersection(centre_box); } @@ -684,35 +588,27 @@ public ConvexShape shrink(double p_offset) * Returns the maximum of the edge widths of the shape. * Only defined when the shape is bounded. */ - public double length() - { - if (!this.is_bounded()) - { + public double length() { + if (!this.is_bounded()) { return Integer.MAX_VALUE; } int dimension = this.dimension(); - if (dimension <= 0) - { + if (dimension <= 0) { return 0; } - if (dimension == 1) - { + if (dimension == 1) { return this.circumference() / 2; } // now the shape is 2-dimensional double max_distance = -1; double max_distance_2 = -1; FloatPoint gravity_point = this.centre_of_gravity(); - for (int i = 0; i < border_line_count(); ++i) - { + for (int i = 0; i < border_line_count(); ++i) { double curr_distance = Math.abs(border_line(i).signed_distance(gravity_point)); - if (curr_distance > max_distance) - { + if (curr_distance > max_distance) { max_distance_2 = max_distance; max_distance = curr_distance; - } - else if (curr_distance > max_distance_2) - { + } else if (curr_distance > max_distance_2) { max_distance_2 = curr_distance; } } @@ -726,24 +622,20 @@ else if (curr_distance > max_distance_2) * Otherwise an array of dimension 0 is returned. * Used if the intersection shape is 1-dimensional. */ - public int[] touching_sides(TileShape p_other) - { + public int[] touching_sides(TileShape p_other) { // search the first edge line of p_other with reverse direction >= right int side_no_2 = -1; Direction dir2 = null; - for (int i = 0; i < p_other.border_line_count(); ++i) - { + for (int i = 0; i < p_other.border_line_count(); ++i) { Direction curr_dir = p_other.border_line(i).direction(); - if (curr_dir.compareTo(Direction.LEFT) >= 0) - { + if (curr_dir.compareTo(Direction.LEFT) >= 0) { side_no_2 = i; dir2 = curr_dir.opposite(); break; } } - if (dir2 == null) - { + if (dir2 == null) { System.out.println("touching_side : dir2 not found"); return new int[0]; } @@ -751,13 +643,10 @@ public int[] touching_sides(TileShape p_other) Direction dir1 = this.border_line(0).direction(); final int max_ind = this.border_line_count() + p_other.border_line_count(); - for (int i = 0; i < max_ind; ++i) - { + for (int i = 0; i < max_ind; ++i) { int compare = dir2.compareTo(dir1); - if (compare == 0) - { - if (this.border_line(side_no_1).is_equal_or_opposite(p_other.border_line(side_no_2))) - { + if (compare == 0) { + if (this.border_line(side_no_1).is_equal_or_opposite(p_other.border_line(side_no_2))) { int[] result = new int[2]; result[0] = side_no_1; result[1] = side_no_2; @@ -768,8 +657,7 @@ public int[] touching_sides(TileShape p_other) { side_no_1 = (side_no_1 + 1) % this.border_line_count(); dir1 = this.border_line(side_no_1).direction(); - } - else //dir1 is bigger than dir2 + } else //dir1 is bigger than dir2 { side_no_2 = (side_no_2 + 1) % p_other.border_line_count(); dir2 = p_other.border_line(side_no_2).direction().opposite(); @@ -784,19 +672,15 @@ public int[] touching_sides(TileShape p_other) * Returns -1, if p_line is on the right of this shape or intersects * with the interiour of this shape. */ - public double distance_to_the_left(Line p_line) - { + public double distance_to_the_left(Line p_line) { double result = Integer.MAX_VALUE; - for (int i = 0; i < this.border_line_count(); ++i) - { + for (int i = 0; i < this.border_line_count(); ++i) { FloatPoint curr_corner = this.corner_approx(i); Side line_side = p_line.side_of(curr_corner, 1); - if (line_side == Side.COLLINEAR) - { + if (line_side == Side.COLLINEAR) { line_side = p_line.side_of(this.corner(i)); } - if (line_side == Side.ON_THE_RIGHT) - { + if (line_side == Side.ON_THE_RIGHT) { // curr_point would be outside the result shape result = -1; break; @@ -811,99 +695,74 @@ public double distance_to_the_left(Line p_line) * Side.ON_THE_LEFT, if this shape is completely on the left of p_line * or Side.ON_THE_RIGHT, if this shape is completely on the right of p_line. */ - public Side side_of(Line p_line) - { + public Side side_of(Line p_line) { boolean on_the_left = false; boolean on_the_right = false; - for (int i = 0; i < this.border_line_count(); ++i) - { + for (int i = 0; i < this.border_line_count(); ++i) { Side curr_side = p_line.side_of(this.corner(i)); - if (curr_side == Side.ON_THE_LEFT) - { + if (curr_side == Side.ON_THE_LEFT) { on_the_right = true; - } - else if (curr_side == Side.ON_THE_RIGHT) - { + } else if (curr_side == Side.ON_THE_RIGHT) { on_the_left = true; } - if (on_the_left && on_the_right) - { + if (on_the_left && on_the_right) { return Side.COLLINEAR; } } Side result; - if (on_the_left) - { + if (on_the_left) { result = Side.ON_THE_LEFT; - } - else - { + } else { result = Side.ON_THE_RIGHT; } return result; } - public TileShape turn_90_degree(int p_factor, IntPoint p_pole) - { + public TileShape turn_90_degree(int p_factor, IntPoint p_pole) { Line[] new_lines = new Line[border_line_count()]; - for (int i = 0; i < new_lines.length; ++i) - { + for (int i = 0; i < new_lines.length; ++i) { new_lines[i] = this.border_line(i).turn_90_degree(p_factor, p_pole); } return get_instance(new_lines); } - public TileShape rotate_approx(double p_angle, FloatPoint p_pole) - { - if (p_angle == 0) - { + public TileShape rotate_approx(double p_angle, FloatPoint p_pole) { + if (p_angle == 0) { return this; } IntPoint[] new_corners = new IntPoint[border_line_count()]; - for (int i = 0; i < new_corners.length; ++i) - { + for (int i = 0; i < new_corners.length; ++i) { new_corners[i] = this.corner_approx(i).rotate(p_angle, p_pole).round(); } Polygon corner_polygon = new Polygon(new_corners); Point[] polygon_corners = corner_polygon.corner_array(); TileShape result; - if (polygon_corners.length >= 3) - { + if (polygon_corners.length >= 3) { result = get_instance(polygon_corners); - } - else if (polygon_corners.length == 2) - { + } else if (polygon_corners.length == 2) { Polyline curr_polyline = new Polyline(polygon_corners); LineSegment curr_segment = new LineSegment(curr_polyline, 0); result = curr_segment.to_simplex(); - } - else if (polygon_corners.length == 1) - { + } else if (polygon_corners.length == 1) { result = get_instance(polygon_corners[0]); - } - else - { + } else { result = Simplex.EMPTY; } return result; } - public TileShape mirror_vertical(IntPoint p_pole) - { + public TileShape mirror_vertical(IntPoint p_pole) { Line[] new_lines = new Line[border_line_count()]; - for (int i = 0; i < new_lines.length; ++i) - { + for (int i = 0; i < new_lines.length; ++i) { new_lines[i] = this.border_line(i).mirror_vertical(p_pole); } return get_instance(new_lines); } - public TileShape mirror_horizontal(IntPoint p_pole) - { + public TileShape mirror_horizontal(IntPoint p_pole) { Line[] new_lines = new Line[border_line_count()]; - for (int i = 0; i < new_lines.length; ++i) - { + for (int i = 0; i < new_lines.length; ++i) { new_lines[i] = this.border_line(i).mirror_horizontal(p_pole); } return get_instance(new_lines); @@ -913,10 +772,8 @@ public TileShape mirror_horizontal(IntPoint p_pole) * Calculates the border line of this shape intersecting the ray from p_from_point into the direction p_direction. * p_from_point is assumed to be inside this shape, otherwise -1 is returned. */ - public int intersecting_border_line_no(Point p_from_point, Direction p_direction) - { - if (!this.contains(p_from_point)) - { + public int intersecting_border_line_no(Point p_from_point, Direction p_direction) { + if (!this.contains(p_from_point)) { return -1; } FloatPoint from_point = p_from_point.to_float(); @@ -924,20 +781,16 @@ public int intersecting_border_line_no(Point p_from_point, Direction p_direction FloatPoint second_line_point = intersection_line.b.to_float(); int result = -1; double min_distance = Float.MAX_VALUE; - for (int i = 0; i < this.border_line_count(); ++i) - { + for (int i = 0; i < this.border_line_count(); ++i) { Line curr_border_line = this.border_line(i); FloatPoint curr_intersection = curr_border_line.intersection_approx(intersection_line); - if (curr_intersection.x >= Integer.MAX_VALUE) - { + if (curr_intersection.x >= Integer.MAX_VALUE) { continue; // lines are parallel } double curr_distence = curr_intersection.distance_square(from_point); - if (curr_distence < min_distance) - { + if (curr_distence < min_distance) { boolean direction_ok = curr_border_line.side_of(second_line_point) == Side.ON_THE_LEFT || second_line_point.distance_square(curr_intersection) < curr_distence; - if (direction_ok) - { + if (direction_ok) { result = i; min_distance = curr_distence; } @@ -960,22 +813,18 @@ public int intersecting_border_line_no(Point p_from_point, Direction p_direction * simplex, which is crossed there. * That means that the entrance point is the intersection of this 2 lines. */ - public int[][] entrance_points(Polyline p_polyline) - { + public int[][] entrance_points(Polyline p_polyline) { int[][] result = new int[2 * p_polyline.arr.length][2]; int intersection_count = 0; int prev_intersection_line_no = -1; int prev_intersection_edge_no = -1; - for (int line_no = 1; line_no < p_polyline.arr.length - 1; ++line_no) - { + for (int line_no = 1; line_no < p_polyline.arr.length - 1; ++line_no) { LineSegment curr_line_seg = new LineSegment(p_polyline, line_no); int[] curr_intersections = curr_line_seg.border_intersections(this); - for (int i = 0; i < curr_intersections.length; ++i) - { + for (int i = 0; i < curr_intersections.length; ++i) { int edge_no = curr_intersections[i]; if (line_no != prev_intersection_line_no || - edge_no != prev_intersection_edge_no) - { + edge_no != prev_intersection_edge_no) { result[intersection_count][0] = line_no; result[intersection_count][1] = edge_no; ++intersection_count; @@ -985,10 +834,8 @@ public int[][] entrance_points(Polyline p_polyline) } } int[][] normalized_result = new int[intersection_count][2]; - for (int j = 0; j < intersection_count; ++j) - { - for (int i = 0; i < 2; ++i) - { + for (int j = 0; j < intersection_count; ++j) { + for (int i = 0; i < 2; ++i) { normalized_result[j][i] = result[j][i]; } } @@ -1001,8 +848,7 @@ public int[][] entrance_points(Polyline p_polyline) * Pieces completely contained in the border of this shape * are not returned. */ - public Polyline[] cutout(Polyline p_polyline) - { + public Polyline[] cutout(Polyline p_polyline) { int[][] intersection_no = this.entrance_points(p_polyline); Point first_corner = p_polyline.first_corner(); boolean first_corner_is_inside = this.contains_inside(first_corner); @@ -1036,8 +882,7 @@ public Polyline[] cutout(Polyline p_polyline) // close the polyline piece with the intersected edge line. curr_lines[curr_polyline_intersection_no + 1] = this.border_line(curr_intersection_tuple[1]); Polyline curr_piece = new Polyline(curr_lines); - if (!curr_piece.is_empty()) - { + if (!curr_piece.is_empty()) { pieces.add(curr_piece); } } @@ -1058,25 +903,21 @@ public Polyline[] cutout(Polyline p_polyline) // and can be ignored boolean insert_piece = false; for (int i = curr_intersection_no_of_polyline + 1; - i < next_intersection_no_of_polyline; ++i) - { - if (this.is_outside(p_polyline.corner(i))) - { + i < next_intersection_no_of_polyline; ++i) { + if (this.is_outside(p_polyline.corner(i))) { insert_piece = true; break; } } - if (insert_piece) - { + if (insert_piece) { Line[] curr_lines = new Line[next_intersection_no_of_polyline - curr_intersection_no_of_polyline + 3]; curr_lines[0] = this.border_line(curr_intersection_tuple[1]); System.arraycopy(p_polyline.arr, curr_intersection_no_of_polyline, curr_lines, 1, curr_lines.length - 2); curr_lines[curr_lines.length - 1] = this.border_line(next_intersection_tuple[1]); Polyline curr_piece = new Polyline(curr_lines); - if (!curr_piece.is_empty()) - { + if (!curr_piece.is_empty()) { pieces.add(curr_piece); } } @@ -1092,22 +933,19 @@ public Polyline[] cutout(Polyline p_polyline) System.arraycopy(p_polyline.arr, curr_polyline_intersection_no, curr_lines, 1, curr_lines.length - 1); Polyline curr_piece = new Polyline(curr_lines); - if (!curr_piece.is_empty()) - { + if (!curr_piece.is_empty()) { pieces.add(curr_piece); } } Polyline[] result = new Polyline[pieces.size()]; Iterator it = pieces.iterator(); - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = it.next(); } return result; } - public TileShape[] split_to_convex() - { + public TileShape[] split_to_convex() { TileShape[] result = new TileShape[1]; result[0] = this; return result; @@ -1117,28 +955,23 @@ public TileShape[] split_to_convex() * Divides this shape into sections with width and height at most p_max_section_width * of about equal size. */ - public TileShape[] divide_into_sections(double p_max_section_width) - { - if (this.is_empty()) - { + public TileShape[] divide_into_sections(double p_max_section_width) { + if (this.is_empty()) { TileShape[] result = new TileShape[1]; result[0] = this; return result; } TileShape[] section_boxes = this.bounding_box().divide_into_sections(p_max_section_width); Collection section_list = new LinkedList(); - for (int i = 0; i < section_boxes.length; ++i) - { + for (int i = 0; i < section_boxes.length; ++i) { TileShape curr_section = this.intersection_with_simplify(section_boxes[i]); - if (curr_section.dimension() == 2) - { + if (curr_section.dimension() == 2) { section_list.add(curr_section); } } TileShape[] result = new TileShape[section_list.size()]; Iterator it = section_list.iterator(); - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = it.next(); } return result; @@ -1147,28 +980,23 @@ public TileShape[] divide_into_sections(double p_max_section_width) /** * Checks, if p_line_segment has a common point with the interiour of this shape. */ - public boolean is_intersected_interiour_by(LineSegment p_line_segment) - { + public boolean is_intersected_interiour_by(LineSegment p_line_segment) { FloatPoint float_start_point = p_line_segment.start_point_approx(); FloatPoint float_end_point = p_line_segment.end_point_approx(); Side[] border_line_side_of_start_point_arr = new Side[this.border_line_count()]; Side[] border_line_side_of_end_point_arr = new Side[border_line_side_of_start_point_arr.length]; - for (int i = 0; i < border_line_side_of_start_point_arr.length; ++i) - { + for (int i = 0; i < border_line_side_of_start_point_arr.length; ++i) { Line curr_border_line = this.border_line(i); Side border_line_side_of_start_point = curr_border_line.side_of(float_start_point, 1); - if (border_line_side_of_start_point == Side.COLLINEAR) - { + if (border_line_side_of_start_point == Side.COLLINEAR) { border_line_side_of_start_point = curr_border_line.side_of(p_line_segment.start_point()); } Side border_line_side_of_end_point = curr_border_line.side_of(float_end_point, 1); - if (border_line_side_of_end_point == Side.COLLINEAR) - { + if (border_line_side_of_end_point == Side.COLLINEAR) { border_line_side_of_end_point = curr_border_line.side_of(p_line_segment.end_point()); } - if (border_line_side_of_start_point != Side.ON_THE_RIGHT && border_line_side_of_end_point != Side.ON_THE_RIGHT) - { + if (border_line_side_of_start_point != Side.ON_THE_RIGHT && border_line_side_of_end_point != Side.ON_THE_RIGHT) { // both endpoints are outside the border_line, // no intersection possible return false; @@ -1177,65 +1005,50 @@ public boolean is_intersected_interiour_by(LineSegment p_line_segment) border_line_side_of_end_point_arr[i] = border_line_side_of_end_point; } boolean start_point_is_inside = true; - for (int i = 0; i < border_line_side_of_start_point_arr.length; ++i) - { - if (border_line_side_of_start_point_arr[i] != Side.ON_THE_RIGHT) - { + for (int i = 0; i < border_line_side_of_start_point_arr.length; ++i) { + if (border_line_side_of_start_point_arr[i] != Side.ON_THE_RIGHT) { start_point_is_inside = false; break; } } - if (start_point_is_inside) - { + if (start_point_is_inside) { return true; } boolean end_point_is_inside = true; - for (int i = 0; i < border_line_side_of_end_point_arr.length; ++i) - { - if (border_line_side_of_end_point_arr[i] != Side.ON_THE_RIGHT) - { + for (int i = 0; i < border_line_side_of_end_point_arr.length; ++i) { + if (border_line_side_of_end_point_arr[i] != Side.ON_THE_RIGHT) { end_point_is_inside = false; break; } } - if (end_point_is_inside) - { + if (end_point_is_inside) { return true; } Line segment_line = p_line_segment.get_line(); // Check, if this line segments intersect a border line of p_shape. - for (int i = 0; i < border_line_side_of_start_point_arr.length; ++i) - { + for (int i = 0; i < border_line_side_of_start_point_arr.length; ++i) { Side border_line_side_of_start_point = border_line_side_of_start_point_arr[i]; Side border_line_side_of_end_point = border_line_side_of_end_point_arr[i]; - if (border_line_side_of_start_point != border_line_side_of_end_point) - { - if (border_line_side_of_start_point == Side.COLLINEAR && border_line_side_of_end_point == Side.ON_THE_LEFT || border_line_side_of_end_point == Side.COLLINEAR && border_line_side_of_start_point == Side.ON_THE_LEFT) - { + if (border_line_side_of_start_point != border_line_side_of_end_point) { + if (border_line_side_of_start_point == Side.COLLINEAR && border_line_side_of_end_point == Side.ON_THE_LEFT || border_line_side_of_end_point == Side.COLLINEAR && border_line_side_of_start_point == Side.ON_THE_LEFT) { // the interiour of p_shape is not intersected. continue; } Side prev_corner_side = segment_line.side_of(this.corner_approx(i), 1); - if (prev_corner_side == Side.COLLINEAR) - { + if (prev_corner_side == Side.COLLINEAR) { prev_corner_side = segment_line.side_of(this.corner(i)); } int next_corner_index; - if (i == border_line_side_of_start_point_arr.length - 1) - { + if (i == border_line_side_of_start_point_arr.length - 1) { next_corner_index = 0; - } - else - { + } else { next_corner_index = i + 1; } Side next_corner_side = segment_line.side_of(this.corner_approx(next_corner_index), 1); - if (next_corner_side == Side.COLLINEAR) - { + if (next_corner_side == Side.COLLINEAR) { next_corner_side = segment_line.side_of(this.corner(next_corner_index)); } - if (prev_corner_side == Side.ON_THE_LEFT && next_corner_side == Side.ON_THE_RIGHT || prev_corner_side == Side.ON_THE_RIGHT && next_corner_side == Side.ON_THE_LEFT) - { + if (prev_corner_side == Side.ON_THE_LEFT && next_corner_side == Side.ON_THE_RIGHT || prev_corner_side == Side.ON_THE_RIGHT && next_corner_side == Side.ON_THE_LEFT) { // this line segment crosses a border line of p_shape return true; } diff --git a/src/main/java/net/freerouting/geometry/planar/Vector.java b/src/main/java/net/freerouting/geometry/planar/Vector.java index f94bb49b..29e66314 100644 --- a/src/main/java/net/freerouting/geometry/planar/Vector.java +++ b/src/main/java/net/freerouting/geometry/planar/Vector.java @@ -20,10 +20,10 @@ package net.freerouting.geometry.planar; -import java.math.BigInteger; - import net.freerouting.datastructures.Signum; +import java.math.BigInteger; + /** * Abstract class describing functionality of Vectors. * Vectors are used for translating Points in the plane. @@ -31,208 +31,198 @@ * @author Alfons Wirtz */ -public abstract class Vector implements java.io.Serializable -{ - +public abstract class Vector implements java.io.Serializable { + + /** + * Standard implementation of the zero vector . + */ + public static final IntVector ZERO = new IntVector(0, 0); + + /** + * Creates a Vector (p_x, p_y) in the plane. + */ + public static Vector get_instance(int p_x, int p_y) { + IntVector result = new IntVector(p_x, p_y); + if (Math.abs(p_x) > Limits.CRIT_INT || + Math.abs(p_x) > Limits.CRIT_INT) { + return new RationalVector(result); + } + return result; + } + + /** + * Creates a 2-dimensinal Vector from the 3 input values. + * If p_z != 0 it correspondents to the Vector in the plane + * with rational number coordinates (p_x / p_z, p_y / p_z). + */ + public static Vector get_instance(BigInteger p_x, BigInteger p_y, + BigInteger p_z) { + if (p_z.signum() < 0) { + // the dominator z of a RationalVector is expected to be positive + p_x = p_x.negate(); + p_y = p_y.negate(); + p_z = p_z.negate(); + + } + if ((p_x.mod(p_z)).signum() == 0 && (p_x.mod(p_z)).signum() == 0) { + // p_x and p_y can be divided by p_z + p_x = p_x.divide(p_z); + p_y = p_y.divide(p_z); + p_z = BigInteger.ONE; + } + if (p_z.equals(BigInteger.ONE)) { + if ((p_x.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0 && + (p_y.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0) { + // the Point fits into an IntPoint + return new IntVector(p_x.intValue(), p_y.intValue()); + } + } + return new RationalVector(p_x, p_y, p_z); + } + /** * returns true, if this vector is equal to the zero vector. */ public abstract boolean is_zero(); - + /** * returns the Vector such that this plus this.negate() is zero */ public abstract Vector negate(); - + /** * adds p_other to this vector */ - public abstract Vector add( Vector p_other); - + public abstract Vector add(Vector p_other); + /** * Let L be the line from the Zero Vector to p_other. * The function returns - * Side.ON_THE_LEFT, if this Vector is on the left of L - * Side.ON_THE_RIGHT, if this Vector is on the right of L - * and Side.COLLINEAR, if this Vector is collinear with L. + * Side.ON_THE_LEFT, if this Vector is on the left of L + * Side.ON_THE_RIGHT, if this Vector is on the right of L + * and Side.COLLINEAR, if this Vector is collinear with L. */ public abstract Side side_of(Vector p_other); - + /** * returns true, if the vector is horizontal or vertical */ public abstract boolean is_orthogonal(); - + /** * returns true, if the vector is diagonal */ public abstract boolean is_diagonal(); - + /** * Returns true, if the vector is orthogonal or diagonal */ - public boolean is_multiple_of_45_degree() - { + public boolean is_multiple_of_45_degree() { return is_orthogonal() || is_diagonal(); } - + /** * The function returns - * Signum.POSITIVE, if the scalar product of this vector and p_other > 0, - * Signum.NEGATIVE, if the scalar product Vector is < 0, - * and Signum.ZERO, if the scalar product is equal 0. + * Signum.POSITIVE, if the scalar product of this vector and p_other > 0, + * Signum.NEGATIVE, if the scalar product Vector is < 0, + * and Signum.ZERO, if the scalar product is equal 0. */ public abstract Signum projection(Vector p_other); - + /** * Returns an approximation of the scalar product of this vector * with p_other by a double. */ public abstract double scalar_product(Vector p_other); - + /** * approximates the coordinates of this vector by float coordinates */ public abstract FloatPoint to_float(); - + /** * Turns this vector by p_factor times 90 degree. */ public abstract Vector turn_90_degree(int p_factor); - + /** * Mirrors this vector at the x axis. */ public abstract Vector mirror_at_x_axis(); - + /** * Mirrors this vector at the y axis. */ public abstract Vector mirror_at_y_axis(); - - /** - * Standard implementation of the zero vector . - */ - public static final IntVector ZERO = new IntVector(0, 0); - - /** - * Creates a Vector (p_x, p_y) in the plane. - */ - public static Vector get_instance(int p_x, int p_y) - { - IntVector result = new IntVector(p_x, p_y); - if ( Math.abs(p_x) > Limits.CRIT_INT || - Math.abs(p_x) > Limits.CRIT_INT ) - { - return new RationalVector(result); - } - return result; - } - - /** - * Creates a 2-dimensinal Vector from the 3 input values. - * If p_z != 0 it correspondents to the Vector in the plane - * with rational number coordinates (p_x / p_z, p_y / p_z). - */ - public static Vector get_instance(BigInteger p_x, BigInteger p_y, - BigInteger p_z) - { - if (p_z.signum() < 0) - { - // the dominator z of a RationalVector is expected to be positive - p_x = p_x.negate(); - p_y = p_y.negate(); - p_z = p_z.negate(); - - } - if ((p_x.mod(p_z)).signum() == 0 && (p_x.mod(p_z)).signum() == 0) - { - // p_x and p_y can be divided by p_z - p_x = p_x.divide(p_z); - p_y = p_y.divide(p_z); - p_z = BigInteger.ONE; - } - if (p_z.equals(BigInteger.ONE)) - { - if ( (p_x.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0 && - (p_y.abs()).compareTo(Limits.CRIT_INT_BIG) <= 0 ) - { - // the Point fits into an IntPoint - return new IntVector(p_x.intValue(), p_y.intValue()); - } - } - return new RationalVector(p_x, p_y, p_z); - } - + /** * returns an approximation of the euclidian length of this vector */ - public double length_approx() - { + public double length_approx() { return this.to_float().size(); } - - + + /** * Returns an approximation of the cosinus of the angle * between this vector and p_other by a double. */ - public double cos_angle(Vector p_other) - { + public double cos_angle(Vector p_other) { double result = this.scalar_product(p_other); result /= this.to_float().size() * p_other.to_float().size(); return result; } - + /** * Returns an approximation of the signed angle between this vector and p_other. */ - public double angle_approx(Vector p_other) - { + public double angle_approx(Vector p_other) { double result = Math.acos(cos_angle(p_other)); - if (this.side_of(p_other) == Side.ON_THE_LEFT) - { - result = - result; + if (this.side_of(p_other) == Side.ON_THE_LEFT) { + result = -result; } return result; } - + /** * Returns an approximation of the signed angle between this vector and the x axis. */ - public double angle_approx() - { + public double angle_approx() { Vector other = new IntVector(1, 0); return other.angle_approx(this); } - + /** * Returns an approximation vector of this vector with the same direction and * length p_length. */ public abstract Vector change_length_approx(double p_lenght); - + abstract Direction to_normalized_direction(); - - - + + // auxiliary functions needed because the virtual function mechanism // does not work in parameter position - - abstract Vector add( IntVector p_other); - abstract Vector add( RationalVector p_other); - + + abstract Vector add(IntVector p_other); + + abstract Vector add(RationalVector p_other); + abstract Point add_to(IntPoint p_point); + abstract Point add_to(RationalPoint p_point); - + abstract Side side_of(IntVector p_other); + abstract Side side_of(RationalVector p_other); - + abstract Signum projection(IntVector p_other); + abstract Signum projection(RationalVector p_other); - + abstract double scalar_product(IntVector p_other); + abstract double scalar_product(RationalVector p_other); - - + + } \ No newline at end of file diff --git a/src/main/java/net/freerouting/geometry/planar/package.html b/src/main/java/net/freerouting/geometry/planar/package.html index 5a5f6b41..a104068f 100644 --- a/src/main/java/net/freerouting/geometry/planar/package.html +++ b/src/main/java/net/freerouting/geometry/planar/package.html @@ -1,5 +1,6 @@ -java.text package - Contains general purpose 2-dimensional geometry classes. -

-

Some preliminary considerations on computational geometry: +Contains general purpose 2-dimensional geometry classes. + +
+

Some preliminary considerations on computational geometry:

-

What is better in arithmetic calculations? Using floating-point or fixed-point arithmetic? In floating-point arithmetic we can forget about absolute exactness. There is for example no way to find out if three points are exactly collinear in floating-point arithmetic. In fixed-point arithmetic however there is an easy way to calculate for any line, if a point is on the left, on the right, or exact on this line. That exactness is the main reason to prefer fixed-point (integer) arithmetic to floating-point arithmetic in computational geometry. 

-

With integer arithmetic we get no problems in calculations with orthogonal lines, and some limited problems with 45-degree lines. With any-angle lines however there is a problem. Between the start point and the end point of a line segment there may not exist a single integer point exact on the line. Also the intersection of two lines can in general not be represented exactly by an integer point.

-

Can we get exactness in calculations with shapes defined by integer points in spite of this? + +

What is better in arithmetic calculations? Using floating-point or fixed-point arithmetic? In floating-point arithmetic we can forget about absolute exactness. There is for example no way to find out if three points are exactly collinear in floating-point arithmetic. In fixed-point arithmetic however there is an easy way to calculate for any line, if a point is on the left, on the right, or exact on this line. That exactness is the main reason to prefer fixed-point (integer) arithmetic to floating-point arithmetic in computational geometry. 

+ +

With integer arithmetic we get no problems in calculations with orthogonal lines, and some limited problems with 45-degree lines. With any-angle lines however there is a problem. Between the start point and the end point of a line segment there may not exist a single integer point exact on the line. Also the intersection of two lines can in general not be represented exactly by an integer point. +

+ +

Can we get exactness in calculations with shapes defined by integer points in spite of this?

-

Suppose we represent polygon shapes by its corner points. The intersection of two polygon shapes is then represented by a subset of the corners of the two polygons and the intersections of its boundary line segments. But these line intersections can in general not be represented by integer points. If we round them to integer points, the result will not be exact. + +

Suppose we represent polygon shapes by its corner points. The intersection of two polygon shapes is then represented by a subset of the corners of the two polygons and the intersections of its boundary line segments. But these line intersections can in general not be represented by integer points. If we round them to integer points, the result will not be exact.

-

But we can do better. We can represent shapes by its boundary lines instead of its corner points.  The intersection of two shapes is then described by a subset of the boundary lines of the shapes. The only work to do is skipping boundary lines that do not contribute to the result. But because we have not calculated any new geometrical objects, the result of this calculation remains exact. + +

But we can do better. We can represent shapes by its boundary lines instead of its corner points.  The intersection of two shapes is then described by a subset of the boundary lines of the shapes. The only work to do is skipping boundary lines that do not contribute to the result. But because we have not calculated any new geometrical objects, the result of this calculation remains exact.

-

Similar problems exist with polygons for example. Therefore we will not represent them by a sequence of corner points, but by a sequence of lines with integer coordinates. + +

Similar problems exist with polygons for example. Therefore we will not represent them by a sequence of corner points, but by a sequence of lines with integer coordinates.

-

Although our key concern will be on fixed-point (integer) arithmetic, we will also use some floating-point and infinite precision rational number arithmetic in our geometry system. + +

Although our key concern will be on fixed-point (integer) arithmetic, we will also use some floating-point and infinite precision rational number arithmetic in our geometry system.

-

General Programming Principles used in the code: + +

General Programming Principles used in the code:

-

Principle 1: Immutability + +

Principle 1: Immutability

-

An object is called immutable, if its content will never change after it is constructed. In this prototype all objects are created immutable, if there is no good reason to do otherwise. In a language with a garbage collector there never arises the need to copy an immutable object. Instead just another reference to the object can be added. That is safe because nobody else is allowed to change the object. The garbage collector recycles the object automatically, when there is no more reference to it. Immutable objects also have no synchronisation problems, in case they are accessed by several threads simultaneously.

-

Having objects in geometry immutable lets them look much more like they are used in school or university mathematics. You do not expect in mathematics for example, that the coordinates of a point will change later on. + +

An object is called immutable, if its content will never change after it is constructed. In this prototype all objects are created immutable, if there is no good reason to do otherwise. In a language with a garbage collector there never arises the need to copy an immutable object. Instead just another reference to the object can be added. That is safe because nobody else is allowed to change the object. The garbage collector recycles the object automatically, when there is no more reference to it. Immutable objects also have no synchronisation problems, in case they are accessed by several threads simultaneously. +

+ +

Having objects in geometry immutable lets them look much more like they are used in school or university mathematics. You do not expect in mathematics for example, that the coordinates of a point will change later on.

-

Principle 2: Abstract Data Types + +

Principle 2: Abstract Data Types

-

Object variables should be of abstract classes, if possible. Concrete classes should only be used in the creation of objects, that is on the right side of the ‘new’ keyword or in a so-called factory method. That makes it easy to exchange and mix several implementations of an abstract class. The user has no access to the actual implementation, but only to the abstract functions every implementation must provide. There is one major problem. The virtual function mechanism does not work in parameter position. This means that the appropriate concrete class will not be found automatically, if an abstract class is provided in parameter position. Adding for such functions a private helper function for each concrete implementation of the abstract class solves the problem, as long as the function has no more than one abstract parameter. This solution still looks reasonable. Until now I could always avoid the need for functions to have more than one abstract parameter. Functions with many parameters may be bad designed anyway. + +

Object variables should be of abstract classes, if possible. Concrete classes should only be used in the creation of objects, that is on the right side of the ‘new’ keyword or in a so-called factory method. That makes it easy to exchange and mix several implementations of an abstract class. The user has no access to the actual implementation, but only to the abstract functions every implementation must provide. There is one major problem. The virtual function mechanism does not work in parameter position. This means that the appropriate concrete class will not be found automatically, if an abstract class is provided in parameter position. Adding for such functions a private helper function for each concrete implementation of the abstract class solves the problem, as long as the function has no more than one abstract parameter. This solution still looks reasonable. Until now I could always avoid the need for functions to have more than one abstract parameter. Functions with many parameters may be bad designed anyway.

-

Description of the package: + +

Description of the package:

-

This packages contains the implementation of 2-dimensional geometric objects such as points, vectors, lines, shapes, and so on.

-

The abstract class Point for example defines the behaviour, which must be implemented by each concrete Point class.  There are two concrete implementations of the class Point at the moment, the class IntPoint, which implements the Point as a tuple of integer values, and the class RationalPoint. The class RationalPoint implements infinite precision integer points in the projective plane. This is a generalisation of an implementation of infinite precision rational points in the affine plane. With RationalPoints for example the intersection of two lines can always be calculated exactly. The usage of these two classes is mixed and RationalPoints will always be converted to IntPoints if possible, to improve the performance.

-

Strongly related to the class Point is the class Vector. A Vector can be added to a Point resulting in another Point. A Point can be subtracted from another Point resulting in a Vector. Of course two vectors can be added resulting in another vector. For every vector v there exists the negative vector v.negate () so that v + v.negate () is the zero vector. + +

This packages contains the implementation of 2-dimensional geometric objects such as points, vectors, lines, shapes, and so on. +

+ +

The abstract class Point for example defines the behaviour, which must be implemented by each concrete Point class.  There are two concrete implementations of the class Point at the moment, the class IntPoint, which implements the Point as a tuple of integer values, and the class RationalPoint. The class RationalPoint implements infinite precision integer points in the projective plane. This is a generalisation of an implementation of infinite precision rational points in the affine plane. With RationalPoints for example the intersection of two lines can always be calculated exactly. The usage of these two classes is mixed and RationalPoints will always be converted to IntPoints if possible, to improve the performance. +

+ +

Strongly related to the class Point is the class Vector. A Vector can be added to a Point resulting in another Point. A Point can be subtracted from another Point resulting in a Vector. Of course two vectors can be added resulting in another vector. For every vector v there exists the negative vector v.negate () so that v + v.negate () is the zero vector.

-

Instead of angles we use Directions in our geometry system. The reason is that for a Line (to be defined later) its Direction can be represented exactly while its angle can be not. The best we can do with angles is to approximate them by floating point numbers. But in this case there exists for example no exact algorithm to determine if two angles are equal. A Direction is defined as an equivalence class of Vectors. Two vectors define the same Direction, if they point into the same direction. + +

Instead of angles we use Directions in our geometry system. The reason is that for a Line (to be defined later) its Direction can be represented exactly while its angle can be not. The best we can do with angles is to approximate them by floating point numbers. But in this case there exists for example no exact algorithm to determine if two angles are equal. A Direction is defined as an equivalence class of Vectors. Two vectors define the same Direction, if they point into the same direction.

-

Directions are ordered in the following way. A Direction d1 is bigger than a Direction d2, if it has a bigger angle with the positive X-axis. We can compare the size of 2 Directions by calculating the determinant of their defining vectors. This calculation is exact in integer arithmetic. + +

Directions are ordered in the following way. A Direction d1 is bigger than a Direction d2, if it has a bigger angle with the positive X-axis. We can compare the size of 2 Directions by calculating the determinant of their defining vectors. This calculation is exact in integer arithmetic.

-

An object of the class Line is defined as an infinite directed line. In addition to an ordinary infinite line a directed line defines a positive and a negative half-plane. The positive half-plane is to the left of the line, and the negative half-plane to the right. Such a Line is represented by a tuple of abstract points (a, b) on the line, which are assumed to be not equal. The positive half-plane is the set of points p, so that a path from a to b to p makes a left turn. Of course two different tuples of points can define the same line. + +

An object of the class Line is defined as an infinite directed line. In addition to an ordinary infinite line a directed line defines a positive and a negative half-plane. The positive half-plane is to the left of the line, and the negative half-plane to the right. Such a Line is represented by a tuple of abstract points (a, b) on the line, which are assumed to be not equal. The positive half-plane is the set of points p, so that a path from a to b to p makes a left turn. Of course two different tuples of points can define the same line.

-

The class FloatPoint is used in arithmetic calculations, where execution speed is more important than numerical accuracy.  The class Line for example contains the two methods: “intersection” and “intersection_approx”. Both of them calculate the intersection of two lines. The function “intersection” returns an object of the abstract class Point. The result is exact, but the calculation may be slow, because it uses infinite precision arithmetic.

-

The function “intersection_approx” uses double precision floating point arithmetic to calculate an object of the class FloatPoint. This calculation is quite fast, but the result of floating point arithmetic is not exact in general.

-

Because all calculations in the abstract class Point are expected to be exact, FloatPoint is not derived from the abstract class Point, as IntPoint and RationalPoint are. + +

The class FloatPoint is used in arithmetic calculations, where execution speed is more important than numerical accuracy.  The class Line for example contains the two methods: “intersection” and “intersection_approx”. Both of them calculate the intersection of two lines. The function “intersection” returns an object of the abstract class Point. The result is exact, but the calculation may be slow, because it uses infinite precision arithmetic. +

+ +

The function “intersection_approx” uses double precision floating point arithmetic to calculate an object of the class FloatPoint. This calculation is quite fast, but the result of floating point arithmetic is not exact in general. +

+ +

Because all calculations in the abstract class Point are expected to be exact, FloatPoint is not derived from the abstract class Point, as IntPoint and RationalPoint are.

-

In the following section we describe the class hierarchy describing shapes in the plane. The root of the hierarchy is the interface Area. It defines  functionality of  of connected 2-dimensional sets of points in the plane, which need not necessarily to be simply connected. (For non mathematicians that means an Area may have holes.)  Derived from the Interface Area is the interface Shape, which defines functionality for simply connected areas (areas without holes). Derived from the interface Shape are the Interface ConvexShape and the abstract class PolylineShape. A shape is convex, if for any 2 points a, b inside the shape the line segment from a to b is contained completely in the shape. A PolylineShape is defined as a shape, whose border consists of  a sequence of straight lines. Derived from PolylineShape is the class PolygonShape. A PolygonShape is a PolylineShape represented by a closed polygon of corner points. From ConvexShape the class Circle and  the abstract class TileShape are derived. TileShape is also derived from PolylineShape,  There are currently 3 implementations of the class TileShape : IntBox, IntOctagon and Simplex. IntBoxes are axis parallel rectangles with int coordinates, IntOctagons are convex shapes, whose boundary line angles are multiples of 45 degree,

-

A Simplex is implemented as a finite set of lines. The shape of a Simplex is defined as the intersection of all positive half-planes of its lines. Simplexes are similar to convex polygons defined by a finite set of corner points. The difference is that a Simplex may contain infinite parts. A half-plane for example is a Simplex, but not a convex polygon. In an Integer geometry system using Simplexes instead of convex polygons has many advantages. Assume for example that we want to calculate the intersection of two polygons. For this purpose we have to calculate the intersections of the crossing edge lines. These intersections are in general no longer integer points. This means, that the intersection of two convex polygons can not be represented exactly by a convex polygon with integer coordinates. We could use RationalPoints for the corners to achieve this goal, but then the arithmetic calculations would get very slow. Calculating the intersection of two Simplexes is quite different. We just take the sum of the defining lines of the two Simplexes. The real work is skipping the lines, which do not contribute to the result. So the intersection of two Simplexes calculated in this way is exact, even if our lines have integer coordinates. A RegularTileShape is a TileShape, where the directions of the boundary lines may only be from a fixed finite set. IntBoxes and IntOctagons are RegularTileShape´s, but Simplexes are not. + +

In the following section we describe the class hierarchy describing shapes in the plane. The root of the hierarchy is the interface Area. It defines  functionality of  of connected 2-dimensional sets of points in the plane, which need not necessarily to be simply connected. (For non mathematicians that means an Area may have holes.)  Derived from the Interface Area is the interface Shape, which defines functionality for simply connected areas (areas without holes). Derived from the interface Shape are the Interface ConvexShape and the abstract class PolylineShape. A shape is convex, if for any 2 points a, b inside the shape the line segment from a to b is contained completely in the shape. A PolylineShape is defined as a shape, whose border consists of  a sequence of straight lines. Derived from PolylineShape is the class PolygonShape. A PolygonShape is a PolylineShape represented by a closed polygon of corner points. From ConvexShape the class Circle and  the abstract class TileShape are derived. TileShape is also derived from PolylineShape,  There are currently 3 implementations of the class TileShape : IntBox, IntOctagon and Simplex. IntBoxes are axis parallel rectangles with int coordinates, IntOctagons are convex shapes, whose boundary line angles are multiples of 45 degree, +

+ +

A Simplex is implemented as a finite set of lines. The shape of a Simplex is defined as the intersection of all positive half-planes of its lines. Simplexes are similar to convex polygons defined by a finite set of corner points. The difference is that a Simplex may contain infinite parts. A half-plane for example is a Simplex, but not a convex polygon. In an Integer geometry system using Simplexes instead of convex polygons has many advantages. Assume for example that we want to calculate the intersection of two polygons. For this purpose we have to calculate the intersections of the crossing edge lines. These intersections are in general no longer integer points. This means, that the intersection of two convex polygons can not be represented exactly by a convex polygon with integer coordinates. We could use RationalPoints for the corners to achieve this goal, but then the arithmetic calculations would get very slow. Calculating the intersection of two Simplexes is quite different. We just take the sum of the defining lines of the two Simplexes. The real work is skipping the lines, which do not contribute to the result. So the intersection of two Simplexes calculated in this way is exact, even if our lines have integer coordinates. A RegularTileShape is a TileShape, where the directions of the boundary lines may only be from a fixed finite set. IntBoxes and IntOctagons are RegularTileShape´s, but Simplexes are not.

-

In the class Polyline curves in the plane consisting of a list of straight lines are described. No two consecutive lines in that list may be parallel. Therefore a Polyline of n lines with integer coordinates is equivalent to a polygon of n – 1 RationalPoints, where the k-th RationalPoint is the intersection of the k-th and the k+1-th line for 0 <= k < n –1 (if we disregard the possibility of integer overflow). We will use the class Polyline especially to describe Traces on a Printed Circuit Board. That enables us to implement a numerical stable any-angle pushing algorithm for traces. The reason is similar as for Simplexes. We do not use intersection points of lines to create the geometry of new trace objects in the pushing algorithm. Instead we use lines, which already exist, for that purpose. That concept is also advantageous when we want to smoothen traces by cutting of corners. If this is done with polygons represented by corners, the intersection of lines has to be calculated and used as primary data. If integer points are used, these intersection points are not exact.  Neighbour lines change slightly and a small clearance violation may occur. If rational points are used, the algorithm gets very slow. With Polylines these problems do not exist, because intersection points of lines never become primary data. + +

In the class Polyline curves in the plane consisting of a list of straight lines are described. No two consecutive lines in that list may be parallel. Therefore a Polyline of n lines with integer coordinates is equivalent to a polygon of n – 1 RationalPoints, where the k-th RationalPoint is the intersection of the k-th and the k+1-th line for 0 <= k < n –1 (if we disregard the possibility of integer overflow). We will use the class Polyline especially to describe Traces on a Printed Circuit Board. That enables us to implement a numerical stable any-angle pushing algorithm for traces. The reason is similar as for Simplexes. We do not use intersection points of lines to create the geometry of new trace objects in the pushing algorithm. Instead we use lines, which already exist, for that purpose. That concept is also advantageous when we want to smoothen traces by cutting of corners. If this is done with polygons represented by corners, the intersection of lines has to be calculated and used as primary data. If integer points are used, these intersection points are not exact.  Neighbour lines change slightly and a small clearance violation may occur. If rational points are used, the algorithm gets very slow. With Polylines these problems do not exist, because intersection points of lines never become primary data.

-

- \ No newline at end of file +

+ + \ No newline at end of file diff --git a/src/main/java/net/freerouting/gui/BoardFrame.java b/src/main/java/net/freerouting/gui/BoardFrame.java index 8622216f..64f8ac32 100644 --- a/src/main/java/net/freerouting/gui/BoardFrame.java +++ b/src/main/java/net/freerouting/gui/BoardFrame.java @@ -27,46 +27,85 @@ import java.io.InputStream; /** - * * Graphical frame of for interactive editing of a routing board. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class BoardFrame extends javax.swing.JFrame -{ - public enum Option - { - FROM_START_MENU, SINGLE_FRAME, SESSION_FILE, EXTENDED_TOOL_BAR - } - +public class BoardFrame extends javax.swing.JFrame { /** - * Creates a new board frame with the input design file imbedded into a host cad software. + * The windows above stored in an array */ - public static BoardFrame get_embedded_instance(String p_design_file_path_name, - BoardObservers p_observers, IdNoGenerator p_id_no_generator, java.util.Locale p_locale) - { - final net.freerouting.gui.DesignFile design_file = net.freerouting.gui.DesignFile.get_instance(p_design_file_path_name); - if (design_file == null) - { - WindowMessage.show("designfile not found"); - return null; - } - net.freerouting.gui.BoardFrame board_frame = new net.freerouting.gui.BoardFrame(design_file, net.freerouting.gui.BoardFrame.Option.SINGLE_FRAME, - TestLevel.RELEASE_VERSION, p_observers, p_id_no_generator, p_locale, false); - - - InputStream input_stream = design_file.get_input_stream(); - boolean read_ok = board_frame.read(input_stream, true, null); - if (!read_ok) - { - String error_message = "Unable to read design file with pathname " + p_design_file_path_name; - board_frame.setVisible(true); // to be able to display the status message - board_frame.screen_messages.set_status_message(error_message); - } - return board_frame; - } - + static final int SUBWINDOW_COUNT = 24; + static final String[] log_file_extensions = {"log"}; + static final String GUI_DEFAULTS_FILE_NAME = "gui_defaults.par"; + static final String GUI_DEFAULTS_FILE_BACKUP_NAME = "gui_defaults.par.bak"; + static final FileFilter logfile_filter = new FileFilter(log_file_extensions); + static javax.help.HelpSet help_set = null; + static javax.help.HelpBroker help_broker = null; + /** + * The scroll pane for the panel of the routing board. + */ + final javax.swing.JScrollPane scroll_pane; + /** + * The menubar of this frame + */ + final BoardMenuBar menubar; + /** + * The panel with the graphical representation of the board. + */ + final BoardPanel board_panel; + final ScreenMessages screen_messages; + /** + * true, if the frame is created by an application running under Java Web Start + */ + final boolean is_web_start = false; + /** + * The panel with the toolbars + */ + private final BoardToolbar toolbar_panel; + /** + * The toolbar used in the selected item state. + */ + private final javax.swing.JToolBar select_toolbar; + /** + * The panel with the message line + */ + private final BoardPanelStatus message_panel; + private final TestLevel test_level; + private final boolean help_system_used; + private final boolean confirm_cancel; + private final java.util.ResourceBundle resources; + private final BoardObservers board_observers; + private final net.freerouting.datastructures.IdNoGenerator item_id_no_generator; + WindowAbout about_window = null; + WindowRouteParameter route_parameter_window = null; + WindowAutorouteParameter autoroute_parameter_window = null; + WindowSelectParameter select_parameter_window = null; + WindowMoveParameter move_parameter_window = null; + WindowClearanceMatrix clearance_matrix_window = null; + WindowVia via_window = null; + WindowEditVias edit_vias_window = null; + WindowNetClasses edit_net_rules_window = null; + WindowAssignNetClass assign_net_classes_window = null; + WindowPadstacks padstacks_window = null; + WindowPackages packages_window = null; + WindowIncompletes incompletes_window = null; + WindowNets net_info_window = null; + WindowClearanceViolations clearance_violations_window = null; + WindowLengthViolations length_violations_window = null; + WindowUnconnectedRoute unconnected_route_window = null; + WindowRouteStubs route_stubs_window = null; + WindowComponents components_window = null; + WindowLayerVisibility layer_visibility_window = null; + WindowObjectVisibility object_visibility_window = null; + WindowDisplayMisc display_misc_window = null; + WindowSnapshot snapshot_window = null; + ColorManager color_manager = null; + BoardSavableSubWindow[] permanent_subwindows = new BoardSavableSubWindow[SUBWINDOW_COUNT]; + java.util.Collection temporary_subwindows = new java.util.LinkedList(); + DesignFile design_file = null; + private java.util.Locale locale; /** * Creates new form BoardFrame. * If p_option = FROM_START_MENU this frame is created from a start menu frame. @@ -79,24 +118,21 @@ public static BoardFrame get_embedded_instance(String p_design_file_path_name, * Also the warning output depends on p_test_level. */ public BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, - java.util.Locale p_locale, boolean p_confirm_cancel) - { + java.util.Locale p_locale, boolean p_confirm_cancel) { this(p_design, p_option, p_test_level, new net.freerouting.board.BoardObserverAdaptor(), new net.freerouting.board.ItemIdNoGenerator(), p_locale, p_confirm_cancel); } - /** * Creates new form BoardFrame. * The parameters p_item_observers and p_item_id_no_generator are used for syncronizing purposes, * if the frame is embedded into a host system, */ BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, BoardObservers p_observers, - net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, java.util.Locale p_locale, boolean p_confirm_cancel) - { + net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, java.util.Locale p_locale, boolean p_confirm_cancel) { this.design_file = p_design; this.test_level = p_test_level; - + this.confirm_cancel = p_confirm_cancel; this.board_observers = p_observers; this.item_id_no_generator = p_item_id_no_generator; @@ -104,13 +140,10 @@ public BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardFrame", p_locale); BoardMenuBar curr_menubar; boolean session_file_option = (p_option == Option.SESSION_FILE); - boolean curr_help_system_used = true; - try - { + boolean curr_help_system_used = true; + try { curr_menubar = BoardMenuBar.get_instance(this, curr_help_system_used, session_file_option); - } - catch (java.lang.NoClassDefFoundError e) - { + } catch (java.lang.NoClassDefFoundError e) { // the system-file jh.jar may be missing curr_help_system_used = false; curr_menubar = BoardMenuBar.get_instance(this, false, session_file_option); @@ -119,19 +152,19 @@ public BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, this.menubar = curr_menubar; this.help_system_used = curr_help_system_used; setJMenuBar(this.menubar); - + this.toolbar_panel = new BoardToolbar(this); this.add(this.toolbar_panel, java.awt.BorderLayout.NORTH); - + this.message_panel = new BoardPanelStatus(this.locale); this.add(this.message_panel, java.awt.BorderLayout.SOUTH); - + this.select_toolbar = new BoardToolbarSelectedItem(this, p_option == Option.EXTENDED_TOOL_BAR); - + this.screen_messages = new ScreenMessages(this.message_panel.status_message, this.message_panel.add_message, - this.message_panel.current_layer, this.message_panel.mouse_position, this.locale); - + this.message_panel.current_layer, this.message_panel.mouse_position, this.locale); + this.scroll_pane = new javax.swing.JScrollPane(); this.scroll_pane.setPreferredSize(new java.awt.Dimension(1150, 800)); this.scroll_pane.setVerifyInputWhenFocusTarget(false); @@ -139,104 +172,105 @@ public BoardFrame(DesignFile p_design, Option p_option, TestLevel p_test_level, this.board_panel = new BoardPanel(screen_messages, this, p_locale); this.scroll_pane.setViewportView(board_panel); - + this.setTitle(resources.getString("title")); this.addWindowListener(new WindowStateListener()); - + this.pack(); } - + + /** + * Creates a new board frame with the input design file imbedded into a host cad software. + */ + public static BoardFrame get_embedded_instance(String p_design_file_path_name, + BoardObservers p_observers, IdNoGenerator p_id_no_generator, java.util.Locale p_locale) { + final net.freerouting.gui.DesignFile design_file = net.freerouting.gui.DesignFile.get_instance(p_design_file_path_name); + if (design_file == null) { + WindowMessage.show("designfile not found"); + return null; + } + net.freerouting.gui.BoardFrame board_frame = new net.freerouting.gui.BoardFrame(design_file, net.freerouting.gui.BoardFrame.Option.SINGLE_FRAME, + TestLevel.RELEASE_VERSION, p_observers, p_id_no_generator, p_locale, false); + + + InputStream input_stream = design_file.get_input_stream(); + boolean read_ok = board_frame.read(input_stream, true, null); + if (!read_ok) { + String error_message = "Unable to read design file with pathname " + p_design_file_path_name; + board_frame.setVisible(true); // to be able to display the status message + board_frame.screen_messages.set_status_message(error_message); + } + return board_frame; + } + /** * Reads interactive actions from a logfile. */ - void read_logfile(InputStream p_input_stream) - { + void read_logfile(InputStream p_input_stream) { board_panel.board_handling.read_logfile(p_input_stream); } - - + /** * Reads an existing board design from file. * If p_is_import, the design is read from a scpecctra dsn file. * Returns false, if the file is invalid. */ - boolean read(InputStream p_input_stream, boolean p_is_import, javax.swing.JTextField p_message_field) - { + boolean read(InputStream p_input_stream, boolean p_is_import, javax.swing.JTextField p_message_field) { java.awt.Point viewport_position = null; - if (p_is_import) - { + if (p_is_import) { DsnFile.ReadResult read_result = board_panel.board_handling.import_design(p_input_stream, this.board_observers, this.item_id_no_generator, this.test_level); - if (read_result != DsnFile.ReadResult.OK) - { - if (p_message_field != null) - { - if (read_result == DsnFile.ReadResult.OUTLINE_MISSING) - { + if (read_result != DsnFile.ReadResult.OK) { + if (p_message_field != null) { + if (read_result == DsnFile.ReadResult.OUTLINE_MISSING) { p_message_field.setText(resources.getString("error_7")); - } - else - { - p_message_field.setText(resources.getString("error_6")); + } else { + p_message_field.setText(resources.getString("error_6")); } } return false; } - viewport_position = new java.awt.Point(0,0); + viewport_position = new java.awt.Point(0, 0); initialize_windows(); - } - else - { + } else { java.io.ObjectInputStream object_stream = null; - try - { + try { object_stream = new java.io.ObjectInputStream(p_input_stream); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { return false; } boolean read_ok = board_panel.board_handling.read_design(object_stream, this.test_level); - if (!read_ok) - { + if (!read_ok) { return false; } java.awt.Point frame_location; java.awt.Rectangle frame_bounds; - try - { + try { viewport_position = (java.awt.Point) object_stream.readObject(); frame_location = (java.awt.Point) object_stream.readObject(); frame_bounds = (java.awt.Rectangle) object_stream.readObject(); - } - catch (Exception e) - { + } catch (Exception e) { return false; } this.setLocation(frame_location); this.setBounds(frame_bounds); - + allocate_permanent_subwindows(); - - for (int i = 0; i < this.permanent_subwindows.length; ++i) - { + + for (int i = 0; i < this.permanent_subwindows.length; ++i) { this.permanent_subwindows[i].read(object_stream); } } - try - { + try { p_input_stream.close(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { return false; } - + java.awt.Dimension panel_size = board_panel.board_handling.graphics_context.get_panel_size(); board_panel.setSize(panel_size); board_panel.setPreferredSize(panel_size); - if (viewport_position != null) - { + if (viewport_position != null) { board_panel.set_viewport_position(viewport_position); } board_panel.create_popup_menus(); @@ -246,33 +280,25 @@ boolean read(InputStream p_input_stream, boolean p_is_import, javax.swing.JTextF this.toolbar_panel.unit_factor_field.setValue(board_panel.board_handling.coordinate_transform.user_unit_factor); this.toolbar_panel.unit_combo_box.setSelectedItem(board_panel.board_handling.coordinate_transform.user_unit); this.setVisible(true); - if (p_is_import) - { + if (p_is_import) { // Read the default gui settings, if gui default file exists. InputStream input_stream = null; boolean defaults_file_found; File defaults_file = new File(this.design_file.get_parent(), GUI_DEFAULTS_FILE_NAME); defaults_file_found = true; - try - { + try { input_stream = new java.io.FileInputStream(defaults_file); - } catch (java.io.FileNotFoundException e) - { + } catch (java.io.FileNotFoundException e) { defaults_file_found = false; } - if (defaults_file_found) - { + if (defaults_file_found) { boolean read_ok = net.freerouting.gui.GUIDefaultsFile.read(this, board_panel.board_handling, input_stream); - if (!read_ok) - { + if (!read_ok) { screen_messages.set_status_message(resources.getString("error_1")); } - try - { + try { input_stream.close(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { return false; } } @@ -280,82 +306,61 @@ boolean read(InputStream p_input_stream, boolean p_is_import, javax.swing.JTextF } return true; } - - + /** * Saves the interactive settings and the design file to disk. * Returns false, if the save failed. */ - boolean save() - { - if (this.design_file == null) - { + boolean save() { + if (this.design_file == null) { return false; } java.io.OutputStream output_stream = null; java.io.ObjectOutputStream object_stream = null; - try - { + try { output_stream = new java.io.FileOutputStream(this.design_file.get_output_file()); object_stream = new java.io.ObjectOutputStream(output_stream); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { screen_messages.set_status_message(resources.getString("error_2")); return false; - } - catch (java.security.AccessControlException e) - { + } catch (java.security.AccessControlException e) { screen_messages.set_status_message(resources.getString("error_3")); return false; } boolean save_ok = board_panel.board_handling.save_design_file(object_stream); - if (!save_ok) - { + if (!save_ok) { return false; } - try - { + try { object_stream.writeObject(board_panel.get_viewport_position()); object_stream.writeObject(this.getLocation()); object_stream.writeObject(this.getBounds()); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { screen_messages.set_status_message(resources.getString("error_4")); return false; } - for (int i = 0; i < this.permanent_subwindows.length; ++i) - { + for (int i = 0; i < this.permanent_subwindows.length; ++i) { this.permanent_subwindows[i].save(object_stream); } - try - { + try { object_stream.flush(); output_stream.close(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { screen_messages.set_status_message(resources.getString("error_5")); return false; } return true; } - + /** * Sets contexts sensitive help for the input component, if the help system is used. */ - public void set_context_sensitive_help(java.awt.Component p_component, String p_help_id) - { - if (this.help_system_used) - { + public void set_context_sensitive_help(java.awt.Component p_component, String p_help_id) { + if (this.help_system_used) { java.awt.Component curr_component; - if (p_component instanceof javax.swing.JFrame) - { + if (p_component instanceof javax.swing.JFrame) { curr_component = ((javax.swing.JFrame) p_component).getRootPane(); - } - else - { + } else { curr_component = p_component; } String help_id = "html_files." + p_help_id; @@ -363,86 +368,80 @@ public void set_context_sensitive_help(java.awt.Component p_component, String p_ help_broker.enableHelpKey(curr_component, help_id, help_set); } } - - /** Sets the toolbar to the buttons of the selected item state. */ - public void set_select_toolbar() - { + + /** + * Sets the toolbar to the buttons of the selected item state. + */ + public void set_select_toolbar() { getContentPane().remove(toolbar_panel); getContentPane().add(select_toolbar, java.awt.BorderLayout.NORTH); repaint(); } - - /** Sets the toolbar buttons to the select. route and drag menu buttons of the main menu. */ - public void set_menu_toolbar() - { + + /** + * Sets the toolbar buttons to the select. route and drag menu buttons of the main menu. + */ + public void set_menu_toolbar() { getContentPane().remove(select_toolbar); getContentPane().add(toolbar_panel, java.awt.BorderLayout.NORTH); repaint(); } - + /** * Calculates the absolute location of the board frame in his outmost parent frame. */ - java.awt.Point absolute_panel_location() - { + java.awt.Point absolute_panel_location() { int x = this.scroll_pane.getX(); int y = this.scroll_pane.getY(); java.awt.Container curr_parent = this.scroll_pane.getParent(); - while (curr_parent != null) - { + while (curr_parent != null) { x += curr_parent.getX(); y += curr_parent.getY(); curr_parent = curr_parent.getParent(); } return new java.awt.Point(x, y); } - - /** Sets the displayed region to the whole board. */ - public void zoom_all() - { + + /** + * Sets the displayed region to the whole board. + */ + public void zoom_all() { board_panel.board_handling.adjust_design_bounds(); java.awt.Rectangle display_rect = board_panel.get_viewport_bounds(); java.awt.Rectangle design_bounds = board_panel.board_handling.graphics_context.get_design_bounds(); - double width_factor = display_rect.getWidth() /design_bounds.getWidth(); - double height_factor = display_rect.getHeight() /design_bounds.getHeight(); - double zoom_factor = Math.min(width_factor, height_factor); + double width_factor = display_rect.getWidth() / design_bounds.getWidth(); + double height_factor = display_rect.getHeight() / design_bounds.getHeight(); + double zoom_factor = Math.min(width_factor, height_factor); java.awt.geom.Point2D zoom_center = board_panel.board_handling.graphics_context.get_design_center(); board_panel.zoom(zoom_factor, zoom_center); java.awt.geom.Point2D new_vieport_center = board_panel.board_handling.graphics_context.get_design_center(); board_panel.set_viewport_center(new_vieport_center); - + } - + /** * Actions to be taken when this frame vanishes. */ - public void dispose() - { - for (int i = 0; i < this.permanent_subwindows.length; ++i) - { - if (this.permanent_subwindows[i] != null) - { + public void dispose() { + for (int i = 0; i < this.permanent_subwindows.length; ++i) { + if (this.permanent_subwindows[i] != null) { this.permanent_subwindows[i].dispose(); this.permanent_subwindows[i] = null; } } - for (BoardTemporarySubWindow curr_subwindow : this.temporary_subwindows) - { - if (curr_subwindow != null) - { + for (BoardTemporarySubWindow curr_subwindow : this.temporary_subwindows) { + if (curr_subwindow != null) { curr_subwindow.board_frame_disposed(); } } - if (board_panel.board_handling != null) - { + if (board_panel.board_handling != null) { board_panel.board_handling.dispose(); board_panel.board_handling = null; } super.dispose(); } - - private void allocate_permanent_subwindows() - { + + private void allocate_permanent_subwindows() { this.color_manager = new ColorManager(this); this.permanent_subwindows[0] = this.color_manager; this.object_visibility_window = WindowObjectVisibility.get_instance(this); @@ -492,19 +491,18 @@ private void allocate_permanent_subwindows() this.autoroute_parameter_window = new WindowAutorouteParameter(this); this.permanent_subwindows[23] = this.autoroute_parameter_window; } - + /** * Creates the additional frames of the board frame. */ - private void initialize_windows() - { + private void initialize_windows() { allocate_permanent_subwindows(); - + this.setLocation(120, 0); - + this.select_parameter_window.setLocation(0, 0); this.select_parameter_window.setVisible(true); - + this.route_parameter_window.setLocation(0, 100); this.autoroute_parameter_window.setLocation(0, 200); this.move_parameter_window.setLocation(0, 50); @@ -529,85 +527,72 @@ private void initialize_windows() this.color_manager.setLocation(0, 600); this.about_window.setLocation(200, 200); } - + /** * Returns the currently used locale for the language dependent output. */ - public java.util.Locale get_locale() - { + public java.util.Locale get_locale() { return this.locale; } - + /** * Sets the background of the board panel */ - public void set_board_background(java.awt.Color p_color) - { + public void set_board_background(java.awt.Color p_color) { this.board_panel.setBackground(p_color); } - + /** * Refreshs all displayed coordinates after the user unit has changed. */ - public void refresh_windows() - { - for (int i = 0; i < this.permanent_subwindows.length; ++i) - { - if (permanent_subwindows[i] != null) - { + public void refresh_windows() { + for (int i = 0; i < this.permanent_subwindows.length; ++i) { + if (permanent_subwindows[i] != null) { permanent_subwindows[i].refresh(); } } } - + /** * Sets the selected button in the menu button button group */ - public void hilight_selected_button() - { + public void hilight_selected_button() { this.toolbar_panel.hilight_selected_button(); } - + /** * Restore the selected snapshot in the snapshot window. */ - public void goto_selected_snapshot() - { - if (this.snapshot_window != null) - { + public void goto_selected_snapshot() { + if (this.snapshot_window != null) { this.snapshot_window.goto_selected(); } } - + /** * Selects the snapshot, which is previous to the current selected snapshot. * Thecurent selected snapshot will be no more selected. */ - public void select_previous_snapshot() - { - if (this.snapshot_window != null) - { + public void select_previous_snapshot() { + if (this.snapshot_window != null) { this.snapshot_window.select_previous_item(); } } - + /** * Selects the snapshot, which is next to the current selected snapshot. * Thecurent selected snapshot will be no more selected. */ - public void select_next_snapshot() - { - if (this.snapshot_window != null) - { + public void select_next_snapshot() { + if (this.snapshot_window != null) { this.snapshot_window.select_next_item(); } } - + /** * Used for storing the subwindowfilters in a snapshot. */ - public SubwindowSelections get_snapshot_subwindow_selections() - { + public SubwindowSelections get_snapshot_subwindow_selections() { SubwindowSelections result = new SubwindowSelections(); result.incompletes_selection = this.incompletes_window.get_snapshot_info(); result.packages_selection = this.packages_window.get_snapshot_info(); @@ -616,169 +601,78 @@ public SubwindowSelections get_snapshot_subwindow_selections() result.padstacks_selection = this.padstacks_window.get_snapshot_info(); return result; } - + /** * Used for restoring the subwindowfilters from a snapshot. */ - public void set_snapshot_subwindow_selections(SubwindowSelections p_filters) - { + public void set_snapshot_subwindow_selections(SubwindowSelections p_filters) { this.incompletes_window.set_snapshot_info(p_filters.incompletes_selection); this.packages_window.set_snapshot_info(p_filters.packages_selection); this.net_info_window.set_snapshot_info(p_filters.nets_selection); this.components_window.set_snapshot_info(p_filters.components_selection); this.padstacks_window.set_snapshot_info(p_filters.padstacks_selection); } - + /** * Repaints this board frame and all the subwindows of the board. */ - public void repaint_all() - { + public void repaint_all() { this.repaint(); - for (int i = 0; i < permanent_subwindows.length; ++i) - { + for (int i = 0; i < permanent_subwindows.length; ++i) { permanent_subwindows[i].repaint(); } } - - /** The scroll pane for the panel of the routing board. */ - final javax.swing.JScrollPane scroll_pane; - - /** The menubar of this frame */ - final BoardMenuBar menubar; - - /** The panel with the graphical representation of the board. */ - final BoardPanel board_panel; - - /** The panel with the toolbars */ - private final BoardToolbar toolbar_panel; - - /** The toolbar used in the selected item state. */ - private final javax.swing.JToolBar select_toolbar; - - /** The panel with the message line */ - private final BoardPanelStatus message_panel; - - final ScreenMessages screen_messages; - - private final TestLevel test_level; - - /** true, if the frame is created by an application running under Java Web Start */ - final boolean is_web_start = false; - - private final boolean help_system_used; - static javax.help.HelpSet help_set = null; - static javax.help.HelpBroker help_broker = null; - - private final boolean confirm_cancel; - - private final java.util.ResourceBundle resources; - private java.util.Locale locale; - - private final BoardObservers board_observers; - private final net.freerouting.datastructures.IdNoGenerator item_id_no_generator; - - WindowAbout about_window = null; - WindowRouteParameter route_parameter_window = null; - WindowAutorouteParameter autoroute_parameter_window = null; - WindowSelectParameter select_parameter_window = null; - WindowMoveParameter move_parameter_window = null; - WindowClearanceMatrix clearance_matrix_window = null; - WindowVia via_window = null; - WindowEditVias edit_vias_window = null; - WindowNetClasses edit_net_rules_window = null; - WindowAssignNetClass assign_net_classes_window = null; - WindowPadstacks padstacks_window = null; - WindowPackages packages_window = null; - WindowIncompletes incompletes_window = null; - WindowNets net_info_window = null; - WindowClearanceViolations clearance_violations_window = null; - WindowLengthViolations length_violations_window = null; - WindowUnconnectedRoute unconnected_route_window = null; - WindowRouteStubs route_stubs_window = null; - WindowComponents components_window = null; - WindowLayerVisibility layer_visibility_window = null; - WindowObjectVisibility object_visibility_window = null; - WindowDisplayMisc display_misc_window = null; - WindowSnapshot snapshot_window = null; - ColorManager color_manager = null; - - /** The windows above stored in an array */ - static final int SUBWINDOW_COUNT = 24; - BoardSavableSubWindow[] permanent_subwindows = new BoardSavableSubWindow[SUBWINDOW_COUNT]; - - java.util.Collection temporary_subwindows = new java.util.LinkedList(); - - - DesignFile design_file = null; - - static final String [] log_file_extensions = { "log" }; - - static final String GUI_DEFAULTS_FILE_NAME = "gui_defaults.par"; - static final String GUI_DEFAULTS_FILE_BACKUP_NAME = "gui_defaults.par.bak"; - - static final FileFilter logfile_filter = new FileFilter(log_file_extensions); - - private class WindowStateListener extends java.awt.event.WindowAdapter - { - public void windowClosing(java.awt.event.WindowEvent evt) - { - setDefaultCloseOperation(DISPOSE_ON_CLOSE ); - if (confirm_cancel) - { + + public enum Option { + FROM_START_MENU, SINGLE_FRAME, SESSION_FILE, EXTENDED_TOOL_BAR + } + + /** + * Used for storing the subwindow filters in a snapshot. + */ + public static class SubwindowSelections implements java.io.Serializable { + private WindowObjectListWithFilter.SnapshotInfo incompletes_selection; + private WindowObjectListWithFilter.SnapshotInfo packages_selection; + private WindowObjectListWithFilter.SnapshotInfo nets_selection; + private WindowObjectListWithFilter.SnapshotInfo components_selection; + private WindowObjectListWithFilter.SnapshotInfo padstacks_selection; + } + + private class WindowStateListener extends java.awt.event.WindowAdapter { + public void windowClosing(java.awt.event.WindowEvent evt) { + setDefaultCloseOperation(DISPOSE_ON_CLOSE); + if (confirm_cancel) { int option = javax.swing.JOptionPane.showConfirmDialog(null, resources.getString("confirm_cancel"), null, javax.swing.JOptionPane.YES_NO_OPTION); - if (option == javax.swing.JOptionPane.NO_OPTION) - { + if (option == javax.swing.JOptionPane.NO_OPTION) { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); } } } - - public void windowIconified(java.awt.event.WindowEvent evt) - { - for (int i = 0; i < permanent_subwindows.length; ++i) - { + + public void windowIconified(java.awt.event.WindowEvent evt) { + for (int i = 0; i < permanent_subwindows.length; ++i) { permanent_subwindows[i].parent_iconified(); } - for (BoardSubWindow curr_subwindow : temporary_subwindows) - { - if (curr_subwindow != null) - { + for (BoardSubWindow curr_subwindow : temporary_subwindows) { + if (curr_subwindow != null) { curr_subwindow.parent_iconified(); } } } - - public void windowDeiconified(java.awt.event.WindowEvent evt) - { - for (int i = 0; i < permanent_subwindows.length; ++i) - { - if (permanent_subwindows[i] != null) - { + + public void windowDeiconified(java.awt.event.WindowEvent evt) { + for (int i = 0; i < permanent_subwindows.length; ++i) { + if (permanent_subwindows[i] != null) { permanent_subwindows[i].parent_deiconified(); } } - for (BoardSubWindow curr_subwindow : temporary_subwindows) - { - if (curr_subwindow != null) - { + for (BoardSubWindow curr_subwindow : temporary_subwindows) { + if (curr_subwindow != null) { curr_subwindow.parent_deiconified(); } } } } - - /** - * Used for storing the subwindow filters in a snapshot. - */ - public static class SubwindowSelections implements java.io.Serializable - { - private WindowObjectListWithFilter.SnapshotInfo incompletes_selection; - private WindowObjectListWithFilter.SnapshotInfo packages_selection; - private WindowObjectListWithFilter.SnapshotInfo nets_selection; - private WindowObjectListWithFilter.SnapshotInfo components_selection; - private WindowObjectListWithFilter.SnapshotInfo padstacks_selection; - } } diff --git a/src/main/java/net/freerouting/gui/BoardMenuBar.java b/src/main/java/net/freerouting/gui/BoardMenuBar.java index 42dcc084..b13bc2be 100644 --- a/src/main/java/net/freerouting/gui/BoardMenuBar.java +++ b/src/main/java/net/freerouting/gui/BoardMenuBar.java @@ -25,13 +25,15 @@ * * @author Alfons Wirtz */ -class BoardMenuBar extends javax.swing.JMenuBar -{ - - /** Creates a new BoardMenuBar together with its menus */ +class BoardMenuBar extends javax.swing.JMenuBar { + + private BoardMenuFile file_menu; + + /** + * Creates a new BoardMenuBar together with its menus + */ static BoardMenuBar get_instance(BoardFrame p_board_frame, - boolean p_help_system_used, boolean p_session_file_option) - { + boolean p_help_system_used, boolean p_session_file_option) { BoardMenuBar menubar = new BoardMenuBar(); menubar.file_menu = BoardMenuFile.get_instance(p_board_frame, p_session_file_option); menubar.add(menubar.file_menu); @@ -45,23 +47,17 @@ static BoardMenuBar get_instance(BoardFrame p_board_frame, menubar.add(info_menu); javax.swing.JMenu other_menu = BoardMenuOther.get_instance(p_board_frame); menubar.add(other_menu); - if (p_help_system_used) - { + if (p_help_system_used) { javax.swing.JMenu help_menu = new BoardMenuHelp(p_board_frame); menubar.add(help_menu); - } - else - { + } else { javax.swing.JMenu help_menu = new BoardMenuHelpReduced(p_board_frame); menubar.add(help_menu); } return menubar; } - - void add_design_dependent_items() - { + + void add_design_dependent_items() { this.file_menu.add_design_dependent_items(); } - - private BoardMenuFile file_menu; } diff --git a/src/main/java/net/freerouting/gui/BoardMenuDisplay.java b/src/main/java/net/freerouting/gui/BoardMenuDisplay.java index 4bdc5835..af4623f4 100644 --- a/src/main/java/net/freerouting/gui/BoardMenuDisplay.java +++ b/src/main/java/net/freerouting/gui/BoardMenuDisplay.java @@ -25,75 +25,68 @@ * * @author Alfons Wirtz */ -public class BoardMenuDisplay extends javax.swing.JMenu -{ - /** Returns a new display menu for the board frame. */ - public static BoardMenuDisplay get_instance(BoardFrame p_board_frame) - { +public class BoardMenuDisplay extends javax.swing.JMenu { + private final BoardFrame board_frame; + private final java.util.ResourceBundle resources; + + /** + * Creates a new instance of BoardDisplayMenu + */ + private BoardMenuDisplay(BoardFrame p_board_frame) { + board_frame = p_board_frame; + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuDisplay", p_board_frame.get_locale()); + } + + /** + * Returns a new display menu for the board frame. + */ + public static BoardMenuDisplay get_instance(BoardFrame p_board_frame) { final BoardMenuDisplay display_menu = new BoardMenuDisplay(p_board_frame); display_menu.setText(display_menu.resources.getString("display")); - + javax.swing.JMenuItem itemvisibility = new javax.swing.JMenuItem(); itemvisibility.setText(display_menu.resources.getString("object_visibility")); itemvisibility.setToolTipText(display_menu.resources.getString("object_visibility_tooltip")); - itemvisibility.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + itemvisibility.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { display_menu.board_frame.object_visibility_window.setVisible(true); } }); - + display_menu.add(itemvisibility); - + javax.swing.JMenuItem layervisibility = new javax.swing.JMenuItem(); layervisibility.setText(display_menu.resources.getString("layer_visibility")); layervisibility.setToolTipText(display_menu.resources.getString("layer_visibility_tooltip")); - layervisibility.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + layervisibility.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { display_menu.board_frame.layer_visibility_window.setVisible(true); } }); - + display_menu.add(layervisibility); - + javax.swing.JMenuItem colors = new javax.swing.JMenuItem(); colors.setText(display_menu.resources.getString("colors")); colors.setToolTipText(display_menu.resources.getString("colors_tooltip")); - colors.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + colors.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { display_menu.board_frame.color_manager.setVisible(true); } }); - + display_menu.add(colors); - + javax.swing.JMenuItem miscellanious = new javax.swing.JMenuItem(); miscellanious.setText(display_menu.resources.getString("miscellaneous")); - miscellanious.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + miscellanious.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { display_menu.board_frame.display_misc_window.setVisible(true); } }); - + display_menu.add(miscellanious); - + return display_menu; } - - /** Creates a new instance of BoardDisplayMenu */ - private BoardMenuDisplay(BoardFrame p_board_frame) - { - board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuDisplay", p_board_frame.get_locale()); - } - - private final BoardFrame board_frame; - private final java.util.ResourceBundle resources; } diff --git a/src/main/java/net/freerouting/gui/BoardMenuFile.java b/src/main/java/net/freerouting/gui/BoardMenuFile.java index 2a85a62e..df773b75 100644 --- a/src/main/java/net/freerouting/gui/BoardMenuFile.java +++ b/src/main/java/net/freerouting/gui/BoardMenuFile.java @@ -24,31 +24,40 @@ * * @author Alfons Wirtz */ -public class BoardMenuFile extends javax.swing.JMenu -{ +public class BoardMenuFile extends javax.swing.JMenu { - /** Returns a new file menu for the board frame. */ - public static BoardMenuFile get_instance(BoardFrame p_board_frame, boolean p_session_file_option) - { + private final BoardFrame board_frame; + private final boolean session_file_option; + private final java.util.ResourceBundle resources; + + /** + * Creates a new instance of BoardFileMenu + */ + private BoardMenuFile(BoardFrame p_board_frame, boolean p_session_file_option) { + session_file_option = p_session_file_option; + board_frame = p_board_frame; + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); + } + + /** + * Returns a new file menu for the board frame. + */ + public static BoardMenuFile get_instance(BoardFrame p_board_frame, boolean p_session_file_option) { final BoardMenuFile file_menu = new BoardMenuFile(p_board_frame, p_session_file_option); file_menu.setText(file_menu.resources.getString("file")); // Create the menu items. - if (!p_session_file_option) - { + if (!p_session_file_option) { javax.swing.JMenuItem save_item = new javax.swing.JMenuItem(); save_item.setText(file_menu.resources.getString("save")); save_item.setToolTipText(file_menu.resources.getString("save_tooltip")); - save_item.addActionListener(new java.awt.event.ActionListener() - { + save_item.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { boolean save_ok = file_menu.board_frame.save(); file_menu.board_frame.board_panel.board_handling.close_files(); - if (save_ok) - { + if (save_ok) { file_menu.board_frame.screen_messages.set_status_message(file_menu.resources.getString("save_message")); } } @@ -60,17 +69,12 @@ public void actionPerformed(java.awt.event.ActionEvent evt) javax.swing.JMenuItem save_and_exit_item = new javax.swing.JMenuItem(); save_and_exit_item.setText(file_menu.resources.getString("save_and_exit")); save_and_exit_item.setToolTipText(file_menu.resources.getString("save_and_exit_tooltip")); - save_and_exit_item.addActionListener(new java.awt.event.ActionListener() - { + save_and_exit_item.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) - { - if (file_menu.session_file_option) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { + if (file_menu.session_file_option) { file_menu.board_frame.design_file.write_specctra_session_file(file_menu.board_frame); - } - else - { + } else { file_menu.board_frame.save(); } file_menu.board_frame.dispose(); @@ -82,27 +86,22 @@ public void actionPerformed(java.awt.event.ActionEvent evt) javax.swing.JMenuItem cancel_and_exit_item = new javax.swing.JMenuItem(); cancel_and_exit_item.setText(file_menu.resources.getString("cancel_and_exit")); cancel_and_exit_item.setToolTipText(file_menu.resources.getString("cancel_and_exit_tooltip")); - cancel_and_exit_item.addActionListener(new java.awt.event.ActionListener() - { + cancel_and_exit_item.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { file_menu.board_frame.dispose(); } }); file_menu.add(cancel_and_exit_item); - if (!file_menu.session_file_option) - { + if (!file_menu.session_file_option) { javax.swing.JMenuItem save_as_item = new javax.swing.JMenuItem(); save_as_item.setText(file_menu.resources.getString("save_as")); save_as_item.setToolTipText(file_menu.resources.getString("save_as_tooltip")); - save_as_item.addActionListener(new java.awt.event.ActionListener() - { + save_as_item.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { file_menu.save_as_action(); } }); @@ -112,11 +111,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) javax.swing.JMenuItem write_logfile_item = new javax.swing.JMenuItem(); write_logfile_item.setText(file_menu.resources.getString("generate_logfile")); write_logfile_item.setToolTipText(file_menu.resources.getString("generate_logfile_tooltip")); - write_logfile_item.addActionListener(new java.awt.event.ActionListener() - { + write_logfile_item.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { file_menu.write_logfile_action(); } }); @@ -126,11 +123,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) javax.swing.JMenuItem replay_logfile_item = new javax.swing.JMenuItem(); replay_logfile_item.setText(file_menu.resources.getString("replay_logfile")); replay_logfile_item.setToolTipText(file_menu.resources.getString("replay_logfile_tooltip")); - replay_logfile_item.addActionListener(new java.awt.event.ActionListener() - { + replay_logfile_item.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { file_menu.read_logfile_action(); } }); @@ -143,10 +138,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) return file_menu; } - public void add_design_dependent_items() - { - if (this.session_file_option) - { + public void add_design_dependent_items() { + if (this.session_file_option) { return; } net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); @@ -155,34 +148,28 @@ public void add_design_dependent_items() javax.swing.JMenuItem write_session_file_item = new javax.swing.JMenuItem(); write_session_file_item.setText(resources.getString("session_file")); write_session_file_item.setToolTipText(resources.getString("session_file_tooltip")); - write_session_file_item.addActionListener(new java.awt.event.ActionListener() - { + write_session_file_item.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.design_file.write_specctra_session_file(board_frame); } }); - if ((routing_board.get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION || !host_cad_is_eagle)) - { + if ((routing_board.get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION || !host_cad_is_eagle)) { this.add(write_session_file_item); } javax.swing.JMenuItem write_eagle_session_script_item = new javax.swing.JMenuItem(); write_eagle_session_script_item.setText(resources.getString("eagle_script")); write_eagle_session_script_item.setToolTipText(resources.getString("eagle_script_tooltip")); - write_eagle_session_script_item.addActionListener(new java.awt.event.ActionListener() - { + write_eagle_session_script_item.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.design_file.update_eagle(board_frame); } }); - if (routing_board.get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION || host_cad_is_eagle) - { + if (routing_board.get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION || host_cad_is_eagle) { this.add(write_eagle_session_script_item); } } @@ -190,69 +177,54 @@ public void actionPerformed(java.awt.event.ActionEvent evt) /** * Adds a menu item for saving the current interactive settings as default. */ - private void add_save_settings_item() - { + private void add_save_settings_item() { javax.swing.JMenuItem save_settings_item = new javax.swing.JMenuItem(); save_settings_item.setText(resources.getString("settings")); save_settings_item.setToolTipText(resources.getString("settings_tooltip")); - save_settings_item.addActionListener(new java.awt.event.ActionListener() - { + save_settings_item.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { save_defaults_action(); } }); add(save_settings_item); } - private void save_as_action() - { - if (this.board_frame.design_file != null) - { + private void save_as_action() { + if (this.board_frame.design_file != null) { this.board_frame.design_file.save_as_dialog(this, this.board_frame); } } - private void write_logfile_action() - { + private void write_logfile_action() { javax.swing.JFileChooser file_chooser = new javax.swing.JFileChooser(); java.io.File logfile_dir = board_frame.design_file.get_parent_file(); file_chooser.setCurrentDirectory(logfile_dir); file_chooser.setFileFilter(BoardFrame.logfile_filter); file_chooser.showOpenDialog(this); java.io.File filename = file_chooser.getSelectedFile(); - if (filename == null) - { + if (filename == null) { board_frame.screen_messages.set_status_message(resources.getString("message_8")); - } - else - { + } else { board_frame.screen_messages.set_status_message(resources.getString("message_9")); board_frame.board_panel.board_handling.start_logfile(filename); } } - private void read_logfile_action() - { + private void read_logfile_action() { javax.swing.JFileChooser file_chooser = new javax.swing.JFileChooser(); java.io.File logfile_dir = board_frame.design_file.get_parent_file(); file_chooser.setCurrentDirectory(logfile_dir); file_chooser.setFileFilter(BoardFrame.logfile_filter); file_chooser.showOpenDialog(this); java.io.File filename = file_chooser.getSelectedFile(); - if (filename == null) - { + if (filename == null) { board_frame.screen_messages.set_status_message(resources.getString("message_10")); - } - else - { + } else { java.io.InputStream input_stream = null; - try - { + try { input_stream = new java.io.FileInputStream(filename); - } catch (java.io.FileNotFoundException e) - { + } catch (java.io.FileNotFoundException e) { return; } board_frame.read_logfile(input_stream); @@ -284,15 +256,4 @@ private void save_defaults_action() { } } - - /** Creates a new instance of BoardFileMenu */ - private BoardMenuFile(BoardFrame p_board_frame, boolean p_session_file_option) - { - session_file_option = p_session_file_option; - board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); - } - private final BoardFrame board_frame; - private final boolean session_file_option; - private final java.util.ResourceBundle resources; } diff --git a/src/main/java/net/freerouting/gui/BoardMenuHelp.java b/src/main/java/net/freerouting/gui/BoardMenuHelp.java index 76f26dce..693fb53b 100644 --- a/src/main/java/net/freerouting/gui/BoardMenuHelp.java +++ b/src/main/java/net/freerouting/gui/BoardMenuHelp.java @@ -27,81 +27,63 @@ import java.net.URL; /** - * * @author Alfons Wirtz */ -public class BoardMenuHelp extends BoardMenuHelpReduced -{ +public class BoardMenuHelp extends BoardMenuHelpReduced { + private static CSH.DisplayHelpFromSource contents_help = null; + private static CSH.DisplayHelpAfterTracking direct_help = null; + /** * Creates a new instance of BoardMenuHelp * Separated from BoardMenuHelpReduced to avoid ClassNotFound exception when the library * jh.jar is not found, which is only used in this extended class. */ - public BoardMenuHelp(BoardFrame p_board_frame) - { + public BoardMenuHelp(BoardFrame p_board_frame) { super(p_board_frame); this.initialize_help(p_board_frame.get_locale()); javax.swing.JMenuItem direct_help_window = new javax.swing.JMenuItem(); direct_help_window.setText(this.resources.getString("direct_help")); - if (direct_help != null) - { + if (direct_help != null) { direct_help_window.addActionListener(direct_help); } this.add(direct_help_window, 0); javax.swing.JMenuItem contents_window = new javax.swing.JMenuItem(); contents_window.setText(this.resources.getString("contents")); - if (contents_help != null) - { + if (contents_help != null) { contents_window.addActionListener(contents_help); } this.add(contents_window, 0); } - - private void initialize_help(java.util.Locale p_locale) - { + + private void initialize_help(java.util.Locale p_locale) { // try to find the helpset and create a HelpBroker object - if (BoardFrame.help_broker == null) - { + if (BoardFrame.help_broker == null) { String language = p_locale.getLanguage(); String helpset_name; - if (language.equalsIgnoreCase("de")) - { + if (language.equalsIgnoreCase("de")) { helpset_name = "net/freerouting/helpset/de/Help.hs"; - } - else - { + } else { helpset_name = "net/freerouting/helpset/en/Help.hs"; } - try - { + try { URL hsURL = HelpSet.findHelpSet(this.getClass().getClassLoader(), helpset_name); - if (hsURL == null) - { + if (hsURL == null) { System.out.println("HelpSet " + helpset_name + " not found."); - } - else - { + } else { BoardFrame.help_set = new HelpSet(null, hsURL); } - } - catch (HelpSetException ee) - { + } catch (HelpSetException ee) { System.out.println("HelpSet " + helpset_name + " could not be opened."); System.out.println(ee.getMessage()); } - if (BoardFrame.help_set != null) - { + if (BoardFrame.help_set != null) { BoardFrame.help_broker = BoardFrame.help_set.createHelpBroker(); } - if (BoardFrame.help_broker != null) - { + if (BoardFrame.help_broker != null) { // CSH.DisplayHelpFromSource is a convenience class to display the helpset contents_help = new CSH.DisplayHelpFromSource(BoardFrame.help_broker); direct_help = new CSH.DisplayHelpAfterTracking(BoardFrame.help_broker); } } } - - private static CSH.DisplayHelpFromSource contents_help = null; - private static CSH.DisplayHelpAfterTracking direct_help = null; } diff --git a/src/main/java/net/freerouting/gui/BoardMenuHelpReduced.java b/src/main/java/net/freerouting/gui/BoardMenuHelpReduced.java index b181ea7f..39ab2966 100644 --- a/src/main/java/net/freerouting/gui/BoardMenuHelpReduced.java +++ b/src/main/java/net/freerouting/gui/BoardMenuHelpReduced.java @@ -22,34 +22,28 @@ package net.freerouting.gui; /** - * * @author Alfons Wirtz */ -public class BoardMenuHelpReduced extends javax.swing.JMenu -{ +public class BoardMenuHelpReduced extends javax.swing.JMenu { + protected final BoardFrame board_frame; + protected final java.util.ResourceBundle resources; /** * Creates a new instance of BoardMenuHelpReduced * Separated from BoardMenuHelp to avoid ClassNotFound exception when the library * jh.jar is not found, which is only used in the extended help menu. */ - public BoardMenuHelpReduced(BoardFrame p_board_frame) - { + public BoardMenuHelpReduced(BoardFrame p_board_frame) { this.board_frame = p_board_frame; this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuHelp", p_board_frame.get_locale()); this.setText(this.resources.getString("help")); - + javax.swing.JMenuItem about_window = new javax.swing.JMenuItem(); about_window.setText(this.resources.getString("about")); - about_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + about_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.about_window.setVisible(true); } }); this.add(about_window); } - - protected final BoardFrame board_frame; - protected final java.util.ResourceBundle resources; } diff --git a/src/main/java/net/freerouting/gui/BoardMenuInfo.java b/src/main/java/net/freerouting/gui/BoardMenuInfo.java index 8e10d4ed..cf563f86 100644 --- a/src/main/java/net/freerouting/gui/BoardMenuInfo.java +++ b/src/main/java/net/freerouting/gui/BoardMenuInfo.java @@ -21,119 +21,102 @@ package net.freerouting.gui; /** - * * @author Alfons Wirtz */ -public class BoardMenuInfo extends javax.swing.JMenu -{ - /** Returns a new info menu for the board frame. */ - public static BoardMenuInfo get_instance(BoardFrame p_board_frame) - { +public class BoardMenuInfo extends javax.swing.JMenu { + private final BoardFrame board_frame; + private final java.util.ResourceBundle resources; + + + /** + * Creates a new instance of BoardLibraryMenu + */ + private BoardMenuInfo(BoardFrame p_board_frame) { + board_frame = p_board_frame; + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuInfo", p_board_frame.get_locale()); + } + + /** + * Returns a new info menu for the board frame. + */ + public static BoardMenuInfo get_instance(BoardFrame p_board_frame) { final BoardMenuInfo info_menu = new BoardMenuInfo(p_board_frame); - + info_menu.setText(info_menu.resources.getString("info")); - + javax.swing.JMenuItem package_window = new javax.swing.JMenuItem(); package_window.setText(info_menu.resources.getString("library_packages")); - package_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + package_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { info_menu.board_frame.packages_window.setVisible(true); } }); info_menu.add(package_window); - + javax.swing.JMenuItem padstacks_window = new javax.swing.JMenuItem(); padstacks_window.setText(info_menu.resources.getString("library_padstacks")); - padstacks_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + padstacks_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { info_menu.board_frame.padstacks_window.setVisible(true); } }); info_menu.add(padstacks_window); - + javax.swing.JMenuItem components_window = new javax.swing.JMenuItem(); components_window.setText(info_menu.resources.getString("board_components")); - components_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + components_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { info_menu.board_frame.components_window.setVisible(true); } }); info_menu.add(components_window); - + javax.swing.JMenuItem incompletes_window = new javax.swing.JMenuItem(); incompletes_window.setText(info_menu.resources.getString("incompletes")); - incompletes_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + incompletes_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { info_menu.board_frame.incompletes_window.setVisible(true); } }); info_menu.add(incompletes_window); - - + + javax.swing.JMenuItem length_violations_window = new javax.swing.JMenuItem(); length_violations_window.setText(info_menu.resources.getString("length_violations")); - length_violations_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + length_violations_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { info_menu.board_frame.length_violations_window.setVisible(true); } }); info_menu.add(length_violations_window); - + javax.swing.JMenuItem clearance_violations_window = new javax.swing.JMenuItem(); clearance_violations_window.setText(info_menu.resources.getString("clearance_violations")); - clearance_violations_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + clearance_violations_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { info_menu.board_frame.clearance_violations_window.setVisible(true); } }); info_menu.add(clearance_violations_window); - + javax.swing.JMenuItem unconnnected_route_window = new javax.swing.JMenuItem(); unconnnected_route_window.setText(info_menu.resources.getString("unconnected_route")); - unconnnected_route_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + unconnnected_route_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { info_menu.board_frame.unconnected_route_window.setVisible(true); } }); info_menu.add(unconnnected_route_window); - + javax.swing.JMenuItem route_stubs_window = new javax.swing.JMenuItem(); route_stubs_window.setText(info_menu.resources.getString("route_stubs")); - route_stubs_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + route_stubs_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { info_menu.board_frame.route_stubs_window.setVisible(true); } }); info_menu.add(route_stubs_window); - + return info_menu; } - - /** Creates a new instance of BoardLibraryMenu */ - private BoardMenuInfo(BoardFrame p_board_frame) - { - board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuInfo", p_board_frame.get_locale()); - } - - - - private final BoardFrame board_frame; - private final java.util.ResourceBundle resources; } diff --git a/src/main/java/net/freerouting/gui/BoardMenuOther.java b/src/main/java/net/freerouting/gui/BoardMenuOther.java index fa80bbb4..dd212787 100644 --- a/src/main/java/net/freerouting/gui/BoardMenuOther.java +++ b/src/main/java/net/freerouting/gui/BoardMenuOther.java @@ -22,43 +22,41 @@ package net.freerouting.gui; /** - * * @author Alfons Wirtz */ -public class BoardMenuOther extends javax.swing.JMenu -{ - /** Returns a new other menu for the board frame. */ - public static BoardMenuOther get_instance(BoardFrame p_board_frame) - { +public class BoardMenuOther extends javax.swing.JMenu { + private final BoardFrame board_frame; + private final java.util.ResourceBundle resources; + + /** + * Creates a new instance of BoardMenuOther + */ + private BoardMenuOther(BoardFrame p_board_frame) { + board_frame = p_board_frame; + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuOther", p_board_frame.get_locale()); + } + + /** + * Returns a new other menu for the board frame. + */ + public static BoardMenuOther get_instance(BoardFrame p_board_frame) { final BoardMenuOther other_menu = new BoardMenuOther(p_board_frame); - + other_menu.setText(other_menu.resources.getString("other")); - - + + javax.swing.JMenuItem snapshots = new javax.swing.JMenuItem(); snapshots.setText(other_menu.resources.getString("snapshots")); snapshots.setToolTipText(other_menu.resources.getString("snapshots_tooltip")); - snapshots.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + snapshots.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { other_menu.board_frame.snapshot_window.setVisible(true); } }); - + other_menu.add(snapshots); - + return other_menu; } - - /** Creates a new instance of BoardMenuOther */ - private BoardMenuOther(BoardFrame p_board_frame) - { - board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuOther", p_board_frame.get_locale()); - } - - private final BoardFrame board_frame; - private final java.util.ResourceBundle resources; - + } diff --git a/src/main/java/net/freerouting/gui/BoardMenuParameter.java b/src/main/java/net/freerouting/gui/BoardMenuParameter.java index 16597d47..5327f8f3 100644 --- a/src/main/java/net/freerouting/gui/BoardMenuParameter.java +++ b/src/main/java/net/freerouting/gui/BoardMenuParameter.java @@ -25,73 +25,66 @@ * * @author Alfons Wirtz */ -public class BoardMenuParameter extends javax.swing.JMenu -{ - /** Returns a new windows menu for the board frame. */ - public static BoardMenuParameter get_instance(BoardFrame p_board_frame) - { +public class BoardMenuParameter extends javax.swing.JMenu { + private final BoardFrame board_frame; + private final java.util.ResourceBundle resources; + + /** + * Creates a new instance of BoardSelectMenu + */ + private BoardMenuParameter(BoardFrame p_board_frame) { + board_frame = p_board_frame; + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuParameter", p_board_frame.get_locale()); + } + + /** + * Returns a new windows menu for the board frame. + */ + public static BoardMenuParameter get_instance(BoardFrame p_board_frame) { final BoardMenuParameter parameter_menu = new BoardMenuParameter(p_board_frame); - + parameter_menu.setText(parameter_menu.resources.getString("parameter")); - + javax.swing.JMenuItem selectwindow = new javax.swing.JMenuItem(); selectwindow.setText(parameter_menu.resources.getString("select")); - selectwindow.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + selectwindow.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { parameter_menu.board_frame.select_parameter_window.setVisible(true); } }); - + parameter_menu.add(selectwindow); - + javax.swing.JMenuItem routewindow = new javax.swing.JMenuItem(); routewindow.setText(parameter_menu.resources.getString("route")); - routewindow.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + routewindow.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { parameter_menu.board_frame.route_parameter_window.setVisible(true); } }); - + parameter_menu.add(routewindow); - + javax.swing.JMenuItem autoroutewindow = new javax.swing.JMenuItem(); autoroutewindow.setText(parameter_menu.resources.getString("autoroute")); - autoroutewindow.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + autoroutewindow.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { parameter_menu.board_frame.autoroute_parameter_window.setVisible(true); } }); - + parameter_menu.add(autoroutewindow); - + javax.swing.JMenuItem movewindow = new javax.swing.JMenuItem(); movewindow.setText(parameter_menu.resources.getString("move")); - movewindow.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + movewindow.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { parameter_menu.board_frame.move_parameter_window.setVisible(true); } }); - + parameter_menu.add(movewindow); - + return parameter_menu; } - - /** Creates a new instance of BoardSelectMenu */ - private BoardMenuParameter(BoardFrame p_board_frame) - { - board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuParameter", p_board_frame.get_locale()); - } - - private final BoardFrame board_frame; - private final java.util.ResourceBundle resources; } diff --git a/src/main/java/net/freerouting/gui/BoardMenuRules.java b/src/main/java/net/freerouting/gui/BoardMenuRules.java index 45e6593c..02fd3eac 100644 --- a/src/main/java/net/freerouting/gui/BoardMenuRules.java +++ b/src/main/java/net/freerouting/gui/BoardMenuRules.java @@ -25,72 +25,65 @@ * * @author Alfons Wirtz */ -public class BoardMenuRules extends javax.swing.JMenu -{ - - /** Returns a new windows menu for the board frame. */ - public static BoardMenuRules get_instance(BoardFrame p_board_frame) - { +public class BoardMenuRules extends javax.swing.JMenu { + + private final BoardFrame board_frame; + private final java.util.ResourceBundle resources; + + + /** + * Creates a new instance of BoardRulesMenu + */ + private BoardMenuRules(BoardFrame p_board_frame) { + board_frame = p_board_frame; + resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuRules", p_board_frame.get_locale()); + } + + /** + * Returns a new windows menu for the board frame. + */ + public static BoardMenuRules get_instance(BoardFrame p_board_frame) { final BoardMenuRules rules_menu = new BoardMenuRules(p_board_frame); - + rules_menu.setText(rules_menu.resources.getString("rules")); - + javax.swing.JMenuItem clearance_window = new javax.swing.JMenuItem(); clearance_window.setText(rules_menu.resources.getString("clearance_matrix")); - clearance_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + clearance_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { rules_menu.board_frame.clearance_matrix_window.setVisible(true); } }); rules_menu.add(clearance_window); - + javax.swing.JMenuItem via_window = new javax.swing.JMenuItem(); via_window.setText(rules_menu.resources.getString("vias")); - via_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + via_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { rules_menu.board_frame.via_window.setVisible(true); } }); rules_menu.add(via_window); - + javax.swing.JMenuItem nets_window = new javax.swing.JMenuItem(); nets_window.setText(rules_menu.resources.getString("nets")); - nets_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + nets_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { rules_menu.board_frame.net_info_window.setVisible(true); } }); - + rules_menu.add(nets_window); - + javax.swing.JMenuItem net_class_window = new javax.swing.JMenuItem(); net_class_window.setText(rules_menu.resources.getString("net_classes")); - net_class_window.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + net_class_window.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { rules_menu.board_frame.edit_net_rules_window.setVisible(true); } }); rules_menu.add(net_class_window); - + return rules_menu; } - - /** Creates a new instance of BoardRulesMenu */ - private BoardMenuRules(BoardFrame p_board_frame) - { - board_frame = p_board_frame; - resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuRules", p_board_frame.get_locale()); - } - - - private final BoardFrame board_frame; - private final java.util.ResourceBundle resources; } diff --git a/src/main/java/net/freerouting/gui/BoardPanel.java b/src/main/java/net/freerouting/gui/BoardPanel.java index 0bf59871..3f075980 100644 --- a/src/main/java/net/freerouting/gui/BoardPanel.java +++ b/src/main/java/net/freerouting/gui/BoardPanel.java @@ -31,21 +31,41 @@ /** - * * Panel containing the graphical representation of a routing board. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class BoardPanel extends javax.swing.JPanel -{ - - /** Creates a new BoardPanel in an Application */ +public class BoardPanel extends javax.swing.JPanel { + + private static final double c_zoom_factor = 2.0; + public final ScreenMessages screen_messages; + public final BoardFrame board_frame; + private final JScrollPane scroll_pane; + public javax.swing.JPopupMenu popup_menu_insert_cancel; + public PopupMenuCopy popup_menu_copy; + public PopupMenuMove popup_menu_move; + public javax.swing.JPopupMenu popup_menu_corneritem_construction; + public javax.swing.JPopupMenu popup_menu_main; + public PopupMenuDynamicRoute popup_menu_dynamic_route; + public PopupMenuStitchRoute popup_menu_stitch_route; + public javax.swing.JPopupMenu popup_menu_select; + BoardHandling board_handling = null; + Point2D right_button_click_location = null; + private java.awt.Robot robot; + private java.awt.Point middle_drag_position = null; + /** + * Defines the appearance of the custom custom_cursor in the board panel. + * Null, if the standard custom_cursor is used. + */ + private Cursor custom_cursor = null; + + /** + * Creates a new BoardPanel in an Application + */ public BoardPanel(ScreenMessages p_screen_messages, BoardFrame p_board_frame, - java.util.Locale p_locale) - { + java.util.Locale p_locale) { screen_messages = p_screen_messages; - try - { + try { // used to be able to change the location of the mouse pointer robot = new java.awt.Robot(); } catch (java.awt.AWTException e) { @@ -55,53 +75,44 @@ public BoardPanel(ScreenMessages p_screen_messages, BoardFrame p_board_frame, this.scroll_pane = board_frame.scroll_pane; default_init(p_locale); } - - private void default_init(java.util.Locale p_locale) - { + + private void default_init(java.util.Locale p_locale) { setLayout(new java.awt.BorderLayout()); - + setBackground(new java.awt.Color(0, 0, 0)); setMaximumSize(new java.awt.Dimension(30000, 20000)); setMinimumSize(new java.awt.Dimension(90, 60)); setPreferredSize(new java.awt.Dimension(1200, 900)); - addMouseMotionListener(new java.awt.event.MouseMotionAdapter() - { - public void mouseDragged(java.awt.event.MouseEvent evt) - { + addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { + public void mouseDragged(java.awt.event.MouseEvent evt) { mouse_dragged_action(evt); } - public void mouseMoved(java.awt.event.MouseEvent evt) - { + + public void mouseMoved(java.awt.event.MouseEvent evt) { mouse_moved_action(evt); } }); - addKeyListener(new java.awt.event.KeyAdapter() - { - public void keyTyped(java.awt.event.KeyEvent evt) - { + addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { board_handling.key_typed_action(evt.getKeyChar()); } }); - addMouseListener(new java.awt.event.MouseAdapter() - { - public void mouseClicked(java.awt.event.MouseEvent evt) - { + addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { mouse_clicked_action(evt); } - public void mousePressed(java.awt.event.MouseEvent evt) - { + + public void mousePressed(java.awt.event.MouseEvent evt) { mouse_pressed_action(evt); } - public void mouseReleased(java.awt.event.MouseEvent evt) - { + + public void mouseReleased(java.awt.event.MouseEvent evt) { board_handling.button_released(); - middle_drag_position = null ; + middle_drag_position = null; } }); - addMouseWheelListener(new java.awt.event.MouseWheelListener() - { - public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) - { + addMouseWheelListener(new java.awt.event.MouseWheelListener() { + public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { board_handling.mouse_wheel_moved(evt.getWheelRotation()); } }); @@ -109,9 +120,8 @@ public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) setAutoscrolls(true); this.setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR)); } - - void create_popup_menus() - { + + void create_popup_menus() { popup_menu_main = new PopupMenuMain(this.board_frame); popup_menu_dynamic_route = new PopupMenuDynamicRoute(this.board_frame); popup_menu_stitch_route = new PopupMenuStitchRoute(this.board_frame); @@ -121,70 +131,51 @@ void create_popup_menus() popup_menu_copy = new PopupMenuCopy(this.board_frame); popup_menu_move = new PopupMenuMove(this.board_frame); } - - - public void zoom_with_mouse_wheel(java.awt.geom.Point2D p_point, int p_wheel_rotation) - { - if (this.middle_drag_position != null || p_wheel_rotation == 0) - { + + public void zoom_with_mouse_wheel(java.awt.geom.Point2D p_point, int p_wheel_rotation) { + if (this.middle_drag_position != null || p_wheel_rotation == 0) { return; // scrolling with the middle mouse butten in progress } double zoom_factor = 1 - 0.1 * p_wheel_rotation; zoom_factor = Math.max(zoom_factor, 0.5); zoom(zoom_factor, p_point); } - - private void mouse_pressed_action(java.awt.event.MouseEvent evt) - { - if (evt.getButton() == 1) - { + + private void mouse_pressed_action(java.awt.event.MouseEvent evt) { + if (evt.getButton() == 1) { board_handling.mouse_pressed(evt.getPoint()); + } else if (evt.getButton() == 2 && middle_drag_position == null) { + middle_drag_position = new java.awt.Point(evt.getPoint()); } - else if (evt.getButton() == 2 && middle_drag_position == null) - { - middle_drag_position = new java.awt.Point(evt.getPoint()) ; - } - + } - - private void mouse_dragged_action(java.awt.event.MouseEvent evt) - { - if (middle_drag_position != null) - { - scroll_middle_mouse(evt) ; - } - else - { + + private void mouse_dragged_action(java.awt.event.MouseEvent evt) { + if (middle_drag_position != null) { + scroll_middle_mouse(evt); + } else { board_handling.mouse_dragged(evt.getPoint()); scroll_near_border(evt); } } - - private void mouse_moved_action(java.awt.event.MouseEvent p_evt) - { + + private void mouse_moved_action(java.awt.event.MouseEvent p_evt) { this.requestFocusInWindow(); // to enable keyboard aliases - if (board_handling != null) - { + if (board_handling != null) { board_handling.mouse_moved(p_evt.getPoint()); } - if (this.custom_cursor != null) - { + if (this.custom_cursor != null) { this.custom_cursor.set_location(p_evt.getPoint()); this.repaint(); } } - - private void mouse_clicked_action(java.awt.event.MouseEvent evt) - { - if (evt.getButton() == 1) - { + + private void mouse_clicked_action(java.awt.event.MouseEvent evt) { + if (evt.getButton() == 1) { board_handling.left_button_clicked(evt.getPoint()); - } - else if (evt.getButton() == 3) - { + } else if (evt.getButton() == 3) { JPopupMenu curr_menu = board_handling.get_current_popup_menu(); - if (curr_menu != null) - { + if (curr_menu != null) { int curr_x = evt.getX(); int curr_y = evt.getY(); curr_menu.show(this, curr_x, curr_y); @@ -192,114 +183,100 @@ else if (evt.getButton() == 3) right_button_click_location = evt.getPoint(); } } - + /** * overwrites the paintComponent method to draw the routing board */ - public void paintComponent(Graphics p_g) - { + public void paintComponent(Graphics p_g) { super.paintComponent(p_g); - if (board_handling != null) - { - board_handling.draw(p_g) ; + if (board_handling != null) { + board_handling.draw(p_g); } - if (this.custom_cursor != null) - { + if (this.custom_cursor != null) { this.custom_cursor.draw(p_g); } } - + /** * Returns the position of the viewport */ - public java.awt.Point get_viewport_position() - { - JViewport viewport = scroll_pane.getViewport(); + public java.awt.Point get_viewport_position() { + JViewport viewport = scroll_pane.getViewport(); return viewport.getViewPosition(); } - + /** * Sets the position of the viewport */ - void set_viewport_position(java.awt.Point p_position) - { - JViewport viewport = scroll_pane.getViewport(); + void set_viewport_position(java.awt.Point p_position) { + JViewport viewport = scroll_pane.getViewport(); viewport.setViewPosition(p_position); } - + /** * zooms in at p_position */ - public void zoom_in(java.awt.geom.Point2D p_position) - { + public void zoom_in(java.awt.geom.Point2D p_position) { zoom(c_zoom_factor, p_position); } - + /** * zooms out at p_position */ - public void zoom_out(java.awt.geom.Point2D p_position) - { - double zoom_factor = 1/c_zoom_factor; + public void zoom_out(java.awt.geom.Point2D p_position) { + double zoom_factor = 1 / c_zoom_factor; zoom(zoom_factor, p_position); } - + /** * zooms to frame */ - public void zoom_frame(java.awt.geom.Point2D p_position1, java.awt.geom.Point2D p_position2) - { - double width_of_zoom_frame = Math.abs(p_position1.getX() - p_position2.getX()) ; - double height_of_zoom_frame = Math.abs(p_position1.getY() - p_position2.getY()) ; - - double center_x = Math.min(p_position1.getX(), p_position2.getX()) + (width_of_zoom_frame/2) ; - double center_y = Math.min(p_position1.getY(), p_position2.getY()) + (height_of_zoom_frame/2) ; - - Point2D center_point = new Point2D.Double(center_x, center_y) ; - + public void zoom_frame(java.awt.geom.Point2D p_position1, java.awt.geom.Point2D p_position2) { + double width_of_zoom_frame = Math.abs(p_position1.getX() - p_position2.getX()); + double height_of_zoom_frame = Math.abs(p_position1.getY() - p_position2.getY()); + + double center_x = Math.min(p_position1.getX(), p_position2.getX()) + (width_of_zoom_frame / 2); + double center_y = Math.min(p_position1.getY(), p_position2.getY()) + (height_of_zoom_frame / 2); + + Point2D center_point = new Point2D.Double(center_x, center_y); + java.awt.Rectangle display_rect = get_viewport_bounds(); - - double width_factor = display_rect.getWidth() / width_of_zoom_frame ; - double height_factor = display_rect.getHeight() / height_of_zoom_frame ; - - java.awt.geom.Point2D changed_location = zoom(Math.min(width_factor, height_factor), center_point) ; + + double width_factor = display_rect.getWidth() / width_of_zoom_frame; + double height_factor = display_rect.getHeight() / height_of_zoom_frame; + + java.awt.geom.Point2D changed_location = zoom(Math.min(width_factor, height_factor), center_point); set_viewport_center(changed_location); } - - public void center_display(Point2D p_new_center) - { + + public void center_display(Point2D p_new_center) { java.awt.Point delta = set_viewport_center(p_new_center); java.awt.geom.Point2D new_center = get_viewport_center(); java.awt.Point new_mouse_location = - new java.awt.Point((int)(new_center.getX() - delta.getX()), (int)(new_center.getY() - delta.getY())); + new java.awt.Point((int) (new_center.getX() - delta.getX()), (int) (new_center.getY() - delta.getY())); move_mouse(new_mouse_location); repaint(); this.board_handling.logfile.start_scope(net.freerouting.interactive.LogfileScope.CENTER_DISPLAY); net.freerouting.geometry.planar.FloatPoint curr_corner = new net.freerouting.geometry.planar.FloatPoint(p_new_center.getX(), p_new_center.getY()); this.board_handling.logfile.add_corner(curr_corner); } - - - public java.awt.geom.Point2D get_viewport_center() - { + + public java.awt.geom.Point2D get_viewport_center() { java.awt.Point pos = get_viewport_position(); java.awt.Rectangle display_rect = get_viewport_bounds(); return new java.awt.geom.Point2D.Double(pos.getX() + display_rect.getCenterX(), pos.getY() + display_rect.getCenterY()); } - - + /** * zooms the content of the board by p_factor * Returns the change of the cursor location */ - public java.awt.geom.Point2D zoom(double p_factor, java.awt.geom.Point2D p_location) - { + public java.awt.geom.Point2D zoom(double p_factor, java.awt.geom.Point2D p_location) { final int max_panel_size = 10000000; Dimension old_size = this.getSize(); java.awt.geom.Point2D old_center = get_viewport_center(); - - if (p_factor > 1 && Math.max(old_size.getWidth(), old_size.getHeight()) >= max_panel_size) - { + + if (p_factor > 1 && Math.max(old_size.getWidth(), old_size.getHeight()) >= max_panel_size) { return p_location; // to prevent an sun.dc.pr.PRException, which I do not know, how to handle; maybe a bug in Java. } int new_width = (int) Math.round(p_factor * old_size.getWidth()); @@ -309,8 +286,8 @@ public java.awt.geom.Point2D zoom(double p_factor, java.awt.geom.Point2D p_locat setPreferredSize(new_size); setSize(new_size); revalidate(); - - java.awt.geom.Point2D new_cursor = new java.awt.geom.Point2D.Double(p_location.getX()* p_factor, p_location.getY()* p_factor); + + java.awt.geom.Point2D new_cursor = new java.awt.geom.Point2D.Double(p_location.getX() * p_factor, p_location.getY() * p_factor); double dx = new_cursor.getX() - p_location.getX(); double dy = new_cursor.getY() - p_location.getY(); java.awt.geom.Point2D new_center = new java.awt.geom.Point2D.Double(old_center.getX() + dx, old_center.getY() + dy); @@ -319,161 +296,117 @@ public java.awt.geom.Point2D zoom(double p_factor, java.awt.geom.Point2D p_locat java.awt.geom.Point2D adjusted_new_cursor = new java.awt.geom.Point2D.Double(new_cursor.getX() + adjustment_vector.getX() + 0.5, new_cursor.getY() + adjustment_vector.getY() + 0.5); return adjusted_new_cursor; } - + /** * Returns the viewport bounds of the scroll pane */ - java.awt.Rectangle get_viewport_bounds() - { + java.awt.Rectangle get_viewport_bounds() { return scroll_pane.getViewportBorderBounds(); } - + /** * Sets the viewport center to p_point. * Adjust the result, if p_point is near the border of the viewport. * Returns the adjustment vector */ - java.awt.Point set_viewport_center(java.awt.geom.Point2D p_point) - { + java.awt.Point set_viewport_center(java.awt.geom.Point2D p_point) { java.awt.Rectangle display_rect = get_viewport_bounds(); double x_corner = p_point.getX() - display_rect.getWidth() / 2; - double y_corner = p_point.getY() - display_rect.getHeight()/ 2; + double y_corner = p_point.getY() - display_rect.getHeight() / 2; Dimension panel_size = getSize(); double adjusted_x_corner = Math.min(x_corner, panel_size.getWidth()); adjusted_x_corner = Math.max(x_corner, 0); double adjusted_y_corner = Math.min(y_corner, panel_size.getHeight()); adjusted_y_corner = Math.max(y_corner, 0); - java.awt.Point new_position = new java.awt.Point((int) adjusted_x_corner, (int)adjusted_y_corner); + java.awt.Point new_position = new java.awt.Point((int) adjusted_x_corner, (int) adjusted_y_corner); set_viewport_position(new_position); java.awt.Point adjustment_vector = - new java.awt.Point((int)(adjusted_x_corner - x_corner), (int)(adjusted_y_corner - y_corner)); + new java.awt.Point((int) (adjusted_x_corner - x_corner), (int) (adjusted_y_corner - y_corner)); return adjustment_vector; } - + /** * Selects the p_signal_layer_no-th layer in the select_parameter_window. */ - public void set_selected_signal_layer(int p_signal_layer_no) - { - if (this.board_frame.select_parameter_window != null) - { + public void set_selected_signal_layer(int p_signal_layer_no) { + if (this.board_frame.select_parameter_window != null) { this.board_frame.select_parameter_window.select(p_signal_layer_no); this.popup_menu_dynamic_route.disable_layer_item(p_signal_layer_no); this.popup_menu_stitch_route.disable_layer_item(p_signal_layer_no); this.popup_menu_copy.disable_layer_item(p_signal_layer_no); } } - - void init_colors() - { + + void init_colors() { board_handling.graphics_context.item_color_table.addTableModelListener(new ColorTableListener()); board_handling.graphics_context.other_color_table.addTableModelListener(new ColorTableListener()); setBackground(board_handling.graphics_context.get_background_color()); } - - private void scroll_near_border(java.awt.event.MouseEvent p_evt) - { + + private void scroll_near_border(java.awt.event.MouseEvent p_evt) { final int border_dist = 50; java.awt.Rectangle r = new java.awt.Rectangle(p_evt.getX() - border_dist, p_evt.getY() - border_dist, 2 * border_dist, 2 * border_dist); - ((JPanel)p_evt.getSource()).scrollRectToVisible(r); + ((JPanel) p_evt.getSource()).scrollRectToVisible(r); } - - private void scroll_middle_mouse(java.awt.event.MouseEvent p_evt) - { + + private void scroll_middle_mouse(java.awt.event.MouseEvent p_evt) { double delta_x = middle_drag_position.x - p_evt.getX(); - double delta_y = middle_drag_position.y - p_evt.getY(); - + double delta_y = middle_drag_position.y - p_evt.getY(); + java.awt.Point view_position = get_viewport_position(); - - double x = (view_position.x + delta_x) ; - double y = (view_position.y + delta_y) ; - + + double x = (view_position.x + delta_x); + double y = (view_position.y + delta_y); + Dimension panel_size = this.getSize(); x = Math.min(x, panel_size.getWidth() - this.get_viewport_bounds().getWidth()); y = Math.min(y, panel_size.getHeight() - this.get_viewport_bounds().getHeight()); - + x = Math.max(x, 0); y = Math.max(y, 0); - - java.awt.Point p = new java.awt.Point((int) x, (int) y) ; - set_viewport_position(p) ; + + java.awt.Point p = new java.awt.Point((int) x, (int) y); + set_viewport_position(p); } - - public void move_mouse(Point2D p_location) - { - if (robot == null) - { + + public void move_mouse(Point2D p_location) { + if (robot == null) { return; } java.awt.Point absolute_panel_location = board_frame.absolute_panel_location(); java.awt.Point view_position = get_viewport_position(); int x = (int) Math.round(absolute_panel_location.getX() - view_position.getX() + p_location.getX()) + 1; - int y = (int) Math.round(absolute_panel_location.getY() - view_position.getY() + p_location.getY() + 1); + int y = (int) Math.round(absolute_panel_location.getY() - view_position.getY() + p_location.getY() + 1); robot.mouseMove(x, y); } - + /** * If p_value is true, the custom crosshair cursor will be used in display. * Otherwise the standard Cursor will be used. * Using the custom cursor may slow down the display performance a lot. */ - public void set_custom_crosshair_cursor(boolean p_value) - { - if (p_value) - { + public void set_custom_crosshair_cursor(boolean p_value) { + if (p_value) { this.custom_cursor = Cursor.get_45_degree_cross_hair_cursor(); - } - else - { + } else { this.custom_cursor = null; } board_frame.refresh_windows(); repaint(); } - + /** * If the result is true, the custom crosshair cursor will be used in display. * Otherwise the standard Cursor will be used. * Using the custom cursor may slow down the display performance a lot. */ - public boolean is_custom_cross_hair_cursor() - { + public boolean is_custom_cross_hair_cursor() { return this.custom_cursor != null; } - - public javax.swing.JPopupMenu popup_menu_insert_cancel; - public PopupMenuCopy popup_menu_copy; - public PopupMenuMove popup_menu_move; - public javax.swing.JPopupMenu popup_menu_corneritem_construction; - public javax.swing.JPopupMenu popup_menu_main; - public PopupMenuDynamicRoute popup_menu_dynamic_route; - public PopupMenuStitchRoute popup_menu_stitch_route; - public javax.swing.JPopupMenu popup_menu_select; - - public final ScreenMessages screen_messages; - - public final BoardFrame board_frame; - - BoardHandling board_handling = null; - - private final JScrollPane scroll_pane; - Point2D right_button_click_location = null; - private static final double c_zoom_factor = 2.0; - private java.awt.Robot robot; - private java.awt.Point middle_drag_position = null ; - - /** - * Defines the appearance of the custom custom_cursor in the board panel. - * Null, if the standard custom_cursor is used. - */ - private Cursor custom_cursor = null; - - - private class ColorTableListener implements TableModelListener - { - public void tableChanged(TableModelEvent p_event) - { + + private class ColorTableListener implements TableModelListener { + public void tableChanged(TableModelEvent p_event) { //redisplay board because some colors have changed. setBackground(board_handling.graphics_context.get_background_color()); repaint(); diff --git a/src/main/java/net/freerouting/gui/BoardPanelStatus.java b/src/main/java/net/freerouting/gui/BoardPanelStatus.java index 4ee48eca..79c4b143 100644 --- a/src/main/java/net/freerouting/gui/BoardPanelStatus.java +++ b/src/main/java/net/freerouting/gui/BoardPanelStatus.java @@ -26,50 +26,54 @@ * * @author Alfons Wirtz */ -class BoardPanelStatus extends javax.swing.JPanel -{ - - /** Creates a new instance of BoardStatusPanel */ - BoardPanelStatus(java.util.Locale p_locale) - { +class BoardPanelStatus extends javax.swing.JPanel { + + final javax.swing.JLabel status_message; + final javax.swing.JLabel add_message; + final javax.swing.JLabel current_layer; + final javax.swing.JLabel mouse_position; + /** + * Creates a new instance of BoardStatusPanel + */ + BoardPanelStatus(java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardPanelStatus", p_locale); this.setLayout(new java.awt.BorderLayout()); this.setPreferredSize(new java.awt.Dimension(300, 20)); - + javax.swing.JPanel left_message_panel = new javax.swing.JPanel(); left_message_panel.setLayout(new java.awt.BorderLayout()); - + status_message = new javax.swing.JLabel(); status_message.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); status_message.setText(resources.getString("status_line")); left_message_panel.add(status_message, java.awt.BorderLayout.CENTER); - + add_message = new javax.swing.JLabel(); add_message.setText(resources.getString("additional_text_field")); add_message.setMaximumSize(new java.awt.Dimension(300, 14)); add_message.setMinimumSize(new java.awt.Dimension(140, 14)); add_message.setPreferredSize(new java.awt.Dimension(180, 14)); left_message_panel.add(add_message, java.awt.BorderLayout.EAST); - + this.add(left_message_panel, java.awt.BorderLayout.CENTER); - + javax.swing.JPanel right_message_panel = new javax.swing.JPanel(); right_message_panel.setLayout(new java.awt.BorderLayout()); - + right_message_panel.setMinimumSize(new java.awt.Dimension(200, 20)); right_message_panel.setOpaque(false); right_message_panel.setPreferredSize(new java.awt.Dimension(450, 20)); - + current_layer = new javax.swing.JLabel(); current_layer.setText(resources.getString("current_layer")); right_message_panel.add(current_layer, java.awt.BorderLayout.CENTER); - + javax.swing.JPanel cursor_panel = new javax.swing.JPanel(); cursor_panel.setLayout(new java.awt.BorderLayout()); cursor_panel.setMinimumSize(new java.awt.Dimension(220, 14)); cursor_panel.setPreferredSize(new java.awt.Dimension(220, 14)); - + javax.swing.JLabel cursor = new javax.swing.JLabel(); cursor.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); cursor.setText(resources.getString("cursor")); @@ -77,20 +81,15 @@ class BoardPanelStatus extends javax.swing.JPanel cursor.setMinimumSize(new java.awt.Dimension(50, 14)); cursor.setPreferredSize(new java.awt.Dimension(50, 14)); cursor_panel.add(cursor, java.awt.BorderLayout.WEST); - + mouse_position = new javax.swing.JLabel(); mouse_position.setText("(0,0)"); mouse_position.setMaximumSize(new java.awt.Dimension(170, 14)); mouse_position.setPreferredSize(new java.awt.Dimension(170, 14)); cursor_panel.add(mouse_position, java.awt.BorderLayout.EAST); - + right_message_panel.add(cursor_panel, java.awt.BorderLayout.EAST); - + this.add(right_message_panel, java.awt.BorderLayout.EAST); } - - final javax.swing.JLabel status_message; - final javax.swing.JLabel add_message; - final javax.swing.JLabel current_layer; - final javax.swing.JLabel mouse_position; } diff --git a/src/main/java/net/freerouting/gui/BoardSavableSubWindow.java b/src/main/java/net/freerouting/gui/BoardSavableSubWindow.java index 33c6c838..f45c37df 100644 --- a/src/main/java/net/freerouting/gui/BoardSavableSubWindow.java +++ b/src/main/java/net/freerouting/gui/BoardSavableSubWindow.java @@ -25,67 +25,54 @@ * * @author Alfons Wirtz */ -public abstract class BoardSavableSubWindow extends BoardSubWindow -{ - +public abstract class BoardSavableSubWindow extends BoardSubWindow { + /** * Reads the data of this frame from disc. * Returns false, if the reading failed. */ - public boolean read(java.io.ObjectInputStream p_object_stream) - { - try - { + public boolean read(java.io.ObjectInputStream p_object_stream) { + try { SavedAttributes saved_attributes = (SavedAttributes) p_object_stream.readObject(); this.setBounds(saved_attributes.bounds); this.setVisible(saved_attributes.is_visible); return true; - } - catch (Exception e) - { + } catch (Exception e) { System.out.println("SelectParameterWindow.read: read failed"); return false; } } - + /** * Saves this frame to disk. */ - public void save(java.io.ObjectOutputStream p_object_stream) - { + public void save(java.io.ObjectOutputStream p_object_stream) { SavedAttributes saved_attributes = new SavedAttributes(this.getBounds(), this.isVisible()); - - try - { + + try { p_object_stream.writeObject(saved_attributes); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("BoardSubWindow.save: save failed"); } } - - /** + + /** * Refreshs the displayed values in this window. * To be overwritten in derived classes. */ - public void refresh() - { - + public void refresh() { + } - + /** * Type for attributes of this class, which are saved to an Objectstream. */ - static private class SavedAttributes implements java.io.Serializable - { - public SavedAttributes(java.awt.Rectangle p_bounds, boolean p_is_visible) - { + static private class SavedAttributes implements java.io.Serializable { + public final java.awt.Rectangle bounds; + public final boolean is_visible; + public SavedAttributes(java.awt.Rectangle p_bounds, boolean p_is_visible) { bounds = p_bounds; is_visible = p_is_visible; } - - public final java.awt.Rectangle bounds; - public final boolean is_visible; } } diff --git a/src/main/java/net/freerouting/gui/BoardSubWindow.java b/src/main/java/net/freerouting/gui/BoardSubWindow.java index f9953937..522c5b80 100644 --- a/src/main/java/net/freerouting/gui/BoardSubWindow.java +++ b/src/main/java/net/freerouting/gui/BoardSubWindow.java @@ -26,20 +26,16 @@ * * @author Alfons Wirtz */ -public class BoardSubWindow extends javax.swing.JFrame -{ - - public void parent_iconified() - { +public class BoardSubWindow extends javax.swing.JFrame { + + private boolean visible_before_iconifying = false; + + public void parent_iconified() { this.visible_before_iconifying = this.isVisible(); this.setVisible(false); } - - public void parent_deiconified() - { + + public void parent_deiconified() { this.setVisible(this.visible_before_iconifying); } - - - private boolean visible_before_iconifying = false; } diff --git a/src/main/java/net/freerouting/gui/BoardTemporarySubWindow.java b/src/main/java/net/freerouting/gui/BoardTemporarySubWindow.java index 8c681c96..24e03a56 100644 --- a/src/main/java/net/freerouting/gui/BoardTemporarySubWindow.java +++ b/src/main/java/net/freerouting/gui/BoardTemporarySubWindow.java @@ -23,37 +23,36 @@ /** * Class for temporary subwindows of the boarrd frame + * * @author Alfons Wirtz */ -public class BoardTemporarySubWindow extends BoardSubWindow -{ - - /** Creates a new instance of BoardTemporarySubWindow */ - public BoardTemporarySubWindow(BoardFrame p_board_frame) - { +public class BoardTemporarySubWindow extends BoardSubWindow { + + protected final BoardFrame board_frame; + + /** + * Creates a new instance of BoardTemporarySubWindow + */ + public BoardTemporarySubWindow(BoardFrame p_board_frame) { this.board_frame = p_board_frame; p_board_frame.temporary_subwindows.add(this); - - this.addWindowListener(new java.awt.event.WindowAdapter() - { - public void windowClosing(java.awt.event.WindowEvent evt) - { + + this.addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { dispose(); } }); } - - /** Used, when the board frame with all the subwindows is disposed. */ - public void board_frame_disposed() - { + + /** + * Used, when the board frame with all the subwindows is disposed. + */ + public void board_frame_disposed() { super.dispose(); } - - public void dispose() - { + + public void dispose() { this.board_frame.temporary_subwindows.remove(this); super.dispose(); } - - protected final BoardFrame board_frame; } diff --git a/src/main/java/net/freerouting/gui/BoardToolbar.java b/src/main/java/net/freerouting/gui/BoardToolbar.java index 702ce3d0..4fdf6aa5 100644 --- a/src/main/java/net/freerouting/gui/BoardToolbar.java +++ b/src/main/java/net/freerouting/gui/BoardToolbar.java @@ -25,194 +25,180 @@ * * @author Alfons Wirtz */ -class BoardToolbar extends javax.swing.JPanel -{ - - /** Creates a new instance of BoardToolbarPanel */ - BoardToolbar(BoardFrame p_board_frame) - { +class BoardToolbar extends javax.swing.JPanel { + + final javax.swing.JFormattedTextField unit_factor_field; + final javax.swing.JComboBox unit_combo_box; + private final BoardFrame board_frame; + private final javax.swing.JToggleButton select_button; + private final javax.swing.JToggleButton route_button; + private final javax.swing.JToggleButton drag_button; + /** + * Creates a new instance of BoardToolbarPanel + */ + BoardToolbar(BoardFrame p_board_frame) { this.board_frame = p_board_frame; - - java.util.ResourceBundle resources = + + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardToolbar", p_board_frame.get_locale()); - + this.setLayout(new java.awt.BorderLayout()); - + // create the left toolbar - + final javax.swing.JToolBar left_toolbar = new javax.swing.JToolBar(); final javax.swing.ButtonGroup toolbar_button_group = new javax.swing.ButtonGroup(); this.select_button = new javax.swing.JToggleButton(); this.route_button = new javax.swing.JToggleButton(); this.drag_button = new javax.swing.JToggleButton(); final javax.swing.JLabel jLabel1 = new javax.swing.JLabel(); - + left_toolbar.setMaximumSize(new java.awt.Dimension(1200, 23)); toolbar_button_group.add(select_button); select_button.setSelected(true); select_button.setText(resources.getString("select_button")); select_button.setToolTipText(resources.getString("select_button_tooltip")); - select_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + select_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.set_select_menu_state(); } }); - + left_toolbar.add(select_button); - + toolbar_button_group.add(route_button); route_button.setText(resources.getString("route_button")); route_button.setToolTipText(resources.getString("route_button_tooltip")); - route_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + route_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.set_route_menu_state(); } }); - + left_toolbar.add(route_button); - + toolbar_button_group.add(drag_button); drag_button.setText(resources.getString("drag_button")); drag_button.setToolTipText(resources.getString("drag_button_tooltip")); - drag_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + drag_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.set_drag_menu_state(); } }); - + left_toolbar.add(drag_button); - + jLabel1.setMaximumSize(new java.awt.Dimension(30, 10)); jLabel1.setMinimumSize(new java.awt.Dimension(3, 10)); jLabel1.setPreferredSize(new java.awt.Dimension(30, 10)); left_toolbar.add(jLabel1); - + this.add(left_toolbar, java.awt.BorderLayout.WEST); - + // create the middle toolbar - + final javax.swing.JToolBar middle_toolbar = new javax.swing.JToolBar(); - + final javax.swing.JButton autoroute_button = new javax.swing.JButton(); autoroute_button.setText(resources.getString("autoroute_button")); autoroute_button.setToolTipText(resources.getString("autoroute_button_tooltip")); - autoroute_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + autoroute_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.start_batch_autorouter(); } }); - + middle_toolbar.add(autoroute_button); - + final javax.swing.JLabel separator_2 = new javax.swing.JLabel(); separator_2.setMaximumSize(new java.awt.Dimension(10, 10)); separator_2.setPreferredSize(new java.awt.Dimension(10, 10)); separator_2.setRequestFocusEnabled(false); middle_toolbar.add(separator_2); - + final javax.swing.JButton undo_button = new javax.swing.JButton(); undo_button.setText(resources.getString("undo_button")); undo_button.setToolTipText(resources.getString("undo_button_tooltip")); - undo_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + undo_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.cancel_state(); board_frame.board_panel.board_handling.undo(); board_frame.refresh_windows(); } }); - + middle_toolbar.add(undo_button); - + final javax.swing.JButton redo_button = new javax.swing.JButton(); redo_button.setText(resources.getString("redo_button")); redo_button.setToolTipText(resources.getString("redo_button_tooltip")); - redo_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + redo_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.redo(); } }); - + middle_toolbar.add(redo_button); - + final javax.swing.JLabel separator_1 = new javax.swing.JLabel(); separator_1.setMaximumSize(new java.awt.Dimension(10, 10)); separator_1.setPreferredSize(new java.awt.Dimension(10, 10)); middle_toolbar.add(separator_1); - + final javax.swing.JButton incompletes_button = new javax.swing.JButton(); incompletes_button.setText(resources.getString("incompletes_button")); incompletes_button.setToolTipText(resources.getString("incompletes_button_tooltip")); - incompletes_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + incompletes_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.toggle_ratsnest(); } }); - + middle_toolbar.add(incompletes_button); - + final javax.swing.JButton violation_button = new javax.swing.JButton(); violation_button.setText(resources.getString("violations_button")); violation_button.setToolTipText(resources.getString("violations_button_tooltip")); - violation_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + violation_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.toggle_clearance_violations(); } }); - + middle_toolbar.add(violation_button); - + final javax.swing.JLabel separator_3 = new javax.swing.JLabel(); separator_3.setMaximumSize(new java.awt.Dimension(10, 10)); separator_3.setPreferredSize(new java.awt.Dimension(10, 10)); separator_3.setRequestFocusEnabled(false); middle_toolbar.add(separator_3); - + final javax.swing.JButton display_all_button = new javax.swing.JButton(); display_all_button.setText(resources.getString("display_all_button")); display_all_button.setToolTipText(resources.getString("display_all_button_tooltip")); - display_all_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + display_all_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.zoom_all(); } }); - + middle_toolbar.add(display_all_button); - + final javax.swing.JButton display_region_button = new javax.swing.JButton(); display_region_button.setText(resources.getString("display_region_button")); display_region_button.setToolTipText(resources.getString("display_region_button_tooltip")); - display_region_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + display_region_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.zoom_region(); } }); - + middle_toolbar.add(display_region_button); - + this.add(middle_toolbar, java.awt.BorderLayout.CENTER); - + // create the right toolbar - + final javax.swing.JToolBar right_toolbar = new javax.swing.JToolBar(); final javax.swing.JLabel unit_label = new javax.swing.JLabel(); java.text.NumberFormat number_format = java.text.NumberFormat.getInstance(p_board_frame.get_locale()); @@ -220,43 +206,38 @@ public void actionPerformed(java.awt.event.ActionEvent evt) this.unit_factor_field = new javax.swing.JFormattedTextField(number_format); this.unit_combo_box = new javax.swing.JComboBox(); final javax.swing.JLabel jLabel4 = new javax.swing.JLabel(); - + right_toolbar.setAutoscrolls(true); unit_label.setText(resources.getString("unit_button")); unit_label.setMaximumSize(new java.awt.Dimension(30, 21)); unit_label.setPreferredSize(new java.awt.Dimension(30, 21)); right_toolbar.add(unit_label); - + unit_factor_field.setHorizontalAlignment(javax.swing.JTextField.CENTER); unit_factor_field.setValue(1); unit_factor_field.setMaximumSize(new java.awt.Dimension(100, 18)); unit_factor_field.setMinimumSize(new java.awt.Dimension(40, 18)); unit_factor_field.setPreferredSize(new java.awt.Dimension(80, 18)); - unit_factor_field.addKeyListener(new java.awt.event.KeyAdapter() - { - public void keyTyped(java.awt.event.KeyEvent evt) - { - if (evt.getKeyChar() == '\n') - { + unit_factor_field.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + if (evt.getKeyChar() == '\n') { Object input = unit_factor_field.getValue(); - if (input instanceof Number) - { - double input_value = ((Number)input).doubleValue(); - if (input_value > 0) - { + if (input instanceof Number) { + double input_value = ((Number) input).doubleValue(); + if (input_value > 0) { board_frame.board_panel.board_handling.change_user_unit_factor(input_value); } } double unit_factor = board_frame.board_panel.board_handling.coordinate_transform.user_unit_factor; unit_factor_field.setValue(unit_factor); - + board_frame.refresh_windows(); } } }); - + right_toolbar.add(unit_factor_field); - + unit_combo_box.setModel(new javax.swing.DefaultComboBoxModel(net.freerouting.board.Unit.values())); unit_combo_box.setFocusTraversalPolicyProvider(true); unit_combo_box.setInheritsPopupMenu(true); @@ -264,49 +245,34 @@ public void keyTyped(java.awt.event.KeyEvent evt) unit_combo_box.setMinimumSize(new java.awt.Dimension(60, 18)); unit_combo_box.setOpaque(false); unit_combo_box.setPreferredSize(new java.awt.Dimension(60, 18)); - unit_combo_box.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + unit_combo_box.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { net.freerouting.board.Unit new_unit = (net.freerouting.board.Unit) unit_combo_box.getSelectedItem(); board_frame.board_panel.board_handling.change_user_unit(new_unit); board_frame.refresh_windows(); } }); - + right_toolbar.add(unit_combo_box); - + jLabel4.setMaximumSize(new java.awt.Dimension(30, 14)); jLabel4.setPreferredSize(new java.awt.Dimension(30, 14)); right_toolbar.add(jLabel4); - + this.add(right_toolbar, java.awt.BorderLayout.EAST); } - + /** * Sets the selected button in the menu button button group */ - void hilight_selected_button() - { + void hilight_selected_button() { net.freerouting.interactive.InteractiveState interactive_state = this.board_frame.board_panel.board_handling.get_interactive_state(); - if (interactive_state instanceof net.freerouting.interactive.RouteMenuState) - { + if (interactive_state instanceof net.freerouting.interactive.RouteMenuState) { this.route_button.setSelected(true); - } - else if (interactive_state instanceof net.freerouting.interactive.DragMenuState) - { + } else if (interactive_state instanceof net.freerouting.interactive.DragMenuState) { this.drag_button.setSelected(true); - } - else if (interactive_state instanceof net.freerouting.interactive.SelectMenuState) - { + } else if (interactive_state instanceof net.freerouting.interactive.SelectMenuState) { this.select_button.setSelected(true); } } - - private final BoardFrame board_frame; - private final javax.swing.JToggleButton select_button; - private final javax.swing.JToggleButton route_button; - private final javax.swing.JToggleButton drag_button; - final javax.swing.JFormattedTextField unit_factor_field; - final javax.swing.JComboBox unit_combo_box; } diff --git a/src/main/java/net/freerouting/gui/BoardToolbarSelectedItem.java b/src/main/java/net/freerouting/gui/BoardToolbarSelectedItem.java index 9b7e4fd8..deaf2e1f 100644 --- a/src/main/java/net/freerouting/gui/BoardToolbarSelectedItem.java +++ b/src/main/java/net/freerouting/gui/BoardToolbarSelectedItem.java @@ -25,325 +25,277 @@ * * @author Alfons Wirtz */ -class BoardToolbarSelectedItem extends javax.swing.JToolBar -{ - +class BoardToolbarSelectedItem extends javax.swing.JToolBar { + + private final BoardFrame board_frame; + private final java.util.ResourceBundle resources; + /** * Creates a new instance of BoardSelectedItemToolbar. * If p_extended, some additional buttons are generated. */ - BoardToolbarSelectedItem(BoardFrame p_board_frame, boolean p_extended) - { + BoardToolbarSelectedItem(BoardFrame p_board_frame, boolean p_extended) { this.board_frame = p_board_frame; - - this.resources = + + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardToolbarSelectedItem", p_board_frame.get_locale()); - + javax.swing.JButton cancel_button = new javax.swing.JButton(); cancel_button.setText(resources.getString("cancel")); cancel_button.setToolTipText(resources.getString("cancel_tooltip")); - cancel_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + cancel_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.cancel_state(); } }); - + this.add(cancel_button); - + javax.swing.JButton info_button = new javax.swing.JButton(); info_button.setText(resources.getString("info")); info_button.setToolTipText(resources.getString("info_tooltip")); - info_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + info_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.display_selected_item_info(); } }); - + this.add(info_button); - + javax.swing.JButton delete_button = new javax.swing.JButton(); delete_button.setText(resources.getString("delete")); delete_button.setToolTipText(resources.getString("delete_tooltip")); - delete_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + delete_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.delete_selected_items(); } }); - + this.add(delete_button); - - + + javax.swing.JButton cutout_button = new javax.swing.JButton(); cutout_button.setText(resources.getString("cutout")); cutout_button.setToolTipText(resources.getString("cutout_tooltip")); - cutout_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + cutout_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.cutout_selected_items(); } }); - + this.add(cutout_button); - + javax.swing.JButton fix_button = new javax.swing.JButton(); fix_button.setText(resources.getString("fix")); fix_button.setToolTipText(resources.getString("fix_tooltip")); - fix_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + fix_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.fix_selected_items(); } }); - + this.add(fix_button); - + javax.swing.JButton unfix_button = new javax.swing.JButton(); unfix_button.setText(resources.getString("unfix")); unfix_button.setToolTipText(resources.getString("unfix_tooltip")); - unfix_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + unfix_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.unfix_selected_items(); } }); - + this.add(unfix_button); - + javax.swing.JButton autoroute_button = new javax.swing.JButton(); autoroute_button.setText(resources.getString("autoroute")); autoroute_button.setToolTipText(resources.getString("autoroute_tooltip")); - autoroute_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + autoroute_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.autoroute_selected_items(); } }); this.add(autoroute_button); - + javax.swing.JButton tidy_button = new javax.swing.JButton(); tidy_button.setText(resources.getString("pull_tight")); tidy_button.setToolTipText(resources.getString("pull_tight_tooltip")); - tidy_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + tidy_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.optimize_selected_items(); } }); - + this.add(tidy_button); - + javax.swing.JButton clearance_class_button = new javax.swing.JButton(); clearance_class_button.setText(resources.getString("spacing")); clearance_class_button.setToolTipText(resources.getString("spacing_tooltip")); - clearance_class_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + clearance_class_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { assign_clearance_class(); } }); - + javax.swing.JButton fanout_button = new javax.swing.JButton(); fanout_button.setText(resources.getString("fanout")); fanout_button.setToolTipText(resources.getString("fanout_tooltip")); - fanout_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + fanout_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.fanout_selected_items(); } }); this.add(fanout_button); - + this.add(clearance_class_button); - + javax.swing.JLabel jLabel5 = new javax.swing.JLabel(); jLabel5.setMaximumSize(new java.awt.Dimension(10, 10)); jLabel5.setPreferredSize(new java.awt.Dimension(10, 10)); this.add(jLabel5); - + javax.swing.JButton whole_nets_button = new javax.swing.JButton(); whole_nets_button.setText(resources.getString("nets")); whole_nets_button.setToolTipText(resources.getString("nets_tooltip")); - whole_nets_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + whole_nets_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.extend_selection_to_whole_nets(); } }); - + this.add(whole_nets_button); - + javax.swing.JButton whole_connected_sets_button = new javax.swing.JButton(); whole_connected_sets_button.setText(resources.getString("conn_sets")); whole_connected_sets_button.setToolTipText(resources.getString("conn_sets_tooltip")); - whole_connected_sets_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + whole_connected_sets_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.extend_selection_to_whole_connected_sets(); } }); - + this.add(whole_connected_sets_button); - + javax.swing.JButton whole_connections_button = new javax.swing.JButton(); whole_connections_button.setText(resources.getString("connections")); whole_connections_button.setToolTipText(resources.getString("connections_tooltip")); - whole_connections_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + whole_connections_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.extend_selection_to_whole_connections(); } }); - + this.add(whole_connections_button); - + javax.swing.JButton whole_groups_button = new javax.swing.JButton(); whole_groups_button.setText(resources.getString("components")); whole_groups_button.setToolTipText(resources.getString("components_tooltip")); - whole_groups_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + whole_groups_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.extend_selection_to_whole_components(); } }); - + this.add(whole_groups_button); - - if (p_extended) - { + + if (p_extended) { javax.swing.JButton new_net_button = new javax.swing.JButton(); new_net_button.setText(resources.getString("new_net")); new_net_button.setToolTipText(resources.getString("new_net_tooltip")); - new_net_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + new_net_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.assign_selected_to_new_net(); } }); - + this.add(new_net_button); - + javax.swing.JButton new_group_button = new javax.swing.JButton(); new_group_button.setText(resources.getString("new_component")); new_group_button.setToolTipText(resources.getString("new_component_tooltip")); - new_group_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + new_group_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.assign_selected_to_new_group(); } }); - + this.add(new_group_button); } - + javax.swing.JLabel jLabel6 = new javax.swing.JLabel(); jLabel6.setMaximumSize(new java.awt.Dimension(10, 10)); jLabel6.setPreferredSize(new java.awt.Dimension(10, 10)); this.add(jLabel6); - + javax.swing.JButton violation_button = new javax.swing.JButton(); violation_button.setText(resources.getString("violations")); violation_button.setToolTipText(resources.getString("violations_tooltip")); - violation_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + violation_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.toggle_selected_item_violations(); } }); - + this.add(violation_button); - + javax.swing.JLabel jLabel7 = new javax.swing.JLabel(); jLabel7.setMaximumSize(new java.awt.Dimension(10, 10)); jLabel7.setPreferredSize(new java.awt.Dimension(10, 10)); this.add(jLabel7); - - + + javax.swing.JButton display_selection_button = new javax.swing.JButton(); display_selection_button.setText(resources.getString("zoom_selection")); display_selection_button.setToolTipText(resources.getString("zoom_selection_tooltip")); - display_selection_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + display_selection_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.zoom_selection(); - + } }); this.add(display_selection_button); - + javax.swing.JButton display_all_button = new javax.swing.JButton(); display_all_button.setText(resources.getString("zoom_all")); display_all_button.setToolTipText(resources.getString("zoom_all_tooltip")); - display_all_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + display_all_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.zoom_all(); } }); this.add(display_all_button); - + javax.swing.JButton display_region_button = new javax.swing.JButton(); display_region_button.setText(resources.getString("zoom_region")); display_region_button.setToolTipText(resources.getString("zoom_region_tooltip")); - display_region_button.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + display_region_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_frame.board_panel.board_handling.zoom_region(); } }); - + this.add(display_region_button); } - - private void assign_clearance_class() - { - if (board_frame.board_panel.board_handling.is_board_read_only()) - { + + private void assign_clearance_class() { + if (board_frame.board_panel.board_handling.is_board_read_only()) { return; } net.freerouting.rules.ClearanceMatrix clearance_matrix = board_frame.board_panel.board_handling.get_routing_board().rules.clearance_matrix; - Object [] class_name_arr = new Object[clearance_matrix.get_class_count()]; - for (int i = 0; i < class_name_arr.length; ++i) - { - class_name_arr[i] = clearance_matrix.get_name(i); + Object[] class_name_arr = new Object[clearance_matrix.get_class_count()]; + for (int i = 0; i < class_name_arr.length; ++i) { + class_name_arr[i] = clearance_matrix.get_name(i); } Object selected_value = javax.swing.JOptionPane.showInputDialog(null, resources.getString("select_clearance_class"), resources.getString("assign_clearance_class"), javax.swing.JOptionPane.INFORMATION_MESSAGE, null, class_name_arr, class_name_arr[0]); - if(selected_value == null || !(selected_value instanceof String)) - { + if (selected_value == null || !(selected_value instanceof String)) { return; } int class_index = clearance_matrix.get_no((String) selected_value); - if (class_index < 0) - { + if (class_index < 0) { return; } board_frame.board_panel.board_handling.assign_clearance_classs_to_selected_items(class_index); } - - private final BoardFrame board_frame; - private final java.util.ResourceBundle resources; } diff --git a/src/main/java/net/freerouting/gui/ColorManager.java b/src/main/java/net/freerouting/gui/ColorManager.java index 278fc2c6..a970c14c 100644 --- a/src/main/java/net/freerouting/gui/ColorManager.java +++ b/src/main/java/net/freerouting/gui/ColorManager.java @@ -20,130 +20,101 @@ package net.freerouting.gui; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import net.freerouting.boardgraphics.GraphicsContext; -import javax.swing.BorderFactory; -import javax.swing.DefaultCellEditor; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JColorChooser; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTable; +import javax.swing.*; import javax.swing.border.Border; import javax.swing.table.TableCellRenderer; - -import net.freerouting.boardgraphics.GraphicsContext; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Window for changing the colors of board objects. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class ColorManager extends BoardSavableSubWindow -{ - - /** Creates a new instance of ColorManager */ - public ColorManager(BoardFrame p_board_frame) - { +public class ColorManager extends BoardSavableSubWindow { + + private final JTable item_color_table; + private final JTable other_color_table; + + + /** + * Creates a new instance of ColorManager + */ + public ColorManager(BoardFrame p_board_frame) { GraphicsContext graphics_context = p_board_frame.board_panel.board_handling.graphics_context; - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); this.setTitle(resources.getString("color_manager")); - final JPanel panel = new JPanel(); + final JPanel panel = new JPanel(); final int textfield_height = 17; final int table_width = 1100; final int item_color_table_height = graphics_context.item_color_table.getRowCount() * textfield_height; panel.setPreferredSize(new Dimension(10 + table_width, 70 + item_color_table_height)); - + this.item_color_table = new JTable(graphics_context.item_color_table); item_color_table.setPreferredScrollableViewportSize(new Dimension(table_width, item_color_table_height)); JScrollPane item_scroll_pane = init_color_table(item_color_table, p_board_frame.get_locale()); panel.add(item_scroll_pane, BorderLayout.NORTH); - + this.other_color_table = new JTable(graphics_context.other_color_table); this.other_color_table.setPreferredScrollableViewportSize(new Dimension(table_width, textfield_height)); JScrollPane other_scroll_pane = init_color_table(other_color_table, p_board_frame.get_locale()); - panel.add(other_scroll_pane, BorderLayout.SOUTH); + panel.add(other_scroll_pane, BorderLayout.SOUTH); getContentPane().add(panel, BorderLayout.CENTER); p_board_frame.set_context_sensitive_help(this, "WindowDisplay_Colors"); this.pack(); this.setResizable(false); } - - /** - * Reassigns the table model variables because they may have changed in p_graphics_context. - */ - public void set_table_models(GraphicsContext p_graphics_context) - { - this.item_color_table.setModel(p_graphics_context.item_color_table); - this.other_color_table.setModel(p_graphics_context.other_color_table); - } - - - + /** * Initializes p_color_table and return the created scroll_pane of the color table. */ - private static JScrollPane init_color_table(JTable p_color_table, java.util.Locale p_locale) - { + private static JScrollPane init_color_table(JTable p_color_table, java.util.Locale p_locale) { //Create the scroll pane and add the table to it. JScrollPane scroll_pane = new JScrollPane(p_color_table); //Set up renderer and editor for the Color columns. p_color_table.setDefaultRenderer(Color.class, new ColorRenderer(true)); - + setUpColorEditor(p_color_table, p_locale); return scroll_pane; } - + //Set up the editor for the Color cells. - private static void setUpColorEditor(JTable p_table, java.util.Locale p_locale) - { + private static void setUpColorEditor(JTable p_table, java.util.Locale p_locale) { //First, set up the button that brings up the dialog. - final JButton button = new JButton("") - { - public void setText(String s) - { + final JButton button = new JButton("") { + public void setText(String s) { //Button never shows text -- only color. } }; button.setBackground(Color.white); button.setBorderPainted(false); - button.setMargin(new Insets(0,0,0,0)); - + button.setMargin(new Insets(0, 0, 0, 0)); + //Now create an editor to encapsulate the button, and //set it up as the editor for all Color cells. final ColorEditor colorEditor = new ColorEditor(button); p_table.setDefaultEditor(Color.class, colorEditor); - + //Set up the dialog that the button brings up. final JColorChooser colorChooser = new JColorChooser(); - ActionListener okListener = new ActionListener() - { - public void actionPerformed(ActionEvent e) - { + ActionListener okListener = new ActionListener() { + public void actionPerformed(ActionEvent e) { colorEditor.currentColor = colorChooser.getColor(); } }; - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_locale); final JDialog dialog = JColorChooser.createDialog(button, resources.getString("pick_a_color"), true, colorChooser, okListener, null); - + //Here's the code that brings up the dialog. - button.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { + button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { button.setBackground(colorEditor.currentColor); colorChooser.setColor(colorEditor.currentColor); //Without the following line, the dialog comes up @@ -153,46 +124,42 @@ public void actionPerformed(ActionEvent e) } }); } - - private final JTable item_color_table; - private final JTable other_color_table; - - private static class ColorRenderer extends JLabel implements TableCellRenderer - { + + /** + * Reassigns the table model variables because they may have changed in p_graphics_context. + */ + public void set_table_models(GraphicsContext p_graphics_context) { + this.item_color_table.setModel(p_graphics_context.item_color_table); + this.other_color_table.setModel(p_graphics_context.other_color_table); + } + + private static class ColorRenderer extends JLabel implements TableCellRenderer { Border unselectedBorder = null; Border selectedBorder = null; boolean isBordered = true; - - public ColorRenderer(boolean p_is_bordered) - { + + public ColorRenderer(boolean p_is_bordered) { super(); this.isBordered = p_is_bordered; setOpaque(true); //MUST do this for background to show up. } - + public Component getTableCellRendererComponent( JTable p_table, Object p_color, boolean p_is_selected, boolean p_has_focus, - int p_row, int p_column) - { - setBackground((Color)p_color); - if (isBordered) - { - if (p_is_selected) - { - if (selectedBorder == null) - { + int p_row, int p_column) { + setBackground((Color) p_color); + if (isBordered) { + if (p_is_selected) { + if (selectedBorder == null) { selectedBorder = - BorderFactory.createMatteBorder(2,5,2,5, - p_table.getSelectionBackground()); + BorderFactory.createMatteBorder(2, 5, 2, 5, + p_table.getSelectionBackground()); } setBorder(selectedBorder); - } - else - { - if (unselectedBorder == null) - { - unselectedBorder = BorderFactory.createMatteBorder(2,5,2,5, + } else { + if (unselectedBorder == null) { + unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, p_table.getBackground()); } setBorder(unselectedBorder); @@ -201,7 +168,7 @@ public Component getTableCellRendererComponent( return this; } } - + /** * The editor button that brings up the dialog. * We extend DefaultCellEditor for convenience, @@ -210,46 +177,39 @@ public Component getTableCellRendererComponent( * the implementation of TableCellEditor methods * from the source code for DefaultCellEditor. */ - private static class ColorEditor extends DefaultCellEditor - { + private static class ColorEditor extends DefaultCellEditor { Color currentColor = null; - - public ColorEditor(JButton b) - { + + public ColorEditor(JButton b) { super(new JCheckBox()); //Unfortunately, the constructor //expects a check box, combo box, //or text field. editorComponent = b; setClickCountToStart(1); //This is usually 1 or 2. - + //Must do this so that editing stops when appropriate. - b.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { fireEditingStopped(); } }); } - - protected void fireEditingStopped() - { + + protected void fireEditingStopped() { super.fireEditingStopped(); } - - public Object getCellEditorValue() - { + + public Object getCellEditorValue() { return currentColor; } - + public Component getTableCellEditorComponent(JTable table, - Object value, - boolean isSelected, - int row, - int column) - { - ((JButton)editorComponent).setText(value.toString()); - currentColor = (Color)value; + Object value, + boolean isSelected, + int row, + int column) { + ((JButton) editorComponent).setText(value.toString()); + currentColor = (Color) value; return editorComponent; } } diff --git a/src/main/java/net/freerouting/gui/ComboBoxClearance.java b/src/main/java/net/freerouting/gui/ComboBoxClearance.java index 526d2c84..56b60796 100644 --- a/src/main/java/net/freerouting/gui/ComboBoxClearance.java +++ b/src/main/java/net/freerouting/gui/ComboBoxClearance.java @@ -19,6 +19,7 @@ */ package net.freerouting.gui; + import net.freerouting.rules.ClearanceMatrix; /** @@ -26,71 +27,63 @@ * * @author alfons */ -public class ComboBoxClearance extends javax.swing.JComboBox -{ - - /** Creates a new instance of ClearanceComboBox */ - public ComboBoxClearance(ClearanceMatrix p_clearance_matrix) - { - this.class_arr = new ClearanceClass [p_clearance_matrix.get_class_count()]; - for (int i = 0; i < this.class_arr.length; ++i) - { +public class ComboBoxClearance extends javax.swing.JComboBox { + + private ClearanceClass[] class_arr; + + /** + * Creates a new instance of ClearanceComboBox + */ + public ComboBoxClearance(ClearanceMatrix p_clearance_matrix) { + this.class_arr = new ClearanceClass[p_clearance_matrix.get_class_count()]; + for (int i = 0; i < this.class_arr.length; ++i) { this.class_arr[i] = new ClearanceClass(p_clearance_matrix.get_name(i), i); } this.setModel(new javax.swing.DefaultComboBoxModel(this.class_arr)); this.setSelectedIndex(1); } - + /** * Adjusts this combo box to p_new_clearance_matrix. */ - public void adjust(ClearanceMatrix p_new_clearance_matrix) - { + public void adjust(ClearanceMatrix p_new_clearance_matrix) { int old_index = this.get_selected_class_index(); - this.class_arr = new ClearanceClass [p_new_clearance_matrix.get_class_count()]; - for (int i = 0; i < this.class_arr.length; ++i) - { + this.class_arr = new ClearanceClass[p_new_clearance_matrix.get_class_count()]; + for (int i = 0; i < this.class_arr.length; ++i) { this.class_arr[i] = new ClearanceClass(p_new_clearance_matrix.get_name(i), i); } this.setModel(new javax.swing.DefaultComboBoxModel(this.class_arr)); this.setSelectedIndex(Math.min(old_index, this.class_arr.length - 1)); } - + /** * Returns the index of the selected clearance class in the clearance matrix. */ - public int get_selected_class_index() - { + public int get_selected_class_index() { return ((ClearanceClass) this.getSelectedItem()).index; } - + /** * Returns the number of clearance classes in this combo box. */ - public int get_class_count() - { + public int get_class_count() { return this.class_arr.length; } - - private ClearanceClass[] class_arr; - + /** * Contains the name of a clearance class and its index in the clearance matrix. */ - private static class ClearanceClass - { - public ClearanceClass(String p_name, int p_index) - { + private static class ClearanceClass { + public final String name; + public final int index; + + public ClearanceClass(String p_name, int p_index) { this.name = p_name; this.index = p_index; } - - public String toString() - { + + public String toString() { return name; } - - public final String name; - public final int index; } } diff --git a/src/main/java/net/freerouting/gui/ComboBoxLayer.java b/src/main/java/net/freerouting/gui/ComboBoxLayer.java index 1ea89170..4256ca2e 100644 --- a/src/main/java/net/freerouting/gui/ComboBoxLayer.java +++ b/src/main/java/net/freerouting/gui/ComboBoxLayer.java @@ -19,6 +19,7 @@ */ package net.freerouting.gui; + import net.freerouting.board.LayerStructure; /** @@ -26,31 +27,38 @@ * * @author Alfons Wirtz */ -public class ComboBoxLayer extends javax.swing.JComboBox -{ - - /** Creates a new instance of LayerComboBox */ - public ComboBoxLayer(LayerStructure p_layer_structure, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = +public class ComboBoxLayer extends javax.swing.JComboBox { + + /** + * The layer index, when all layers are selected. + */ + public final static int ALL_LAYER_INDEX = -1; + /** + * The layer index, when all inner layers ar selected. + */ + public final static int INNER_LAYER_INDEX = -2; + private final Layer[] layer_arr; + + /** + * Creates a new instance of LayerComboBox + */ + public ComboBoxLayer(LayerStructure p_layer_structure, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_locale); int signal_layer_count = p_layer_structure.signal_layer_count(); int item_count = signal_layer_count + 1; boolean add_inner_layer_item = signal_layer_count > 2; - if (add_inner_layer_item) - { + if (add_inner_layer_item) { ++item_count; } - this.layer_arr = new Layer [item_count]; + this.layer_arr = new Layer[item_count]; this.layer_arr[0] = new Layer(resources.getString("all"), ALL_LAYER_INDEX); int curr_layer_no = 0; - if (add_inner_layer_item ) - { + if (add_inner_layer_item) { this.layer_arr[1] = new Layer(resources.getString("inner"), INNER_LAYER_INDEX); ++curr_layer_no; } - for (int i = 0; i < signal_layer_count; ++i) - { + for (int i = 0; i < signal_layer_count; ++i) { ++curr_layer_no; net.freerouting.board.Layer curr_signal_layer = p_layer_structure.get_signal_layer(i); layer_arr[curr_layer_no] = new Layer(curr_signal_layer.name, p_layer_structure.get_no(curr_signal_layer)); @@ -58,39 +66,29 @@ public ComboBoxLayer(LayerStructure p_layer_structure, java.util.Locale p_locale this.setModel(new javax.swing.DefaultComboBoxModel(layer_arr)); this.setSelectedIndex(0); } - - public Layer get_selected_layer() - { + + public Layer get_selected_layer() { return (Layer) this.getSelectedItem(); } - - private final Layer [] layer_arr; - + /** * Layers of the board layer structure plus layer "all". * Index is the layer number in the board layer structure or -1 for layer "all". */ - public static class Layer - { - Layer(String p_name, int p_index) - { + public static class Layer { + final String name; + /** + * The index in the board layer_structure, -1 for the layers with name "all" or "inner" + */ + final int index; + + Layer(String p_name, int p_index) { name = p_name; index = p_index; } - - public String toString() - { + + public String toString() { return name; } - - final String name; - - /** The index in the board layer_structure, -1 for the layers with name "all" or "inner" */ - final int index; } - - /** The layer index, when all layers are selected. */ - public final static int ALL_LAYER_INDEX = -1; - /** The layer index, when all inner layers ar selected. */ - public final static int INNER_LAYER_INDEX = -2; } diff --git a/src/main/java/net/freerouting/gui/Cursor.java b/src/main/java/net/freerouting/gui/Cursor.java index c8b6c17b..9988ca91 100644 --- a/src/main/java/net/freerouting/gui/Cursor.java +++ b/src/main/java/net/freerouting/gui/Cursor.java @@ -21,72 +21,54 @@ package net.freerouting.gui; -import java.awt.AlphaComposite; -import java.awt.BasicStroke; -import java.awt.Graphics; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.RenderingHints; - +import java.awt.*; import java.awt.geom.GeneralPath; -import java.awt.geom.Point2D; import java.awt.geom.Line2D; +import java.awt.geom.Point2D; /** - * * @author Alfons Wirtz */ -public abstract class Cursor -{ - - public static Cursor get_45_degree_cross_hair_cursor() - { +public abstract class Cursor { + + private static final double MAX_COOR = 1000; + private static Line2D VERTICAL_LINE = new Line2D.Double(0, -MAX_COOR, 0, MAX_COOR); + private static Line2D HORIZONTAL_LINE = new Line2D.Double(-MAX_COOR, 0, MAX_COOR, 0); + private static Line2D RIGHT_DIAGONAL_LINE = new Line2D.Double(-MAX_COOR, -MAX_COOR, MAX_COOR, MAX_COOR); + private static Line2D LEFT_DIAGONAL_LINE = new Line2D.Double(-MAX_COOR, MAX_COOR, MAX_COOR, -MAX_COOR); + double x_coor; + double y_coor; + boolean location_initialized = false; + + public static Cursor get_45_degree_cross_hair_cursor() { return new FortyfiveDegreeCrossHairCursor(); } - - public abstract void draw(Graphics p_graphics); - - public void set_location(Point2D p_location) - { - this.x_coor = p_location.getX(); - this.y_coor = p_location.getY(); - location_initialized = true; - } - - protected static void init_graphics(Graphics2D p_graphics) - { + + protected static void init_graphics(Graphics2D p_graphics) { BasicStroke bs = new BasicStroke(0, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); p_graphics.setStroke(bs); p_graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); p_graphics.setColor(Color.WHITE); p_graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1)); } - - double x_coor; - double y_coor; - - boolean location_initialized = false; - - private static final double MAX_COOR = 1000; - - private static Line2D VERTICAL_LINE = new Line2D.Double(0, -MAX_COOR, 0, MAX_COOR); - private static Line2D HORIZONTAL_LINE = new Line2D.Double(-MAX_COOR, 0, MAX_COOR, 0); - private static Line2D RIGHT_DIAGONAL_LINE = new Line2D.Double(-MAX_COOR, -MAX_COOR, MAX_COOR, MAX_COOR); - private static Line2D LEFT_DIAGONAL_LINE = new Line2D.Double(-MAX_COOR, MAX_COOR, MAX_COOR, -MAX_COOR); - - - private static class FortyfiveDegreeCrossHairCursor extends Cursor - { - - public void draw(Graphics p_graphics) - { - - if (!location_initialized) - { + + public abstract void draw(Graphics p_graphics); + + public void set_location(Point2D p_location) { + this.x_coor = p_location.getX(); + this.y_coor = p_location.getY(); + location_initialized = true; + } + + private static class FortyfiveDegreeCrossHairCursor extends Cursor { + + public void draw(Graphics p_graphics) { + + if (!location_initialized) { return; } - Graphics2D g2 = (Graphics2D)p_graphics; + Graphics2D g2 = (Graphics2D) p_graphics; init_graphics(g2); GeneralPath draw_path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); draw_path.append(VERTICAL_LINE, false); @@ -97,5 +79,5 @@ public void draw(Graphics p_graphics) g2.draw(draw_path); } } - + } diff --git a/src/main/java/net/freerouting/gui/DesignFile.java b/src/main/java/net/freerouting/gui/DesignFile.java index 809ab58a..af16ee84 100644 --- a/src/main/java/net/freerouting/gui/DesignFile.java +++ b/src/main/java/net/freerouting/gui/DesignFile.java @@ -25,21 +25,42 @@ import net.freerouting.interactive.BoardHandling; /** - * File functionality with security restrictions used, when the application is opened with Java Webstart + * File functionality with security restrictions used, when the application is opened with Java Webstart * * @author Alfons Wirtz */ -public class DesignFile -{ +public class DesignFile { public static final String[] all_file_extensions = {"bin", "dsn"}; public static final String[] text_file_extensions = {"dsn"}; public static final String binary_file_extension = "bin"; + private static final String RULES_FILE_EXTENSION = ".rules"; + private final java.io.File input_file; + /** + * Used, if the application is run without Java Web Start. + */ + private java.io.File output_file; + private javax.swing.JFileChooser file_chooser; - public static DesignFile get_instance(String p_design_file_name) - { - if (p_design_file_name == null) - { + /** + * Creates a new instance of DesignFile. + */ + private DesignFile(java.io.File p_design_file, javax.swing.JFileChooser p_file_chooser) { + this.file_chooser = p_file_chooser; + this.input_file = p_design_file; + this.output_file = p_design_file; + if (p_design_file != null) { + String file_name = p_design_file.getName(); + String[] name_parts = file_name.split("\\."); + if (name_parts[name_parts.length - 1].compareToIgnoreCase(binary_file_extension) != 0) { + String binfile_name = name_parts[0] + "." + binary_file_extension; + this.output_file = new java.io.File(p_design_file.getParent(), binfile_name); + } + } + } + + public static DesignFile get_instance(String p_design_file_name) { + if (p_design_file_name == null) { return null; } return new DesignFile(new java.io.File(p_design_file_name), null); @@ -48,55 +69,50 @@ public static DesignFile get_instance(String p_design_file_name) /** * Shows a file chooser for opening a design file. */ - public static DesignFile open_dialog(String p_design_dir_name) - { + public static DesignFile open_dialog(String p_design_dir_name) { javax.swing.JFileChooser file_chooser = new javax.swing.JFileChooser(p_design_dir_name); FileFilter file_filter = new FileFilter(all_file_extensions); file_chooser.setFileFilter(file_filter); file_chooser.showOpenDialog(null); java.io.File curr_design_file = file_chooser.getSelectedFile(); - if (curr_design_file == null) - { + if (curr_design_file == null) { return null; } return new DesignFile(curr_design_file, file_chooser); } - /** - * Creates a new instance of DesignFile. - */ - private DesignFile(java.io.File p_design_file, javax.swing.JFileChooser p_file_chooser) - { - this.file_chooser = p_file_chooser; - this.input_file = p_design_file; - this.output_file = p_design_file; - if (p_design_file != null) - { - String file_name = p_design_file.getName(); - String[] name_parts = file_name.split("\\."); - if (name_parts[name_parts.length - 1].compareToIgnoreCase(binary_file_extension) != 0) - { - String binfile_name = name_parts[0] + "." + binary_file_extension; - this.output_file = new java.io.File(p_design_file.getParent(), binfile_name); + public static boolean read_rules_file(String p_design_name, String p_parent_name, + BoardHandling p_board_handling, String p_confirm_message) { + boolean result; + String rule_file_name = p_design_name + ".rules"; + boolean dsn_file_generated_by_host = p_board_handling.get_routing_board().communication.specctra_parser_info.dsn_file_generated_by_host; + try { + java.io.File rules_file = new java.io.File(p_parent_name, rule_file_name); + java.io.InputStream input_stream = new java.io.FileInputStream(rules_file); + result = dsn_file_generated_by_host && WindowMessage.confirm(p_confirm_message) && RulesFile.read(input_stream, p_design_name, p_board_handling); + try { + input_stream.close(); + rules_file.delete(); + } catch (java.io.IOException e) { + result = false; } + } catch (java.io.FileNotFoundException e) { + result = false; } + return result; } /** * Gets an InputStream from the file. Returns null, if the algorithm failed. */ - public java.io.InputStream get_input_stream() - { + public java.io.InputStream get_input_stream() { java.io.InputStream result; - if (this.input_file == null) - { + if (this.input_file == null) { return null; } - try - { + try { result = new java.io.FileInputStream(this.input_file); - } catch (Exception e) - { + } catch (Exception e) { result = null; } return result; @@ -105,37 +121,28 @@ public java.io.InputStream get_input_stream() /** * Gets the file name as a String. Returns null on failure. */ - public String get_name() - { + public String get_name() { String result; - if (this.input_file != null) - { + if (this.input_file != null) { result = this.input_file.getName(); - } - else - { + } else { result = null; } return result; } - public void save_as_dialog(java.awt.Component p_parent, BoardFrame p_board_frame) - { + public void save_as_dialog(java.awt.Component p_parent, BoardFrame p_board_frame) { final java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); String[] file_name_parts = this.get_name().split("\\.", 2); String design_name = file_name_parts[0]; - if (this.file_chooser == null) - { + if (this.file_chooser == null) { String design_dir_name; - if (this.output_file == null) - { + if (this.output_file == null) { design_dir_name = null; - } - else - { + } else { design_dir_name = this.output_file.getParent(); } this.file_chooser = new javax.swing.JFileChooser(design_dir_name); @@ -145,41 +152,31 @@ public void save_as_dialog(java.awt.Component p_parent, BoardFrame p_board_frame this.file_chooser.showSaveDialog(p_parent); java.io.File new_file = file_chooser.getSelectedFile(); - if (new_file == null) - { + if (new_file == null) { p_board_frame.screen_messages.set_status_message(resources.getString("message_1")); return; } String new_file_name = new_file.getName(); String[] new_name_parts = new_file_name.split("\\."); String found_file_extension = new_name_parts[new_name_parts.length - 1]; - if (found_file_extension.compareToIgnoreCase(binary_file_extension) == 0) - { + if (found_file_extension.compareToIgnoreCase(binary_file_extension) == 0) { p_board_frame.screen_messages.set_status_message(resources.getString("message_2") + " " + new_file.getName()); this.output_file = new_file; p_board_frame.save(); - } - else - { - if (found_file_extension.compareToIgnoreCase("dsn") != 0) - { + } else { + if (found_file_extension.compareToIgnoreCase("dsn") != 0) { p_board_frame.screen_messages.set_status_message(resources.getString("message_3")); return; } java.io.OutputStream output_stream; - try - { + try { output_stream = new java.io.FileOutputStream(new_file); - } catch (Exception e) - { + } catch (Exception e) { output_stream = null; } - if (p_board_frame.board_panel.board_handling.export_to_dsn_file(output_stream, design_name, false)) - { + if (p_board_frame.board_panel.board_handling.export_to_dsn_file(output_stream, design_name, false)) { p_board_frame.screen_messages.set_status_message(resources.getString("message_4") + " " + new_file_name + " " + resources.getString("message_5")); - } - else - { + } else { p_board_frame.screen_messages.set_status_message(resources.getString("message_6") + " " + new_file_name + " " + resources.getString("message_7")); } } @@ -189,8 +186,7 @@ public void save_as_dialog(java.awt.Component p_parent, BoardFrame p_board_frame * Writes a Specctra Session File to update the design file in the host system. * Returns false, if the write failed */ - public boolean write_specctra_session_file(BoardFrame p_board_frame) - { + public boolean write_specctra_session_file(BoardFrame p_board_frame) { final java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); String design_file_name = this.get_name(); @@ -199,27 +195,21 @@ public boolean write_specctra_session_file(BoardFrame p_board_frame) String output_file_name = design_name + ".ses"; java.io.File curr_output_file = new java.io.File(get_parent(), output_file_name); java.io.OutputStream output_stream; - try - { + try { output_stream = new java.io.FileOutputStream(curr_output_file); - } catch (Exception e) - { + } catch (Exception e) { output_stream = null; } - if (p_board_frame.board_panel.board_handling.export_specctra_session_file(design_file_name, output_stream)) - { + if (p_board_frame.board_panel.board_handling.export_specctra_session_file(design_file_name, output_stream)) { p_board_frame.screen_messages.set_status_message(resources.getString("message_11") + " " + output_file_name + " " + resources.getString("message_12")); - } - else - { + } else { p_board_frame.screen_messages.set_status_message(resources.getString("message_13") + " " + output_file_name + " " + resources.getString("message_7")); return false; } - if (WindowMessage.confirm(resources.getString("confirm"))) - { + if (WindowMessage.confirm(resources.getString("confirm"))) { return write_rules_file(design_name, p_board_frame.board_panel.board_handling); } return true; @@ -228,16 +218,13 @@ public boolean write_specctra_session_file(BoardFrame p_board_frame) /** * Saves the board rule to file, so that they can be reused later on. */ - private boolean write_rules_file(String p_design_name, net.freerouting.interactive.BoardHandling p_board_handling) - { + private boolean write_rules_file(String p_design_name, net.freerouting.interactive.BoardHandling p_board_handling) { String rules_file_name = p_design_name + RULES_FILE_EXTENSION; java.io.OutputStream output_stream; java.io.File rules_file = new java.io.File(this.get_parent(), rules_file_name); - try - { + try { output_stream = new java.io.FileOutputStream(rules_file); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to create rules file"); return false; } @@ -245,36 +232,12 @@ private boolean write_rules_file(String p_design_name, net.freerouting.interacti return true; } - public static boolean read_rules_file(String p_design_name, String p_parent_name, - BoardHandling p_board_handling, String p_confirm_message) - { - boolean result; - String rule_file_name = p_design_name + ".rules"; - boolean dsn_file_generated_by_host = p_board_handling.get_routing_board().communication.specctra_parser_info.dsn_file_generated_by_host; - try { - java.io.File rules_file = new java.io.File(p_parent_name, rule_file_name); - java.io.InputStream input_stream = new java.io.FileInputStream(rules_file); - result = dsn_file_generated_by_host && WindowMessage.confirm(p_confirm_message) && RulesFile.read(input_stream, p_design_name, p_board_handling); - try { - input_stream.close(); - rules_file.delete(); - } catch (java.io.IOException e) { - result = false; - } - } catch (java.io.FileNotFoundException e) { - result = false; - } - return result; - } - - public void update_eagle(BoardFrame p_board_frame) - { + public void update_eagle(BoardFrame p_board_frame) { final java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.BoardMenuFile", p_board_frame.get_locale()); String design_file_name = get_name(); java.io.ByteArrayOutputStream session_output_stream = new java.io.ByteArrayOutputStream(); - if (!p_board_frame.board_panel.board_handling.export_specctra_session_file(design_file_name, session_output_stream)) - { + if (!p_board_frame.board_panel.board_handling.export_specctra_session_file(design_file_name, session_output_stream)) { return; } java.io.InputStream input_stream = new java.io.ByteArrayInputStream(session_output_stream.toByteArray()); @@ -284,24 +247,18 @@ public void update_eagle(BoardFrame p_board_frame) String output_file_name = design_name + ".scr"; java.io.File curr_output_file = new java.io.File(get_parent(), output_file_name); java.io.OutputStream output_stream; - try - { + try { output_stream = new java.io.FileOutputStream(curr_output_file); - } catch (Exception e) - { + } catch (Exception e) { output_stream = null; } - if (p_board_frame.board_panel.board_handling.export_eagle_session_file(input_stream, output_stream)) - { + if (p_board_frame.board_panel.board_handling.export_eagle_session_file(input_stream, output_stream)) { p_board_frame.screen_messages.set_status_message(resources.getString("message_14") + " " + output_file_name + " " + resources.getString("message_15")); - } - else - { + } else { p_board_frame.screen_messages.set_status_message(resources.getString("message_16") + " " + output_file_name + " " + resources.getString("message_7")); } - if (WindowMessage.confirm(resources.getString("confirm"))) - { + if (WindowMessage.confirm(resources.getString("confirm"))) { write_rules_file(design_name, p_board_frame.board_panel.board_handling); } } @@ -310,37 +267,25 @@ public void update_eagle(BoardFrame p_board_frame) * Gets the binary file for saving or null, if the design file is not available * because the application is run with Java Web Start. */ - public java.io.File get_output_file() - { + public java.io.File get_output_file() { return this.output_file; } - public String get_parent() - { - if (input_file != null) - { + public String get_parent() { + if (input_file != null) { return input_file.getParent(); } return null; } - public java.io.File get_parent_file() - { - if (input_file != null) - { + public java.io.File get_parent_file() { + if (input_file != null) { return input_file.getParentFile(); } return null; } - public boolean is_created_from_text_file() - { + public boolean is_created_from_text_file() { return this.input_file != this.output_file; } - - /** Used, if the application is run without Java Web Start. */ - private java.io.File output_file; - private final java.io.File input_file; - private javax.swing.JFileChooser file_chooser; - private static final String RULES_FILE_EXTENSION = ".rules"; } diff --git a/src/main/java/net/freerouting/gui/GUIDefaultsFile.java b/src/main/java/net/freerouting/gui/GUIDefaultsFile.java index 20b3d99f..e9af1597 100644 --- a/src/main/java/net/freerouting/gui/GUIDefaultsFile.java +++ b/src/main/java/net/freerouting/gui/GUIDefaultsFile.java @@ -20,111 +20,113 @@ package net.freerouting.gui; -import net.freerouting.datastructures.IndentFileWriter; - import net.freerouting.board.ItemSelectionFilter; +import net.freerouting.datastructures.IndentFileWriter; /** * Description of a text file, where the board independent interactive settings are stored. * * @author Alfons Wirtz */ -public class GUIDefaultsFile -{ +public class GUIDefaultsFile { + private final net.freerouting.gui.BoardFrame board_frame; + private final net.freerouting.interactive.BoardHandling board_handling; /** - * Keywords in the gui defaults file. + * Used, when reading a defaults file, null otherwise. */ - enum Keyword - { - ALL_VISIBLE, ASSIGN_NET_RULES, AUTOMATIC_LAYER_DIMMING, BACKGROUND, BOARD_FRAME, BOUNDS, - CLEARANCE_COMPENSATION, CLEARANCE_MATRIX, CLOSED_BRACKET, COLOR_MANAGER, COLORS, - COMPONENT_BACK, COMPONENT_FRONT, COMPONENT_GRID, COMPONENT_INFO, CONDUCTION, CURRENT_LAYER, - CURRENT_ONLY, DESELECTED_SNAPSHOT_ATTRIBUTES, DISPLAY_MISCELLANIOUS, DISPLAY_REGION, - DRAG_COMPONENTS_ENABLED, DYNAMIC, EDIT_VIAS, EDIT_NET_RULES, FIXED, FIXED_TRACES, FIXED_VIAS, - FORTYFIVE_DEGREE, GUI_DEFAULTS,HILIGHT, HILIGHT_ROUTING_OBSTACLE, IGNORE_CONDUCTION_AREAS, INCOMPLETES, INCOMPLETES_INFO, - INTERACTIVE_STATE, KEEPOUT, LAYER_VISIBILITY, LENGTH_MATCHING, MANUAL_RULES, MANUAL_RULE_SETTINGS, - MOVE_PARAMETER, NET_INFO, NINETY_DEGREE, NONE, NOT_VISIBLE, OBJECT_COLORS, OBJECT_VISIBILITY, - OPEN_BRACKET, OFF, ON, OUTLINE, PARAMETER, PACKAGE_INFO, PADSTACK_INFO, PINS, PULL_TIGHT_ACCURACY, - PULL_TIGHT_REGION, PUSH_AND_SHOVE_ENABLED, ROUTE_DETAILS, ROUTE_MODE, ROUTE_PARAMETER, - RULE_SELECTION, SELECT_PARAMETER, SELECTABLE_ITEMS, SELECTION_LAYERS, SNAPSHOTS, - SHOVE_ENABLED, STITCHING, TRACES, UNFIXED, VIA_KEEPOUT, VISIBLE, VIA_RULES, VIA_SNAP_TO_SMD_CENTER, - VIAS, VIOLATIONS, VIOLATIONS_INFO, WINDOWS + private final GUIDefaultsScanner scanner; + /** + * Used, when writing a defaults file; null otherwise. + */ + private final IndentFileWriter out_file; + + private GUIDefaultsFile(net.freerouting.gui.BoardFrame p_board_frame, net.freerouting.interactive.BoardHandling p_board_handling, + GUIDefaultsScanner p_scanner, IndentFileWriter p_output_file) { + board_frame = p_board_frame; + board_handling = p_board_handling; + scanner = p_scanner; + out_file = p_output_file; } - + /** * Writes the GUI setting of p_board_frame as default to p_file. * Returns false, if an error occured. */ public static boolean write(net.freerouting.gui.BoardFrame p_board_frame, - net.freerouting.interactive.BoardHandling p_board_handling, java.io.OutputStream p_output_stream) - { - if (p_output_stream == null) - { + net.freerouting.interactive.BoardHandling p_board_handling, java.io.OutputStream p_output_stream) { + if (p_output_stream == null) { return false; } - + IndentFileWriter output_file = new IndentFileWriter(p_output_stream); - + GUIDefaultsFile result = new GUIDefaultsFile(p_board_frame, p_board_handling, null, output_file); - try - { + try { result.write_defaults_scope(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to write defaults file"); return false; } - - try - { + + try { output_file.close(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to close defaults file"); return false; } return true; } - + /** * Reads the GUI setting of p_board_frame from file. * Returns false, if an error occured while reading the file. */ public static boolean read(net.freerouting.gui.BoardFrame p_board_frame, - net.freerouting.interactive.BoardHandling p_board_handling, java.io.InputStream p_input_stream) - { - if (p_input_stream == null) - { + net.freerouting.interactive.BoardHandling p_board_handling, java.io.InputStream p_input_stream) { + if (p_input_stream == null) { return false; } GUIDefaultsScanner scanner = new GUIDefaultsScanner(p_input_stream); GUIDefaultsFile new_instance = new GUIDefaultsFile(p_board_frame, p_board_handling, scanner, null); boolean result = true; - try - { + try { result = new_instance.read_defaults_scope(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("unable to read defaults file"); result = false; } return result; } - - private GUIDefaultsFile(net.freerouting.gui.BoardFrame p_board_frame, net.freerouting.interactive.BoardHandling p_board_handling, - GUIDefaultsScanner p_scanner, IndentFileWriter p_output_file) - { - board_frame = p_board_frame; - board_handling = p_board_handling; - scanner = p_scanner; - out_file = p_output_file; + + /** + * Skips the current scope. + * Returns false, if no legal scope was found. + */ + private static boolean skip_scope(GUIDefaultsScanner p_scanner) { + int open_bracked_count = 1; + while (open_bracked_count > 0) { + Object curr_token = null; + try { + curr_token = p_scanner.next_token(); + } catch (Exception e) { + System.out.println("GUIDefaultsFile.skip_scope: Error while scanning file"); + System.out.println(e); + return false; + } + if (curr_token == null) { + return false; // end of file + } + if (curr_token == Keyword.OPEN_BRACKET) { + ++open_bracked_count; + } else if (curr_token == Keyword.CLOSED_BRACKET) { + --open_bracked_count; + } + } + System.out.println("GUIDefaultsFile.skip_spope: unknown scope skipped"); + return true; } - - private void write_defaults_scope() throws java.io.IOException - { + + private void write_defaults_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("gui_defaults"); write_windows_scope(); @@ -132,62 +134,45 @@ private void write_defaults_scope() throws java.io.IOException write_parameter_scope(); out_file.end_scope(); } - - private boolean read_defaults_scope() throws java.io.IOException - { + + private boolean read_defaults_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); - - if (next_token != Keyword.OPEN_BRACKET) - { + + if (next_token != Keyword.OPEN_BRACKET) { return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.GUI_DEFAULTS) - { + if (next_token != Keyword.GUI_DEFAULTS) { return false; } - + // read the direct subscopes of the gui_defaults scope - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = this.scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { // end of file return true; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - - if (prev_token == Keyword.OPEN_BRACKET) - { - if (next_token == Keyword.COLORS) - { - if (!read_colors_scope()) - { + + if (prev_token == Keyword.OPEN_BRACKET) { + if (next_token == Keyword.COLORS) { + if (!read_colors_scope()) { return false; } - } - else if (next_token == Keyword.WINDOWS) - { - if (!read_windows_scope()) - { + } else if (next_token == Keyword.WINDOWS) { + if (!read_windows_scope()) { return false; } - } - else if (next_token == Keyword.PARAMETER) - { - if (!read_parameter_scope()) - { + } else if (next_token == Keyword.PARAMETER) { + if (!read_parameter_scope()) { return false; } - } - else - { + } else { // overread all scopes except the routes scope for the time being skip_scope(this.scanner); } @@ -196,45 +181,37 @@ else if (next_token == Keyword.PARAMETER) this.board_frame.refresh_windows(); return true; } - - private boolean read_windows_scope() throws java.io.IOException - { + + private boolean read_windows_scope() throws java.io.IOException { // read the direct subscopes of the windows scope Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = this.scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { // unexpected end of file return false; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - - if (prev_token == Keyword.OPEN_BRACKET) - { - if (!(next_token instanceof Keyword)) - { + + if (prev_token == Keyword.OPEN_BRACKET) { + if (!(next_token instanceof Keyword)) { System.out.println("GUIDefaultsFile.windows: Keyword expected"); return false; } - if (!read_frame_scope((Keyword) next_token)) - { - + if (!read_frame_scope((Keyword) next_token)) { + return false; } } } return true; } - - private void write_windows_scope() throws java.io.IOException - { + + private void write_windows_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("windows"); write_frame_scope(this.board_frame, "board_frame"); @@ -261,194 +238,127 @@ private void write_windows_scope() throws java.io.IOException write_frame_scope(this.board_frame.clearance_violations_window, "violations_info"); out_file.end_scope(); } - - private boolean read_frame_scope(Keyword p_frame) throws java.io.IOException - { + + private boolean read_frame_scope(Keyword p_frame) throws java.io.IOException { boolean is_visible; Object next_token = this.scanner.next_token(); - if (next_token == Keyword.VISIBLE) - { + if (next_token == Keyword.VISIBLE) { is_visible = true; - } - else if (next_token == Keyword.NOT_VISIBLE) - { + } else if (next_token == Keyword.NOT_VISIBLE) { is_visible = false; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_frame_scope: visible or not_visible expected"); return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.OPEN_BRACKET) - { + if (next_token != Keyword.OPEN_BRACKET) { System.out.println("GUIDefaultsFile.read_frame_scope: open_bracket expected"); return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.BOUNDS) - { + if (next_token != Keyword.BOUNDS) { System.out.println("GUIDefaultsFile.read_frame_scope: bounds expected"); return false; } java.awt.Rectangle bounds = read_rectangle(); - if (bounds == null) - { + if (bounds == null) { return false; } - for (int i = 0; i < 2; ++i) - { + for (int i = 0; i < 2; ++i) { next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_frame_scope: closing bracket expected"); return false; } } javax.swing.JFrame curr_frame; - if (p_frame == Keyword.BOARD_FRAME) - { + if (p_frame == Keyword.BOARD_FRAME) { curr_frame = this.board_frame; - } - else if (p_frame == Keyword.COLOR_MANAGER) - { + } else if (p_frame == Keyword.COLOR_MANAGER) { curr_frame = this.board_frame.color_manager; - } - else if (p_frame == Keyword.OBJECT_VISIBILITY) - { + } else if (p_frame == Keyword.OBJECT_VISIBILITY) { curr_frame = this.board_frame.object_visibility_window; - } - else if (p_frame == Keyword.LAYER_VISIBILITY) - { + } else if (p_frame == Keyword.LAYER_VISIBILITY) { curr_frame = this.board_frame.layer_visibility_window; - } - else if (p_frame == Keyword.DISPLAY_MISCELLANIOUS) - { + } else if (p_frame == Keyword.DISPLAY_MISCELLANIOUS) { curr_frame = this.board_frame.display_misc_window; - } - else if (p_frame == Keyword.SNAPSHOTS) - { + } else if (p_frame == Keyword.SNAPSHOTS) { curr_frame = this.board_frame.snapshot_window; - } - else if (p_frame == Keyword.SELECT_PARAMETER) - { + } else if (p_frame == Keyword.SELECT_PARAMETER) { curr_frame = this.board_frame.select_parameter_window; - } - else if (p_frame == Keyword.ROUTE_PARAMETER) - { + } else if (p_frame == Keyword.ROUTE_PARAMETER) { curr_frame = this.board_frame.route_parameter_window; - } - else if (p_frame == Keyword.MANUAL_RULES) - { + } else if (p_frame == Keyword.MANUAL_RULES) { curr_frame = this.board_frame.route_parameter_window.manual_rule_window; - } - else if (p_frame == Keyword.ROUTE_DETAILS) - { + } else if (p_frame == Keyword.ROUTE_DETAILS) { curr_frame = this.board_frame.route_parameter_window.detail_window; - } - else if (p_frame == Keyword.MOVE_PARAMETER) - { + } else if (p_frame == Keyword.MOVE_PARAMETER) { curr_frame = this.board_frame.move_parameter_window; - } - else if (p_frame == Keyword.CLEARANCE_MATRIX) - { + } else if (p_frame == Keyword.CLEARANCE_MATRIX) { curr_frame = this.board_frame.clearance_matrix_window; - } - else if (p_frame == Keyword.VIA_RULES) - { + } else if (p_frame == Keyword.VIA_RULES) { curr_frame = this.board_frame.via_window; - } - else if (p_frame == Keyword.EDIT_VIAS) - { + } else if (p_frame == Keyword.EDIT_VIAS) { curr_frame = this.board_frame.edit_vias_window; - } - else if (p_frame == Keyword.EDIT_NET_RULES) - { + } else if (p_frame == Keyword.EDIT_NET_RULES) { curr_frame = this.board_frame.edit_net_rules_window; - } - else if (p_frame == Keyword.ASSIGN_NET_RULES) - { + } else if (p_frame == Keyword.ASSIGN_NET_RULES) { curr_frame = this.board_frame.assign_net_classes_window; - } - else if (p_frame == Keyword.PADSTACK_INFO) - { + } else if (p_frame == Keyword.PADSTACK_INFO) { curr_frame = this.board_frame.padstacks_window; - } - else if (p_frame == Keyword.PACKAGE_INFO) - { + } else if (p_frame == Keyword.PACKAGE_INFO) { curr_frame = this.board_frame.packages_window; - } - else if (p_frame == Keyword.COMPONENT_INFO) - { + } else if (p_frame == Keyword.COMPONENT_INFO) { curr_frame = this.board_frame.components_window; - } - else if (p_frame == Keyword.NET_INFO) - { + } else if (p_frame == Keyword.NET_INFO) { curr_frame = this.board_frame.net_info_window; - } - else if (p_frame == Keyword.INCOMPLETES_INFO) - { + } else if (p_frame == Keyword.INCOMPLETES_INFO) { curr_frame = this.board_frame.incompletes_window; - } - else if (p_frame == Keyword.VIOLATIONS_INFO) - { + } else if (p_frame == Keyword.VIOLATIONS_INFO) { curr_frame = this.board_frame.clearance_violations_window; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_frame_scope: unknown frame"); return false; } curr_frame.setVisible(is_visible); - if (p_frame == Keyword.BOARD_FRAME) - { + if (p_frame == Keyword.BOARD_FRAME) { curr_frame.setBounds(bounds); - } - else - { + } else { // Set only the location. // Do not change the size of the frame because it depends on the layer count. curr_frame.setLocation(bounds.getLocation()); } return true; } - - private java.awt.Rectangle read_rectangle() throws java.io.IOException - { - int[] coor = new int [4]; - for (int i = 0; i < 4; ++i) - { + + private java.awt.Rectangle read_rectangle() throws java.io.IOException { + int[] coor = new int[4]; + for (int i = 0; i < 4; ++i) { Object next_token = this.scanner.next_token(); - if (!(next_token instanceof Integer)) - { + if (!(next_token instanceof Integer)) { System.out.println("GUIDefaultsFile.read_rectangle: Integer expected"); return null; } coor[i] = (Integer) next_token; } - return new java.awt.Rectangle(coor[0],coor[1],coor[2],coor[3]); + return new java.awt.Rectangle(coor[0], coor[1], coor[2], coor[3]); } - + private void write_frame_scope(javax.swing.JFrame p_frame, String p_frame_name) - throws java.io.IOException - { + throws java.io.IOException { out_file.start_scope(); out_file.write(p_frame_name); out_file.new_line(); - if (p_frame.isVisible()) - { + if (p_frame.isVisible()) { out_file.write("visible"); - } - else - { + } else { out_file.write("not_visible"); } write_bounds(p_frame.getBounds()); out_file.end_scope(); } - - private void write_bounds(java.awt.Rectangle p_bounds) throws java.io.IOException - { + + private void write_bounds(java.awt.Rectangle p_bounds) throws java.io.IOException { out_file.start_scope(); out_file.write("bounds"); out_file.new_line(); @@ -465,143 +375,89 @@ private void write_bounds(java.awt.Rectangle p_bounds) throws java.io.IOExceptio out_file.write(height.toString()); out_file.end_scope(); } - - private boolean read_colors_scope() throws java.io.IOException - { + + private boolean read_colors_scope() throws java.io.IOException { // read the direct subscopes of the colors scope Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = this.scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { // unexpected end of file return false; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - - if (prev_token == Keyword.OPEN_BRACKET) - { - - if (next_token == Keyword.BACKGROUND) - { - if (!read_background_color()) - { + + if (prev_token == Keyword.OPEN_BRACKET) { + + if (next_token == Keyword.BACKGROUND) { + if (!read_background_color()) { return false; } - } - else if (next_token == Keyword.CONDUCTION) - { - if (!read_conduction_colors()) - { + } else if (next_token == Keyword.CONDUCTION) { + if (!read_conduction_colors()) { return false; } - } - else if (next_token == Keyword.HILIGHT) - { - if (!read_hilight_color()) - { + } else if (next_token == Keyword.HILIGHT) { + if (!read_hilight_color()) { return false; } - } - else if (next_token == Keyword.INCOMPLETES) - { - if (!read_incompletes_color()) - { + } else if (next_token == Keyword.INCOMPLETES) { + if (!read_incompletes_color()) { return false; } - } - else if (next_token == Keyword.KEEPOUT) - { - if (!read_keepout_colors()) - { + } else if (next_token == Keyword.KEEPOUT) { + if (!read_keepout_colors()) { return false; } - } - else if (next_token == Keyword.OUTLINE) - { - if (!read_outline_color()) - { + } else if (next_token == Keyword.OUTLINE) { + if (!read_outline_color()) { return false; } - } - else if (next_token == Keyword.COMPONENT_FRONT) - { - if (!read_component_color(true)) - { + } else if (next_token == Keyword.COMPONENT_FRONT) { + if (!read_component_color(true)) { return false; } - } - else if (next_token == Keyword.COMPONENT_BACK) - { - if (!read_component_color(false)) - { + } else if (next_token == Keyword.COMPONENT_BACK) { + if (!read_component_color(false)) { return false; } - } - else if (next_token == Keyword.LENGTH_MATCHING) - { - if (!read_length_matching_color()) - { + } else if (next_token == Keyword.LENGTH_MATCHING) { + if (!read_length_matching_color()) { return false; } - } - else if (next_token == Keyword.PINS) - { - if (!read_pin_colors()) - { + } else if (next_token == Keyword.PINS) { + if (!read_pin_colors()) { return false; } - } - else if (next_token == Keyword.TRACES) - { - if (!read_trace_colors(false)) - { + } else if (next_token == Keyword.TRACES) { + if (!read_trace_colors(false)) { return false; } - } - else if (next_token == Keyword.FIXED_TRACES) - { - if (!read_trace_colors(true)) - { + } else if (next_token == Keyword.FIXED_TRACES) { + if (!read_trace_colors(true)) { return false; } - } - else if (next_token == Keyword.VIA_KEEPOUT) - { - if (!read_via_keepout_colors()) - { + } else if (next_token == Keyword.VIA_KEEPOUT) { + if (!read_via_keepout_colors()) { return false; } - } - else if (next_token == Keyword.VIAS) - { - if (!read_via_colors(false)) - { + } else if (next_token == Keyword.VIAS) { + if (!read_via_colors(false)) { return false; } - } - else if (next_token == Keyword.FIXED_VIAS) - { - if (!read_via_colors(true)) - { + } else if (next_token == Keyword.FIXED_VIAS) { + if (!read_via_colors(true)) { return false; } - } - else if (next_token == Keyword.VIOLATIONS) - { - if (!read_violations_color()) - { + } else if (next_token == Keyword.VIOLATIONS) { + if (!read_violations_color()) { return false; } - } - else - { + } else { // skip unknown scope skip_scope(this.scanner); } @@ -609,318 +465,260 @@ else if (next_token == Keyword.VIOLATIONS) } return true; } - - private boolean read_trace_colors(boolean p_fixed) throws java.io.IOException - { + + private boolean read_trace_colors(boolean p_fixed) throws java.io.IOException { double intensity = read_color_intensity(); - if (intensity < 0) - { + if (intensity < 0) { return false; } this.board_handling.graphics_context.set_trace_color_intensity(intensity); java.awt.Color[] curr_colors = read_color_array(); - if (curr_colors.length < 1) - { + if (curr_colors.length < 1) { return false; } this.board_handling.graphics_context.item_color_table.set_trace_colors(curr_colors, p_fixed); return true; } - - private boolean read_via_colors(boolean p_fixed) throws java.io.IOException - { + + private boolean read_via_colors(boolean p_fixed) throws java.io.IOException { double intensity = read_color_intensity(); - if (intensity < 0) - { + if (intensity < 0) { return false; } this.board_handling.graphics_context.set_via_color_intensity(intensity); java.awt.Color[] curr_colors = read_color_array(); - if (curr_colors.length < 1) - { + if (curr_colors.length < 1) { return false; } this.board_handling.graphics_context.item_color_table.set_via_colors(curr_colors, p_fixed); return true; } - - private boolean read_pin_colors() throws java.io.IOException - { + + private boolean read_pin_colors() throws java.io.IOException { double intensity = read_color_intensity(); - if (intensity < 0) - { + if (intensity < 0) { return false; } this.board_handling.graphics_context.set_pin_color_intensity(intensity); java.awt.Color[] curr_colors = read_color_array(); - if (curr_colors.length < 1) - { + if (curr_colors.length < 1) { return false; } this.board_handling.graphics_context.item_color_table.set_pin_colors(curr_colors); return true; } - - private boolean read_conduction_colors() throws java.io.IOException - { + + private boolean read_conduction_colors() throws java.io.IOException { double intensity = read_color_intensity(); - if (intensity < 0) - { + if (intensity < 0) { return false; } this.board_handling.graphics_context.set_conduction_color_intensity(intensity); java.awt.Color[] curr_colors = read_color_array(); - if (curr_colors.length < 1) - { + if (curr_colors.length < 1) { return false; } this.board_handling.graphics_context.item_color_table.set_conduction_colors(curr_colors); return true; } - - private boolean read_keepout_colors() throws java.io.IOException - { + + private boolean read_keepout_colors() throws java.io.IOException { double intensity = read_color_intensity(); - if (intensity < 0) - { + if (intensity < 0) { return false; } this.board_handling.graphics_context.set_obstacle_color_intensity(intensity); java.awt.Color[] curr_colors = read_color_array(); - if (curr_colors.length < 1) - { + if (curr_colors.length < 1) { return false; } this.board_handling.graphics_context.item_color_table.set_keepout_colors(curr_colors); return true; } - - private boolean read_via_keepout_colors() throws java.io.IOException - { + + private boolean read_via_keepout_colors() throws java.io.IOException { double intensity = read_color_intensity(); - if (intensity < 0) - { + if (intensity < 0) { return false; } this.board_handling.graphics_context.set_via_obstacle_color_intensity(intensity); java.awt.Color[] curr_colors = read_color_array(); - if (curr_colors.length < 1) - { + if (curr_colors.length < 1) { return false; } this.board_handling.graphics_context.item_color_table.set_via_keepout_colors(curr_colors); return true; } - - private boolean read_background_color() throws java.io.IOException - { + + private boolean read_background_color() throws java.io.IOException { java.awt.Color curr_color = read_color(); - if (curr_color == null) - { + if (curr_color == null) { return false; } this.board_handling.graphics_context.other_color_table.set_background_color(curr_color); this.board_frame.set_board_background(curr_color); Object next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_background_color: closing bracket expected"); return false; } return true; } - - private boolean read_hilight_color() throws java.io.IOException - { + + private boolean read_hilight_color() throws java.io.IOException { double intensity = read_color_intensity(); - if (intensity < 0) - { + if (intensity < 0) { return false; } this.board_handling.graphics_context.set_hilight_color_intensity(intensity); java.awt.Color curr_color = read_color(); - if (curr_color == null) - { + if (curr_color == null) { return false; } this.board_handling.graphics_context.other_color_table.set_hilight_color(curr_color); Object next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_higlight_color: closing bracket expected"); return false; } return true; } - - private boolean read_incompletes_color() throws java.io.IOException - { + + private boolean read_incompletes_color() throws java.io.IOException { double intensity = read_color_intensity(); - if (intensity < 0) - { + if (intensity < 0) { return false; } this.board_handling.graphics_context.set_incomplete_color_intensity(intensity); java.awt.Color curr_color = read_color(); - if (curr_color == null) - { + if (curr_color == null) { return false; } this.board_handling.graphics_context.other_color_table.set_incomplete_color(curr_color); Object next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_incompletes_color: closing bracket expected"); return false; } return true; } - - private boolean read_length_matching_color() throws java.io.IOException - { + + private boolean read_length_matching_color() throws java.io.IOException { double intensity = read_color_intensity(); - if (intensity < 0) - { + if (intensity < 0) { return false; } this.board_handling.graphics_context.set_length_matching_area_color_intensity(intensity); java.awt.Color curr_color = read_color(); - if (curr_color == null) - { + if (curr_color == null) { return false; } this.board_handling.graphics_context.other_color_table.set_length_matching_area_color(curr_color); Object next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_length_matching_color: closing bracket expected"); return false; } return true; } - - private boolean read_violations_color() throws java.io.IOException - { + + private boolean read_violations_color() throws java.io.IOException { java.awt.Color curr_color = read_color(); - if (curr_color == null) - { + if (curr_color == null) { return false; } this.board_handling.graphics_context.other_color_table.set_violations_color(curr_color); Object next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_violations_color: closing bracket expected"); return false; } return true; } - - private boolean read_outline_color() throws java.io.IOException - { + + private boolean read_outline_color() throws java.io.IOException { java.awt.Color curr_color = read_color(); - if (curr_color == null) - { + if (curr_color == null) { return false; } this.board_handling.graphics_context.other_color_table.set_outline_color(curr_color); Object next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_outline_color: closing bracket expected"); return false; } return true; } - - private boolean read_component_color(boolean p_front) throws java.io.IOException - { + + private boolean read_component_color(boolean p_front) throws java.io.IOException { java.awt.Color curr_color = read_color(); - if (curr_color == null) - { + if (curr_color == null) { return false; } this.board_handling.graphics_context.other_color_table.set_component_color(curr_color, p_front); Object next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_component_color: closing bracket expected"); return false; } return true; } - - - private double read_color_intensity() throws java.io.IOException - { + + private double read_color_intensity() throws java.io.IOException { double result; Object next_token = this.scanner.next_token(); - if (next_token instanceof Double) - { + if (next_token instanceof Double) { result = (Double) next_token; - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { result = (Integer) next_token; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_color_intensity: Number expected"); result = -1; } return result; } - + /** * reads a java.awt.Color from the defaults file. * Returns null, if no valid color was found. */ - private java.awt.Color read_color() throws java.io.IOException - { - int [] rgb_color_arr = new int [3]; - for (int i = 0; i < 3; ++i) - { + private java.awt.Color read_color() throws java.io.IOException { + int[] rgb_color_arr = new int[3]; + for (int i = 0; i < 3; ++i) { Object next_token = this.scanner.next_token(); - if (!(next_token instanceof Integer)) - { - if (next_token != Keyword.CLOSED_BRACKET) - { + if (!(next_token instanceof Integer)) { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_color: closing bracket expected"); } return null; } - rgb_color_arr[i] = (Integer)next_token; + rgb_color_arr[i] = (Integer) next_token; } - return new java.awt.Color(rgb_color_arr[0], rgb_color_arr[1],rgb_color_arr[2]); + return new java.awt.Color(rgb_color_arr[0], rgb_color_arr[1], rgb_color_arr[2]); } - + /** * reads a n array java.awt.Color from the defaults file. * Returns null, if no valid colors were found. */ - private java.awt.Color[] read_color_array() throws java.io.IOException - { + private java.awt.Color[] read_color_array() throws java.io.IOException { java.util.Collection color_list = new java.util.LinkedList(); - for(;;) - { + for (; ; ) { java.awt.Color curr_color = read_color(); - if (curr_color == null) - { + if (curr_color == null) { break; } color_list.add(curr_color); } java.awt.Color[] result = new java.awt.Color[color_list.size()]; java.util.Iterator it = color_list.iterator(); - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = it.next(); } return result; } - - private void write_colors_scope() throws java.io.IOException - { + + private void write_colors_scope() throws java.io.IOException { net.freerouting.boardgraphics.GraphicsContext graphics_context = this.board_handling.graphics_context; out_file.start_scope(); out_file.write("colors"); @@ -1001,16 +799,14 @@ private void write_colors_scope() throws java.io.IOException out_file.end_scope(); out_file.end_scope(); } - - private void write_color_intensity(double p_value)throws java.io.IOException - { + + private void write_color_intensity(double p_value) throws java.io.IOException { out_file.write(" "); Float value = (float) p_value; out_file.write(value.toString()); } - - private void write_color_scope(java.awt.Color p_color) throws java.io.IOException - { + + private void write_color_scope(java.awt.Color p_color) throws java.io.IOException { out_file.new_line(); Integer red = p_color.getRed(); out_file.write(red.toString()); @@ -1021,130 +817,83 @@ private void write_color_scope(java.awt.Color p_color) throws java.io.IOExceptio Integer blue = p_color.getBlue(); out_file.write(blue.toString()); } - - private void write_color(java.awt.Color[] p_colors) throws java.io.IOException - { - for (int i = 0; i < p_colors.length; ++i) - { + + private void write_color(java.awt.Color[] p_colors) throws java.io.IOException { + for (int i = 0; i < p_colors.length; ++i) { write_color_scope(p_colors[i]); } } - - private boolean read_parameter_scope() throws java.io.IOException - { + + private boolean read_parameter_scope() throws java.io.IOException { // read the subscopes of the parameter scope Object next_token = null; - for (;;) - { + for (; ; ) { Object prev_token = next_token; next_token = this.scanner.next_token(); - if (next_token == null) - { + if (next_token == null) { // unexpected end of file return false; } - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { // end of scope break; } - - if (prev_token == Keyword.OPEN_BRACKET) - { - - if (next_token == Keyword.SELECTION_LAYERS) - { - if (!read_selection_layer_scope()) - { + + if (prev_token == Keyword.OPEN_BRACKET) { + + if (next_token == Keyword.SELECTION_LAYERS) { + if (!read_selection_layer_scope()) { return false; } - } - else if (next_token == Keyword.VIA_SNAP_TO_SMD_CENTER) - { - if (!read_via_snap_to_smd_center_scope()) - { + } else if (next_token == Keyword.VIA_SNAP_TO_SMD_CENTER) { + if (!read_via_snap_to_smd_center_scope()) { return false; } - } - else if (next_token == Keyword.SHOVE_ENABLED) - { - if (!read_shove_enabled_scope()) - { + } else if (next_token == Keyword.SHOVE_ENABLED) { + if (!read_shove_enabled_scope()) { return false; } - } - else if (next_token == Keyword.DRAG_COMPONENTS_ENABLED) - { - if (!read_drag_components_enabled_scope()) - { + } else if (next_token == Keyword.DRAG_COMPONENTS_ENABLED) { + if (!read_drag_components_enabled_scope()) { return false; } - } - else if (next_token == Keyword.ROUTE_MODE) - { - if (!read_route_mode_scope()) - { + } else if (next_token == Keyword.ROUTE_MODE) { + if (!read_route_mode_scope()) { return false; } - } - else if (next_token == Keyword.PULL_TIGHT_REGION) - { - if (!read_pull_tight_region_scope()) - { + } else if (next_token == Keyword.PULL_TIGHT_REGION) { + if (!read_pull_tight_region_scope()) { return false; } - } - else if (next_token == Keyword.PULL_TIGHT_ACCURACY) - { - if (!read_pull_tight_accuracy_scope()) - { + } else if (next_token == Keyword.PULL_TIGHT_ACCURACY) { + if (!read_pull_tight_accuracy_scope()) { return false; } - } - else if (next_token == Keyword.IGNORE_CONDUCTION_AREAS) - { - if (!read_ignore_conduction_scope()) - { + } else if (next_token == Keyword.IGNORE_CONDUCTION_AREAS) { + if (!read_ignore_conduction_scope()) { return false; } - } - else if (next_token == Keyword.AUTOMATIC_LAYER_DIMMING) - { - if (!read_automatic_layer_dimming_scope()) - { + } else if (next_token == Keyword.AUTOMATIC_LAYER_DIMMING) { + if (!read_automatic_layer_dimming_scope()) { return false; } - } - else if (next_token == Keyword.CLEARANCE_COMPENSATION) - { - if (!read_clearance_compensation_scope()) - { + } else if (next_token == Keyword.CLEARANCE_COMPENSATION) { + if (!read_clearance_compensation_scope()) { return false; } - } - else if (next_token == Keyword.HILIGHT_ROUTING_OBSTACLE) - { - if (!read_hilight_routing_obstacle_scope()) - { + } else if (next_token == Keyword.HILIGHT_ROUTING_OBSTACLE) { + if (!read_hilight_routing_obstacle_scope()) { return false; } - } - else if (next_token == Keyword.SELECTABLE_ITEMS) - { - if (!read_selectable_item_scope()) - { + } else if (next_token == Keyword.SELECTABLE_ITEMS) { + if (!read_selectable_item_scope()) { return false; } - } - else if (next_token == Keyword.DESELECTED_SNAPSHOT_ATTRIBUTES) - { - if (!read_deselected_snapshot_attributes()) - { + } else if (next_token == Keyword.DESELECTED_SNAPSHOT_ATTRIBUTES) { + if (!read_deselected_snapshot_attributes()) { return false; } - } - else - { + } else { // skip unknown scope skip_scope(this.scanner); } @@ -1152,9 +901,8 @@ else if (next_token == Keyword.DESELECTED_SNAPSHOT_ATTRIBUTES) } return true; } - - private void write_parameter_scope() throws java.io.IOException - { + + private void write_parameter_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("parameter"); write_selection_layer_scope(); @@ -1172,243 +920,184 @@ private void write_parameter_scope() throws java.io.IOException write_deselected_snapshot_attributes(); out_file.end_scope(); } - - private boolean read_selection_layer_scope() throws java.io.IOException - { + + private boolean read_selection_layer_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); boolean select_on_all_layers; - if (next_token == Keyword.ALL_VISIBLE) - { + if (next_token == Keyword.ALL_VISIBLE) { select_on_all_layers = true; - } - else if (next_token == Keyword.CURRENT_ONLY) - { + } else if (next_token == Keyword.CURRENT_ONLY) { select_on_all_layers = false; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_selection_layer_scope: unexpected token"); return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_selection_layer_scop: closing bracket expected"); return false; } this.board_handling.settings.set_select_on_all_visible_layers(select_on_all_layers); return true; } - - private boolean read_shove_enabled_scope() throws java.io.IOException - { + + private boolean read_shove_enabled_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); boolean shove_enabled; - if (next_token == Keyword.ON) - { + if (next_token == Keyword.ON) { shove_enabled = true; - } - else if (next_token == Keyword.OFF) - { + } else if (next_token == Keyword.OFF) { shove_enabled = false; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_shove_enabled_scope: unexpected token"); return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_shove_enabled_scope: closing bracket expected"); return false; } this.board_handling.settings.set_push_enabled(shove_enabled); return true; } - - private boolean read_drag_components_enabled_scope() throws java.io.IOException - { + + private boolean read_drag_components_enabled_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); boolean drag_components_enabled; - if (next_token == Keyword.ON) - { + if (next_token == Keyword.ON) { drag_components_enabled = true; - } - else if (next_token == Keyword.OFF) - { + } else if (next_token == Keyword.OFF) { drag_components_enabled = false; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_drag_components_enabled_scope: unexpected token"); return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_drag_components_enabled_scope: closing bracket expected"); return false; } this.board_handling.settings.set_drag_components_enabled(drag_components_enabled); return true; } - - private boolean read_ignore_conduction_scope() throws java.io.IOException - { + + private boolean read_ignore_conduction_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); boolean ignore_conduction; - if (next_token == Keyword.ON) - { + if (next_token == Keyword.ON) { ignore_conduction = true; - } - else if (next_token == Keyword.OFF) - { + } else if (next_token == Keyword.OFF) { ignore_conduction = false; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_ignore_conduction_scope: unexpected token"); return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_ignore_conduction_scope: closing bracket expected"); return false; } this.board_handling.set_ignore_conduction(ignore_conduction); return true; } - - private void write_shove_enabled_scope() throws java.io.IOException - { + + private void write_shove_enabled_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("shove_enabled "); out_file.new_line(); - if (this.board_handling.settings.get_push_enabled()) - { + if (this.board_handling.settings.get_push_enabled()) { out_file.write("on"); - } - else - { + } else { out_file.write("off"); } out_file.end_scope(); } - - private void write_drag_components_enabled_scope() throws java.io.IOException - { + + private void write_drag_components_enabled_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("drag_components_enabled "); out_file.new_line(); - if (this.board_handling.settings.get_drag_components_enabled()) - { + if (this.board_handling.settings.get_drag_components_enabled()) { out_file.write("on"); - } - else - { + } else { out_file.write("off"); } out_file.end_scope(); } - - private void write_ignore_conduction_scope() throws java.io.IOException - { + + private void write_ignore_conduction_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("ignore_conduction_areas "); out_file.new_line(); - if (this.board_handling.get_routing_board().rules.get_ignore_conduction()) - { + if (this.board_handling.get_routing_board().rules.get_ignore_conduction()) { out_file.write("on"); - } - else - { + } else { out_file.write("off"); } out_file.end_scope(); } - - private void write_selection_layer_scope() throws java.io.IOException - { + + private void write_selection_layer_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("selection_layers "); out_file.new_line(); - if (this.board_handling.settings.get_select_on_all_visible_layers()) - { + if (this.board_handling.settings.get_select_on_all_visible_layers()) { out_file.write("all_visible"); - } - else - { + } else { out_file.write("current_only"); } out_file.end_scope(); } - - private boolean read_route_mode_scope() throws java.io.IOException - { + + private boolean read_route_mode_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); boolean is_stitch_mode; - if (next_token == Keyword.STITCHING) - { + if (next_token == Keyword.STITCHING) { is_stitch_mode = true; - } - else if (next_token == Keyword.DYNAMIC) - { + } else if (next_token == Keyword.DYNAMIC) { is_stitch_mode = false; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_roude_mode_scope: unexpected token"); return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_selection_layer_scope: closing bracket expected"); return false; } this.board_handling.settings.set_stitch_route(is_stitch_mode); return true; } - - private void write_route_mode_scope() throws java.io.IOException - { + + private void write_route_mode_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("route_mode "); out_file.new_line(); - if (this.board_handling.settings.get_is_stitch_route()) - { + if (this.board_handling.settings.get_is_stitch_route()) { out_file.write("stitching"); - } - else - { + } else { out_file.write("dynamic"); } out_file.end_scope(); } - - private boolean read_pull_tight_region_scope() throws java.io.IOException - { + + private boolean read_pull_tight_region_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); - if (!(next_token instanceof Integer) ) - { + if (!(next_token instanceof Integer)) { System.out.println("GUIDefaultsFile.read_pull_tight_region_scope: Integer expected"); return false; } int pull_tight_region = (Integer) next_token; next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_pull_tight_region_scope: closing bracket expected"); return false; } this.board_handling.settings.set_current_pull_tight_region_width(pull_tight_region); return true; } - - private void write_pull_tight_region_scope() throws java.io.IOException - { + + private void write_pull_tight_region_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("pull_tight_region "); out_file.new_line(); @@ -1416,28 +1105,24 @@ private void write_pull_tight_region_scope() throws java.io.IOException out_file.write(pull_tight_region.toString()); out_file.end_scope(); } - - private boolean read_pull_tight_accuracy_scope() throws java.io.IOException - { + + private boolean read_pull_tight_accuracy_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); - if (!(next_token instanceof Integer) ) - { + if (!(next_token instanceof Integer)) { System.out.println("GUIDefaultsFile.read_pull_tight_accuracy_scope: Integer expected"); return false; } int pull_tight_accuracy = (Integer) next_token; next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_pull_tight_accuracy_scope: closing bracket expected"); return false; } this.board_handling.settings.set_current_pull_tight_accuracy(pull_tight_accuracy); return true; } - - private void write_pull_tight_accuracy_scope() throws java.io.IOException - { + + private void write_pull_tight_accuracy_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("pull_tight_accuracy "); out_file.new_line(); @@ -1445,36 +1130,28 @@ private void write_pull_tight_accuracy_scope() throws java.io.IOException out_file.write(pull_tight_accuracy.toString()); out_file.end_scope(); } - - private boolean read_automatic_layer_dimming_scope() throws java.io.IOException - { + + private boolean read_automatic_layer_dimming_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); double intensity; - if (next_token instanceof Double) - { + if (next_token instanceof Double) { intensity = (Double) next_token; - } - else if (next_token instanceof Integer) - { + } else if (next_token instanceof Integer) { intensity = (Integer) next_token; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_automatic_layer_dimming_scope: Integer expected"); return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_automatic_layer_dimming_scope: closing bracket expected"); return false; } this.board_handling.graphics_context.set_auto_layer_dim_factor(intensity); return true; } - - private void write_automatic_layer_dimming_scope() throws java.io.IOException - { + + private void write_automatic_layer_dimming_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("automatic_layer_dimming "); out_file.new_line(); @@ -1482,407 +1159,274 @@ private void write_automatic_layer_dimming_scope() throws java.io.IOException out_file.write(layer_dimming.toString()); out_file.end_scope(); } - - private boolean read_hilight_routing_obstacle_scope() throws java.io.IOException - { + + private boolean read_hilight_routing_obstacle_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); boolean hilight_obstacle; - if (next_token == Keyword.ON) - { + if (next_token == Keyword.ON) { hilight_obstacle = true; - } - else if (next_token == Keyword.OFF) - { + } else if (next_token == Keyword.OFF) { hilight_obstacle = false; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_hilight_routing_obstacle_scope: unexpected token"); return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_hilight_routing_obstacle_scope: closing bracket expected"); return false; } this.board_handling.settings.set_hilight_routing_obstacle(hilight_obstacle); return true; } - - - private void write_hilight_routing_obstacle_scope() throws java.io.IOException - { + + private void write_hilight_routing_obstacle_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("hilight_routing_obstacle "); out_file.new_line(); - if (this.board_handling.settings.get_hilight_routing_obstacle()) - { + if (this.board_handling.settings.get_hilight_routing_obstacle()) { out_file.write("on"); - } - else - { + } else { out_file.write("off"); } out_file.end_scope(); } - - private boolean read_clearance_compensation_scope() throws java.io.IOException - { + + private boolean read_clearance_compensation_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); boolean clearance_compensation; - if (next_token == Keyword.ON) - { + if (next_token == Keyword.ON) { clearance_compensation = true; - } - else if (next_token == Keyword.OFF) - { + } else if (next_token == Keyword.OFF) { clearance_compensation = false; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_clearance_compensation_scope: unexpected token"); return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_clearance_compensation_scope: closing bracket expected"); return false; } this.board_handling.set_clearance_compensation(clearance_compensation); return true; } - - private void write_clearance_compensation_scope() throws java.io.IOException - { + + private void write_clearance_compensation_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("clearance_compensation "); out_file.new_line(); - if (this.board_handling.get_routing_board().search_tree_manager.is_clearance_compensation_used()) - { + if (this.board_handling.get_routing_board().search_tree_manager.is_clearance_compensation_used()) { out_file.write("on"); - } - else - { + } else { out_file.write("off"); } out_file.end_scope(); } - - private boolean read_via_snap_to_smd_center_scope() throws java.io.IOException - { + + private boolean read_via_snap_to_smd_center_scope() throws java.io.IOException { Object next_token = this.scanner.next_token(); boolean snap; - if (next_token == Keyword.ON) - { + if (next_token == Keyword.ON) { snap = true; - } - else if (next_token == Keyword.OFF) - { + } else if (next_token == Keyword.OFF) { snap = false; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_via_snap_to_smd_center_scope: unexpected token"); return false; } next_token = this.scanner.next_token(); - if (next_token != Keyword.CLOSED_BRACKET) - { + if (next_token != Keyword.CLOSED_BRACKET) { System.out.println("GUIDefaultsFile.read_via_snap_to_smd_center_scope: closing bracket expected"); return false; } this.board_handling.settings.set_via_snap_to_smd_center(snap); return true; } - - private void write_via_snap_to_smd_center_scope() throws java.io.IOException - { + + private void write_via_snap_to_smd_center_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("via_snap_to_smd_center "); out_file.new_line(); - if (this.board_handling.settings.get_via_snap_to_smd_center()) - { + if (this.board_handling.settings.get_via_snap_to_smd_center()) { out_file.write("on"); - } - else - { + } else { out_file.write("off"); } out_file.end_scope(); } - - private boolean read_selectable_item_scope() throws java.io.IOException - { + + private boolean read_selectable_item_scope() throws java.io.IOException { ItemSelectionFilter item_selection_filter = this.board_handling.settings.get_item_selection_filter(); item_selection_filter.deselect_all(); - for (;;) - { + for (; ; ) { Object next_token = this.scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (next_token == Keyword.TRACES) - { + if (next_token == Keyword.TRACES) { item_selection_filter.set_selected(ItemSelectionFilter.SelectableChoices.TRACES, true); - } - else if (next_token == Keyword.VIAS) - { + } else if (next_token == Keyword.VIAS) { item_selection_filter.set_selected(ItemSelectionFilter.SelectableChoices.VIAS, true); - } - else if (next_token == Keyword.PINS) - { + } else if (next_token == Keyword.PINS) { item_selection_filter.set_selected(ItemSelectionFilter.SelectableChoices.PINS, true); - } - else if (next_token == Keyword.CONDUCTION) - { + } else if (next_token == Keyword.CONDUCTION) { item_selection_filter.set_selected(ItemSelectionFilter.SelectableChoices.CONDUCTION, true); - } - else if (next_token == Keyword.KEEPOUT) - { + } else if (next_token == Keyword.KEEPOUT) { item_selection_filter.set_selected(ItemSelectionFilter.SelectableChoices.KEEPOUT, true); - } - else if (next_token == Keyword.VIA_KEEPOUT) - { + } else if (next_token == Keyword.VIA_KEEPOUT) { item_selection_filter.set_selected(ItemSelectionFilter.SelectableChoices.VIA_KEEPOUT, true); - } - else if (next_token == Keyword.FIXED) - { + } else if (next_token == Keyword.FIXED) { item_selection_filter.set_selected(ItemSelectionFilter.SelectableChoices.FIXED, true); - } - else if (next_token == Keyword.UNFIXED) - { + } else if (next_token == Keyword.UNFIXED) { item_selection_filter.set_selected(ItemSelectionFilter.SelectableChoices.UNFIXED, true); - } - else if (next_token == Keyword.VIAS) - { + } else if (next_token == Keyword.VIAS) { item_selection_filter.set_selected(ItemSelectionFilter.SelectableChoices.VIAS, true); - } - else - { + } else { System.out.println("GUIDefaultsFile.read_selectable_item_scope: unexpected token"); return false; } } return true; } - - - private void write_selectable_item_scope() throws java.io.IOException - { + + private void write_selectable_item_scope() throws java.io.IOException { out_file.start_scope(); out_file.write("selectable_items "); out_file.new_line(); ItemSelectionFilter item_selection_filter = this.board_handling.settings.get_item_selection_filter(); - ItemSelectionFilter.SelectableChoices [] selectable_choices + ItemSelectionFilter.SelectableChoices[] selectable_choices = ItemSelectionFilter.SelectableChoices.values(); - for (int i = 0; i < selectable_choices.length; ++i) - { - if (item_selection_filter.is_selected(selectable_choices[i])) - { + for (int i = 0; i < selectable_choices.length; ++i) { + if (item_selection_filter.is_selected(selectable_choices[i])) { out_file.write(selectable_choices[i].toString()); out_file.write(" "); } } out_file.end_scope(); } - - private void write_deselected_snapshot_attributes() throws java.io.IOException - { + + private void write_deselected_snapshot_attributes() throws java.io.IOException { net.freerouting.interactive.SnapShot.Attributes attributes = this.board_handling.settings.get_snapshot_attributes(); out_file.start_scope(); out_file.write("deselected_snapshot_attributes "); - if (!attributes.object_colors) - { + if (!attributes.object_colors) { out_file.new_line(); out_file.write("object_colors "); } - if (!attributes.object_visibility) - { + if (!attributes.object_visibility) { out_file.new_line(); out_file.write("object_visibility "); } - if (!attributes.layer_visibility) - { + if (!attributes.layer_visibility) { out_file.new_line(); out_file.write("layer_visibility "); } - if (!attributes.display_region) - { + if (!attributes.display_region) { out_file.new_line(); out_file.write("display_region "); } - if (!attributes.interactive_state) - { + if (!attributes.interactive_state) { out_file.new_line(); out_file.write("interactive_state "); } - if (!attributes.selection_layers) - { + if (!attributes.selection_layers) { out_file.new_line(); out_file.write("selection_layers "); } - if (!attributes.selectable_items) - { + if (!attributes.selectable_items) { out_file.new_line(); out_file.write("selectable_items "); } - if (!attributes.current_layer) - { + if (!attributes.current_layer) { out_file.new_line(); out_file.write("current_layer "); } - if (!attributes.rule_selection) - { + if (!attributes.rule_selection) { out_file.new_line(); out_file.write("rule_selection "); } - if (!attributes.manual_rule_settings) - { + if (!attributes.manual_rule_settings) { out_file.new_line(); out_file.write("manual_rule_settings "); } - if (!attributes.push_and_shove_enabled) - { + if (!attributes.push_and_shove_enabled) { out_file.new_line(); out_file.write("push_and_shove_enabled "); } - if (!attributes.drag_components_enabled) - { + if (!attributes.drag_components_enabled) { out_file.new_line(); out_file.write("drag_components_enabled "); } - if (!attributes.pull_tight_region) - { + if (!attributes.pull_tight_region) { out_file.new_line(); out_file.write("pull_tight_region "); } - if (!attributes.component_grid) - { + if (!attributes.component_grid) { out_file.new_line(); out_file.write("component_grid "); } out_file.end_scope(); } - - private boolean read_deselected_snapshot_attributes() throws java.io.IOException - { + + private boolean read_deselected_snapshot_attributes() throws java.io.IOException { net.freerouting.interactive.SnapShot.Attributes attributes = this.board_handling.settings.get_snapshot_attributes(); - for (;;) - { + for (; ; ) { Object next_token = this.scanner.next_token(); - if (next_token == Keyword.CLOSED_BRACKET) - { + if (next_token == Keyword.CLOSED_BRACKET) { break; } - if (next_token == Keyword.OBJECT_COLORS) - { + if (next_token == Keyword.OBJECT_COLORS) { attributes.object_colors = false; - } - else if (next_token == Keyword.OBJECT_VISIBILITY) - { + } else if (next_token == Keyword.OBJECT_VISIBILITY) { attributes.object_visibility = false; - } - else if (next_token == Keyword.LAYER_VISIBILITY) - { + } else if (next_token == Keyword.LAYER_VISIBILITY) { attributes.layer_visibility = false; - } - else if (next_token == Keyword.DISPLAY_REGION) - { + } else if (next_token == Keyword.DISPLAY_REGION) { attributes.display_region = false; - } - else if (next_token == Keyword.INTERACTIVE_STATE) - { + } else if (next_token == Keyword.INTERACTIVE_STATE) { attributes.interactive_state = false; - } - else if (next_token == Keyword.SELECTION_LAYERS) - { + } else if (next_token == Keyword.SELECTION_LAYERS) { attributes.selection_layers = false; - } - else if (next_token == Keyword.SELECTABLE_ITEMS) - { + } else if (next_token == Keyword.SELECTABLE_ITEMS) { attributes.selectable_items = false; - } - else if (next_token == Keyword.CURRENT_LAYER) - { + } else if (next_token == Keyword.CURRENT_LAYER) { attributes.current_layer = false; - } - else if (next_token == Keyword.RULE_SELECTION) - { + } else if (next_token == Keyword.RULE_SELECTION) { attributes.rule_selection = false; - } - else if (next_token == Keyword.MANUAL_RULE_SETTINGS) - { + } else if (next_token == Keyword.MANUAL_RULE_SETTINGS) { attributes.manual_rule_settings = false; - } - else if (next_token == Keyword.PUSH_AND_SHOVE_ENABLED) - { + } else if (next_token == Keyword.PUSH_AND_SHOVE_ENABLED) { attributes.push_and_shove_enabled = false; - } - else if (next_token == Keyword.DRAG_COMPONENTS_ENABLED) - { + } else if (next_token == Keyword.DRAG_COMPONENTS_ENABLED) { attributes.drag_components_enabled = false; - } - else if (next_token == Keyword.PULL_TIGHT_REGION) - { + } else if (next_token == Keyword.PULL_TIGHT_REGION) { attributes.pull_tight_region = false; - } - else if (next_token == Keyword.COMPONENT_GRID) - { + } else if (next_token == Keyword.COMPONENT_GRID) { attributes.component_grid = false; - } - else - { + } else { System.out.println("GUIDefaultsFile.read_deselected_snapshot_attributes: unexpected token"); return false; } } return true; } - /** - * Skips the current scope. - * Returns false, if no legal scope was found. + * Keywords in the gui defaults file. */ - private static boolean skip_scope(GUIDefaultsScanner p_scanner) - { - int open_bracked_count = 1; - while (open_bracked_count > 0) - { - Object curr_token = null; - try - { - curr_token = p_scanner.next_token(); - } - catch (Exception e) - { - System.out.println("GUIDefaultsFile.skip_scope: Error while scanning file"); - System.out.println(e); - return false; - } - if (curr_token == null) - { - return false; // end of file - } - if (curr_token == Keyword.OPEN_BRACKET) - { - ++open_bracked_count; - } - else if (curr_token == Keyword.CLOSED_BRACKET) - { - --open_bracked_count; - } - } - System.out.println("GUIDefaultsFile.skip_spope: unknown scope skipped"); - return true; + enum Keyword { + ALL_VISIBLE, ASSIGN_NET_RULES, AUTOMATIC_LAYER_DIMMING, BACKGROUND, BOARD_FRAME, BOUNDS, + CLEARANCE_COMPENSATION, CLEARANCE_MATRIX, CLOSED_BRACKET, COLOR_MANAGER, COLORS, + COMPONENT_BACK, COMPONENT_FRONT, COMPONENT_GRID, COMPONENT_INFO, CONDUCTION, CURRENT_LAYER, + CURRENT_ONLY, DESELECTED_SNAPSHOT_ATTRIBUTES, DISPLAY_MISCELLANIOUS, DISPLAY_REGION, + DRAG_COMPONENTS_ENABLED, DYNAMIC, EDIT_VIAS, EDIT_NET_RULES, FIXED, FIXED_TRACES, FIXED_VIAS, + FORTYFIVE_DEGREE, GUI_DEFAULTS, HILIGHT, HILIGHT_ROUTING_OBSTACLE, IGNORE_CONDUCTION_AREAS, INCOMPLETES, INCOMPLETES_INFO, + INTERACTIVE_STATE, KEEPOUT, LAYER_VISIBILITY, LENGTH_MATCHING, MANUAL_RULES, MANUAL_RULE_SETTINGS, + MOVE_PARAMETER, NET_INFO, NINETY_DEGREE, NONE, NOT_VISIBLE, OBJECT_COLORS, OBJECT_VISIBILITY, + OPEN_BRACKET, OFF, ON, OUTLINE, PARAMETER, PACKAGE_INFO, PADSTACK_INFO, PINS, PULL_TIGHT_ACCURACY, + PULL_TIGHT_REGION, PUSH_AND_SHOVE_ENABLED, ROUTE_DETAILS, ROUTE_MODE, ROUTE_PARAMETER, + RULE_SELECTION, SELECT_PARAMETER, SELECTABLE_ITEMS, SELECTION_LAYERS, SNAPSHOTS, + SHOVE_ENABLED, STITCHING, TRACES, UNFIXED, VIA_KEEPOUT, VISIBLE, VIA_RULES, VIA_SNAP_TO_SMD_CENTER, + VIAS, VIOLATIONS, VIOLATIONS_INFO, WINDOWS } - - private final net.freerouting.gui.BoardFrame board_frame; - private final net.freerouting.interactive.BoardHandling board_handling; - /** Used, when reading a defaults file, null otherwise. */ - private final GUIDefaultsScanner scanner; - /** Used, when writing a defaults file; null otherwise. */ - private final IndentFileWriter out_file; } diff --git a/src/main/java/net/freerouting/gui/GUIDefaultsScanner.java b/src/main/java/net/freerouting/gui/GUIDefaultsScanner.java index 1eea23ba..f9d86b60 100644 --- a/src/main/java/net/freerouting/gui/GUIDefaultsScanner.java +++ b/src/main/java/net/freerouting/gui/GUIDefaultsScanner.java @@ -1,6 +1,7 @@ /* The following code was generated by JFlex 1.4 on 16.03.07 09:07 */ package net.freerouting.gui; + @SuppressWarnings("all") /** @@ -11,1673 +12,1750 @@ */ class GUIDefaultsScanner { - /** This character denotes the end of file */ - public static final int YYEOF = -1; - - /** initial size of the lookahead buffer */ - private static final int ZZ_BUFFERSIZE = 16384; - - /** lexical states */ - public static final int YYINITIAL = 0; - - /** - * Translates characters to character classes - */ - private static final String ZZ_CMAP_PACKED = - "\11\0\1\3\1\2\1\0\1\3\1\1\22\0\1\3\2\0\1\6"+ - "\4\0\1\45\1\46\1\5\1\11\1\0\1\11\1\13\1\4\1\12"+ - "\11\10\7\0\1\16\1\23\1\33\1\35\1\14\1\37\1\24\1\42"+ - "\1\21\1\43\1\36\1\17\1\32\1\25\1\31\1\40\1\7\1\27"+ - "\1\22\1\26\1\30\1\20\1\44\1\41\1\34\1\7\4\0\1\15"+ - "\1\0\1\16\1\23\1\33\1\35\1\14\1\37\1\24\1\42\1\21"+ - "\1\43\1\36\1\17\1\32\1\25\1\31\1\40\1\7\1\27\1\22"+ - "\1\26\1\30\1\20\1\44\1\41\1\34\1\7\uff85\0"; - - /** - * Translates characters to character classes - */ - private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); - - /** - * Translates DFA states to action switch labels. - */ - private static final int [] ZZ_ACTION = zzUnpackAction(); - - private static final String ZZ_ACTION_PACKED_0 = - "\1\0\1\1\2\2\2\1\1\3\1\4\1\1\1\4"+ - "\25\3\1\5\1\6\4\0\1\7\30\3\1\10\23\3"+ - "\2\0\2\7\1\0\1\7\36\3\1\11\26\3\1\0"+ - "\7\3\1\12\17\3\1\13\30\3\1\14\57\3\1\15"+ - "\35\3\1\16\4\3\1\17\12\3\1\20\32\3\1\21"+ - "\24\3\1\22\1\3\1\23\12\3\1\24\1\25\10\3"+ - "\1\26\1\27\27\3\1\30\33\3\1\31\7\3\1\32"+ - "\10\3\1\33\1\34\33\3\1\35\15\3\1\36\7\3"+ - "\1\37\5\3\1\40\12\3\1\41\5\3\1\42\10\3"+ - "\1\43\5\3\1\44\3\3\1\45\4\3\1\46\2\3"+ - "\1\47\51\3\1\50\7\3\1\51\4\3\1\52\11\3"+ - "\1\53\1\3\1\54\22\3\1\55\1\56\1\3\1\57"+ - "\2\3\1\60\4\3\1\61\1\62\11\3\1\63\4\3"+ - "\1\64\14\3\1\65\3\3\1\66\2\3\1\67\1\70"+ - "\1\71\2\3\1\72\11\3\1\73\2\3\1\74\6\3"+ - "\1\75\4\3\1\76\10\3\1\77\1\3\1\100\3\3"+ - "\1\101\1\102\1\103\1\104\2\3\1\105\4\3\1\106"+ - "\7\3\1\107\1\110\6\3\1\111\25\3\1\112\5\3"+ - "\1\113\13\3\1\114\4\3\1\115\1\3\1\116\2\3"+ - "\1\117\1\3\1\120\1\121\1\3\1\122\2\3\1\123"+ - "\5\3\1\124"; - - private static int [] zzUnpackAction() { - int [] result = new int[796]; - int offset = 0; - offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAction(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); + /** + * This character denotes the end of file + */ + public static final int YYEOF = -1; + /** + * lexical states + */ + public static final int YYINITIAL = 0; + /** + * initial size of the lookahead buffer + */ + private static final int ZZ_BUFFERSIZE = 16384; + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\0\1\3\1\2\1\0\1\3\1\1\22\0\1\3\2\0\1\6" + + "\4\0\1\45\1\46\1\5\1\11\1\0\1\11\1\13\1\4\1\12" + + "\11\10\7\0\1\16\1\23\1\33\1\35\1\14\1\37\1\24\1\42" + + "\1\21\1\43\1\36\1\17\1\32\1\25\1\31\1\40\1\7\1\27" + + "\1\22\1\26\1\30\1\20\1\44\1\41\1\34\1\7\4\0\1\15" + + "\1\0\1\16\1\23\1\33\1\35\1\14\1\37\1\24\1\42\1\21" + + "\1\43\1\36\1\17\1\32\1\25\1\31\1\40\1\7\1\27\1\22" + + "\1\26\1\30\1\20\1\44\1\41\1\34\1\7\uff85\0"; + + /** + * Translates characters to character classes + */ + private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + private static final String ZZ_ACTION_PACKED_0 = + "\1\0\1\1\2\2\2\1\1\3\1\4\1\1\1\4" + + "\25\3\1\5\1\6\4\0\1\7\30\3\1\10\23\3" + + "\2\0\2\7\1\0\1\7\36\3\1\11\26\3\1\0" + + "\7\3\1\12\17\3\1\13\30\3\1\14\57\3\1\15" + + "\35\3\1\16\4\3\1\17\12\3\1\20\32\3\1\21" + + "\24\3\1\22\1\3\1\23\12\3\1\24\1\25\10\3" + + "\1\26\1\27\27\3\1\30\33\3\1\31\7\3\1\32" + + "\10\3\1\33\1\34\33\3\1\35\15\3\1\36\7\3" + + "\1\37\5\3\1\40\12\3\1\41\5\3\1\42\10\3" + + "\1\43\5\3\1\44\3\3\1\45\4\3\1\46\2\3" + + "\1\47\51\3\1\50\7\3\1\51\4\3\1\52\11\3" + + "\1\53\1\3\1\54\22\3\1\55\1\56\1\3\1\57" + + "\2\3\1\60\4\3\1\61\1\62\11\3\1\63\4\3" + + "\1\64\14\3\1\65\3\3\1\66\2\3\1\67\1\70" + + "\1\71\2\3\1\72\11\3\1\73\2\3\1\74\6\3" + + "\1\75\4\3\1\76\10\3\1\77\1\3\1\100\3\3" + + "\1\101\1\102\1\103\1\104\2\3\1\105\4\3\1\106" + + "\7\3\1\107\1\110\6\3\1\111\25\3\1\112\5\3" + + "\1\113\13\3\1\114\4\3\1\115\1\3\1\116\2\3" + + "\1\117\1\3\1\120\1\121\1\3\1\122\2\3\1\123" + + "\5\3\1\124"; + /** + * Translates DFA states to action switch labels. + */ + private static final int[] ZZ_ACTION = zzUnpackAction(); + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\47\0\116\0\47\0\165\0\234\0\303\0\352" + + "\0\u0111\0\u0138\0\u015f\0\u0186\0\u01ad\0\u01d4\0\u01fb\0\u0222" + + "\0\u0249\0\u0270\0\u0297\0\u02be\0\u02e5\0\u030c\0\u0333\0\u035a" + + "\0\u0381\0\u03a8\0\u03cf\0\u03f6\0\u041d\0\u0444\0\u046b\0\47" + + "\0\47\0\u0492\0\234\0\u04b9\0\u04e0\0\u0138\0\u0507\0\u052e" + + "\0\u0555\0\u057c\0\u05a3\0\u05ca\0\u05f1\0\u0618\0\u063f\0\u0666" + + "\0\u068d\0\u06b4\0\u06db\0\u0702\0\u0729\0\u0750\0\u0777\0\u079e" + + "\0\u07c5\0\u07ec\0\u0813\0\u083a\0\u0861\0\u0888\0\303\0\u08af" + + "\0\u08d6\0\u08fd\0\u0924\0\u094b\0\u0972\0\u0999\0\u09c0\0\u09e7" + + "\0\u0a0e\0\u0a35\0\u0a5c\0\u0a83\0\u0aaa\0\u0ad1\0\u0af8\0\u0b1f" + + "\0\u0b46\0\u0b6d\0\u0b94\0\u0bbb\0\u0be2\0\u0c09\0\u0c30\0\47" + + "\0\u0c57\0\u0c7e\0\u0ca5\0\u0ccc\0\u0cf3\0\u0d1a\0\u0d41\0\u0d68" + + "\0\u0d8f\0\u0db6\0\u0ddd\0\u0e04\0\u0e2b\0\u0e52\0\u0e79\0\u0ea0" + + "\0\u0ec7\0\u0eee\0\u0f15\0\u0f3c\0\u0f63\0\u0f8a\0\u0fb1\0\u0fd8" + + "\0\u0fff\0\u1026\0\u104d\0\u1074\0\u109b\0\u10c2\0\303\0\u10e9" + + "\0\u1110\0\u1137\0\u115e\0\u1185\0\u11ac\0\u11d3\0\u11fa\0\u1221" + + "\0\u1248\0\u126f\0\u1296\0\u12bd\0\u12e4\0\u130b\0\u1332\0\u1359" + + "\0\u1380\0\u13a7\0\u13ce\0\u13f5\0\u141c\0\u1443\0\u146a\0\u1491" + + "\0\u14b8\0\u14df\0\u1506\0\u152d\0\u1554\0\303\0\u157b\0\u15a2" + + "\0\u15c9\0\u15f0\0\u1617\0\u163e\0\u1665\0\u168c\0\u16b3\0\u16da" + + "\0\u1701\0\u1728\0\u174f\0\u1776\0\u179d\0\303\0\u17c4\0\u17eb" + + "\0\u1812\0\u1839\0\u1860\0\u1887\0\u18ae\0\u18d5\0\u18fc\0\u1923" + + "\0\u194a\0\u1971\0\u1998\0\u19bf\0\u19e6\0\u1a0d\0\u1a34\0\u1a5b" + + "\0\u1a82\0\u1aa9\0\u1ad0\0\u1af7\0\u1b1e\0\u1b45\0\303\0\u1b6c" + + "\0\u1b93\0\u1bba\0\u1be1\0\u1c08\0\u1c2f\0\u1c56\0\u1c7d\0\u1ca4" + + "\0\u1ccb\0\u1cf2\0\u1d19\0\u1d40\0\u1d67\0\u1d8e\0\u1db5\0\u1ddc" + + "\0\u1e03\0\u1e2a\0\u1e51\0\u1e78\0\u1e9f\0\u1ec6\0\u1eed\0\u1f14" + + "\0\u1f3b\0\u1f62\0\u1f89\0\u1fb0\0\u1fd7\0\u1ffe\0\u2025\0\u204c" + + "\0\u2073\0\u209a\0\u20c1\0\u20e8\0\u210f\0\u2136\0\u215d\0\u2184" + + "\0\u21ab\0\u21d2\0\u21f9\0\u2220\0\u2247\0\u226e\0\u2295\0\u22bc" + + "\0\u22e3\0\u230a\0\u2331\0\u2358\0\u237f\0\u23a6\0\u23cd\0\u23f4" + + "\0\u241b\0\u2442\0\u2469\0\u2490\0\u24b7\0\u24de\0\u2505\0\u252c" + + "\0\u2553\0\u257a\0\u25a1\0\u25c8\0\u25ef\0\u2616\0\u263d\0\u2664" + + "\0\u268b\0\u26b2\0\u26d9\0\u2700\0\303\0\u2727\0\u274e\0\u2775" + + "\0\u279c\0\303\0\u27c3\0\u27ea\0\u2811\0\u2838\0\u285f\0\u2886" + + "\0\u28ad\0\u28d4\0\u28fb\0\u2922\0\303\0\u2949\0\u2970\0\u2997" + + "\0\u29be\0\u29e5\0\u2a0c\0\u2a33\0\u2a5a\0\u2a81\0\u2aa8\0\u2acf" + + "\0\u2af6\0\u2b1d\0\u2b44\0\u2b6b\0\u2b92\0\u2bb9\0\u2be0\0\u2c07" + + "\0\u2c2e\0\u2c55\0\u2c7c\0\u2ca3\0\u2cca\0\u2cf1\0\u2d18\0\303" + + "\0\u2d3f\0\u2d66\0\u2d8d\0\u2db4\0\u2ddb\0\u2e02\0\u2e29\0\u2e50" + + "\0\u2e77\0\u2e9e\0\u2ec5\0\u2eec\0\u2f13\0\u2f3a\0\u2f61\0\u2f88" + + "\0\u2faf\0\u2fd6\0\u2ffd\0\u3024\0\303\0\u304b\0\303\0\u3072" + + "\0\u3099\0\u30c0\0\u30e7\0\u310e\0\u3135\0\u315c\0\u3183\0\u31aa" + + "\0\u31d1\0\303\0\303\0\u31f8\0\u321f\0\u3246\0\u326d\0\u3294" + + "\0\u32bb\0\u32e2\0\u3309\0\u3330\0\303\0\u3357\0\u337e\0\u33a5" + + "\0\u33cc\0\u33f3\0\u341a\0\u3441\0\u3468\0\u348f\0\u34b6\0\u34dd" + + "\0\u3504\0\u352b\0\u3552\0\u3579\0\u35a0\0\u35c7\0\u35ee\0\u3615" + + "\0\u363c\0\u3663\0\u368a\0\u36b1\0\303\0\u36d8\0\u36ff\0\u3726" + + "\0\u374d\0\u3774\0\u379b\0\u37c2\0\u37e9\0\u3810\0\u3837\0\u385e" + + "\0\u3885\0\u38ac\0\u38d3\0\u38fa\0\u3921\0\u3948\0\u396f\0\u3996" + + "\0\u39bd\0\u39e4\0\u3a0b\0\u3a32\0\u3a59\0\u3a80\0\u3aa7\0\u3ace" + + "\0\303\0\u3af5\0\u3b1c\0\u3b43\0\u3b6a\0\u3b91\0\u3bb8\0\u3bdf" + + "\0\303\0\u3c06\0\u3c2d\0\u3c54\0\u3c7b\0\u3ca2\0\u3cc9\0\u3cf0" + + "\0\u3d17\0\303\0\303\0\u3d3e\0\u3d65\0\u3d8c\0\u3db3\0\u3dda" + + "\0\u3e01\0\u3e28\0\u3e4f\0\u3e76\0\u3e9d\0\u3ec4\0\u3eeb\0\u3f12" + + "\0\u3f39\0\u3f60\0\u3f87\0\u3fae\0\u3fd5\0\u3ffc\0\u4023\0\u404a" + + "\0\u4071\0\u4098\0\u40bf\0\u40e6\0\u410d\0\u4134\0\303\0\u415b" + + "\0\u4182\0\u41a9\0\u41d0\0\u41f7\0\u421e\0\u4245\0\u426c\0\u4293" + + "\0\u42ba\0\u42e1\0\u4308\0\u432f\0\u4356\0\u437d\0\u43a4\0\u43cb" + + "\0\u43f2\0\u4419\0\u4440\0\u4467\0\303\0\u448e\0\u44b5\0\u44dc" + + "\0\u4503\0\u452a\0\303\0\u4551\0\u4578\0\u459f\0\u45c6\0\u45ed" + + "\0\u4614\0\u463b\0\u4662\0\u4689\0\u46b0\0\303\0\u46d7\0\u46fe" + + "\0\u4725\0\u474c\0\u4773\0\303\0\u479a\0\u47c1\0\u47e8\0\u480f" + + "\0\u4836\0\u485d\0\u4884\0\u48ab\0\303\0\u48d2\0\u48f9\0\u4920" + + "\0\u4947\0\u496e\0\303\0\u4995\0\u49bc\0\u49e3\0\u4a0a\0\u4a31" + + "\0\u4a58\0\u4a7f\0\u4aa6\0\303\0\u4acd\0\u4af4\0\303\0\u4b1b" + + "\0\u4b42\0\u4b69\0\u4b90\0\u4bb7\0\u4bde\0\u4c05\0\u4c2c\0\u4c53" + + "\0\u4c7a\0\u4ca1\0\u4cc8\0\u4cef\0\u4d16\0\u4d3d\0\u4d64\0\u4d8b" + + "\0\u4db2\0\u4dd9\0\u4e00\0\u4e27\0\u4e4e\0\u4e75\0\u4e9c\0\u4ec3" + + "\0\u4eea\0\u4f11\0\u4f38\0\u4f5f\0\u4f86\0\u4fad\0\u4fd4\0\u4ffb" + + "\0\u5022\0\u5049\0\u5070\0\u5097\0\u50be\0\u50e5\0\u510c\0\u5133" + + "\0\303\0\u515a\0\u5181\0\u51a8\0\u51cf\0\u51f6\0\u521d\0\u5244" + + "\0\303\0\u526b\0\u5292\0\u52b9\0\u52e0\0\303\0\u5307\0\u532e" + + "\0\u5355\0\u537c\0\u53a3\0\u53ca\0\u53f1\0\u5418\0\u543f\0\303" + + "\0\u5466\0\303\0\u548d\0\u54b4\0\u54db\0\u5502\0\u5529\0\u5550" + + "\0\u5577\0\u559e\0\u55c5\0\u55ec\0\u5613\0\u563a\0\u5661\0\u5688" + + "\0\u56af\0\u56d6\0\u56fd\0\u5724\0\303\0\303\0\u574b\0\303" + + "\0\u5772\0\u5799\0\303\0\u57c0\0\u57e7\0\u580e\0\u5835\0\303" + + "\0\303\0\u585c\0\u5883\0\u58aa\0\u58d1\0\u58f8\0\u591f\0\u5946" + + "\0\u596d\0\u5994\0\303\0\u59bb\0\u59e2\0\u5a09\0\u5a30\0\303" + + "\0\u5a57\0\u5a7e\0\u5aa5\0\u5acc\0\u5af3\0\u5b1a\0\u5b41\0\u5b68" + + "\0\u5b8f\0\u5bb6\0\u5bdd\0\u5c04\0\303\0\u5c2b\0\u5c52\0\u5c79" + + "\0\303\0\u5ca0\0\u5cc7\0\303\0\303\0\303\0\u5cee\0\u5d15" + + "\0\303\0\u5d3c\0\u5d63\0\u5d8a\0\u5db1\0\u5dd8\0\u5dff\0\u5e26" + + "\0\u5e4d\0\u5e74\0\303\0\u5e9b\0\u5ec2\0\303\0\u5ee9\0\u5f10" + + "\0\u5f37\0\u5f5e\0\u5f85\0\u5fac\0\303\0\u5fd3\0\u5ffa\0\u6021" + + "\0\u6048\0\303\0\u606f\0\u6096\0\u60bd\0\u60e4\0\u610b\0\u6132" + + "\0\u6159\0\u6180\0\303\0\u61a7\0\303\0\u61ce\0\u61f5\0\u621c" + + "\0\303\0\303\0\303\0\303\0\u6243\0\u626a\0\303\0\u6291" + + "\0\u62b8\0\u62df\0\u6306\0\303\0\u632d\0\u6354\0\u637b\0\u63a2" + + "\0\u63c9\0\u63f0\0\u6417\0\303\0\303\0\u643e\0\u6465\0\u648c" + + "\0\u64b3\0\u64da\0\u6501\0\303\0\u6528\0\u654f\0\u6576\0\u659d" + + "\0\u65c4\0\u65eb\0\u6612\0\u6639\0\u6660\0\u6687\0\u66ae\0\u66d5" + + "\0\u66fc\0\u6723\0\u674a\0\u6771\0\u6798\0\u67bf\0\u67e6\0\u680d" + + "\0\u6834\0\303\0\u685b\0\u6882\0\u68a9\0\u68d0\0\u68f7\0\303" + + "\0\u691e\0\u6945\0\u696c\0\u6993\0\u69ba\0\u69e1\0\u6a08\0\u6a2f" + + "\0\u6a56\0\u6a7d\0\u6aa4\0\303\0\u6acb\0\u6af2\0\u6b19\0\u6b40" + + "\0\303\0\u6b67\0\303\0\u6b8e\0\u6bb5\0\303\0\u6bdc\0\303" + + "\0\303\0\u6c03\0\303\0\u6c2a\0\u6c51\0\303\0\u6c78\0\u6c9f" + + "\0\u6cc6\0\u6ced\0\u6d14\0\303"; + /** + * Translates a state to a row index in the transition table + */ + private static final int[] ZZ_ROWMAP = zzUnpackRowMap(); + private static final String ZZ_TRANS_PACKED_0 = + "\1\2\1\3\2\4\1\5\1\2\1\6\1\7\1\10" + + "\1\11\1\12\1\2\1\13\1\7\1\14\1\15\1\16" + + "\1\17\1\20\1\21\1\22\1\23\1\24\1\25\1\26" + + "\1\27\1\30\1\31\1\7\1\32\1\33\1\34\1\35" + + "\1\7\1\36\1\7\1\37\1\40\1\41\51\0\1\4" + + "\51\0\1\42\41\0\1\43\1\3\1\4\44\43\7\0" + + "\2\7\1\0\1\7\1\0\31\7\12\0\1\10\1\0" + + "\1\10\1\44\1\45\42\0\1\10\1\0\1\12\44\0" + + "\1\46\1\0\1\46\1\44\1\45\41\0\2\7\1\0" + + "\1\7\1\0\21\7\1\47\7\7\11\0\2\7\1\0" + + "\1\7\1\0\3\7\1\50\2\7\1\51\5\7\1\52" + + "\14\7\11\0\2\7\1\0\1\7\1\0\1\53\1\7" + + "\1\54\26\7\11\0\2\7\1\0\1\7\1\0\5\7" + + "\1\55\23\7\11\0\2\7\1\0\1\7\1\0\10\7" + + "\1\56\1\57\17\7\11\0\2\7\1\0\1\7\1\0" + + "\1\60\10\7\1\61\1\62\13\7\1\63\2\7\11\0" + + "\2\7\1\0\1\7\1\0\2\7\1\64\12\7\1\65" + + "\13\7\11\0\2\7\1\0\1\7\1\0\14\7\1\66" + + "\14\7\11\0\2\7\1\0\1\7\1\0\1\67\4\7" + + "\1\70\7\7\1\71\13\7\11\0\2\7\1\0\1\7" + + "\1\0\13\7\1\72\15\7\11\0\2\7\1\0\1\7" + + "\1\0\14\7\1\73\1\74\13\7\11\0\2\7\1\0" + + "\1\7\1\0\11\7\1\75\17\7\11\0\2\7\1\0" + + "\1\7\1\0\7\7\1\76\1\7\1\77\2\7\1\100" + + "\6\7\1\101\5\7\11\0\2\7\1\0\1\7\1\0" + + "\2\7\1\102\12\7\1\103\13\7\11\0\2\7\1\0" + + "\1\7\1\0\3\7\1\104\10\7\1\105\1\106\13\7" + + "\11\0\2\7\1\0\1\7\1\0\1\107\4\7\1\110" + + "\5\7\1\111\4\7\1\112\10\7\11\0\2\7\1\0" + + "\1\7\1\0\1\113\30\7\11\0\2\7\1\0\1\7" + + "\1\0\5\7\1\114\7\7\1\115\13\7\11\0\2\7" + + "\1\0\1\7\1\0\2\7\1\116\2\7\1\117\6\7" + + "\1\120\14\7\11\0\2\7\1\0\1\7\1\0\5\7" + + "\1\121\23\7\11\0\2\7\1\0\1\7\1\0\5\7" + + "\1\122\23\7\2\0\5\123\1\124\41\123\10\0\1\125" + + "\1\0\1\125\44\0\1\126\1\127\1\130\43\0\2\7" + + "\1\0\1\7\1\0\5\7\1\131\23\7\11\0\2\7" + + "\1\0\1\7\1\0\3\7\1\132\25\7\11\0\2\7" + + "\1\0\1\7\1\0\6\7\1\133\22\7\11\0\2\7" + + "\1\0\1\7\1\0\12\7\1\134\16\7\11\0\2\7" + + "\1\0\1\7\1\0\11\7\1\135\17\7\11\0\2\7" + + "\1\0\1\7\1\0\20\7\1\136\10\7\11\0\2\7" + + "\1\0\1\7\1\0\2\7\1\137\3\7\1\140\6\7" + + "\1\141\13\7\11\0\2\7\1\0\1\7\1\0\11\7" + + "\1\142\17\7\11\0\2\7\1\0\1\7\1\0\12\7" + + "\1\143\4\7\1\144\11\7\11\0\2\7\1\0\1\7" + + "\1\0\3\7\1\145\25\7\11\0\2\7\1\0\1\7" + + "\1\0\2\7\1\146\26\7\11\0\2\7\1\0\1\7" + + "\1\0\5\7\1\147\23\7\11\0\2\7\1\0\1\7" + + "\1\0\15\7\1\150\13\7\11\0\2\7\1\0\1\7" + + "\1\0\17\7\1\151\11\7\11\0\2\7\1\0\1\7" + + "\1\0\2\7\1\152\11\7\1\153\14\7\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\154\23\7\11\0\2\7" + + "\1\0\1\7\1\0\12\7\1\155\16\7\11\0\2\7" + + "\1\0\1\7\1\0\11\7\1\156\17\7\11\0\2\7" + + "\1\0\1\7\1\0\11\7\1\157\1\160\16\7\11\0" + + "\2\7\1\0\1\7\1\0\2\7\1\161\26\7\11\0" + + "\2\7\1\0\1\7\1\0\3\7\1\162\25\7\11\0" + + "\2\7\1\0\1\7\1\0\14\7\1\163\14\7\11\0" + + "\2\7\1\0\1\7\1\0\23\7\1\164\5\7\11\0" + + "\2\7\1\0\1\7\1\0\27\7\1\165\1\7\11\0" + + "\2\7\1\0\1\7\1\0\12\7\1\166\16\7\11\0" + + "\2\7\1\0\1\7\1\0\23\7\1\167\5\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\170\17\7\11\0" + + "\2\7\1\0\1\7\1\0\4\7\1\171\24\7\11\0" + + "\2\7\1\0\1\7\1\0\1\172\30\7\11\0\2\7" + + "\1\0\1\7\1\0\13\7\1\173\15\7\11\0\2\7" + + "\1\0\1\7\1\0\3\7\1\174\5\7\1\175\4\7" + + "\1\176\12\7\11\0\2\7\1\0\1\7\1\0\6\7" + + "\1\177\22\7\11\0\2\7\1\0\1\7\1\0\6\7" + + "\1\200\22\7\11\0\2\7\1\0\1\7\1\0\2\7" + + "\1\201\26\7\11\0\2\7\1\0\1\7\1\0\11\7" + + "\1\202\17\7\11\0\2\7\1\0\1\7\1\0\1\203" + + "\30\7\11\0\2\7\1\0\1\7\1\0\25\7\1\204" + + "\3\7\11\0\2\7\1\0\1\7\1\0\13\7\1\205" + + "\15\7\11\0\2\7\1\0\1\7\1\0\13\7\1\206" + + "\3\7\1\207\1\7\1\210\7\7\11\0\2\7\1\0" + + "\1\7\1\0\11\7\1\211\17\7\11\0\2\7\1\0" + + "\1\7\1\0\3\7\1\212\2\7\1\213\22\7\11\0" + + "\2\7\1\0\1\7\1\0\3\7\1\214\25\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\215\17\7\2\0" + + "\5\123\1\216\41\123\4\0\1\4\1\124\51\0\1\125" + + "\1\0\1\125\1\0\1\45\42\0\1\126\1\0\1\126" + + "\44\0\1\126\1\0\1\130\43\0\2\7\1\0\1\7" + + "\1\0\12\7\1\217\16\7\11\0\2\7\1\0\1\7" + + "\1\0\1\7\1\220\27\7\11\0\2\7\1\0\1\7" + + "\1\0\5\7\1\221\23\7\11\0\2\7\1\0\1\7" + + "\1\0\15\7\1\222\13\7\11\0\2\7\1\0\1\7" + + "\1\0\10\7\1\223\20\7\11\0\2\7\1\0\1\7" + + "\1\0\1\224\30\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\225\4\7\1\226\22\7\11\0\2\7\1\0" + + "\1\7\1\0\5\7\1\227\23\7\11\0\2\7\1\0" + + "\1\7\1\0\3\7\1\230\25\7\11\0\2\7\1\0" + + "\1\7\1\0\15\7\1\231\13\7\11\0\2\7\1\0" + + "\1\7\1\0\1\232\30\7\11\0\2\7\1\0\1\7" + + "\1\0\15\7\1\233\13\7\11\0\2\7\1\0\1\7" + + "\1\0\1\234\30\7\11\0\2\7\1\0\1\7\1\0" + + "\24\7\1\235\4\7\11\0\2\7\1\0\1\7\1\0" + + "\12\7\1\236\16\7\11\0\2\7\1\0\1\7\1\0" + + "\4\7\1\237\24\7\11\0\2\7\1\0\1\7\1\0" + + "\22\7\1\240\6\7\11\0\2\7\1\0\1\7\1\0" + + "\13\7\1\241\15\7\11\0\2\7\1\0\1\7\1\0" + + "\11\7\1\242\17\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\243\27\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\244\27\7\11\0\2\7\1\0\1\7\1\0" + + "\1\245\30\7\11\0\2\7\1\0\1\7\1\0\1\246" + + "\30\7\11\0\2\7\1\0\1\7\1\0\1\7\1\247" + + "\27\7\11\0\2\7\1\0\1\7\1\0\17\7\1\250" + + "\11\7\11\0\2\7\1\0\1\7\1\0\1\251\30\7" + + "\11\0\2\7\1\0\1\7\1\0\12\7\1\252\16\7" + + "\11\0\2\7\1\0\1\7\1\0\5\7\1\253\23\7" + + "\11\0\2\7\1\0\1\7\1\0\1\254\30\7\11\0" + + "\2\7\1\0\1\7\1\0\3\7\1\255\25\7\11\0" + + "\2\7\1\0\1\7\1\0\14\7\1\256\14\7\11\0" + + "\2\7\1\0\1\7\1\0\1\257\30\7\11\0\2\7" + + "\1\0\1\7\1\0\2\7\1\260\26\7\11\0\2\7" + + "\1\0\1\7\1\0\13\7\1\261\15\7\11\0\2\7" + + "\1\0\1\7\1\0\15\7\1\262\13\7\11\0\2\7" + + "\1\0\1\7\1\0\21\7\1\263\7\7\11\0\2\7" + + "\1\0\1\7\1\0\24\7\1\264\4\7\11\0\2\7" + + "\1\0\1\7\1\0\1\265\30\7\11\0\2\7\1\0" + + "\1\7\1\0\24\7\1\266\4\7\11\0\2\7\1\0" + + "\1\7\1\0\10\7\1\267\20\7\11\0\2\7\1\0" + + "\1\7\1\0\2\7\1\270\26\7\11\0\2\7\1\0" + + "\1\7\1\0\24\7\1\271\4\7\11\0\2\7\1\0" + + "\1\7\1\0\1\272\30\7\11\0\2\7\1\0\1\7" + + "\1\0\12\7\1\273\16\7\11\0\2\7\1\0\1\7" + + "\1\0\2\7\1\274\26\7\11\0\2\7\1\0\1\7" + + "\1\0\22\7\1\275\6\7\11\0\2\7\1\0\1\7" + + "\1\0\6\7\1\276\22\7\11\0\2\7\1\0\1\7" + + "\1\0\6\7\1\277\22\7\11\0\2\7\1\0\1\7" + + "\1\0\3\7\1\300\25\7\11\0\2\7\1\0\1\7" + + "\1\0\26\7\1\301\2\7\11\0\2\7\1\0\1\7" + + "\1\0\5\7\1\302\23\7\11\0\2\7\1\0\1\7" + + "\1\0\21\7\1\303\7\7\2\0\4\123\1\4\1\216" + + "\41\123\7\0\2\7\1\0\1\7\1\0\1\7\1\304" + + "\27\7\11\0\2\7\1\0\1\7\1\0\4\7\1\305" + + "\24\7\11\0\2\7\1\0\1\7\1\0\10\7\1\306" + + "\20\7\11\0\2\7\1\0\1\7\1\0\16\7\1\307" + + "\12\7\11\0\2\7\1\0\1\7\1\0\12\7\1\310" + + "\16\7\11\0\2\7\1\0\1\7\1\0\13\7\1\311" + + "\15\7\11\0\2\7\1\0\1\7\1\0\6\7\1\312" + + "\4\7\1\313\6\7\1\314\6\7\11\0\2\7\1\0" + + "\1\7\1\0\7\7\1\315\21\7\11\0\2\7\1\0" + + "\1\7\1\0\2\7\1\316\26\7\11\0\2\7\1\0" + + "\1\7\1\0\13\7\1\317\15\7\11\0\2\7\1\0" + + "\1\7\1\0\13\7\1\320\15\7\11\0\2\7\1\0" + + "\1\7\1\0\16\7\1\321\12\7\11\0\2\7\1\0" + + "\1\7\1\0\17\7\1\322\11\7\11\0\2\7\1\0" + + "\1\7\1\0\6\7\1\323\22\7\11\0\2\7\1\0" + + "\1\7\1\0\17\7\1\324\11\7\11\0\2\7\1\0" + + "\1\7\1\0\1\325\30\7\11\0\2\7\1\0\1\7" + + "\1\0\10\7\1\326\20\7\11\0\2\7\1\0\1\7" + + "\1\0\21\7\1\327\7\7\11\0\2\7\1\0\1\7" + + "\1\0\21\7\1\330\7\7\11\0\2\7\1\0\1\7" + + "\1\0\21\7\1\331\7\7\11\0\2\7\1\0\1\7" + + "\1\0\5\7\1\332\23\7\11\0\2\7\1\0\1\7" + + "\1\0\12\7\1\333\16\7\11\0\2\7\1\0\1\7" + + "\1\0\4\7\1\334\24\7\11\0\2\7\1\0\1\7" + + "\1\0\1\335\30\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\336\27\7\11\0\2\7\1\0\1\7\1\0" + + "\1\337\30\7\11\0\2\7\1\0\1\7\1\0\25\7" + + "\1\340\3\7\11\0\2\7\1\0\1\7\1\0\17\7" + + "\1\341\11\7\11\0\2\7\1\0\1\7\1\0\5\7" + + "\1\342\23\7\11\0\2\7\1\0\1\7\1\0\2\7" + + "\1\343\26\7\11\0\2\7\1\0\1\7\1\0\1\7" + + "\1\344\27\7\11\0\2\7\1\0\1\7\1\0\13\7" + + "\1\345\15\7\11\0\2\7\1\0\1\7\1\0\1\346" + + "\30\7\11\0\2\7\1\0\1\7\1\0\13\7\1\347" + + "\15\7\11\0\2\7\1\0\1\7\1\0\14\7\1\350" + + "\14\7\11\0\2\7\1\0\1\7\1\0\15\7\1\351" + + "\13\7\11\0\2\7\1\0\1\7\1\0\3\7\1\352" + + "\25\7\11\0\2\7\1\0\1\7\1\0\3\7\1\353" + + "\25\7\11\0\2\7\1\0\1\7\1\0\1\7\1\354" + + "\27\7\11\0\2\7\1\0\1\7\1\0\16\7\1\355" + + "\12\7\11\0\2\7\1\0\1\7\1\0\15\7\1\356" + + "\13\7\11\0\2\7\1\0\1\7\1\0\21\7\1\357" + + "\7\7\11\0\2\7\1\0\1\7\1\0\20\7\1\360" + + "\10\7\11\0\2\7\1\0\1\7\1\0\16\7\1\361" + + "\12\7\11\0\2\7\1\0\1\7\1\0\2\7\1\362" + + "\26\7\11\0\2\7\1\0\1\7\1\0\12\7\1\363" + + "\16\7\11\0\2\7\1\0\1\7\1\0\1\7\1\364" + + "\27\7\11\0\2\7\1\0\1\7\1\0\1\7\1\365" + + "\27\7\11\0\2\7\1\0\1\7\1\0\10\7\1\366" + + "\20\7\11\0\2\7\1\0\1\7\1\0\15\7\1\367" + + "\13\7\11\0\2\7\1\0\1\7\1\0\4\7\1\370" + + "\4\7\1\371\17\7\11\0\2\7\1\0\1\7\1\0" + + "\5\7\1\372\23\7\11\0\2\7\1\0\1\7\1\0" + + "\11\7\1\373\17\7\11\0\2\7\1\0\1\7\1\0" + + "\2\7\1\374\26\7\11\0\2\7\1\0\1\7\1\0" + + "\26\7\1\375\2\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\376\27\7\11\0\2\7\1\0\1\7\1\0" + + "\11\7\1\377\17\7\11\0\2\7\1\0\1\7\1\0" + + "\14\7\1\u0100\14\7\11\0\2\7\1\0\1\7\1\0" + + "\1\u0101\30\7\11\0\2\7\1\0\1\7\1\0\3\7" + + "\1\u0102\25\7\11\0\2\7\1\0\1\7\1\0\12\7" + + "\1\u0103\16\7\11\0\2\7\1\0\1\7\1\0\1\u0104" + + "\30\7\11\0\2\7\1\0\1\7\1\0\2\7\1\u0105" + + "\26\7\11\0\2\7\1\0\1\7\1\0\24\7\1\u0106" + + "\4\7\11\0\2\7\1\0\1\7\1\0\12\7\1\u0107" + + "\16\7\11\0\2\7\1\0\1\7\1\0\26\7\1\u0108" + + "\2\7\11\0\2\7\1\0\1\7\1\0\26\7\1\u0109" + + "\2\7\11\0\2\7\1\0\1\7\1\0\1\7\1\u010a" + + "\27\7\11\0\2\7\1\0\1\7\1\0\13\7\1\u010b" + + "\15\7\11\0\2\7\1\0\1\7\1\0\1\7\1\u010c" + + "\27\7\11\0\2\7\1\0\1\7\1\0\6\7\1\u010d" + + "\22\7\11\0\2\7\1\0\1\7\1\0\1\u010e\30\7" + + "\11\0\2\7\1\0\1\7\1\0\11\7\1\u010f\17\7" + + "\11\0\2\7\1\0\1\7\1\0\20\7\1\u0110\10\7" + + "\11\0\2\7\1\0\1\7\1\0\5\7\1\u0111\23\7" + + "\11\0\2\7\1\0\1\7\1\0\6\7\1\u0112\22\7" + + "\11\0\2\7\1\0\1\7\1\0\6\7\1\u0113\22\7" + + "\11\0\2\7\1\0\1\7\1\0\1\7\1\u0114\27\7" + + "\11\0\2\7\1\0\1\7\1\0\1\u0115\30\7\11\0" + + "\2\7\1\0\1\7\1\0\12\7\1\u0116\16\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\u0117\17\7\11\0" + + "\2\7\1\0\1\7\1\0\3\7\1\u0118\25\7\11\0" + + "\2\7\1\0\1\7\1\0\24\7\1\u0119\4\7\11\0" + + "\2\7\1\0\1\7\1\0\2\7\1\u011a\26\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\u011b\17\7\11\0" + + "\2\7\1\0\1\7\1\0\1\7\1\u011c\4\7\1\u011d" + + "\22\7\11\0\2\7\1\0\1\7\1\0\17\7\1\u011e" + + "\11\7\11\0\2\7\1\0\1\7\1\0\11\7\1\u011f" + + "\17\7\11\0\2\7\1\0\1\7\1\0\1\u0120\30\7" + + "\11\0\2\7\1\0\1\7\1\0\2\7\1\u0121\26\7" + + "\11\0\2\7\1\0\1\7\1\0\17\7\1\u0122\11\7" + + "\11\0\2\7\1\0\1\7\1\0\5\7\1\u0123\23\7" + + "\11\0\2\7\1\0\1\7\1\0\14\7\1\u0124\14\7" + + "\11\0\2\7\1\0\1\7\1\0\1\7\1\u0125\27\7" + + "\11\0\2\7\1\0\1\7\1\0\23\7\1\u0126\5\7" + + "\11\0\2\7\1\0\1\7\1\0\1\u0127\30\7\11\0" + + "\2\7\1\0\1\7\1\0\10\7\1\u0128\20\7\11\0" + + "\2\7\1\0\1\7\1\0\2\7\1\u0129\26\7\11\0" + + "\2\7\1\0\1\7\1\0\12\7\1\u012a\16\7\11\0" + + "\2\7\1\0\1\7\1\0\2\7\1\u012b\26\7\11\0" + + "\2\7\1\0\1\7\1\0\26\7\1\u012c\2\7\11\0" + + "\2\7\1\0\1\7\1\0\30\7\1\u012d\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\u012e\23\7\11\0\2\7" + + "\1\0\1\7\1\0\1\u012f\30\7\11\0\2\7\1\0" + + "\1\7\1\0\6\7\1\u0130\22\7\11\0\2\7\1\0" + + "\1\7\1\0\1\7\1\u0131\27\7\11\0\2\7\1\0" + + "\1\7\1\0\12\7\1\u0132\16\7\11\0\2\7\1\0" + + "\1\7\1\0\1\7\1\u0133\27\7\11\0\2\7\1\0" + + "\1\7\1\0\4\7\1\u0134\24\7\11\0\2\7\1\0" + + "\1\7\1\0\2\7\1\u0135\26\7\11\0\2\7\1\0" + + "\1\7\1\0\3\7\1\u0136\25\7\11\0\2\7\1\0" + + "\1\7\1\0\1\u0137\30\7\11\0\2\7\1\0\1\7" + + "\1\0\1\u0138\30\7\11\0\2\7\1\0\1\7\1\0" + + "\5\7\1\u0139\23\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\u013a\27\7\11\0\2\7\1\0\1\7\1\0" + + "\17\7\1\u013b\11\7\11\0\2\7\1\0\1\7\1\0" + + "\3\7\1\u013c\25\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\u013d\1\u013e\2\7\1\u013f\23\7\11\0\2\7" + + "\1\0\1\7\1\0\15\7\1\u0140\13\7\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\u0141\23\7\11\0\2\7" + + "\1\0\1\7\1\0\1\u0142\30\7\11\0\2\7\1\0" + + "\1\7\1\0\15\7\1\u0143\13\7\11\0\2\7\1\0" + + "\1\7\1\0\23\7\1\u0144\5\7\11\0\2\7\1\0" + + "\1\7\1\0\23\7\1\u0145\5\7\11\0\2\7\1\0" + + "\1\7\1\0\23\7\1\u0146\5\7\11\0\2\7\1\0" + + "\1\7\1\0\1\7\1\u0147\27\7\11\0\2\7\1\0" + + "\1\7\1\0\6\7\1\u0148\22\7\11\0\2\7\1\0" + + "\1\7\1\0\1\u0149\30\7\11\0\2\7\1\0\1\7" + + "\1\0\16\7\1\u014a\2\7\1\u014b\2\7\1\u014c\4\7" + + "\11\0\2\7\1\0\1\7\1\0\21\7\1\u014d\7\7" + + "\11\0\2\7\1\0\1\7\1\0\1\7\1\u014e\27\7" + + "\11\0\2\7\1\0\1\7\1\0\1\u014f\30\7\11\0" + + "\2\7\1\0\1\7\1\0\1\7\1\u0150\27\7\11\0" + + "\2\7\1\0\1\7\1\0\2\7\1\u0151\26\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\u0152\17\7\11\0" + + "\2\7\1\0\1\7\1\0\12\7\1\u0153\16\7\11\0" + + "\2\7\1\0\1\7\1\0\16\7\1\u0154\12\7\11\0" + + "\2\7\1\0\1\7\1\0\12\7\1\u0155\16\7\11\0" + + "\2\7\1\0\1\7\1\0\1\u0156\30\7\11\0\2\7" + + "\1\0\1\7\1\0\17\7\1\u0157\11\7\11\0\2\7" + + "\1\0\1\7\1\0\20\7\1\u0158\10\7\11\0\2\7" + + "\1\0\1\7\1\0\15\7\1\u0159\13\7\11\0\2\7" + + "\1\0\1\7\1\0\17\7\1\u015a\11\7\11\0\2\7" + + "\1\0\1\7\1\0\12\7\1\u015b\16\7\11\0\2\7" + + "\1\0\1\7\1\0\4\7\1\u015c\5\7\1\u015d\16\7" + + "\11\0\2\7\1\0\1\7\1\0\5\7\1\u015e\23\7" + + "\11\0\2\7\1\0\1\7\1\0\12\7\1\u015f\16\7" + + "\11\0\2\7\1\0\1\7\1\0\1\u0160\30\7\11\0" + + "\2\7\1\0\1\7\1\0\17\7\1\u0161\11\7\11\0" + + "\2\7\1\0\1\7\1\0\5\7\1\u0162\23\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\u0163\17\7\11\0" + + "\2\7\1\0\1\7\1\0\12\7\1\u0164\16\7\11\0" + + "\2\7\1\0\1\7\1\0\6\7\1\u0165\22\7\11\0" + + "\2\7\1\0\1\7\1\0\2\7\1\u0166\26\7\11\0" + + "\2\7\1\0\1\7\1\0\12\7\1\u0167\16\7\11\0" + + "\2\7\1\0\1\7\1\0\5\7\1\u0168\23\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\u0169\17\7\11\0" + + "\2\7\1\0\1\7\1\0\5\7\1\u016a\23\7\11\0" + + "\2\7\1\0\1\7\1\0\16\7\1\u016b\12\7\11\0" + + "\2\7\1\0\1\7\1\0\5\7\1\u016c\23\7\11\0" + + "\2\7\1\0\1\7\1\0\24\7\1\u016d\4\7\11\0" + + "\2\7\1\0\1\7\1\0\1\u016e\30\7\11\0\2\7" + + "\1\0\1\7\1\0\24\7\1\u016f\4\7\11\0\2\7" + + "\1\0\1\7\1\0\15\7\1\u0170\13\7\11\0\2\7" + + "\1\0\1\7\1\0\17\7\1\u0171\11\7\11\0\2\7" + + "\1\0\1\7\1\0\12\7\1\u0172\16\7\11\0\2\7" + + "\1\0\1\7\1\0\1\u0173\30\7\11\0\2\7\1\0" + + "\1\7\1\0\24\7\1\u0174\4\7\11\0\2\7\1\0" + + "\1\7\1\0\7\7\1\u0175\21\7\11\0\2\7\1\0" + + "\1\7\1\0\15\7\1\u0176\13\7\11\0\2\7\1\0" + + "\1\7\1\0\12\7\1\u0177\16\7\11\0\2\7\1\0" + + "\1\7\1\0\11\7\1\u0178\17\7\11\0\2\7\1\0" + + "\1\7\1\0\11\7\1\u0179\17\7\11\0\2\7\1\0" + + "\1\7\1\0\14\7\1\u017a\14\7\11\0\2\7\1\0" + + "\1\7\1\0\13\7\1\u017b\15\7\11\0\2\7\1\0" + + "\1\7\1\0\2\7\1\u017c\26\7\11\0\2\7\1\0" + + "\1\7\1\0\15\7\1\u017d\13\7\11\0\2\7\1\0" + + "\1\7\1\0\21\7\1\u017e\7\7\11\0\2\7\1\0" + + "\1\7\1\0\5\7\1\u017f\23\7\11\0\2\7\1\0" + + "\1\7\1\0\3\7\1\u0180\25\7\11\0\2\7\1\0" + + "\1\7\1\0\15\7\1\u0181\13\7\11\0\2\7\1\0" + + "\1\7\1\0\1\u0182\30\7\11\0\2\7\1\0\1\7" + + "\1\0\2\7\1\u0183\26\7\11\0\2\7\1\0\1\7" + + "\1\0\4\7\1\u0184\12\7\1\u0185\11\7\11\0\2\7" + + "\1\0\1\7\1\0\13\7\1\u0186\15\7\11\0\2\7" + + "\1\0\1\7\1\0\13\7\1\u0187\15\7\11\0\2\7" + + "\1\0\1\7\1\0\17\7\1\u0188\11\7\11\0\2\7" + + "\1\0\1\7\1\0\1\7\1\u0189\27\7\11\0\2\7" + + "\1\0\1\7\1\0\2\7\1\u018a\26\7\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\u018b\23\7\11\0\2\7" + + "\1\0\1\7\1\0\11\7\1\u018c\17\7\11\0\2\7" + + "\1\0\1\7\1\0\12\7\1\u018d\16\7\11\0\2\7" + + "\1\0\1\7\1\0\1\7\1\u018e\27\7\11\0\2\7" + + "\1\0\1\7\1\0\16\7\1\u018f\12\7\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\u0190\23\7\11\0\2\7" + + "\1\0\1\7\1\0\13\7\1\u0191\15\7\11\0\2\7" + + "\1\0\1\7\1\0\4\7\1\u0192\24\7\11\0\2\7" + + "\1\0\1\7\1\0\1\u0193\30\7\11\0\2\7\1\0" + + "\1\7\1\0\1\7\1\u0194\27\7\11\0\2\7\1\0" + + "\1\7\1\0\22\7\1\u0195\6\7\11\0\2\7\1\0" + + "\1\7\1\0\10\7\1\u0196\20\7\11\0\2\7\1\0" + + "\1\7\1\0\21\7\1\u0197\7\7\11\0\2\7\1\0" + + "\1\7\1\0\1\7\1\u0198\27\7\11\0\2\7\1\0" + + "\1\7\1\0\6\7\1\u0199\22\7\11\0\2\7\1\0" + + "\1\7\1\0\1\7\1\u019a\27\7\11\0\2\7\1\0" + + "\1\7\1\0\7\7\1\u019b\21\7\11\0\2\7\1\0" + + "\1\7\1\0\1\u019c\30\7\11\0\2\7\1\0\1\7" + + "\1\0\17\7\1\u019d\11\7\11\0\2\7\1\0\1\7" + + "\1\0\2\7\1\u019e\26\7\11\0\2\7\1\0\1\7" + + "\1\0\6\7\1\u019f\22\7\11\0\2\7\1\0\1\7" + + "\1\0\1\7\1\u01a0\27\7\11\0\2\7\1\0\1\7" + + "\1\0\6\7\1\u01a1\22\7\11\0\2\7\1\0\1\7" + + "\1\0\15\7\1\u01a2\13\7\11\0\2\7\1\0\1\7" + + "\1\0\11\7\1\u01a3\17\7\11\0\2\7\1\0\1\7" + + "\1\0\15\7\1\u01a4\13\7\11\0\2\7\1\0\1\7" + + "\1\0\5\7\1\u01a5\23\7\11\0\2\7\1\0\1\7" + + "\1\0\12\7\1\u01a6\16\7\11\0\2\7\1\0\1\7" + + "\1\0\2\7\1\u01a7\26\7\11\0\2\7\1\0\1\7" + + "\1\0\3\7\1\u01a8\25\7\11\0\2\7\1\0\1\7" + + "\1\0\11\7\1\u01a9\17\7\11\0\2\7\1\0\1\7" + + "\1\0\6\7\1\u01aa\22\7\11\0\2\7\1\0\1\7" + + "\1\0\10\7\1\u01ab\20\7\11\0\2\7\1\0\1\7" + + "\1\0\2\7\1\u01ac\26\7\11\0\2\7\1\0\1\7" + + "\1\0\11\7\1\u01ad\17\7\11\0\2\7\1\0\1\7" + + "\1\0\2\7\1\u01ae\26\7\11\0\2\7\1\0\1\7" + + "\1\0\14\7\1\u01af\14\7\11\0\2\7\1\0\1\7" + + "\1\0\1\u01b0\30\7\11\0\2\7\1\0\1\7\1\0" + + "\7\7\1\u01b1\21\7\11\0\2\7\1\0\1\7\1\0" + + "\1\u01b2\30\7\11\0\2\7\1\0\1\7\1\0\21\7" + + "\1\u01b3\7\7\11\0\2\7\1\0\1\7\1\0\12\7" + + "\1\u01b4\16\7\11\0\2\7\1\0\1\7\1\0\13\7" + + "\1\u01b5\15\7\11\0\2\7\1\0\1\7\1\0\5\7" + + "\1\u01b6\23\7\11\0\2\7\1\0\1\7\1\0\15\7" + + "\1\u01b7\13\7\11\0\2\7\1\0\1\7\1\0\14\7" + + "\1\u01b8\14\7\11\0\2\7\1\0\1\7\1\0\2\7" + + "\1\u01b9\26\7\11\0\2\7\1\0\1\7\1\0\1\u01ba" + + "\30\7\11\0\2\7\1\0\1\7\1\0\3\7\1\u01bb" + + "\11\7\1\u01bc\13\7\11\0\2\7\1\0\1\7\1\0" + + "\11\7\1\u01bd\17\7\11\0\2\7\1\0\1\7\1\0" + + "\15\7\1\u01be\13\7\11\0\2\7\1\0\1\7\1\0" + + "\12\7\1\u01bf\16\7\11\0\2\7\1\0\1\7\1\0" + + "\1\u01c0\30\7\11\0\2\7\1\0\1\7\1\0\13\7" + + "\1\u01c1\2\7\1\u01c2\12\7\11\0\2\7\1\0\1\7" + + "\1\0\24\7\1\u01c3\4\7\11\0\2\7\1\0\1\7" + + "\1\0\2\7\1\u01c4\26\7\11\0\2\7\1\0\1\7" + + "\1\0\2\7\1\u01c5\26\7\11\0\2\7\1\0\1\7" + + "\1\0\1\u01c6\30\7\11\0\2\7\1\0\1\7\1\0" + + "\13\7\1\u01c7\15\7\11\0\2\7\1\0\1\7\1\0" + + "\5\7\1\u01c8\23\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\u01c9\27\7\11\0\2\7\1\0\1\7\1\0" + + "\26\7\1\u01ca\2\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\u01cb\27\7\11\0\2\7\1\0\1\7\1\0" + + "\13\7\1\u01cc\15\7\11\0\2\7\1\0\1\7\1\0" + + "\13\7\1\u01cd\15\7\11\0\2\7\1\0\1\7\1\0" + + "\3\7\1\u01ce\25\7\11\0\2\7\1\0\1\7\1\0" + + "\12\7\1\u01cf\16\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\u01d0\27\7\11\0\2\7\1\0\1\7\1\0" + + "\12\7\1\u01d1\16\7\11\0\2\7\1\0\1\7\1\0" + + "\5\7\1\u01d2\23\7\11\0\2\7\1\0\1\7\1\0" + + "\12\7\1\u01d3\16\7\11\0\2\7\1\0\1\7\1\0" + + "\14\7\1\u01d4\14\7\11\0\2\7\1\0\1\7\1\0" + + "\6\7\1\u01d5\22\7\11\0\2\7\1\0\1\7\1\0" + + "\11\7\1\u01d6\17\7\11\0\2\7\1\0\1\7\1\0" + + "\4\7\1\u01d7\24\7\11\0\2\7\1\0\1\7\1\0" + + "\1\u01d8\30\7\11\0\2\7\1\0\1\7\1\0\13\7" + + "\1\u01d9\15\7\11\0\2\7\1\0\1\7\1\0\1\u01da" + + "\30\7\11\0\2\7\1\0\1\7\1\0\1\7\1\u01db" + + "\27\7\11\0\2\7\1\0\1\7\1\0\7\7\1\u01dc" + + "\21\7\11\0\2\7\1\0\1\7\1\0\21\7\1\u01dd" + + "\7\7\11\0\2\7\1\0\1\7\1\0\16\7\1\u01de" + + "\12\7\11\0\2\7\1\0\1\7\1\0\3\7\1\u01df" + + "\25\7\11\0\2\7\1\0\1\7\1\0\10\7\1\u01e0" + + "\20\7\11\0\2\7\1\0\1\7\1\0\3\7\1\u01e1" + + "\25\7\11\0\2\7\1\0\1\7\1\0\17\7\1\u01e2" + + "\11\7\11\0\2\7\1\0\1\7\1\0\1\u01e3\30\7" + + "\11\0\2\7\1\0\1\7\1\0\2\7\1\u01e4\26\7" + + "\11\0\2\7\1\0\1\7\1\0\2\7\1\u01e5\26\7" + + "\11\0\2\7\1\0\1\7\1\0\6\7\1\u01e6\22\7" + + "\11\0\2\7\1\0\1\7\1\0\3\7\1\u01e7\25\7" + + "\11\0\2\7\1\0\1\7\1\0\3\7\1\u01e8\25\7" + + "\11\0\2\7\1\0\1\7\1\0\16\7\1\u01e9\12\7" + + "\11\0\2\7\1\0\1\7\1\0\1\7\1\u01ea\27\7" + + "\11\0\2\7\1\0\1\7\1\0\2\7\1\u01eb\26\7" + + "\11\0\2\7\1\0\1\7\1\0\11\7\1\u01ec\17\7" + + "\11\0\2\7\1\0\1\7\1\0\2\7\1\u01ed\26\7" + + "\11\0\2\7\1\0\1\7\1\0\11\7\1\u01ee\17\7" + + "\11\0\2\7\1\0\1\7\1\0\1\7\1\u01ef\27\7" + + "\11\0\2\7\1\0\1\7\1\0\21\7\1\u01f0\7\7" + + "\11\0\2\7\1\0\1\7\1\0\1\u01f1\30\7\11\0" + + "\2\7\1\0\1\7\1\0\5\7\1\u01f2\23\7\11\0" + + "\2\7\1\0\1\7\1\0\15\7\1\u01f3\13\7\11\0" + + "\2\7\1\0\1\7\1\0\6\7\1\u01f4\22\7\11\0" + + "\2\7\1\0\1\7\1\0\17\7\1\u01f5\11\7\11\0" + + "\2\7\1\0\1\7\1\0\1\7\1\u01f6\27\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\u01f7\17\7\11\0" + + "\2\7\1\0\1\7\1\0\5\7\1\u01f8\23\7\11\0" + + "\2\7\1\0\1\7\1\0\12\7\1\u01f9\16\7\11\0" + + "\2\7\1\0\1\7\1\0\6\7\1\u01fa\22\7\11\0" + + "\2\7\1\0\1\7\1\0\15\7\1\u01fb\13\7\11\0" + + "\2\7\1\0\1\7\1\0\14\7\1\u01fc\14\7\11\0" + + "\2\7\1\0\1\7\1\0\1\u01fd\30\7\11\0\2\7" + + "\1\0\1\7\1\0\1\7\1\u01fe\27\7\11\0\2\7" + + "\1\0\1\7\1\0\3\7\1\u01ff\25\7\11\0\2\7" + + "\1\0\1\7\1\0\17\7\1\u0200\11\7\11\0\2\7" + + "\1\0\1\7\1\0\7\7\1\u0201\21\7\11\0\2\7" + + "\1\0\1\7\1\0\15\7\1\u0202\13\7\11\0\2\7" + + "\1\0\1\7\1\0\12\7\1\u0203\16\7\11\0\2\7" + + "\1\0\1\7\1\0\1\7\1\u0204\27\7\11\0\2\7" + + "\1\0\1\7\1\0\21\7\1\u0205\7\7\11\0\2\7" + + "\1\0\1\7\1\0\1\u0206\30\7\11\0\2\7\1\0" + + "\1\7\1\0\6\7\1\u0207\22\7\11\0\2\7\1\0" + + "\1\7\1\0\2\7\1\u0208\26\7\11\0\2\7\1\0" + + "\1\7\1\0\1\7\1\u0209\27\7\11\0\2\7\1\0" + + "\1\7\1\0\3\7\1\u020a\25\7\11\0\2\7\1\0" + + "\1\7\1\0\3\7\1\u020b\25\7\11\0\2\7\1\0" + + "\1\7\1\0\1\u020c\30\7\11\0\2\7\1\0\1\7" + + "\1\0\12\7\1\u020d\16\7\11\0\2\7\1\0\1\7" + + "\1\0\13\7\1\u020e\15\7\11\0\2\7\1\0\1\7" + + "\1\0\1\u020f\30\7\11\0\2\7\1\0\1\7\1\0" + + "\12\7\1\u0210\16\7\11\0\2\7\1\0\1\7\1\0" + + "\5\7\1\u0211\23\7\11\0\2\7\1\0\1\7\1\0" + + "\16\7\1\u0212\12\7\11\0\2\7\1\0\1\7\1\0" + + "\5\7\1\u0213\23\7\11\0\2\7\1\0\1\7\1\0" + + "\15\7\1\u0214\13\7\11\0\2\7\1\0\1\7\1\0" + + "\1\u0215\30\7\11\0\2\7\1\0\1\7\1\0\1\u0216" + + "\30\7\11\0\2\7\1\0\1\7\1\0\16\7\1\u0217" + + "\1\u0218\11\7\11\0\2\7\1\0\1\7\1\0\20\7" + + "\1\u0219\10\7\11\0\2\7\1\0\1\7\1\0\3\7" + + "\1\u021a\25\7\11\0\2\7\1\0\1\7\1\0\10\7" + + "\1\u021b\20\7\11\0\2\7\1\0\1\7\1\0\5\7" + + "\1\u021c\1\7\1\u021d\1\u021e\12\7\1\u021f\5\7\11\0" + + "\2\7\1\0\1\7\1\0\1\7\1\u0220\27\7\11\0" + + "\2\7\1\0\1\7\1\0\10\7\1\u0221\20\7\11\0" + + "\2\7\1\0\1\7\1\0\6\7\1\u0222\22\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\u0223\17\7\11\0" + + "\2\7\1\0\1\7\1\0\1\u0224\30\7\11\0\2\7" + + "\1\0\1\7\1\0\21\7\1\u0225\7\7\11\0\2\7" + + "\1\0\1\7\1\0\23\7\1\u0226\5\7\11\0\2\7" + + "\1\0\1\7\1\0\11\7\1\u0227\17\7\11\0\2\7" + + "\1\0\1\7\1\0\1\7\1\u0228\27\7\11\0\2\7" + + "\1\0\1\7\1\0\26\7\1\u0229\2\7\11\0\2\7" + + "\1\0\1\7\1\0\14\7\1\u022a\14\7\11\0\2\7" + + "\1\0\1\7\1\0\3\7\1\u022b\25\7\11\0\2\7" + + "\1\0\1\7\1\0\13\7\1\u022c\15\7\11\0\2\7" + + "\1\0\1\7\1\0\2\7\1\u022d\26\7\11\0\2\7" + + "\1\0\1\7\1\0\26\7\1\u022e\2\7\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\u022f\23\7\11\0\2\7" + + "\1\0\1\7\1\0\1\7\1\u0230\27\7\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\u0231\23\7\11\0\2\7" + + "\1\0\1\7\1\0\14\7\1\u0232\14\7\11\0\2\7" + + "\1\0\1\7\1\0\1\7\1\u0233\27\7\11\0\2\7" + + "\1\0\1\7\1\0\1\7\1\u0234\27\7\11\0\2\7" + + "\1\0\1\7\1\0\16\7\1\u0235\12\7\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\u0236\23\7\11\0\2\7" + + "\1\0\1\7\1\0\2\7\1\u0237\26\7\11\0\2\7" + + "\1\0\1\7\1\0\1\u0238\30\7\11\0\2\7\1\0" + + "\1\7\1\0\6\7\1\u0239\22\7\11\0\2\7\1\0" + + "\1\7\1\0\1\u023a\30\7\11\0\2\7\1\0\1\7" + + "\1\0\5\7\1\u023b\23\7\11\0\2\7\1\0\1\7" + + "\1\0\3\7\1\u023c\25\7\11\0\2\7\1\0\1\7" + + "\1\0\1\u023d\30\7\11\0\2\7\1\0\1\7\1\0" + + "\7\7\1\u023e\21\7\11\0\2\7\1\0\1\7\1\0" + + "\13\7\1\u023f\15\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\u0240\4\7\1\u0241\22\7\11\0\2\7\1\0" + + "\1\7\1\0\12\7\1\u0242\16\7\11\0\2\7\1\0" + + "\1\7\1\0\2\7\1\u0243\26\7\11\0\2\7\1\0" + + "\1\7\1\0\15\7\1\u0244\13\7\11\0\2\7\1\0" + + "\1\7\1\0\1\u0245\30\7\11\0\2\7\1\0\1\7" + + "\1\0\20\7\1\u0246\10\7\11\0\2\7\1\0\1\7" + + "\1\0\1\u0247\30\7\11\0\2\7\1\0\1\7\1\0" + + "\11\7\1\u0248\17\7\11\0\2\7\1\0\1\7\1\0" + + "\2\7\1\u0249\26\7\11\0\2\7\1\0\1\7\1\0" + + "\13\7\1\u024a\15\7\11\0\2\7\1\0\1\7\1\0" + + "\13\7\1\u024b\15\7\11\0\2\7\1\0\1\7\1\0" + + "\6\7\1\u024c\22\7\11\0\2\7\1\0\1\7\1\0" + + "\5\7\1\u024d\23\7\11\0\2\7\1\0\1\7\1\0" + + "\17\7\1\u024e\11\7\11\0\2\7\1\0\1\7\1\0" + + "\1\u024f\30\7\11\0\2\7\1\0\1\7\1\0\6\7" + + "\1\u0250\22\7\11\0\2\7\1\0\1\7\1\0\1\u0251" + + "\30\7\11\0\2\7\1\0\1\7\1\0\15\7\1\u0252" + + "\13\7\11\0\2\7\1\0\1\7\1\0\23\7\1\u0253" + + "\5\7\11\0\2\7\1\0\1\7\1\0\2\7\1\u0254" + + "\10\7\1\u0255\15\7\11\0\2\7\1\0\1\7\1\0" + + "\15\7\1\u0256\13\7\11\0\2\7\1\0\1\7\1\0" + + "\12\7\1\u0257\16\7\11\0\2\7\1\0\1\7\1\0" + + "\1\u0258\30\7\11\0\2\7\1\0\1\7\1\0\14\7" + + "\1\u0259\14\7\11\0\2\7\1\0\1\7\1\0\20\7" + + "\1\u025a\10\7\11\0\2\7\1\0\1\7\1\0\5\7" + + "\1\u025b\23\7\11\0\2\7\1\0\1\7\1\0\3\7" + + "\1\u025c\25\7\11\0\2\7\1\0\1\7\1\0\6\7" + + "\1\u025d\22\7\11\0\2\7\1\0\1\7\1\0\11\7" + + "\1\u025e\17\7\11\0\2\7\1\0\1\7\1\0\17\7" + + "\1\u025f\11\7\11\0\2\7\1\0\1\7\1\0\6\7" + + "\1\u0260\22\7\11\0\2\7\1\0\1\7\1\0\5\7" + + "\1\u0261\23\7\11\0\2\7\1\0\1\7\1\0\1\u0262" + + "\30\7\11\0\2\7\1\0\1\7\1\0\12\7\1\u0263" + + "\16\7\11\0\2\7\1\0\1\7\1\0\20\7\1\u0264" + + "\10\7\11\0\2\7\1\0\1\7\1\0\21\7\1\u0265" + + "\7\7\11\0\2\7\1\0\1\7\1\0\1\u0266\30\7" + + "\11\0\2\7\1\0\1\7\1\0\15\7\1\u0267\13\7" + + "\11\0\2\7\1\0\1\7\1\0\6\7\1\u0268\22\7" + + "\11\0\2\7\1\0\1\7\1\0\12\7\1\u0269\16\7" + + "\11\0\2\7\1\0\1\7\1\0\5\7\1\u026a\23\7" + + "\11\0\2\7\1\0\1\7\1\0\6\7\1\u026b\22\7" + + "\11\0\2\7\1\0\1\7\1\0\6\7\1\u026c\22\7" + + "\11\0\2\7\1\0\1\7\1\0\1\u026d\30\7\11\0" + + "\2\7\1\0\1\7\1\0\12\7\1\u026e\16\7\11\0" + + "\2\7\1\0\1\7\1\0\16\7\1\u026f\12\7\11\0" + + "\2\7\1\0\1\7\1\0\13\7\1\u0270\15\7\11\0" + + "\2\7\1\0\1\7\1\0\13\7\1\u0271\15\7\11\0" + + "\2\7\1\0\1\7\1\0\23\7\1\u0272\5\7\11\0" + + "\2\7\1\0\1\7\1\0\17\7\1\u0273\11\7\11\0" + + "\2\7\1\0\1\7\1\0\5\7\1\u0274\23\7\11\0" + + "\2\7\1\0\1\7\1\0\15\7\1\u0275\13\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\u0276\17\7\11\0" + + "\2\7\1\0\1\7\1\0\15\7\1\u0277\13\7\11\0" + + "\2\7\1\0\1\7\1\0\1\u0278\30\7\11\0\2\7" + + "\1\0\1\7\1\0\11\7\1\u0279\17\7\11\0\2\7" + + "\1\0\1\7\1\0\10\7\1\u027a\20\7\11\0\2\7" + + "\1\0\1\7\1\0\15\7\1\u027b\13\7\11\0\2\7" + + "\1\0\1\7\1\0\17\7\1\u027c\11\7\11\0\2\7" + + "\1\0\1\7\1\0\1\u027d\30\7\11\0\2\7\1\0" + + "\1\7\1\0\4\7\1\u027e\24\7\11\0\2\7\1\0" + + "\1\7\1\0\5\7\1\u027f\23\7\11\0\2\7\1\0" + + "\1\7\1\0\6\7\1\u0280\22\7\11\0\2\7\1\0" + + "\1\7\1\0\3\7\1\u0281\25\7\11\0\2\7\1\0" + + "\1\7\1\0\1\u0282\30\7\11\0\2\7\1\0\1\7" + + "\1\0\11\7\1\u0283\17\7\11\0\2\7\1\0\1\7" + + "\1\0\5\7\1\u0284\23\7\11\0\2\7\1\0\1\7" + + "\1\0\16\7\1\u0285\12\7\11\0\2\7\1\0\1\7" + + "\1\0\23\7\1\u0286\5\7\11\0\2\7\1\0\1\7" + + "\1\0\12\7\1\u0287\16\7\11\0\2\7\1\0\1\7" + + "\1\0\12\7\1\u0288\16\7\11\0\2\7\1\0\1\7" + + "\1\0\11\7\1\u0289\17\7\11\0\2\7\1\0\1\7" + + "\1\0\12\7\1\u028a\16\7\11\0\2\7\1\0\1\7" + + "\1\0\1\u028b\30\7\11\0\2\7\1\0\1\7\1\0" + + "\1\u028c\30\7\11\0\2\7\1\0\1\7\1\0\11\7" + + "\1\u028d\17\7\11\0\2\7\1\0\1\7\1\0\1\u028e" + + "\30\7\11\0\2\7\1\0\1\7\1\0\3\7\1\u028f" + + "\25\7\11\0\2\7\1\0\1\7\1\0\1\u0290\30\7" + + "\11\0\2\7\1\0\1\7\1\0\13\7\1\u0291\15\7" + + "\11\0\2\7\1\0\1\7\1\0\13\7\1\u0292\15\7" + + "\11\0\2\7\1\0\1\7\1\0\24\7\1\u0293\4\7" + + "\11\0\2\7\1\0\1\7\1\0\15\7\1\u0294\13\7" + + "\11\0\2\7\1\0\1\7\1\0\22\7\1\u0295\6\7" + + "\11\0\2\7\1\0\1\7\1\0\21\7\1\u0296\7\7" + + "\11\0\2\7\1\0\1\7\1\0\11\7\1\u0297\17\7" + + "\11\0\2\7\1\0\1\7\1\0\2\7\1\u0298\26\7" + + "\11\0\2\7\1\0\1\7\1\0\11\7\1\u0299\17\7" + + "\11\0\2\7\1\0\1\7\1\0\3\7\1\u029a\25\7" + + "\11\0\2\7\1\0\1\7\1\0\12\7\1\u029b\16\7" + + "\11\0\2\7\1\0\1\7\1\0\13\7\1\u029c\15\7" + + "\11\0\2\7\1\0\1\7\1\0\17\7\1\u029d\11\7" + + "\11\0\2\7\1\0\1\7\1\0\10\7\1\u029e\20\7" + + "\11\0\2\7\1\0\1\7\1\0\1\u029f\30\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\u02a0\17\7\11\0" + + "\2\7\1\0\1\7\1\0\1\u02a1\30\7\11\0\2\7" + + "\1\0\1\7\1\0\13\7\1\u02a2\15\7\11\0\2\7" + + "\1\0\1\7\1\0\10\7\1\u02a3\20\7\11\0\2\7" + + "\1\0\1\7\1\0\12\7\1\u02a4\16\7\11\0\2\7" + + "\1\0\1\7\1\0\21\7\1\u02a5\7\7\11\0\2\7" + + "\1\0\1\7\1\0\15\7\1\u02a6\13\7\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\u02a7\23\7\11\0\2\7" + + "\1\0\1\7\1\0\2\7\1\u02a8\26\7\11\0\2\7" + + "\1\0\1\7\1\0\23\7\1\u02a9\5\7\11\0\2\7" + + "\1\0\1\7\1\0\1\u02aa\30\7\11\0\2\7\1\0" + + "\1\7\1\0\16\7\1\u02ab\12\7\11\0\2\7\1\0" + + "\1\7\1\0\13\7\1\u02ac\15\7\11\0\2\7\1\0" + + "\1\7\1\0\13\7\1\u02ad\15\7\11\0\2\7\1\0" + + "\1\7\1\0\5\7\1\u02ae\23\7\11\0\2\7\1\0" + + "\1\7\1\0\12\7\1\u02af\16\7\11\0\2\7\1\0" + + "\1\7\1\0\5\7\1\u02b0\23\7\11\0\2\7\1\0" + + "\1\7\1\0\1\u02b1\30\7\11\0\2\7\1\0\1\7" + + "\1\0\12\7\1\u02b2\16\7\11\0\2\7\1\0\1\7" + + "\1\0\24\7\1\u02b3\4\7\11\0\2\7\1\0\1\7" + + "\1\0\3\7\1\u02b4\25\7\11\0\2\7\1\0\1\7" + + "\1\0\6\7\1\u02b5\22\7\11\0\2\7\1\0\1\7" + + "\1\0\1\u02b6\30\7\11\0\2\7\1\0\1\7\1\0" + + "\14\7\1\u02b7\14\7\11\0\2\7\1\0\1\7\1\0" + + "\5\7\1\u02b8\23\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\u02b9\27\7\11\0\2\7\1\0\1\7\1\0" + + "\10\7\1\u02ba\20\7\11\0\2\7\1\0\1\7\1\0" + + "\6\7\1\u02bb\22\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\u02bc\27\7\11\0\2\7\1\0\1\7\1\0" + + "\20\7\1\u02bd\10\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\u02be\27\7\11\0\2\7\1\0\1\7\1\0" + + "\15\7\1\u02bf\13\7\11\0\2\7\1\0\1\7\1\0" + + "\12\7\1\u02c0\16\7\11\0\2\7\1\0\1\7\1\0" + + "\15\7\1\u02c1\13\7\11\0\2\7\1\0\1\7\1\0" + + "\13\7\1\u02c2\15\7\11\0\2\7\1\0\1\7\1\0" + + "\6\7\1\u02c3\22\7\11\0\2\7\1\0\1\7\1\0" + + "\6\7\1\u02c4\22\7\11\0\2\7\1\0\1\7\1\0" + + "\12\7\1\u02c5\16\7\11\0\2\7\1\0\1\7\1\0" + + "\12\7\1\u02c6\16\7\11\0\2\7\1\0\1\7\1\0" + + "\25\7\1\u02c7\3\7\11\0\2\7\1\0\1\7\1\0" + + "\11\7\1\u02c8\17\7\11\0\2\7\1\0\1\7\1\0" + + "\6\7\1\u02c9\22\7\11\0\2\7\1\0\1\7\1\0" + + "\2\7\1\u02ca\26\7\11\0\2\7\1\0\1\7\1\0" + + "\1\7\1\u02cb\27\7\11\0\2\7\1\0\1\7\1\0" + + "\1\u02cc\30\7\11\0\2\7\1\0\1\7\1\0\13\7" + + "\1\u02cd\15\7\11\0\2\7\1\0\1\7\1\0\15\7" + + "\1\u02ce\13\7\11\0\2\7\1\0\1\7\1\0\1\u02cf" + + "\30\7\11\0\2\7\1\0\1\7\1\0\1\7\1\u02d0" + + "\27\7\11\0\2\7\1\0\1\7\1\0\21\7\1\u02d1" + + "\7\7\11\0\2\7\1\0\1\7\1\0\17\7\1\u02d2" + + "\11\7\11\0\2\7\1\0\1\7\1\0\11\7\1\u02d3" + + "\17\7\11\0\2\7\1\0\1\7\1\0\1\u02d4\30\7" + + "\11\0\2\7\1\0\1\7\1\0\20\7\1\u02d5\10\7" + + "\11\0\2\7\1\0\1\7\1\0\5\7\1\u02d6\23\7" + + "\11\0\2\7\1\0\1\7\1\0\6\7\1\u02d7\22\7" + + "\11\0\2\7\1\0\1\7\1\0\26\7\1\u02d8\2\7" + + "\11\0\2\7\1\0\1\7\1\0\11\7\1\u02d9\17\7" + + "\11\0\2\7\1\0\1\7\1\0\1\u02da\30\7\11\0" + + "\2\7\1\0\1\7\1\0\2\7\1\u02db\26\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\u02dc\17\7\11\0" + + "\2\7\1\0\1\7\1\0\11\7\1\u02dd\17\7\11\0" + + "\2\7\1\0\1\7\1\0\15\7\1\u02de\13\7\11\0" + + "\2\7\1\0\1\7\1\0\5\7\1\u02df\23\7\11\0" + + "\2\7\1\0\1\7\1\0\1\u02e0\30\7\11\0\2\7" + + "\1\0\1\7\1\0\1\7\1\u02e1\27\7\11\0\2\7" + + "\1\0\1\7\1\0\11\7\1\u02e2\17\7\11\0\2\7" + + "\1\0\1\7\1\0\2\7\1\u02e3\26\7\11\0\2\7" + + "\1\0\1\7\1\0\15\7\1\u02e4\13\7\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\u02e5\23\7\11\0\2\7" + + "\1\0\1\7\1\0\11\7\1\u02e6\17\7\11\0\2\7" + + "\1\0\1\7\1\0\17\7\1\u02e7\11\7\11\0\2\7" + + "\1\0\1\7\1\0\2\7\1\u02e8\26\7\11\0\2\7" + + "\1\0\1\7\1\0\7\7\1\u02e9\21\7\11\0\2\7" + + "\1\0\1\7\1\0\16\7\1\u02ea\12\7\11\0\2\7" + + "\1\0\1\7\1\0\11\7\1\u02eb\17\7\11\0\2\7" + + "\1\0\1\7\1\0\2\7\1\u02ec\26\7\11\0\2\7" + + "\1\0\1\7\1\0\10\7\1\u02ed\20\7\11\0\2\7" + + "\1\0\1\7\1\0\12\7\1\u02ee\16\7\11\0\2\7" + + "\1\0\1\7\1\0\12\7\1\u02ef\16\7\11\0\2\7" + + "\1\0\1\7\1\0\15\7\1\u02f0\13\7\11\0\2\7" + + "\1\0\1\7\1\0\2\7\1\u02f1\26\7\11\0\2\7" + + "\1\0\1\7\1\0\20\7\1\u02f2\10\7\11\0\2\7" + + "\1\0\1\7\1\0\7\7\1\u02f3\21\7\11\0\2\7" + + "\1\0\1\7\1\0\6\7\1\u02f4\22\7\11\0\2\7" + + "\1\0\1\7\1\0\16\7\1\u02f5\12\7\11\0\2\7" + + "\1\0\1\7\1\0\12\7\1\u02f6\16\7\11\0\2\7" + + "\1\0\1\7\1\0\13\7\1\u02f7\15\7\11\0\2\7" + + "\1\0\1\7\1\0\6\7\1\u02f8\22\7\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\u02f9\23\7\11\0\2\7" + + "\1\0\1\7\1\0\1\7\1\u02fa\27\7\11\0\2\7" + + "\1\0\1\7\1\0\14\7\1\u02fb\14\7\11\0\2\7" + + "\1\0\1\7\1\0\7\7\1\u02fc\21\7\11\0\2\7" + + "\1\0\1\7\1\0\3\7\1\u02fd\25\7\11\0\2\7" + + "\1\0\1\7\1\0\12\7\1\u02fe\16\7\11\0\2\7" + + "\1\0\1\7\1\0\5\7\1\u02ff\23\7\11\0\2\7" + + "\1\0\1\7\1\0\1\u0300\30\7\11\0\2\7\1\0" + + "\1\7\1\0\1\u0301\30\7\11\0\2\7\1\0\1\7" + + "\1\0\15\7\1\u0302\13\7\11\0\2\7\1\0\1\7" + + "\1\0\2\7\1\u0303\26\7\11\0\2\7\1\0\1\7" + + "\1\0\6\7\1\u0304\22\7\11\0\2\7\1\0\1\7" + + "\1\0\3\7\1\u0305\25\7\11\0\2\7\1\0\1\7" + + "\1\0\1\u0306\30\7\11\0\2\7\1\0\1\7\1\0" + + "\2\7\1\u0307\26\7\11\0\2\7\1\0\1\7\1\0" + + "\11\7\1\u0308\17\7\11\0\2\7\1\0\1\7\1\0" + + "\13\7\1\u0309\15\7\11\0\2\7\1\0\1\7\1\0" + + "\2\7\1\u030a\26\7\11\0\2\7\1\0\1\7\1\0" + + "\11\7\1\u030b\17\7\11\0\2\7\1\0\1\7\1\0" + + "\12\7\1\u030c\16\7\11\0\2\7\1\0\1\7\1\0" + + "\1\u030d\30\7\11\0\2\7\1\0\1\7\1\0\21\7" + + "\1\u030e\7\7\11\0\2\7\1\0\1\7\1\0\17\7" + + "\1\u030f\11\7\11\0\2\7\1\0\1\7\1\0\10\7" + + "\1\u0310\20\7\11\0\2\7\1\0\1\7\1\0\6\7" + + "\1\u0311\22\7\11\0\2\7\1\0\1\7\1\0\12\7" + + "\1\u0312\16\7\11\0\2\7\1\0\1\7\1\0\21\7" + + "\1\u0313\7\7\11\0\2\7\1\0\1\7\1\0\3\7" + + "\1\u0314\25\7\11\0\2\7\1\0\1\7\1\0\13\7" + + "\1\u0315\15\7\11\0\2\7\1\0\1\7\1\0\1\u0316" + + "\30\7\11\0\2\7\1\0\1\7\1\0\5\7\1\u0317" + + "\23\7\11\0\2\7\1\0\1\7\1\0\7\7\1\u0318" + + "\21\7\11\0\2\7\1\0\1\7\1\0\14\7\1\u0319" + + "\14\7\11\0\2\7\1\0\1\7\1\0\12\7\1\u031a" + + "\16\7\11\0\2\7\1\0\1\7\1\0\1\u031b\30\7" + + "\11\0\2\7\1\0\1\7\1\0\6\7\1\u031c\22\7" + + "\2\0"; + /** + * The transition table of the DFA + */ + private static final int[] ZZ_TRANS = zzUnpackTrans(); + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\1\0\1\11\1\1\1\11\33\1\2\11\4\0\55\1" + + "\2\0\2\1\1\0\1\11\65\1\1\0\u028e\1"; + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState + */ + private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute(); + /** + * the input device + */ + private java.io.Reader zzReader; + /** + * the current state of the DFA + */ + private int zzState; + /** + * the current lexical state + */ + private int zzLexicalState = YYINITIAL; + /** + * this buffer contains the current text to be matched and is + * the source of the yytext() string + */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + /** + * the textposition at the last accepting state + */ + private int zzMarkedPos; + /** + * the textposition at the last state to be included in yytext + */ + private int zzPushbackPos; + /** + * the current text position in the buffer + */ + private int zzCurrentPos; + /** + * startRead marks the beginning of the yytext() string in the buffer + */ + private int zzStartRead; + /** + * endRead marks the last character in the buffer, that has been read + * from input + */ + private int zzEndRead; + /** + * number of newlines encountered up to the start of the matched text + */ + private int yyline; + /** + * the number of characters up to the start of the matched text + */ + private int yychar; + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + /** + * zzAtEOF == true <=> the scanner is at the EOF + */ + private boolean zzAtEOF; + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + GUIDefaultsScanner(java.io.Reader in) { + this.zzReader = in; } - return j; - } - - /** - * Translates a state to a row index in the transition table - */ - private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); - - private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\47\0\116\0\47\0\165\0\234\0\303\0\352"+ - "\0\u0111\0\u0138\0\u015f\0\u0186\0\u01ad\0\u01d4\0\u01fb\0\u0222"+ - "\0\u0249\0\u0270\0\u0297\0\u02be\0\u02e5\0\u030c\0\u0333\0\u035a"+ - "\0\u0381\0\u03a8\0\u03cf\0\u03f6\0\u041d\0\u0444\0\u046b\0\47"+ - "\0\47\0\u0492\0\234\0\u04b9\0\u04e0\0\u0138\0\u0507\0\u052e"+ - "\0\u0555\0\u057c\0\u05a3\0\u05ca\0\u05f1\0\u0618\0\u063f\0\u0666"+ - "\0\u068d\0\u06b4\0\u06db\0\u0702\0\u0729\0\u0750\0\u0777\0\u079e"+ - "\0\u07c5\0\u07ec\0\u0813\0\u083a\0\u0861\0\u0888\0\303\0\u08af"+ - "\0\u08d6\0\u08fd\0\u0924\0\u094b\0\u0972\0\u0999\0\u09c0\0\u09e7"+ - "\0\u0a0e\0\u0a35\0\u0a5c\0\u0a83\0\u0aaa\0\u0ad1\0\u0af8\0\u0b1f"+ - "\0\u0b46\0\u0b6d\0\u0b94\0\u0bbb\0\u0be2\0\u0c09\0\u0c30\0\47"+ - "\0\u0c57\0\u0c7e\0\u0ca5\0\u0ccc\0\u0cf3\0\u0d1a\0\u0d41\0\u0d68"+ - "\0\u0d8f\0\u0db6\0\u0ddd\0\u0e04\0\u0e2b\0\u0e52\0\u0e79\0\u0ea0"+ - "\0\u0ec7\0\u0eee\0\u0f15\0\u0f3c\0\u0f63\0\u0f8a\0\u0fb1\0\u0fd8"+ - "\0\u0fff\0\u1026\0\u104d\0\u1074\0\u109b\0\u10c2\0\303\0\u10e9"+ - "\0\u1110\0\u1137\0\u115e\0\u1185\0\u11ac\0\u11d3\0\u11fa\0\u1221"+ - "\0\u1248\0\u126f\0\u1296\0\u12bd\0\u12e4\0\u130b\0\u1332\0\u1359"+ - "\0\u1380\0\u13a7\0\u13ce\0\u13f5\0\u141c\0\u1443\0\u146a\0\u1491"+ - "\0\u14b8\0\u14df\0\u1506\0\u152d\0\u1554\0\303\0\u157b\0\u15a2"+ - "\0\u15c9\0\u15f0\0\u1617\0\u163e\0\u1665\0\u168c\0\u16b3\0\u16da"+ - "\0\u1701\0\u1728\0\u174f\0\u1776\0\u179d\0\303\0\u17c4\0\u17eb"+ - "\0\u1812\0\u1839\0\u1860\0\u1887\0\u18ae\0\u18d5\0\u18fc\0\u1923"+ - "\0\u194a\0\u1971\0\u1998\0\u19bf\0\u19e6\0\u1a0d\0\u1a34\0\u1a5b"+ - "\0\u1a82\0\u1aa9\0\u1ad0\0\u1af7\0\u1b1e\0\u1b45\0\303\0\u1b6c"+ - "\0\u1b93\0\u1bba\0\u1be1\0\u1c08\0\u1c2f\0\u1c56\0\u1c7d\0\u1ca4"+ - "\0\u1ccb\0\u1cf2\0\u1d19\0\u1d40\0\u1d67\0\u1d8e\0\u1db5\0\u1ddc"+ - "\0\u1e03\0\u1e2a\0\u1e51\0\u1e78\0\u1e9f\0\u1ec6\0\u1eed\0\u1f14"+ - "\0\u1f3b\0\u1f62\0\u1f89\0\u1fb0\0\u1fd7\0\u1ffe\0\u2025\0\u204c"+ - "\0\u2073\0\u209a\0\u20c1\0\u20e8\0\u210f\0\u2136\0\u215d\0\u2184"+ - "\0\u21ab\0\u21d2\0\u21f9\0\u2220\0\u2247\0\u226e\0\u2295\0\u22bc"+ - "\0\u22e3\0\u230a\0\u2331\0\u2358\0\u237f\0\u23a6\0\u23cd\0\u23f4"+ - "\0\u241b\0\u2442\0\u2469\0\u2490\0\u24b7\0\u24de\0\u2505\0\u252c"+ - "\0\u2553\0\u257a\0\u25a1\0\u25c8\0\u25ef\0\u2616\0\u263d\0\u2664"+ - "\0\u268b\0\u26b2\0\u26d9\0\u2700\0\303\0\u2727\0\u274e\0\u2775"+ - "\0\u279c\0\303\0\u27c3\0\u27ea\0\u2811\0\u2838\0\u285f\0\u2886"+ - "\0\u28ad\0\u28d4\0\u28fb\0\u2922\0\303\0\u2949\0\u2970\0\u2997"+ - "\0\u29be\0\u29e5\0\u2a0c\0\u2a33\0\u2a5a\0\u2a81\0\u2aa8\0\u2acf"+ - "\0\u2af6\0\u2b1d\0\u2b44\0\u2b6b\0\u2b92\0\u2bb9\0\u2be0\0\u2c07"+ - "\0\u2c2e\0\u2c55\0\u2c7c\0\u2ca3\0\u2cca\0\u2cf1\0\u2d18\0\303"+ - "\0\u2d3f\0\u2d66\0\u2d8d\0\u2db4\0\u2ddb\0\u2e02\0\u2e29\0\u2e50"+ - "\0\u2e77\0\u2e9e\0\u2ec5\0\u2eec\0\u2f13\0\u2f3a\0\u2f61\0\u2f88"+ - "\0\u2faf\0\u2fd6\0\u2ffd\0\u3024\0\303\0\u304b\0\303\0\u3072"+ - "\0\u3099\0\u30c0\0\u30e7\0\u310e\0\u3135\0\u315c\0\u3183\0\u31aa"+ - "\0\u31d1\0\303\0\303\0\u31f8\0\u321f\0\u3246\0\u326d\0\u3294"+ - "\0\u32bb\0\u32e2\0\u3309\0\u3330\0\303\0\u3357\0\u337e\0\u33a5"+ - "\0\u33cc\0\u33f3\0\u341a\0\u3441\0\u3468\0\u348f\0\u34b6\0\u34dd"+ - "\0\u3504\0\u352b\0\u3552\0\u3579\0\u35a0\0\u35c7\0\u35ee\0\u3615"+ - "\0\u363c\0\u3663\0\u368a\0\u36b1\0\303\0\u36d8\0\u36ff\0\u3726"+ - "\0\u374d\0\u3774\0\u379b\0\u37c2\0\u37e9\0\u3810\0\u3837\0\u385e"+ - "\0\u3885\0\u38ac\0\u38d3\0\u38fa\0\u3921\0\u3948\0\u396f\0\u3996"+ - "\0\u39bd\0\u39e4\0\u3a0b\0\u3a32\0\u3a59\0\u3a80\0\u3aa7\0\u3ace"+ - "\0\303\0\u3af5\0\u3b1c\0\u3b43\0\u3b6a\0\u3b91\0\u3bb8\0\u3bdf"+ - "\0\303\0\u3c06\0\u3c2d\0\u3c54\0\u3c7b\0\u3ca2\0\u3cc9\0\u3cf0"+ - "\0\u3d17\0\303\0\303\0\u3d3e\0\u3d65\0\u3d8c\0\u3db3\0\u3dda"+ - "\0\u3e01\0\u3e28\0\u3e4f\0\u3e76\0\u3e9d\0\u3ec4\0\u3eeb\0\u3f12"+ - "\0\u3f39\0\u3f60\0\u3f87\0\u3fae\0\u3fd5\0\u3ffc\0\u4023\0\u404a"+ - "\0\u4071\0\u4098\0\u40bf\0\u40e6\0\u410d\0\u4134\0\303\0\u415b"+ - "\0\u4182\0\u41a9\0\u41d0\0\u41f7\0\u421e\0\u4245\0\u426c\0\u4293"+ - "\0\u42ba\0\u42e1\0\u4308\0\u432f\0\u4356\0\u437d\0\u43a4\0\u43cb"+ - "\0\u43f2\0\u4419\0\u4440\0\u4467\0\303\0\u448e\0\u44b5\0\u44dc"+ - "\0\u4503\0\u452a\0\303\0\u4551\0\u4578\0\u459f\0\u45c6\0\u45ed"+ - "\0\u4614\0\u463b\0\u4662\0\u4689\0\u46b0\0\303\0\u46d7\0\u46fe"+ - "\0\u4725\0\u474c\0\u4773\0\303\0\u479a\0\u47c1\0\u47e8\0\u480f"+ - "\0\u4836\0\u485d\0\u4884\0\u48ab\0\303\0\u48d2\0\u48f9\0\u4920"+ - "\0\u4947\0\u496e\0\303\0\u4995\0\u49bc\0\u49e3\0\u4a0a\0\u4a31"+ - "\0\u4a58\0\u4a7f\0\u4aa6\0\303\0\u4acd\0\u4af4\0\303\0\u4b1b"+ - "\0\u4b42\0\u4b69\0\u4b90\0\u4bb7\0\u4bde\0\u4c05\0\u4c2c\0\u4c53"+ - "\0\u4c7a\0\u4ca1\0\u4cc8\0\u4cef\0\u4d16\0\u4d3d\0\u4d64\0\u4d8b"+ - "\0\u4db2\0\u4dd9\0\u4e00\0\u4e27\0\u4e4e\0\u4e75\0\u4e9c\0\u4ec3"+ - "\0\u4eea\0\u4f11\0\u4f38\0\u4f5f\0\u4f86\0\u4fad\0\u4fd4\0\u4ffb"+ - "\0\u5022\0\u5049\0\u5070\0\u5097\0\u50be\0\u50e5\0\u510c\0\u5133"+ - "\0\303\0\u515a\0\u5181\0\u51a8\0\u51cf\0\u51f6\0\u521d\0\u5244"+ - "\0\303\0\u526b\0\u5292\0\u52b9\0\u52e0\0\303\0\u5307\0\u532e"+ - "\0\u5355\0\u537c\0\u53a3\0\u53ca\0\u53f1\0\u5418\0\u543f\0\303"+ - "\0\u5466\0\303\0\u548d\0\u54b4\0\u54db\0\u5502\0\u5529\0\u5550"+ - "\0\u5577\0\u559e\0\u55c5\0\u55ec\0\u5613\0\u563a\0\u5661\0\u5688"+ - "\0\u56af\0\u56d6\0\u56fd\0\u5724\0\303\0\303\0\u574b\0\303"+ - "\0\u5772\0\u5799\0\303\0\u57c0\0\u57e7\0\u580e\0\u5835\0\303"+ - "\0\303\0\u585c\0\u5883\0\u58aa\0\u58d1\0\u58f8\0\u591f\0\u5946"+ - "\0\u596d\0\u5994\0\303\0\u59bb\0\u59e2\0\u5a09\0\u5a30\0\303"+ - "\0\u5a57\0\u5a7e\0\u5aa5\0\u5acc\0\u5af3\0\u5b1a\0\u5b41\0\u5b68"+ - "\0\u5b8f\0\u5bb6\0\u5bdd\0\u5c04\0\303\0\u5c2b\0\u5c52\0\u5c79"+ - "\0\303\0\u5ca0\0\u5cc7\0\303\0\303\0\303\0\u5cee\0\u5d15"+ - "\0\303\0\u5d3c\0\u5d63\0\u5d8a\0\u5db1\0\u5dd8\0\u5dff\0\u5e26"+ - "\0\u5e4d\0\u5e74\0\303\0\u5e9b\0\u5ec2\0\303\0\u5ee9\0\u5f10"+ - "\0\u5f37\0\u5f5e\0\u5f85\0\u5fac\0\303\0\u5fd3\0\u5ffa\0\u6021"+ - "\0\u6048\0\303\0\u606f\0\u6096\0\u60bd\0\u60e4\0\u610b\0\u6132"+ - "\0\u6159\0\u6180\0\303\0\u61a7\0\303\0\u61ce\0\u61f5\0\u621c"+ - "\0\303\0\303\0\303\0\303\0\u6243\0\u626a\0\303\0\u6291"+ - "\0\u62b8\0\u62df\0\u6306\0\303\0\u632d\0\u6354\0\u637b\0\u63a2"+ - "\0\u63c9\0\u63f0\0\u6417\0\303\0\303\0\u643e\0\u6465\0\u648c"+ - "\0\u64b3\0\u64da\0\u6501\0\303\0\u6528\0\u654f\0\u6576\0\u659d"+ - "\0\u65c4\0\u65eb\0\u6612\0\u6639\0\u6660\0\u6687\0\u66ae\0\u66d5"+ - "\0\u66fc\0\u6723\0\u674a\0\u6771\0\u6798\0\u67bf\0\u67e6\0\u680d"+ - "\0\u6834\0\303\0\u685b\0\u6882\0\u68a9\0\u68d0\0\u68f7\0\303"+ - "\0\u691e\0\u6945\0\u696c\0\u6993\0\u69ba\0\u69e1\0\u6a08\0\u6a2f"+ - "\0\u6a56\0\u6a7d\0\u6aa4\0\303\0\u6acb\0\u6af2\0\u6b19\0\u6b40"+ - "\0\303\0\u6b67\0\303\0\u6b8e\0\u6bb5\0\303\0\u6bdc\0\303"+ - "\0\303\0\u6c03\0\303\0\u6c2a\0\u6c51\0\303\0\u6c78\0\u6c9f"+ - "\0\u6cc6\0\u6ced\0\u6d14\0\303"; - - private static int [] zzUnpackRowMap() { - int [] result = new int[796]; - int offset = 0; - offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackRowMap(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int high = packed.charAt(i++) << 16; - result[j++] = high | packed.charAt(i++); + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + GUIDefaultsScanner(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); } - return j; - } - - /** - * The transition table of the DFA - */ - private static final int [] ZZ_TRANS = zzUnpackTrans(); - private static final String ZZ_TRANS_PACKED_0 = - "\1\2\1\3\2\4\1\5\1\2\1\6\1\7\1\10"+ - "\1\11\1\12\1\2\1\13\1\7\1\14\1\15\1\16"+ - "\1\17\1\20\1\21\1\22\1\23\1\24\1\25\1\26"+ - "\1\27\1\30\1\31\1\7\1\32\1\33\1\34\1\35"+ - "\1\7\1\36\1\7\1\37\1\40\1\41\51\0\1\4"+ - "\51\0\1\42\41\0\1\43\1\3\1\4\44\43\7\0"+ - "\2\7\1\0\1\7\1\0\31\7\12\0\1\10\1\0"+ - "\1\10\1\44\1\45\42\0\1\10\1\0\1\12\44\0"+ - "\1\46\1\0\1\46\1\44\1\45\41\0\2\7\1\0"+ - "\1\7\1\0\21\7\1\47\7\7\11\0\2\7\1\0"+ - "\1\7\1\0\3\7\1\50\2\7\1\51\5\7\1\52"+ - "\14\7\11\0\2\7\1\0\1\7\1\0\1\53\1\7"+ - "\1\54\26\7\11\0\2\7\1\0\1\7\1\0\5\7"+ - "\1\55\23\7\11\0\2\7\1\0\1\7\1\0\10\7"+ - "\1\56\1\57\17\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\60\10\7\1\61\1\62\13\7\1\63\2\7\11\0"+ - "\2\7\1\0\1\7\1\0\2\7\1\64\12\7\1\65"+ - "\13\7\11\0\2\7\1\0\1\7\1\0\14\7\1\66"+ - "\14\7\11\0\2\7\1\0\1\7\1\0\1\67\4\7"+ - "\1\70\7\7\1\71\13\7\11\0\2\7\1\0\1\7"+ - "\1\0\13\7\1\72\15\7\11\0\2\7\1\0\1\7"+ - "\1\0\14\7\1\73\1\74\13\7\11\0\2\7\1\0"+ - "\1\7\1\0\11\7\1\75\17\7\11\0\2\7\1\0"+ - "\1\7\1\0\7\7\1\76\1\7\1\77\2\7\1\100"+ - "\6\7\1\101\5\7\11\0\2\7\1\0\1\7\1\0"+ - "\2\7\1\102\12\7\1\103\13\7\11\0\2\7\1\0"+ - "\1\7\1\0\3\7\1\104\10\7\1\105\1\106\13\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\107\4\7\1\110"+ - "\5\7\1\111\4\7\1\112\10\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\113\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\5\7\1\114\7\7\1\115\13\7\11\0\2\7"+ - "\1\0\1\7\1\0\2\7\1\116\2\7\1\117\6\7"+ - "\1\120\14\7\11\0\2\7\1\0\1\7\1\0\5\7"+ - "\1\121\23\7\11\0\2\7\1\0\1\7\1\0\5\7"+ - "\1\122\23\7\2\0\5\123\1\124\41\123\10\0\1\125"+ - "\1\0\1\125\44\0\1\126\1\127\1\130\43\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\131\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\3\7\1\132\25\7\11\0\2\7"+ - "\1\0\1\7\1\0\6\7\1\133\22\7\11\0\2\7"+ - "\1\0\1\7\1\0\12\7\1\134\16\7\11\0\2\7"+ - "\1\0\1\7\1\0\11\7\1\135\17\7\11\0\2\7"+ - "\1\0\1\7\1\0\20\7\1\136\10\7\11\0\2\7"+ - "\1\0\1\7\1\0\2\7\1\137\3\7\1\140\6\7"+ - "\1\141\13\7\11\0\2\7\1\0\1\7\1\0\11\7"+ - "\1\142\17\7\11\0\2\7\1\0\1\7\1\0\12\7"+ - "\1\143\4\7\1\144\11\7\11\0\2\7\1\0\1\7"+ - "\1\0\3\7\1\145\25\7\11\0\2\7\1\0\1\7"+ - "\1\0\2\7\1\146\26\7\11\0\2\7\1\0\1\7"+ - "\1\0\5\7\1\147\23\7\11\0\2\7\1\0\1\7"+ - "\1\0\15\7\1\150\13\7\11\0\2\7\1\0\1\7"+ - "\1\0\17\7\1\151\11\7\11\0\2\7\1\0\1\7"+ - "\1\0\2\7\1\152\11\7\1\153\14\7\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\154\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\12\7\1\155\16\7\11\0\2\7"+ - "\1\0\1\7\1\0\11\7\1\156\17\7\11\0\2\7"+ - "\1\0\1\7\1\0\11\7\1\157\1\160\16\7\11\0"+ - "\2\7\1\0\1\7\1\0\2\7\1\161\26\7\11\0"+ - "\2\7\1\0\1\7\1\0\3\7\1\162\25\7\11\0"+ - "\2\7\1\0\1\7\1\0\14\7\1\163\14\7\11\0"+ - "\2\7\1\0\1\7\1\0\23\7\1\164\5\7\11\0"+ - "\2\7\1\0\1\7\1\0\27\7\1\165\1\7\11\0"+ - "\2\7\1\0\1\7\1\0\12\7\1\166\16\7\11\0"+ - "\2\7\1\0\1\7\1\0\23\7\1\167\5\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\170\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\4\7\1\171\24\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\172\30\7\11\0\2\7"+ - "\1\0\1\7\1\0\13\7\1\173\15\7\11\0\2\7"+ - "\1\0\1\7\1\0\3\7\1\174\5\7\1\175\4\7"+ - "\1\176\12\7\11\0\2\7\1\0\1\7\1\0\6\7"+ - "\1\177\22\7\11\0\2\7\1\0\1\7\1\0\6\7"+ - "\1\200\22\7\11\0\2\7\1\0\1\7\1\0\2\7"+ - "\1\201\26\7\11\0\2\7\1\0\1\7\1\0\11\7"+ - "\1\202\17\7\11\0\2\7\1\0\1\7\1\0\1\203"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\25\7\1\204"+ - "\3\7\11\0\2\7\1\0\1\7\1\0\13\7\1\205"+ - "\15\7\11\0\2\7\1\0\1\7\1\0\13\7\1\206"+ - "\3\7\1\207\1\7\1\210\7\7\11\0\2\7\1\0"+ - "\1\7\1\0\11\7\1\211\17\7\11\0\2\7\1\0"+ - "\1\7\1\0\3\7\1\212\2\7\1\213\22\7\11\0"+ - "\2\7\1\0\1\7\1\0\3\7\1\214\25\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\215\17\7\2\0"+ - "\5\123\1\216\41\123\4\0\1\4\1\124\51\0\1\125"+ - "\1\0\1\125\1\0\1\45\42\0\1\126\1\0\1\126"+ - "\44\0\1\126\1\0\1\130\43\0\2\7\1\0\1\7"+ - "\1\0\12\7\1\217\16\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\7\1\220\27\7\11\0\2\7\1\0\1\7"+ - "\1\0\5\7\1\221\23\7\11\0\2\7\1\0\1\7"+ - "\1\0\15\7\1\222\13\7\11\0\2\7\1\0\1\7"+ - "\1\0\10\7\1\223\20\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\224\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\225\4\7\1\226\22\7\11\0\2\7\1\0"+ - "\1\7\1\0\5\7\1\227\23\7\11\0\2\7\1\0"+ - "\1\7\1\0\3\7\1\230\25\7\11\0\2\7\1\0"+ - "\1\7\1\0\15\7\1\231\13\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\232\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\15\7\1\233\13\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\234\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\24\7\1\235\4\7\11\0\2\7\1\0\1\7\1\0"+ - "\12\7\1\236\16\7\11\0\2\7\1\0\1\7\1\0"+ - "\4\7\1\237\24\7\11\0\2\7\1\0\1\7\1\0"+ - "\22\7\1\240\6\7\11\0\2\7\1\0\1\7\1\0"+ - "\13\7\1\241\15\7\11\0\2\7\1\0\1\7\1\0"+ - "\11\7\1\242\17\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\243\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\244\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\245\30\7\11\0\2\7\1\0\1\7\1\0\1\246"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\1\7\1\247"+ - "\27\7\11\0\2\7\1\0\1\7\1\0\17\7\1\250"+ - "\11\7\11\0\2\7\1\0\1\7\1\0\1\251\30\7"+ - "\11\0\2\7\1\0\1\7\1\0\12\7\1\252\16\7"+ - "\11\0\2\7\1\0\1\7\1\0\5\7\1\253\23\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\254\30\7\11\0"+ - "\2\7\1\0\1\7\1\0\3\7\1\255\25\7\11\0"+ - "\2\7\1\0\1\7\1\0\14\7\1\256\14\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\257\30\7\11\0\2\7"+ - "\1\0\1\7\1\0\2\7\1\260\26\7\11\0\2\7"+ - "\1\0\1\7\1\0\13\7\1\261\15\7\11\0\2\7"+ - "\1\0\1\7\1\0\15\7\1\262\13\7\11\0\2\7"+ - "\1\0\1\7\1\0\21\7\1\263\7\7\11\0\2\7"+ - "\1\0\1\7\1\0\24\7\1\264\4\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\265\30\7\11\0\2\7\1\0"+ - "\1\7\1\0\24\7\1\266\4\7\11\0\2\7\1\0"+ - "\1\7\1\0\10\7\1\267\20\7\11\0\2\7\1\0"+ - "\1\7\1\0\2\7\1\270\26\7\11\0\2\7\1\0"+ - "\1\7\1\0\24\7\1\271\4\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\272\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\12\7\1\273\16\7\11\0\2\7\1\0\1\7"+ - "\1\0\2\7\1\274\26\7\11\0\2\7\1\0\1\7"+ - "\1\0\22\7\1\275\6\7\11\0\2\7\1\0\1\7"+ - "\1\0\6\7\1\276\22\7\11\0\2\7\1\0\1\7"+ - "\1\0\6\7\1\277\22\7\11\0\2\7\1\0\1\7"+ - "\1\0\3\7\1\300\25\7\11\0\2\7\1\0\1\7"+ - "\1\0\26\7\1\301\2\7\11\0\2\7\1\0\1\7"+ - "\1\0\5\7\1\302\23\7\11\0\2\7\1\0\1\7"+ - "\1\0\21\7\1\303\7\7\2\0\4\123\1\4\1\216"+ - "\41\123\7\0\2\7\1\0\1\7\1\0\1\7\1\304"+ - "\27\7\11\0\2\7\1\0\1\7\1\0\4\7\1\305"+ - "\24\7\11\0\2\7\1\0\1\7\1\0\10\7\1\306"+ - "\20\7\11\0\2\7\1\0\1\7\1\0\16\7\1\307"+ - "\12\7\11\0\2\7\1\0\1\7\1\0\12\7\1\310"+ - "\16\7\11\0\2\7\1\0\1\7\1\0\13\7\1\311"+ - "\15\7\11\0\2\7\1\0\1\7\1\0\6\7\1\312"+ - "\4\7\1\313\6\7\1\314\6\7\11\0\2\7\1\0"+ - "\1\7\1\0\7\7\1\315\21\7\11\0\2\7\1\0"+ - "\1\7\1\0\2\7\1\316\26\7\11\0\2\7\1\0"+ - "\1\7\1\0\13\7\1\317\15\7\11\0\2\7\1\0"+ - "\1\7\1\0\13\7\1\320\15\7\11\0\2\7\1\0"+ - "\1\7\1\0\16\7\1\321\12\7\11\0\2\7\1\0"+ - "\1\7\1\0\17\7\1\322\11\7\11\0\2\7\1\0"+ - "\1\7\1\0\6\7\1\323\22\7\11\0\2\7\1\0"+ - "\1\7\1\0\17\7\1\324\11\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\325\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\10\7\1\326\20\7\11\0\2\7\1\0\1\7"+ - "\1\0\21\7\1\327\7\7\11\0\2\7\1\0\1\7"+ - "\1\0\21\7\1\330\7\7\11\0\2\7\1\0\1\7"+ - "\1\0\21\7\1\331\7\7\11\0\2\7\1\0\1\7"+ - "\1\0\5\7\1\332\23\7\11\0\2\7\1\0\1\7"+ - "\1\0\12\7\1\333\16\7\11\0\2\7\1\0\1\7"+ - "\1\0\4\7\1\334\24\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\335\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\336\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\337\30\7\11\0\2\7\1\0\1\7\1\0\25\7"+ - "\1\340\3\7\11\0\2\7\1\0\1\7\1\0\17\7"+ - "\1\341\11\7\11\0\2\7\1\0\1\7\1\0\5\7"+ - "\1\342\23\7\11\0\2\7\1\0\1\7\1\0\2\7"+ - "\1\343\26\7\11\0\2\7\1\0\1\7\1\0\1\7"+ - "\1\344\27\7\11\0\2\7\1\0\1\7\1\0\13\7"+ - "\1\345\15\7\11\0\2\7\1\0\1\7\1\0\1\346"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\13\7\1\347"+ - "\15\7\11\0\2\7\1\0\1\7\1\0\14\7\1\350"+ - "\14\7\11\0\2\7\1\0\1\7\1\0\15\7\1\351"+ - "\13\7\11\0\2\7\1\0\1\7\1\0\3\7\1\352"+ - "\25\7\11\0\2\7\1\0\1\7\1\0\3\7\1\353"+ - "\25\7\11\0\2\7\1\0\1\7\1\0\1\7\1\354"+ - "\27\7\11\0\2\7\1\0\1\7\1\0\16\7\1\355"+ - "\12\7\11\0\2\7\1\0\1\7\1\0\15\7\1\356"+ - "\13\7\11\0\2\7\1\0\1\7\1\0\21\7\1\357"+ - "\7\7\11\0\2\7\1\0\1\7\1\0\20\7\1\360"+ - "\10\7\11\0\2\7\1\0\1\7\1\0\16\7\1\361"+ - "\12\7\11\0\2\7\1\0\1\7\1\0\2\7\1\362"+ - "\26\7\11\0\2\7\1\0\1\7\1\0\12\7\1\363"+ - "\16\7\11\0\2\7\1\0\1\7\1\0\1\7\1\364"+ - "\27\7\11\0\2\7\1\0\1\7\1\0\1\7\1\365"+ - "\27\7\11\0\2\7\1\0\1\7\1\0\10\7\1\366"+ - "\20\7\11\0\2\7\1\0\1\7\1\0\15\7\1\367"+ - "\13\7\11\0\2\7\1\0\1\7\1\0\4\7\1\370"+ - "\4\7\1\371\17\7\11\0\2\7\1\0\1\7\1\0"+ - "\5\7\1\372\23\7\11\0\2\7\1\0\1\7\1\0"+ - "\11\7\1\373\17\7\11\0\2\7\1\0\1\7\1\0"+ - "\2\7\1\374\26\7\11\0\2\7\1\0\1\7\1\0"+ - "\26\7\1\375\2\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\376\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\11\7\1\377\17\7\11\0\2\7\1\0\1\7\1\0"+ - "\14\7\1\u0100\14\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\u0101\30\7\11\0\2\7\1\0\1\7\1\0\3\7"+ - "\1\u0102\25\7\11\0\2\7\1\0\1\7\1\0\12\7"+ - "\1\u0103\16\7\11\0\2\7\1\0\1\7\1\0\1\u0104"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\2\7\1\u0105"+ - "\26\7\11\0\2\7\1\0\1\7\1\0\24\7\1\u0106"+ - "\4\7\11\0\2\7\1\0\1\7\1\0\12\7\1\u0107"+ - "\16\7\11\0\2\7\1\0\1\7\1\0\26\7\1\u0108"+ - "\2\7\11\0\2\7\1\0\1\7\1\0\26\7\1\u0109"+ - "\2\7\11\0\2\7\1\0\1\7\1\0\1\7\1\u010a"+ - "\27\7\11\0\2\7\1\0\1\7\1\0\13\7\1\u010b"+ - "\15\7\11\0\2\7\1\0\1\7\1\0\1\7\1\u010c"+ - "\27\7\11\0\2\7\1\0\1\7\1\0\6\7\1\u010d"+ - "\22\7\11\0\2\7\1\0\1\7\1\0\1\u010e\30\7"+ - "\11\0\2\7\1\0\1\7\1\0\11\7\1\u010f\17\7"+ - "\11\0\2\7\1\0\1\7\1\0\20\7\1\u0110\10\7"+ - "\11\0\2\7\1\0\1\7\1\0\5\7\1\u0111\23\7"+ - "\11\0\2\7\1\0\1\7\1\0\6\7\1\u0112\22\7"+ - "\11\0\2\7\1\0\1\7\1\0\6\7\1\u0113\22\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\7\1\u0114\27\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\u0115\30\7\11\0"+ - "\2\7\1\0\1\7\1\0\12\7\1\u0116\16\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\u0117\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\3\7\1\u0118\25\7\11\0"+ - "\2\7\1\0\1\7\1\0\24\7\1\u0119\4\7\11\0"+ - "\2\7\1\0\1\7\1\0\2\7\1\u011a\26\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\u011b\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\7\1\u011c\4\7\1\u011d"+ - "\22\7\11\0\2\7\1\0\1\7\1\0\17\7\1\u011e"+ - "\11\7\11\0\2\7\1\0\1\7\1\0\11\7\1\u011f"+ - "\17\7\11\0\2\7\1\0\1\7\1\0\1\u0120\30\7"+ - "\11\0\2\7\1\0\1\7\1\0\2\7\1\u0121\26\7"+ - "\11\0\2\7\1\0\1\7\1\0\17\7\1\u0122\11\7"+ - "\11\0\2\7\1\0\1\7\1\0\5\7\1\u0123\23\7"+ - "\11\0\2\7\1\0\1\7\1\0\14\7\1\u0124\14\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\7\1\u0125\27\7"+ - "\11\0\2\7\1\0\1\7\1\0\23\7\1\u0126\5\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\u0127\30\7\11\0"+ - "\2\7\1\0\1\7\1\0\10\7\1\u0128\20\7\11\0"+ - "\2\7\1\0\1\7\1\0\2\7\1\u0129\26\7\11\0"+ - "\2\7\1\0\1\7\1\0\12\7\1\u012a\16\7\11\0"+ - "\2\7\1\0\1\7\1\0\2\7\1\u012b\26\7\11\0"+ - "\2\7\1\0\1\7\1\0\26\7\1\u012c\2\7\11\0"+ - "\2\7\1\0\1\7\1\0\30\7\1\u012d\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\u012e\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\u012f\30\7\11\0\2\7\1\0"+ - "\1\7\1\0\6\7\1\u0130\22\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\7\1\u0131\27\7\11\0\2\7\1\0"+ - "\1\7\1\0\12\7\1\u0132\16\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\7\1\u0133\27\7\11\0\2\7\1\0"+ - "\1\7\1\0\4\7\1\u0134\24\7\11\0\2\7\1\0"+ - "\1\7\1\0\2\7\1\u0135\26\7\11\0\2\7\1\0"+ - "\1\7\1\0\3\7\1\u0136\25\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\u0137\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\u0138\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\5\7\1\u0139\23\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\u013a\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\17\7\1\u013b\11\7\11\0\2\7\1\0\1\7\1\0"+ - "\3\7\1\u013c\25\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\u013d\1\u013e\2\7\1\u013f\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\15\7\1\u0140\13\7\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\u0141\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\u0142\30\7\11\0\2\7\1\0"+ - "\1\7\1\0\15\7\1\u0143\13\7\11\0\2\7\1\0"+ - "\1\7\1\0\23\7\1\u0144\5\7\11\0\2\7\1\0"+ - "\1\7\1\0\23\7\1\u0145\5\7\11\0\2\7\1\0"+ - "\1\7\1\0\23\7\1\u0146\5\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\7\1\u0147\27\7\11\0\2\7\1\0"+ - "\1\7\1\0\6\7\1\u0148\22\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\u0149\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\16\7\1\u014a\2\7\1\u014b\2\7\1\u014c\4\7"+ - "\11\0\2\7\1\0\1\7\1\0\21\7\1\u014d\7\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\7\1\u014e\27\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\u014f\30\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\7\1\u0150\27\7\11\0"+ - "\2\7\1\0\1\7\1\0\2\7\1\u0151\26\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\u0152\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\12\7\1\u0153\16\7\11\0"+ - "\2\7\1\0\1\7\1\0\16\7\1\u0154\12\7\11\0"+ - "\2\7\1\0\1\7\1\0\12\7\1\u0155\16\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\u0156\30\7\11\0\2\7"+ - "\1\0\1\7\1\0\17\7\1\u0157\11\7\11\0\2\7"+ - "\1\0\1\7\1\0\20\7\1\u0158\10\7\11\0\2\7"+ - "\1\0\1\7\1\0\15\7\1\u0159\13\7\11\0\2\7"+ - "\1\0\1\7\1\0\17\7\1\u015a\11\7\11\0\2\7"+ - "\1\0\1\7\1\0\12\7\1\u015b\16\7\11\0\2\7"+ - "\1\0\1\7\1\0\4\7\1\u015c\5\7\1\u015d\16\7"+ - "\11\0\2\7\1\0\1\7\1\0\5\7\1\u015e\23\7"+ - "\11\0\2\7\1\0\1\7\1\0\12\7\1\u015f\16\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\u0160\30\7\11\0"+ - "\2\7\1\0\1\7\1\0\17\7\1\u0161\11\7\11\0"+ - "\2\7\1\0\1\7\1\0\5\7\1\u0162\23\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\u0163\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\12\7\1\u0164\16\7\11\0"+ - "\2\7\1\0\1\7\1\0\6\7\1\u0165\22\7\11\0"+ - "\2\7\1\0\1\7\1\0\2\7\1\u0166\26\7\11\0"+ - "\2\7\1\0\1\7\1\0\12\7\1\u0167\16\7\11\0"+ - "\2\7\1\0\1\7\1\0\5\7\1\u0168\23\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\u0169\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\5\7\1\u016a\23\7\11\0"+ - "\2\7\1\0\1\7\1\0\16\7\1\u016b\12\7\11\0"+ - "\2\7\1\0\1\7\1\0\5\7\1\u016c\23\7\11\0"+ - "\2\7\1\0\1\7\1\0\24\7\1\u016d\4\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\u016e\30\7\11\0\2\7"+ - "\1\0\1\7\1\0\24\7\1\u016f\4\7\11\0\2\7"+ - "\1\0\1\7\1\0\15\7\1\u0170\13\7\11\0\2\7"+ - "\1\0\1\7\1\0\17\7\1\u0171\11\7\11\0\2\7"+ - "\1\0\1\7\1\0\12\7\1\u0172\16\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\u0173\30\7\11\0\2\7\1\0"+ - "\1\7\1\0\24\7\1\u0174\4\7\11\0\2\7\1\0"+ - "\1\7\1\0\7\7\1\u0175\21\7\11\0\2\7\1\0"+ - "\1\7\1\0\15\7\1\u0176\13\7\11\0\2\7\1\0"+ - "\1\7\1\0\12\7\1\u0177\16\7\11\0\2\7\1\0"+ - "\1\7\1\0\11\7\1\u0178\17\7\11\0\2\7\1\0"+ - "\1\7\1\0\11\7\1\u0179\17\7\11\0\2\7\1\0"+ - "\1\7\1\0\14\7\1\u017a\14\7\11\0\2\7\1\0"+ - "\1\7\1\0\13\7\1\u017b\15\7\11\0\2\7\1\0"+ - "\1\7\1\0\2\7\1\u017c\26\7\11\0\2\7\1\0"+ - "\1\7\1\0\15\7\1\u017d\13\7\11\0\2\7\1\0"+ - "\1\7\1\0\21\7\1\u017e\7\7\11\0\2\7\1\0"+ - "\1\7\1\0\5\7\1\u017f\23\7\11\0\2\7\1\0"+ - "\1\7\1\0\3\7\1\u0180\25\7\11\0\2\7\1\0"+ - "\1\7\1\0\15\7\1\u0181\13\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\u0182\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\2\7\1\u0183\26\7\11\0\2\7\1\0\1\7"+ - "\1\0\4\7\1\u0184\12\7\1\u0185\11\7\11\0\2\7"+ - "\1\0\1\7\1\0\13\7\1\u0186\15\7\11\0\2\7"+ - "\1\0\1\7\1\0\13\7\1\u0187\15\7\11\0\2\7"+ - "\1\0\1\7\1\0\17\7\1\u0188\11\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\7\1\u0189\27\7\11\0\2\7"+ - "\1\0\1\7\1\0\2\7\1\u018a\26\7\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\u018b\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\11\7\1\u018c\17\7\11\0\2\7"+ - "\1\0\1\7\1\0\12\7\1\u018d\16\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\7\1\u018e\27\7\11\0\2\7"+ - "\1\0\1\7\1\0\16\7\1\u018f\12\7\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\u0190\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\13\7\1\u0191\15\7\11\0\2\7"+ - "\1\0\1\7\1\0\4\7\1\u0192\24\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\u0193\30\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\7\1\u0194\27\7\11\0\2\7\1\0"+ - "\1\7\1\0\22\7\1\u0195\6\7\11\0\2\7\1\0"+ - "\1\7\1\0\10\7\1\u0196\20\7\11\0\2\7\1\0"+ - "\1\7\1\0\21\7\1\u0197\7\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\7\1\u0198\27\7\11\0\2\7\1\0"+ - "\1\7\1\0\6\7\1\u0199\22\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\7\1\u019a\27\7\11\0\2\7\1\0"+ - "\1\7\1\0\7\7\1\u019b\21\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\u019c\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\17\7\1\u019d\11\7\11\0\2\7\1\0\1\7"+ - "\1\0\2\7\1\u019e\26\7\11\0\2\7\1\0\1\7"+ - "\1\0\6\7\1\u019f\22\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\7\1\u01a0\27\7\11\0\2\7\1\0\1\7"+ - "\1\0\6\7\1\u01a1\22\7\11\0\2\7\1\0\1\7"+ - "\1\0\15\7\1\u01a2\13\7\11\0\2\7\1\0\1\7"+ - "\1\0\11\7\1\u01a3\17\7\11\0\2\7\1\0\1\7"+ - "\1\0\15\7\1\u01a4\13\7\11\0\2\7\1\0\1\7"+ - "\1\0\5\7\1\u01a5\23\7\11\0\2\7\1\0\1\7"+ - "\1\0\12\7\1\u01a6\16\7\11\0\2\7\1\0\1\7"+ - "\1\0\2\7\1\u01a7\26\7\11\0\2\7\1\0\1\7"+ - "\1\0\3\7\1\u01a8\25\7\11\0\2\7\1\0\1\7"+ - "\1\0\11\7\1\u01a9\17\7\11\0\2\7\1\0\1\7"+ - "\1\0\6\7\1\u01aa\22\7\11\0\2\7\1\0\1\7"+ - "\1\0\10\7\1\u01ab\20\7\11\0\2\7\1\0\1\7"+ - "\1\0\2\7\1\u01ac\26\7\11\0\2\7\1\0\1\7"+ - "\1\0\11\7\1\u01ad\17\7\11\0\2\7\1\0\1\7"+ - "\1\0\2\7\1\u01ae\26\7\11\0\2\7\1\0\1\7"+ - "\1\0\14\7\1\u01af\14\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\u01b0\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\7\7\1\u01b1\21\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\u01b2\30\7\11\0\2\7\1\0\1\7\1\0\21\7"+ - "\1\u01b3\7\7\11\0\2\7\1\0\1\7\1\0\12\7"+ - "\1\u01b4\16\7\11\0\2\7\1\0\1\7\1\0\13\7"+ - "\1\u01b5\15\7\11\0\2\7\1\0\1\7\1\0\5\7"+ - "\1\u01b6\23\7\11\0\2\7\1\0\1\7\1\0\15\7"+ - "\1\u01b7\13\7\11\0\2\7\1\0\1\7\1\0\14\7"+ - "\1\u01b8\14\7\11\0\2\7\1\0\1\7\1\0\2\7"+ - "\1\u01b9\26\7\11\0\2\7\1\0\1\7\1\0\1\u01ba"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\3\7\1\u01bb"+ - "\11\7\1\u01bc\13\7\11\0\2\7\1\0\1\7\1\0"+ - "\11\7\1\u01bd\17\7\11\0\2\7\1\0\1\7\1\0"+ - "\15\7\1\u01be\13\7\11\0\2\7\1\0\1\7\1\0"+ - "\12\7\1\u01bf\16\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\u01c0\30\7\11\0\2\7\1\0\1\7\1\0\13\7"+ - "\1\u01c1\2\7\1\u01c2\12\7\11\0\2\7\1\0\1\7"+ - "\1\0\24\7\1\u01c3\4\7\11\0\2\7\1\0\1\7"+ - "\1\0\2\7\1\u01c4\26\7\11\0\2\7\1\0\1\7"+ - "\1\0\2\7\1\u01c5\26\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\u01c6\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\13\7\1\u01c7\15\7\11\0\2\7\1\0\1\7\1\0"+ - "\5\7\1\u01c8\23\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\u01c9\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\26\7\1\u01ca\2\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\u01cb\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\13\7\1\u01cc\15\7\11\0\2\7\1\0\1\7\1\0"+ - "\13\7\1\u01cd\15\7\11\0\2\7\1\0\1\7\1\0"+ - "\3\7\1\u01ce\25\7\11\0\2\7\1\0\1\7\1\0"+ - "\12\7\1\u01cf\16\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\u01d0\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\12\7\1\u01d1\16\7\11\0\2\7\1\0\1\7\1\0"+ - "\5\7\1\u01d2\23\7\11\0\2\7\1\0\1\7\1\0"+ - "\12\7\1\u01d3\16\7\11\0\2\7\1\0\1\7\1\0"+ - "\14\7\1\u01d4\14\7\11\0\2\7\1\0\1\7\1\0"+ - "\6\7\1\u01d5\22\7\11\0\2\7\1\0\1\7\1\0"+ - "\11\7\1\u01d6\17\7\11\0\2\7\1\0\1\7\1\0"+ - "\4\7\1\u01d7\24\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\u01d8\30\7\11\0\2\7\1\0\1\7\1\0\13\7"+ - "\1\u01d9\15\7\11\0\2\7\1\0\1\7\1\0\1\u01da"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\1\7\1\u01db"+ - "\27\7\11\0\2\7\1\0\1\7\1\0\7\7\1\u01dc"+ - "\21\7\11\0\2\7\1\0\1\7\1\0\21\7\1\u01dd"+ - "\7\7\11\0\2\7\1\0\1\7\1\0\16\7\1\u01de"+ - "\12\7\11\0\2\7\1\0\1\7\1\0\3\7\1\u01df"+ - "\25\7\11\0\2\7\1\0\1\7\1\0\10\7\1\u01e0"+ - "\20\7\11\0\2\7\1\0\1\7\1\0\3\7\1\u01e1"+ - "\25\7\11\0\2\7\1\0\1\7\1\0\17\7\1\u01e2"+ - "\11\7\11\0\2\7\1\0\1\7\1\0\1\u01e3\30\7"+ - "\11\0\2\7\1\0\1\7\1\0\2\7\1\u01e4\26\7"+ - "\11\0\2\7\1\0\1\7\1\0\2\7\1\u01e5\26\7"+ - "\11\0\2\7\1\0\1\7\1\0\6\7\1\u01e6\22\7"+ - "\11\0\2\7\1\0\1\7\1\0\3\7\1\u01e7\25\7"+ - "\11\0\2\7\1\0\1\7\1\0\3\7\1\u01e8\25\7"+ - "\11\0\2\7\1\0\1\7\1\0\16\7\1\u01e9\12\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\7\1\u01ea\27\7"+ - "\11\0\2\7\1\0\1\7\1\0\2\7\1\u01eb\26\7"+ - "\11\0\2\7\1\0\1\7\1\0\11\7\1\u01ec\17\7"+ - "\11\0\2\7\1\0\1\7\1\0\2\7\1\u01ed\26\7"+ - "\11\0\2\7\1\0\1\7\1\0\11\7\1\u01ee\17\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\7\1\u01ef\27\7"+ - "\11\0\2\7\1\0\1\7\1\0\21\7\1\u01f0\7\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\u01f1\30\7\11\0"+ - "\2\7\1\0\1\7\1\0\5\7\1\u01f2\23\7\11\0"+ - "\2\7\1\0\1\7\1\0\15\7\1\u01f3\13\7\11\0"+ - "\2\7\1\0\1\7\1\0\6\7\1\u01f4\22\7\11\0"+ - "\2\7\1\0\1\7\1\0\17\7\1\u01f5\11\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\7\1\u01f6\27\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\u01f7\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\5\7\1\u01f8\23\7\11\0"+ - "\2\7\1\0\1\7\1\0\12\7\1\u01f9\16\7\11\0"+ - "\2\7\1\0\1\7\1\0\6\7\1\u01fa\22\7\11\0"+ - "\2\7\1\0\1\7\1\0\15\7\1\u01fb\13\7\11\0"+ - "\2\7\1\0\1\7\1\0\14\7\1\u01fc\14\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\u01fd\30\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\7\1\u01fe\27\7\11\0\2\7"+ - "\1\0\1\7\1\0\3\7\1\u01ff\25\7\11\0\2\7"+ - "\1\0\1\7\1\0\17\7\1\u0200\11\7\11\0\2\7"+ - "\1\0\1\7\1\0\7\7\1\u0201\21\7\11\0\2\7"+ - "\1\0\1\7\1\0\15\7\1\u0202\13\7\11\0\2\7"+ - "\1\0\1\7\1\0\12\7\1\u0203\16\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\7\1\u0204\27\7\11\0\2\7"+ - "\1\0\1\7\1\0\21\7\1\u0205\7\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\u0206\30\7\11\0\2\7\1\0"+ - "\1\7\1\0\6\7\1\u0207\22\7\11\0\2\7\1\0"+ - "\1\7\1\0\2\7\1\u0208\26\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\7\1\u0209\27\7\11\0\2\7\1\0"+ - "\1\7\1\0\3\7\1\u020a\25\7\11\0\2\7\1\0"+ - "\1\7\1\0\3\7\1\u020b\25\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\u020c\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\12\7\1\u020d\16\7\11\0\2\7\1\0\1\7"+ - "\1\0\13\7\1\u020e\15\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\u020f\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\12\7\1\u0210\16\7\11\0\2\7\1\0\1\7\1\0"+ - "\5\7\1\u0211\23\7\11\0\2\7\1\0\1\7\1\0"+ - "\16\7\1\u0212\12\7\11\0\2\7\1\0\1\7\1\0"+ - "\5\7\1\u0213\23\7\11\0\2\7\1\0\1\7\1\0"+ - "\15\7\1\u0214\13\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\u0215\30\7\11\0\2\7\1\0\1\7\1\0\1\u0216"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\16\7\1\u0217"+ - "\1\u0218\11\7\11\0\2\7\1\0\1\7\1\0\20\7"+ - "\1\u0219\10\7\11\0\2\7\1\0\1\7\1\0\3\7"+ - "\1\u021a\25\7\11\0\2\7\1\0\1\7\1\0\10\7"+ - "\1\u021b\20\7\11\0\2\7\1\0\1\7\1\0\5\7"+ - "\1\u021c\1\7\1\u021d\1\u021e\12\7\1\u021f\5\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\7\1\u0220\27\7\11\0"+ - "\2\7\1\0\1\7\1\0\10\7\1\u0221\20\7\11\0"+ - "\2\7\1\0\1\7\1\0\6\7\1\u0222\22\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\u0223\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\u0224\30\7\11\0\2\7"+ - "\1\0\1\7\1\0\21\7\1\u0225\7\7\11\0\2\7"+ - "\1\0\1\7\1\0\23\7\1\u0226\5\7\11\0\2\7"+ - "\1\0\1\7\1\0\11\7\1\u0227\17\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\7\1\u0228\27\7\11\0\2\7"+ - "\1\0\1\7\1\0\26\7\1\u0229\2\7\11\0\2\7"+ - "\1\0\1\7\1\0\14\7\1\u022a\14\7\11\0\2\7"+ - "\1\0\1\7\1\0\3\7\1\u022b\25\7\11\0\2\7"+ - "\1\0\1\7\1\0\13\7\1\u022c\15\7\11\0\2\7"+ - "\1\0\1\7\1\0\2\7\1\u022d\26\7\11\0\2\7"+ - "\1\0\1\7\1\0\26\7\1\u022e\2\7\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\u022f\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\7\1\u0230\27\7\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\u0231\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\14\7\1\u0232\14\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\7\1\u0233\27\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\7\1\u0234\27\7\11\0\2\7"+ - "\1\0\1\7\1\0\16\7\1\u0235\12\7\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\u0236\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\2\7\1\u0237\26\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\u0238\30\7\11\0\2\7\1\0"+ - "\1\7\1\0\6\7\1\u0239\22\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\u023a\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\5\7\1\u023b\23\7\11\0\2\7\1\0\1\7"+ - "\1\0\3\7\1\u023c\25\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\u023d\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\7\7\1\u023e\21\7\11\0\2\7\1\0\1\7\1\0"+ - "\13\7\1\u023f\15\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\u0240\4\7\1\u0241\22\7\11\0\2\7\1\0"+ - "\1\7\1\0\12\7\1\u0242\16\7\11\0\2\7\1\0"+ - "\1\7\1\0\2\7\1\u0243\26\7\11\0\2\7\1\0"+ - "\1\7\1\0\15\7\1\u0244\13\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\u0245\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\20\7\1\u0246\10\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\u0247\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\11\7\1\u0248\17\7\11\0\2\7\1\0\1\7\1\0"+ - "\2\7\1\u0249\26\7\11\0\2\7\1\0\1\7\1\0"+ - "\13\7\1\u024a\15\7\11\0\2\7\1\0\1\7\1\0"+ - "\13\7\1\u024b\15\7\11\0\2\7\1\0\1\7\1\0"+ - "\6\7\1\u024c\22\7\11\0\2\7\1\0\1\7\1\0"+ - "\5\7\1\u024d\23\7\11\0\2\7\1\0\1\7\1\0"+ - "\17\7\1\u024e\11\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\u024f\30\7\11\0\2\7\1\0\1\7\1\0\6\7"+ - "\1\u0250\22\7\11\0\2\7\1\0\1\7\1\0\1\u0251"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\15\7\1\u0252"+ - "\13\7\11\0\2\7\1\0\1\7\1\0\23\7\1\u0253"+ - "\5\7\11\0\2\7\1\0\1\7\1\0\2\7\1\u0254"+ - "\10\7\1\u0255\15\7\11\0\2\7\1\0\1\7\1\0"+ - "\15\7\1\u0256\13\7\11\0\2\7\1\0\1\7\1\0"+ - "\12\7\1\u0257\16\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\u0258\30\7\11\0\2\7\1\0\1\7\1\0\14\7"+ - "\1\u0259\14\7\11\0\2\7\1\0\1\7\1\0\20\7"+ - "\1\u025a\10\7\11\0\2\7\1\0\1\7\1\0\5\7"+ - "\1\u025b\23\7\11\0\2\7\1\0\1\7\1\0\3\7"+ - "\1\u025c\25\7\11\0\2\7\1\0\1\7\1\0\6\7"+ - "\1\u025d\22\7\11\0\2\7\1\0\1\7\1\0\11\7"+ - "\1\u025e\17\7\11\0\2\7\1\0\1\7\1\0\17\7"+ - "\1\u025f\11\7\11\0\2\7\1\0\1\7\1\0\6\7"+ - "\1\u0260\22\7\11\0\2\7\1\0\1\7\1\0\5\7"+ - "\1\u0261\23\7\11\0\2\7\1\0\1\7\1\0\1\u0262"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\12\7\1\u0263"+ - "\16\7\11\0\2\7\1\0\1\7\1\0\20\7\1\u0264"+ - "\10\7\11\0\2\7\1\0\1\7\1\0\21\7\1\u0265"+ - "\7\7\11\0\2\7\1\0\1\7\1\0\1\u0266\30\7"+ - "\11\0\2\7\1\0\1\7\1\0\15\7\1\u0267\13\7"+ - "\11\0\2\7\1\0\1\7\1\0\6\7\1\u0268\22\7"+ - "\11\0\2\7\1\0\1\7\1\0\12\7\1\u0269\16\7"+ - "\11\0\2\7\1\0\1\7\1\0\5\7\1\u026a\23\7"+ - "\11\0\2\7\1\0\1\7\1\0\6\7\1\u026b\22\7"+ - "\11\0\2\7\1\0\1\7\1\0\6\7\1\u026c\22\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\u026d\30\7\11\0"+ - "\2\7\1\0\1\7\1\0\12\7\1\u026e\16\7\11\0"+ - "\2\7\1\0\1\7\1\0\16\7\1\u026f\12\7\11\0"+ - "\2\7\1\0\1\7\1\0\13\7\1\u0270\15\7\11\0"+ - "\2\7\1\0\1\7\1\0\13\7\1\u0271\15\7\11\0"+ - "\2\7\1\0\1\7\1\0\23\7\1\u0272\5\7\11\0"+ - "\2\7\1\0\1\7\1\0\17\7\1\u0273\11\7\11\0"+ - "\2\7\1\0\1\7\1\0\5\7\1\u0274\23\7\11\0"+ - "\2\7\1\0\1\7\1\0\15\7\1\u0275\13\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\u0276\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\15\7\1\u0277\13\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\u0278\30\7\11\0\2\7"+ - "\1\0\1\7\1\0\11\7\1\u0279\17\7\11\0\2\7"+ - "\1\0\1\7\1\0\10\7\1\u027a\20\7\11\0\2\7"+ - "\1\0\1\7\1\0\15\7\1\u027b\13\7\11\0\2\7"+ - "\1\0\1\7\1\0\17\7\1\u027c\11\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\u027d\30\7\11\0\2\7\1\0"+ - "\1\7\1\0\4\7\1\u027e\24\7\11\0\2\7\1\0"+ - "\1\7\1\0\5\7\1\u027f\23\7\11\0\2\7\1\0"+ - "\1\7\1\0\6\7\1\u0280\22\7\11\0\2\7\1\0"+ - "\1\7\1\0\3\7\1\u0281\25\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\u0282\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\11\7\1\u0283\17\7\11\0\2\7\1\0\1\7"+ - "\1\0\5\7\1\u0284\23\7\11\0\2\7\1\0\1\7"+ - "\1\0\16\7\1\u0285\12\7\11\0\2\7\1\0\1\7"+ - "\1\0\23\7\1\u0286\5\7\11\0\2\7\1\0\1\7"+ - "\1\0\12\7\1\u0287\16\7\11\0\2\7\1\0\1\7"+ - "\1\0\12\7\1\u0288\16\7\11\0\2\7\1\0\1\7"+ - "\1\0\11\7\1\u0289\17\7\11\0\2\7\1\0\1\7"+ - "\1\0\12\7\1\u028a\16\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\u028b\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\u028c\30\7\11\0\2\7\1\0\1\7\1\0\11\7"+ - "\1\u028d\17\7\11\0\2\7\1\0\1\7\1\0\1\u028e"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\3\7\1\u028f"+ - "\25\7\11\0\2\7\1\0\1\7\1\0\1\u0290\30\7"+ - "\11\0\2\7\1\0\1\7\1\0\13\7\1\u0291\15\7"+ - "\11\0\2\7\1\0\1\7\1\0\13\7\1\u0292\15\7"+ - "\11\0\2\7\1\0\1\7\1\0\24\7\1\u0293\4\7"+ - "\11\0\2\7\1\0\1\7\1\0\15\7\1\u0294\13\7"+ - "\11\0\2\7\1\0\1\7\1\0\22\7\1\u0295\6\7"+ - "\11\0\2\7\1\0\1\7\1\0\21\7\1\u0296\7\7"+ - "\11\0\2\7\1\0\1\7\1\0\11\7\1\u0297\17\7"+ - "\11\0\2\7\1\0\1\7\1\0\2\7\1\u0298\26\7"+ - "\11\0\2\7\1\0\1\7\1\0\11\7\1\u0299\17\7"+ - "\11\0\2\7\1\0\1\7\1\0\3\7\1\u029a\25\7"+ - "\11\0\2\7\1\0\1\7\1\0\12\7\1\u029b\16\7"+ - "\11\0\2\7\1\0\1\7\1\0\13\7\1\u029c\15\7"+ - "\11\0\2\7\1\0\1\7\1\0\17\7\1\u029d\11\7"+ - "\11\0\2\7\1\0\1\7\1\0\10\7\1\u029e\20\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\u029f\30\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\u02a0\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\u02a1\30\7\11\0\2\7"+ - "\1\0\1\7\1\0\13\7\1\u02a2\15\7\11\0\2\7"+ - "\1\0\1\7\1\0\10\7\1\u02a3\20\7\11\0\2\7"+ - "\1\0\1\7\1\0\12\7\1\u02a4\16\7\11\0\2\7"+ - "\1\0\1\7\1\0\21\7\1\u02a5\7\7\11\0\2\7"+ - "\1\0\1\7\1\0\15\7\1\u02a6\13\7\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\u02a7\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\2\7\1\u02a8\26\7\11\0\2\7"+ - "\1\0\1\7\1\0\23\7\1\u02a9\5\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\u02aa\30\7\11\0\2\7\1\0"+ - "\1\7\1\0\16\7\1\u02ab\12\7\11\0\2\7\1\0"+ - "\1\7\1\0\13\7\1\u02ac\15\7\11\0\2\7\1\0"+ - "\1\7\1\0\13\7\1\u02ad\15\7\11\0\2\7\1\0"+ - "\1\7\1\0\5\7\1\u02ae\23\7\11\0\2\7\1\0"+ - "\1\7\1\0\12\7\1\u02af\16\7\11\0\2\7\1\0"+ - "\1\7\1\0\5\7\1\u02b0\23\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\u02b1\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\12\7\1\u02b2\16\7\11\0\2\7\1\0\1\7"+ - "\1\0\24\7\1\u02b3\4\7\11\0\2\7\1\0\1\7"+ - "\1\0\3\7\1\u02b4\25\7\11\0\2\7\1\0\1\7"+ - "\1\0\6\7\1\u02b5\22\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\u02b6\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\14\7\1\u02b7\14\7\11\0\2\7\1\0\1\7\1\0"+ - "\5\7\1\u02b8\23\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\u02b9\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\10\7\1\u02ba\20\7\11\0\2\7\1\0\1\7\1\0"+ - "\6\7\1\u02bb\22\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\u02bc\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\20\7\1\u02bd\10\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\u02be\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\15\7\1\u02bf\13\7\11\0\2\7\1\0\1\7\1\0"+ - "\12\7\1\u02c0\16\7\11\0\2\7\1\0\1\7\1\0"+ - "\15\7\1\u02c1\13\7\11\0\2\7\1\0\1\7\1\0"+ - "\13\7\1\u02c2\15\7\11\0\2\7\1\0\1\7\1\0"+ - "\6\7\1\u02c3\22\7\11\0\2\7\1\0\1\7\1\0"+ - "\6\7\1\u02c4\22\7\11\0\2\7\1\0\1\7\1\0"+ - "\12\7\1\u02c5\16\7\11\0\2\7\1\0\1\7\1\0"+ - "\12\7\1\u02c6\16\7\11\0\2\7\1\0\1\7\1\0"+ - "\25\7\1\u02c7\3\7\11\0\2\7\1\0\1\7\1\0"+ - "\11\7\1\u02c8\17\7\11\0\2\7\1\0\1\7\1\0"+ - "\6\7\1\u02c9\22\7\11\0\2\7\1\0\1\7\1\0"+ - "\2\7\1\u02ca\26\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\7\1\u02cb\27\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\u02cc\30\7\11\0\2\7\1\0\1\7\1\0\13\7"+ - "\1\u02cd\15\7\11\0\2\7\1\0\1\7\1\0\15\7"+ - "\1\u02ce\13\7\11\0\2\7\1\0\1\7\1\0\1\u02cf"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\1\7\1\u02d0"+ - "\27\7\11\0\2\7\1\0\1\7\1\0\21\7\1\u02d1"+ - "\7\7\11\0\2\7\1\0\1\7\1\0\17\7\1\u02d2"+ - "\11\7\11\0\2\7\1\0\1\7\1\0\11\7\1\u02d3"+ - "\17\7\11\0\2\7\1\0\1\7\1\0\1\u02d4\30\7"+ - "\11\0\2\7\1\0\1\7\1\0\20\7\1\u02d5\10\7"+ - "\11\0\2\7\1\0\1\7\1\0\5\7\1\u02d6\23\7"+ - "\11\0\2\7\1\0\1\7\1\0\6\7\1\u02d7\22\7"+ - "\11\0\2\7\1\0\1\7\1\0\26\7\1\u02d8\2\7"+ - "\11\0\2\7\1\0\1\7\1\0\11\7\1\u02d9\17\7"+ - "\11\0\2\7\1\0\1\7\1\0\1\u02da\30\7\11\0"+ - "\2\7\1\0\1\7\1\0\2\7\1\u02db\26\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\u02dc\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\11\7\1\u02dd\17\7\11\0"+ - "\2\7\1\0\1\7\1\0\15\7\1\u02de\13\7\11\0"+ - "\2\7\1\0\1\7\1\0\5\7\1\u02df\23\7\11\0"+ - "\2\7\1\0\1\7\1\0\1\u02e0\30\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\7\1\u02e1\27\7\11\0\2\7"+ - "\1\0\1\7\1\0\11\7\1\u02e2\17\7\11\0\2\7"+ - "\1\0\1\7\1\0\2\7\1\u02e3\26\7\11\0\2\7"+ - "\1\0\1\7\1\0\15\7\1\u02e4\13\7\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\u02e5\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\11\7\1\u02e6\17\7\11\0\2\7"+ - "\1\0\1\7\1\0\17\7\1\u02e7\11\7\11\0\2\7"+ - "\1\0\1\7\1\0\2\7\1\u02e8\26\7\11\0\2\7"+ - "\1\0\1\7\1\0\7\7\1\u02e9\21\7\11\0\2\7"+ - "\1\0\1\7\1\0\16\7\1\u02ea\12\7\11\0\2\7"+ - "\1\0\1\7\1\0\11\7\1\u02eb\17\7\11\0\2\7"+ - "\1\0\1\7\1\0\2\7\1\u02ec\26\7\11\0\2\7"+ - "\1\0\1\7\1\0\10\7\1\u02ed\20\7\11\0\2\7"+ - "\1\0\1\7\1\0\12\7\1\u02ee\16\7\11\0\2\7"+ - "\1\0\1\7\1\0\12\7\1\u02ef\16\7\11\0\2\7"+ - "\1\0\1\7\1\0\15\7\1\u02f0\13\7\11\0\2\7"+ - "\1\0\1\7\1\0\2\7\1\u02f1\26\7\11\0\2\7"+ - "\1\0\1\7\1\0\20\7\1\u02f2\10\7\11\0\2\7"+ - "\1\0\1\7\1\0\7\7\1\u02f3\21\7\11\0\2\7"+ - "\1\0\1\7\1\0\6\7\1\u02f4\22\7\11\0\2\7"+ - "\1\0\1\7\1\0\16\7\1\u02f5\12\7\11\0\2\7"+ - "\1\0\1\7\1\0\12\7\1\u02f6\16\7\11\0\2\7"+ - "\1\0\1\7\1\0\13\7\1\u02f7\15\7\11\0\2\7"+ - "\1\0\1\7\1\0\6\7\1\u02f8\22\7\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\u02f9\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\7\1\u02fa\27\7\11\0\2\7"+ - "\1\0\1\7\1\0\14\7\1\u02fb\14\7\11\0\2\7"+ - "\1\0\1\7\1\0\7\7\1\u02fc\21\7\11\0\2\7"+ - "\1\0\1\7\1\0\3\7\1\u02fd\25\7\11\0\2\7"+ - "\1\0\1\7\1\0\12\7\1\u02fe\16\7\11\0\2\7"+ - "\1\0\1\7\1\0\5\7\1\u02ff\23\7\11\0\2\7"+ - "\1\0\1\7\1\0\1\u0300\30\7\11\0\2\7\1\0"+ - "\1\7\1\0\1\u0301\30\7\11\0\2\7\1\0\1\7"+ - "\1\0\15\7\1\u0302\13\7\11\0\2\7\1\0\1\7"+ - "\1\0\2\7\1\u0303\26\7\11\0\2\7\1\0\1\7"+ - "\1\0\6\7\1\u0304\22\7\11\0\2\7\1\0\1\7"+ - "\1\0\3\7\1\u0305\25\7\11\0\2\7\1\0\1\7"+ - "\1\0\1\u0306\30\7\11\0\2\7\1\0\1\7\1\0"+ - "\2\7\1\u0307\26\7\11\0\2\7\1\0\1\7\1\0"+ - "\11\7\1\u0308\17\7\11\0\2\7\1\0\1\7\1\0"+ - "\13\7\1\u0309\15\7\11\0\2\7\1\0\1\7\1\0"+ - "\2\7\1\u030a\26\7\11\0\2\7\1\0\1\7\1\0"+ - "\11\7\1\u030b\17\7\11\0\2\7\1\0\1\7\1\0"+ - "\12\7\1\u030c\16\7\11\0\2\7\1\0\1\7\1\0"+ - "\1\u030d\30\7\11\0\2\7\1\0\1\7\1\0\21\7"+ - "\1\u030e\7\7\11\0\2\7\1\0\1\7\1\0\17\7"+ - "\1\u030f\11\7\11\0\2\7\1\0\1\7\1\0\10\7"+ - "\1\u0310\20\7\11\0\2\7\1\0\1\7\1\0\6\7"+ - "\1\u0311\22\7\11\0\2\7\1\0\1\7\1\0\12\7"+ - "\1\u0312\16\7\11\0\2\7\1\0\1\7\1\0\21\7"+ - "\1\u0313\7\7\11\0\2\7\1\0\1\7\1\0\3\7"+ - "\1\u0314\25\7\11\0\2\7\1\0\1\7\1\0\13\7"+ - "\1\u0315\15\7\11\0\2\7\1\0\1\7\1\0\1\u0316"+ - "\30\7\11\0\2\7\1\0\1\7\1\0\5\7\1\u0317"+ - "\23\7\11\0\2\7\1\0\1\7\1\0\7\7\1\u0318"+ - "\21\7\11\0\2\7\1\0\1\7\1\0\14\7\1\u0319"+ - "\14\7\11\0\2\7\1\0\1\7\1\0\12\7\1\u031a"+ - "\16\7\11\0\2\7\1\0\1\7\1\0\1\u031b\30\7"+ - "\11\0\2\7\1\0\1\7\1\0\6\7\1\u031c\22\7"+ - "\2\0"; - - private static int [] zzUnpackTrans() { - int [] result = new int[27963]; - int offset = 0; - offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackTrans(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - value--; - do result[j++] = value; while (--count > 0); + private static int[] zzUnpackAction() { + int[] result = new int[796]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; } - return j; - } - - - /* error codes */ - private static final int ZZ_UNKNOWN_ERROR = 0; - private static final int ZZ_NO_MATCH = 1; - private static final int ZZ_PUSHBACK_2BIG = 2; - /* error messages for the codes above */ - private static final String ZZ_ERROR_MSG[] = { - "Unkown internal scanner error", - "Error: could not match input", - "Error: pushback value was too large" - }; - - /** - * ZZ_ATTRIBUTE[aState] contains the attributes of state aState - */ - private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); - - private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\1\0\1\11\1\1\1\11\33\1\2\11\4\0\55\1"+ - "\2\0\2\1\1\0\1\11\65\1\1\0\u028e\1"; - - private static int [] zzUnpackAttribute() { - int [] result = new int[796]; - int offset = 0; - offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAttribute(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); + private static int zzUnpackAction(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; } - return j; - } - - /** the input device */ - private java.io.Reader zzReader; - - /** the current state of the DFA */ - private int zzState; - - /** the current lexical state */ - private int zzLexicalState = YYINITIAL; - - /** this buffer contains the current text to be matched and is - the source of the yytext() string */ - private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; - /** the textposition at the last accepting state */ - private int zzMarkedPos; - - /** the textposition at the last state to be included in yytext */ - private int zzPushbackPos; - - /** the current text position in the buffer */ - private int zzCurrentPos; - - /** startRead marks the beginning of the yytext() string in the buffer */ - private int zzStartRead; - - /** endRead marks the last character in the buffer, that has been read - from input */ - private int zzEndRead; - - /** number of newlines encountered up to the start of the matched text */ - private int yyline; - - /** the number of characters up to the start of the matched text */ - private int yychar; - - /** - * the number of characters from the last newline up to the start of the - * matched text - */ - private int yycolumn; + private static int[] zzUnpackRowMap() { + int[] result = new int[796]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } - /** - * zzAtBOL == true <=> the scanner is currently at the beginning of a line - */ - private boolean zzAtBOL = true; + private static int zzUnpackRowMap(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } - /** zzAtEOF == true <=> the scanner is at the EOF */ - private boolean zzAtEOF; + private static int[] zzUnpackTrans() { + int[] result = new int[27963]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + private static int zzUnpackTrans(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } - /** - * Creates a new scanner - * There is also a java.io.InputStream version of this constructor. - * - * @param in the java.io.Reader to read input from. - */ - GUIDefaultsScanner(java.io.Reader in) { - this.zzReader = in; - } + private static int[] zzUnpackAttribute() { + int[] result = new int[796]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } - /** - * Creates a new scanner. - * There is also java.io.Reader version of this constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - GUIDefaultsScanner(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } + private static int zzUnpackAttribute(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table - */ - private static char [] zzUnpackCMap(String packed) { - char [] map = new char[0x10000]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 156) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do map[j++] = value; while (--count > 0); + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char[] zzUnpackCMap(String packed) { + char[] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 156) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; } - return map; - } - /** - * Refills the input buffer. - * - * @return false, iff there was new input. - * - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean zzRefill() throws java.io.IOException { + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * @throws java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { /* first: make room (if you can) */ - if (zzStartRead > 0) { - System.arraycopy(zzBuffer, zzStartRead, - zzBuffer, 0, - zzEndRead-zzStartRead); + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead - zzStartRead); /* translate stored positions */ - zzEndRead-= zzStartRead; - zzCurrentPos-= zzStartRead; - zzMarkedPos-= zzStartRead; - zzPushbackPos-= zzStartRead; - zzStartRead = 0; - } + zzEndRead -= zzStartRead; + zzCurrentPos -= zzStartRead; + zzMarkedPos -= zzStartRead; + zzPushbackPos -= zzStartRead; + zzStartRead = 0; + } /* is the buffer big enough? */ - if (zzCurrentPos >= zzBuffer.length) { + if (zzCurrentPos >= zzBuffer.length) { /* if not: blow it up */ - char newBuffer[] = new char[zzCurrentPos*2]; - System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); - zzBuffer = newBuffer; - } + char newBuffer[] = new char[zzCurrentPos * 2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } /* finally: fill the buffer with new input */ - int numRead = zzReader.read(zzBuffer, zzEndRead, - zzBuffer.length-zzEndRead); - - if (numRead < 0) { - return true; - } - else { - zzEndRead+= numRead; - return false; + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length - zzEndRead); + + if (numRead < 0) { + return true; + } else { + zzEndRead += numRead; + return false; + } } - } - - - /** - * Closes the input stream. - */ - public final void yyclose() throws java.io.IOException { - zzAtEOF = true; /* indicate end of file */ - zzEndRead = zzStartRead; /* invalidate buffer */ - - if (zzReader != null) - zzReader.close(); - } - - /** - * Resets the scanner to read from a new input stream. - * Does not close the old reader. - * - * All internal variables are reset, the old input stream - * cannot be reused (internal buffer is discarded and lost). - * Lexical state is set to ZZ_INITIAL. - * - * @param reader the new input stream - */ - public final void yyreset(java.io.Reader reader) { - zzReader = reader; - zzAtBOL = true; - zzAtEOF = false; - zzEndRead = zzStartRead = 0; - zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; - yyline = yychar = yycolumn = 0; - zzLexicalState = YYINITIAL; - } + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ - /** - * Returns the current lexical state. - */ - public final int yystate() { - return zzLexicalState; - } - - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - public final void yybegin(int newState) { - zzLexicalState = newState; - } + if (zzReader != null) + zzReader.close(); + } - /** - * Returns the text matched by the current regular expression. - */ - public final String yytext() { - return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); - } + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + *

+ * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to ZZ_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + } - /** - * Returns the character at position pos from the - * matched text. - * - * It is equivalent to yytext().charAt(pos), but faster - * - * @param pos the position of the character to fetch. - * A value from 0 to yylength()-1. - * - * @return the character at position pos - */ - public final char yycharat(int pos) { - return zzBuffer[zzStartRead+pos]; - } + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } - /** - * Returns the length of the matched text region. - */ - public final int yylength() { - return zzMarkedPos-zzStartRead; - } + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } - /** - * Reports an error that occured while scanning. - * - * In a wellformed scanner (no or only correct usage of - * yypushback(int) and a match-all fallback rule) this method - * will only be called with things that "Can't Possibly Happen". - * If this method is called, something is seriously wrong - * (e.g. a JFlex bug producing a faulty scanner etc.). - * - * Usual syntax/scanner level error handling should be done - * in error fallback rules. - * - * @param errorCode the code of the errormessage to display - */ - private void zzScanError(int errorCode) { - String message; - try { - message = ZZ_ERROR_MSG[errorCode]; - } - catch (ArrayIndexOutOfBoundsException e) { - message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); } - throw new Error(message); - } + /** + * Returns the character at position pos from the + * matched text. + *

+ * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead + pos]; + } - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. - * This number must not be greater than yylength()! - */ - public void yypushback(int number) { - if ( number > yylength() ) - zzScanError(ZZ_PUSHBACK_2BIG); - zzMarkedPos -= number; - } + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos - zzStartRead; + } - /** - * Resumes scanning until the next regular expression is matched, - * the end of input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception java.io.IOException if any I/O-Error occurs - */ - public Object next_token() throws java.io.IOException { - int zzInput; - int zzAction; + /** + * Reports an error that occured while scanning. + *

+ * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + *

+ * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } - // cached fields: - int zzCurrentPosL; - int zzMarkedPosL; - int zzEndReadL = zzEndRead; - char [] zzBufferL = zzBuffer; - char [] zzCMapL = ZZ_CMAP; + throw new Error(message); + } - int [] zzTransL = ZZ_TRANS; - int [] zzRowMapL = ZZ_ROWMAP; - int [] zzAttrL = ZZ_ATTRIBUTE; - while (true) { - zzMarkedPosL = zzMarkedPos; + /** + * Pushes the specified amount of characters back into the input stream. + *

+ * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if (number > yylength()) + zzScanError(ZZ_PUSHBACK_2BIG); - zzAction = -1; + zzMarkedPos -= number; + } - zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; - - zzState = zzLexicalState; + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @throws java.io.IOException if any I/O-Error occurs + */ + public Object next_token() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char[] zzBufferL = zzBuffer; + char[] zzCMapL = ZZ_CMAP; + + int[] zzTransL = ZZ_TRANS; + int[] zzRowMapL = ZZ_ROWMAP; + int[] zzAttrL = ZZ_ATTRIBUTE; - zzForAction: { while (true) { - - if (zzCurrentPosL < zzEndReadL) - zzInput = zzBufferL[zzCurrentPosL++]; - else if (zzAtEOF) { - zzInput = YYEOF; - break zzForAction; - } - else { - // store back cached positions - zzCurrentPos = zzCurrentPosL; - zzMarkedPos = zzMarkedPosL; - boolean eof = zzRefill(); - // get translated positions and possibly new buffer - zzCurrentPosL = zzCurrentPos; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - zzEndReadL = zzEndRead; - if (eof) { - zzInput = YYEOF; - break zzForAction; - } - else { - zzInput = zzBufferL[zzCurrentPosL++]; + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = zzLexicalState; + + + zzForAction: + { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[zzRowMapL[zzState] + zzCMapL[zzInput]]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ((zzAttributes & 1) == 1) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ((zzAttributes & 8) == 8) break zzForAction; + } + + } } - } - int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; - if (zzNext == -1) break zzForAction; - zzState = zzNext; - - int zzAttributes = zzAttrL[zzState]; - if ( (zzAttributes & 1) == 1 ) { - zzAction = zzState; - zzMarkedPosL = zzCurrentPosL; - if ( (zzAttributes & 8) == 8 ) break zzForAction; - } + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 11: { + return GUIDefaultsFile.Keyword.NONE; + } + case 85: + break; + case 52: { + return GUIDefaultsFile.Keyword.EDIT_NET_RULES; + } + case 86: + break; + case 44: { + return GUIDefaultsFile.Keyword.PACKAGE_INFO; + } + case 87: + break; + case 34: { + return GUIDefaultsFile.Keyword.FIXED_VIAS; + } + case 88: + break; + case 60: { + return GUIDefaultsFile.Keyword.VIOLATIONS_INFO; + } + case 89: + break; + case 70: { + return GUIDefaultsFile.Keyword.FORTYFIVE_DEGREE; + } + case 90: + break; + case 54: { + return GUIDefaultsFile.Keyword.MOVE_PARAMETER; + } + case 91: + break; + case 76: { + return GUIDefaultsFile.Keyword.DISPLAY_MISCELLANIOUS; + } + case 92: + break; + case 53: { + return GUIDefaultsFile.Keyword.RULE_SELECTION; + } + case 93: + break; + case 41: { + return GUIDefaultsFile.Keyword.MANUAL_RULES; + } + case 94: + break; + case 17: { + return GUIDefaultsFile.Keyword.VISIBLE; + } + case 95: + break; + case 12: { + return GUIDefaultsFile.Keyword.PINS; + } + case 96: + break; + case 56: { + return GUIDefaultsFile.Keyword.COMPONENT_BACK; + } + case 97: + break; + case 40: { + return GUIDefaultsFile.Keyword.GUI_DEFAULTS; + } + case 98: + break; + case 15: { + return GUIDefaultsFile.Keyword.TRACES; + } + case 99: + break; + case 73: { + return GUIDefaultsFile.Keyword.PULL_TIGHT_REGION; + } + case 100: + break; + case 26: { + return GUIDefaultsFile.Keyword.VIA_RULES; + } + case 101: + break; + case 77: { + return GUIDefaultsFile.Keyword.VIA_SNAP_TO_SMD_CENTER; + } + case 102: + break; + case 38: { + return GUIDefaultsFile.Keyword.BOARD_FRAME; + } + case 103: + break; + case 61: { + return GUIDefaultsFile.Keyword.ROUTE_PARAMETER; + } + case 104: + break; + case 29: { + return GUIDefaultsFile.Keyword.PARAMETER; + } + case 105: + break; + case 33: { + return GUIDefaultsFile.Keyword.CONDUCTION; + } + case 106: + break; + case 48: { + return GUIDefaultsFile.Keyword.OBJECT_COLORS; + } + case 107: + break; + case 28: { + return GUIDefaultsFile.Keyword.STITCHING; + } + case 108: + break; + case 66: { + return GUIDefaultsFile.Keyword.SELECT_PARAMETER; + } + case 109: + break; + case 72: { + return GUIDefaultsFile.Keyword.OBJECT_VISIBILITY; + } + case 110: + break; + case 74: { + return GUIDefaultsFile.Keyword.PULL_TIGHT_ACCURACY; + } + case 111: + break; + case 58: { + return GUIDefaultsFile.Keyword.DISPLAY_REGION; + } + case 112: + break; + case 71: { + return GUIDefaultsFile.Keyword.INTERACTIVE_STATE; + } + case 113: + break; + case 39: { + return GUIDefaultsFile.Keyword.NOT_VISIBLE; + } + case 114: + break; + case 20: { + return GUIDefaultsFile.Keyword.DYNAMIC; + } + case 115: + break; + case 84: { + return GUIDefaultsFile.Keyword.DESELECTED_SNAPSHOT_ATTRIBUTES; + } + case 116: + break; + case 31: { + return GUIDefaultsFile.Keyword.BACKGROUND; + } + case 117: + break; + case 64: { + return GUIDefaultsFile.Keyword.LAYER_VISIBILITY; + } + case 118: + break; + case 43: { + return GUIDefaultsFile.Keyword.FIXED_TRACES; + } + case 119: + break; + case 51: { + return GUIDefaultsFile.Keyword.PADSTACK_INFO; + } + case 120: + break; + case 22: { + return GUIDefaultsFile.Keyword.HILIGHT; + } + case 121: + break; + case 14: { + return GUIDefaultsFile.Keyword.BOUNDS; + } + case 122: + break; + case 82: { + return GUIDefaultsFile.Keyword.DRAG_COMPONENTS_ENABLED; + } + case 123: + break; + case 75: { + return GUIDefaultsFile.Keyword.MANUAL_RULE_SETTINGS; + } + case 124: + break; + case 10: { + return GUIDefaultsFile.Keyword.VIAS; + } + case 125: + break; + case 3: { + return yytext(); + } + case 126: + break; + case 55: { + return GUIDefaultsFile.Keyword.COMPONENT_INFO; + } + case 127: + break; + case 32: { + return GUIDefaultsFile.Keyword.ROUTE_MODE; + } + case 128: + break; + case 50: { + return GUIDefaultsFile.Keyword.COLOR_MANAGER; + } + case 129: + break; + case 30: { + return GUIDefaultsFile.Keyword.VIOLATIONS; + } + case 130: + break; + case 67: { + return GUIDefaultsFile.Keyword.SELECTABLE_ITEMS; + } + case 131: + break; + case 19: { + return GUIDefaultsFile.Keyword.OUTLINE; + } + case 132: + break; + case 42: { + return GUIDefaultsFile.Keyword.CURRENT_ONLY; + } + case 133: + break; + case 9: { + return GUIDefaultsFile.Keyword.OFF; + } + case 134: + break; + case 45: { + return GUIDefaultsFile.Keyword.SHOVE_ENABLED; + } + case 135: + break; + case 63: { + return GUIDefaultsFile.Keyword.ASSIGN_NET_RULES; + } + case 136: + break; + case 25: { + return GUIDefaultsFile.Keyword.EDIT_VIAS; + } + case 137: + break; + case 81: { + return GUIDefaultsFile.Keyword.IGNORE_CONDUCTION_AREAS; + } + case 138: + break; + case 5: { + return GUIDefaultsFile.Keyword.OPEN_BRACKET; + } + case 139: + break; + case 36: { + return GUIDefaultsFile.Keyword.VIA_KEEPOUT; + } + case 140: + break; + case 8: { + return GUIDefaultsFile.Keyword.ON; + } + case 141: + break; + case 16: { + return GUIDefaultsFile.Keyword.COLORS; + } + case 142: + break; + case 68: { + return GUIDefaultsFile.Keyword.SELECTION_LAYERS; + } + case 143: + break; + case 46: { + return GUIDefaultsFile.Keyword.NINETY_DEGREE; + } + case 144: + break; + case 23: { + return GUIDefaultsFile.Keyword.WINDOWS; + } + case 145: + break; + case 57: { + return GUIDefaultsFile.Keyword.COMPONENT_GRID; + } + case 146: + break; + case 7: { + return new Double(yytext()); + } + case 147: + break; + case 69: { + return GUIDefaultsFile.Keyword.CLEARANCE_MATRIX; + } + case 148: + break; + case 65: { + return GUIDefaultsFile.Keyword.INCOMPLETES_INFO; + } + case 149: + break; + case 62: { + return GUIDefaultsFile.Keyword.COMPONENT_FRONT; + } + case 150: + break; + case 18: { + return GUIDefaultsFile.Keyword.UNFIXED; + } + case 151: + break; + case 59: { + return GUIDefaultsFile.Keyword.LENGTH_MATCHING; + } + case 152: + break; + case 80: { + return GUIDefaultsFile.Keyword.AUTOMATIC_LAYER_DIMMING; + } + case 153: + break; + case 79: { + return GUIDefaultsFile.Keyword.PUSH_AND_SHOVE_ENABLED; + } + case 154: + break; + case 24: { + return GUIDefaultsFile.Keyword.NET_INFO; + } + case 155: + break; + case 78: { + return GUIDefaultsFile.Keyword.CLEARANCE_COMPENSATION; + } + case 156: + break; + case 47: { + return GUIDefaultsFile.Keyword.ROUTE_DETAILS; + } + case 157: + break; + case 2: { /* ignore */ + } + case 158: + break; + case 83: { + return GUIDefaultsFile.Keyword.HILIGHT_ROUTING_OBSTACLE; + } + case 159: + break; + case 35: { + return GUIDefaultsFile.Keyword.ALL_VISIBLE; + } + case 160: + break; + case 6: { + return GUIDefaultsFile.Keyword.CLOSED_BRACKET; + } + case 161: + break; + case 1: { + throw new Error("Illegal character <" + + yytext() + ">"); + } + case 162: + break; + case 37: { + return GUIDefaultsFile.Keyword.INCOMPLETES; + } + case 163: + break; + case 49: { + return GUIDefaultsFile.Keyword.CURRENT_LAYER; + } + case 164: + break; + case 21: { + return GUIDefaultsFile.Keyword.KEEPOUT; + } + case 165: + break; + case 4: { + return new Integer(yytext()); + } + case 166: + break; + case 13: { + return GUIDefaultsFile.Keyword.FIXED; + } + case 167: + break; + case 27: { + return GUIDefaultsFile.Keyword.SNAPSHOTS; + } + case 168: + break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + return null; + } else { + zzScanError(ZZ_NO_MATCH); + } + } } - } - - // store back cached position - zzMarkedPos = zzMarkedPosL; - - switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 11: - { return GUIDefaultsFile.Keyword.NONE; - } - case 85: break; - case 52: - { return GUIDefaultsFile.Keyword.EDIT_NET_RULES; - } - case 86: break; - case 44: - { return GUIDefaultsFile.Keyword.PACKAGE_INFO; - } - case 87: break; - case 34: - { return GUIDefaultsFile.Keyword.FIXED_VIAS; - } - case 88: break; - case 60: - { return GUIDefaultsFile.Keyword.VIOLATIONS_INFO; - } - case 89: break; - case 70: - { return GUIDefaultsFile.Keyword.FORTYFIVE_DEGREE; - } - case 90: break; - case 54: - { return GUIDefaultsFile.Keyword.MOVE_PARAMETER; - } - case 91: break; - case 76: - { return GUIDefaultsFile.Keyword.DISPLAY_MISCELLANIOUS; - } - case 92: break; - case 53: - { return GUIDefaultsFile.Keyword.RULE_SELECTION; - } - case 93: break; - case 41: - { return GUIDefaultsFile.Keyword.MANUAL_RULES; - } - case 94: break; - case 17: - { return GUIDefaultsFile.Keyword.VISIBLE; - } - case 95: break; - case 12: - { return GUIDefaultsFile.Keyword.PINS; - } - case 96: break; - case 56: - { return GUIDefaultsFile.Keyword.COMPONENT_BACK; - } - case 97: break; - case 40: - { return GUIDefaultsFile.Keyword.GUI_DEFAULTS; - } - case 98: break; - case 15: - { return GUIDefaultsFile.Keyword.TRACES; - } - case 99: break; - case 73: - { return GUIDefaultsFile.Keyword.PULL_TIGHT_REGION; - } - case 100: break; - case 26: - { return GUIDefaultsFile.Keyword.VIA_RULES; - } - case 101: break; - case 77: - { return GUIDefaultsFile.Keyword.VIA_SNAP_TO_SMD_CENTER; - } - case 102: break; - case 38: - { return GUIDefaultsFile.Keyword.BOARD_FRAME; - } - case 103: break; - case 61: - { return GUIDefaultsFile.Keyword.ROUTE_PARAMETER; - } - case 104: break; - case 29: - { return GUIDefaultsFile.Keyword.PARAMETER; - } - case 105: break; - case 33: - { return GUIDefaultsFile.Keyword.CONDUCTION; - } - case 106: break; - case 48: - { return GUIDefaultsFile.Keyword.OBJECT_COLORS; - } - case 107: break; - case 28: - { return GUIDefaultsFile.Keyword.STITCHING; - } - case 108: break; - case 66: - { return GUIDefaultsFile.Keyword.SELECT_PARAMETER; - } - case 109: break; - case 72: - { return GUIDefaultsFile.Keyword.OBJECT_VISIBILITY; - } - case 110: break; - case 74: - { return GUIDefaultsFile.Keyword.PULL_TIGHT_ACCURACY; - } - case 111: break; - case 58: - { return GUIDefaultsFile.Keyword.DISPLAY_REGION; - } - case 112: break; - case 71: - { return GUIDefaultsFile.Keyword.INTERACTIVE_STATE; - } - case 113: break; - case 39: - { return GUIDefaultsFile.Keyword.NOT_VISIBLE; - } - case 114: break; - case 20: - { return GUIDefaultsFile.Keyword.DYNAMIC; - } - case 115: break; - case 84: - { return GUIDefaultsFile.Keyword.DESELECTED_SNAPSHOT_ATTRIBUTES; - } - case 116: break; - case 31: - { return GUIDefaultsFile.Keyword.BACKGROUND; - } - case 117: break; - case 64: - { return GUIDefaultsFile.Keyword.LAYER_VISIBILITY; - } - case 118: break; - case 43: - { return GUIDefaultsFile.Keyword.FIXED_TRACES; - } - case 119: break; - case 51: - { return GUIDefaultsFile.Keyword.PADSTACK_INFO; - } - case 120: break; - case 22: - { return GUIDefaultsFile.Keyword.HILIGHT; - } - case 121: break; - case 14: - { return GUIDefaultsFile.Keyword.BOUNDS; - } - case 122: break; - case 82: - { return GUIDefaultsFile.Keyword.DRAG_COMPONENTS_ENABLED; - } - case 123: break; - case 75: - { return GUIDefaultsFile.Keyword.MANUAL_RULE_SETTINGS; - } - case 124: break; - case 10: - { return GUIDefaultsFile.Keyword.VIAS; - } - case 125: break; - case 3: - { return yytext(); - } - case 126: break; - case 55: - { return GUIDefaultsFile.Keyword.COMPONENT_INFO; - } - case 127: break; - case 32: - { return GUIDefaultsFile.Keyword.ROUTE_MODE; - } - case 128: break; - case 50: - { return GUIDefaultsFile.Keyword.COLOR_MANAGER; - } - case 129: break; - case 30: - { return GUIDefaultsFile.Keyword.VIOLATIONS; - } - case 130: break; - case 67: - { return GUIDefaultsFile.Keyword.SELECTABLE_ITEMS; - } - case 131: break; - case 19: - { return GUIDefaultsFile.Keyword.OUTLINE; - } - case 132: break; - case 42: - { return GUIDefaultsFile.Keyword.CURRENT_ONLY; - } - case 133: break; - case 9: - { return GUIDefaultsFile.Keyword.OFF; - } - case 134: break; - case 45: - { return GUIDefaultsFile.Keyword.SHOVE_ENABLED; - } - case 135: break; - case 63: - { return GUIDefaultsFile.Keyword.ASSIGN_NET_RULES; - } - case 136: break; - case 25: - { return GUIDefaultsFile.Keyword.EDIT_VIAS; - } - case 137: break; - case 81: - { return GUIDefaultsFile.Keyword.IGNORE_CONDUCTION_AREAS; - } - case 138: break; - case 5: - { return GUIDefaultsFile.Keyword.OPEN_BRACKET; - } - case 139: break; - case 36: - { return GUIDefaultsFile.Keyword.VIA_KEEPOUT; - } - case 140: break; - case 8: - { return GUIDefaultsFile.Keyword.ON; - } - case 141: break; - case 16: - { return GUIDefaultsFile.Keyword.COLORS; - } - case 142: break; - case 68: - { return GUIDefaultsFile.Keyword.SELECTION_LAYERS; - } - case 143: break; - case 46: - { return GUIDefaultsFile.Keyword.NINETY_DEGREE; - } - case 144: break; - case 23: - { return GUIDefaultsFile.Keyword.WINDOWS; - } - case 145: break; - case 57: - { return GUIDefaultsFile.Keyword.COMPONENT_GRID; - } - case 146: break; - case 7: - { return new Double(yytext()); - } - case 147: break; - case 69: - { return GUIDefaultsFile.Keyword.CLEARANCE_MATRIX; - } - case 148: break; - case 65: - { return GUIDefaultsFile.Keyword.INCOMPLETES_INFO; - } - case 149: break; - case 62: - { return GUIDefaultsFile.Keyword.COMPONENT_FRONT; - } - case 150: break; - case 18: - { return GUIDefaultsFile.Keyword.UNFIXED; - } - case 151: break; - case 59: - { return GUIDefaultsFile.Keyword.LENGTH_MATCHING; - } - case 152: break; - case 80: - { return GUIDefaultsFile.Keyword.AUTOMATIC_LAYER_DIMMING; - } - case 153: break; - case 79: - { return GUIDefaultsFile.Keyword.PUSH_AND_SHOVE_ENABLED; - } - case 154: break; - case 24: - { return GUIDefaultsFile.Keyword.NET_INFO; - } - case 155: break; - case 78: - { return GUIDefaultsFile.Keyword.CLEARANCE_COMPENSATION; - } - case 156: break; - case 47: - { return GUIDefaultsFile.Keyword.ROUTE_DETAILS; - } - case 157: break; - case 2: - { /* ignore */ - } - case 158: break; - case 83: - { return GUIDefaultsFile.Keyword.HILIGHT_ROUTING_OBSTACLE; - } - case 159: break; - case 35: - { return GUIDefaultsFile.Keyword.ALL_VISIBLE; - } - case 160: break; - case 6: - { return GUIDefaultsFile.Keyword.CLOSED_BRACKET; - } - case 161: break; - case 1: - { throw new Error("Illegal character <"+ - yytext()+">"); - } - case 162: break; - case 37: - { return GUIDefaultsFile.Keyword.INCOMPLETES; - } - case 163: break; - case 49: - { return GUIDefaultsFile.Keyword.CURRENT_LAYER; - } - case 164: break; - case 21: - { return GUIDefaultsFile.Keyword.KEEPOUT; - } - case 165: break; - case 4: - { return new Integer(yytext()); - } - case 166: break; - case 13: - { return GUIDefaultsFile.Keyword.FIXED; - } - case 167: break; - case 27: - { return GUIDefaultsFile.Keyword.SNAPSHOTS; - } - case 168: break; - default: - if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { - zzAtEOF = true; - return null; - } - else { - zzScanError(ZZ_NO_MATCH); - } - } } - } } diff --git a/src/main/java/net/freerouting/gui/MainApplication.java b/src/main/java/net/freerouting/gui/MainApplication.java index 54c67b72..e66b9bdc 100644 --- a/src/main/java/net/freerouting/gui/MainApplication.java +++ b/src/main/java/net/freerouting/gui/MainApplication.java @@ -25,114 +25,39 @@ import java.util.Locale; /** - * * Main application for creating frames with new or existing board designs. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class MainApplication extends javax.swing.JFrame -{ +public class MainApplication extends javax.swing.JFrame { + static final String WEB_FILE_BASE_NAME = "http://www.freerouting.net/java/"; /** - * Main function of the Application + * Change this string when creating a new version */ - public static void main(String p_args[]) - { - boolean single_design_option = false; - boolean test_version_option = false; - boolean session_file_option = false; - String design_file_name = null; - String design_dir_name = null; - java.util.Locale current_locale = java.util.Locale.ENGLISH; - for (int i = 0; i < p_args.length; ++i) - { - if (p_args[i].startsWith("-de")) - // the design file is provided - { - if (p_args.length > i + 1 && !p_args[i + 1].startsWith("-")) - { - single_design_option = true; - design_file_name = p_args[i + 1]; - } - } - else if (p_args[i].startsWith("-di")) - // the design directory is provided - { - if (p_args.length > i + 1 && !p_args[i + 1].startsWith("-")) - { - design_dir_name = p_args[i + 1]; - } - } - else if (p_args[i].startsWith("-l")) - // the locale is provided - { - if (p_args.length > i + 1 && p_args[i + 1].startsWith("d")) - { - current_locale = java.util.Locale.GERMAN; - } - } - else if (p_args[i].startsWith("-s")) - { - session_file_option = true; - } - else if (p_args[i].startsWith("-test")) - { - test_version_option = true; - } - } - - if (single_design_option) - { - java.util.ResourceBundle resources = - java.util.ResourceBundle.getBundle("net.freerouting.gui.MainApplication", current_locale); - BoardFrame.Option board_option; - if (session_file_option) - { - board_option = BoardFrame.Option.SESSION_FILE; - } - else - { - board_option = BoardFrame.Option.SINGLE_FRAME; - } - DesignFile design_file = DesignFile.get_instance(design_file_name); - if (design_file == null) - { - System.out.print(resources.getString("message_6") + " "); - System.out.print(design_file_name); - System.out.println(" " + resources.getString("message_7")); - return; - } - String message = resources.getString("loading_design") + " " + design_file_name; - WindowMessage welcome_window = WindowMessage.show(message); - final BoardFrame new_frame = - create_board_frame(design_file, null, board_option, test_version_option, current_locale); - welcome_window.dispose(); - if (new_frame == null) - { - Runtime.getRuntime().exit(1); - } - new_frame.addWindowListener(new java.awt.event.WindowAdapter() - { - - public void windowClosed(java.awt.event.WindowEvent evt) - { - Runtime.getRuntime().exit(0); - } - }); - } - else - { - new MainApplication(design_dir_name, test_version_option, current_locale).setVisible(true); - } - } - + static final String VERSION_NUMBER_STRING = "1.2.43"; + private static final TestLevel DEBUG_LEVEL = TestLevel.CRITICAL_DEBUGGING_OUTPUT; + private static final boolean OFFLINE_ALLOWED = true; + private final java.util.ResourceBundle resources; + private final javax.swing.JButton demonstration_button; + private final javax.swing.JButton sample_board_button; + private final javax.swing.JButton open_board_button; + private final javax.swing.JButton restore_defaults_button; + private final boolean is_test_version; + private final java.util.Locale locale; + private javax.swing.JTextField message_field; + private javax.swing.JPanel main_panel; + /** + * The list of open board frames + */ + private java.util.Collection board_frames = new java.util.LinkedList(); + private String design_dir_name = null; /** * Creates new form MainApplication * It takes the directory of the board designs as optional argument. */ public MainApplication(String p_design_dir, boolean p_is_test_version, - Locale p_current_locale) - { + Locale p_current_locale) { this.design_dir_name = p_design_dir; this.is_test_version = p_is_test_version; this.locale = p_current_locale; @@ -159,11 +84,9 @@ public MainApplication(String p_design_dir, boolean p_is_test_version, open_board_button.setText(resources.getString("open_own_design")); open_board_button.setToolTipText(resources.getString("open_own_design_tooltip")); - open_board_button.addActionListener(new java.awt.event.ActionListener() - { + open_board_button.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { open_board_design_action(evt); } }); @@ -180,40 +103,76 @@ public void actionPerformed(java.awt.event.ActionEvent evt) pack(); } - /** opens a board design from a binary file or a specctra dsn file. */ - private void open_board_design_action(java.awt.event.ActionEvent evt) - { - - DesignFile design_file = DesignFile.open_dialog(this.design_dir_name); - - if (design_file == null) - { - message_field.setText(resources.getString("message_3")); - return; + /** + * Main function of the Application + */ + public static void main(String p_args[]) { + boolean single_design_option = false; + boolean test_version_option = false; + boolean session_file_option = false; + String design_file_name = null; + String design_dir_name = null; + java.util.Locale current_locale = java.util.Locale.ENGLISH; + for (int i = 0; i < p_args.length; ++i) { + if (p_args[i].startsWith("-de")) + // the design file is provided + { + if (p_args.length > i + 1 && !p_args[i + 1].startsWith("-")) { + single_design_option = true; + design_file_name = p_args[i + 1]; + } + } else if (p_args[i].startsWith("-di")) + // the design directory is provided + { + if (p_args.length > i + 1 && !p_args[i + 1].startsWith("-")) { + design_dir_name = p_args[i + 1]; + } + } else if (p_args[i].startsWith("-l")) + // the locale is provided + { + if (p_args.length > i + 1 && p_args[i + 1].startsWith("d")) { + current_locale = java.util.Locale.GERMAN; + } + } else if (p_args[i].startsWith("-s")) { + session_file_option = true; + } else if (p_args[i].startsWith("-test")) { + test_version_option = true; + } } - BoardFrame.Option option; - option = BoardFrame.Option.FROM_START_MENU; - String message = resources.getString("loading_design") + " " + design_file.get_name(); - message_field.setText(message); - WindowMessage welcome_window = WindowMessage.show(message); - welcome_window.setTitle(message); - BoardFrame new_frame = - create_board_frame(design_file, message_field, option, this.is_test_version, this.locale); - welcome_window.dispose(); - if (new_frame == null) - { - return; - } - message_field.setText(resources.getString("message_4") + " " + design_file.get_name() + " " + resources.getString("message_5")); - board_frames.add(new_frame); - new_frame.addWindowListener(new BoardFrameWindowListener(new_frame)); - } + if (single_design_option) { + java.util.ResourceBundle resources = + java.util.ResourceBundle.getBundle("net.freerouting.gui.MainApplication", current_locale); + BoardFrame.Option board_option; + if (session_file_option) { + board_option = BoardFrame.Option.SESSION_FILE; + } else { + board_option = BoardFrame.Option.SINGLE_FRAME; + } + DesignFile design_file = DesignFile.get_instance(design_file_name); + if (design_file == null) { + System.out.print(resources.getString("message_6") + " "); + System.out.print(design_file_name); + System.out.println(" " + resources.getString("message_7")); + return; + } + String message = resources.getString("loading_design") + " " + design_file_name; + WindowMessage welcome_window = WindowMessage.show(message); + final BoardFrame new_frame = + create_board_frame(design_file, null, board_option, test_version_option, current_locale); + welcome_window.dispose(); + if (new_frame == null) { + Runtime.getRuntime().exit(1); + } + new_frame.addWindowListener(new java.awt.event.WindowAdapter() { - /** Exit the Application */ - private void exitForm(java.awt.event.WindowEvent evt) - { - System.exit(0); + public void windowClosed(java.awt.event.WindowEvent evt) { + Runtime.getRuntime().exit(0); + } + }); + } else { + new MainApplication(design_dir_name, test_version_option, current_locale).setVisible(true); + } } /** @@ -221,39 +180,31 @@ private void exitForm(java.awt.event.WindowEvent evt) * Returns null, if an error occured. */ static private BoardFrame create_board_frame(DesignFile p_design_file, javax.swing.JTextField p_message_field, - BoardFrame.Option p_option, boolean p_is_test_version, java.util.Locale p_locale) - { + BoardFrame.Option p_option, boolean p_is_test_version, java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.MainApplication", p_locale); java.io.InputStream input_stream = p_design_file.get_input_stream(); - if (input_stream == null) - { - if (p_message_field != null) - { + if (input_stream == null) { + if (p_message_field != null) { p_message_field.setText(resources.getString("message_8") + " " + p_design_file.get_name()); } return null; } TestLevel test_level; - if (p_is_test_version) - { + if (p_is_test_version) { test_level = DEBUG_LEVEL; - } - else - { + } else { test_level = TestLevel.RELEASE_VERSION; } BoardFrame new_frame = new BoardFrame(p_design_file, p_option, test_level, p_locale, !p_is_test_version); boolean read_ok = new_frame.read(input_stream, p_design_file.is_created_from_text_file(), p_message_field); - if (!read_ok) - { + if (!read_ok) { return null; } new_frame.menubar.add_design_dependent_items(); - if (p_design_file.is_created_from_text_file()) - { + if (p_design_file.is_created_from_text_file()) { // Read the file with the saved rules, if it is existing. String file_name = p_design_file.get_name(); @@ -266,68 +217,77 @@ static private BoardFrame create_board_frame(DesignFile p_design_file, javax.swi } return new_frame; } - private final java.util.ResourceBundle resources; - private final javax.swing.JButton demonstration_button; - private final javax.swing.JButton sample_board_button; - private final javax.swing.JButton open_board_button; - private final javax.swing.JButton restore_defaults_button; - private javax.swing.JTextField message_field; - private javax.swing.JPanel main_panel; - /** The list of open board frames */ - private java.util.Collection board_frames = new java.util.LinkedList(); - private String design_dir_name = null; - private final boolean is_test_version; - private final java.util.Locale locale; - private static final TestLevel DEBUG_LEVEL = TestLevel.CRITICAL_DEBUGGING_OUTPUT; - private class BoardFrameWindowListener extends java.awt.event.WindowAdapter - { + /** + * opens a board design from a binary file or a specctra dsn file. + */ + private void open_board_design_action(java.awt.event.ActionEvent evt) { - public BoardFrameWindowListener(BoardFrame p_board_frame) - { + DesignFile design_file = DesignFile.open_dialog(this.design_dir_name); + + if (design_file == null) { + message_field.setText(resources.getString("message_3")); + return; + } + + BoardFrame.Option option; + option = BoardFrame.Option.FROM_START_MENU; + String message = resources.getString("loading_design") + " " + design_file.get_name(); + message_field.setText(message); + WindowMessage welcome_window = WindowMessage.show(message); + welcome_window.setTitle(message); + BoardFrame new_frame = + create_board_frame(design_file, message_field, option, this.is_test_version, this.locale); + welcome_window.dispose(); + if (new_frame == null) { + return; + } + message_field.setText(resources.getString("message_4") + " " + design_file.get_name() + " " + resources.getString("message_5")); + board_frames.add(new_frame); + new_frame.addWindowListener(new BoardFrameWindowListener(new_frame)); + } + + /** + * Exit the Application + */ + private void exitForm(java.awt.event.WindowEvent evt) { + System.exit(0); + } + + private class BoardFrameWindowListener extends java.awt.event.WindowAdapter { + + private BoardFrame board_frame; + + public BoardFrameWindowListener(BoardFrame p_board_frame) { this.board_frame = p_board_frame; } - public void windowClosed(java.awt.event.WindowEvent evt) - { - if (board_frame != null) - { + public void windowClosed(java.awt.event.WindowEvent evt) { + if (board_frame != null) { // remove this board_frame from the list of board frames board_frame.dispose(); board_frames.remove(board_frame); board_frame = null; } } - private BoardFrame board_frame; } - private class WindowStateListener extends java.awt.event.WindowAdapter - { + private class WindowStateListener extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent evt) - { + public void windowClosing(java.awt.event.WindowEvent evt) { setDefaultCloseOperation(DISPOSE_ON_CLOSE); boolean exit_program = true; - if (!is_test_version && board_frames.size() > 0) - { + if (!is_test_version && board_frames.size() > 0) { int option = javax.swing.JOptionPane.showConfirmDialog(null, resources.getString("confirm_cancel"), null, javax.swing.JOptionPane.YES_NO_OPTION); - if (option == javax.swing.JOptionPane.NO_OPTION) - { + if (option == javax.swing.JOptionPane.NO_OPTION) { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); exit_program = false; } } - if (exit_program) - { + if (exit_program) { exitForm(evt); } } } - static final String WEB_FILE_BASE_NAME = "http://www.freerouting.net/java/"; - private static final boolean OFFLINE_ALLOWED = true; - /** - * Change this string when creating a new version - */ - static final String VERSION_NUMBER_STRING = "1.2.43"; } diff --git a/src/main/java/net/freerouting/gui/PopupMenuChangeLayer.java b/src/main/java/net/freerouting/gui/PopupMenuChangeLayer.java index 22df420a..72cfaa9f 100644 --- a/src/main/java/net/freerouting/gui/PopupMenuChangeLayer.java +++ b/src/main/java/net/freerouting/gui/PopupMenuChangeLayer.java @@ -25,26 +25,27 @@ * * @author Alfons Wirtz */ -class PopupMenuChangeLayer extends javax.swing.JMenu -{ - - /** Creates a new instance of ChangeLayerMenu */ - PopupMenuChangeLayer(BoardFrame p_board_frame) - { +class PopupMenuChangeLayer extends javax.swing.JMenu { + + private final BoardFrame board_frame; + private final LayermenuItem[] item_arr; + + /** + * Creates a new instance of ChangeLayerMenu + */ + PopupMenuChangeLayer(BoardFrame p_board_frame) { this.board_frame = p_board_frame; - + net.freerouting.board.LayerStructure layer_structure = board_frame.board_panel.board_handling.get_routing_board().layer_structure; this.item_arr = new LayermenuItem[layer_structure.signal_layer_count()]; - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); - + this.setText(resources.getString("change_layer")); this.setToolTipText(resources.getString("change_layer_tooltip")); int curr_signal_layer_no = 0; - for (int i = 0; i < layer_structure.arr.length; ++i) - { - if (layer_structure.arr[i].is_signal) - { + for (int i = 0; i < layer_structure.arr.length; ++i) { + if (layer_structure.arr[i].is_signal) { this.item_arr[curr_signal_layer_no] = new LayermenuItem(i); this.item_arr[curr_signal_layer_no].setText(layer_structure.arr[i].name); this.add(this.item_arr[curr_signal_layer_no]); @@ -52,44 +53,32 @@ class PopupMenuChangeLayer extends javax.swing.JMenu } } } - + /** * Disables the item with index p_no and enables all other items. */ - void disable_item(int p_no) - { - for (int i = 0; i < item_arr.length; ++i) - { - if (i == p_no) - { + void disable_item(int p_no) { + for (int i = 0; i < item_arr.length; ++i) { + if (i == p_no) { this.item_arr[i].setEnabled(false); - } - else - { + } else { this.item_arr[i].setEnabled(true); } } } - - private final BoardFrame board_frame; - - private final LayermenuItem [] item_arr; - - private class LayermenuItem extends javax.swing.JMenuItem - { - LayermenuItem(int p_layer_no) - { - java.util.ResourceBundle resources = + + private class LayermenuItem extends javax.swing.JMenuItem { + private final int layer_no; + private final String message1; + LayermenuItem(int p_layer_no) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", board_frame.get_locale()); message1 = resources.getString("layer_changed_to") + " "; layer_no = p_layer_no; - addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { final BoardPanel board_panel = board_frame.board_panel; - if (board_panel.board_handling.change_layer_action(layer_no)) - { + if (board_panel.board_handling.change_layer_action(layer_no)) { String layer_name = board_panel.board_handling.get_routing_board().layer_structure.arr[layer_no].name; board_panel.screen_messages.set_status_message(message1 + layer_name); } @@ -99,8 +88,5 @@ public void actionPerformed(java.awt.event.ActionEvent evt) } }); } - - private final int layer_no; - private final String message1; } } diff --git a/src/main/java/net/freerouting/gui/PopupMenuCopy.java b/src/main/java/net/freerouting/gui/PopupMenuCopy.java index aeea4a66..88ddc599 100644 --- a/src/main/java/net/freerouting/gui/PopupMenuCopy.java +++ b/src/main/java/net/freerouting/gui/PopupMenuCopy.java @@ -25,64 +25,55 @@ * * @author Alfons Wirtz */ -public class PopupMenuCopy extends PopupMenuDisplay -{ - - /** Creates a new instance of CopyPopupMenu */ - PopupMenuCopy(BoardFrame p_board_frame) - { +public class PopupMenuCopy extends PopupMenuDisplay { + + private final PopupMenuChangeLayer change_layer_menu; + + /** + * Creates a new instance of CopyPopupMenu + */ + PopupMenuCopy(BoardFrame p_board_frame) { super(p_board_frame); net.freerouting.board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; - - if (layer_structure.arr.length > 0) - { + + if (layer_structure.arr.length > 0) { change_layer_menu = new PopupMenuChangeLayer(p_board_frame); this.add(change_layer_menu, 0); - } - else - { + } else { change_layer_menu = null; } - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem insert_item = new javax.swing.JMenuItem(); insert_item.setText(resources.getString("insert")); - insert_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + insert_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.left_button_clicked(board_panel.right_button_click_location); } }); - + this.add(insert_item, 0); - + javax.swing.JMenuItem done_item = new javax.swing.JMenuItem(); done_item.setText(resources.getString("done")); - done_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + done_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.return_from_state(); } }); - + this.add(done_item, 1); - + net.freerouting.board.Layer curr_layer = layer_structure.arr[board_panel.board_handling.settings.get_layer()]; disable_layer_item(layer_structure.get_signal_layer_no(curr_layer)); } - + /** * Disables the p_no-th item in the change_layer_menu. */ - void disable_layer_item( int p_no) - { - if (this.change_layer_menu != null) - { + void disable_layer_item(int p_no) { + if (this.change_layer_menu != null) { this.change_layer_menu.disable_item(p_no); } } - - private final PopupMenuChangeLayer change_layer_menu; } diff --git a/src/main/java/net/freerouting/gui/PopupMenuDisplay.java b/src/main/java/net/freerouting/gui/PopupMenuDisplay.java index 62d9d589..93f3a063 100644 --- a/src/main/java/net/freerouting/gui/PopupMenuDisplay.java +++ b/src/main/java/net/freerouting/gui/PopupMenuDisplay.java @@ -25,59 +25,52 @@ package net.freerouting.gui; /** - * * @author Alfons Wirtz */ -public class PopupMenuDisplay extends javax.swing.JPopupMenu -{ - - /** Creates a new instance of PopupMenuDisplay */ - public PopupMenuDisplay(BoardFrame p_board_frame) - { +public class PopupMenuDisplay extends javax.swing.JPopupMenu { + + protected final BoardPanel board_panel; + + /** + * Creates a new instance of PopupMenuDisplay + */ + public PopupMenuDisplay(BoardFrame p_board_frame) { this.board_panel = p_board_frame.board_panel; - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem center_display_item = new javax.swing.JMenuItem(); center_display_item.setText(resources.getString("center_display")); - center_display_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + center_display_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.center_display(board_panel.right_button_click_location); } }); - + this.add(center_display_item); - + javax.swing.JMenu zoom_menu = new javax.swing.JMenu(); zoom_menu.setText(resources.getString("zoom")); - + javax.swing.JMenuItem zoom_in_item = new javax.swing.JMenuItem(); zoom_in_item.setText(resources.getString("zoom_in")); - zoom_in_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + zoom_in_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.zoom_in(board_panel.right_button_click_location); } }); - + zoom_menu.add(zoom_in_item); - + javax.swing.JMenuItem zoom_out_item = new javax.swing.JMenuItem(); zoom_out_item.setText(resources.getString("zoom_out")); - zoom_out_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + zoom_out_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.zoom_out(board_panel.right_button_click_location); } }); - + zoom_menu.add(zoom_out_item); - + this.add(zoom_menu); } - - protected final BoardPanel board_panel; } diff --git a/src/main/java/net/freerouting/gui/PopupMenuDynamicRoute.java b/src/main/java/net/freerouting/gui/PopupMenuDynamicRoute.java index 354926be..2093fa3f 100644 --- a/src/main/java/net/freerouting/gui/PopupMenuDynamicRoute.java +++ b/src/main/java/net/freerouting/gui/PopupMenuDynamicRoute.java @@ -25,79 +25,68 @@ * * @author Alfons Wirtz */ -public class PopupMenuDynamicRoute extends PopupMenuDisplay -{ - - /** Creates a new instance of RoutePopupMenu */ - PopupMenuDynamicRoute(BoardFrame p_board_frame) - { +public class PopupMenuDynamicRoute extends PopupMenuDisplay { + + private final PopupMenuChangeLayer change_layer_menu; + + /** + * Creates a new instance of RoutePopupMenu + */ + PopupMenuDynamicRoute(BoardFrame p_board_frame) { super(p_board_frame); - - java.util.ResourceBundle resources = + + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); net.freerouting.board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; - - + + javax.swing.JMenuItem end_route_item = new javax.swing.JMenuItem(); end_route_item.setText(resources.getString("end_route")); - end_route_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + end_route_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.return_from_state(); } }); - + this.add(end_route_item, 0); - + javax.swing.JMenuItem cancel_item = new javax.swing.JMenuItem(); cancel_item.setText(resources.getString("cancel_route")); - cancel_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + cancel_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.cancel_state(); } }); - + this.add(cancel_item, 1); - + javax.swing.JMenuItem snapshot_item = new javax.swing.JMenuItem(); snapshot_item.setText(resources.getString("generate_snapshot")); - snapshot_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + snapshot_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.generate_snapshot(); } }); - + this.add(snapshot_item, 2); - - if ( layer_structure.arr.length > 0) - { + + if (layer_structure.arr.length > 0) { this.change_layer_menu = new PopupMenuChangeLayer(p_board_frame); this.add(change_layer_menu, 0); - } - else - { + } else { this.change_layer_menu = null; } - + net.freerouting.board.Layer curr_layer = layer_structure.arr[board_panel.board_handling.settings.get_layer()]; disable_layer_item(layer_structure.get_signal_layer_no(curr_layer)); } - + /** * Disables the p_no-th item in the change_layer_menu. */ - void disable_layer_item( int p_no) - { - if (this.change_layer_menu != null) - { + void disable_layer_item(int p_no) { + if (this.change_layer_menu != null) { this.change_layer_menu.disable_item(p_no); } } - - private final PopupMenuChangeLayer change_layer_menu; } diff --git a/src/main/java/net/freerouting/gui/PopupMenuInsertCancel.java b/src/main/java/net/freerouting/gui/PopupMenuInsertCancel.java index e173c15f..e8efdb1d 100644 --- a/src/main/java/net/freerouting/gui/PopupMenuInsertCancel.java +++ b/src/main/java/net/freerouting/gui/PopupMenuInsertCancel.java @@ -25,39 +25,35 @@ * * @author Alfons Wirtz */ -class PopupMenuInsertCancel extends javax.swing.JPopupMenu -{ - - /** Creates a new instance of CompleteCancelPopupMenu */ - PopupMenuInsertCancel(BoardFrame p_board_frame) - { +class PopupMenuInsertCancel extends javax.swing.JPopupMenu { + + private final BoardPanel board_panel; + + /** + * Creates a new instance of CompleteCancelPopupMenu + */ + PopupMenuInsertCancel(BoardFrame p_board_frame) { this.board_panel = p_board_frame.board_panel; - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem insert_item = new javax.swing.JMenuItem(); insert_item.setText(resources.getString("insert")); - insert_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + insert_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.return_from_state(); } }); - + this.add(insert_item); - + javax.swing.JMenuItem cancel_item = new javax.swing.JMenuItem(); cancel_item.setText(resources.getString("cancel")); - cancel_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + cancel_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.cancel_state(); } }); - + this.add(cancel_item); } - - private final BoardPanel board_panel; } diff --git a/src/main/java/net/freerouting/gui/PopupMenuMain.java b/src/main/java/net/freerouting/gui/PopupMenuMain.java index 7fed91a7..edb752b2 100644 --- a/src/main/java/net/freerouting/gui/PopupMenuMain.java +++ b/src/main/java/net/freerouting/gui/PopupMenuMain.java @@ -25,118 +25,102 @@ * * @author Alfons Wirtz */ -class PopupMenuMain extends PopupMenuDisplay -{ - - /** Creates a new instance of MainPopupMenu */ - PopupMenuMain(BoardFrame p_board_frame) - { - super(p_board_frame) ; - java.util.ResourceBundle resources = +class PopupMenuMain extends PopupMenuDisplay { + + /** + * Creates a new instance of MainPopupMenu + */ + PopupMenuMain(BoardFrame p_board_frame) { + super(p_board_frame); + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.PopupMenuMain", p_board_frame.get_locale()); - + // add the item for selecting items - + javax.swing.JMenuItem select_item_item = new javax.swing.JMenuItem(); select_item_item.setText(resources.getString("select_item")); - select_item_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + select_item_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.select_items(board_panel.right_button_click_location); } }); - + this.add(select_item_item, 0); - + // Insert the start route item. - + javax.swing.JMenuItem start_route_item = new javax.swing.JMenuItem(); start_route_item.setText(resources.getString("start_route")); - start_route_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + start_route_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.start_route(board_panel.right_button_click_location); } }); - + this.add(start_route_item, 1); - + // Insert the create_obstacle_menu. - + javax.swing.JMenu create_obstacle_menu = new javax.swing.JMenu(); - + create_obstacle_menu.setText(resources.getString("create_keepout")); - + javax.swing.JMenuItem create_tile_item = new javax.swing.JMenuItem(); create_tile_item.setText(resources.getString("tile")); - create_tile_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + create_tile_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.start_tile(board_panel.right_button_click_location); } }); - - if (board_panel.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) - { + + if (board_panel.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { create_obstacle_menu.add(create_tile_item); } - + javax.swing.JMenuItem create_circle_item = new javax.swing.JMenuItem(); create_circle_item.setText(resources.getString("circle")); - create_circle_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + create_circle_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.start_circle(board_panel.right_button_click_location); } }); - + create_obstacle_menu.add(create_circle_item); - + javax.swing.JMenuItem create_polygon_item = new javax.swing.JMenuItem(); create_polygon_item.setText(resources.getString("polygon")); - create_polygon_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { - board_panel.board_handling.start_polygonshape_item( board_panel.right_button_click_location); + create_polygon_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + board_panel.board_handling.start_polygonshape_item(board_panel.right_button_click_location); } }); - + create_obstacle_menu.add(create_polygon_item); - + javax.swing.JMenuItem add_hole_item = new javax.swing.JMenuItem(); add_hole_item.setText(resources.getString("hole")); - add_hole_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + add_hole_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.start_adding_hole(board_panel.right_button_click_location); } }); - + create_obstacle_menu.add(add_hole_item); - + this.add(create_obstacle_menu, 2); - + // Insert the pin swap item. - - if (board_panel.board_handling.get_routing_board().library.logical_parts.count() > 0) - { + + if (board_panel.board_handling.get_routing_board().library.logical_parts.count() > 0) { // the board contains swappable gates or pins javax.swing.JMenuItem swap_pin_item = new javax.swing.JMenuItem(); swap_pin_item.setText(resources.getString("swap_pin")); - swap_pin_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + swap_pin_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.swap_pin(board_panel.right_button_click_location); } }); - + this.add(swap_pin_item, 3); } } diff --git a/src/main/java/net/freerouting/gui/PopupMenuMove.java b/src/main/java/net/freerouting/gui/PopupMenuMove.java index 3903fb08..f7cafaff 100644 --- a/src/main/java/net/freerouting/gui/PopupMenuMove.java +++ b/src/main/java/net/freerouting/gui/PopupMenuMove.java @@ -25,157 +25,132 @@ package net.freerouting.gui; /** - * * @author Alfons Wirtz */ -public class PopupMenuMove extends PopupMenuDisplay -{ - - /** Creates a new instance of PopupMenuMove */ - public PopupMenuMove(BoardFrame p_board_frame) - { +public class PopupMenuMove extends PopupMenuDisplay { + + /** + * Creates a new instance of PopupMenuMove + */ + public PopupMenuMove(BoardFrame p_board_frame) { super(p_board_frame); - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.PopupMenuMove", p_board_frame.get_locale()); - + // Add menu for turning the items by a multiple of 90 degree - + javax.swing.JMenuItem rotate_menu = new javax.swing.JMenu(); rotate_menu.setText(resources.getString("turn")); this.add(rotate_menu, 0); - + javax.swing.JMenuItem turn_90_item = new javax.swing.JMenuItem(); turn_90_item.setText(resources.getString("90_degree")); - turn_90_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + turn_90_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { turn_45_degree(2); } }); rotate_menu.add(turn_90_item); - + javax.swing.JMenuItem turn_180_item = new javax.swing.JMenuItem(); turn_180_item.setText(resources.getString("180_degree")); - turn_180_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + turn_180_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { turn_45_degree(4); } }); rotate_menu.add(turn_180_item); - + javax.swing.JMenuItem turn_270_item = new javax.swing.JMenuItem(); turn_270_item.setText(resources.getString("-90_degree")); - turn_270_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + turn_270_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { turn_45_degree(6); } }); rotate_menu.add(turn_270_item); - + javax.swing.JMenuItem turn_45_item = new javax.swing.JMenuItem(); turn_45_item.setText(resources.getString("45_degree")); - turn_45_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + turn_45_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { turn_45_degree(1); } }); rotate_menu.add(turn_45_item); - + javax.swing.JMenuItem turn_135_item = new javax.swing.JMenuItem(); turn_135_item.setText(resources.getString("135_degree")); - turn_135_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + turn_135_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { turn_45_degree(3); } }); rotate_menu.add(turn_135_item); - + javax.swing.JMenuItem turn_225_item = new javax.swing.JMenuItem(); turn_225_item.setText(resources.getString("-135_degree")); - turn_225_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + turn_225_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { turn_45_degree(5); } }); rotate_menu.add(turn_225_item); - + javax.swing.JMenuItem turn_315_item = new javax.swing.JMenuItem(); turn_315_item.setText(resources.getString("-45_degree")); - turn_315_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + turn_315_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { turn_45_degree(7); } }); rotate_menu.add(turn_315_item); - + javax.swing.JMenuItem change_side_item = new javax.swing.JMenuItem(); change_side_item.setText(resources.getString("change_side")); - change_side_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + change_side_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.change_placement_side(); } }); - + this.add(change_side_item, 1); - + javax.swing.JMenuItem reset_rotation_item = new javax.swing.JMenuItem(); reset_rotation_item.setText(resources.getString("reset_rotation")); - reset_rotation_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + reset_rotation_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { net.freerouting.interactive.InteractiveState interactive_state = board_panel.board_handling.get_interactive_state(); - if (interactive_state instanceof net.freerouting.interactive.MoveItemState) - { - ((net.freerouting.interactive.MoveItemState)interactive_state).reset_rotation(); + if (interactive_state instanceof net.freerouting.interactive.MoveItemState) { + ((net.freerouting.interactive.MoveItemState) interactive_state).reset_rotation(); } } }); - + this.add(reset_rotation_item, 2); - + javax.swing.JMenuItem insert_item = new javax.swing.JMenuItem(); insert_item.setText(resources.getString("insert")); - insert_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + insert_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.return_from_state(); } }); - + this.add(insert_item, 3); - + javax.swing.JMenuItem cancel_item = new javax.swing.JMenuItem(); cancel_item.setText(resources.getString("cancel")); - cancel_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + cancel_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.cancel_state(); } }); - + this.add(cancel_item, 4); } - - private void turn_45_degree(int p_factor) - { + + private void turn_45_degree(int p_factor) { board_panel.board_handling.turn_45_degree(p_factor); board_panel.move_mouse(board_panel.right_button_click_location); } diff --git a/src/main/java/net/freerouting/gui/PopupMenuSelectedItems.java b/src/main/java/net/freerouting/gui/PopupMenuSelectedItems.java index e59d840f..4c8b3232 100644 --- a/src/main/java/net/freerouting/gui/PopupMenuSelectedItems.java +++ b/src/main/java/net/freerouting/gui/PopupMenuSelectedItems.java @@ -25,40 +25,35 @@ * * @author Alfons Wirtz */ -class PopupMenuSelectedItems extends PopupMenuDisplay -{ - - /** Creates a new instance of SelectedItemPopupMenu */ - PopupMenuSelectedItems(BoardFrame p_board_frame) - { +class PopupMenuSelectedItems extends PopupMenuDisplay { + + /** + * Creates a new instance of SelectedItemPopupMenu + */ + PopupMenuSelectedItems(BoardFrame p_board_frame) { super(p_board_frame); - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem copy_item = new javax.swing.JMenuItem(); copy_item.setText(resources.getString("copy")); - copy_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + copy_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.copy_selected_items(board_panel.right_button_click_location); } }); - - if (board_panel.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) - { + + if (board_panel.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { this.add(copy_item); } - + javax.swing.JMenuItem move_item = new javax.swing.JMenuItem(); move_item.setText(resources.getString("move")); - move_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + move_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.move_selected_items(board_panel.right_button_click_location); } }); - + this.add(move_item, 0); } } diff --git a/src/main/java/net/freerouting/gui/PopupMenuStitchRoute.java b/src/main/java/net/freerouting/gui/PopupMenuStitchRoute.java index ee9d290b..083921ef 100644 --- a/src/main/java/net/freerouting/gui/PopupMenuStitchRoute.java +++ b/src/main/java/net/freerouting/gui/PopupMenuStitchRoute.java @@ -22,79 +22,67 @@ package net.freerouting.gui; /** - * * @author Alfons Wirtz */ -public class PopupMenuStitchRoute extends PopupMenuDisplay -{ - - /** Creates a new instance of PopupMenuStitchRoute */ - public PopupMenuStitchRoute(BoardFrame p_board_frame) - { +public class PopupMenuStitchRoute extends PopupMenuDisplay { + + private final PopupMenuChangeLayer change_layer_menu; + + /** + * Creates a new instance of PopupMenuStitchRoute + */ + public PopupMenuStitchRoute(BoardFrame p_board_frame) { super(p_board_frame); net.freerouting.board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; - - if (layer_structure.arr.length > 0) - { + + if (layer_structure.arr.length > 0) { change_layer_menu = new PopupMenuChangeLayer(p_board_frame); this.add(change_layer_menu, 0); - } - else - { + } else { change_layer_menu = null; } - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem insert_item = new javax.swing.JMenuItem(); insert_item.setText(resources.getString("insert")); - insert_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + insert_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.left_button_clicked(board_panel.right_button_click_location); } }); - + this.add(insert_item, 0); - + javax.swing.JMenuItem done_item = new javax.swing.JMenuItem(); done_item.setText(resources.getString("done")); - done_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + done_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.return_from_state(); } }); - + this.add(done_item, 1); - + javax.swing.JMenuItem cancel_item = new javax.swing.JMenuItem(); cancel_item.setText(resources.getString("cancel")); - cancel_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + cancel_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.cancel_state(); } }); - + this.add(cancel_item, 2); - + net.freerouting.board.Layer curr_layer = layer_structure.arr[board_panel.board_handling.settings.get_layer()]; disable_layer_item(layer_structure.get_signal_layer_no(curr_layer)); } - + /** * Disables the p_no-th item in the change_layer_menu. */ - void disable_layer_item( int p_no) - { - if (this.change_layer_menu != null) - { + void disable_layer_item(int p_no) { + if (this.change_layer_menu != null) { this.change_layer_menu.disable_item(p_no); } } - - private final PopupMenuChangeLayer change_layer_menu; } diff --git a/src/main/java/net/freerouting/gui/PupupMenuCornerItemConstruction.java b/src/main/java/net/freerouting/gui/PupupMenuCornerItemConstruction.java index afa3b9a4..59f59ab2 100644 --- a/src/main/java/net/freerouting/gui/PupupMenuCornerItemConstruction.java +++ b/src/main/java/net/freerouting/gui/PupupMenuCornerItemConstruction.java @@ -25,54 +25,48 @@ * * @author Alfons Wirtz */ -class PupupMenuCornerItemConstruction extends javax.swing.JPopupMenu -{ - - /** Creates a new instance of CornerItemConstructionPopupMenu */ - PupupMenuCornerItemConstruction(BoardFrame p_board_frame) - { +class PupupMenuCornerItemConstruction extends javax.swing.JPopupMenu { + + private final BoardPanel board_panel; + + /** + * Creates a new instance of CornerItemConstructionPopupMenu + */ + PupupMenuCornerItemConstruction(BoardFrame p_board_frame) { this.board_panel = p_board_frame.board_panel; - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JMenuItem add_corner_item = new javax.swing.JMenuItem(); add_corner_item.setText(resources.getString("add_corner")); - add_corner_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + add_corner_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { // Same action as if the left button is clicked with // the current mouse coordinates in this situation // because the left button is a short cut for this action. board_panel.board_handling.left_button_clicked(board_panel.right_button_click_location); } }); - + this.add(add_corner_item); - + javax.swing.JMenuItem close_item = new javax.swing.JMenuItem(); close_item.setText(resources.getString("close")); - close_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + close_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.return_from_state(); } }); - + this.add(close_item); - + javax.swing.JMenuItem cancel_item = new javax.swing.JMenuItem(); cancel_item.setText(resources.getString("cancel")); - cancel_item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + cancel_item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { board_panel.board_handling.cancel_state(); } }); - + this.add(cancel_item); } - - private final BoardPanel board_panel; } diff --git a/src/main/java/net/freerouting/gui/WindowAbout.java b/src/main/java/net/freerouting/gui/WindowAbout.java index 6dededb2..de2bff8c 100644 --- a/src/main/java/net/freerouting/gui/WindowAbout.java +++ b/src/main/java/net/freerouting/gui/WindowAbout.java @@ -27,46 +27,44 @@ * * @author Alfons Wirtz */ -public class WindowAbout extends BoardSavableSubWindow -{ - public WindowAbout(java.util.Locale p_locale) - { +public class WindowAbout extends BoardSavableSubWindow { + public WindowAbout(java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowAbout", p_locale); this.setTitle(resources.getString("title")); - + final javax.swing.JPanel window_panel = new javax.swing.JPanel(); this.add(window_panel); - + // Initialize gridbag layout. - + java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); window_panel.setLayout(gridbag); java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); gridbag_constraints.insets = new java.awt.Insets(5, 10, 5, 10); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; - + javax.swing.JLabel description_label = new javax.swing.JLabel(resources.getString("description")); gridbag.setConstraints(description_label, gridbag_constraints); window_panel.add(description_label, gridbag_constraints); - + String version_string = resources.getString("version") + " " + MainApplication.VERSION_NUMBER_STRING; javax.swing.JLabel version_label = new javax.swing.JLabel(version_string); gridbag.setConstraints(version_label, gridbag_constraints); window_panel.add(version_label, gridbag_constraints); - + javax.swing.JLabel warrenty_label = new javax.swing.JLabel(resources.getString("warranty")); gridbag.setConstraints(warrenty_label, gridbag_constraints); window_panel.add(warrenty_label, gridbag_constraints); - + javax.swing.JLabel homepage_label = new javax.swing.JLabel(resources.getString("homepage")); gridbag.setConstraints(homepage_label, gridbag_constraints); window_panel.add(homepage_label, gridbag_constraints); - + javax.swing.JLabel support_label = new javax.swing.JLabel(resources.getString("support")); gridbag.setConstraints(support_label, gridbag_constraints); window_panel.add(support_label, gridbag_constraints); - + this.add(window_panel); this.pack(); } diff --git a/src/main/java/net/freerouting/gui/WindowAssignNetClass.java b/src/main/java/net/freerouting/gui/WindowAssignNetClass.java index 89059a0d..66826de1 100644 --- a/src/main/java/net/freerouting/gui/WindowAssignNetClass.java +++ b/src/main/java/net/freerouting/gui/WindowAssignNetClass.java @@ -1,4 +1,3 @@ - /* * Copyright (C) 2014 Alfons Wirtz * website www.freerouting.net @@ -25,91 +24,82 @@ import net.freerouting.rules.NetClass; /** - * * @author Alfons Wirtz */ -public class WindowAssignNetClass extends BoardSavableSubWindow -{ - - /** Creates a new instance of AssignNetRulesWindow */ - public WindowAssignNetClass(BoardFrame p_board_frame) - { +public class WindowAssignNetClass extends BoardSavableSubWindow { + + private static final int TEXTFIELD_HEIGHT = 16; + private static final int TEXTFIELD_WIDTH = 100; + private final BoardFrame board_frame; + private final javax.swing.JPanel main_panel; + private final java.util.ResourceBundle resources; + private javax.swing.JScrollPane scroll_pane; + private AssignRuleTable table; + private AssignRuleTableModel table_model; + + private javax.swing.JComboBox net_rule_combo_box; + + /** + * Creates a new instance of AssignNetRulesWindow + */ + public WindowAssignNetClass(BoardFrame p_board_frame) { this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowAssignNetClass", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); - + this.board_frame = p_board_frame; - + this.main_panel = new javax.swing.JPanel(); this.main_panel.setLayout(new java.awt.BorderLayout()); - + this.table_model = new AssignRuleTableModel(); - this.table = new AssignRuleTable(this.table_model); + this.table = new AssignRuleTable(this.table_model); this.table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); this.scroll_pane = new javax.swing.JScrollPane(this.table); int table_height = TEXTFIELD_HEIGHT * Math.min(this.table_model.getRowCount(), 20); - int table_width = TEXTFIELD_WIDTH * this.table_model.getColumnCount(); + int table_width = TEXTFIELD_WIDTH * this.table_model.getColumnCount(); this.table.setPreferredScrollableViewportSize(new java.awt.Dimension(table_width, table_height)); this.main_panel.add(scroll_pane, java.awt.BorderLayout.CENTER); add_net_class_combo_box(); - + p_board_frame.set_context_sensitive_help(this, "WindowNetClasses_AssignNetClass"); - + this.add(main_panel); this.pack(); } - - private void add_net_class_combo_box() - { + + private void add_net_class_combo_box() { this.net_rule_combo_box = new javax.swing.JComboBox(); net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); - for(int i = 0; i < routing_board.rules.net_classes.count(); ++i) - { + for (int i = 0; i < routing_board.rules.net_classes.count(); ++i) { net_rule_combo_box.addItem(routing_board.rules.net_classes.get(i)); } this.table.getColumnModel().getColumn(1).setCellEditor(new javax.swing.DefaultCellEditor(net_rule_combo_box)); } - - public void refresh() - { + + public void refresh() { // Reinsert the net class column. - for (int i = 0; i < table_model.getRowCount(); ++i) - { - table_model.setValueAt(((Net)table_model.getValueAt(i, 0)).get_class(), i, 1); + for (int i = 0; i < table_model.getRowCount(); ++i) { + table_model.setValueAt(((Net) table_model.getValueAt(i, 0)).get_class(), i, 1); } - + // Reinsert the net rule combobox because a rule may have been added or deleted. add_net_class_combo_box(); } - - - private final BoardFrame board_frame; - - private final javax.swing.JPanel main_panel; - - private javax.swing.JScrollPane scroll_pane; - private AssignRuleTable table; - private AssignRuleTableModel table_model; - - private javax.swing.JComboBox net_rule_combo_box; - - private final java.util.ResourceBundle resources; - - private static final int TEXTFIELD_HEIGHT = 16; - private static final int TEXTFIELD_WIDTH = 100; - - private class AssignRuleTable extends javax.swing.JTable - { - public AssignRuleTable(AssignRuleTableModel p_table_model) - { + + private class AssignRuleTable extends javax.swing.JTable { + private final String[] column_tool_tips = + { + resources.getString("net_name_tooltip"), resources.getString("class_name_tooltip") + }; + + public AssignRuleTable(AssignRuleTableModel p_table_model) { super(p_table_model); } + //Implement table header tool tips. - protected javax.swing.table.JTableHeader createDefaultTableHeader() - { - return new javax.swing.table.JTableHeader(columnModel) - { - public String getToolTipText(java.awt.event.MouseEvent e) - { + protected javax.swing.table.JTableHeader createDefaultTableHeader() { + return new javax.swing.table.JTableHeader(columnModel) { + public String getToolTipText(java.awt.event.MouseEvent e) { java.awt.Point p = e.getPoint(); int index = columnModel.getColumnIndexAtX(p.x); int realIndex = columnModel.getColumn(index).getModelIndex(); @@ -117,98 +107,81 @@ public String getToolTipText(java.awt.event.MouseEvent e) } }; } - - private final String[] column_tool_tips = - { - resources.getString("net_name_tooltip"), resources.getString("class_name_tooltip") - }; } - + /** * Table model of the net rule table. */ - private class AssignRuleTableModel extends javax.swing.table.AbstractTableModel - { - public AssignRuleTableModel() - { + private class AssignRuleTableModel extends javax.swing.table.AbstractTableModel { + private Object[][] data = null; + private String[] column_names = null; + + + public AssignRuleTableModel() { column_names = new String[2]; - + column_names[0] = resources.getString("net_name"); column_names[1] = resources.getString("class_name"); - + net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; data = new Object[board_rules.nets.max_net_no()][]; - for (int i = 0; i < data.length; ++i) - { + for (int i = 0; i < data.length; ++i) { this.data[i] = new Object[column_names.length]; } set_values(); } - - /** Calculates the the valus in this table */ - public void set_values() - { + + /** + * Calculates the the valus in this table + */ + public void set_values() { net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; Net[] sorted_arr = new Net[this.getRowCount()]; - for (int i = 0; i < sorted_arr.length; ++i) - { + for (int i = 0; i < sorted_arr.length; ++i) { sorted_arr[i] = board_rules.nets.get(i + 1); } java.util.Arrays.sort(sorted_arr); - for (int i = 0; i < data.length; ++i) - { + for (int i = 0; i < data.length; ++i) { this.data[i][0] = sorted_arr[i]; this.data[i][1] = sorted_arr[i].get_class(); } } - - - public String getColumnName(int p_col) - { + + public String getColumnName(int p_col) { return column_names[p_col]; } - - public int getRowCount() - { + + public int getRowCount() { return data.length; } - - public int getColumnCount() - { + + public int getColumnCount() { return column_names.length; } - - public Object getValueAt(int p_row, int p_col) - { + + public Object getValueAt(int p_row, int p_col) { return data[p_row][p_col]; } - - public boolean isCellEditable(int p_row, int p_col) - { + + public boolean isCellEditable(int p_row, int p_col) { return p_col > 0; } - - public void setValueAt(Object p_value, int p_row, int p_col) - { - if (p_col != 1 || !(p_value instanceof NetClass)) - { + + public void setValueAt(Object p_value, int p_row, int p_col) { + if (p_col != 1 || !(p_value instanceof NetClass)) { return; } Object first_row_object = getValueAt(p_row, 0); - if (!(first_row_object instanceof Net)) - { + if (!(first_row_object instanceof Net)) { System.out.println("AssignNetRuLesVindow.setValueAt: Net expected"); return; } Net curr_net = (Net) first_row_object; - NetClass curr_net_rule = (NetClass)p_value; + NetClass curr_net_rule = (NetClass) p_value; curr_net.set_class(curr_net_rule); - + this.data[p_row][p_col] = p_value; fireTableCellUpdated(p_row, p_col); } - - private Object[][] data = null; - private String[] column_names = null; } } diff --git a/src/main/java/net/freerouting/gui/WindowAutorouteDetailParameter.java b/src/main/java/net/freerouting/gui/WindowAutorouteDetailParameter.java index c4e12053..257bf109 100644 --- a/src/main/java/net/freerouting/gui/WindowAutorouteDetailParameter.java +++ b/src/main/java/net/freerouting/gui/WindowAutorouteDetailParameter.java @@ -21,15 +21,30 @@ package net.freerouting.gui; /** - * * @author Alfons Wirtz */ -public class WindowAutorouteDetailParameter extends BoardSavableSubWindow -{ +public class WindowAutorouteDetailParameter extends BoardSavableSubWindow { - /** Creates a new instance of WindowAutorouteDetailParameter */ - public WindowAutorouteDetailParameter(BoardFrame p_board_frame) - { + private final net.freerouting.interactive.BoardHandling board_handling; + private final javax.swing.JFormattedTextField via_cost_field; + private final javax.swing.JFormattedTextField plane_via_cost_field; + private final javax.swing.JFormattedTextField start_ripup_costs; + private final javax.swing.JFormattedTextField start_pass_no; + private final javax.swing.JComboBox speed_combo_box; + private final String speed_fast; + private final String speed_slow; + private final javax.swing.JLabel[] layer_name_arr; + private final javax.swing.JFormattedTextField[] preferred_direction_trace_cost_arr; + private final javax.swing.JFormattedTextField[] against_preferred_direction_trace_cost_arr; + private final boolean[] preferred_direction_trace_costs_input_completed; + private final boolean[] against_preferred_direction_trace_costs_input_completed; + private boolean via_cost_input_completed = true; + private boolean plane_via_cost_input_completed = true; + private boolean start_ripup_cost_input_completed = true; + /** + * Creates a new instance of WindowAutorouteDetailParameter + */ + public WindowAutorouteDetailParameter(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowAutorouteParameter", p_board_frame.get_locale()); @@ -106,7 +121,6 @@ public WindowAutorouteDetailParameter(BoardFrame p_board_frame) main_panel.add(start_ripup_costs); - // add label and combo box for the router speed (if the speed is set to slow, free angle geometry // is used also in the 45 and 90 degree modes. this.speed_fast = resources.getString("fast"); @@ -116,8 +130,7 @@ public WindowAutorouteDetailParameter(BoardFrame p_board_frame) speed_combo_box.addItem(this.speed_slow); speed_combo_box.addActionListener(new SpeedListener()); - if (this.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) - { + if (this.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { gridbag_constraints.gridwidth = 2; javax.swing.JLabel speed_label = new javax.swing.JLabel(); speed_label.setText(resources.getString("speed")); @@ -160,8 +173,7 @@ public WindowAutorouteDetailParameter(BoardFrame p_board_frame) number_format = java.text.NumberFormat.getInstance(p_board_frame.get_locale()); number_format.setMaximumFractionDigits(2); final int TEXT_FIELD_LENGTH = 2; - for (int i = 0; i < signal_layer_count; ++i) - { + for (int i = 0; i < signal_layer_count; ++i) { layer_name_arr[i] = new javax.swing.JLabel(); net.freerouting.board.Layer curr_signal_layer = layer_structure.get_signal_layer(i); layer_name_arr[i].setText(curr_signal_layer.name); @@ -195,60 +207,35 @@ public WindowAutorouteDetailParameter(BoardFrame p_board_frame) /** * Recalculates all displayed values */ - public void refresh() - { + public void refresh() { net.freerouting.interactive.AutorouteSettings settings = this.board_handling.settings.autoroute_settings; net.freerouting.board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; this.via_cost_field.setValue(settings.get_via_costs()); this.plane_via_cost_field.setValue(settings.get_plane_via_costs()); this.start_ripup_costs.setValue(settings.get_start_ripup_costs()); this.start_pass_no.setValue(settings.get_pass_no()); - for (int i = 0; i < preferred_direction_trace_cost_arr.length; ++i) - { + for (int i = 0; i < preferred_direction_trace_cost_arr.length; ++i) { this.preferred_direction_trace_cost_arr[i].setValue(settings.get_preferred_direction_trace_costs(layer_structure.get_layer_no(i))); } - for (int i = 0; i < against_preferred_direction_trace_cost_arr.length; ++i) - { + for (int i = 0; i < against_preferred_direction_trace_cost_arr.length; ++i) { this.against_preferred_direction_trace_cost_arr[i].setValue(settings.get_against_preferred_direction_trace_costs(layer_structure.get_layer_no(i))); } } - private final net.freerouting.interactive.BoardHandling board_handling; - private final javax.swing.JFormattedTextField via_cost_field; - private final javax.swing.JFormattedTextField plane_via_cost_field; - private final javax.swing.JFormattedTextField start_ripup_costs; - private final javax.swing.JFormattedTextField start_pass_no; - private final javax.swing.JComboBox speed_combo_box; - private final String speed_fast; - private final String speed_slow; - private final javax.swing.JLabel[] layer_name_arr; - private final javax.swing.JFormattedTextField[] preferred_direction_trace_cost_arr; - private final javax.swing.JFormattedTextField[] against_preferred_direction_trace_cost_arr; - private boolean via_cost_input_completed = true; - private boolean plane_via_cost_input_completed = true; - private boolean start_ripup_cost_input_completed = true; - private final boolean[] preferred_direction_trace_costs_input_completed; - private final boolean[] against_preferred_direction_trace_costs_input_completed; - private class ViaCostFieldKeyListener extends java.awt.event.KeyAdapter - { + private class ViaCostFieldKeyListener extends java.awt.event.KeyAdapter { - public void keyTyped(java.awt.event.KeyEvent p_evt) - { - if (p_evt.getKeyChar() == '\n') - { + public void keyTyped(java.awt.event.KeyEvent p_evt) { + if (p_evt.getKeyChar() == '\n') { int old_value = board_handling.settings.autoroute_settings.get_via_costs(); Object input = via_cost_field.getValue(); int input_value; - if (input instanceof Number) - { + if (input instanceof Number) { input_value = ((Number) input).intValue(); - if (input_value <= 0) - { + if (input_value <= 0) { input_value = 1; via_cost_field.setValue(input_value); } - } else - { + } else { input_value = old_value; via_cost_field.setValue(old_value); } @@ -256,50 +243,39 @@ public void keyTyped(java.awt.event.KeyEvent p_evt) via_cost_field.setValue(input_value); via_cost_input_completed = true; - } else - { + } else { via_cost_input_completed = false; } } } - private class ViaCostFieldFocusListener implements java.awt.event.FocusListener - { + private class ViaCostFieldFocusListener implements java.awt.event.FocusListener { - public void focusLost(java.awt.event.FocusEvent p_evt) - { - if (!via_cost_input_completed) - { + public void focusLost(java.awt.event.FocusEvent p_evt) { + if (!via_cost_input_completed) { via_cost_input_completed = true; refresh(); } } - public void focusGained(java.awt.event.FocusEvent p_evt) - { + public void focusGained(java.awt.event.FocusEvent p_evt) { } } - private class PlaneViaCostFieldKeyListener extends java.awt.event.KeyAdapter - { + private class PlaneViaCostFieldKeyListener extends java.awt.event.KeyAdapter { - public void keyTyped(java.awt.event.KeyEvent p_evt) - { - if (p_evt.getKeyChar() == '\n') - { + public void keyTyped(java.awt.event.KeyEvent p_evt) { + if (p_evt.getKeyChar() == '\n') { int old_value = board_handling.settings.autoroute_settings.get_plane_via_costs(); Object input = plane_via_cost_field.getValue(); int input_value; - if (input instanceof Number) - { + if (input instanceof Number) { input_value = ((Number) input).intValue(); - if (input_value <= 0) - { + if (input_value <= 0) { input_value = 1; plane_via_cost_field.setValue(input_value); } - } else - { + } else { input_value = old_value; plane_via_cost_field.setValue(old_value); } @@ -307,101 +283,78 @@ public void keyTyped(java.awt.event.KeyEvent p_evt) plane_via_cost_field.setValue(input_value); plane_via_cost_input_completed = true; - } else - { + } else { plane_via_cost_input_completed = false; } } } - private class PlaneViaCostFieldFocusListener implements java.awt.event.FocusListener - { + private class PlaneViaCostFieldFocusListener implements java.awt.event.FocusListener { - public void focusLost(java.awt.event.FocusEvent p_evt) - { - if (!plane_via_cost_input_completed) - { + public void focusLost(java.awt.event.FocusEvent p_evt) { + if (!plane_via_cost_input_completed) { plane_via_cost_input_completed = true; refresh(); } } - public void focusGained(java.awt.event.FocusEvent p_evt) - { + public void focusGained(java.awt.event.FocusEvent p_evt) { } } - private class StartRipupCostFieldKeyListener extends java.awt.event.KeyAdapter - { + private class StartRipupCostFieldKeyListener extends java.awt.event.KeyAdapter { - public void keyTyped(java.awt.event.KeyEvent p_evt) - { - if (p_evt.getKeyChar() == '\n') - { + public void keyTyped(java.awt.event.KeyEvent p_evt) { + if (p_evt.getKeyChar() == '\n') { int old_value = board_handling.settings.autoroute_settings.get_start_ripup_costs(); Object input = start_ripup_costs.getValue(); int input_value; - if (input instanceof Number) - { + if (input instanceof Number) { input_value = ((Number) input).intValue(); - if (input_value <= 0) - { + if (input_value <= 0) { input_value = 1; } - } else - { + } else { input_value = old_value; } board_handling.settings.autoroute_settings.set_start_ripup_costs(input_value); start_ripup_costs.setValue(input_value); start_ripup_cost_input_completed = true; - } else - { + } else { start_ripup_cost_input_completed = false; } } } - private class StartRipupCostFieldFocusListener implements java.awt.event.FocusListener - { + private class StartRipupCostFieldFocusListener implements java.awt.event.FocusListener { - public void focusLost(java.awt.event.FocusEvent p_evt) - { - if (!start_ripup_cost_input_completed) - { + public void focusLost(java.awt.event.FocusEvent p_evt) { + if (!start_ripup_cost_input_completed) { start_ripup_cost_input_completed = true; refresh(); } } - public void focusGained(java.awt.event.FocusEvent p_evt) - { + public void focusGained(java.awt.event.FocusEvent p_evt) { } } - private class StartPassFieldKeyListener extends java.awt.event.KeyAdapter - { + private class StartPassFieldKeyListener extends java.awt.event.KeyAdapter { - public void keyTyped(java.awt.event.KeyEvent p_evt) - { - if (p_evt.getKeyChar() == '\n') - { + public void keyTyped(java.awt.event.KeyEvent p_evt) { + if (p_evt.getKeyChar() == '\n') { int old_value = board_handling.settings.autoroute_settings.get_pass_no(); Object input = start_pass_no.getValue(); int input_value; - if (input instanceof Number) - { + if (input instanceof Number) { input_value = ((Number) input).intValue(); - if (input_value < 1) - { + if (input_value < 1) { input_value = 1; } - if (input_value > 99) - { + if (input_value > 99) { input_value = 99; } - } else - { + } else { input_value = old_value; } board_handling.settings.autoroute_settings.set_pass_no(input_value); @@ -411,158 +364,129 @@ public void keyTyped(java.awt.event.KeyEvent p_evt) } } - private class StartPassFieldFocusListener implements java.awt.event.FocusListener - { + private class StartPassFieldFocusListener implements java.awt.event.FocusListener { - public void focusLost(java.awt.event.FocusEvent p_evt) - { - if (!start_ripup_cost_input_completed) - { + public void focusLost(java.awt.event.FocusEvent p_evt) { + if (!start_ripup_cost_input_completed) { refresh(); } } - public void focusGained(java.awt.event.FocusEvent p_evt) - { + public void focusGained(java.awt.event.FocusEvent p_evt) { } } - private class SpeedListener implements java.awt.event.ActionListener - { + private class SpeedListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { boolean old_is_slow = board_handling.get_routing_board().rules.get_slow_autoroute_algorithm(); boolean new_is_slow = speed_combo_box.getSelectedItem() == speed_slow; - if (old_is_slow != new_is_slow) - { + if (old_is_slow != new_is_slow) { board_handling.get_routing_board().rules.set_slow_autoroute_algorithm(new_is_slow); board_handling.get_routing_board().search_tree_manager.reset_compensated_trees(); } } } - private class PreferredDirectionTraceCostKeyListener extends java.awt.event.KeyAdapter - { + private class PreferredDirectionTraceCostKeyListener extends java.awt.event.KeyAdapter { - public PreferredDirectionTraceCostKeyListener(int p_layer_no) - { + private final int signal_layer_no; + + public PreferredDirectionTraceCostKeyListener(int p_layer_no) { this.signal_layer_no = p_layer_no; } - public void keyTyped(java.awt.event.KeyEvent p_evt) - { - if (p_evt.getKeyChar() == '\n') - { + public void keyTyped(java.awt.event.KeyEvent p_evt) { + if (p_evt.getKeyChar() == '\n') { int curr_layer_no = board_handling.get_routing_board().layer_structure.get_layer_no(this.signal_layer_no); double old_value = board_handling.settings.autoroute_settings.get_preferred_direction_trace_costs(curr_layer_no); Object input = preferred_direction_trace_cost_arr[this.signal_layer_no].getValue(); double input_value; - if (input instanceof Number) - { + if (input instanceof Number) { input_value = ((Number) input).doubleValue(); - if (input_value <= 0) - { + if (input_value <= 0) { input_value = old_value; } - } else - { + } else { input_value = old_value; } board_handling.settings.autoroute_settings.set_preferred_direction_trace_costs(curr_layer_no, input_value); preferred_direction_trace_cost_arr[this.signal_layer_no].setValue(input_value); preferred_direction_trace_costs_input_completed[this.signal_layer_no] = true; - } else - { + } else { preferred_direction_trace_costs_input_completed[this.signal_layer_no] = false; } } - private final int signal_layer_no; } - private class PreferredDirectionTraceCostFocusListener implements java.awt.event.FocusListener - { + private class PreferredDirectionTraceCostFocusListener implements java.awt.event.FocusListener { - public PreferredDirectionTraceCostFocusListener(int p_layer_no) - { + private final int signal_layer_no; + + public PreferredDirectionTraceCostFocusListener(int p_layer_no) { this.signal_layer_no = p_layer_no; } - public void focusLost(java.awt.event.FocusEvent p_evt) - { - if (!preferred_direction_trace_costs_input_completed[this.signal_layer_no]) - { + public void focusLost(java.awt.event.FocusEvent p_evt) { + if (!preferred_direction_trace_costs_input_completed[this.signal_layer_no]) { start_ripup_cost_input_completed = true; refresh(); } } - public void focusGained(java.awt.event.FocusEvent p_evt) - { + public void focusGained(java.awt.event.FocusEvent p_evt) { } - private final int signal_layer_no; } - private class AgainstPreferredDirectionTraceCostKeyListener extends java.awt.event.KeyAdapter - { + private class AgainstPreferredDirectionTraceCostKeyListener extends java.awt.event.KeyAdapter { - public AgainstPreferredDirectionTraceCostKeyListener(int p_layer_no) - { + private final int signal_layer_no; + + public AgainstPreferredDirectionTraceCostKeyListener(int p_layer_no) { this.signal_layer_no = p_layer_no; } - public void keyTyped(java.awt.event.KeyEvent p_evt) - { - if (p_evt.getKeyChar() == '\n') - { + public void keyTyped(java.awt.event.KeyEvent p_evt) { + if (p_evt.getKeyChar() == '\n') { int curr_layer_no = board_handling.get_routing_board().layer_structure.get_layer_no(this.signal_layer_no); double old_value = board_handling.settings.autoroute_settings.get_against_preferred_direction_trace_costs(curr_layer_no); Object input = against_preferred_direction_trace_cost_arr[this.signal_layer_no].getValue(); double input_value; - if (input instanceof Number) - { + if (input instanceof Number) { input_value = ((Number) input).doubleValue(); - if (input_value <= 0) - { + if (input_value <= 0) { input_value = old_value; } - } else - { + } else { input_value = old_value; } board_handling.settings.autoroute_settings.set_against_preferred_direction_trace_costs(curr_layer_no, input_value); against_preferred_direction_trace_cost_arr[this.signal_layer_no].setValue(input_value); against_preferred_direction_trace_costs_input_completed[this.signal_layer_no] = true; - } else - { + } else { against_preferred_direction_trace_costs_input_completed[this.signal_layer_no] = false; } } - private final int signal_layer_no; } - private class AgainstPreferredDirectionTraceCostFocusListener implements java.awt.event.FocusListener - { + private class AgainstPreferredDirectionTraceCostFocusListener implements java.awt.event.FocusListener { - public AgainstPreferredDirectionTraceCostFocusListener(int p_layer_no) - { + private final int signal_layer_no; + + public AgainstPreferredDirectionTraceCostFocusListener(int p_layer_no) { this.signal_layer_no = p_layer_no; } - public void focusLost(java.awt.event.FocusEvent p_evt) - { - if (!against_preferred_direction_trace_costs_input_completed[this.signal_layer_no]) - { + public void focusLost(java.awt.event.FocusEvent p_evt) { + if (!against_preferred_direction_trace_costs_input_completed[this.signal_layer_no]) { start_ripup_cost_input_completed = true; refresh(); } } - public void focusGained(java.awt.event.FocusEvent p_evt) - { + public void focusGained(java.awt.event.FocusEvent p_evt) { } - private final int signal_layer_no; } } diff --git a/src/main/java/net/freerouting/gui/WindowAutorouteParameter.java b/src/main/java/net/freerouting/gui/WindowAutorouteParameter.java index 2fa19baf..bc767d68 100644 --- a/src/main/java/net/freerouting/gui/WindowAutorouteParameter.java +++ b/src/main/java/net/freerouting/gui/WindowAutorouteParameter.java @@ -25,12 +25,24 @@ * * @author Alfons Wirtz */ -public class WindowAutorouteParameter extends BoardSavableSubWindow -{ +public class WindowAutorouteParameter extends BoardSavableSubWindow { - /** Creates a new instance of WindowAutorouteParameter */ - public WindowAutorouteParameter(BoardFrame p_board_frame) - { + private final net.freerouting.interactive.BoardHandling board_handling; + private final javax.swing.JLabel[] signal_layer_name_arr; + private final javax.swing.JCheckBox[] signal_layer_active_arr; + private final javax.swing.JComboBox[] combo_box_arr; + private final javax.swing.JCheckBox vias_allowed; + private final javax.swing.JRadioButton fanout_pass_button; + private final javax.swing.JRadioButton autoroute_pass_button; + private final javax.swing.JRadioButton postroute_pass_button; + private final WindowAutorouteDetailParameter detail_window; + private final DetailListener detail_listener; + private final String horizontal; + private final String vertical; + /** + * Creates a new instance of WindowAutorouteParameter + */ + public WindowAutorouteParameter(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowAutorouteParameter", p_board_frame.get_locale()); @@ -70,8 +82,7 @@ public WindowAutorouteParameter(BoardFrame p_board_frame) signal_layer_name_arr = new javax.swing.JLabel[signal_layer_count]; signal_layer_active_arr = new javax.swing.JCheckBox[signal_layer_count]; combo_box_arr = new javax.swing.JComboBox[signal_layer_count]; - for (int i = 0; i < signal_layer_count; ++i) - { + for (int i = 0; i < signal_layer_count; ++i) { signal_layer_name_arr[i] = new javax.swing.JLabel(); net.freerouting.board.Layer curr_signal_layer = layer_structure.get_signal_layer(i); signal_layer_name_arr[i].setText(curr_signal_layer.name); @@ -163,8 +174,7 @@ public WindowAutorouteParameter(BoardFrame p_board_frame) /** * Recalculates all displayed values */ - public void refresh() - { + public void refresh() { net.freerouting.interactive.AutorouteSettings settings = this.board_handling.settings.autoroute_settings; net.freerouting.board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; @@ -173,140 +183,106 @@ public void refresh() this.autoroute_pass_button.setSelected(settings.get_with_autoroute()); this.postroute_pass_button.setSelected(settings.get_with_postroute()); - for (int i = 0; i < signal_layer_active_arr.length; ++i) - { + for (int i = 0; i < signal_layer_active_arr.length; ++i) { this.signal_layer_active_arr[i].setSelected(settings.get_layer_active(layer_structure.get_layer_no(i))); } - for (int i = 0; i < combo_box_arr.length; ++i) - { - if (settings.get_preferred_direction_is_horizontal(layer_structure.get_layer_no(i))) - { + for (int i = 0; i < combo_box_arr.length; ++i) { + if (settings.get_preferred_direction_is_horizontal(layer_structure.get_layer_no(i))) { this.combo_box_arr[i].setSelectedItem(this.horizontal); - } - else - { + } else { this.combo_box_arr[i].setSelectedItem(this.vertical); } } this.detail_window.refresh(); } - public void dispose() - { + public void dispose() { detail_window.dispose(); super.dispose(); } - public void parent_iconified() - { + public void parent_iconified() { detail_window.parent_iconified(); super.parent_iconified(); } - public void parent_deiconified() - { + public void parent_deiconified() { detail_window.parent_deiconified(); super.parent_deiconified(); } - private final net.freerouting.interactive.BoardHandling board_handling; - private final javax.swing.JLabel[] signal_layer_name_arr; - private final javax.swing.JCheckBox[] signal_layer_active_arr; - private final javax.swing.JComboBox[] combo_box_arr; - private final javax.swing.JCheckBox vias_allowed; - private final javax.swing.JRadioButton fanout_pass_button; - private final javax.swing.JRadioButton autoroute_pass_button; - private final javax.swing.JRadioButton postroute_pass_button; - private final WindowAutorouteDetailParameter detail_window; - private final DetailListener detail_listener; - private final String horizontal; - private final String vertical; - private class DetailListener implements java.awt.event.ActionListener - { + private class DetailListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - if (first_time) - { + private boolean first_time = true; + + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + if (first_time) { java.awt.Point location = getLocation(); detail_window.setLocation((int) location.getX() + 200, (int) location.getY() + 100); first_time = false; } detail_window.setVisible(true); } - private boolean first_time = true; } - private class LayerActiveListener implements java.awt.event.ActionListener - { + private class LayerActiveListener implements java.awt.event.ActionListener { + + private final int signal_layer_no; - public LayerActiveListener(int p_layer_no) - { + public LayerActiveListener(int p_layer_no) { signal_layer_no = p_layer_no; } - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { int curr_layer_no = board_handling.get_routing_board().layer_structure.get_layer_no(this.signal_layer_no); board_handling.settings.autoroute_settings.set_layer_active(curr_layer_no, signal_layer_active_arr[this.signal_layer_no].isSelected()); } - private final int signal_layer_no; } - private class PreferredDirectionListener implements java.awt.event.ActionListener - { + private class PreferredDirectionListener implements java.awt.event.ActionListener { + + private final int signal_layer_no; - public PreferredDirectionListener(int p_layer_no) - { + public PreferredDirectionListener(int p_layer_no) { signal_layer_no = p_layer_no; } - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { int curr_layer_no = board_handling.get_routing_board().layer_structure.get_layer_no(this.signal_layer_no); board_handling.settings.autoroute_settings.set_preferred_direction_is_horizontal(curr_layer_no, combo_box_arr[signal_layer_no].getSelectedItem() == horizontal); } - private final int signal_layer_no; } - private class ViasAllowedListener implements java.awt.event.ActionListener - { + private class ViasAllowedListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.autoroute_settings.set_vias_allowed(vias_allowed.isSelected()); } } - private class FanoutListener implements java.awt.event.ActionListener - { + private class FanoutListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.interactive.AutorouteSettings autoroute_settings = board_handling.settings.autoroute_settings; autoroute_settings.set_with_fanout(fanout_pass_button.isSelected()); autoroute_settings.set_pass_no(1); } } - private class AutorouteListener implements java.awt.event.ActionListener - { + private class AutorouteListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.interactive.AutorouteSettings autoroute_settings = board_handling.settings.autoroute_settings; autoroute_settings.set_with_autoroute(autoroute_pass_button.isSelected()); autoroute_settings.set_pass_no(1); } } - private class PostrouteListener implements java.awt.event.ActionListener - { + private class PostrouteListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.interactive.AutorouteSettings autoroute_settings = board_handling.settings.autoroute_settings; autoroute_settings.set_with_postroute(postroute_pass_button.isSelected()); autoroute_settings.set_pass_no(1); diff --git a/src/main/java/net/freerouting/gui/WindowClearanceMatrix.java b/src/main/java/net/freerouting/gui/WindowClearanceMatrix.java index 474a8a52..f126d421 100644 --- a/src/main/java/net/freerouting/gui/WindowClearanceMatrix.java +++ b/src/main/java/net/freerouting/gui/WindowClearanceMatrix.java @@ -20,101 +20,108 @@ package net.freerouting.gui; -import net.freerouting.rules.ClearanceMatrix; - import net.freerouting.datastructures.UndoableObjects; +import net.freerouting.rules.ClearanceMatrix; /** * Window for interactive editing of the clearance Matrix. * * @author Alfons Wirtz */ -public class WindowClearanceMatrix extends BoardSavableSubWindow -{ - - /** Creates a new instance of ClearanceMatrixWindow */ - public WindowClearanceMatrix(BoardFrame p_board_frame) - { +public class WindowClearanceMatrix extends BoardSavableSubWindow { + + /** + * Characters, which are not allowed in the name of a clearance class. + */ + private static final String[] reserved_name_chars = {"(", ")", " ", "_"}; + private final BoardFrame board_frame; + private final javax.swing.JPanel main_panel; + private final ComboBoxLayer layer_combo_box; + private final java.util.ResourceBundle resources; + private javax.swing.JPanel center_panel; + private javax.swing.JTable clearance_table; + private ClearanceTableModel clearance_table_model; + + /** + * Creates a new instance of ClearanceMatrixWindow + */ + public WindowClearanceMatrix(BoardFrame p_board_frame) { this.board_frame = p_board_frame; this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowClearanceMatrix", p_board_frame.get_locale()); - + this.setTitle(resources.getString("title")); - + this.main_panel = new javax.swing.JPanel(); - main_panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(20,20,20,20)); + main_panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(20, 20, 20, 20)); main_panel.setLayout(new java.awt.BorderLayout()); - + // Add the layer combo box. - + final javax.swing.JPanel north_panel = new javax.swing.JPanel(); - north_panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,20,0)); + north_panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 20, 0)); javax.swing.JLabel layer_label = new javax.swing.JLabel(resources.getString("layer") + " "); layer_label.setToolTipText(resources.getString("layer_tooltip")); north_panel.add(layer_label); - + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; layer_combo_box = new ComboBoxLayer(board_handling.get_routing_board().layer_structure, p_board_frame.get_locale()); north_panel.add(this.layer_combo_box); this.layer_combo_box.addActionListener(new ComboBoxListener()); - + main_panel.add(north_panel, java.awt.BorderLayout.NORTH); - + // Add the clearance table. - + this.center_panel = add_clearance_table(p_board_frame); - + main_panel.add(center_panel, java.awt.BorderLayout.CENTER); - + // Add panel with buttons. - + javax.swing.JPanel south_panel = new javax.swing.JPanel(); - south_panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(20,20,20,20)); + south_panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(20, 20, 20, 20)); south_panel.setLayout(new java.awt.BorderLayout()); this.add(south_panel); - - final javax.swing.JButton add_class_button = new javax.swing.JButton(resources.getString("add_class")); + + final javax.swing.JButton add_class_button = new javax.swing.JButton(resources.getString("add_class")); add_class_button.setToolTipText(resources.getString("add_class_tooltip")); add_class_button.addActionListener(new AddClassListener()); south_panel.add(add_class_button, java.awt.BorderLayout.WEST); - - final javax.swing.JButton prune_button = new javax.swing.JButton(resources.getString("prune")); + + final javax.swing.JButton prune_button = new javax.swing.JButton(resources.getString("prune")); prune_button.setToolTipText(resources.getString("prune_tooltip")); prune_button.addActionListener(new PruneListener()); south_panel.add(prune_button, java.awt.BorderLayout.EAST); - + main_panel.add(south_panel, java.awt.BorderLayout.SOUTH); - + p_board_frame.set_context_sensitive_help(this, "WindowClearanceMatrix"); - + this.add(main_panel); this.pack(); } - - + /** * Recalculates all displayed values */ - public void refresh() - { + public void refresh() { net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); - if (this.clearance_table_model.getRowCount() != routing_board.rules.clearance_matrix.get_class_count()) - { + if (this.clearance_table_model.getRowCount() != routing_board.rules.clearance_matrix.get_class_count()) { this.adjust_clearance_table(); } this.clearance_table_model.set_values(this.layer_combo_box.get_selected_layer().index); this.repaint(); } - - private javax.swing.JPanel add_clearance_table(BoardFrame p_board_frame) - { + + private javax.swing.JPanel add_clearance_table(BoardFrame p_board_frame) { this.clearance_table_model = new ClearanceTableModel(p_board_frame.board_panel.board_handling); this.clearance_table = new javax.swing.JTable(clearance_table_model); - + // Put the clearance table into a scroll pane. final int textfield_height = 16; final int textfield_width = Math.max(6 * max_name_length(), 100); int table_height = textfield_height * (this.clearance_table_model.getRowCount()); - int table_width = textfield_width * this.clearance_table_model.getColumnCount(); + int table_width = textfield_width * this.clearance_table_model.getColumnCount(); this.clearance_table.setPreferredSize(new java.awt.Dimension(table_width, table_height)); this.clearance_table.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); // Put a panel around the table and the header before putting the table into the scroll pane, @@ -123,111 +130,95 @@ private javax.swing.JPanel add_clearance_table(BoardFrame p_board_frame) scroll_panel.setLayout(new java.awt.BorderLayout()); scroll_panel.add(this.clearance_table.getTableHeader(), java.awt.BorderLayout.NORTH); scroll_panel.add(this.clearance_table, java.awt.BorderLayout.CENTER); - javax.swing.JScrollPane scroll_pane = new javax.swing.JScrollPane( scroll_panel, + javax.swing.JScrollPane scroll_pane = new javax.swing.JScrollPane(scroll_panel, javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - - final int scroll_bar_width = 20; - final int scroll_pane_height = textfield_height * this.clearance_table_model.getRowCount() + scroll_bar_width; + + final int scroll_bar_width = 20; + final int scroll_pane_height = textfield_height * this.clearance_table_model.getRowCount() + scroll_bar_width; final int scroll_pane_width = Math.min(table_width + scroll_bar_width, 1200); scroll_pane.setPreferredSize(new java.awt.Dimension(scroll_pane_width, scroll_pane_height)); // Change the background color of the header and the first column of the table. java.awt.Color header_background_color = new java.awt.Color(220, 220, 255); javax.swing.table.JTableHeader table_header = this.clearance_table.getTableHeader(); table_header.setBackground(header_background_color); - - javax.swing.table.TableColumn first_column = this.clearance_table.getColumnModel().getColumn(0); + + javax.swing.table.TableColumn first_column = this.clearance_table.getColumnModel().getColumn(0); javax.swing.table.DefaultTableCellRenderer first_colunn_renderer = new javax.swing.table.DefaultTableCellRenderer(); first_colunn_renderer.setBackground(header_background_color); first_column.setCellRenderer(first_colunn_renderer); - + final javax.swing.JPanel result = new javax.swing.JPanel(); result.setLayout(new java.awt.BorderLayout()); - + result.add(scroll_pane, java.awt.BorderLayout.CENTER); - + // add message for german localisation bug - if (p_board_frame.get_locale().getLanguage().equalsIgnoreCase("de")) - { + if (p_board_frame.get_locale().getLanguage().equalsIgnoreCase("de")) { javax.swing.JLabel bug_label = new javax.swing.JLabel("Wegen eines Java-System-Bugs muss das Dezimalkomma in dieser Tabelle als Punkt eingegeben werden!"); result.add(bug_label, java.awt.BorderLayout.SOUTH); } return result; } - + /** * Adds a new class to the clearance matrix. */ - private void add_class() - { + private void add_class() { String new_name = null; // Ask for the name of the new class. - for (;;) - { + for (; ; ) { new_name = javax.swing.JOptionPane.showInputDialog(resources.getString("new_name")); - if (new_name == null) - { + if (new_name == null) { return; } new_name = new_name.trim(); - if (is_legal_class_name(new_name)) - { + if (is_legal_class_name(new_name)) { break; } } - final net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); + final net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); final net.freerouting.rules.ClearanceMatrix clearance_matrix = routing_board.rules.clearance_matrix; - + // Check, if the name exists already. boolean name_exists = false; - for (int i = 0; i < clearance_matrix.get_class_count(); ++i) - { - if (new_name.equals(clearance_matrix.get_name(i))) - { + for (int i = 0; i < clearance_matrix.get_class_count(); ++i) { + if (new_name.equals(clearance_matrix.get_name(i))) { name_exists = true; break; } } - if (name_exists) - { + if (name_exists) { return; } clearance_matrix.append_class(new_name); - if (routing_board.get_test_level() == net.freerouting.board.TestLevel.RELEASE_VERSION) - { + if (routing_board.get_test_level() == net.freerouting.board.TestLevel.RELEASE_VERSION) { // clearance compensation is only used, if there are only the clearance classes default and null. routing_board.search_tree_manager.set_clearance_compensation_used(false); } adjust_clearance_table(); } - + /** * Removes clearance classs, whose clearance values are all equal to a previous class. */ - private void prune_clearance_matrix() - { + private void prune_clearance_matrix() { final net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); ClearanceMatrix clearance_matrix = routing_board.rules.clearance_matrix; - for (int i = clearance_matrix.get_class_count() - 1; i >= 2; --i) - { - for (int j = clearance_matrix.get_class_count() - 1; j >= 0; --j) - { - if (i == j) - { + for (int i = clearance_matrix.get_class_count() - 1; i >= 2; --i) { + for (int j = clearance_matrix.get_class_count() - 1; j >= 0; --j) { + if (i == j) { continue; } - if (clearance_matrix.is_equal(i, j)) - { + if (clearance_matrix.is_equal(i, j)) { String message = resources.getString("confirm_remove") + " " + clearance_matrix.get_name(i); int selected_option = javax.swing.JOptionPane.showConfirmDialog(this, message, null, javax.swing.JOptionPane.YES_NO_OPTION); - if (selected_option == javax.swing.JOptionPane.YES_OPTION) - { - java.util.Collection board_items = routing_board.get_items(); + if (selected_option == javax.swing.JOptionPane.YES_OPTION) { + java.util.Collection board_items = routing_board.get_items(); routing_board.rules.change_clearance_class_no(i, j, board_items); - if (!routing_board.rules.remove_clearance_class(i, board_items)) - { + if (!routing_board.rules.remove_clearance_class(i, board_items)) { System.out.println("WindowClearanceMatrix.prune_clearance_matrix error removing clearance class"); return; } @@ -239,12 +230,11 @@ private void prune_clearance_matrix() } } } - + /** * Adjusts the displayed window with the clearance table after the size of the clearance matrix has changed. */ - private void adjust_clearance_table() - { + private void adjust_clearance_table() { this.clearance_table_model = new ClearanceTableModel(this.board_frame.board_panel.board_handling); this.clearance_table = new javax.swing.JTable(clearance_table_model); this.main_panel.remove(this.center_panel); @@ -253,283 +243,214 @@ private void adjust_clearance_table() this.pack(); this.board_frame.refresh_windows(); } - - + /** * Returns true, if p_string is a legal class name. */ - private boolean is_legal_class_name(String p_string) - { - if (p_string.equals("")) - { + private boolean is_legal_class_name(String p_string) { + if (p_string.equals("")) { return false; } - for (int i = 0; i < reserved_name_chars.length; ++i) - { - if (p_string.contains(reserved_name_chars[i])) - { + for (int i = 0; i < reserved_name_chars.length; ++i) { + if (p_string.contains(reserved_name_chars[i])) { return false; } } return true; } - - - private int max_name_length() - { - int result = 1; + + private int max_name_length() { + int result = 1; net.freerouting.rules.ClearanceMatrix clearance_matrix = board_frame.board_panel.board_handling.get_routing_board().rules.clearance_matrix; - for (int i = 0; i < clearance_matrix.get_class_count(); ++i) - { + for (int i = 0; i < clearance_matrix.get_class_count(); ++i) { result = Math.max(result, clearance_matrix.get_name(i).length()); } return result; } - - private class ComboBoxListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + + private class ComboBoxListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent evt) { refresh(); } } - - private final BoardFrame board_frame; - private final javax.swing.JPanel main_panel; - private javax.swing.JPanel center_panel; - private final ComboBoxLayer layer_combo_box; - private javax.swing.JTable clearance_table; - private ClearanceTableModel clearance_table_model; - private final java.util.ResourceBundle resources; - - /** Characters, which are not allowed in the name of a clearance class. */ - private static final String[] reserved_name_chars = {"(", ")", " ", "_"}; - - private class AddClassListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class AddClassListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { add_class(); } } - - private class PruneListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class PruneListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { prune_clearance_matrix(); } } - + /** * Table model of the clearance matrix. */ - private class ClearanceTableModel extends javax.swing.table.AbstractTableModel implements java.io.Serializable - { - public ClearanceTableModel(net.freerouting.interactive.BoardHandling p_board_handling) - { + private class ClearanceTableModel extends javax.swing.table.AbstractTableModel implements java.io.Serializable { + private Object[][] data = null; + private String[] column_names = null; + + public ClearanceTableModel(net.freerouting.interactive.BoardHandling p_board_handling) { net.freerouting.rules.ClearanceMatrix clearance_matrix = p_board_handling.get_routing_board().rules.clearance_matrix; - + column_names = new String[clearance_matrix.get_class_count() + 1]; column_names[0] = resources.getString("class"); - + data = new Object[clearance_matrix.get_class_count()][]; - for (int i = 0; i < clearance_matrix.get_class_count(); ++i) - { + for (int i = 0; i < clearance_matrix.get_class_count(); ++i) { this.column_names[i + 1] = clearance_matrix.get_name(i); this.data[i] = new Object[clearance_matrix.get_class_count() + 1]; this.data[i][0] = clearance_matrix.get_name(i); } this.set_values(0); } - - public String getColumnName(int p_col) - { + + public String getColumnName(int p_col) { return column_names[p_col]; } - - public int getRowCount() - { + + public int getRowCount() { return data.length; } - - public int getColumnCount() - { + + public int getColumnCount() { return column_names.length; } - - public Object getValueAt(int p_row, int p_col) - { + + public Object getValueAt(int p_row, int p_col) { return data[p_row][p_col]; } - - public void setValueAt(Object p_value, int p_row, int p_col) - { + + public void setValueAt(Object p_value, int p_row, int p_col) { Number number_value = null; - if (p_value instanceof Number) - { + if (p_value instanceof Number) { // does ot work because of a localisation Bug in Java number_value = (Number) p_value; - } - else - { + } else { // Workaround because of a localisation Bug in Java // The numbers are always displayed in the English Format. - if (!(p_value instanceof String)) - { + if (!(p_value instanceof String)) { return; } - try - { + try { number_value = Float.parseFloat((String) p_value); - } - catch (Exception e) - { + } catch (Exception e) { return; } } int curr_row = p_row; int curr_column = p_col - 1; - + // check, if there are items on the board assigned to clearance class i or j. - + net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; net.freerouting.datastructures.UndoableObjects item_list = board_handling.get_routing_board().item_list; boolean items_already_assigned_row = false; boolean items_already_assigned_column = false; java.util.Iterator it = item_list.start_read_object(); - for(;;) - { + for (; ; ) { net.freerouting.board.Item curr_item = (net.freerouting.board.Item) item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } int curr_item_class_no = curr_item.clearance_class_no(); - if (curr_item_class_no == curr_row) - { + if (curr_item_class_no == curr_row) { items_already_assigned_row = true; } - if (curr_item_class_no == curr_column) - { + if (curr_item_class_no == curr_column) { items_already_assigned_column = true; } - + } ClearanceMatrix clearance_matrix = board_handling.get_routing_board().rules.clearance_matrix; boolean items_already_assigned = items_already_assigned_row && items_already_assigned_column; - if ( items_already_assigned) - { + if (items_already_assigned) { String message = resources.getString("already_assigned") + " "; - if (curr_row == curr_column) - { + if (curr_row == curr_column) { message += resources.getString("the_class") + " " + clearance_matrix.get_name(curr_row); - } - else - { + } else { message += resources.getString("the_classes") + " " + clearance_matrix.get_name(curr_row) + " " + resources.getString("and") + " " + clearance_matrix.get_name(curr_column); } message += resources.getString("change_anyway"); int selected_option = javax.swing.JOptionPane.showConfirmDialog(board_frame.clearance_matrix_window, message, null, javax.swing.JOptionPane.YES_NO_OPTION); - if (selected_option != javax.swing.JOptionPane.YES_OPTION) - { + if (selected_option != javax.swing.JOptionPane.YES_OPTION) { return; } } - + this.data[p_row][p_col] = number_value; - this.data[p_col- 1] [p_row + 1] = number_value; + this.data[p_col - 1][p_row + 1] = number_value; fireTableCellUpdated(p_row, p_col); fireTableCellUpdated(p_col - 1, p_row + 1); - + int board_value = (int) Math.round(board_handling.coordinate_transform.user_to_board((number_value).doubleValue())); int layer_no = layer_combo_box.get_selected_layer().index; - if (layer_no == ComboBoxLayer.ALL_LAYER_INDEX) - { + if (layer_no == ComboBoxLayer.ALL_LAYER_INDEX) { // change the clearance on all layers clearance_matrix.set_value(curr_row, curr_column, board_value); clearance_matrix.set_value(curr_column, curr_row, board_value); - } - else if (layer_no == ComboBoxLayer.INNER_LAYER_INDEX) - { + } else if (layer_no == ComboBoxLayer.INNER_LAYER_INDEX) { // change the clearance on all inner layers clearance_matrix.set_inner_value(curr_row, curr_column, board_value); clearance_matrix.set_inner_value(curr_column, curr_row, board_value); - } - else - { + } else { // change the clearance on layer with index layer_no clearance_matrix.set_value(curr_row, curr_column, layer_no, board_value); clearance_matrix.set_value(curr_column, curr_row, layer_no, board_value); } - if (items_already_assigned) - { + if (items_already_assigned) { // force reinserting all item into the searck tree, because their tree shapes may have changed board_handling.get_routing_board().search_tree_manager.clearance_value_changed(); } } - - public boolean isCellEditable(int p_row, int p_col) - { + + public boolean isCellEditable(int p_row, int p_col) { return p_row > 0 && p_col > 1; } - - public Class getColumnClass(int p_col) - { - if (p_col == 0) - { + + public Class getColumnClass(int p_col) { + if (p_col == 0) { return String.class; } return String.class; // Should be Number.class or Float.class. But that does not work because of a localisation bug in Java. } - + /** * Sets the values of this clearance table to the values of the clearance matrix on the input layer. */ - private void set_values(int p_layer) - { + private void set_values(int p_layer) { net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; ClearanceMatrix clearance_matrix = board_handling.get_routing_board().rules.clearance_matrix; - - for (int i = 0; i < clearance_matrix.get_class_count(); ++i) - { - for (int j = 0; j < clearance_matrix.get_class_count(); ++j) - { - if (p_layer == ComboBoxLayer.ALL_LAYER_INDEX) - { + + for (int i = 0; i < clearance_matrix.get_class_count(); ++i) { + for (int j = 0; j < clearance_matrix.get_class_count(); ++j) { + if (p_layer == ComboBoxLayer.ALL_LAYER_INDEX) { // all layers - - if (clearance_matrix.is_layer_dependent(i, j)) - { + + if (clearance_matrix.is_layer_dependent(i, j)) { this.data[i][j + 1] = -1; - } - else - { + } else { Float curr_table_value = (float) board_handling.coordinate_transform.board_to_user(clearance_matrix.value(i, j, 0)); this.data[i][j + 1] = curr_table_value; } - } - else if (p_layer == ComboBoxLayer.INNER_LAYER_INDEX) - { + } else if (p_layer == ComboBoxLayer.INNER_LAYER_INDEX) { // all layers - - if (clearance_matrix.is_inner_layer_dependent(i, j)) - { + + if (clearance_matrix.is_inner_layer_dependent(i, j)) { this.data[i][j + 1] = -1; - } - else - { + } else { Float curr_table_value = (float) board_handling.coordinate_transform.board_to_user(clearance_matrix.value(i, j, 1)); this.data[i][j + 1] = curr_table_value; } - } - else - { + } else { Float curr_table_value = (float) board_handling.coordinate_transform.board_to_user(clearance_matrix.value(i, j, p_layer)); this.data[i][j + 1] = curr_table_value; @@ -537,8 +458,5 @@ else if (p_layer == ComboBoxLayer.INNER_LAYER_INDEX) } } } - - private Object[][] data = null; - private String[] column_names = null; } } diff --git a/src/main/java/net/freerouting/gui/WindowClearanceViolations.java b/src/main/java/net/freerouting/gui/WindowClearanceViolations.java index 8a7b8dcc..8b933260 100644 --- a/src/main/java/net/freerouting/gui/WindowClearanceViolations.java +++ b/src/main/java/net/freerouting/gui/WindowClearanceViolations.java @@ -20,157 +20,122 @@ package net.freerouting.gui; -import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.board.ClearanceViolation; - +import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.interactive.ClearanceViolations; /** - * * @author Alfons Wirtz */ -public class WindowClearanceViolations extends WindowObjectListWithFilter -{ - - /** Creates a new instance of IncompletesWindow */ - public WindowClearanceViolations(BoardFrame p_board_frame) - { +public class WindowClearanceViolations extends WindowObjectListWithFilter { + + private final java.util.ResourceBundle resources; + + + /** + * Creates a new instance of IncompletesWindow + */ + public WindowClearanceViolations(BoardFrame p_board_frame) { super(p_board_frame); this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowClearanceViolations", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); this.list_empty_message.setText(resources.getString("list_empty_message")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_ClearanceViolations"); } - - - protected void fill_list() - { + + protected void fill_list() { net.freerouting.interactive.BoardHandling board_handling = this.board_frame.board_panel.board_handling; - + ClearanceViolations clearance_violations = new ClearanceViolations(board_handling.get_routing_board().get_items()); java.util.SortedSet sorted_set = new java.util.TreeSet(); - for (ClearanceViolation curr_violation : clearance_violations.list) - { + for (ClearanceViolation curr_violation : clearance_violations.list) { sorted_set.add(new ViolationInfo(curr_violation)); } - for (ViolationInfo curr_violation : sorted_set) - { + for (ViolationInfo curr_violation : sorted_set) { this.add_to_list(curr_violation); } this.list.setVisibleRowCount(Math.min(sorted_set.size(), DEFAULT_TABLE_SIZE)); } - - protected void select_instances() - { + + protected void select_instances() { Object[] selected_violations = list.getSelectedValues(); - if (selected_violations.length <= 0) - { + if (selected_violations.length <= 0) { return; } java.util.Set selected_items = new java.util.TreeSet(); - for (int i = 0; i < selected_violations.length; ++i) - { + for (int i = 0; i < selected_violations.length; ++i) { ClearanceViolation curr_violation = ((ViolationInfo) selected_violations[i]).violation; selected_items.add(curr_violation.first_item); selected_items.add(curr_violation.second_item); - + } net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; board_handling.select_items(selected_items); board_handling.toggle_selected_item_violations(); board_handling.zoom_selection(); } - - private String item_info(net.freerouting.board.Item p_item) - { + + private String item_info(net.freerouting.board.Item p_item) { String result; - if (p_item instanceof net.freerouting.board.Pin) - { + if (p_item instanceof net.freerouting.board.Pin) { result = resources.getString("pin"); - } - else if (p_item instanceof net.freerouting.board.Via) - { + } else if (p_item instanceof net.freerouting.board.Via) { result = resources.getString("via"); - } - else if (p_item instanceof net.freerouting.board.Trace) - { + } else if (p_item instanceof net.freerouting.board.Trace) { result = resources.getString("trace"); - } - else if (p_item instanceof net.freerouting.board.ConductionArea) - { + } else if (p_item instanceof net.freerouting.board.ConductionArea) { result = resources.getString("conduction_area"); - } - else if (p_item instanceof net.freerouting.board.ObstacleArea) - { + } else if (p_item instanceof net.freerouting.board.ObstacleArea) { result = resources.getString("keepout"); - } - else if (p_item instanceof net.freerouting.board.ViaObstacleArea) - { + } else if (p_item instanceof net.freerouting.board.ViaObstacleArea) { result = resources.getString("via_keepout"); - } - else if (p_item instanceof net.freerouting.board.ComponentObstacleArea) - { + } else if (p_item instanceof net.freerouting.board.ComponentObstacleArea) { result = resources.getString("component_keepout"); - } - else if (p_item instanceof net.freerouting.board.BoardOutline) - { + } else if (p_item instanceof net.freerouting.board.BoardOutline) { result = resources.getString("board_outline"); - } - else - { + } else { result = resources.getString("unknown"); } return result; } - - private final java.util.ResourceBundle resources; - - private class ViolationInfo implements Comparable, WindowObjectInfo.Printable - { - public ViolationInfo(ClearanceViolation p_violation) - { + + private class ViolationInfo implements Comparable, WindowObjectInfo.Printable { + public final ClearanceViolation violation; + public final FloatPoint location; + + public ViolationInfo(ClearanceViolation p_violation) { this.violation = p_violation; FloatPoint board_location = p_violation.shape.centre_of_gravity(); this.location = board_frame.board_panel.board_handling.coordinate_transform.board_to_user(board_location); } - - public String toString() - { - net.freerouting.board.LayerStructure layer_structure = board_frame.board_panel.board_handling.get_routing_board().layer_structure; + + public String toString() { + net.freerouting.board.LayerStructure layer_structure = board_frame.board_panel.board_handling.get_routing_board().layer_structure; String result = item_info(violation.first_item) + " - " + item_info(violation.second_item) - + " " + resources.getString("at") + " " + location.to_string(board_frame.get_locale()) + " " + + " " + resources.getString("at") + " " + location.to_string(board_frame.get_locale()) + " " + resources.getString("on_layer") + " " + layer_structure.arr[violation.layer].name; return result; } - - public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) - { + + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { this.violation.print_info(p_window, p_locale); } - - public int compareTo(ViolationInfo p_other) - { - if (this.location.x > p_other.location.x) - { + + public int compareTo(ViolationInfo p_other) { + if (this.location.x > p_other.location.x) { return 1; } - if (this.location.x < p_other.location.x) - { + if (this.location.x < p_other.location.x) { return -1; } - if (this.location.y > p_other.location.y) - { + if (this.location.y > p_other.location.y) { return 1; } - if (this.location.y < p_other.location.y) - { + if (this.location.y < p_other.location.y) { return -1; } return this.violation.layer - p_other.violation.layer; } - - public final ClearanceViolation violation; - public final FloatPoint location; } } \ No newline at end of file diff --git a/src/main/java/net/freerouting/gui/WindowComponents.java b/src/main/java/net/freerouting/gui/WindowComponents.java index 19a45222..0fbe5afd 100644 --- a/src/main/java/net/freerouting/gui/WindowComponents.java +++ b/src/main/java/net/freerouting/gui/WindowComponents.java @@ -19,6 +19,7 @@ */ package net.freerouting.gui; + import net.freerouting.board.Component; import net.freerouting.board.Components; @@ -27,64 +28,54 @@ * * @author Alfons Wirtz */ -public class WindowComponents extends WindowObjectListWithFilter -{ - - /** Creates a new instance of ComponentsWindow */ - public WindowComponents(BoardFrame p_board_frame) - { +public class WindowComponents extends WindowObjectListWithFilter { + + /** + * Creates a new instance of ComponentsWindow + */ + public WindowComponents(BoardFrame p_board_frame) { super(p_board_frame); - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); this.setTitle(resources.getString("components")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_BoardComponents"); } - + /** * Fills the list with the board components. */ - protected void fill_list() - { + protected void fill_list() { Components components = this.board_frame.board_panel.board_handling.get_routing_board().components; Component[] sorted_arr = new Component[components.count()]; - for (int i = 0; i < sorted_arr.length; ++i) - { + for (int i = 0; i < sorted_arr.length; ++i) { sorted_arr[i] = components.get(i + 1); } java.util.Arrays.sort(sorted_arr); - for (int i = 0; i < sorted_arr.length; ++i) - { + for (int i = 0; i < sorted_arr.length; ++i) { this.add_to_list(sorted_arr[i]); } this.list.setVisibleRowCount(Math.min(components.count(), DEFAULT_TABLE_SIZE)); } - - protected void select_instances() - { + + protected void select_instances() { Object[] selected_components = list.getSelectedValues(); - if (selected_components.length <= 0) - { + if (selected_components.length <= 0) { return; } net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); java.util.Set selected_items = new java.util.TreeSet(); java.util.Collection board_items = routing_board.get_items(); - for (net.freerouting.board.Item curr_item : board_items) - { - if (curr_item.get_component_no() > 0) - { + for (net.freerouting.board.Item curr_item : board_items) { + if (curr_item.get_component_no() > 0) { net.freerouting.board.Component curr_component = routing_board.components.get(curr_item.get_component_no()); boolean component_matches = false; - for (int i = 0; i < selected_components.length; ++i) - { - if (curr_component == selected_components[i]) - { + for (int i = 0; i < selected_components.length; ++i) { + if (curr_component == selected_components[i]) { component_matches = true; break; } } - if (component_matches) - { + if (component_matches) { selected_items.add(curr_item); } } diff --git a/src/main/java/net/freerouting/gui/WindowDisplayMisc.java b/src/main/java/net/freerouting/gui/WindowDisplayMisc.java index 97128059..6dc99f37 100644 --- a/src/main/java/net/freerouting/gui/WindowDisplayMisc.java +++ b/src/main/java/net/freerouting/gui/WindowDisplayMisc.java @@ -25,142 +25,154 @@ * * @author Alfons Wirtz */ -public class WindowDisplayMisc extends BoardSavableSubWindow -{ - - /** Creates a new instance of DisplayMiscWindow */ - public WindowDisplayMisc(BoardFrame p_board_frame) - { +public class WindowDisplayMisc extends BoardSavableSubWindow { + + private static final int MAX_SLIDER_VALUE = 100; + private final BoardPanel panel; + private final javax.swing.JRadioButton small_cursor_checkbox; + private final javax.swing.JRadioButton big_cursor_checkbox; + private final javax.swing.JRadioButton rotation_none_checkbox; + private final javax.swing.JRadioButton rotation_90_degree_checkbox; + private final javax.swing.JRadioButton rotation_180_degree_checkbox; + private final javax.swing.JRadioButton rotation_270_degree_checkbox; + private final javax.swing.JRadioButton mirror_none_checkbox; + private final javax.swing.JRadioButton vertical_mirror_checkbox; + private final javax.swing.JRadioButton horizontal_mirror_checkbox; + private final javax.swing.JSlider auto_layer_dim_slider; + /** + * Creates a new instance of DisplayMiscWindow + */ + public WindowDisplayMisc(BoardFrame p_board_frame) { this.panel = p_board_frame.board_panel; - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.DisplayMisc", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); - + // Create main panel - + final javax.swing.JPanel main_panel = new javax.swing.JPanel(); getContentPane().add(main_panel); - + // Initialize gridbag layout. - + java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); main_panel.setLayout(gridbag); java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); gridbag_constraints.anchor = java.awt.GridBagConstraints.WEST; gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; - + // add label and buttongroup for the apearance of the cross hair cursor. - + javax.swing.JLabel cursor_label = new javax.swing.JLabel(" " + resources.getString("cross_hair_cursor")); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridbag_constraints.gridheight = 2; gridbag.setConstraints(cursor_label, gridbag_constraints); main_panel.add(cursor_label, gridbag_constraints); - + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag_constraints.gridheight = 1; - + small_cursor_checkbox = new javax.swing.JRadioButton(resources.getString("small")); small_cursor_checkbox.setToolTipText(resources.getString("cursor_checkbox_tooltip")); small_cursor_checkbox.addActionListener(new SmallCursorListener()); gridbag.setConstraints(small_cursor_checkbox, gridbag_constraints); main_panel.add(small_cursor_checkbox, gridbag_constraints); - + big_cursor_checkbox = new javax.swing.JRadioButton(resources.getString("big")); big_cursor_checkbox.addActionListener(new BigCursorListener()); big_cursor_checkbox.setToolTipText(resources.getString("cursor_checkbox_tooltip")); gridbag.setConstraints(big_cursor_checkbox, gridbag_constraints); main_panel.add(big_cursor_checkbox, gridbag_constraints); - + javax.swing.ButtonGroup cursor_button_group = new javax.swing.ButtonGroup(); cursor_button_group.add(small_cursor_checkbox); cursor_button_group.add(big_cursor_checkbox); - + javax.swing.JLabel separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + // Add label and buttongroup for the rotation of the board. - + javax.swing.JLabel rotation_label = new javax.swing.JLabel(" " + resources.getString("rotation")); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridbag_constraints.gridheight = 4; gridbag.setConstraints(rotation_label, gridbag_constraints); main_panel.add(rotation_label, gridbag_constraints); - + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag_constraints.gridheight = 1; - + rotation_none_checkbox = new javax.swing.JRadioButton(resources.getString("none")); gridbag.setConstraints(rotation_none_checkbox, gridbag_constraints); main_panel.add(rotation_none_checkbox, gridbag_constraints); - + rotation_90_degree_checkbox = new javax.swing.JRadioButton(resources.getString("90_degree")); gridbag.setConstraints(rotation_90_degree_checkbox, gridbag_constraints); main_panel.add(rotation_90_degree_checkbox, gridbag_constraints); - + rotation_180_degree_checkbox = new javax.swing.JRadioButton(resources.getString("180_degree")); gridbag.setConstraints(rotation_180_degree_checkbox, gridbag_constraints); main_panel.add(rotation_180_degree_checkbox, gridbag_constraints); - + rotation_270_degree_checkbox = new javax.swing.JRadioButton(resources.getString("-90_degree")); gridbag.setConstraints(rotation_270_degree_checkbox, gridbag_constraints); main_panel.add(rotation_270_degree_checkbox, gridbag_constraints); - + javax.swing.ButtonGroup rotation_button_group = new javax.swing.ButtonGroup(); rotation_button_group.add(rotation_none_checkbox); rotation_button_group.add(rotation_90_degree_checkbox); rotation_button_group.add(rotation_180_degree_checkbox); rotation_button_group.add(rotation_270_degree_checkbox); - + rotation_none_checkbox.addActionListener(new RotationNoneListener()); rotation_90_degree_checkbox.addActionListener(new Rotation90Listener()); rotation_180_degree_checkbox.addActionListener(new Rotation180Listener()); rotation_270_degree_checkbox.addActionListener(new Rotation270Listener()); - + separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - - + + // add label and buttongroup for the mirroring of the board. - + javax.swing.JLabel mirroring_label = new javax.swing.JLabel(" " + resources.getString("board_mirroring")); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridbag_constraints.gridheight = 3; gridbag.setConstraints(mirroring_label, gridbag_constraints); main_panel.add(mirroring_label, gridbag_constraints); - + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag_constraints.gridheight = 1; - - + + mirror_none_checkbox = new javax.swing.JRadioButton(resources.getString("none")); mirror_none_checkbox.addActionListener(new MirrorNoneListener()); gridbag.setConstraints(mirror_none_checkbox, gridbag_constraints); main_panel.add(mirror_none_checkbox, gridbag_constraints); - + vertical_mirror_checkbox = new javax.swing.JRadioButton(resources.getString("left_right")); vertical_mirror_checkbox.addActionListener(new VerticalMirrorListener()); gridbag.setConstraints(vertical_mirror_checkbox, gridbag_constraints); main_panel.add(vertical_mirror_checkbox, gridbag_constraints); - + horizontal_mirror_checkbox = new javax.swing.JRadioButton(resources.getString("top_bottom")); horizontal_mirror_checkbox.addActionListener(new HorizontalMirrorListener()); gridbag.setConstraints(horizontal_mirror_checkbox, gridbag_constraints); main_panel.add(horizontal_mirror_checkbox, gridbag_constraints); - + javax.swing.ButtonGroup mirroring_button_group = new javax.swing.ButtonGroup(); mirroring_button_group.add(mirror_none_checkbox); mirroring_button_group.add(vertical_mirror_checkbox); mirroring_button_group.add(horizontal_mirror_checkbox); - + separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + // add slider for automatic layer dimming - + gridbag_constraints.insets = new java.awt.Insets(5, 10, 5, 10); javax.swing.JLabel auto_layer_dim_label = new javax.swing.JLabel(resources.getString("layer_dimming")); auto_layer_dim_label.setToolTipText(resources.getString("layer_dimming_tooltip")); @@ -170,144 +182,104 @@ public WindowDisplayMisc(BoardFrame p_board_frame) gridbag.setConstraints(auto_layer_dim_slider, gridbag_constraints); main_panel.add(auto_layer_dim_slider); this.auto_layer_dim_slider.addChangeListener(new SliderChangeListener()); - + p_board_frame.set_context_sensitive_help(this, "WindowDisplay_Miscellanious"); - + this.refresh(); this.pack(); this.setResizable(false); } - + /** * Refreshs the displayed values in this window. */ - public void refresh() - { + public void refresh() { small_cursor_checkbox.setSelected(!panel.is_custom_cross_hair_cursor()); big_cursor_checkbox.setSelected(panel.is_custom_cross_hair_cursor()); - + int ninety_degree_rotation = panel.board_handling.graphics_context.coordinate_transform.get_90_degree_rotation(); - - if (ninety_degree_rotation == 0) - { + + if (ninety_degree_rotation == 0) { rotation_none_checkbox.setSelected(true); - } - else if (ninety_degree_rotation == 1) - { + } else if (ninety_degree_rotation == 1) { rotation_90_degree_checkbox.setSelected(true); - } - else if (ninety_degree_rotation == 2) - { + } else if (ninety_degree_rotation == 2) { rotation_180_degree_checkbox.setSelected(true); - } - else if (ninety_degree_rotation == 3) - { + } else if (ninety_degree_rotation == 3) { rotation_270_degree_checkbox.setSelected(true); - } - else - { + } else { System.out.println("DisplayMiscWindow: unexpected ninety_degree_rotation"); rotation_none_checkbox.setSelected(true); } - + boolean is_mirror_left_right = panel.board_handling.graphics_context.coordinate_transform.is_mirror_left_right(); boolean is_mirror_top_button = panel.board_handling.graphics_context.coordinate_transform.is_mirror_top_bottom(); mirror_none_checkbox.setSelected(!(is_mirror_left_right || is_mirror_top_button)); - + vertical_mirror_checkbox.setSelected( panel.board_handling.graphics_context.coordinate_transform.is_mirror_left_right()); horizontal_mirror_checkbox.setSelected( panel.board_handling.graphics_context.coordinate_transform.is_mirror_top_bottom()); - + int curr_slider_value = - (int) Math.round(MAX_SLIDER_VALUE * ( 1 - panel.board_handling.graphics_context.get_auto_layer_dim_factor())); + (int) Math.round(MAX_SLIDER_VALUE * (1 - panel.board_handling.graphics_context.get_auto_layer_dim_factor())); auto_layer_dim_slider.setValue(curr_slider_value); } - - private final BoardPanel panel; - private final javax.swing.JRadioButton small_cursor_checkbox; - private final javax.swing.JRadioButton big_cursor_checkbox; - private final javax.swing.JRadioButton rotation_none_checkbox; - private final javax.swing.JRadioButton rotation_90_degree_checkbox; - private final javax.swing.JRadioButton rotation_180_degree_checkbox; - private final javax.swing.JRadioButton rotation_270_degree_checkbox; - private final javax.swing.JRadioButton mirror_none_checkbox; - private final javax.swing.JRadioButton vertical_mirror_checkbox; - private final javax.swing.JRadioButton horizontal_mirror_checkbox; - private final javax.swing.JSlider auto_layer_dim_slider; - - private static final int MAX_SLIDER_VALUE = 100; - - - private class SmallCursorListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class SmallCursorListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { panel.set_custom_crosshair_cursor(false); } } - - private class BigCursorListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class BigCursorListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { panel.set_custom_crosshair_cursor(true); } } - - private class RotationNoneListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class RotationNoneListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; coordinate_transform.set_rotation(0); panel.repaint(); } } - - private class Rotation90Listener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class Rotation90Listener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; coordinate_transform.set_rotation(0.5 * Math.PI); panel.repaint(); } } - - private class Rotation180Listener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class Rotation180Listener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; coordinate_transform.set_rotation(Math.PI); panel.repaint(); } } - - private class Rotation270Listener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class Rotation270Listener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; coordinate_transform.set_rotation(1.5 * Math.PI); panel.repaint(); } } - - private class MirrorNoneListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class MirrorNoneListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; - if(!(coordinate_transform.is_mirror_left_right() || coordinate_transform.is_mirror_top_bottom())) - { + if (!(coordinate_transform.is_mirror_left_right() || coordinate_transform.is_mirror_top_bottom())) { return; // mirroring already switched off } // remember the old viewort center to retain the displayed section of the board. @@ -319,16 +291,13 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) panel.repaint(); } } - - - private class VerticalMirrorListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + + private class VerticalMirrorListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; - if (coordinate_transform.is_mirror_left_right()) - { + if (coordinate_transform.is_mirror_left_right()) { return; // already mirrored } // remember the old viewort center to retain the displayed section of the board. @@ -340,15 +309,12 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) panel.repaint(); } } - - private class HorizontalMirrorListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class HorizontalMirrorListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.boardgraphics.CoordinateTransform coordinate_transform = panel.board_handling.graphics_context.coordinate_transform; - if (coordinate_transform.is_mirror_top_bottom()) - { + if (coordinate_transform.is_mirror_top_bottom()) { return; // already mirrored } // remember the old viewort center to retain the displayed section of the board. @@ -360,15 +326,13 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) panel.repaint(); } } - - private class SliderChangeListener implements javax.swing.event.ChangeListener - { - public void stateChanged(javax.swing.event.ChangeEvent evt) - { - double new_value = 1 - (double) auto_layer_dim_slider.getValue()/(double) MAX_SLIDER_VALUE; + + private class SliderChangeListener implements javax.swing.event.ChangeListener { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + double new_value = 1 - (double) auto_layer_dim_slider.getValue() / (double) MAX_SLIDER_VALUE; panel.board_handling.graphics_context.set_auto_layer_dim_factor(new_value); panel.repaint(); } } - + } diff --git a/src/main/java/net/freerouting/gui/WindowEditVias.java b/src/main/java/net/freerouting/gui/WindowEditVias.java index 7fb68ea7..7c64719f 100644 --- a/src/main/java/net/freerouting/gui/WindowEditVias.java +++ b/src/main/java/net/freerouting/gui/WindowEditVias.java @@ -20,98 +20,103 @@ package net.freerouting.gui; +import net.freerouting.rules.BoardRules; import net.freerouting.rules.ViaInfo; import net.freerouting.rules.ViaInfos; -import net.freerouting.rules.BoardRules; /** * Edit window for the table of available vias. * * @author Alfons Wirtz */ -public class WindowEditVias extends BoardSavableSubWindow -{ - - /** Creates a new instance of ViaTablePanel */ - public WindowEditVias(BoardFrame p_board_frame) - { +public class WindowEditVias extends BoardSavableSubWindow { + + private static final int TEXTFIELD_HEIGHT = 16; + private static final int TEXTFIELD_WIDTH = 100; + private final BoardFrame board_frame; + private final javax.swing.JPanel main_panel; + private final javax.swing.JComboBox cl_class_combo_box; + private final javax.swing.JComboBox padstack_combo_box; + private final java.util.ResourceBundle resources; + private javax.swing.JScrollPane scroll_pane; + private javax.swing.JTable table; + private ViaTableModel table_model; + + /** + * Creates a new instance of ViaTablePanel + */ + public WindowEditVias(BoardFrame p_board_frame) { this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowEditVias", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); - + this.board_frame = p_board_frame; - + this.main_panel = new javax.swing.JPanel(); this.main_panel.setLayout(new java.awt.BorderLayout()); - + this.cl_class_combo_box = new javax.swing.JComboBox(); this.padstack_combo_box = new javax.swing.JComboBox(); add_combobox_items(); - + add_table(); - + javax.swing.JPanel via_info_button_panel = new javax.swing.JPanel(); via_info_button_panel.setLayout(new java.awt.FlowLayout()); - this.main_panel.add(via_info_button_panel,java.awt.BorderLayout.SOUTH); - final javax.swing.JButton add_via_button = new javax.swing.JButton(resources.getString("add")); + this.main_panel.add(via_info_button_panel, java.awt.BorderLayout.SOUTH); + final javax.swing.JButton add_via_button = new javax.swing.JButton(resources.getString("add")); add_via_button.setToolTipText(resources.getString("add_tooltip")); add_via_button.addActionListener(new AddViaListener()); via_info_button_panel.add(add_via_button); - final javax.swing.JButton remove_via_button = new javax.swing.JButton(resources.getString("remove")); + final javax.swing.JButton remove_via_button = new javax.swing.JButton(resources.getString("remove")); remove_via_button.setToolTipText(resources.getString("remove_tooltip")); remove_via_button.addActionListener(new RemoveViaListener()); via_info_button_panel.add(remove_via_button); - + p_board_frame.set_context_sensitive_help(this, "WindowVia_EditVia"); - + this.add(main_panel); this.pack(); } - + /** * Recalculates all values displayed in the parent window */ - public void refresh() - { + public void refresh() { this.padstack_combo_box.removeAllItems(); this.cl_class_combo_box.removeAllItems(); this.add_combobox_items(); this.table_model.set_values(); } - - private void add_table() - { + + private void add_table() { this.table_model = new ViaTableModel(); - this.table = new javax.swing.JTable(this.table_model); + this.table = new javax.swing.JTable(this.table_model); this.scroll_pane = new javax.swing.JScrollPane(this.table); int table_height = TEXTFIELD_HEIGHT * this.table_model.getRowCount(); - int table_width = TEXTFIELD_WIDTH * this.table_model.getColumnCount(); + int table_width = TEXTFIELD_WIDTH * this.table_model.getColumnCount(); this.table.setPreferredScrollableViewportSize(new java.awt.Dimension(table_width, table_height)); this.table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); this.main_panel.add(scroll_pane, java.awt.BorderLayout.CENTER); - + this.table.getColumnModel().getColumn(ColumnName.CLEARANCE_CLASS.ordinal()).setCellEditor(new javax.swing.DefaultCellEditor(cl_class_combo_box)); - + this.table.getColumnModel().getColumn(ColumnName.PADSTACK.ordinal()).setCellEditor(new javax.swing.DefaultCellEditor(padstack_combo_box)); } - - private void add_combobox_items() - { + + private void add_combobox_items() { net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); - for (int i = 0; i < routing_board.rules.clearance_matrix.get_class_count(); ++i) - { + for (int i = 0; i < routing_board.rules.clearance_matrix.get_class_count(); ++i) { cl_class_combo_box.addItem(routing_board.rules.clearance_matrix.get_name(i)); } - for (int i = 0; i < routing_board.library.via_padstack_count(); ++i) - { + for (int i = 0; i < routing_board.library.via_padstack_count(); ++i) { padstack_combo_box.addItem(routing_board.library.get_via_padstack(i).name); } } - + /** * Adjusts the displayed window with the via table after the size of the table has been changed. */ - private void adjust_table() - { + private void adjust_table() { this.table_model = new ViaTableModel(); this.table = new javax.swing.JTable(this.table_model); this.main_panel.remove(this.scroll_pane); @@ -119,37 +124,21 @@ private void adjust_table() this.pack(); this.board_frame.refresh_windows(); } - - private final BoardFrame board_frame; - - private final javax.swing.JPanel main_panel; - - private javax.swing.JScrollPane scroll_pane; - private javax.swing.JTable table; - private ViaTableModel table_model; - - private final javax.swing.JComboBox cl_class_combo_box; - private final javax.swing.JComboBox padstack_combo_box; - - private final java.util.ResourceBundle resources; - - private static final int TEXTFIELD_HEIGHT = 16; - private static final int TEXTFIELD_WIDTH = 100; - - private class AddViaListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private enum ColumnName { + NAME, PADSTACK, CLEARANCE_CLASS, ATTACH_SMD + } + + private class AddViaListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); ViaInfos via_infos = routing_board.rules.via_infos; Integer no = 1; String new_name = null; final String name_start = resources.getString("new_via"); - for (;;) - { + for (; ; ) { new_name = name_start + no.toString(); - if (!via_infos.name_exists(new_name)) - { + if (!via_infos.name_exists(new_name)) { break; } ++no; @@ -162,40 +151,32 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) adjust_table(); } } - - private class RemoveViaListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - if (table_model.getRowCount() <= 1) - { + + private class RemoveViaListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + if (table_model.getRowCount() <= 1) { board_frame.screen_messages.set_status_message(resources.getString("message_1")); return; } int selected_row = table.getSelectedRow(); - if (selected_row < 0) - { + if (selected_row < 0) { return; } Object via_name = table_model.getValueAt(selected_row, ColumnName.NAME.ordinal()); - if (!(via_name instanceof String)) - { + if (!(via_name instanceof String)) { return; } BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; ViaInfo via_info = board_rules.via_infos.get((String) via_name); // Check, if via_info is used in a via rule. - for (net.freerouting.rules.ViaRule curr_rule : board_rules.via_rules) - { - if (curr_rule.contains(via_info)) - { + for (net.freerouting.rules.ViaRule curr_rule : board_rules.via_rules) { + if (curr_rule.contains(via_info)) { String message = resources.getString("message_2") + " " + curr_rule.name; board_frame.screen_messages.set_status_message(message); return; } } - if (board_rules.via_infos.remove(via_info)) - { + if (board_rules.via_infos.remove(via_info)) { adjust_table(); String message = resources.getString("via") + "via " + via_info.get_name() + " " + resources.getString("removed"); @@ -203,130 +184,108 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) } } } - + /** * Table model of the via table. */ - private class ViaTableModel extends javax.swing.table.AbstractTableModel - { - public ViaTableModel() - { + private class ViaTableModel extends javax.swing.table.AbstractTableModel { + private Object[][] data = null; + private String[] column_names = null; + + public ViaTableModel() { column_names = new String[ColumnName.values().length]; - - for (int i = 0; i < column_names.length; ++i) - { - column_names[i] = resources.getString((ColumnName.values()[i]).toString()); + + for (int i = 0; i < column_names.length; ++i) { + column_names[i] = resources.getString((ColumnName.values()[i]).toString()); } net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; data = new Object[board_rules.via_infos.count()][]; - for (int i = 0; i < data.length; ++i) - { + for (int i = 0; i < data.length; ++i) { this.data[i] = new Object[ColumnName.values().length]; } set_values(); } - - /** Calculates the the valus in this table */ - public void set_values() - { + + /** + * Calculates the the valus in this table + */ + public void set_values() { net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; - for (int i = 0; i < data.length; ++i) - { + for (int i = 0; i < data.length; ++i) { ViaInfo curr_via = board_rules.via_infos.get(i); this.data[i][ColumnName.NAME.ordinal()] = curr_via.get_name(); this.data[i][ColumnName.PADSTACK.ordinal()] = curr_via.get_padstack().name; - this.data[i] [ColumnName.CLEARANCE_CLASS.ordinal()] = board_rules.clearance_matrix.get_name(curr_via.get_clearance_class()); - this.data[i] [ColumnName.ATTACH_SMD.ordinal()] = curr_via.attach_smd_allowed(); + this.data[i][ColumnName.CLEARANCE_CLASS.ordinal()] = board_rules.clearance_matrix.get_name(curr_via.get_clearance_class()); + this.data[i][ColumnName.ATTACH_SMD.ordinal()] = curr_via.attach_smd_allowed(); } } - - public String getColumnName(int p_col) - { + + public String getColumnName(int p_col) { return column_names[p_col]; } - - public int getRowCount() - { + + public int getRowCount() { return data.length; } - - public int getColumnCount() - { + + public int getColumnCount() { return column_names.length; } - - public Object getValueAt(int p_row, int p_col) - { + + public Object getValueAt(int p_row, int p_col) { return data[p_row][p_col]; } - - public void setValueAt(Object p_value, int p_row, int p_col) - { - net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); + + public void setValueAt(Object p_value, int p_row, int p_col) { + net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); BoardRules board_rules = routing_board.rules; Object via_name = getValueAt(p_row, ColumnName.NAME.ordinal()); - if (!(via_name instanceof String)) - { + if (!(via_name instanceof String)) { System.out.println("ViaVindow.setValueAt: String expected"); return; } ViaInfo via_info = board_rules.via_infos.get((String) via_name); - if (via_info == null) - { + if (via_info == null) { System.out.println("ViaVindow.setValueAt: via_info not found"); return; } - - if (p_col == ColumnName.NAME.ordinal()) - { - if (!(p_value instanceof String)) - { + + if (p_col == ColumnName.NAME.ordinal()) { + if (!(p_value instanceof String)) { return; } String new_name = (String) p_value; - if (board_rules.via_infos.name_exists(new_name)) - { + if (board_rules.via_infos.name_exists(new_name)) { return; } via_info.set_name(new_name); board_frame.via_window.refresh(); - } - else if (p_col == ColumnName.PADSTACK.ordinal()) - { - if (!(p_value instanceof String)) - { + } else if (p_col == ColumnName.PADSTACK.ordinal()) { + if (!(p_value instanceof String)) { return; } String new_name = (String) p_value; net.freerouting.library.Padstack new_padstack = routing_board.library.get_via_padstack(new_name); - if (new_padstack == null) - { + if (new_padstack == null) { System.out.println("ViaVindow.setValueAt: via padstack not found"); return; } via_info.set_padstack(new_padstack); - } - else if (p_col == ColumnName.CLEARANCE_CLASS.ordinal()) - { - if (!(p_value instanceof String)) - { + } else if (p_col == ColumnName.CLEARANCE_CLASS.ordinal()) { + if (!(p_value instanceof String)) { return; } String new_name = (String) p_value; int new_cl_class_index = board_rules.clearance_matrix.get_no(new_name); { - if (new_cl_class_index < 0) - { + if (new_cl_class_index < 0) { System.out.println("ViaVindow.setValueAt: clearance class not found"); return; } } via_info.set_clearance_class(new_cl_class_index); - } - else if (p_col == ColumnName.ATTACH_SMD.ordinal()) - { - if (!(p_value instanceof Boolean)) - { + } else if (p_col == ColumnName.ATTACH_SMD.ordinal()) { + if (!(p_value instanceof Boolean)) { System.out.println("ViaVindow.setValueAt: Boolean expected"); return; } @@ -336,23 +295,13 @@ else if (p_col == ColumnName.ATTACH_SMD.ordinal()) this.data[p_row][p_col] = p_value; fireTableCellUpdated(p_row, p_col); } - - public boolean isCellEditable(int p_row, int p_col) - { + + public boolean isCellEditable(int p_row, int p_col) { return true; } - - public Class getColumnClass(int p_col) - { + + public Class getColumnClass(int p_col) { return getValueAt(0, p_col).getClass(); } - - private Object[][] data = null; - private String[] column_names = null; - } - - private enum ColumnName - { - NAME, PADSTACK, CLEARANCE_CLASS, ATTACH_SMD } } diff --git a/src/main/java/net/freerouting/gui/WindowIncompletes.java b/src/main/java/net/freerouting/gui/WindowIncompletes.java index cabad7fd..c19d040d 100644 --- a/src/main/java/net/freerouting/gui/WindowIncompletes.java +++ b/src/main/java/net/freerouting/gui/WindowIncompletes.java @@ -23,54 +23,48 @@ import net.freerouting.interactive.RatsNest; /** - * * @author Alfons Wirtz */ -public class WindowIncompletes extends WindowObjectListWithFilter -{ - - /** Creates a new instance of IncompletesWindow */ - public WindowIncompletes(BoardFrame p_board_frame) - { - super(p_board_frame); - java.util.ResourceBundle resources = +public class WindowIncompletes extends WindowObjectListWithFilter { + + /** + * Creates a new instance of IncompletesWindow + */ + public WindowIncompletes(BoardFrame p_board_frame) { + super(p_board_frame); + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); this.setTitle(resources.getString("incompletes")); this.list_empty_message.setText(resources.getString("route_completed")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_Incompletes"); } - - + + /** * Fills the list with the board incompletes. */ - protected void fill_list() - { + protected void fill_list() { RatsNest ratsnest = board_frame.board_panel.board_handling.get_ratsnest(); RatsNest.AirLine[] sorted_arr = ratsnest.get_airlines(); - + java.util.Arrays.sort(sorted_arr); - for (int i = 0; i < sorted_arr.length; ++i) - { + for (int i = 0; i < sorted_arr.length; ++i) { this.add_to_list(sorted_arr[i]); } this.list.setVisibleRowCount(Math.min(sorted_arr.length, DEFAULT_TABLE_SIZE)); } - - protected void select_instances() - { + + protected void select_instances() { Object[] selected_incompletes = list.getSelectedValues(); - if (selected_incompletes.length <= 0) - { + if (selected_incompletes.length <= 0) { return; } java.util.Set selected_items = new java.util.TreeSet(); - for (int i = 0; i < selected_incompletes.length; ++i) - { + for (int i = 0; i < selected_incompletes.length; ++i) { RatsNest.AirLine curr_airline = (RatsNest.AirLine) selected_incompletes[i]; selected_items.add(curr_airline.from_item); selected_items.add(curr_airline.to_item); - + } board_frame.board_panel.board_handling.select_items(selected_items); board_frame.board_panel.board_handling.zoom_selection(); diff --git a/src/main/java/net/freerouting/gui/WindowLayerVisibility.java b/src/main/java/net/freerouting/gui/WindowLayerVisibility.java index 22930f95..b76a8afa 100644 --- a/src/main/java/net/freerouting/gui/WindowLayerVisibility.java +++ b/src/main/java/net/freerouting/gui/WindowLayerVisibility.java @@ -23,66 +23,59 @@ /** * Interactive Frame to adjust the visibility of the individual board layers * - * @author alfons + * @author alfons */ -public class WindowLayerVisibility extends WindowVisibility -{ - /** Returns a new instance of LayerVisibilityFrame */ - public static WindowLayerVisibility get_instance(BoardFrame p_board_frame) - { +public class WindowLayerVisibility extends WindowVisibility { + /** + * Creates a new instance of LayerVisibilityFrame + */ + private WindowLayerVisibility(BoardFrame p_board_frame, String p_title, String p_header_message, String[] p_message_arr) { + + super(p_board_frame, p_title, p_header_message, p_message_arr); + } + + /** + * Returns a new instance of LayerVisibilityFrame + */ + public static WindowLayerVisibility get_instance(BoardFrame p_board_frame) { BoardPanel board_panel = p_board_frame.board_panel; - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); String title = resources.getString("layer_visibility"); String header_message = resources.getString("layer_visibility_header"); net.freerouting.board.LayerStructure layer_structure = board_panel.board_handling.get_routing_board().layer_structure; - String [] message_arr = new String [layer_structure.arr.length]; - for (int i = 0; i < message_arr.length; ++i) - { + String[] message_arr = new String[layer_structure.arr.length]; + for (int i = 0; i < message_arr.length; ++i) { message_arr[i] = layer_structure.arr[i].name; } WindowLayerVisibility result = new WindowLayerVisibility(p_board_frame, title, header_message, message_arr); - for (int i = 0; i < message_arr.length; ++i) - { + for (int i = 0; i < message_arr.length; ++i) { result.set_slider_value(i, board_panel.board_handling.graphics_context.get_raw_layer_visibility(i)); } p_board_frame.set_context_sensitive_help(result, "WindowDisplay_LayerVisibility"); return result; } - - /** Creates a new instance of LayerVisibilityFrame */ - private WindowLayerVisibility(BoardFrame p_board_frame, String p_title, String p_header_message, String[] p_message_arr) - { - - super(p_board_frame, p_title, p_header_message, p_message_arr); - } - - protected void set_changed_value(int p_index, double p_value) - { + + protected void set_changed_value(int p_index, double p_value) { get_board_handling().set_layer_visibility(p_index, p_value); } - - protected void set_all_minimum() - { + + protected void set_all_minimum() { int layer_count = this.get_board_handling().graphics_context.layer_count(); - for (int i = 0; i < layer_count; ++i) - { - if (i != this.get_board_handling().settings.get_layer()) - { + for (int i = 0; i < layer_count; ++i) { + if (i != this.get_board_handling().settings.get_layer()) { set_slider_value(i, 0); set_changed_value(i, 0); } } } - + /** * Refreshs the displayed values in this window. */ - public void refresh() - { + public void refresh() { net.freerouting.boardgraphics.GraphicsContext graphics_context = this.get_board_handling().graphics_context; - for (int i = 0; i < graphics_context.layer_count(); ++i) - { + for (int i = 0; i < graphics_context.layer_count(); ++i) { this.set_slider_value(i, graphics_context.get_raw_layer_visibility(i)); } } diff --git a/src/main/java/net/freerouting/gui/WindowLengthViolations.java b/src/main/java/net/freerouting/gui/WindowLengthViolations.java index b64ecfbc..00537394 100644 --- a/src/main/java/net/freerouting/gui/WindowLengthViolations.java +++ b/src/main/java/net/freerouting/gui/WindowLengthViolations.java @@ -21,107 +21,91 @@ package net.freerouting.gui; +import net.freerouting.interactive.RatsNest; import net.freerouting.rules.Net; -import net.freerouting.rules.Nets; import net.freerouting.rules.NetClass; - -import net.freerouting.interactive.RatsNest; +import net.freerouting.rules.Nets; /** - * * @author Alfons Wirtz */ -public class WindowLengthViolations extends WindowObjectListWithFilter -{ - - /** Creates a new instance of WindowLengthViolations */ - public WindowLengthViolations(BoardFrame p_board_frame) - { +public class WindowLengthViolations extends WindowObjectListWithFilter { + + private final java.util.ResourceBundle resources; + + /** + * Creates a new instance of WindowLengthViolations + */ + public WindowLengthViolations(BoardFrame p_board_frame) { super(p_board_frame); this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowLengthViolations", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); this.list_empty_message.setText(resources.getString("list_empty")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_LengthViolations"); } - - protected void fill_list() - { + + protected void fill_list() { RatsNest ratsnest = this.board_frame.board_panel.board_handling.get_ratsnest(); Nets net_list = this.board_frame.board_panel.board_handling.get_routing_board().rules.nets; java.util.SortedSet length_violations = new java.util.TreeSet(); - for (int net_index = 1; net_index <= net_list.max_net_no(); ++net_index) - { + for (int net_index = 1; net_index <= net_list.max_net_no(); ++net_index) { double curr_violation_length = ratsnest.get_length_violation(net_index); - if (curr_violation_length != 0) - { + if (curr_violation_length != 0) { LengthViolation curr_length_violation = new LengthViolation(net_list.get(net_index), curr_violation_length); length_violations.add(curr_length_violation); } } - - for (LengthViolation curr_violation : length_violations) - { + + for (LengthViolation curr_violation : length_violations) { this.add_to_list(curr_violation); } this.list.setVisibleRowCount(Math.min(length_violations.size(), DEFAULT_TABLE_SIZE)); } - - protected void select_instances() - { + + protected void select_instances() { Object[] selected_violations = list.getSelectedValues(); - if (selected_violations.length <= 0) - { + if (selected_violations.length <= 0) { return; } java.util.Set selected_items = new java.util.TreeSet(); - for (int i = 0; i < selected_violations.length; ++i) - { + for (int i = 0; i < selected_violations.length; ++i) { LengthViolation curr_violation = ((LengthViolation) selected_violations[i]); - selected_items.addAll(curr_violation.net.get_items()); + selected_items.addAll(curr_violation.net.get_items()); } net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; board_handling.select_items(selected_items); board_handling.zoom_selection(); } - - private final java.util.ResourceBundle resources; - - private class LengthViolation implements Comparable - { - LengthViolation(Net p_net, double p_violation_length) - { + + private class LengthViolation implements Comparable { + final Net net; + final double violation_length; + + LengthViolation(Net p_net, double p_violation_length) { net = p_net; violation_length = p_violation_length; } - - public int compareTo(LengthViolation p_other) - { + + public int compareTo(LengthViolation p_other) { return this.net.name.compareToIgnoreCase(p_other.net.name); } - - public String toString() - { + + public String toString() { net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; NetClass net_class = this.net.get_class(); Float allowed_length; String allowed_string; - if (violation_length > 0) - { + if (violation_length > 0) { allowed_length = (float) coordinate_transform.board_to_user(net_class.get_maximum_trace_length()); allowed_string = " " + resources.getString("maximum_allowed") + " "; - } - else - { + } else { allowed_length = (float) coordinate_transform.board_to_user(net_class.get_minimum_trace_length()); allowed_string = " " + resources.getString("minimum_allowed") + " "; } Float length = (float) coordinate_transform.board_to_user(this.net.get_trace_length()); - String result = resources.getString("net") + " " + this.net.name + resources.getString("trace_length") - + " " + length.toString() + allowed_string + allowed_length; + String result = resources.getString("net") + " " + this.net.name + resources.getString("trace_length") + + " " + length.toString() + allowed_string + allowed_length; return result; } - - final Net net; - final double violation_length; } } diff --git a/src/main/java/net/freerouting/gui/WindowManualRules.java b/src/main/java/net/freerouting/gui/WindowManualRules.java index e5d9fbed..ce56c554 100644 --- a/src/main/java/net/freerouting/gui/WindowManualRules.java +++ b/src/main/java/net/freerouting/gui/WindowManualRules.java @@ -22,14 +22,22 @@ /** * Used for manual choice of trace widths in interactive routing. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class WindowManualRules extends BoardSavableSubWindow -{ +public class WindowManualRules extends BoardSavableSubWindow { - /** Creates a new instance of TraceWidthWindow */ - public WindowManualRules(BoardFrame p_board_frame) - { + private static final int max_slider_value = 15000; + private static double scale_factor = 1; + private final net.freerouting.interactive.BoardHandling board_handling; + private final ComboBoxLayer layer_combo_box; + private final ComboBoxClearance clearance_combo_box; + private final javax.swing.JComboBox via_rule_combo_box; + private final javax.swing.JFormattedTextField trace_width_field; + private boolean key_input_completed = true; + /** + * Creates a new instance of TraceWidthWindow + */ + public WindowManualRules(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowManualRule", p_board_frame.get_locale()); @@ -114,34 +122,27 @@ public WindowManualRules(BoardFrame p_board_frame) /** * Recalculates the values in the trace width fields. */ - public void refresh() - { + public void refresh() { net.freerouting.board.RoutingBoard routing_board = board_handling.get_routing_board(); javax.swing.ComboBoxModel new_model = new javax.swing.DefaultComboBoxModel(routing_board.rules.via_rules); this.via_rule_combo_box.setModel(new_model); net.freerouting.rules.ClearanceMatrix clearance_matrix = board_handling.get_routing_board().rules.clearance_matrix; - if (this.clearance_combo_box.get_class_count() != routing_board.rules.clearance_matrix.get_class_count()) - { + if (this.clearance_combo_box.get_class_count() != routing_board.rules.clearance_matrix.get_class_count()) { this.clearance_combo_box.adjust(clearance_matrix); } this.clearance_combo_box.setSelectedIndex(board_handling.settings.get_manual_trace_clearance_class()); int via_rule_index = board_handling.settings.get_manual_via_rule_index(); - if (via_rule_index < this.via_rule_combo_box.getItemCount()) - { + if (via_rule_index < this.via_rule_combo_box.getItemCount()) { this.via_rule_combo_box.setSelectedIndex(board_handling.settings.get_manual_via_rule_index()); } this.set_selected_layer(this.layer_combo_box.get_selected_layer()); this.repaint(); } - public void set_trace_width_field(int p_half_width) - { - if (p_half_width < 0) - { + public void set_trace_width_field(int p_half_width) { + if (p_half_width < 0) { this.trace_width_field.setText(""); - } - else - { + } else { Float trace_width = (float) board_handling.coordinate_transform.board_to_user(2 * p_half_width); this.trace_width_field.setValue(trace_width); } @@ -150,144 +151,102 @@ public void set_trace_width_field(int p_half_width) /** * Sets the selected layer to p_layer. */ - private void set_selected_layer(ComboBoxLayer.Layer p_layer) - { + private void set_selected_layer(ComboBoxLayer.Layer p_layer) { int curr_half_width; - if (p_layer.index == ComboBoxLayer.ALL_LAYER_INDEX) - { + if (p_layer.index == ComboBoxLayer.ALL_LAYER_INDEX) { // check if the half width is layer_dependent. boolean trace_widths_layer_dependent = false; int first_half_width = this.board_handling.settings.get_manual_trace_half_width(0); - for (int i = 1; i < this.board_handling.get_layer_count(); ++i) - { - if (this.board_handling.settings.get_manual_trace_half_width(i) != first_half_width) - { + for (int i = 1; i < this.board_handling.get_layer_count(); ++i) { + if (this.board_handling.settings.get_manual_trace_half_width(i) != first_half_width) { trace_widths_layer_dependent = true; break; } } - if (trace_widths_layer_dependent) - { + if (trace_widths_layer_dependent) { curr_half_width = -1; - } - else - { + } else { curr_half_width = first_half_width; } - } - else if (p_layer.index == ComboBoxLayer.INNER_LAYER_INDEX) - { + } else if (p_layer.index == ComboBoxLayer.INNER_LAYER_INDEX) { // check if the half width is layer_dependent on the inner layers. boolean trace_widths_layer_dependent = false; int first_half_width = this.board_handling.settings.get_manual_trace_half_width(1); - for (int i = 2; i < this.board_handling.get_layer_count() - 1; ++i) - { - if (this.board_handling.settings.get_manual_trace_half_width(i) != first_half_width) - { + for (int i = 2; i < this.board_handling.get_layer_count() - 1; ++i) { + if (this.board_handling.settings.get_manual_trace_half_width(i) != first_half_width) { trace_widths_layer_dependent = true; break; } } - if (trace_widths_layer_dependent) - { + if (trace_widths_layer_dependent) { curr_half_width = -1; - } - else - { + } else { curr_half_width = first_half_width; } - } - else - { + } else { curr_half_width = this.board_handling.settings.get_manual_trace_half_width(p_layer.index); } set_trace_width_field(curr_half_width); } - private final net.freerouting.interactive.BoardHandling board_handling; - private final ComboBoxLayer layer_combo_box; - private final ComboBoxClearance clearance_combo_box; - private final javax.swing.JComboBox via_rule_combo_box; - private final javax.swing.JFormattedTextField trace_width_field; - private boolean key_input_completed = true; - private static final int max_slider_value = 15000; - private static double scale_factor = 1; - - private class LayerComboBoxListener implements java.awt.event.ActionListener - { + private class LayerComboBoxListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { ComboBoxLayer.Layer new_selected_layer = layer_combo_box.get_selected_layer(); set_selected_layer(new_selected_layer); } } - private class ClearanceComboBoxListener implements java.awt.event.ActionListener - { + private class ClearanceComboBoxListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { int new_index = clearance_combo_box.get_selected_class_index(); board_handling.settings.set_manual_trace_clearance_class(new_index); } } - private class ViaRuleComboBoxListener implements java.awt.event.ActionListener - { + private class ViaRuleComboBoxListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + public void actionPerformed(java.awt.event.ActionEvent evt) { int new_index = via_rule_combo_box.getSelectedIndex(); board_handling.settings.set_manual_via_rule_index(new_index); } } - private class TraceWidthFieldKeyListener extends java.awt.event.KeyAdapter - { + private class TraceWidthFieldKeyListener extends java.awt.event.KeyAdapter { - public void keyTyped(java.awt.event.KeyEvent p_evt) - { - if (p_evt.getKeyChar() == '\n') - { + public void keyTyped(java.awt.event.KeyEvent p_evt) { + if (p_evt.getKeyChar() == '\n') { key_input_completed = true; Object input = trace_width_field.getValue(); - if (!(input instanceof Number)) - { + if (!(input instanceof Number)) { return; } double input_value = ((Number) input).doubleValue(); - if (input_value <= 0) - { + if (input_value <= 0) { return; } double board_value = board_handling.coordinate_transform.user_to_board(input_value); int new_half_width = (int) Math.round(0.5 * board_value); board_handling.set_manual_trace_half_width(layer_combo_box.get_selected_layer().index, new_half_width); set_trace_width_field(new_half_width); - } - else - { + } else { key_input_completed = false; } } } - private class TraceWidthFieldFocusListener implements java.awt.event.FocusListener - { + private class TraceWidthFieldFocusListener implements java.awt.event.FocusListener { - public void focusLost(java.awt.event.FocusEvent p_evt) - { - if (!key_input_completed) - { + public void focusLost(java.awt.event.FocusEvent p_evt) { + if (!key_input_completed) { // restore the text field. set_selected_layer(layer_combo_box.get_selected_layer()); key_input_completed = true; } } - public void focusGained(java.awt.event.FocusEvent p_evt) - { + public void focusGained(java.awt.event.FocusEvent p_evt) { } } } diff --git a/src/main/java/net/freerouting/gui/WindowMessage.java b/src/main/java/net/freerouting/gui/WindowMessage.java index b4629171..014fc5d8 100644 --- a/src/main/java/net/freerouting/gui/WindowMessage.java +++ b/src/main/java/net/freerouting/gui/WindowMessage.java @@ -25,14 +25,35 @@ * * @author Alfons Wirtz */ -public class WindowMessage extends javax.swing.JFrame -{ +public class WindowMessage extends javax.swing.JFrame { + + /** + * Creates a new instance of WindowMessage + */ + private WindowMessage(String[] p_message_arr) { + final javax.swing.JPanel main_panel = new javax.swing.JPanel(); + final java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); + main_panel.setLayout(gridbag); + final java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); + gridbag_constraints.insets = new java.awt.Insets(40, 40, 40, 40); + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + for (int i = 0; i < p_message_arr.length; ++i) { + final javax.swing.JLabel message_label = new javax.swing.JLabel(); + message_label.setText(p_message_arr[i]); + + gridbag.setConstraints(message_label, gridbag_constraints); + main_panel.add(message_label, gridbag_constraints); + } + this.add(main_panel); + this.pack(); + this.setLocation(500, 400); + this.setVisible(true); + } /** * Displays a window with the input message at the center of the screen. */ - public static WindowMessage show(String p_message) - { + public static WindowMessage show(String p_message) { String[] message_arr = new String[1]; message_arr[0] = p_message; return new WindowMessage(message_arr); @@ -41,18 +62,15 @@ public static WindowMessage show(String p_message) /** * Displays a window with the input messages at the center of the screen. */ - public static WindowMessage show(String[] p_messages) - { + public static WindowMessage show(String[] p_messages) { return new WindowMessage(p_messages); } /** * Calls a confirm dialog. Returns true, if the user confirmed the action or if p_message is null. */ - public static boolean confirm(String p_message) - { - if (p_message == null) - { + public static boolean confirm(String p_message) { + if (p_message == null) { return true; } @@ -64,33 +82,7 @@ public static boolean confirm(String p_message) /** * Calls a dialog with an ok-button. */ - public static void ok(String p_message) - { + public static void ok(String p_message) { javax.swing.JOptionPane.showMessageDialog(null, p_message); } - - /** - * Creates a new instance of WindowMessage - */ - private WindowMessage(String[] p_message_arr) - { - final javax.swing.JPanel main_panel = new javax.swing.JPanel(); - final java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); - main_panel.setLayout(gridbag); - final java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); - gridbag_constraints.insets = new java.awt.Insets(40, 40, 40, 40); - gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; - for (int i = 0; i < p_message_arr.length; ++i) - { - final javax.swing.JLabel message_label = new javax.swing.JLabel(); - message_label.setText(p_message_arr[i]); - - gridbag.setConstraints(message_label, gridbag_constraints); - main_panel.add(message_label, gridbag_constraints); - } - this.add(main_panel); - this.pack(); - this.setLocation(500, 400); - this.setVisible(true); - } } diff --git a/src/main/java/net/freerouting/gui/WindowMoveParameter.java b/src/main/java/net/freerouting/gui/WindowMoveParameter.java index e082991c..8411dafb 100644 --- a/src/main/java/net/freerouting/gui/WindowMoveParameter.java +++ b/src/main/java/net/freerouting/gui/WindowMoveParameter.java @@ -26,19 +26,25 @@ * * @author Alfons Wirtz */ -public class WindowMoveParameter extends BoardSavableSubWindow -{ - - /** Creates a new instance of WindowMoveParameter */ - public WindowMoveParameter(BoardFrame p_board_frame) - { +public class WindowMoveParameter extends BoardSavableSubWindow { + + private final net.freerouting.interactive.BoardHandling board_handling; + private final javax.swing.JFormattedTextField horizontal_grid_field; + private final javax.swing.JFormattedTextField vertical_grid_field; + private final javax.swing.JRadioButton zoom_button; + private final javax.swing.JRadioButton rotate_button; + private boolean key_input_completed = true; + /** + * Creates a new instance of WindowMoveParameter + */ + public WindowMoveParameter(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowMoveParameter", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); - + // create main panel - + final javax.swing.JPanel main_panel = new javax.swing.JPanel(); this.add(main_panel); java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); @@ -46,14 +52,14 @@ public WindowMoveParameter(BoardFrame p_board_frame) java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); gridbag_constraints.anchor = java.awt.GridBagConstraints.WEST; gridbag_constraints.insets = new java.awt.Insets(1, 10, 1, 10); - + // Create label and number field for the horizontal and verical component grid - + gridbag_constraints.gridwidth = 2; javax.swing.JLabel horizontal_grid_label = new javax.swing.JLabel(resources.getString("horizontal_component_grid")); gridbag.setConstraints(horizontal_grid_label, gridbag_constraints); main_panel.add(horizontal_grid_label); - + java.text.NumberFormat number_format = java.text.NumberFormat.getInstance(p_board_frame.get_locale()); number_format.setMaximumFractionDigits(7); this.horizontal_grid_field = new javax.swing.JFormattedTextField(number_format); @@ -64,12 +70,12 @@ public WindowMoveParameter(BoardFrame p_board_frame) set_horizontal_grid_field(this.board_handling.settings.get_horizontal_component_grid()); horizontal_grid_field.addKeyListener(new HorizontalGridFieldKeyListener()); horizontal_grid_field.addFocusListener(new HorizontalGridFieldFocusListener()); - + gridbag_constraints.gridwidth = 2; javax.swing.JLabel vertical_grid_label = new javax.swing.JLabel(resources.getString("vertical_component_grid")); gridbag.setConstraints(vertical_grid_label, gridbag_constraints); main_panel.add(vertical_grid_label); - + this.vertical_grid_field = new javax.swing.JFormattedTextField(number_format); this.vertical_grid_field.setColumns(5); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; @@ -78,191 +84,148 @@ public WindowMoveParameter(BoardFrame p_board_frame) set_vertical_grid_field(this.board_handling.settings.get_vertical_component_grid()); vertical_grid_field.addKeyListener(new VerticalGridFieldKeyListener()); vertical_grid_field.addFocusListener(new VerticalGridFieldFocusListener()); - + javax.swing.JLabel separator = new javax.swing.JLabel(" ----------------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + // add label and button group for the wheel function. - + javax.swing.JLabel wheel_function_label = new javax.swing.JLabel(resources.getString("wheel_function")); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridbag_constraints.gridheight = 2; gridbag.setConstraints(wheel_function_label, gridbag_constraints); main_panel.add(wheel_function_label); wheel_function_label.setToolTipText(resources.getString("wheel_function_tooltip")); - + this.zoom_button = new javax.swing.JRadioButton(resources.getString("zoom")); this.rotate_button = new javax.swing.JRadioButton(resources.getString("rotate")); - + zoom_button.addActionListener(new ZoomButtonListener()); rotate_button.addActionListener(new RotateButtonListener()); - + javax.swing.ButtonGroup button_group = new javax.swing.ButtonGroup(); button_group.add(zoom_button); button_group.add(rotate_button); - if (this.board_handling.settings.get_zoom_with_wheel()) - { + if (this.board_handling.settings.get_zoom_with_wheel()) { zoom_button.setSelected(true); - } - else - { + } else { rotate_button.setSelected(true); } - + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag_constraints.gridheight = 1; gridbag.setConstraints(zoom_button, gridbag_constraints); main_panel.add(zoom_button, gridbag_constraints); gridbag.setConstraints(rotate_button, gridbag_constraints); main_panel.add(rotate_button, gridbag_constraints); - + p_board_frame.set_context_sensitive_help(this, "WindowMoveParameter"); - + this.refresh(); this.pack(); this.setResizable(false); } - - private void set_horizontal_grid_field(double p_value) - { - if (p_value <= 0) - { + + private void set_horizontal_grid_field(double p_value) { + if (p_value <= 0) { this.horizontal_grid_field.setValue(0); - } - else - { - Float grid_width =(float) board_handling.coordinate_transform.board_to_user(p_value); + } else { + Float grid_width = (float) board_handling.coordinate_transform.board_to_user(p_value); this.horizontal_grid_field.setValue(grid_width); } } - - private void set_vertical_grid_field(double p_value) - { - if (p_value <= 0) - { + + private void set_vertical_grid_field(double p_value) { + if (p_value <= 0) { this.vertical_grid_field.setValue(0); - } - else - { - Float grid_width =(float) board_handling.coordinate_transform.board_to_user(p_value); + } else { + Float grid_width = (float) board_handling.coordinate_transform.board_to_user(p_value); this.vertical_grid_field.setValue(grid_width); } } - - - private final net.freerouting.interactive.BoardHandling board_handling; - private final javax.swing.JFormattedTextField horizontal_grid_field; - private final javax.swing.JFormattedTextField vertical_grid_field; - private boolean key_input_completed = true; - private final javax.swing.JRadioButton zoom_button; - private final javax.swing.JRadioButton rotate_button; - - private class HorizontalGridFieldKeyListener extends java.awt.event.KeyAdapter - { - public void keyTyped(java.awt.event.KeyEvent p_evt) - { - if (p_evt.getKeyChar() == '\n') - { + + private class HorizontalGridFieldKeyListener extends java.awt.event.KeyAdapter { + public void keyTyped(java.awt.event.KeyEvent p_evt) { + if (p_evt.getKeyChar() == '\n') { key_input_completed = true; Object input = horizontal_grid_field.getValue(); double input_value; - if (!(input instanceof Number)) - { + if (!(input instanceof Number)) { input_value = 0; } - input_value = ((Number)input).doubleValue(); - if (input_value < 0) - { + input_value = ((Number) input).doubleValue(); + if (input_value < 0) { input_value = 0; } board_handling.settings.set_horizontal_component_grid ((int) Math.round(board_handling.coordinate_transform.user_to_board(input_value))); set_horizontal_grid_field(board_handling.settings.get_horizontal_component_grid()); - } - else - { + } else { key_input_completed = false; } } } - - - private class HorizontalGridFieldFocusListener implements java.awt.event.FocusListener - { - public void focusLost(java.awt.event.FocusEvent p_evt) - { - if (!key_input_completed) - { + + + private class HorizontalGridFieldFocusListener implements java.awt.event.FocusListener { + public void focusLost(java.awt.event.FocusEvent p_evt) { + if (!key_input_completed) { // restore the text field. set_horizontal_grid_field(board_handling.settings.get_horizontal_component_grid()); key_input_completed = true; } } - public void focusGained(java.awt.event.FocusEvent p_evt) - { + + public void focusGained(java.awt.event.FocusEvent p_evt) { } } - - private class VerticalGridFieldKeyListener extends java.awt.event.KeyAdapter - { - public void keyTyped(java.awt.event.KeyEvent p_evt) - { - if (p_evt.getKeyChar() == '\n') - { + + private class VerticalGridFieldKeyListener extends java.awt.event.KeyAdapter { + public void keyTyped(java.awt.event.KeyEvent p_evt) { + if (p_evt.getKeyChar() == '\n') { key_input_completed = true; Object input = vertical_grid_field.getValue(); double input_value; - if (!(input instanceof Number)) - { + if (!(input instanceof Number)) { input_value = 0; } - input_value = ((Number)input).doubleValue(); - if (input_value < 0) - { + input_value = ((Number) input).doubleValue(); + if (input_value < 0) { input_value = 0; } board_handling.settings.set_vertical_component_grid ((int) Math.round(board_handling.coordinate_transform.user_to_board(input_value))); set_vertical_grid_field(board_handling.settings.get_vertical_component_grid()); - } - else - { + } else { key_input_completed = false; } } } - - private class VerticalGridFieldFocusListener implements java.awt.event.FocusListener - { - public void focusLost(java.awt.event.FocusEvent p_evt) - { - if (!key_input_completed) - { + + private class VerticalGridFieldFocusListener implements java.awt.event.FocusListener { + public void focusLost(java.awt.event.FocusEvent p_evt) { + if (!key_input_completed) { // restore the text field. set_vertical_grid_field(board_handling.settings.get_vertical_component_grid()); key_input_completed = true; } } - public void focusGained(java.awt.event.FocusEvent p_evt) - { + + public void focusGained(java.awt.event.FocusEvent p_evt) { } } - - private class ZoomButtonListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class ZoomButtonListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.set_zoom_with_wheel(true); } } - - private class RotateButtonListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class RotateButtonListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.set_zoom_with_wheel(false); } } - + } diff --git a/src/main/java/net/freerouting/gui/WindowNetClasses.java b/src/main/java/net/freerouting/gui/WindowNetClasses.java index 103717f1..1f011036 100644 --- a/src/main/java/net/freerouting/gui/WindowNetClasses.java +++ b/src/main/java/net/freerouting/gui/WindowNetClasses.java @@ -19,23 +19,38 @@ */ package net.freerouting.gui; +import net.freerouting.board.ObjectInfoPanel.Printable; +import net.freerouting.rules.BoardRules; import net.freerouting.rules.NetClass; import net.freerouting.rules.ViaRule; -import net.freerouting.rules.BoardRules; - -import net.freerouting.board.ObjectInfoPanel.Printable; /** * Edit window for the table of net rules. * * @author Alfons Wirtz */ -public class WindowNetClasses extends BoardSavableSubWindow -{ +public class WindowNetClasses extends BoardSavableSubWindow { - /** Creates a new instance of NetClassesWindow */ - public WindowNetClasses(BoardFrame p_board_frame) - { + private static final int TEXTFIELD_HEIGHT = 16; + private static final int TEXTFIELD_WIDTH = 100; + private static final int WINDOW_OFFSET = 30; + private final BoardFrame board_frame; + private final javax.swing.JPanel main_panel; + private final ComboBoxLayer layer_combo_box; + private final java.util.ResourceBundle resources; + /** + * The subwindows created inside this window + */ + private final java.util.Collection subwindows = new java.util.LinkedList(); + private javax.swing.JPanel center_panel; + private NetClassTable table; + private NetClassTableModel table_model; + private javax.swing.JComboBox cl_class_combo_box; + private javax.swing.JComboBox via_rule_combo_box; + /** + * Creates a new instance of NetClassesWindow + */ + public WindowNetClasses(BoardFrame p_board_frame) { this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowNetClasses", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); @@ -92,8 +107,7 @@ public WindowNetClasses(BoardFrame p_board_frame) this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } - public void refresh() - { + public void refresh() { this.cl_class_combo_box.removeAllItems(); this.via_rule_combo_box.removeAllItems(); add_combobox_items(); @@ -108,11 +122,9 @@ public void refresh() // Dispose all subwindows because they may be no longer uptodate. java.util.Iterator it = this.subwindows.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { javax.swing.JFrame curr_subwindow = it.next(); - if (curr_subwindow != null) - { + if (curr_subwindow != null) { curr_subwindow.dispose(); } @@ -120,20 +132,16 @@ public void refresh() } } - public void dispose() - { - for (javax.swing.JFrame curr_subwindow : this.subwindows) - { - if (curr_subwindow != null) - { + public void dispose() { + for (javax.swing.JFrame curr_subwindow : this.subwindows) { + if (curr_subwindow != null) { curr_subwindow.dispose(); } } super.dispose(); } - private void add_table() - { + private void add_table() { this.table_model = new NetClassTableModel(); this.table = new NetClassTable(this.table_model); javax.swing.JScrollPane scroll_pane = new javax.swing.JScrollPane(this.table); @@ -146,8 +154,7 @@ private void add_table() this.center_panel.add(scroll_pane, java.awt.BorderLayout.CENTER); // add message for german localisation bug - if (board_frame.get_locale().getLanguage().equalsIgnoreCase("de")) - { + if (board_frame.get_locale().getLanguage().equalsIgnoreCase("de")) { javax.swing.JLabel bug_label = new javax.swing.JLabel("Wegen eines Java-System-Bugs muss das Dezimalkomma in dieser Tabelle zur Zeit als Punkt eingegeben werden!"); this.center_panel.add(bug_label, java.awt.BorderLayout.SOUTH); @@ -160,15 +167,12 @@ private void add_table() this.table.getColumnModel().getColumn(ColumnName.ON_LAYER.ordinal()).setCellEditor(new javax.swing.DefaultCellEditor(layer_combo_box)); } - private void add_combobox_items() - { + private void add_combobox_items() { net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); - for (int i = 0; i < routing_board.rules.clearance_matrix.get_class_count(); ++i) - { + for (int i = 0; i < routing_board.rules.clearance_matrix.get_class_count(); ++i) { cl_class_combo_box.addItem(routing_board.rules.clearance_matrix.get_name(i)); } - for (ViaRule curr_rule : routing_board.rules.via_rules) - { + for (ViaRule curr_rule : routing_board.rules.via_rules) { via_rule_combo_box.addItem(curr_rule.name); } } @@ -176,8 +180,7 @@ private void add_combobox_items() /** * Adjusts the displayed window with the net class table after the size of the table has been changed. */ - private void adjust_table() - { + private void adjust_table() { this.table_model = new NetClassTableModel(); this.table = new NetClassTable(this.table_model); this.main_panel.remove(this.center_panel); @@ -185,66 +188,47 @@ private void adjust_table() this.pack(); this.board_frame.refresh_windows(); } - private final BoardFrame board_frame; - private final javax.swing.JPanel main_panel; - private javax.swing.JPanel center_panel; - private NetClassTable table; - private NetClassTableModel table_model; - private javax.swing.JComboBox cl_class_combo_box; - private javax.swing.JComboBox via_rule_combo_box; - private final ComboBoxLayer layer_combo_box; - private final java.util.ResourceBundle resources; - /** The subwindows created inside this window */ - private final java.util.Collection subwindows = new java.util.LinkedList(); - private static final int TEXTFIELD_HEIGHT = 16; - private static final int TEXTFIELD_WIDTH = 100; - private static final int WINDOW_OFFSET = 30; - private class AddNetClassListener implements java.awt.event.ActionListener - { + private enum ColumnName { + + NAME, VIA_RULE, CLEARANCE_CLASS, TRACE_WIDTH, ON_LAYER, SHOVE_FIXED, CYCLES_WITH_AREAS, MIN_TRACE_LENGTH, MAX_TRACE_LENGTH + } - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + private class AddNetClassListener implements java.awt.event.ActionListener { + + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_frame.board_panel.board_handling.get_routing_board().rules.append_net_class(board_frame.get_locale()); adjust_table(); } } - private class RemoveNetClassListener implements java.awt.event.ActionListener - { + private class RemoveNetClassListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - if (table_model.getRowCount() <= 1) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + if (table_model.getRowCount() <= 1) { board_frame.screen_messages.set_status_message(resources.getString("message_1")); return; } int selected_row = table.getSelectedRow(); - if (selected_row < 0) - { + if (selected_row < 0) { return; } Object net_class_name = table_model.getValueAt(selected_row, ColumnName.NAME.ordinal()); - if (!(net_class_name instanceof String)) - { + if (!(net_class_name instanceof String)) { return; } BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; NetClass net_rule = board_rules.net_classes.get((String) net_class_name); // Check, if net_rule is used in a net of the net list - for (int i = 1; i < board_rules.nets.max_net_no(); ++i) - { + for (int i = 1; i < board_rules.nets.max_net_no(); ++i) { net.freerouting.rules.Net curr_net = board_rules.nets.get(i); - if (curr_net.get_class() == net_rule) - { + if (curr_net.get_class() == net_rule) { String message = resources.getString("message_2") + " " + curr_net.name; board_frame.screen_messages.set_status_message(message); return; } } - if (board_rules.net_classes.remove(net_rule)) - { + if (board_rules.net_classes.remove(net_rule)) { adjust_table(); String message = resources.getString("net_class") + " " + net_rule.get_name() + " " + resources.getString("removed"); @@ -253,59 +237,46 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) } } - private class AssignClassesListener implements java.awt.event.ActionListener - { + private class AssignClassesListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_frame.assign_net_classes_window.setVisible(true); } } - private class SelectClassesListener implements java.awt.event.ActionListener - { + private class SelectClassesListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { int[] selected_rows = table.getSelectedRows(); - if (selected_rows.length <= 0) - { + if (selected_rows.length <= 0) { return; } net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); NetClass[] selected_class_arr = new NetClass[selected_rows.length]; - for (int i = 0; i < selected_class_arr.length; ++i) - { + for (int i = 0; i < selected_class_arr.length; ++i) { selected_class_arr[i] = routing_board.rules.net_classes.get((String) table.getValueAt(selected_rows[i], ColumnName.NAME.ordinal())); } net.freerouting.rules.Nets nets = routing_board.rules.nets; java.util.Set selected_items = new java.util.TreeSet(); java.util.Collection board_items = routing_board.get_items(); - for (net.freerouting.board.Item curr_item : board_items) - { + for (net.freerouting.board.Item curr_item : board_items) { boolean item_matches = false; - for (int i = 0; i < curr_item.net_count(); ++i) - { + for (int i = 0; i < curr_item.net_count(); ++i) { net.freerouting.rules.NetClass curr_net_class = nets.get(curr_item.get_net_no(i)).get_class(); - if (curr_net_class == null) - { + if (curr_net_class == null) { continue; } - for (int j = 0; j < selected_class_arr.length; ++j) - { - if (curr_net_class == selected_class_arr[i]) - { + for (int j = 0; j < selected_class_arr.length; ++j) { + if (curr_net_class == selected_class_arr[i]) { item_matches = true; break; } } - if (item_matches) - { + if (item_matches) { break; } } - if (item_matches) - { + if (item_matches) { selected_items.add(curr_item); } } @@ -314,32 +285,25 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) } } - private class FilterIncompletesListener implements java.awt.event.ActionListener - { + private class FilterIncompletesListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { int[] selected_rows = table.getSelectedRows(); - if (selected_rows.length <= 0) - { + if (selected_rows.length <= 0) { return; } net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; net.freerouting.rules.BoardRules board_rules = board_handling.get_routing_board().rules; NetClass[] selected_class_arr = new NetClass[selected_rows.length]; - for (int i = 0; i < selected_class_arr.length; ++i) - { + for (int i = 0; i < selected_class_arr.length; ++i) { selected_class_arr[i] = board_rules.net_classes.get((String) table.getValueAt(selected_rows[i], ColumnName.NAME.ordinal())); } int max_net_no = board_rules.nets.max_net_no(); - for (int i = 1; i <= max_net_no; ++i) - { + for (int i = 1; i <= max_net_no; ++i) { board_handling.set_incompletes_filter(i, true); NetClass curr_net_class = board_rules.nets.get(i).get_class(); - for (int j = 0; j < selected_class_arr.length; ++j) - { - if (curr_net_class == selected_class_arr[j]) - { + for (int j = 0; j < selected_class_arr.length; ++j) { + if (curr_net_class == selected_class_arr[j]) { board_handling.set_incompletes_filter(i, false); break; } @@ -350,33 +314,26 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) } } - private class ContainedNetsListener implements java.awt.event.ActionListener - { + private class ContainedNetsListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { int[] selected_rows = table.getSelectedRows(); - if (selected_rows.length <= 0) - { + if (selected_rows.length <= 0) { return; } net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; net.freerouting.rules.BoardRules board_rules = board_handling.get_routing_board().rules; NetClass[] selected_class_arr = new NetClass[selected_rows.length]; - for (int i = 0; i < selected_class_arr.length; ++i) - { + for (int i = 0; i < selected_class_arr.length; ++i) { selected_class_arr[i] = board_rules.net_classes.get((String) table.getValueAt(selected_rows[i], ColumnName.NAME.ordinal())); } java.util.Collection contained_nets = new java.util.LinkedList(); int max_net_no = board_rules.nets.max_net_no(); - for (int i = 1; i <= max_net_no; ++i) - { + for (int i = 1; i <= max_net_no; ++i) { net.freerouting.rules.Net curr_net = board_rules.nets.get(i); NetClass curr_net_class = curr_net.get_class(); - for (int j = 0; j < selected_class_arr.length; ++j) - { - if (curr_net_class == selected_class_arr[j]) - { + for (int j = 0; j < selected_class_arr.length; ++j) { + if (curr_net_class == selected_class_arr[j]) { contained_nets.add(curr_net); break; } @@ -393,11 +350,11 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) } } - private class NetClassTable extends javax.swing.JTable - { + private class NetClassTable extends javax.swing.JTable { - public NetClassTable(NetClassTableModel p_table_model) - { + private final String[] column_tool_tips; + + public NetClassTable(NetClassTableModel p_table_model) { super(p_table_model); column_tool_tips = new String[9]; column_tool_tips[0] = null; @@ -410,14 +367,12 @@ public NetClassTable(NetClassTableModel p_table_model) column_tool_tips[7] = resources.getString("column_tool_tip_7"); column_tool_tips[8] = resources.getString("column_tool_tip_8"); } + //Implement table header tool tips. - protected javax.swing.table.JTableHeader createDefaultTableHeader() - { - return new javax.swing.table.JTableHeader(columnModel) - { + protected javax.swing.table.JTableHeader createDefaultTableHeader() { + return new javax.swing.table.JTableHeader(columnModel) { - public String getToolTipText(java.awt.event.MouseEvent e) - { + public String getToolTipText(java.awt.event.MouseEvent e) { java.awt.Point p = e.getPoint(); int index = columnModel.getColumnIndexAtX(p.x); int realIndex = columnModel.getColumn(index).getModelIndex(); @@ -425,56 +380,51 @@ public String getToolTipText(java.awt.event.MouseEvent e) } }; } - private final String[] column_tool_tips; } /** * Table model of the net rule table. */ - private class NetClassTableModel extends javax.swing.table.AbstractTableModel - { + private class NetClassTableModel extends javax.swing.table.AbstractTableModel { + + private Object[][] data = null; + private String[] column_names = null; - public NetClassTableModel() - { + public NetClassTableModel() { column_names = new String[ColumnName.values().length]; - for (int i = 0; i < column_names.length; ++i) - { + for (int i = 0; i < column_names.length; ++i) { column_names[i] = resources.getString(ColumnName.values()[i].toString()); } set_values(); } - /** Calculates the the valus in this table */ - public void set_values() - { + /** + * Calculates the the valus in this table + */ + public void set_values() { net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; this.data = new Object[board_rules.net_classes.count()][]; - for (int i = 0; i < data.length; ++i) - { + for (int i = 0; i < data.length; ++i) { this.data[i] = new Object[ColumnName.values().length]; } - for (int i = 0; i < data.length; ++i) - { + for (int i = 0; i < data.length; ++i) { NetClass curr_net_class = board_rules.net_classes.get(i); this.data[i][ColumnName.NAME.ordinal()] = curr_net_class.get_name(); - if (curr_net_class.get_via_rule() != null) - { + if (curr_net_class.get_via_rule() != null) { this.data[i][ColumnName.VIA_RULE.ordinal()] = curr_net_class.get_via_rule().name; } this.data[i][ColumnName.SHOVE_FIXED.ordinal()] = curr_net_class.is_shove_fixed() || !curr_net_class.get_pull_tight(); this.data[i][ColumnName.CYCLES_WITH_AREAS.ordinal()] = curr_net_class.get_ignore_cycles_with_areas(); double min_trace_length = board_frame.board_panel.board_handling.coordinate_transform.board_to_user(curr_net_class.get_minimum_trace_length()); - if (min_trace_length <= 0) - { + if (min_trace_length <= 0) { min_trace_length = 0; } this.data[i][ColumnName.MIN_TRACE_LENGTH.ordinal()] = (float) min_trace_length; double max_trace_length = board_frame.board_panel.board_handling.coordinate_transform.board_to_user(curr_net_class.get_maximum_trace_length()); - if (max_trace_length <= 0) - { + if (max_trace_length <= 0) { max_trace_length = -1; } this.data[i][ColumnName.MAX_TRACE_LENGTH.ordinal()] = (float) max_trace_length; @@ -486,200 +436,148 @@ public void set_values() } } - void set_trace_width_field(int p_rule_no, ComboBoxLayer.Layer p_layer) - { + void set_trace_width_field(int p_rule_no, ComboBoxLayer.Layer p_layer) { Float trace_width; net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; net.freerouting.rules.BoardRules board_rules = board_handling.get_routing_board().rules; NetClass curr_net_class = board_rules.net_classes.get(p_rule_no); - if (p_layer.index == ComboBoxLayer.ALL_LAYER_INDEX) - { + if (p_layer.index == ComboBoxLayer.ALL_LAYER_INDEX) { // all layers - if (curr_net_class.trace_width_is_layer_dependent()) - { + if (curr_net_class.trace_width_is_layer_dependent()) { trace_width = (float) -1; - } - else - { + } else { trace_width = (float) board_handling.coordinate_transform.board_to_user(2 * curr_net_class.get_trace_half_width(0)); } - } - else if (p_layer.index == ComboBoxLayer.INNER_LAYER_INDEX) - { + } else if (p_layer.index == ComboBoxLayer.INNER_LAYER_INDEX) { // all inner layers - if (curr_net_class.trace_width_is_inner_layer_dependent()) - { + if (curr_net_class.trace_width_is_inner_layer_dependent()) { trace_width = (float) -1; - } - else - { + } else { int first_inner_signal_layer_no = 1; net.freerouting.board.LayerStructure layer_structure = board_handling.get_routing_board().layer_structure; - while (!layer_structure.arr[first_inner_signal_layer_no].is_signal) - { + while (!layer_structure.arr[first_inner_signal_layer_no].is_signal) { ++first_inner_signal_layer_no; } - if (first_inner_signal_layer_no < layer_structure.arr.length - 1) - { + if (first_inner_signal_layer_no < layer_structure.arr.length - 1) { trace_width = (float) board_handling.coordinate_transform.board_to_user(2 * curr_net_class.get_trace_half_width(first_inner_signal_layer_no)); - } - else - { + } else { trace_width = (float) 0; } } - } - else - { + } else { trace_width = (float) board_handling.coordinate_transform.board_to_user(2 * curr_net_class.get_trace_half_width(p_layer.index)); } this.data[p_rule_no][ColumnName.TRACE_WIDTH.ordinal()] = trace_width; fireTableCellUpdated(p_rule_no, ColumnName.TRACE_WIDTH.ordinal()); } - public String getColumnName(int p_col) - { + public String getColumnName(int p_col) { return column_names[p_col]; } - public int getRowCount() - { + public int getRowCount() { return data.length; } - public int getColumnCount() - { + public int getColumnCount() { return column_names.length; } - public Object getValueAt(int p_row, int p_col) - { + public Object getValueAt(int p_row, int p_col) { return data[p_row][p_col]; } - public void setValueAt(Object p_value, int p_row, int p_col) - { + public void setValueAt(Object p_value, int p_row, int p_col) { net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); BoardRules board_rules = routing_board.rules; Object net_class_name = getValueAt(p_row, ColumnName.NAME.ordinal()); - if (!(net_class_name instanceof String)) - { + if (!(net_class_name instanceof String)) { System.out.println("EditNetRuLesVindow.setValueAt: String expected"); return; } NetClass net_rule = board_rules.net_classes.get((String) net_class_name); - if (net_rule == null) - { + if (net_rule == null) { System.out.println("EditNetRuLesVindow.setValueAt: net_rule not found"); return; } - if (p_col == ColumnName.NAME.ordinal()) - { - if (!(p_value instanceof String)) - { + if (p_col == ColumnName.NAME.ordinal()) { + if (!(p_value instanceof String)) { return; } String new_name = (String) p_value; - if (board_rules.net_classes.get(new_name) != null) - { + if (board_rules.net_classes.get(new_name) != null) { return; // name exists already } net_rule.set_name(new_name); board_frame.via_window.refresh(); - } - else if (p_col == ColumnName.VIA_RULE.ordinal()) - { - if (!(p_value instanceof String)) - { + } else if (p_col == ColumnName.VIA_RULE.ordinal()) { + if (!(p_value instanceof String)) { return; } String new_name = (String) p_value; ViaRule new_via_rule = board_rules.get_via_rule(new_name); - if (new_via_rule == null) - { + if (new_via_rule == null) { System.out.println("EditNetRuLesVindow.setValueAt: via_rule not found"); return; } net_rule.set_via_rule(new_via_rule); - } - else if (p_col == ColumnName.SHOVE_FIXED.ordinal()) - { - if (!(p_value instanceof Boolean)) - { + } else if (p_col == ColumnName.SHOVE_FIXED.ordinal()) { + if (!(p_value instanceof Boolean)) { return; } boolean value = (Boolean) p_value; net_rule.set_shove_fixed(value); net_rule.set_pull_tight(!value); - } - else if (p_col == ColumnName.CYCLES_WITH_AREAS.ordinal()) - { - if (!(p_value instanceof Boolean)) - { + } else if (p_col == ColumnName.CYCLES_WITH_AREAS.ordinal()) { + if (!(p_value instanceof Boolean)) { return; } boolean value = (Boolean) p_value; net_rule.set_ignore_cycles_with_areas(value); - } - else if (p_col == ColumnName.MIN_TRACE_LENGTH.ordinal()) - { + } else if (p_col == ColumnName.MIN_TRACE_LENGTH.ordinal()) { Float curr_value = 0f; - if (p_value instanceof Float) - { + if (p_value instanceof Float) { curr_value = (Float) p_value; - } - else if (p_value instanceof String) - { + } else if (p_value instanceof String) { // Workaround because of a localisation Bug in Java // The numbers are always displayed in the English Format. - try - { + try { curr_value = Float.parseFloat((String) p_value); - } catch (Exception e) - { + } catch (Exception e) { curr_value = 0f; } p_value = curr_value.toString(); } - if (curr_value <= 0) - { + if (curr_value <= 0) { curr_value = (float) 0; p_value = curr_value; } double min_trace_length = Math.round(board_frame.board_panel.board_handling.coordinate_transform.user_to_board(curr_value)); net_rule.set_minimum_trace_length(min_trace_length); board_frame.board_panel.board_handling.recalculate_length_violations(); - } - else if (p_col == ColumnName.MAX_TRACE_LENGTH.ordinal()) - { + } else if (p_col == ColumnName.MAX_TRACE_LENGTH.ordinal()) { Float curr_value = 0f; - if (p_value instanceof Float) - { + if (p_value instanceof Float) { curr_value = (Float) p_value; - } - else if (p_value instanceof String) - { + } else if (p_value instanceof String) { // Workaround because of a localisation Bug in Java // The numbers are always displayed in the English Format. - try - { + try { curr_value = Float.parseFloat((String) p_value); - } catch (Exception e) - { + } catch (Exception e) { curr_value = 0f; } p_value = curr_value.toString(); } - if (curr_value <= 0) - { + if (curr_value <= 0) { curr_value = (float) 0; p_value = curr_value - 1; } @@ -687,92 +585,67 @@ else if (p_value instanceof String) double max_trace_length = Math.round(board_frame.board_panel.board_handling.coordinate_transform.user_to_board(curr_value)); net_rule.set_maximum_trace_length(max_trace_length); board_frame.board_panel.board_handling.recalculate_length_violations(); - } - else if (p_col == ColumnName.CLEARANCE_CLASS.ordinal()) - { - if (!(p_value instanceof String)) - { + } else if (p_col == ColumnName.CLEARANCE_CLASS.ordinal()) { + if (!(p_value instanceof String)) { return; } String new_name = (String) p_value; int new_cl_class_index = board_rules.clearance_matrix.get_no(new_name); { - if (new_cl_class_index < 0) - { + if (new_cl_class_index < 0) { System.out.println("EditNetRuLesVindow.setValueAt: clearance class not found"); return; } } net_rule.set_trace_clearance_class(new_cl_class_index); - } - else if (p_col == ColumnName.TRACE_WIDTH.ordinal()) - { + } else if (p_col == ColumnName.TRACE_WIDTH.ordinal()) { Float curr_value = 0f; - if (p_value instanceof Float) - { + if (p_value instanceof Float) { curr_value = (Float) p_value; - } - else if (p_value instanceof String) - { + } else if (p_value instanceof String) { // Workaround because of a localisation Bug in Java // The numbers are always displayed in the English Format. - try - { + try { curr_value = Float.parseFloat((String) p_value); - } catch (Exception e) - { + } catch (Exception e) { curr_value = 0f; } } - if (curr_value < 0) - { + if (curr_value < 0) { return; } int curr_half_width; boolean is_active; - if (curr_value == 0) - { + if (curr_value == 0) { curr_half_width = 0; is_active = false; - } - else - { + } else { curr_half_width = (int) Math.round(board_frame.board_panel.board_handling.coordinate_transform.user_to_board(0.5 * curr_value)); - if (curr_half_width <= 0) - { + if (curr_half_width <= 0) { return; } is_active = true; } - if (p_value instanceof String) - { + if (p_value instanceof String) { p_value = curr_value.toString(); } int layer_index = layer_combo_box.get_selected_layer().index; NetClass curr_net_class = board_rules.net_classes.get(p_row); - if (layer_index == ComboBoxLayer.ALL_LAYER_INDEX) - { + if (layer_index == ComboBoxLayer.ALL_LAYER_INDEX) { curr_net_class.set_trace_half_width(curr_half_width); curr_net_class.set_all_layers_active(is_active); - } - else if (layer_index == ComboBoxLayer.INNER_LAYER_INDEX) - { + } else if (layer_index == ComboBoxLayer.INNER_LAYER_INDEX) { curr_net_class.set_trace_half_width_on_inner(curr_half_width); curr_net_class.set_all_inner_layers_active(is_active); - } - else - { + } else { curr_net_class.set_trace_half_width(layer_index, curr_half_width); curr_net_class.set_active_routing_layer(layer_index, is_active); } - } - else if (p_col == ColumnName.ON_LAYER.ordinal()) - { - if (!(p_value instanceof ComboBoxLayer.Layer)) - { + } else if (p_col == ColumnName.ON_LAYER.ordinal()) { + if (!(p_value instanceof ComboBoxLayer.Layer)) { return; } set_trace_width_field(p_row, (ComboBoxLayer.Layer) p_value); @@ -781,30 +654,19 @@ else if (p_col == ColumnName.ON_LAYER.ordinal()) fireTableCellUpdated(p_row, p_col); } - public boolean isCellEditable(int p_row, int p_col) - { + public boolean isCellEditable(int p_row, int p_col) { // the name of the default class is not editable return p_row > 0 || p_col > 0; } - public Class getColumnClass(int p_col) - { + public Class getColumnClass(int p_col) { Object curr_entry = getValueAt(0, p_col); Class curr_class = curr_entry.getClass(); // changed because of a localisation bug in Java - if (curr_entry instanceof Float) - { + if (curr_entry instanceof Float) { curr_class = String.class; } return curr_class; } - private Object[][] data = null; - private String[] column_names = null; - } - - private enum ColumnName - { - - NAME, VIA_RULE, CLEARANCE_CLASS, TRACE_WIDTH, ON_LAYER, SHOVE_FIXED, CYCLES_WITH_AREAS, MIN_TRACE_LENGTH, MAX_TRACE_LENGTH } } diff --git a/src/main/java/net/freerouting/gui/WindowNets.java b/src/main/java/net/freerouting/gui/WindowNets.java index 2d73eed6..16ef0b2e 100644 --- a/src/main/java/net/freerouting/gui/WindowNets.java +++ b/src/main/java/net/freerouting/gui/WindowNets.java @@ -24,141 +24,117 @@ import net.freerouting.rules.Nets; - - /** - * * @author Alfons Wirtz */ -public class WindowNets extends WindowObjectListWithFilter -{ - - /** Creates a new instance of NetsWindow */ - public WindowNets(BoardFrame p_board_frame) - { +public class WindowNets extends WindowObjectListWithFilter { + + private final java.util.ResourceBundle resources; + + /** + * Creates a new instance of NetsWindow + */ + public WindowNets(BoardFrame p_board_frame) { super(p_board_frame); this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowNets", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); - - javax.swing.JPanel curr_button_panel = new javax.swing.JPanel(); + + javax.swing.JPanel curr_button_panel = new javax.swing.JPanel(); this.south_panel.add(curr_button_panel, java.awt.BorderLayout.NORTH); - - final javax.swing.JButton assign_class_button = new javax.swing.JButton(resources.getString("assign_class")); + + final javax.swing.JButton assign_class_button = new javax.swing.JButton(resources.getString("assign_class")); curr_button_panel.add(assign_class_button); assign_class_button.setToolTipText(resources.getString("assign_class_tooltip")); assign_class_button.addActionListener(new AssignClassListener()); - - final javax.swing.JButton filter_incompletes_button = new javax.swing.JButton(resources.getString("filter_incompletes")); + + final javax.swing.JButton filter_incompletes_button = new javax.swing.JButton(resources.getString("filter_incompletes")); curr_button_panel.add(filter_incompletes_button); filter_incompletes_button.setToolTipText(resources.getString("filter_incompletes_tooltip")); filter_incompletes_button.addActionListener(new FilterIncompletesListener()); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_Nets"); } - + /** * Fills the list with the nets in the net list. */ - protected void fill_list() - { + protected void fill_list() { Nets nets = this.board_frame.board_panel.board_handling.get_routing_board().rules.nets; Net[] sorted_arr = new Net[nets.max_net_no()]; - for (int i = 0; i < sorted_arr.length; ++i) - { + for (int i = 0; i < sorted_arr.length; ++i) { sorted_arr[i] = nets.get(i + 1); } java.util.Arrays.sort(sorted_arr); - for (int i = 0; i < sorted_arr.length; ++i) - { + for (int i = 0; i < sorted_arr.length; ++i) { this.add_to_list(sorted_arr[i]); } this.list.setVisibleRowCount(Math.min(sorted_arr.length, DEFAULT_TABLE_SIZE)); } - - protected void select_instances() - { + + protected void select_instances() { Object[] selected_nets = list.getSelectedValues(); - if (selected_nets.length <= 0) - { + if (selected_nets.length <= 0) { return; } - int [] selected_net_numbers = new int[selected_nets.length]; - for (int i = 0; i < selected_nets.length; ++i) - { + int[] selected_net_numbers = new int[selected_nets.length]; + for (int i = 0; i < selected_nets.length; ++i) { selected_net_numbers[i] = ((Net) selected_nets[i]).net_number; } net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); java.util.Set selected_items = new java.util.TreeSet(); java.util.Collection board_items = routing_board.get_items(); - for (net.freerouting.board.Item curr_item : board_items) - { + for (net.freerouting.board.Item curr_item : board_items) { boolean item_matches = false; - for (int curr_net_no : selected_net_numbers) - { - if (curr_item.contains_net(curr_net_no)) - { + for (int curr_net_no : selected_net_numbers) { + if (curr_item.contains_net(curr_net_no)) { item_matches = true; break; } } - if (item_matches) - { + if (item_matches) { selected_items.add(curr_item); } } board_frame.board_panel.board_handling.select_items(selected_items); board_frame.board_panel.board_handling.zoom_selection(); } - - private final java.util.ResourceBundle resources; - - private class AssignClassListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class AssignClassListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { Object[] selected_nets = list.getSelectedValues(); - if (selected_nets.length <= 0) - { + if (selected_nets.length <= 0) { return; } net.freerouting.rules.NetClasses net_classes = board_frame.board_panel.board_handling.get_routing_board().rules.net_classes; - net.freerouting.rules.NetClass [] class_arr = new net.freerouting.rules.NetClass [net_classes.count()]; - for(int i = 0; i < class_arr.length; ++i) - { + net.freerouting.rules.NetClass[] class_arr = new net.freerouting.rules.NetClass[net_classes.count()]; + for (int i = 0; i < class_arr.length; ++i) { class_arr[i] = net_classes.get(i); } - Object selected_value = javax.swing.JOptionPane.showInputDialog(null, resources.getString("message_1"), - resources.getString("message_2"), javax.swing.JOptionPane.INFORMATION_MESSAGE, + Object selected_value = javax.swing.JOptionPane.showInputDialog(null, resources.getString("message_1"), + resources.getString("message_2"), javax.swing.JOptionPane.INFORMATION_MESSAGE, null, class_arr, class_arr[0]); - if (!(selected_value instanceof net.freerouting.rules.NetClass)) - { + if (!(selected_value instanceof net.freerouting.rules.NetClass)) { return; } net.freerouting.rules.NetClass selected_class = (net.freerouting.rules.NetClass) selected_value; - for (int i = 0; i < selected_nets.length; ++i) - { + for (int i = 0; i < selected_nets.length; ++i) { ((Net) selected_nets[i]).set_class(selected_class); } board_frame.refresh_windows(); } } - - private class FilterIncompletesListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class FilterIncompletesListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { Object[] selected_nets = list.getSelectedValues(); - if (selected_nets.length <= 0) - { + if (selected_nets.length <= 0) { return; } net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; int max_net_no = board_handling.get_routing_board().rules.nets.max_net_no(); - for (int i = 1; i <= max_net_no; ++i) - { + for (int i = 1; i <= max_net_no; ++i) { board_handling.set_incompletes_filter(i, true); } - for (int i = 0; i < selected_nets.length; ++i) - { + for (int i = 0; i < selected_nets.length; ++i) { board_handling.set_incompletes_filter(((Net) selected_nets[i]).net_number, false); } board_frame.board_panel.repaint(); diff --git a/src/main/java/net/freerouting/gui/WindowObjectInfo.java b/src/main/java/net/freerouting/gui/WindowObjectInfo.java index 322da537..f8717959 100644 --- a/src/main/java/net/freerouting/gui/WindowObjectInfo.java +++ b/src/main/java/net/freerouting/gui/WindowObjectInfo.java @@ -28,305 +28,272 @@ * * @author Alfons Wirtz */ -public class WindowObjectInfo extends BoardTemporarySubWindow implements net.freerouting.board.ObjectInfoPanel -{ +public class WindowObjectInfo extends BoardTemporarySubWindow implements net.freerouting.board.ObjectInfoPanel { + private static final int MAX_WINDOW_HEIGHT = 500; + private static final int SCROLLBAR_ADD = 30; + private final javax.swing.JTextPane text_pane; + private final net.freerouting.board.CoordinateTransform coordinate_transform; + private final java.util.ResourceBundle resources; + private final java.text.NumberFormat number_format; + /** + * The new created windows by pushing buttons inside this window. + * Used when closing this window to close also all subwindows. + */ + private Collection subwindows = new java.util.LinkedList(); + + /** + * Creates a new instance of ItemInfoWindow + */ + private WindowObjectInfo(BoardFrame p_board_frame, net.freerouting.board.CoordinateTransform p_coordinate_transform) { + super(p_board_frame); + this.resources = + java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowObjectInfo", p_board_frame.get_locale()); + this.coordinate_transform = p_coordinate_transform; + + // create the text pane + this.text_pane = new javax.swing.JTextPane(); + this.text_pane.setEditable(false); + this.number_format = java.text.NumberFormat.getInstance(p_board_frame.get_locale()); + this.number_format.setMaximumFractionDigits(4); + + + // set document and text styles + javax.swing.text.StyledDocument document = this.text_pane.getStyledDocument(); + + + javax.swing.text.Style default_style = + javax.swing.text.StyleContext.getDefaultStyleContext().getStyle(javax.swing.text.StyleContext.DEFAULT_STYLE); + + + // add bold style to the document + javax.swing.text.Style bold_style = document.addStyle("bold", default_style); + javax.swing.text.StyleConstants.setBold(bold_style, true); + + // Create a scoll_pane arount the text_pane and insert it into this window. + javax.swing.JScrollPane scroll_pane = new javax.swing.JScrollPane(this.text_pane); + this.add(scroll_pane); + + /** Dispose this window and all subwindows when closing the window. */ + this.addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + dispose(); + } + }); + } + /** * Displays a new ObjectInfoWindow with information about the items in p_item_list. * p_coordinate_transform is for transforming board to user coordinates, * and p_location is the location of the window. */ public static void display(Collection p_item_list, - BoardFrame p_board_frame, net.freerouting.board.CoordinateTransform p_coordinate_transform, java.awt.Point p_location) - { + BoardFrame p_board_frame, net.freerouting.board.CoordinateTransform p_coordinate_transform, java.awt.Point p_location) { WindowObjectInfo new_instance = new WindowObjectInfo(p_board_frame, p_coordinate_transform); new_instance.setTitle(new_instance.resources.getString("title")); Integer pin_count = 0; Integer via_count = 0; Integer trace_count = 0; double cumulative_trace_length = 0; - for (WindowObjectInfo.Printable curr_object : p_item_list) - { + for (WindowObjectInfo.Printable curr_object : p_item_list) { curr_object.print_info(new_instance, p_board_frame.get_locale()); - if (curr_object instanceof net.freerouting.board.Pin) - { + if (curr_object instanceof net.freerouting.board.Pin) { ++pin_count; - } - else if (curr_object instanceof net.freerouting.board.Via) - { + } else if (curr_object instanceof net.freerouting.board.Via) { ++via_count; - } - else if (curr_object instanceof net.freerouting.board.Trace) - { + } else if (curr_object instanceof net.freerouting.board.Trace) { ++trace_count; cumulative_trace_length += ((net.freerouting.board.Trace) curr_object).get_length(); } } new_instance.append_bold(new_instance.resources.getString("summary") + " "); - java.text.NumberFormat number_format = java.text.NumberFormat.getInstance(p_board_frame.get_locale()); - if (pin_count > 0) - { + java.text.NumberFormat number_format = java.text.NumberFormat.getInstance(p_board_frame.get_locale()); + if (pin_count > 0) { new_instance.append(number_format.format(pin_count)); - if (pin_count == 1) - { + if (pin_count == 1) { new_instance.append(" " + new_instance.resources.getString("pin")); - } - else - { + } else { new_instance.append(" " + new_instance.resources.getString("pins")); } - if (via_count + trace_count > 0) - { + if (via_count + trace_count > 0) { new_instance.append(", "); } } - if (via_count > 0) - { + if (via_count > 0) { new_instance.append(number_format.format(via_count)); - if (via_count == 1) - { + if (via_count == 1) { new_instance.append(" " + new_instance.resources.getString("via")); - } - else - { + } else { new_instance.append(" " + new_instance.resources.getString("vias")); } - if (trace_count > 0) - { + if (trace_count > 0) { new_instance.append(", "); } } - if (trace_count > 0) - { + if (trace_count > 0) { new_instance.append(number_format.format(trace_count)); - if (trace_count == 1) - { + if (trace_count == 1) { new_instance.append(" " + new_instance.resources.getString("trace") + " "); - } - else - { + } else { new_instance.append(" " + new_instance.resources.getString("traces") + " "); } new_instance.append(cumulative_trace_length); } - - + + new_instance.pack(); java.awt.Dimension size = new_instance.getSize(); // make the window smaller, if its heicht gets bigger than MAX_WINDOW_HEIGHT - if (size.getHeight() > MAX_WINDOW_HEIGHT) - { - new_instance.setPreferredSize(new java.awt.Dimension((int)size.getWidth() + SCROLLBAR_ADD, MAX_WINDOW_HEIGHT)); + if (size.getHeight() > MAX_WINDOW_HEIGHT) { + new_instance.setPreferredSize(new java.awt.Dimension((int) size.getWidth() + SCROLLBAR_ADD, MAX_WINDOW_HEIGHT)); new_instance.pack(); } new_instance.setLocation(p_location); new_instance.setVisible(true); } - + /** * Displays a new ObjectInfoWindow with information about the objects in p_object_list. * p_coordinate_transform is for transforming board to user coordinates, * and p_location is the location of the window. */ public static WindowObjectInfo display(String p_title, Collection p_object_list, - BoardFrame p_board_frame, net.freerouting.board.CoordinateTransform p_coordinate_transform) - { + BoardFrame p_board_frame, net.freerouting.board.CoordinateTransform p_coordinate_transform) { WindowObjectInfo new_window = new WindowObjectInfo(p_board_frame, p_coordinate_transform); new_window.setTitle(p_title); - if (p_object_list.isEmpty()) - { + if (p_object_list.isEmpty()) { new_window.append(new_window.resources.getString("list_empty")); } - for (Printable curr_object : p_object_list) - { + for (Printable curr_object : p_object_list) { curr_object.print_info(new_window, p_board_frame.get_locale()); } new_window.pack(); java.awt.Dimension size = new_window.getSize(); // make the window smaller, if its heicht gets bigger than MAX_WINDOW_HEIGHT - if (size.getHeight() > MAX_WINDOW_HEIGHT) - { - new_window.setPreferredSize(new java.awt.Dimension((int)size.getWidth() + SCROLLBAR_ADD, MAX_WINDOW_HEIGHT)); + if (size.getHeight() > MAX_WINDOW_HEIGHT) { + new_window.setPreferredSize(new java.awt.Dimension((int) size.getWidth() + SCROLLBAR_ADD, MAX_WINDOW_HEIGHT)); new_window.pack(); } new_window.setVisible(true); return new_window; } - - /** Creates a new instance of ItemInfoWindow */ - private WindowObjectInfo(BoardFrame p_board_frame, net.freerouting.board.CoordinateTransform p_coordinate_transform) - { - super(p_board_frame); - this.resources = - java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowObjectInfo", p_board_frame.get_locale()); - this.coordinate_transform = p_coordinate_transform; - - // create the text pane - this.text_pane = new javax.swing.JTextPane(); - this.text_pane.setEditable(false); - this.number_format = java.text.NumberFormat.getInstance(p_board_frame.get_locale()); - this.number_format.setMaximumFractionDigits(4); - - - // set document and text styles - javax.swing.text.StyledDocument document = this.text_pane.getStyledDocument(); - - - javax.swing.text.Style default_style = - javax.swing.text.StyleContext.getDefaultStyleContext().getStyle(javax.swing.text.StyleContext.DEFAULT_STYLE); - - - // add bold style to the document - javax.swing.text.Style bold_style = document.addStyle("bold", default_style); - javax.swing.text.StyleConstants.setBold(bold_style, true); - - // Create a scoll_pane arount the text_pane and insert it into this window. - javax.swing.JScrollPane scroll_pane = new javax.swing.JScrollPane(this.text_pane); - this.add(scroll_pane); - - /** Dispose this window and all subwindows when closing the window. */ - this.addWindowListener(new java.awt.event.WindowAdapter() - { - public void windowClosing(java.awt.event.WindowEvent evt) - { - dispose(); - } - }); - } - - + /** * Appends p_string to the text pane. * Returns false, if that was not possible. */ - private boolean append(String p_string, String p_style) - { - + private boolean append(String p_string, String p_style) { + javax.swing.text.StyledDocument document = text_pane.getStyledDocument(); - try - { + try { document.insertString(document.getLength(), p_string, document.getStyle(p_style)); - } - catch (javax.swing.text.BadLocationException e) - { + } catch (javax.swing.text.BadLocationException e) { System.out.println("ObjectInfoWindow.append: unable to insert text into text pane."); return false; } return true; } - + /** * Appends p_string to the text pane. * Returns false, if that was not possible. */ - public boolean append(String p_string) - { + public boolean append(String p_string) { return append(p_string, "normal"); } - + /** * Appends p_string in bold styleto the text pane. * Returns false, if that was not possible. */ - public boolean append_bold(String p_string) - { + public boolean append_bold(String p_string) { return append(p_string, "bold"); } - + /** * Appends p_value to the text pane after * transforming it to the user coordinate sytem. * Returns false, if that was not possible. */ - public boolean append(double p_value) - { + public boolean append(double p_value) { Float value = (float) this.coordinate_transform.board_to_user(p_value); return append(number_format.format(value)); } - + /** * Appends p_value to the text pane without * transforming it to the user coordinate sytem. * Returns false, if that was not possible. */ - public boolean append_without_transforming(double p_value) - { + public boolean append_without_transforming(double p_value) { Float value = (float) p_value; return append(number_format.format(value)); } - + /** * Appends p_point to the text pane * after transforming to the user coordinate sytem. * Returns false, if that was not possible. */ - public boolean append(net.freerouting.geometry.planar.FloatPoint p_point) - { + public boolean append(net.freerouting.geometry.planar.FloatPoint p_point) { net.freerouting.geometry.planar.FloatPoint transformed_point = this.coordinate_transform.board_to_user(p_point); return append(transformed_point.to_string(board_frame.get_locale())); } - + /** * Appends p_shape to the text pane * after transforming to the user coordinate sytem. * Returns false, if that was not possible. */ - public boolean append(net.freerouting.geometry.planar.Shape p_shape, java.util.Locale p_locale) - { + public boolean append(net.freerouting.geometry.planar.Shape p_shape, java.util.Locale p_locale) { net.freerouting.board.PrintableShape transformed_shape = this.coordinate_transform.board_to_user(p_shape, p_locale); - if (transformed_shape == null) - { + if (transformed_shape == null) { return false; } return append(transformed_shape.toString()); } - + /** * Begins a new line in the text pane. */ - public boolean newline() - { + public boolean newline() { return append("\n"); } - + /** * Appends a fixed number of spaces to the text pane. */ - public boolean indent() - { + public boolean indent() { return append(" "); } - + /** * Appends a button for creating a new ObjectInfoWindow with the information * of p_object to the text pane. Returns false, if that was not possible. */ - public boolean append( String p_button_name, String p_window_title, WindowObjectInfo.Printable p_object) - { + public boolean append(String p_button_name, String p_window_title, WindowObjectInfo.Printable p_object) { java.util.Collection object_list = new java.util.LinkedList(); object_list.add(p_object); return append_objects(p_button_name, p_window_title, object_list); } - + /** * Appends a button for creating a new ObjectInfoWindow with the information * of p_items to the text pane. Returns false, if that was not possible. */ - public boolean append_items( String p_button_name, String p_window_title, java.util.Collection p_items) - { + public boolean append_items(String p_button_name, String p_window_title, java.util.Collection p_items) { java.util.Collection object_list = new java.util.LinkedList(); object_list.addAll(p_items); return append_objects(p_button_name, p_window_title, object_list); } - + /** * Appends a button for creating a new ObjectInfoWindow with the information * of p_objects to the text pane. Returns false, if that was not possible. */ - public boolean append_objects( String p_button_name, String p_window_title, - java.util.Collection p_objects) - { + public boolean append_objects(String p_button_name, String p_window_title, + java.util.Collection p_objects) { // create a button without border and color. - javax.swing.JButton button = new javax.swing. JButton(); + javax.swing.JButton button = new javax.swing.JButton(); button.setText(p_button_name); button.setBorderPainted(false); button.setContentAreaFilled(false); @@ -334,9 +301,9 @@ public boolean append_objects( String p_button_name, String p_window_title, button.setAlignmentY(0.75f); // Display the button name in blue. button.setForeground(java.awt.Color.blue); - + button.addActionListener(new InfoButtonListener(p_window_title, p_objects)); - + // Add style for inserting the button to the document. javax.swing.text.StyledDocument document = this.text_pane.getStyledDocument(); javax.swing.text.Style default_style = @@ -344,73 +311,50 @@ public boolean append_objects( String p_button_name, String p_window_title, javax.swing.text.Style button_style = document.addStyle(p_button_name, default_style); javax.swing.text.StyleConstants.setAlignment(button_style, javax.swing.text.StyleConstants.ALIGN_CENTER); javax.swing.text.StyleConstants.setComponent(button_style, button); - + // Add the button to the document. - try - { + try { document.insertString(document.getLength(), p_button_name, button_style); - } - catch (javax.swing.text.BadLocationException e) - { + } catch (javax.swing.text.BadLocationException e) { System.err.println("ObjectInfoWindow.append: unable to insert text into text pane."); return false; } return true; } - - public void dispose() - { - for (WindowObjectInfo curr_subwindow : this.subwindows) - { - if (curr_subwindow != null) - { + + public void dispose() { + for (WindowObjectInfo curr_subwindow : this.subwindows) { + if (curr_subwindow != null) { curr_subwindow.dispose(); } } super.dispose(); } - - private final javax.swing.JTextPane text_pane; - private final net.freerouting.board.CoordinateTransform coordinate_transform; - - private final java.util.ResourceBundle resources; - private final java.text.NumberFormat number_format; - - /** - * The new created windows by pushing buttons inside this window. - * Used when closing this window to close also all subwindows. - */ - private Collection subwindows = new java.util.LinkedList(); - - private static final int MAX_WINDOW_HEIGHT = 500; - private static final int SCROLLBAR_ADD = 30; - - - private class InfoButtonListener implements java.awt.event.ActionListener - { - public InfoButtonListener(String p_title, java.util.Collection p_objects) - { + + private class InfoButtonListener implements java.awt.event.ActionListener { + private static final int WINDOW_OFFSET = 30; + /** + * The title of this window + */ + private final String title; + /** + * The objects, for which information is displayed in tne new window + */ + private final Collection objects; + + public InfoButtonListener(String p_title, java.util.Collection p_objects) { this.title = p_title; this.objects = p_objects; } - - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + public void actionPerformed(java.awt.event.ActionEvent p_evt) { WindowObjectInfo new_window = display(this.title, this.objects, board_frame, coordinate_transform); - + java.awt.Point loc = getLocation(); java.awt.Point new_window_location = new java.awt.Point((int) (loc.getX() + WINDOW_OFFSET), (int) (loc.getY() + WINDOW_OFFSET)); new_window.setLocation(new_window_location); subwindows.add(new_window); } - - /** The title of this window */ - private final String title; - - /** The objects, for which information is displayed in tne new window */ - private final Collection objects; - - private static final int WINDOW_OFFSET = 30; } } diff --git a/src/main/java/net/freerouting/gui/WindowObjectList.java b/src/main/java/net/freerouting/gui/WindowObjectList.java index ae6e2aed..2643faed 100644 --- a/src/main/java/net/freerouting/gui/WindowObjectList.java +++ b/src/main/java/net/freerouting/gui/WindowObjectList.java @@ -21,179 +21,189 @@ package net.freerouting.gui; /** - * Abstract class for windows displaying a list of objects + * Abstract class for windows displaying a list of objects * * @author Alfons Wirtz */ -public abstract class WindowObjectList extends BoardSavableSubWindow -{ - - /** Creates a new instance of ObjectListWindow */ - public WindowObjectList(BoardFrame p_board_frame) - { +public abstract class WindowObjectList extends BoardSavableSubWindow { + + protected static final int DEFAULT_TABLE_SIZE = 20; + protected final BoardFrame board_frame; + protected final javax.swing.JPanel south_panel; + /** + * The subwindows with information about selected object + */ + protected final java.util.Collection subwindows = new java.util.LinkedList(); + private final javax.swing.JPanel main_panel; + private final java.util.ResourceBundle resources; + protected javax.swing.JLabel list_empty_message; + protected javax.swing.JList list; + private javax.swing.JScrollPane list_scroll_pane = null; + private javax.swing.DefaultListModel list_model = null; + /** + * Creates a new instance of ObjectListWindow + */ + public WindowObjectList(BoardFrame p_board_frame) { this.board_frame = p_board_frame; this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowObjectList", p_board_frame.get_locale()); - + // create main panel this.main_panel = new javax.swing.JPanel(); main_panel.setLayout(new java.awt.BorderLayout()); this.add(main_panel); - - + + // create a panel for adding buttons this.south_panel = new javax.swing.JPanel(); south_panel.setLayout(new java.awt.BorderLayout()); main_panel.add(south_panel, java.awt.BorderLayout.SOUTH); - - - javax.swing.JPanel button_panel = new javax.swing.JPanel(); + + + javax.swing.JPanel button_panel = new javax.swing.JPanel(); button_panel.setLayout(new java.awt.BorderLayout()); this.south_panel.add(button_panel, java.awt.BorderLayout.CENTER); - - javax.swing.JPanel north_button_panel = new javax.swing.JPanel(); + + javax.swing.JPanel north_button_panel = new javax.swing.JPanel(); button_panel.add(north_button_panel, java.awt.BorderLayout.NORTH); - + javax.swing.JButton show_button = new javax.swing.JButton(resources.getString("info")); show_button.setToolTipText(resources.getString("info_tooltip")); ShowListener show_listener = new ShowListener(); show_button.addActionListener(show_listener); north_button_panel.add(show_button); - + javax.swing.JButton instance_button = new javax.swing.JButton(resources.getString("select")); instance_button.setToolTipText(resources.getString("select_tooltip")); SelectListener instance_listener = new SelectListener(); instance_button.addActionListener(instance_listener); north_button_panel.add(instance_button); - - javax.swing.JPanel south_button_panel = new javax.swing.JPanel(); + + javax.swing.JPanel south_button_panel = new javax.swing.JPanel(); button_panel.add(south_button_panel, java.awt.BorderLayout.SOUTH); - + javax.swing.JButton invert_button = new javax.swing.JButton(resources.getString("invert")); invert_button.setToolTipText(resources.getString("invert_tooltip")); invert_button.addActionListener(new InvertListener()); south_button_panel.add(invert_button); - + javax.swing.JButton recalculate_button = new javax.swing.JButton(resources.getString("recalculate")); recalculate_button.setToolTipText(resources.getString("recalculate_tooltip")); RecalculateListener recalculate_listener = new RecalculateListener(); recalculate_button.addActionListener(recalculate_listener); south_button_panel.add(recalculate_button); - + this.list_empty_message = new javax.swing.JLabel(resources.getString("list_empty")); - this.list_empty_message.setBorder(javax.swing.BorderFactory.createEmptyBorder(10,10,10,10)); - + this.list_empty_message.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10)); + /** Dispose this window and all subwindows when closing the window. */ - this.addWindowListener(new java.awt.event.WindowAdapter() - { - public void windowClosing(java.awt.event.WindowEvent evt) - { + this.addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { dispose(); } }); } - - public void setVisible(boolean p_value) - { - if (p_value == true) - { + + public void setVisible(boolean p_value) { + if (p_value == true) { recalculate(); } super.setVisible(p_value); } - - protected void recalculate() - { - if (this.list_scroll_pane != null) - { + + protected void recalculate() { + if (this.list_scroll_pane != null) { main_panel.remove(this.list_scroll_pane); } main_panel.remove(this.list_empty_message); // Create display list this.list_model = new javax.swing.DefaultListModel(); this.list = new javax.swing.JList(this.list_model); - this.list.setBorder(javax.swing.BorderFactory.createEmptyBorder(10,10,10,10)); + this.list.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.fill_list(); - if (this.list.getVisibleRowCount() > 0) - { + if (this.list.getVisibleRowCount() > 0) { list_scroll_pane = new javax.swing.JScrollPane(this.list); main_panel.add(list_scroll_pane, java.awt.BorderLayout.CENTER); - } - else - { + } else { main_panel.add(list_empty_message, java.awt.BorderLayout.CENTER); } this.pack(); - - this.list.addMouseListener(new java.awt.event.MouseAdapter() - { - public void mouseClicked(java.awt.event.MouseEvent evt) - { - if (evt.getClickCount() > 1) - { + + this.list.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + if (evt.getClickCount() > 1) { select_instances(); } } }); } - - public void dispose() - { - for (WindowObjectInfo curr_subwindow : this.subwindows) - { - if (curr_subwindow != null) - { + + public void dispose() { + for (WindowObjectInfo curr_subwindow : this.subwindows) { + if (curr_subwindow != null) { curr_subwindow.dispose(); } } super.dispose(); } - - protected void add_to_list(Object p_object) - { + + protected void add_to_list(Object p_object) { this.list_model.addElement(p_object); } - + /** * Fills the list with the objects to display. */ abstract protected void fill_list(); - + abstract protected void select_instances(); - - protected final BoardFrame board_frame; - - private final javax.swing.JPanel main_panel; - - private javax.swing.JScrollPane list_scroll_pane = null; - protected javax.swing.JLabel list_empty_message; - - private javax.swing.DefaultListModel list_model = null; - protected javax.swing.JList list; - - protected final javax.swing.JPanel south_panel; - - /** The subwindows with information about selected object*/ - protected final java.util.Collection subwindows = new java.util.LinkedList(); - - private final java.util.ResourceBundle resources; - - protected static final int DEFAULT_TABLE_SIZE = 20; - - - /** Listens to the button for showing the selected padstacks */ - private class ShowListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + /** + * Saves also the filter string to disk. + */ + public void save(java.io.ObjectOutputStream p_object_stream) { + int[] selected_indices; + if (this.list != null) { + selected_indices = this.list.getSelectedIndices(); + } else { + selected_indices = new int[0]; + } + try { + p_object_stream.writeObject(selected_indices); + } catch (java.io.IOException e) { + System.out.println("WindowObjectList.save: save failed"); + } + super.save(p_object_stream); + } + + public boolean read(java.io.ObjectInputStream p_object_stream) { + int[] saved_selected_indices = null; + try { + saved_selected_indices = (int[]) p_object_stream.readObject(); + } catch (Exception e) { + System.out.println("WindowObjectListWithFilter.read: read failed"); + return false; + } + boolean result = super.read(p_object_stream); + if (this.list != null && saved_selected_indices.length > 0) { + this.list.setSelectedIndices(saved_selected_indices); + } + return result; + } + + /** + * Listens to the button for showing the selected padstacks + */ + private class ShowListener implements java.awt.event.ActionListener { + private static final int WINDOW_OFFSET = 30; + + public void actionPerformed(java.awt.event.ActionEvent p_evt) { Object[] selected_objects = list.getSelectedValues(); - if (selected_objects.length <= 0) - { + if (selected_objects.length <= 0) { return; } java.util.Collection object_list = new java.util.LinkedList(); - for (int i = 0; i < selected_objects.length; ++i) - { - object_list.add((WindowObjectInfo.Printable)(selected_objects[i])); + for (int i = 0; i < selected_objects.length; ++i) { + object_list.add((WindowObjectInfo.Printable) (selected_objects[i])); } net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; WindowObjectInfo new_window = @@ -204,34 +214,29 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) new_window.setLocation(new_window_location); subwindows.add(new_window); } - - private static final int WINDOW_OFFSET = 30; } - - /** Listens to the button for showing the selected incompletes*/ - private class SelectListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + /** + * Listens to the button for showing the selected incompletes + */ + private class SelectListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { select_instances(); } } - - /** Listens to the button for inverting the selection*/ - private class InvertListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - if (list_model == null) - { + + /** + * Listens to the button for inverting the selection + */ + private class InvertListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + if (list_model == null) { return; } - int [] new_selected_indices = new int [list_model.getSize() - list.getSelectedIndices().length]; + int[] new_selected_indices = new int[list_model.getSize() - list.getSelectedIndices().length]; int curr_index = 0; - for (int i = 0; i < list_model.getSize(); ++i) - { - if (!list.isSelectedIndex(i)) - { + for (int i = 0; i < list_model.getSize(); ++i) { + if (!list.isSelectedIndex(i)) { new_selected_indices[curr_index] = i; ++curr_index; } @@ -239,57 +244,12 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) list.setSelectedIndices(new_selected_indices); } } - + /** - * Saves also the filter string to disk. + * Listens to the button for recalculating the content of the window */ - public void save(java.io.ObjectOutputStream p_object_stream) - { - int [] selected_indices; - if (this.list != null) - { - selected_indices = this.list.getSelectedIndices(); - } - else - { - selected_indices = new int[0]; - } - try - { - p_object_stream.writeObject(selected_indices); - } - catch (java.io.IOException e) - { - System.out.println("WindowObjectList.save: save failed"); - } - super.save(p_object_stream); - } - - public boolean read(java.io.ObjectInputStream p_object_stream) - { - int [] saved_selected_indices = null; - try - { - saved_selected_indices = (int[]) p_object_stream.readObject(); - } - catch (Exception e) - { - System.out.println("WindowObjectListWithFilter.read: read failed"); - return false; - } - boolean result = super.read(p_object_stream); - if (this.list != null && saved_selected_indices.length > 0) - { - this.list.setSelectedIndices(saved_selected_indices); - } - return result; - } - - /** Listens to the button for recalculating the content of the window*/ - private class RecalculateListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + private class RecalculateListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { recalculate(); } } diff --git a/src/main/java/net/freerouting/gui/WindowObjectListWithFilter.java b/src/main/java/net/freerouting/gui/WindowObjectListWithFilter.java index 8f2fc07b..fc0ec276 100644 --- a/src/main/java/net/freerouting/gui/WindowObjectListWithFilter.java +++ b/src/main/java/net/freerouting/gui/WindowObjectListWithFilter.java @@ -21,123 +21,101 @@ package net.freerouting.gui; /** - * Abstract class for windows displaying a list of objects - * The object name can be filttered by an alphanumeric input string. * @author Alfons Wirtz + * Abstract class for windows displaying a list of objects + * The object name can be filttered by an alphanumeric input string. * @author Alfons Wirtz */ -public abstract class WindowObjectListWithFilter extends WindowObjectList -{ - - /** Creates a new instance of ObjectListWindowWithFilter */ - public WindowObjectListWithFilter(BoardFrame p_board_frame) - { +public abstract class WindowObjectListWithFilter extends WindowObjectList { + + private final javax.swing.JTextField filter_string; + + /** + * Creates a new instance of ObjectListWindowWithFilter + */ + public WindowObjectListWithFilter(BoardFrame p_board_frame) { super(p_board_frame); - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowObjectList", p_board_frame.get_locale()); javax.swing.JPanel input_panel = new javax.swing.JPanel(); this.south_panel.add(input_panel, java.awt.BorderLayout.SOUTH); - + javax.swing.JLabel filter_label = new javax.swing.JLabel(resources.getString("filter")); input_panel.add(filter_label, java.awt.BorderLayout.WEST); - + this.filter_string = new javax.swing.JTextField(10); this.filter_string.setText(""); input_panel.add(filter_string, java.awt.BorderLayout.EAST); } - + /** * Adds p_object to the list only if its name matches the filter. */ - protected void add_to_list(Object p_object) - { + protected void add_to_list(Object p_object) { String curr_filter_string = this.filter_string.getText().trim(); boolean object_matches; - if (curr_filter_string.length() == 0) - { + if (curr_filter_string.length() == 0) { object_matches = true; - } - else - { + } else { object_matches = p_object.toString().contains(curr_filter_string); } - if (object_matches) - { + if (object_matches) { super.add_to_list(p_object); } } - + /** * Returns the filter text string of this window. */ - public SnapshotInfo get_snapshot_info() - { - int [] selected_indices; - if (this.list != null) - { + public SnapshotInfo get_snapshot_info() { + int[] selected_indices; + if (this.list != null) { selected_indices = this.list.getSelectedIndices(); - } - else - { + } else { selected_indices = new int[0]; } return new SnapshotInfo(filter_string.getText(), selected_indices); } - - public void set_snapshot_info(SnapshotInfo p_snapshot_info) - { - if (!p_snapshot_info.filter.equals(this.filter_string.getText())) - { + + public void set_snapshot_info(SnapshotInfo p_snapshot_info) { + if (!p_snapshot_info.filter.equals(this.filter_string.getText())) { this.filter_string.setText(p_snapshot_info.filter); this.recalculate(); } - if (this.list != null && p_snapshot_info.selected_indices.length > 0) - { + if (this.list != null && p_snapshot_info.selected_indices.length > 0) { this.list.setSelectedIndices(p_snapshot_info.selected_indices); } } - + /** * Saves also the filter string to disk. */ - public void save(java.io.ObjectOutputStream p_object_stream) - { - try - { + public void save(java.io.ObjectOutputStream p_object_stream) { + try { p_object_stream.writeObject(filter_string.getText()); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("WindowObjectListWithFilter.save: save failed"); } super.save(p_object_stream); } - - public boolean read(java.io.ObjectInputStream p_object_stream) - { - try - { + + public boolean read(java.io.ObjectInputStream p_object_stream) { + try { String curr_string = (String) p_object_stream.readObject(); this.filter_string.setText(curr_string); - } - catch (Exception e) - { + } catch (Exception e) { System.out.println("WindowObjectListWithFilter.read: read failed"); } return super.read(p_object_stream); } - - private final javax.swing.JTextField filter_string; - + /** * Information to be stored in a SnapShot. */ - public static class SnapshotInfo implements java.io.Serializable - { - private SnapshotInfo(String p_filter, int[] p_selected_indices) - { + public static class SnapshotInfo implements java.io.Serializable { + private final String filter; + private final int[] selected_indices; + private SnapshotInfo(String p_filter, int[] p_selected_indices) { filter = p_filter; selected_indices = p_selected_indices; } - private final String filter; - private final int [] selected_indices; } } diff --git a/src/main/java/net/freerouting/gui/WindowObjectVisibility.java b/src/main/java/net/freerouting/gui/WindowObjectVisibility.java index 0e1382b3..f0631e45 100644 --- a/src/main/java/net/freerouting/gui/WindowObjectVisibility.java +++ b/src/main/java/net/freerouting/gui/WindowObjectVisibility.java @@ -25,50 +25,47 @@ /** * Interactive Frame to adjust the visibility of the individual board items * - * @author alfons + * @author alfons */ -public class WindowObjectVisibility extends WindowVisibility -{ - /** Returns a new instance of ItemVisibilityFrame */ - public static WindowObjectVisibility get_instance(BoardFrame p_board_frame) - { - java.util.ResourceBundle resources = +public class WindowObjectVisibility extends WindowVisibility { + /** + * Creates a new instance of ItemVisibilityFrame + */ + private WindowObjectVisibility(BoardFrame p_board_frame, String p_title, String p_header_message, String[] p_message_arr) { + + super(p_board_frame, p_title, p_header_message, p_message_arr); + } + + /** + * Returns a new instance of ItemVisibilityFrame + */ + public static WindowObjectVisibility get_instance(BoardFrame p_board_frame) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowObjectVisibility", p_board_frame.get_locale()); String title = resources.getString("title"); String header_message = resources.getString("header_message"); - String [] message_arr = new String [ObjectNames.values().length]; - for (int i = 0; i < message_arr.length; ++i) - { + String[] message_arr = new String[ObjectNames.values().length]; + for (int i = 0; i < message_arr.length; ++i) { message_arr[i] = resources.getString(ObjectNames.values()[i].toString()); } - WindowObjectVisibility result = new WindowObjectVisibility(p_board_frame, title, header_message, message_arr); + WindowObjectVisibility result = new WindowObjectVisibility(p_board_frame, title, header_message, message_arr); p_board_frame.set_context_sensitive_help(result, "WindowDisplay_ObjectVisibility"); result.refresh(); return result; } - - /** Creates a new instance of ItemVisibilityFrame */ - private WindowObjectVisibility(BoardFrame p_board_frame, String p_title, String p_header_message, String[] p_message_arr) - { - - super(p_board_frame, p_title, p_header_message, p_message_arr); - } - + /** * Refreshs the displayed values in this window. */ - public void refresh() - { + public void refresh() { net.freerouting.boardgraphics.ColorIntensityTable color_intensity_table = this.get_board_handling().graphics_context.color_intensity_table; - for (int i = 0; i < ObjectNames.values().length; ++i) - { + for (int i = 0; i < ObjectNames.values().length; ++i) { this.set_slider_value(i, color_intensity_table.get_value(i)); } } - - protected void set_changed_value(int p_index, double p_value) - { - + + protected void set_changed_value(int p_index, double p_value) { + get_board_handling().graphics_context.color_intensity_table.set_value(p_index, p_value); } } diff --git a/src/main/java/net/freerouting/gui/WindowPackages.java b/src/main/java/net/freerouting/gui/WindowPackages.java index 2deca7a3..e33d1613 100644 --- a/src/main/java/net/freerouting/gui/WindowPackages.java +++ b/src/main/java/net/freerouting/gui/WindowPackages.java @@ -20,73 +20,63 @@ package net.freerouting.gui; -import net.freerouting.library.Packages; import net.freerouting.library.Package; +import net.freerouting.library.Packages; /** * Window displaying the library packagess. * * @author Alfons Wirtz */ -public class WindowPackages extends WindowObjectListWithFilter -{ - - /** Creates a new instance of PackagesWindow */ - public WindowPackages(BoardFrame p_board_frame) - { +public class WindowPackages extends WindowObjectListWithFilter { + + /** + * Creates a new instance of PackagesWindow + */ + public WindowPackages(BoardFrame p_board_frame) { super(p_board_frame); - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); this.setTitle(resources.getString("packages")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_LibraryPackages"); } - + /** * Fills the list with the library packages. */ - protected void fill_list() - { + protected void fill_list() { Packages packages = this.board_frame.board_panel.board_handling.get_routing_board().library.packages; Package[] sorted_arr = new Package[packages.count()]; - for (int i = 0; i < sorted_arr.length; ++i) - { + for (int i = 0; i < sorted_arr.length; ++i) { sorted_arr[i] = packages.get(i + 1); } java.util.Arrays.sort(sorted_arr); - for (int i = 0; i < sorted_arr.length; ++i) - { + for (int i = 0; i < sorted_arr.length; ++i) { this.add_to_list(sorted_arr[i]); } this.list.setVisibleRowCount(Math.min(packages.count(), DEFAULT_TABLE_SIZE)); } - - protected void select_instances() - { + + protected void select_instances() { Object[] selected_packages = list.getSelectedValues(); - if (selected_packages.length <= 0) - { + if (selected_packages.length <= 0) { return; } net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); java.util.Set board_instances = new java.util.TreeSet(); java.util.Collection board_items = routing_board.get_items(); - for (net.freerouting.board.Item curr_item : board_items) - { - if (curr_item.get_component_no() > 0) - { + for (net.freerouting.board.Item curr_item : board_items) { + if (curr_item.get_component_no() > 0) { net.freerouting.board.Component curr_component = routing_board.components.get(curr_item.get_component_no()); Package curr_package = curr_component.get_package(); boolean package_matches = false; - for (int i = 0; i < selected_packages.length; ++i) - { - if (curr_package == selected_packages[i]) - { + for (int i = 0; i < selected_packages.length; ++i) { + if (curr_package == selected_packages[i]) { package_matches = true; break; } } - if (package_matches) - { + if (package_matches) { board_instances.add(curr_item); } } diff --git a/src/main/java/net/freerouting/gui/WindowPadstacks.java b/src/main/java/net/freerouting/gui/WindowPadstacks.java index 6377fd37..6fc3e8a3 100644 --- a/src/main/java/net/freerouting/gui/WindowPadstacks.java +++ b/src/main/java/net/freerouting/gui/WindowPadstacks.java @@ -21,7 +21,6 @@ package net.freerouting.gui; import net.freerouting.datastructures.UndoableObjects; - import net.freerouting.library.Padstack; import net.freerouting.library.Padstacks; @@ -30,68 +29,57 @@ * * @author Alfons Wirtz */ -public class WindowPadstacks extends WindowObjectListWithFilter -{ - - /** Creates a new instance of PadstacksWindow */ - public WindowPadstacks(BoardFrame p_board_frame) - { +public class WindowPadstacks extends WindowObjectListWithFilter { + + /** + * Creates a new instance of PadstacksWindow + */ + public WindowPadstacks(BoardFrame p_board_frame) { super(p_board_frame); - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); this.setTitle(resources.getString("padstacks")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_LibraryPadstacks"); } - + /** * Fills the list with the library padstacks. */ - protected void fill_list() - { + protected void fill_list() { Padstacks padstacks = this.board_frame.board_panel.board_handling.get_routing_board().library.padstacks; Padstack[] sorted_arr = new Padstack[padstacks.count()]; - for (int i = 0; i < sorted_arr.length; ++i) - { + for (int i = 0; i < sorted_arr.length; ++i) { sorted_arr[i] = padstacks.get(i + 1); } java.util.Arrays.sort(sorted_arr); - for (int i = 0; i < sorted_arr.length; ++i) - { + for (int i = 0; i < sorted_arr.length; ++i) { this.add_to_list(sorted_arr[i]); } this.list.setVisibleRowCount(Math.min(padstacks.count(), DEFAULT_TABLE_SIZE)); } - - protected void select_instances() - { + + protected void select_instances() { Object[] selected_padstacks = list.getSelectedValues(); - if (selected_padstacks.length <= 0) - { + if (selected_padstacks.length <= 0) { return; } java.util.Collection padstack_list = new java.util.LinkedList(); - for (int i = 0; i < selected_padstacks.length; ++i) - { - padstack_list.add((Padstack)selected_padstacks[i]); + for (int i = 0; i < selected_padstacks.length; ++i) { + padstack_list.add((Padstack) selected_padstacks[i]); } net.freerouting.board.RoutingBoard routing_board = board_frame.board_panel.board_handling.get_routing_board(); java.util.Set board_instances = new java.util.TreeSet(); java.util.Iterator it = routing_board.item_list.start_read_object(); - for(;;) - { + for (; ; ) { net.freerouting.datastructures.UndoableObjects.Storable curr_object = routing_board.item_list.read_object(it); - if (curr_object == null) - { + if (curr_object == null) { break; } - if (curr_object instanceof net.freerouting.board.DrillItem) - { + if (curr_object instanceof net.freerouting.board.DrillItem) { net.freerouting.library.Padstack curr_padstack = ((net.freerouting.board.DrillItem) curr_object).get_padstack(); - for (Padstack curr_selected_padstack : padstack_list) - { - if (curr_padstack == curr_selected_padstack) - { - board_instances.add((net.freerouting.board.Item)curr_object); + for (Padstack curr_selected_padstack : padstack_list) { + if (curr_padstack == curr_selected_padstack) { + board_instances.add((net.freerouting.board.Item) curr_object); break; } } diff --git a/src/main/java/net/freerouting/gui/WindowRouteDetail.java b/src/main/java/net/freerouting/gui/WindowRouteDetail.java index 94510e66..808439b3 100644 --- a/src/main/java/net/freerouting/gui/WindowRouteDetail.java +++ b/src/main/java/net/freerouting/gui/WindowRouteDetail.java @@ -22,16 +22,23 @@ import net.freerouting.board.BoardOutline; /** - * Window handling detail parameters of the interactive routing. + * Window handling detail parameters of the interactive routing. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class WindowRouteDetail extends BoardSavableSubWindow -{ +public class WindowRouteDetail extends BoardSavableSubWindow { - /** Creates a new instance of RouteDetailWindow */ - public WindowRouteDetail(BoardFrame p_board_frame) - { + private static final int c_max_slider_value = 100; + private static final int c_accuracy_scale_factor = 20; + private final net.freerouting.interactive.BoardHandling board_handling; + private final javax.swing.JSlider accuracy_slider; + private final javax.swing.JRadioButton on_button; + private final javax.swing.JRadioButton off_button; + private final javax.swing.JCheckBox outline_keepout_check_box; + /** + * Creates a new instance of RouteDetailWindow + */ + public WindowRouteDetail(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowRouteDetail", p_board_frame.get_locale()); @@ -118,72 +125,50 @@ public WindowRouteDetail(BoardFrame p_board_frame) /** * Recalculates all displayed values */ - public void refresh() - { - if (this.board_handling.get_routing_board().search_tree_manager.is_clearance_compensation_used()) - { + public void refresh() { + if (this.board_handling.get_routing_board().search_tree_manager.is_clearance_compensation_used()) { this.on_button.setSelected(true); - } - else - { + } else { this.off_button.setSelected(true); } BoardOutline outline = this.board_handling.get_routing_board().get_outline(); - if (outline != null) - { + if (outline != null) { this.outline_keepout_check_box.setSelected(outline.keepout_outside_outline_generated()); } int accuracy_slider_value = c_max_slider_value - this.board_handling.settings.get_trace_pull_tight_accuracy() / c_accuracy_scale_factor + 1; accuracy_slider.setValue(accuracy_slider_value); } - private final net.freerouting.interactive.BoardHandling board_handling; - private final javax.swing.JSlider accuracy_slider; - private final javax.swing.JRadioButton on_button; - private final javax.swing.JRadioButton off_button; - private final javax.swing.JCheckBox outline_keepout_check_box; - private static final int c_max_slider_value = 100; - private static final int c_accuracy_scale_factor = 20; - private class CompensationOnListener implements java.awt.event.ActionListener - { + private class CompensationOnListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.set_clearance_compensation(true); } } - private class CompensationOffListener implements java.awt.event.ActionListener - { + private class CompensationOffListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.set_clearance_compensation(false); } } - private class SliderChangeListener implements javax.swing.event.ChangeListener - { + private class SliderChangeListener implements javax.swing.event.ChangeListener { - public void stateChanged(javax.swing.event.ChangeEvent evt) - { + public void stateChanged(javax.swing.event.ChangeEvent evt) { int new_accurracy = (c_max_slider_value - accuracy_slider.getValue() + 1) * c_accuracy_scale_factor; board_handling.settings.set_current_pull_tight_accuracy(new_accurracy); } } - private class OutLineKeepoutListener implements java.awt.event.ActionListener - { + private class OutLineKeepoutListener implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - if (board_handling.is_board_read_only()) - { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + if (board_handling.is_board_read_only()) { return; } BoardOutline outline = board_handling.get_routing_board().get_outline(); - if (outline != null) - { + if (outline != null) { outline.generate_keepout_outside(outline_keepout_check_box.isSelected()); } } diff --git a/src/main/java/net/freerouting/gui/WindowRouteParameter.java b/src/main/java/net/freerouting/gui/WindowRouteParameter.java index c9b3e26f..27b593b0 100644 --- a/src/main/java/net/freerouting/gui/WindowRouteParameter.java +++ b/src/main/java/net/freerouting/gui/WindowRouteParameter.java @@ -23,29 +23,55 @@ import java.util.Collection; /** - * Window handling parameters of the interactive routing. + * Window handling parameters of the interactive routing. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class WindowRouteParameter extends BoardSavableSubWindow -{ - - /** Creates a new instance of RouteParameterWindow */ - public WindowRouteParameter(BoardFrame p_board_frame) - { +public class WindowRouteParameter extends BoardSavableSubWindow { + + private static final int c_max_slider_value = 999; + private static final int c_region_scale_factor = 200; + final WindowManualRules manual_rule_window; + final WindowRouteDetail detail_window; + private final net.freerouting.interactive.BoardHandling board_handling; + private final java.util.Locale current_locale; + private final javax.swing.JSlider region_slider; + private final javax.swing.JFormattedTextField region_width_field; + private final javax.swing.JFormattedTextField edge_to_turn_dist_field; + private final javax.swing.JRadioButton snap_angle_90_button; + private final javax.swing.JRadioButton snap_angle_45_button; + private final javax.swing.JRadioButton snap_angle_none_button; + private final javax.swing.JRadioButton dynamic_button; + private final javax.swing.JRadioButton stitch_button; + private final javax.swing.JRadioButton automatic_button; + private final javax.swing.JRadioButton manual_button; + private final javax.swing.JCheckBox shove_check_box; + private final javax.swing.JCheckBox drag_component_check_box; + private final javax.swing.JCheckBox ignore_conduction_check_box; + private final javax.swing.JCheckBox via_snap_to_smd_center_check_box; + private final javax.swing.JCheckBox hilight_routing_obstacle_check_box; + private final javax.swing.JCheckBox neckdown_check_box; + private final javax.swing.JCheckBox restrict_pin_exit_directions_check_box; + private final DetailListener detail_listener; + private final ManualTraceWidthListener manual_trace_width_listener; + private boolean key_input_completed = true; + /** + * Creates a new instance of RouteParameterWindow + */ + public WindowRouteParameter(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; this.current_locale = p_board_frame.get_locale(); this.detail_window = new WindowRouteDetail(p_board_frame); this.manual_rule_window = new WindowManualRules(p_board_frame); - - java.util.ResourceBundle resources = + + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowRouteParameter", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); - - this.setDefaultCloseOperation(DISPOSE_ON_CLOSE ); - + + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + // create main panel - + final javax.swing.JPanel main_panel = new javax.swing.JPanel(); getContentPane().add(main_panel); java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); @@ -53,167 +79,167 @@ public WindowRouteParameter(BoardFrame p_board_frame) java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); gridbag_constraints.anchor = java.awt.GridBagConstraints.WEST; gridbag_constraints.insets = new java.awt.Insets(1, 10, 1, 10); - + // add label and button group for the route snap angle. - + javax.swing.JLabel snap_angle_label = new javax.swing.JLabel(resources.getString("snap_angle")); snap_angle_label.setToolTipText(resources.getString("snap_angle_tooltip")); - + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridbag_constraints.gridheight = 3; gridbag.setConstraints(snap_angle_label, gridbag_constraints); main_panel.add(snap_angle_label); - + this.snap_angle_90_button = new javax.swing.JRadioButton(resources.getString("90_degree")); this.snap_angle_45_button = new javax.swing.JRadioButton(resources.getString("45_degree")); this.snap_angle_none_button = new javax.swing.JRadioButton(resources.getString("none")); - + snap_angle_90_button.addActionListener(new SnapAngle90Listener()); snap_angle_45_button.addActionListener(new SnapAngle45Listener()); snap_angle_none_button.addActionListener(new SnapAngleNoneListener()); - + javax.swing.ButtonGroup snap_angle_button_group = new javax.swing.ButtonGroup(); snap_angle_button_group.add(snap_angle_90_button); snap_angle_button_group.add(snap_angle_45_button); snap_angle_button_group.add(snap_angle_none_button); snap_angle_none_button.setSelected(true); - - + + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag_constraints.gridheight = 1; gridbag.setConstraints(snap_angle_90_button, gridbag_constraints); main_panel.add(snap_angle_90_button, gridbag_constraints); - + gridbag.setConstraints(snap_angle_45_button, gridbag_constraints); main_panel.add(snap_angle_45_button, gridbag_constraints); gridbag.setConstraints(snap_angle_none_button, gridbag_constraints); main_panel.add(snap_angle_none_button, gridbag_constraints); - + javax.swing.JLabel separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + // add label and button group for the route mode. - + javax.swing.JLabel route_mode_label = new javax.swing.JLabel(resources.getString("route_mode")); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridbag_constraints.gridheight = 2; gridbag.setConstraints(route_mode_label, gridbag_constraints); main_panel.add(route_mode_label); - + this.dynamic_button = new javax.swing.JRadioButton(resources.getString("dynamic")); this.stitch_button = new javax.swing.JRadioButton(resources.getString("stitching")); - + dynamic_button.addActionListener(new DynamicRouteListener()); stitch_button.addActionListener(new StitchRouteListener()); - + javax.swing.ButtonGroup route_mode_button_group = new javax.swing.ButtonGroup(); route_mode_button_group.add(dynamic_button); route_mode_button_group.add(stitch_button); dynamic_button.setSelected(true); - + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag_constraints.gridheight = 1; gridbag.setConstraints(dynamic_button, gridbag_constraints); main_panel.add(dynamic_button, gridbag_constraints); gridbag.setConstraints(stitch_button, gridbag_constraints); main_panel.add(stitch_button, gridbag_constraints); - + separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + // add label and buttongroup for automatic or manual trace width selection. - + javax.swing.JLabel trace_widths_label = new javax.swing.JLabel(resources.getString("rule_selection")); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridbag_constraints.gridheight = 2; gridbag.setConstraints(trace_widths_label, gridbag_constraints); main_panel.add(trace_widths_label); - + this.automatic_button = new javax.swing.JRadioButton(resources.getString("automatic")); this.manual_button = new javax.swing.JRadioButton(resources.getString("manual")); - + automatic_button.addActionListener(new AutomaticTraceWidthListener()); this.manual_trace_width_listener = new ManualTraceWidthListener(); manual_button.addActionListener(manual_trace_width_listener); - + javax.swing.ButtonGroup trace_widths_button_group = new javax.swing.ButtonGroup(); trace_widths_button_group.add(automatic_button); trace_widths_button_group.add(manual_button); automatic_button.setSelected(true); - + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag_constraints.gridheight = 1; gridbag.setConstraints(automatic_button, gridbag_constraints); main_panel.add(automatic_button, gridbag_constraints); gridbag.setConstraints(manual_button, gridbag_constraints); main_panel.add(manual_button, gridbag_constraints); - + separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + // add check box for push enabled - + this.shove_check_box = new javax.swing.JCheckBox(resources.getString("push&shove_enabled")); this.shove_check_box.addActionListener(new ShoveListener()); gridbag.setConstraints(shove_check_box, gridbag_constraints); this.shove_check_box.setToolTipText(resources.getString("push&shove_enabled_tooltip")); main_panel.add(shove_check_box, gridbag_constraints); - + // add check box for drag components enabled - + this.drag_component_check_box = new javax.swing.JCheckBox(resources.getString("drag_components_enabled")); this.drag_component_check_box.addActionListener(new DragComponentListener()); gridbag.setConstraints(drag_component_check_box, gridbag_constraints); this.drag_component_check_box.setToolTipText(resources.getString("drag_components_enabled_tooltip")); main_panel.add(drag_component_check_box, gridbag_constraints); - + // add check box for via snap to smd center - + this.via_snap_to_smd_center_check_box = new javax.swing.JCheckBox(resources.getString("via_snap_to_smd_center")); this.via_snap_to_smd_center_check_box.addActionListener(new ViaSnapToSMDCenterListener()); gridbag.setConstraints(via_snap_to_smd_center_check_box, gridbag_constraints); this.via_snap_to_smd_center_check_box.setToolTipText(resources.getString("via_snap_to_smd_center_tooltip")); main_panel.add(via_snap_to_smd_center_check_box, gridbag_constraints); - + // add check box for hilighting the routing obstacle - + this.hilight_routing_obstacle_check_box = new javax.swing.JCheckBox(resources.getString("hilight_routing_obstacle")); this.hilight_routing_obstacle_check_box.addActionListener(new HilightObstacleListener()); gridbag.setConstraints(hilight_routing_obstacle_check_box, gridbag_constraints); this.hilight_routing_obstacle_check_box.setToolTipText(resources.getString("hilight_routing_obstacle_tooltip")); main_panel.add(hilight_routing_obstacle_check_box, gridbag_constraints); - + // add check box for ignore_conduction_areas - + this.ignore_conduction_check_box = new javax.swing.JCheckBox(resources.getString("ignore_conduction_areas")); this.ignore_conduction_check_box.addActionListener(new IgnoreConductionListener()); gridbag.setConstraints(ignore_conduction_check_box, gridbag_constraints); this.ignore_conduction_check_box.setToolTipText(resources.getString("ignore_conduction_areas_tooltip")); main_panel.add(ignore_conduction_check_box, gridbag_constraints); - + // add check box for automatic neckdown - + this.neckdown_check_box = new javax.swing.JCheckBox(resources.getString("automatic_neckdown")); this.neckdown_check_box.addActionListener(new NeckDownListener()); gridbag.setConstraints(neckdown_check_box, gridbag_constraints); this.neckdown_check_box.setToolTipText(resources.getString("automatic_neckdown_tooltip")); main_panel.add(neckdown_check_box, gridbag_constraints); - + // add labels and text field for restricting pin exit directions - + separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + this.restrict_pin_exit_directions_check_box = new javax.swing.JCheckBox(resources.getString("restrict_pin_exit_directions")); this.restrict_pin_exit_directions_check_box.addActionListener(new RestrictPinExitDirectionsListener()); gridbag.setConstraints(restrict_pin_exit_directions_check_box, gridbag_constraints); this.restrict_pin_exit_directions_check_box.setToolTipText(resources.getString("restrict_pin_exit_directions_tooltip")); main_panel.add(restrict_pin_exit_directions_check_box, gridbag_constraints); - + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; javax.swing.JLabel pin_exit_edge_to_turn_label = new javax.swing.JLabel(resources.getString("pin_pad_to_turn_gap")); pin_exit_edge_to_turn_label.setToolTipText("pin_pad_to_turn_gap_tooltip"); @@ -228,20 +254,20 @@ public WindowRouteParameter(BoardFrame p_board_frame) main_panel.add(edge_to_turn_dist_field); edge_to_turn_dist_field.addKeyListener(new EdgeToTurnDistFieldKeyListener()); edge_to_turn_dist_field.addFocusListener(new EdgeToTurnDistFieldFocusListener()); - + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; separator = new javax.swing.JLabel("---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + // add label and slider for the pull tight region around the cursor. - + gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; javax.swing.JLabel pull_tight_region_label = new javax.swing.JLabel(resources.getString("pull_tight_region")); pull_tight_region_label.setToolTipText(resources.getString("pull_tight_region_tooltip")); gridbag.setConstraints(pull_tight_region_label, gridbag_constraints); main_panel.add(pull_tight_region_label); - + this.region_width_field = new javax.swing.JFormattedTextField(number_format); this.region_width_field.setColumns(3); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; @@ -249,240 +275,173 @@ public WindowRouteParameter(BoardFrame p_board_frame) main_panel.add(region_width_field); region_width_field.addKeyListener(new RegionWidthFieldKeyListener()); region_width_field.addFocusListener(new RegionWidthFieldFocusListener()); - + this.region_slider = new javax.swing.JSlider(); region_slider.setMaximum(c_max_slider_value); region_slider.addChangeListener(new SliderChangeListener()); gridbag.setConstraints(region_slider, gridbag_constraints); main_panel.add(region_slider); - + separator = new javax.swing.JLabel("---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + javax.swing.JButton detail_button = new javax.swing.JButton(resources.getString("detail_parameter")); this.detail_listener = new DetailListener(); detail_button.addActionListener(detail_listener); gridbag.setConstraints(detail_button, gridbag_constraints); - if (this.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) - { + if (this.board_handling.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { main_panel.add(detail_button); } - + p_board_frame.set_context_sensitive_help(this, "WindowRouteParameter"); - + this.refresh(); this.pack(); this.setResizable(false); } - - public void dispose() - { + + public void dispose() { detail_window.dispose(); manual_rule_window.dispose(); super.dispose(); } - + /** * Reads the data of this frame from disk. * Returns false, if the reading failed. */ - public boolean read(java.io.ObjectInputStream p_object_stream) - { - + public boolean read(java.io.ObjectInputStream p_object_stream) { + boolean read_ok = super.read(p_object_stream); - if(!read_ok) - { + if (!read_ok) { return false; } read_ok = manual_rule_window.read(p_object_stream); - if(!read_ok) - { + if (!read_ok) { return false; } read_ok = detail_window.read(p_object_stream); - if(!read_ok) - { + if (!read_ok) { return false; } this.manual_trace_width_listener.first_time = false; this.detail_listener.first_time = false; this.refresh(); return true; - + } - + /** * Saves this frame to disk. */ - public void save(java.io.ObjectOutputStream p_object_stream) - { + public void save(java.io.ObjectOutputStream p_object_stream) { super.save(p_object_stream); manual_rule_window.save(p_object_stream); detail_window.save(p_object_stream); } - + /** * Recalculates all displayed values */ - public void refresh() - { + public void refresh() { net.freerouting.board.AngleRestriction snap_angle = this.board_handling.get_routing_board().rules.get_trace_angle_restriction(); - - if (snap_angle == net.freerouting.board.AngleRestriction.NINETY_DEGREE) - { + + if (snap_angle == net.freerouting.board.AngleRestriction.NINETY_DEGREE) { snap_angle_90_button.setSelected(true); - } - else if (snap_angle == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (snap_angle == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE) { snap_angle_45_button.setSelected(true); - } - else - { + } else { snap_angle_none_button.setSelected(true); } - - if(this.board_handling.settings.get_is_stitch_route()) - { + + if (this.board_handling.settings.get_is_stitch_route()) { stitch_button.setSelected(true); - } - else - { + } else { dynamic_button.setSelected(true); } - - if(this.board_handling.settings.get_manual_rule_selection()) - { + + if (this.board_handling.settings.get_manual_rule_selection()) { manual_button.setSelected(true); - if (this.manual_rule_window != null) - { + if (this.manual_rule_window != null) { this.manual_rule_window.setVisible(true); } - } - else - { + } else { automatic_button.setSelected(true); } - + this.shove_check_box.setSelected(this.board_handling.settings.get_push_enabled()); this.drag_component_check_box.setSelected(this.board_handling.settings.get_drag_components_enabled()); this.via_snap_to_smd_center_check_box.setSelected(this.board_handling.settings.get_via_snap_to_smd_center()); this.ignore_conduction_check_box.setSelected(this.board_handling.get_routing_board().rules.get_ignore_conduction()); this.hilight_routing_obstacle_check_box.setSelected(this.board_handling.settings.get_hilight_routing_obstacle()); this.neckdown_check_box.setSelected(this.board_handling.settings.get_automatic_neckdown()); - + double edge_to_turn_dist = this.board_handling.get_routing_board().rules.get_pin_edge_to_turn_dist(); edge_to_turn_dist = this.board_handling.coordinate_transform.board_to_user(edge_to_turn_dist); this.edge_to_turn_dist_field.setValue(edge_to_turn_dist); this.restrict_pin_exit_directions_check_box.setSelected(edge_to_turn_dist > 0); - + int region_slider_value = this.board_handling.settings.get_trace_pull_tight_region_width() / c_region_scale_factor; region_slider_value = Math.min(region_slider_value, c_max_slider_value); region_slider.setValue(region_slider_value); region_width_field.setValue(region_slider_value); - - if (this.manual_rule_window != null) - { + + if (this.manual_rule_window != null) { this.manual_rule_window.refresh(); } - if (this.detail_window != null) - { + if (this.detail_window != null) { this.detail_window.refresh(); } } - - public void parent_iconified() - { + + public void parent_iconified() { manual_rule_window.parent_iconified(); detail_window.parent_iconified(); super.parent_iconified(); } - - public void parent_deiconified() - { + + public void parent_deiconified() { manual_rule_window.parent_deiconified(); detail_window.parent_deiconified(); super.parent_deiconified(); } - - private void set_pull_tight_region_width(int p_slider_value) - { + + private void set_pull_tight_region_width(int p_slider_value) { int slider_value = Math.max(p_slider_value, 0); slider_value = Math.min(p_slider_value, c_max_slider_value); int new_tidy_width; - if (slider_value >= 0.9 * c_max_slider_value) - { + if (slider_value >= 0.9 * c_max_slider_value) { p_slider_value = c_max_slider_value; new_tidy_width = Integer.MAX_VALUE; - } - else - { + } else { new_tidy_width = slider_value * c_region_scale_factor; } region_slider.setValue(slider_value); region_width_field.setValue(slider_value); board_handling.settings.set_current_pull_tight_region_width(new_tidy_width); } - - - private final net.freerouting.interactive.BoardHandling board_handling; - private final java.util.Locale current_locale; - final WindowManualRules manual_rule_window; - final WindowRouteDetail detail_window; - private final javax.swing.JSlider region_slider; - private final javax.swing.JFormattedTextField region_width_field; - private final javax.swing.JFormattedTextField edge_to_turn_dist_field; - - private final javax.swing.JRadioButton snap_angle_90_button; - private final javax.swing.JRadioButton snap_angle_45_button; - private final javax.swing.JRadioButton snap_angle_none_button; - private final javax.swing.JRadioButton dynamic_button; - private final javax.swing.JRadioButton stitch_button; - private final javax.swing.JRadioButton automatic_button; - private final javax.swing.JRadioButton manual_button ; - private final javax.swing.JCheckBox shove_check_box; - private final javax.swing.JCheckBox drag_component_check_box; - private final javax.swing.JCheckBox ignore_conduction_check_box; - private final javax.swing.JCheckBox via_snap_to_smd_center_check_box; - private final javax.swing.JCheckBox hilight_routing_obstacle_check_box; - private final javax.swing.JCheckBox neckdown_check_box; - private final javax.swing.JCheckBox restrict_pin_exit_directions_check_box; - - private final DetailListener detail_listener; - private final ManualTraceWidthListener manual_trace_width_listener; - private boolean key_input_completed = true; - - private static final int c_max_slider_value = 999; - private static final int c_region_scale_factor = 200; - - private class SnapAngle90Listener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - if (board_handling.get_routing_board().rules.get_trace_angle_restriction() == net.freerouting.board.AngleRestriction.NINETY_DEGREE) - { + + private class SnapAngle90Listener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + if (board_handling.get_routing_board().rules.get_trace_angle_restriction() == net.freerouting.board.AngleRestriction.NINETY_DEGREE) { return; } Collection trace_list = board_handling.get_routing_board().get_traces(); boolean free_angle_traces_found = false; - for (net.freerouting.board.Trace curr_trace : trace_list) - { - if (curr_trace instanceof net.freerouting.board.PolylineTrace) - { - if (!((net.freerouting.board.PolylineTrace)curr_trace).polyline().is_orthogonal()) - { + for (net.freerouting.board.Trace curr_trace : trace_list) { + if (curr_trace instanceof net.freerouting.board.PolylineTrace) { + if (!((net.freerouting.board.PolylineTrace) curr_trace).polyline().is_orthogonal()) { free_angle_traces_found = true; break; } } } - if (free_angle_traces_found) - { - java.util.ResourceBundle resources = + if (free_angle_traces_found) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowRouteParameter", current_locale); String curr_message = resources.getString("change_snap_angle_90"); - if (!WindowMessage.confirm(curr_message)) - { + if (!WindowMessage.confirm(curr_message)) { refresh(); return; } @@ -490,35 +449,27 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) board_handling.set_current_snap_angle(net.freerouting.board.AngleRestriction.NINETY_DEGREE); } } - - private class SnapAngle45Listener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - if (board_handling.get_routing_board().rules.get_trace_angle_restriction() == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE) - { + + private class SnapAngle45Listener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + if (board_handling.get_routing_board().rules.get_trace_angle_restriction() == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE) { return; } Collection trace_list = board_handling.get_routing_board().get_traces(); boolean free_angle_traces_found = false; - for (net.freerouting.board.Trace curr_trace : trace_list) - { - if (curr_trace instanceof net.freerouting.board.PolylineTrace) - { - if (!((net.freerouting.board.PolylineTrace)curr_trace).polyline().is_multiple_of_45_degree()) - { + for (net.freerouting.board.Trace curr_trace : trace_list) { + if (curr_trace instanceof net.freerouting.board.PolylineTrace) { + if (!((net.freerouting.board.PolylineTrace) curr_trace).polyline().is_multiple_of_45_degree()) { free_angle_traces_found = true; break; } } } - if (free_angle_traces_found) - { - java.util.ResourceBundle resources = + if (free_angle_traces_found) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowRouteParameter", current_locale); String curr_message = resources.getString("change_snap_angle_45"); - if (!WindowMessage.confirm(curr_message)) - { + if (!WindowMessage.confirm(curr_message)) { refresh(); return; } @@ -526,173 +477,133 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) board_handling.set_current_snap_angle(net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE); } } - - private class SnapAngleNoneListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class SnapAngleNoneListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.set_current_snap_angle(net.freerouting.board.AngleRestriction.NONE); } } - - private class DynamicRouteListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class DynamicRouteListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.set_stitch_route(false); } } - - private class StitchRouteListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class StitchRouteListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.set_stitch_route(true); } } - - private class DetailListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - if (first_time) - { + + private class DetailListener implements java.awt.event.ActionListener { + private boolean first_time = true; + + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + if (first_time) { java.awt.Point location = getLocation(); - detail_window.setLocation((int)location.getX() + 200, (int)location.getY() + 300); + detail_window.setLocation((int) location.getX() + 200, (int) location.getY() + 300); first_time = false; } detail_window.setVisible(true); } - private boolean first_time = true; } - - private class AutomaticTraceWidthListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class AutomaticTraceWidthListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { manual_rule_window.setVisible(false); board_handling.settings.set_manual_tracewidth_selection(false); } } - - private class ManualTraceWidthListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - if (first_time) - { + + private class ManualTraceWidthListener implements java.awt.event.ActionListener { + boolean first_time = true; + + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + if (first_time) { java.awt.Point location = getLocation(); - manual_rule_window.setLocation((int)location.getX() + 200, (int)location.getY() + 200); + manual_rule_window.setLocation((int) location.getX() + 200, (int) location.getY() + 200); first_time = false; } manual_rule_window.setVisible(true); board_handling.settings.set_manual_tracewidth_selection(true); } - - boolean first_time = true; } - - private class ShoveListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class ShoveListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.set_push_enabled(shove_check_box.isSelected()); refresh(); } } - - private class ViaSnapToSMDCenterListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class ViaSnapToSMDCenterListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.set_via_snap_to_smd_center(via_snap_to_smd_center_check_box.isSelected()); } } - - private class IgnoreConductionListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class IgnoreConductionListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.set_ignore_conduction(ignore_conduction_check_box.isSelected()); } } - - private class HilightObstacleListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class HilightObstacleListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.set_hilight_routing_obstacle(hilight_routing_obstacle_check_box.isSelected()); } } - - private class DragComponentListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class DragComponentListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.set_drag_components_enabled(drag_component_check_box.isSelected()); refresh(); } } - - private class NeckDownListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class NeckDownListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.set_automatic_neckdown(neckdown_check_box.isSelected()); } } - - - - private class RestrictPinExitDirectionsListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - if (restrict_pin_exit_directions_check_box.isSelected()) - { + + + private class RestrictPinExitDirectionsListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + if (restrict_pin_exit_directions_check_box.isSelected()) { net.freerouting.rules.BoardRules board_rules = board_handling.get_routing_board().rules; double edge_to_turn_dist = board_handling.coordinate_transform.board_to_user(board_rules.get_min_trace_half_width()); board_handling.set_pin_edge_to_turn_dist(edge_to_turn_dist); - } - else - { + } else { board_handling.set_pin_edge_to_turn_dist(0); } refresh(); } } - - private class EdgeToTurnDistFieldKeyListener extends java.awt.event.KeyAdapter - { - public void keyTyped(java.awt.event.KeyEvent p_evt) - { - if (p_evt.getKeyChar() == '\n') - { + + private class EdgeToTurnDistFieldKeyListener extends java.awt.event.KeyAdapter { + public void keyTyped(java.awt.event.KeyEvent p_evt) { + if (p_evt.getKeyChar() == '\n') { key_input_completed = true; Object input = edge_to_turn_dist_field.getValue(); - if (!(input instanceof Number)) - { + if (!(input instanceof Number)) { return; } - float input_value = ((Number)input).floatValue(); + float input_value = ((Number) input).floatValue(); board_handling.set_pin_edge_to_turn_dist(input_value); restrict_pin_exit_directions_check_box.setSelected(input_value > 0); refresh(); - } - else - { + } else { key_input_completed = false; } } } - - private class EdgeToTurnDistFieldFocusListener implements java.awt.event.FocusListener - { - public void focusLost(java.awt.event.FocusEvent p_evt) - { - if (!key_input_completed) - { + + private class EdgeToTurnDistFieldFocusListener implements java.awt.event.FocusListener { + public void focusLost(java.awt.event.FocusEvent p_evt) { + if (!key_input_completed) { // restore the text field. double edge_to_turn_dist = board_handling.get_routing_board().rules.get_pin_edge_to_turn_dist(); edge_to_turn_dist = board_handling.coordinate_transform.board_to_user(edge_to_turn_dist); @@ -700,56 +611,44 @@ public void focusLost(java.awt.event.FocusEvent p_evt) key_input_completed = true; } } - public void focusGained(java.awt.event.FocusEvent p_evt) - { + + public void focusGained(java.awt.event.FocusEvent p_evt) { } } - - - private class RegionWidthFieldKeyListener extends java.awt.event.KeyAdapter - { - public void keyTyped(java.awt.event.KeyEvent p_evt) - { - if (p_evt.getKeyChar() == '\n') - { + + + private class RegionWidthFieldKeyListener extends java.awt.event.KeyAdapter { + public void keyTyped(java.awt.event.KeyEvent p_evt) { + if (p_evt.getKeyChar() == '\n') { key_input_completed = true; Object input = region_width_field.getValue(); - if (!(input instanceof Number)) - { + if (!(input instanceof Number)) { return; } - int input_value = ((Number)input).intValue(); + int input_value = ((Number) input).intValue(); set_pull_tight_region_width(input_value); - } - else - { + } else { key_input_completed = false; } } } - - private class RegionWidthFieldFocusListener implements java.awt.event.FocusListener - { - public void focusLost(java.awt.event.FocusEvent p_evt) - { - if (!key_input_completed) - { + + private class RegionWidthFieldFocusListener implements java.awt.event.FocusListener { + public void focusLost(java.awt.event.FocusEvent p_evt) { + if (!key_input_completed) { // restore the text field. region_width_field.setValue(region_slider.getValue()); key_input_completed = true; } } - public void focusGained(java.awt.event.FocusEvent p_evt) - { + + public void focusGained(java.awt.event.FocusEvent p_evt) { } } - - - - private class SliderChangeListener implements javax.swing.event.ChangeListener - { - public void stateChanged(javax.swing.event.ChangeEvent evt) - { + + + private class SliderChangeListener implements javax.swing.event.ChangeListener { + public void stateChanged(javax.swing.event.ChangeEvent evt) { set_pull_tight_region_width(region_slider.getValue()); } } diff --git a/src/main/java/net/freerouting/gui/WindowRouteStubs.java b/src/main/java/net/freerouting/gui/WindowRouteStubs.java index 12e24dd0..eeb231a4 100644 --- a/src/main/java/net/freerouting/gui/WindowRouteStubs.java +++ b/src/main/java/net/freerouting/gui/WindowRouteStubs.java @@ -21,106 +21,85 @@ package net.freerouting.gui; -import java.util.Collection; -import java.util.Set; -import java.util.SortedSet; -import java.util.Iterator; - +import net.freerouting.board.Item; import net.freerouting.datastructures.Signum; import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.board.Item; +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; +import java.util.SortedSet; /** - * * @author Alfons Wirtz */ -public class WindowRouteStubs extends WindowObjectListWithFilter -{ - - /** Creates a new instance of WindowRouteStubs */ - public WindowRouteStubs(BoardFrame p_board_frame) - { +public class WindowRouteStubs extends WindowObjectListWithFilter { + + private final java.util.ResourceBundle resources; + + /** + * Creates a new instance of WindowRouteStubs + */ + public WindowRouteStubs(BoardFrame p_board_frame) { super(p_board_frame); this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.CleanupWindows", p_board_frame.get_locale()); this.setTitle(resources.getString("route_stubs")); this.list_empty_message.setText(resources.getString("no_route_stubs_found")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_RouteStubs"); } - - protected void fill_list() - { + + protected void fill_list() { net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); - + SortedSet route_stub_info_set = new java.util.TreeSet(); - + Collection board_items = routing_board.get_items(); - for (Item curr_item : board_items) - { - if (!(curr_item instanceof net.freerouting.board.Trace || curr_item instanceof net.freerouting.board.Via)) - { + for (Item curr_item : board_items) { + if (!(curr_item instanceof net.freerouting.board.Trace || curr_item instanceof net.freerouting.board.Via)) { continue; } - if (curr_item.net_count() != 1) - { + if (curr_item.net_count() != 1) { continue; } - + FloatPoint stub_location; int stub_layer; - if (curr_item instanceof net.freerouting.board.Via) - { + if (curr_item instanceof net.freerouting.board.Via) { Collection contact_list = curr_item.get_all_contacts(); - if (contact_list.isEmpty()) - { + if (contact_list.isEmpty()) { stub_layer = curr_item.first_layer(); - } - else - { + } else { Iterator it = contact_list.iterator(); Item curr_contact_item = it.next(); int first_contact_first_layer = curr_contact_item.first_layer(); int first_contact_last_layer = curr_contact_item.last_layer(); boolean all_contacts_on_one_layer = true; - while (it.hasNext()) - { + while (it.hasNext()) { curr_contact_item = it.next(); if (curr_contact_item.first_layer() != first_contact_first_layer - || curr_contact_item.last_layer() != first_contact_last_layer) - { + || curr_contact_item.last_layer() != first_contact_last_layer) { all_contacts_on_one_layer = false; break; } } - if (!all_contacts_on_one_layer) - { + if (!all_contacts_on_one_layer) { continue; } if (curr_item.first_layer() >= first_contact_first_layer && - curr_item.last_layer() <= first_contact_first_layer) - { + curr_item.last_layer() <= first_contact_first_layer) { stub_layer = first_contact_first_layer; - } - else - { + } else { stub_layer = first_contact_last_layer; } } - stub_location = ((net.freerouting.board.Via)curr_item).get_center().to_float(); - } - else - { + stub_location = ((net.freerouting.board.Via) curr_item).get_center().to_float(); + } else { net.freerouting.board.Trace curr_trace = (net.freerouting.board.Trace) curr_item; - if (curr_trace.get_start_contacts().isEmpty()) - { + if (curr_trace.get_start_contacts().isEmpty()) { stub_location = curr_trace.first_corner().to_float(); - } - else if (curr_trace.get_end_contacts().isEmpty()) - { + } else if (curr_trace.get_end_contacts().isEmpty()) { stub_location = curr_trace.last_corner().to_float(); - } - else - { + } else { continue; } stub_layer = curr_trace.get_layer(); @@ -128,57 +107,49 @@ else if (curr_trace.get_end_contacts().isEmpty()) RouteStubInfo curr_route_stub_info = new RouteStubInfo(curr_item, stub_location, stub_layer); route_stub_info_set.add(curr_route_stub_info); } - - for (RouteStubInfo curr_info : route_stub_info_set) - { + + for (RouteStubInfo curr_info : route_stub_info_set) { this.add_to_list(curr_info); } this.list.setVisibleRowCount(Math.min(route_stub_info_set.size(), DEFAULT_TABLE_SIZE)); } - - protected void select_instances() - { + + protected void select_instances() { Object[] selected_list_values = list.getSelectedValues(); - if (selected_list_values.length <= 0) - { + if (selected_list_values.length <= 0) { return; } Set selected_items = new java.util.TreeSet(); - for (int i = 0; i < selected_list_values.length; ++i) - { - selected_items.add(((RouteStubInfo)selected_list_values[i]).stub_item); + for (int i = 0; i < selected_list_values.length; ++i) { + selected_items.add(((RouteStubInfo) selected_list_values[i]).stub_item); } net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; board_handling.select_items(selected_items); board_handling.zoom_selection(); } - - private final java.util.ResourceBundle resources; - + /** * Describes information of a route stub in the list. */ - private class RouteStubInfo implements Comparable - { - public RouteStubInfo(Item p_stub, FloatPoint p_location, int p_layer_no) - { + private class RouteStubInfo implements Comparable { + private final Item stub_item; + private final net.freerouting.rules.Net net; + private final FloatPoint location; + private final int layer_no; + public RouteStubInfo(Item p_stub, FloatPoint p_location, int p_layer_no) { net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; this.stub_item = p_stub; this.location = board_handling.coordinate_transform.board_to_user(p_location); - this.layer_no = p_layer_no; + this.layer_no = p_layer_no; int net_no = p_stub.get_net_no(0); this.net = board_handling.get_routing_board().rules.nets.get(net_no); } - - public String toString() - { + + public String toString() { String item_string; - if (this.stub_item instanceof net.freerouting.board.Trace) - { + if (this.stub_item instanceof net.freerouting.board.Trace) { item_string = resources.getString("trace"); - } - else - { + } else { item_string = resources.getString("via"); } String layer_name = board_frame.board_panel.board_handling.get_routing_board().layer_structure.arr[layer_no].name; @@ -187,28 +158,19 @@ public String toString() resources.getString("on_layer") + " " + layer_name; return result; } - - public int compareTo(RouteStubInfo p_other) - { + + public int compareTo(RouteStubInfo p_other) { int result = this.net.name.compareTo(p_other.net.name); - if (result == 0) - { - result = Signum.as_int(this.location.x - p_other.location.x); + if (result == 0) { + result = Signum.as_int(this.location.x - p_other.location.x); } - if (result == 0) - { - result = Signum.as_int(this.location.y - p_other.location.y); + if (result == 0) { + result = Signum.as_int(this.location.y - p_other.location.y); } - if (result == 0) - { + if (result == 0) { result = this.layer_no - p_other.layer_no; } return result; } - - private final Item stub_item; - private final net.freerouting.rules.Net net; - private final FloatPoint location; - private final int layer_no; } } diff --git a/src/main/java/net/freerouting/gui/WindowSelectParameter.java b/src/main/java/net/freerouting/gui/WindowSelectParameter.java index c2174f65..63f44f32 100644 --- a/src/main/java/net/freerouting/gui/WindowSelectParameter.java +++ b/src/main/java/net/freerouting/gui/WindowSelectParameter.java @@ -25,22 +25,28 @@ /** * Window for the handling of the interactive selection parameters, * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class WindowSelectParameter extends BoardSavableSubWindow -{ - - /** Creates a new instance of SelectWindow */ - public WindowSelectParameter(BoardFrame p_board_frame) - { +public class WindowSelectParameter extends BoardSavableSubWindow { + + private final net.freerouting.interactive.BoardHandling board_handling; + private final javax.swing.JRadioButton[] layer_name_arr; + private final javax.swing.JCheckBox[] item_selection_choices; + private final javax.swing.JRadioButton all_visible_button; + private final javax.swing.JRadioButton current_only_button; + + /** + * Creates a new instance of SelectWindow + */ + public WindowSelectParameter(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; - - java.util.ResourceBundle resources = + + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowSelectParameter", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); - + // create main panel - + final javax.swing.JPanel main_panel = new javax.swing.JPanel(); getContentPane().add(main_panel); java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); @@ -49,21 +55,21 @@ public WindowSelectParameter(BoardFrame p_board_frame) gridbag_constraints.anchor = java.awt.GridBagConstraints.WEST; gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag_constraints.insets = new java.awt.Insets(1, 10, 1, 10); - + // Create buttongroup for the selection layers - + javax.swing.JLabel selection_layer_label = new javax.swing.JLabel(resources.getString("selection_layers")); gridbag.setConstraints(selection_layer_label, gridbag_constraints); main_panel.add(selection_layer_label); - + this.all_visible_button = new javax.swing.JRadioButton(resources.getString("all_visible")); all_visible_button.setToolTipText(resources.getString("all_visible_tooltip")); this.current_only_button = new javax.swing.JRadioButton(resources.getString("current_only")); current_only_button.setToolTipText(resources.getString("current_only_tooltip")); - + all_visible_button.addActionListener(new AllVisibleListener()); current_only_button.addActionListener(new CurrentOnlyListener()); - + javax.swing.ButtonGroup selection_layer_button_group = new javax.swing.ButtonGroup(); selection_layer_button_group.add(all_visible_button); selection_layer_button_group.add(current_only_button); @@ -72,47 +78,45 @@ public WindowSelectParameter(BoardFrame p_board_frame) main_panel.add(all_visible_button, gridbag_constraints); gridbag.setConstraints(current_only_button, gridbag_constraints); main_panel.add(current_only_button, gridbag_constraints); - + javax.swing.JLabel separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + // Create check boxes for selectable items: - + javax.swing.JLabel selectable_items_label = new javax.swing.JLabel(resources.getString("selectable_items")); gridbag.setConstraints(selectable_items_label, gridbag_constraints); main_panel.add(selectable_items_label); - + final ItemSelectionFilter.SelectableChoices[] filter_values = ItemSelectionFilter.SelectableChoices.values(); - - this.item_selection_choices = new javax.swing.JCheckBox [filter_values.length]; - - for (int i = 0; i < filter_values.length; ++i) - { + + this.item_selection_choices = new javax.swing.JCheckBox[filter_values.length]; + + for (int i = 0; i < filter_values.length; ++i) { this.item_selection_choices[i] = new javax.swing.JCheckBox(resources.getString(filter_values[i].toString())); gridbag.setConstraints(this.item_selection_choices[i], gridbag_constraints); main_panel.add(this.item_selection_choices[i], gridbag_constraints); this.item_selection_choices[i].addActionListener(new ItemSelectionListener(i)); } - + javax.swing.JLabel separator2 = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator2, gridbag_constraints); main_panel.add(separator2, gridbag_constraints); - + // Create buttongroup for the current layer: - + net.freerouting.board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; int signal_layer_count = layer_structure.signal_layer_count(); javax.swing.JLabel current_layer_label = new javax.swing.JLabel(resources.getString("current_layer")); current_layer_label.setToolTipText(resources.getString("current_layer_tooltip")); gridbag.setConstraints(current_layer_label, gridbag_constraints); main_panel.add(current_layer_label); - - this.layer_name_arr = new javax.swing.JRadioButton [signal_layer_count]; + + this.layer_name_arr = new javax.swing.JRadioButton[signal_layer_count]; javax.swing.ButtonGroup current_layer_button_group = new javax.swing.ButtonGroup(); gridbag_constraints.gridheight = 1; - for (int i = 0; i < signal_layer_count; ++i) - { + for (int i = 0; i < signal_layer_count; ++i) { net.freerouting.board.Layer curr_signal_layer = layer_structure.get_signal_layer(i); layer_name_arr[i] = new javax.swing.JRadioButton(); layer_name_arr[i].setText(curr_signal_layer.name); @@ -125,131 +129,98 @@ public WindowSelectParameter(BoardFrame p_board_frame) javax.swing.JLabel empty_label = new javax.swing.JLabel(); gridbag.setConstraints(empty_label, gridbag_constraints); main_panel.add(empty_label); - + p_board_frame.set_context_sensitive_help(this, "WindowSelectParameter"); - + this.refresh(); this.pack(); this.setResizable(false); } - + /** * Refreshs the displayed values in this window. */ - public void refresh() - { - if (this.board_handling.settings.get_select_on_all_visible_layers()) - { + public void refresh() { + if (this.board_handling.settings.get_select_on_all_visible_layers()) { all_visible_button.setSelected(true); - } - else - { + } else { current_only_button.setSelected(true); } ItemSelectionFilter item_selection_filter = this.board_handling.settings.get_item_selection_filter(); - if (item_selection_filter == null) - { + if (item_selection_filter == null) { System.out.println("SelectParameterWindow.refresh: item_selection_filter is null"); - } - else - { + } else { final ItemSelectionFilter.SelectableChoices[] filter_values = ItemSelectionFilter.SelectableChoices.values(); - for (int i = 0; i < filter_values.length; ++i) - { - this.item_selection_choices[i].setSelected(item_selection_filter.is_selected(filter_values[i])) ; + for (int i = 0; i < filter_values.length; ++i) { + this.item_selection_choices[i].setSelected(item_selection_filter.is_selected(filter_values[i])); } } net.freerouting.board.LayerStructure layer_structure = this.board_handling.get_routing_board().layer_structure; net.freerouting.board.Layer current_layer = layer_structure.arr[this.board_handling.settings.get_layer()]; layer_name_arr[layer_structure.get_signal_layer_no(current_layer)].setSelected(true); } - + /** * Selects the layer with the input signal number. */ - public void select(int p_signal_layer_no) - { + public void select(int p_signal_layer_no) { layer_name_arr[p_signal_layer_no].setSelected(true); } - - private final net.freerouting.interactive.BoardHandling board_handling; - - private final javax.swing.JRadioButton [] layer_name_arr; - - private final javax.swing.JCheckBox [] item_selection_choices; - - private final javax.swing.JRadioButton all_visible_button; - - private final javax.swing.JRadioButton current_only_button; - - private class CurrentLayerListener implements java.awt.event.ActionListener - { - public CurrentLayerListener(int p_signal_layer_no, int p_layer_no) - { + + private class CurrentLayerListener implements java.awt.event.ActionListener { + public final int signal_layer_no; + public final int layer_no; + + public CurrentLayerListener(int p_signal_layer_no, int p_layer_no) { signal_layer_no = p_signal_layer_no; layer_no = p_layer_no; } - - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.set_current_layer(layer_no); } - - public final int signal_layer_no; - public final int layer_no; } - - private class AllVisibleListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class AllVisibleListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.set_select_on_all_visible_layers(true); } } - - private class CurrentOnlyListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class CurrentOnlyListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.set_select_on_all_visible_layers(false); } } - - private class ItemSelectionListener implements java.awt.event.ActionListener - { - public ItemSelectionListener(int p_item_no) - { + + private class ItemSelectionListener implements java.awt.event.ActionListener { + private final int item_no; + + public ItemSelectionListener(int p_item_no) { item_no = p_item_no; } - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + public void actionPerformed(java.awt.event.ActionEvent p_evt) { boolean is_selected = item_selection_choices[item_no].isSelected(); - + ItemSelectionFilter.SelectableChoices item_type = ItemSelectionFilter.SelectableChoices.values()[item_no]; - + board_handling.set_selectable(item_type, is_selected); - + // make shure that from fixed and unfixed items at least one type is selected. - if (item_type == ItemSelectionFilter.SelectableChoices.FIXED) - { + if (item_type == ItemSelectionFilter.SelectableChoices.FIXED) { int unfixed_no = ItemSelectionFilter.SelectableChoices.UNFIXED.ordinal(); - if (!is_selected && ! item_selection_choices[unfixed_no].isSelected()) - { + if (!is_selected && !item_selection_choices[unfixed_no].isSelected()) { item_selection_choices[unfixed_no].setSelected(true); board_handling.set_selectable(ItemSelectionFilter.SelectableChoices.UNFIXED, true); } - } - else if (item_type == ItemSelectionFilter.SelectableChoices.UNFIXED) - { + } else if (item_type == ItemSelectionFilter.SelectableChoices.UNFIXED) { int fixed_no = ItemSelectionFilter.SelectableChoices.FIXED.ordinal(); - if (!is_selected && ! item_selection_choices[fixed_no].isSelected()) - { + if (!is_selected && !item_selection_choices[fixed_no].isSelected()) { item_selection_choices[fixed_no].setSelected(true); board_handling.set_selectable(ItemSelectionFilter.SelectableChoices.FIXED, true); } } } - - private final int item_no; } } diff --git a/src/main/java/net/freerouting/gui/WindowSnapshot.java b/src/main/java/net/freerouting/gui/WindowSnapshot.java index bd128893..03b510b1 100644 --- a/src/main/java/net/freerouting/gui/WindowSnapshot.java +++ b/src/main/java/net/freerouting/gui/WindowSnapshot.java @@ -23,55 +23,60 @@ /** * Window handling snapshots of the interactive situation. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class WindowSnapshot extends BoardSavableSubWindow -{ - - /** Creates a new instance of SnapshotFrame */ - public WindowSnapshot(BoardFrame p_board_frame) - { +public class WindowSnapshot extends BoardSavableSubWindow { + + final WindowSnapshotSettings settings_window; + private final BoardFrame board_frame; + private final javax.swing.JList list; + private final javax.swing.JTextField name_field; + private final java.util.ResourceBundle resources; + private javax.swing.DefaultListModel list_model = new javax.swing.DefaultListModel(); + private int snapshot_count = 0; + + /** + * Creates a new instance of SnapshotFrame + */ + public WindowSnapshot(BoardFrame p_board_frame) { this.board_frame = p_board_frame; this.settings_window = new WindowSnapshotSettings(p_board_frame); this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowSnapshot", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); - - this.setDefaultCloseOperation(DISPOSE_ON_CLOSE ); - + + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + // create main panel final javax.swing.JPanel main_panel = new javax.swing.JPanel(); getContentPane().add(main_panel); main_panel.setLayout(new java.awt.BorderLayout()); - - + + // create goto button javax.swing.JButton goto_button = new javax.swing.JButton(resources.getString("goto_snapshot")); goto_button.setToolTipText(resources.getString("goto_tooltip")); GotoListener goto_listener = new GotoListener(); goto_button.addActionListener(goto_listener); main_panel.add(goto_button, java.awt.BorderLayout.NORTH); - + // create snapshot list this.list = new javax.swing.JList(this.list_model); this.list.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); this.list.setSelectedIndex(0); this.list.setVisibleRowCount(5); - this.list.addMouseListener(new java.awt.event.MouseAdapter() - { - public void mouseClicked(java.awt.event.MouseEvent evt) - { - if (evt.getClickCount() > 1) - { + this.list.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + if (evt.getClickCount() > 1) { goto_selected(); } } }); - - + + javax.swing.JScrollPane list_scroll_pane = new javax.swing.JScrollPane(this.list); list_scroll_pane.setPreferredSize(new java.awt.Dimension(200, 100)); main_panel.add(list_scroll_pane, java.awt.BorderLayout.CENTER); - + // create the south panel final javax.swing.JPanel south_panel = new javax.swing.JPanel(); main_panel.add(south_panel, java.awt.BorderLayout.SOUTH); @@ -79,35 +84,35 @@ public void mouseClicked(java.awt.event.MouseEvent evt) south_panel.setLayout(gridbag); java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; - + // create panel to add a new snapshot final javax.swing.JPanel add_panel = new javax.swing.JPanel(); gridbag.setConstraints(add_panel, gridbag_constraints); add_panel.setLayout(new java.awt.BorderLayout()); south_panel.add(add_panel); - + javax.swing.JButton add_button = new javax.swing.JButton(resources.getString("create")); AddListener add_listener = new AddListener(); add_button.addActionListener(add_listener); add_panel.add(add_button, java.awt.BorderLayout.WEST); - + this.name_field = new javax.swing.JTextField(10); name_field.setText(resources.getString("snapshot") + " 1"); add_panel.add(name_field, java.awt.BorderLayout.EAST); - + // create delete buttons javax.swing.JButton delete_button = new javax.swing.JButton(resources.getString("remove")); DeleteListener delete_listener = new DeleteListener(); delete_button.addActionListener(delete_listener); gridbag.setConstraints(delete_button, gridbag_constraints); south_panel.add(delete_button); - + javax.swing.JButton delete_all_button = new javax.swing.JButton(resources.getString("remove_all")); DeleteAllListener delete_all_listener = new DeleteAllListener(); delete_all_button.addActionListener(delete_all_listener); gridbag.setConstraints(delete_all_button, gridbag_constraints); south_panel.add(delete_all_button); - + // create button for the snapshot settings javax.swing.JButton settings_button = new javax.swing.JButton(resources.getString("settings")); settings_button.setToolTipText(resources.getString("settings_tooltip")); @@ -115,38 +120,33 @@ public void mouseClicked(java.awt.event.MouseEvent evt) settings_button.addActionListener(settings_listener); gridbag.setConstraints(delete_all_button, gridbag_constraints); south_panel.add(settings_button); - + p_board_frame.set_context_sensitive_help(this, "WindowSnapshots"); - + this.pack(); } - - public void dispose() - { + + public void dispose() { settings_window.dispose(); super.dispose(); } - - public void parent_iconified() - { + + public void parent_iconified() { settings_window.parent_iconified(); super.parent_iconified(); } - - public void parent_deiconified() - { + + public void parent_deiconified() { settings_window.parent_deiconified(); super.parent_deiconified(); } - + /** * Reads the data of this frame from disk. * Returns false, if the reading failed. */ - public boolean read(java.io.ObjectInputStream p_object_stream) - { - try - { + public boolean read(java.io.ObjectInputStream p_object_stream) { + try { SavedAttributes saved_attributes = (SavedAttributes) p_object_stream.readObject(); this.snapshot_count = saved_attributes.snapshot_count; this.list_model = saved_attributes.list_model; @@ -157,56 +157,45 @@ public boolean read(java.io.ObjectInputStream p_object_stream) this.setVisible(saved_attributes.is_visible); this.settings_window.read(p_object_stream); return true; - } - catch (Exception e) - { + } catch (Exception e) { System.out.println("VisibilityFrame.read_attriutes: read failed"); return false; } } - + /** * Saves this frame to disk. */ - public void save(java.io.ObjectOutputStream p_object_stream) - { + public void save(java.io.ObjectOutputStream p_object_stream) { SavedAttributes saved_attributes = new SavedAttributes(this.list_model, this.snapshot_count, this.getLocation(), this.isVisible()); - try - { + try { p_object_stream.writeObject(saved_attributes); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("VisibilityFrame.save_attriutes: save failed"); } this.settings_window.save(p_object_stream); } - - void goto_selected() - { + + void goto_selected() { int index = list.getSelectedIndex(); - if (index >= 0 && list_model.getSize() > index) - { + if (index >= 0 && list_model.getSize() > index) { net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; - net.freerouting.interactive.SnapShot curr_snapshot = (net.freerouting.interactive.SnapShot) list_model.elementAt(index); - + net.freerouting.interactive.SnapShot curr_snapshot = (net.freerouting.interactive.SnapShot) list_model.elementAt(index); + curr_snapshot.go_to(board_handling); - - if (curr_snapshot.settings.get_snapshot_attributes().object_colors) - { + + if (curr_snapshot.settings.get_snapshot_attributes().object_colors) { board_handling.graphics_context.item_color_table = new net.freerouting.boardgraphics.ItemColorTableModel(curr_snapshot.graphics_context.item_color_table); board_handling.graphics_context.other_color_table = new net.freerouting.boardgraphics.OtherColorTableModel(curr_snapshot.graphics_context.other_color_table); - + board_frame.color_manager.set_table_models(board_handling.graphics_context); } - - if (curr_snapshot.settings.get_snapshot_attributes().display_region) - { + + if (curr_snapshot.settings.get_snapshot_attributes().display_region) { java.awt.Point viewport_position = curr_snapshot.copy_viewport_position(); - if (viewport_position != null) - { + if (viewport_position != null) { board_handling.graphics_context.coordinate_transform = new net.freerouting.boardgraphics.CoordinateTransform(curr_snapshot.graphics_context.coordinate_transform); java.awt.Dimension panel_size = board_handling.graphics_context.get_panel_size(); board_frame.board_panel.setSize(panel_size); @@ -214,143 +203,112 @@ void goto_selected() board_frame.board_panel.set_viewport_position(viewport_position); } } - + board_frame.refresh_windows(); board_frame.hilight_selected_button(); board_frame.setVisible(true); board_frame.repaint(); } } - + /** * Refreshs the displayed values in this window. */ - public void refresh() - { + public void refresh() { this.settings_window.refresh(); } - - private final BoardFrame board_frame; - - private javax.swing.DefaultListModel list_model = new javax.swing.DefaultListModel(); - private final javax.swing.JList list; - private final javax.swing.JTextField name_field; - final WindowSnapshotSettings settings_window; - private int snapshot_count = 0; - private final java.util.ResourceBundle resources; - - private class AddListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - net.freerouting.interactive.SnapShot new_snapshot = net.freerouting.interactive.SnapShot.get_instance(name_field.getText(), board_frame.board_panel.board_handling); - if (new_snapshot != null) - { - ++snapshot_count; - list_model.addElement(new_snapshot); - String next_default_name = resources.getString("snapshot") + " " + (new Integer(snapshot_count + 1)).toString(); - name_field.setText(next_default_name); - } - } - } - + /** * Selects the item, which is previous to the current selected item in the list. * The current selected item is then no more selected. */ - public void select_previous_item() - { - if (!this.isVisible()) - { + public void select_previous_item() { + if (!this.isVisible()) { return; } int selected_index = this.list.getSelectedIndex(); - if (selected_index <= 0) - { + if (selected_index <= 0) { return; } this.list.setSelectedIndex(selected_index - 1); } - + /** * Selects the item, which is next to the current selected item in the list. * The current selected item is then no more selected. */ - public void select_next_item() - { - if (!this.isVisible()) - { + public void select_next_item() { + if (!this.isVisible()) { return; } int selected_index = this.list.getSelectedIndex(); - if (selected_index < 0 || selected_index >= this.list_model.getSize() - 1) - { + if (selected_index < 0 || selected_index >= this.list_model.getSize() - 1) { return; } - + this.list.setSelectedIndex(selected_index + 1); } - - private class DeleteListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + /** + * Type for attributes of this class, which are saved to an Objectstream. + */ + static private class SavedAttributes implements java.io.Serializable { + public final javax.swing.DefaultListModel list_model; + public final int snapshot_count; + public final java.awt.Point location; + public final boolean is_visible; + public SavedAttributes(javax.swing.DefaultListModel p_list_model, int p_snapshot_count, java.awt.Point p_location, boolean p_is_visible) { + list_model = p_list_model; + snapshot_count = p_snapshot_count; + location = p_location; + is_visible = p_is_visible; + + } + } + + private class AddListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + net.freerouting.interactive.SnapShot new_snapshot = net.freerouting.interactive.SnapShot.get_instance(name_field.getText(), board_frame.board_panel.board_handling); + if (new_snapshot != null) { + ++snapshot_count; + list_model.addElement(new_snapshot); + String next_default_name = resources.getString("snapshot") + " " + (new Integer(snapshot_count + 1)).toString(); + name_field.setText(next_default_name); + } + } + } + + private class DeleteListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { Object selected_snapshot = list.getSelectedValue(); - if (selected_snapshot != null) - { + if (selected_snapshot != null) { list_model.removeElement(selected_snapshot); } } } - - private class DeleteAllListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class DeleteAllListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { list_model.removeAllElements(); } } - - private class GotoListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class GotoListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { goto_selected(); } } - - private class SettingsListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { - if (first_time) - { + + private class SettingsListener implements java.awt.event.ActionListener { + boolean first_time = true; + + public void actionPerformed(java.awt.event.ActionEvent p_evt) { + if (first_time) { java.awt.Point location = getLocation(); - settings_window.setLocation((int)location.getX() + 200, (int)location.getY()); + settings_window.setLocation((int) location.getX() + 200, (int) location.getY()); first_time = false; } settings_window.setVisible(true); } - boolean first_time = true; - } - - /** - * Type for attributes of this class, which are saved to an Objectstream. - */ - static private class SavedAttributes implements java.io.Serializable - { - public SavedAttributes(javax.swing.DefaultListModel p_list_model, int p_snapshot_count, java.awt.Point p_location, boolean p_is_visible) - { - list_model = p_list_model; - snapshot_count = p_snapshot_count; - location = p_location; - is_visible = p_is_visible; - - } - - public final javax.swing.DefaultListModel list_model; - public final int snapshot_count; - public final java.awt.Point location; - public final boolean is_visible; } } diff --git a/src/main/java/net/freerouting/gui/WindowSnapshotSettings.java b/src/main/java/net/freerouting/gui/WindowSnapshotSettings.java index e4d54d0a..a6a4f4cb 100644 --- a/src/main/java/net/freerouting/gui/WindowSnapshotSettings.java +++ b/src/main/java/net/freerouting/gui/WindowSnapshotSettings.java @@ -26,20 +26,36 @@ * * @author Alfons Wirtz */ -public class WindowSnapshotSettings extends BoardSavableSubWindow -{ - - /** Creates a new instance of WindowSnapshotSettings */ - public WindowSnapshotSettings(BoardFrame p_board_frame) - { +public class WindowSnapshotSettings extends BoardSavableSubWindow { + + final javax.swing.JCheckBox object_color_check_box; + final javax.swing.JCheckBox object_visibility_check_box; + final javax.swing.JCheckBox layer_visibility_check_box; + final javax.swing.JCheckBox display_region_check_box; + final javax.swing.JCheckBox interactive_state_check_box; + final javax.swing.JCheckBox selection_layers_check_box; + final javax.swing.JCheckBox selectable_items_check_box; + final javax.swing.JCheckBox current_layer_check_box; + final javax.swing.JCheckBox rule_selection_check_box; + final javax.swing.JCheckBox manual_rule_settings_check_box; + final javax.swing.JCheckBox push_and_shove_enabled_check_box; + final javax.swing.JCheckBox drag_components_enabled_check_box; + final javax.swing.JCheckBox pull_tight_region_check_box; + final javax.swing.JCheckBox component_grid_check_box; + final javax.swing.JCheckBox info_list_filter_check_box; + private final net.freerouting.interactive.BoardHandling board_handling; + /** + * Creates a new instance of WindowSnapshotSettings + */ + public WindowSnapshotSettings(BoardFrame p_board_frame) { this.board_handling = p_board_frame.board_panel.board_handling; - - java.util.ResourceBundle resources = + + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowSnapshotSettings", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); - + // create main panel - + final javax.swing.JPanel main_panel = new javax.swing.JPanel(); getContentPane().add(main_panel); java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); @@ -48,151 +64,150 @@ public WindowSnapshotSettings(BoardFrame p_board_frame) gridbag_constraints.anchor = java.awt.GridBagConstraints.WEST; gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag_constraints.insets = new java.awt.Insets(1, 10, 1, 10); - + // add check box for the object colors - + this.object_color_check_box = new javax.swing.JCheckBox(resources.getString("object_colors")); gridbag.setConstraints(object_color_check_box, gridbag_constraints); main_panel.add(object_color_check_box, gridbag_constraints); this.object_color_check_box.addActionListener(new ObjectColorListener()); - + // add check box for the object visibility - + this.object_visibility_check_box = new javax.swing.JCheckBox(resources.getString("object_visibility")); gridbag.setConstraints(object_visibility_check_box, gridbag_constraints); main_panel.add(object_visibility_check_box, gridbag_constraints); this.object_visibility_check_box.addActionListener(new ObjectVisibilityListener()); - + // add check box for the layer visibility - + this.layer_visibility_check_box = new javax.swing.JCheckBox(resources.getString("layer_visibility")); gridbag.setConstraints(layer_visibility_check_box, gridbag_constraints); main_panel.add(layer_visibility_check_box, gridbag_constraints); this.layer_visibility_check_box.addActionListener(new LayerVisibilityListener()); - + // add check box for display region - + this.display_region_check_box = new javax.swing.JCheckBox(resources.getString("display_region")); gridbag.setConstraints(display_region_check_box, gridbag_constraints); main_panel.add(display_region_check_box, gridbag_constraints); this.display_region_check_box.addActionListener(new DisplayRegionListener()); - + javax.swing.JLabel separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - - + + // add check box for the interactive state - + this.interactive_state_check_box = new javax.swing.JCheckBox(resources.getString("interactive_state")); gridbag.setConstraints(interactive_state_check_box, gridbag_constraints); main_panel.add(interactive_state_check_box, gridbag_constraints); this.interactive_state_check_box.addActionListener(new InteractiveStateListener()); - + separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - - + + // add check box for the selection layers - + this.selection_layers_check_box = new javax.swing.JCheckBox(resources.getString("selection_layers")); gridbag.setConstraints(selection_layers_check_box, gridbag_constraints); main_panel.add(selection_layers_check_box, gridbag_constraints); this.selection_layers_check_box.addActionListener(new SelectionLayersListener()); - - + + // add check box for the selectable items - + this.selectable_items_check_box = new javax.swing.JCheckBox(resources.getString("selectable_items")); gridbag.setConstraints(selectable_items_check_box, gridbag_constraints); main_panel.add(selectable_items_check_box, gridbag_constraints); this.selectable_items_check_box.addActionListener(new SelectableItemsListener()); - - + + // add check box for the current layer - + this.current_layer_check_box = new javax.swing.JCheckBox(resources.getString("current_layer")); gridbag.setConstraints(current_layer_check_box, gridbag_constraints); main_panel.add(current_layer_check_box, gridbag_constraints); this.current_layer_check_box.addActionListener(new CurrentLayerListener()); - + separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - - + + // add check box for the rule selection - + this.rule_selection_check_box = new javax.swing.JCheckBox(resources.getString("rule_selection")); gridbag.setConstraints(rule_selection_check_box, gridbag_constraints); main_panel.add(rule_selection_check_box, gridbag_constraints); this.rule_selection_check_box.addActionListener(new RuleSelectionListener()); - - + + // add check box for the manual rule settings - + this.manual_rule_settings_check_box = new javax.swing.JCheckBox(resources.getString("manual_rule_settings")); gridbag.setConstraints(manual_rule_settings_check_box, gridbag_constraints); main_panel.add(manual_rule_settings_check_box, gridbag_constraints); this.manual_rule_settings_check_box.addActionListener(new ManualRuleSettingsListener()); - + // add check box for push and shove enabled - + this.push_and_shove_enabled_check_box = new javax.swing.JCheckBox(resources.getString("push&shove_enabled")); gridbag.setConstraints(push_and_shove_enabled_check_box, gridbag_constraints); main_panel.add(push_and_shove_enabled_check_box, gridbag_constraints); this.push_and_shove_enabled_check_box.addActionListener(new PushAndShoveEnabledListener()); - + // add check box for drag components enabled - + this.drag_components_enabled_check_box = new javax.swing.JCheckBox(resources.getString("drag_components_enabled")); gridbag.setConstraints(drag_components_enabled_check_box, gridbag_constraints); main_panel.add(drag_components_enabled_check_box, gridbag_constraints); this.drag_components_enabled_check_box.addActionListener(new DragComponentsEnabledListener()); - + // add check box for the pull tight region - + this.pull_tight_region_check_box = new javax.swing.JCheckBox(resources.getString("pull_tight_region")); gridbag.setConstraints(pull_tight_region_check_box, gridbag_constraints); main_panel.add(pull_tight_region_check_box, gridbag_constraints); this.pull_tight_region_check_box.addActionListener(new PullTightRegionListener()); - + separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + // add check box for the component grid - + this.component_grid_check_box = new javax.swing.JCheckBox(resources.getString("component_grid")); gridbag.setConstraints(component_grid_check_box, gridbag_constraints); main_panel.add(component_grid_check_box, gridbag_constraints); this.component_grid_check_box.addActionListener(new ComponentGridListener()); - + separator = new javax.swing.JLabel(" ---------------------------------------- "); gridbag.setConstraints(separator, gridbag_constraints); main_panel.add(separator, gridbag_constraints); - + // add check box for the info list filters - + this.info_list_filter_check_box = new javax.swing.JCheckBox(resources.getString("info_list_selections")); gridbag.setConstraints(info_list_filter_check_box, gridbag_constraints); main_panel.add(info_list_filter_check_box, gridbag_constraints); this.info_list_filter_check_box.addActionListener(new InfoListFilterListener()); - + p_board_frame.set_context_sensitive_help(this, "WindowSnapshots_SnapshotSettings"); - - + + this.refresh(); this.pack(); this.setResizable(false); } - + /** * Recalculates all displayed values */ - public void refresh() - { + public void refresh() { net.freerouting.interactive.SnapShot.Attributes attributes = this.board_handling.settings.get_snapshot_attributes(); this.object_color_check_box.setSelected(attributes.object_colors); this.object_visibility_check_box.setSelected(attributes.object_visibility); @@ -210,142 +225,94 @@ public void refresh() this.component_grid_check_box.setSelected(attributes.component_grid); info_list_filter_check_box.setSelected(attributes.info_list_selections); } - - private final net.freerouting.interactive.BoardHandling board_handling; - - final javax.swing.JCheckBox object_color_check_box; - final javax.swing.JCheckBox object_visibility_check_box; - final javax.swing.JCheckBox layer_visibility_check_box; - final javax.swing.JCheckBox display_region_check_box; - final javax.swing.JCheckBox interactive_state_check_box; - final javax.swing.JCheckBox selection_layers_check_box; - final javax.swing.JCheckBox selectable_items_check_box; - final javax.swing.JCheckBox current_layer_check_box; - final javax.swing.JCheckBox rule_selection_check_box; - final javax.swing.JCheckBox manual_rule_settings_check_box; - final javax.swing.JCheckBox push_and_shove_enabled_check_box; - final javax.swing.JCheckBox drag_components_enabled_check_box; - final javax.swing.JCheckBox pull_tight_region_check_box; - final javax.swing.JCheckBox component_grid_check_box; - final javax.swing.JCheckBox info_list_filter_check_box; - - private class ObjectColorListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class ObjectColorListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().object_colors = object_color_check_box.isSelected(); } } - - private class ObjectVisibilityListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class ObjectVisibilityListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().object_visibility = object_visibility_check_box.isSelected(); } } - - - private class LayerVisibilityListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + + private class LayerVisibilityListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().layer_visibility = layer_visibility_check_box.isSelected(); } } - - private class DisplayRegionListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class DisplayRegionListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().display_region = display_region_check_box.isSelected(); } } - - private class InteractiveStateListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class InteractiveStateListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().interactive_state = interactive_state_check_box.isSelected(); } } - - private class SelectionLayersListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class SelectionLayersListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().selection_layers = selection_layers_check_box.isSelected(); } } - - private class SelectableItemsListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class SelectableItemsListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().selectable_items = selectable_items_check_box.isSelected(); } } - - private class CurrentLayerListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class CurrentLayerListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().current_layer = current_layer_check_box.isSelected(); } } - - private class RuleSelectionListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class RuleSelectionListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().rule_selection = rule_selection_check_box.isSelected(); } } - - private class ManualRuleSettingsListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class ManualRuleSettingsListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().manual_rule_settings = manual_rule_settings_check_box.isSelected(); } } - - private class PushAndShoveEnabledListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class PushAndShoveEnabledListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().push_and_shove_enabled = push_and_shove_enabled_check_box.isSelected(); } } - - private class DragComponentsEnabledListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class DragComponentsEnabledListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().drag_components_enabled = drag_components_enabled_check_box.isSelected(); } } - - private class PullTightRegionListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class PullTightRegionListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().pull_tight_region = pull_tight_region_check_box.isSelected(); } } - - private class ComponentGridListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class ComponentGridListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().component_grid = component_grid_check_box.isSelected(); } } - - private class InfoListFilterListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class InfoListFilterListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_handling.settings.get_snapshot_attributes().info_list_selections = info_list_filter_check_box.isSelected(); } } diff --git a/src/main/java/net/freerouting/gui/WindowUnconnectedRoute.java b/src/main/java/net/freerouting/gui/WindowUnconnectedRoute.java index cb22183e..31c4b86a 100644 --- a/src/main/java/net/freerouting/gui/WindowUnconnectedRoute.java +++ b/src/main/java/net/freerouting/gui/WindowUnconnectedRoute.java @@ -21,157 +21,131 @@ package net.freerouting.gui; +import net.freerouting.board.Item; + import java.util.Collection; import java.util.Set; import java.util.SortedSet; -import net.freerouting.board.Item; - /** - * * @author Alfons Wirtz */ -public class WindowUnconnectedRoute extends WindowObjectListWithFilter -{ - - /** Creates a new instance of WindowUnconnectedRoute */ - public WindowUnconnectedRoute(BoardFrame p_board_frame) - { +public class WindowUnconnectedRoute extends WindowObjectListWithFilter { + + private final java.util.ResourceBundle resources; + private int max_unconnected_route_info_id_no = 0; + + /** + * Creates a new instance of WindowUnconnectedRoute + */ + public WindowUnconnectedRoute(BoardFrame p_board_frame) { super(p_board_frame); this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.CleanupWindows", p_board_frame.get_locale()); this.setTitle(resources.getString("unconnected_route")); this.list_empty_message.setText(resources.getString("no_unconnected_route_found")); p_board_frame.set_context_sensitive_help(this, "WindowObjectList_UnconnectedRoute"); } - - protected void fill_list() - { + + protected void fill_list() { net.freerouting.board.BasicBoard routing_board = this.board_frame.board_panel.board_handling.get_routing_board(); - + Set handled_items = new java.util.TreeSet(); - + SortedSet unconnected_route_info_set = new java.util.TreeSet(); - + Collection board_items = routing_board.get_items(); - for (Item curr_item : board_items) - { - if (!(curr_item instanceof net.freerouting.board.Trace || curr_item instanceof net.freerouting.board.Via)) - { + for (Item curr_item : board_items) { + if (!(curr_item instanceof net.freerouting.board.Trace || curr_item instanceof net.freerouting.board.Via)) { continue; } - if (handled_items.contains(curr_item)) - { + if (handled_items.contains(curr_item)) { continue; } Collection curr_connected_set = curr_item.get_connected_set(-1); boolean terminal_item_found = false; - for (Item curr_connnected_item : curr_connected_set) - { + for (Item curr_connnected_item : curr_connected_set) { handled_items.add(curr_connnected_item); - if (!(curr_connnected_item instanceof net.freerouting.board.Trace || curr_connnected_item instanceof net.freerouting.board.Via)) - { + if (!(curr_connnected_item instanceof net.freerouting.board.Trace || curr_connnected_item instanceof net.freerouting.board.Via)) { terminal_item_found = true; } } - if (!terminal_item_found) - { + if (!terminal_item_found) { // We have found unconnnected route - if (curr_item.net_count() == 1) - { + if (curr_item.net_count() == 1) { net.freerouting.rules.Net curr_net = routing_board.rules.nets.get(curr_item.get_net_no(0)); - if (curr_net != null) - { + if (curr_net != null) { UnconnectedRouteInfo curr_unconnected_route_info = new UnconnectedRouteInfo(curr_net, curr_connected_set); unconnected_route_info_set.add(curr_unconnected_route_info); } - } - else - { + } else { System.out.println("WindowUnconnectedRoute.fill_list: net_count 1 expected"); } } } - - for (UnconnectedRouteInfo curr_info : unconnected_route_info_set) - { + + for (UnconnectedRouteInfo curr_info : unconnected_route_info_set) { this.add_to_list(curr_info); } this.list.setVisibleRowCount(Math.min(unconnected_route_info_set.size(), DEFAULT_TABLE_SIZE)); } - - protected void select_instances() - { + + protected void select_instances() { Object[] selected_list_values = list.getSelectedValues(); - if (selected_list_values.length <= 0) - { + if (selected_list_values.length <= 0) { return; } Set selected_items = new java.util.TreeSet(); - for (int i = 0; i < selected_list_values.length; ++i) - { - selected_items.addAll(((UnconnectedRouteInfo)selected_list_values[i]).item_list); + for (int i = 0; i < selected_list_values.length; ++i) { + selected_items.addAll(((UnconnectedRouteInfo) selected_list_values[i]).item_list); } net.freerouting.interactive.BoardHandling board_handling = board_frame.board_panel.board_handling; board_handling.select_items(selected_items); board_handling.zoom_selection(); } - - private final java.util.ResourceBundle resources; - private int max_unconnected_route_info_id_no = 0; - + /** * Describes information of a connected set of unconnected traces and vias. */ - private class UnconnectedRouteInfo implements Comparable - { - public UnconnectedRouteInfo(net.freerouting.rules.Net p_net, Collection p_item_list) - { + private class UnconnectedRouteInfo implements Comparable { + private final net.freerouting.rules.Net net; + private final Collection item_list; + private final int id_no; + private final Integer trace_count; + private final Integer via_count; + public UnconnectedRouteInfo(net.freerouting.rules.Net p_net, Collection p_item_list) { this.net = p_net; this.item_list = p_item_list; ++max_unconnected_route_info_id_no; this.id_no = max_unconnected_route_info_id_no; int curr_trace_count = 0; int curr_via_count = 0; - for (Item curr_item: p_item_list) - { - if (curr_item instanceof net.freerouting.board.Trace) - { + for (Item curr_item : p_item_list) { + if (curr_item instanceof net.freerouting.board.Trace) { ++curr_trace_count; - } - else if (curr_item instanceof net.freerouting.board.Via) - { + } else if (curr_item instanceof net.freerouting.board.Via) { ++curr_via_count; } } this.trace_count = curr_trace_count; this.via_count = curr_via_count; } - - public String toString() - { - - String result = resources.getString("net") + " " + this.net.name + ": " + + public String toString() { + + String result = resources.getString("net") + " " + this.net.name + ": " + resources.getString("trace_count") + " " + this.trace_count.toString() + ", " + resources.getString("via_count") + " " + this.via_count.toString(); - + return result; } - - public int compareTo(UnconnectedRouteInfo p_other) - { + + public int compareTo(UnconnectedRouteInfo p_other) { int result = this.net.name.compareTo(p_other.net.name); - if (result == 0) - { + if (result == 0) { result = this.id_no - p_other.id_no; } return result; } - - private final net.freerouting.rules.Net net; - private final Collection item_list; - private final int id_no; - private final Integer trace_count; - private final Integer via_count; } } diff --git a/src/main/java/net/freerouting/gui/WindowVia.java b/src/main/java/net/freerouting/gui/WindowVia.java index 49c06a7a..92ef6ae1 100644 --- a/src/main/java/net/freerouting/gui/WindowVia.java +++ b/src/main/java/net/freerouting/gui/WindowVia.java @@ -20,213 +20,196 @@ package net.freerouting.gui; -import net.freerouting.rules.ViaRule; -import net.freerouting.rules.BoardRules; - import net.freerouting.board.Layer; +import net.freerouting.rules.BoardRules; +import net.freerouting.rules.ViaRule; /** * Window for interactive editing of via rules. * * @author Alfons Wirtz */ -public class WindowVia extends BoardSavableSubWindow -{ - - /** Creates a new instance of ViaWindow */ - public WindowVia(BoardFrame p_board_frame) - { +public class WindowVia extends BoardSavableSubWindow { + + private static final int WINDOW_OFFSET = 30; + private final BoardFrame board_frame; + private final java.util.ResourceBundle resources; + private final javax.swing.JList rule_list; + private final javax.swing.DefaultListModel rule_list_model; + private final javax.swing.JPanel main_panel; + /** + * The subwindows with information about selected object + */ + private final java.util.Collection subwindows = new java.util.LinkedList(); + + /** + * Creates a new instance of ViaWindow + */ + public WindowVia(BoardFrame p_board_frame) { this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowVia", p_board_frame.get_locale()); this.setTitle(resources.getString("title")); - + this.board_frame = p_board_frame; - + this.main_panel = new javax.swing.JPanel(); - main_panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(20,20,20,20)); + main_panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(20, 20, 20, 20)); main_panel.setLayout(new java.awt.BorderLayout()); - + javax.swing.JPanel north_panel = new javax.swing.JPanel(); main_panel.add(north_panel, java.awt.BorderLayout.NORTH); java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); north_panel.setLayout(gridbag); java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; - + javax.swing.JLabel available_via_padstack_label = new javax.swing.JLabel(resources.getString("available_via_padstacks")); - available_via_padstack_label.setBorder(javax.swing.BorderFactory.createEmptyBorder(10,0,10,10)); + available_via_padstack_label.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 0, 10, 10)); gridbag.setConstraints(available_via_padstack_label, gridbag_constraints); north_panel.add(available_via_padstack_label, gridbag_constraints); - + javax.swing.JPanel padstack_button_panel = new javax.swing.JPanel(); padstack_button_panel.setLayout(new java.awt.FlowLayout()); gridbag.setConstraints(padstack_button_panel, gridbag_constraints); north_panel.add(padstack_button_panel, gridbag_constraints); - - final javax.swing.JButton show_padstack_button = new javax.swing.JButton(resources.getString("info")); + + final javax.swing.JButton show_padstack_button = new javax.swing.JButton(resources.getString("info")); show_padstack_button.setToolTipText(resources.getString("info_tooltip")); show_padstack_button.addActionListener(new ShowPadstacksListener()); padstack_button_panel.add(show_padstack_button); - - final javax.swing.JButton add_padstack_button = new javax.swing.JButton(resources.getString("create")); + + final javax.swing.JButton add_padstack_button = new javax.swing.JButton(resources.getString("create")); add_padstack_button.setToolTipText(resources.getString("create_tooltip")); add_padstack_button.addActionListener(new AddPadstackListener()); padstack_button_panel.add(add_padstack_button); - - final javax.swing.JButton remove_padstack_button = new javax.swing.JButton(resources.getString("remove")); + + final javax.swing.JButton remove_padstack_button = new javax.swing.JButton(resources.getString("remove")); remove_padstack_button.setToolTipText(resources.getString("remove_tooltip")); remove_padstack_button.addActionListener(new RemovePadstackListener()); padstack_button_panel.add(remove_padstack_button); - + javax.swing.JLabel separator_label = new javax.swing.JLabel("---------------------------------------------------------"); - separator_label.setBorder(javax.swing.BorderFactory.createEmptyBorder(10,0,10,0)); + separator_label.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 0, 10, 0)); gridbag.setConstraints(separator_label, gridbag_constraints); north_panel.add(separator_label, gridbag_constraints); - + javax.swing.JLabel available_vias_label = new javax.swing.JLabel(resources.getString("available_vias")); - available_vias_label.setBorder(javax.swing.BorderFactory.createEmptyBorder(10,0,10,10)); + available_vias_label.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 0, 10, 10)); gridbag.setConstraints(available_vias_label, gridbag_constraints); north_panel.add(available_vias_label, gridbag_constraints); - + javax.swing.JPanel via_button_panel = new javax.swing.JPanel(); via_button_panel.setLayout(new java.awt.FlowLayout()); gridbag.setConstraints(via_button_panel, gridbag_constraints); north_panel.add(via_button_panel, gridbag_constraints); - - final javax.swing.JButton show_vias_button = new javax.swing.JButton(resources.getString("info")); + + final javax.swing.JButton show_vias_button = new javax.swing.JButton(resources.getString("info")); show_vias_button.setToolTipText(resources.getString("info_tooltip_2")); show_vias_button.addActionListener(new ShowViasListener()); via_button_panel.add(show_vias_button); - - final javax.swing.JButton edit_vias_button = new javax.swing.JButton(resources.getString("edit")); + + final javax.swing.JButton edit_vias_button = new javax.swing.JButton(resources.getString("edit")); edit_vias_button.setToolTipText(resources.getString("edit_tooltip")); edit_vias_button.addActionListener(new EditViasListener()); via_button_panel.add(edit_vias_button); - + separator_label = new javax.swing.JLabel("---------------------------------------------------------"); - separator_label.setBorder(javax.swing.BorderFactory.createEmptyBorder(10,0,10,0)); + separator_label.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 0, 10, 0)); gridbag.setConstraints(separator_label, gridbag_constraints); north_panel.add(separator_label, gridbag_constraints); - + javax.swing.JLabel via_rule_list_name = new javax.swing.JLabel(resources.getString("via_rules")); - via_rule_list_name.setBorder(javax.swing.BorderFactory.createEmptyBorder(10,0,10,10)); + via_rule_list_name.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 0, 10, 10)); gridbag.setConstraints(via_rule_list_name, gridbag_constraints); north_panel.add(via_rule_list_name, gridbag_constraints); north_panel.add(via_rule_list_name, gridbag_constraints); - - + + this.rule_list_model = new javax.swing.DefaultListModel(); this.rule_list = new javax.swing.JList(this.rule_list_model); - + this.rule_list.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); this.rule_list.setSelectedIndex(0); this.rule_list.setVisibleRowCount(5); javax.swing.JScrollPane list_scroll_pane = new javax.swing.JScrollPane(this.rule_list); list_scroll_pane.setPreferredSize(new java.awt.Dimension(200, 100)); this.main_panel.add(list_scroll_pane, java.awt.BorderLayout.CENTER); - + // fill the list BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; - for (ViaRule curr_rule : board_rules.via_rules) - { + for (ViaRule curr_rule : board_rules.via_rules) { this.rule_list_model.addElement(curr_rule); } - + // Add buttons to edit the via rules. javax.swing.JPanel via_rule_button_panel = new javax.swing.JPanel(); via_rule_button_panel.setLayout(new java.awt.FlowLayout()); - this.add(via_rule_button_panel,java.awt.BorderLayout.SOUTH); - - final javax.swing.JButton show_rule_button = new javax.swing.JButton(resources.getString("info")); + this.add(via_rule_button_panel, java.awt.BorderLayout.SOUTH); + + final javax.swing.JButton show_rule_button = new javax.swing.JButton(resources.getString("info")); show_rule_button.setToolTipText(resources.getString("info_tooltip_3")); show_rule_button.addActionListener(new ShowViaRuleListener()); via_rule_button_panel.add(show_rule_button); - - final javax.swing.JButton add_rule_button = new javax.swing.JButton(resources.getString("create")); + + final javax.swing.JButton add_rule_button = new javax.swing.JButton(resources.getString("create")); add_rule_button.setToolTipText(resources.getString("create_tooltip_2")); add_rule_button.addActionListener(new AddViaRuleListener()); via_rule_button_panel.add(add_rule_button); - - final javax.swing.JButton edit_rule_button = new javax.swing.JButton(resources.getString("edit")); + + final javax.swing.JButton edit_rule_button = new javax.swing.JButton(resources.getString("edit")); edit_rule_button.setToolTipText(resources.getString("edit_tooltip_2")); edit_rule_button.addActionListener(new EditViaRuleListener()); - via_rule_button_panel.add(edit_rule_button); - - final javax.swing.JButton remove_rule_button = new javax.swing.JButton(resources.getString("remove")); + via_rule_button_panel.add(edit_rule_button); + + final javax.swing.JButton remove_rule_button = new javax.swing.JButton(resources.getString("remove")); remove_rule_button.setToolTipText(resources.getString("remove_tooltip_2")); remove_rule_button.addActionListener(new RemoveViaRuleListener()); via_rule_button_panel.add(remove_rule_button); - + p_board_frame.set_context_sensitive_help(this, "WindowVia"); - + this.add(main_panel); this.pack(); - this.setDefaultCloseOperation(DISPOSE_ON_CLOSE ); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } - - public void refresh() - { + + public void refresh() { // reinsert the elements in the rule list this.rule_list_model.removeAllElements(); BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; - for (ViaRule curr_rule : board_rules.via_rules) - { + for (ViaRule curr_rule : board_rules.via_rules) { this.rule_list_model.addElement(curr_rule); } - + // Dispose all subwindows because they may be no longer uptodate. java.util.Iterator it = this.subwindows.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { javax.swing.JFrame curr_subwindow = it.next(); - if (curr_subwindow != null) - { - + if (curr_subwindow != null) { + curr_subwindow.dispose(); } it.remove(); } } - - public void dispose() - { - for (javax.swing.JFrame curr_subwindow : this.subwindows) - { - if (curr_subwindow != null) - { + + public void dispose() { + for (javax.swing.JFrame curr_subwindow : this.subwindows) { + if (curr_subwindow != null) { curr_subwindow.dispose(); } } - if (board_frame.edit_vias_window != null) - { + if (board_frame.edit_vias_window != null) { board_frame.edit_vias_window.dispose(); } super.dispose(); } - - private final BoardFrame board_frame; - - private final java.util.ResourceBundle resources; - - private final javax.swing.JList rule_list; - private final javax.swing.DefaultListModel rule_list_model; - - private final javax.swing.JPanel main_panel; - - /** The subwindows with information about selected object*/ - private final java.util.Collection subwindows = new java.util.LinkedList(); - - - private static final int WINDOW_OFFSET = 30; - - private class ShowPadstacksListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class ShowPadstacksListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { java.util.Collection object_list = new java.util.LinkedList(); net.freerouting.library.BoardLibrary board_library = board_frame.board_panel.board_handling.get_routing_board().library; - for (int i = 0; i < board_library.via_padstack_count(); ++i) - { - object_list.add( board_library.get_via_padstack(i)); + for (int i = 0; i < board_library.via_padstack_count(); ++i) { + object_list.add(board_library.get_via_padstack(i)); } net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; WindowObjectInfo new_window = @@ -238,78 +221,63 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) subwindows.add(new_window); } } - - private class AddPadstackListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class AddPadstackListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.board.BasicBoard pcb = board_frame.board_panel.board_handling.get_routing_board(); - if (pcb.layer_structure.arr.length <= 1) - { + if (pcb.layer_structure.arr.length <= 1) { return; } String padstack_name = javax.swing.JOptionPane.showInputDialog(resources.getString("message_1")); - if (padstack_name == null) - { + if (padstack_name == null) { return; } - while (pcb.library.padstacks.get(padstack_name) != null) - { + while (pcb.library.padstacks.get(padstack_name) != null) { padstack_name = javax.swing.JOptionPane.showInputDialog(resources.getString("message_2"), padstack_name); - if (padstack_name == null) - { + if (padstack_name == null) { return; } } Layer start_layer = pcb.layer_structure.arr[0]; - Layer end_layer = pcb.layer_structure.arr[pcb.layer_structure.arr.length - 1]; + Layer end_layer = pcb.layer_structure.arr[pcb.layer_structure.arr.length - 1]; boolean layers_selected = false; - if (pcb.layer_structure.arr.length == 2) - { + if (pcb.layer_structure.arr.length == 2) { layers_selected = true; - } - else - { - Layer[] possible_start_layers = new net.freerouting.board.Layer[pcb.layer_structure.arr.length - 1]; - for (int i = 0; i < possible_start_layers.length; ++i) - { + } else { + Layer[] possible_start_layers = new net.freerouting.board.Layer[pcb.layer_structure.arr.length - 1]; + for (int i = 0; i < possible_start_layers.length; ++i) { possible_start_layers[i] = pcb.layer_structure.arr[i]; } Object selected_value = javax.swing.JOptionPane.showInputDialog(null, resources.getString("select_start_layer"), resources.getString("start_layer_selection"), javax.swing.JOptionPane.INFORMATION_MESSAGE, null, possible_start_layers, possible_start_layers[0]); - if (selected_value == null) - { + if (selected_value == null) { return; } - start_layer = (Layer)selected_value; - if (start_layer == possible_start_layers[possible_start_layers.length - 1]) - { + start_layer = (Layer) selected_value; + if (start_layer == possible_start_layers[possible_start_layers.length - 1]) { layers_selected = true; } } - if (!layers_selected) - { + if (!layers_selected) { int first_possible_end_layer_no = pcb.layer_structure.get_no(start_layer) + 1; - Layer[] possible_end_layers = new net.freerouting.board.Layer[pcb.layer_structure.arr.length - first_possible_end_layer_no]; - for (int i = first_possible_end_layer_no; i < pcb.layer_structure.arr.length; ++i) - { + Layer[] possible_end_layers = new net.freerouting.board.Layer[pcb.layer_structure.arr.length - first_possible_end_layer_no]; + for (int i = first_possible_end_layer_no; i < pcb.layer_structure.arr.length; ++i) { possible_end_layers[i - first_possible_end_layer_no] = pcb.layer_structure.arr[i]; } Object selected_value = javax.swing.JOptionPane.showInputDialog(null, resources.getString("select_end_layer"), resources.getString("end_layer_selection"), javax.swing.JOptionPane.INFORMATION_MESSAGE, null, possible_end_layers, possible_end_layers[possible_end_layers.length - 1]); - if (selected_value == null) - { + if (selected_value == null) { return; } - end_layer = (Layer)selected_value; + end_layer = (Layer) selected_value; } Double default_radius = 100.0; - + // ask for the default radius - + javax.swing.JPanel default_radius_input_panel = new javax.swing.JPanel(); default_radius_input_panel.add(new javax.swing.JLabel(resources.getString("message_3"))); java.text.NumberFormat number_format = java.text.NumberFormat.getInstance(board_frame.get_locale()); @@ -320,63 +288,59 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) javax.swing.JOptionPane.showMessageDialog(board_frame, default_radius_input_panel, null, javax.swing.JOptionPane.PLAIN_MESSAGE); Object input_value = default_radius_input_field.getValue(); - if (input_value instanceof Number) - { - default_radius = ((Number)input_value).doubleValue(); + if (input_value instanceof Number) { + default_radius = ((Number) input_value).doubleValue(); } - + // input panel to make the default radius layer-depemdent - + PadstackInputPanel padstack_input_panel = new PadstackInputPanel(start_layer, end_layer, default_radius); javax.swing.JOptionPane.showMessageDialog(board_frame, padstack_input_panel, resources.getString("adjust_circles"), javax.swing.JOptionPane.PLAIN_MESSAGE); - int from_layer_no = pcb.layer_structure.get_no(start_layer); + int from_layer_no = pcb.layer_structure.get_no(start_layer); int to_layer_no = pcb.layer_structure.get_no(end_layer); net.freerouting.geometry.planar.ConvexShape[] padstack_shapes = new net.freerouting.geometry.planar.ConvexShape[pcb.layer_structure.arr.length]; net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; boolean shape_exists = false; - for (int i = from_layer_no; i <= to_layer_no; ++i) - { + for (int i = from_layer_no; i <= to_layer_no; ++i) { Object input = padstack_input_panel.circle_radius[i - from_layer_no].getValue(); double radius = default_radius; - if (input instanceof Number) - { - radius = ((Number)input).doubleValue(); + if (input instanceof Number) { + radius = ((Number) input).doubleValue(); } int circle_radius = (int) Math.round(coordinate_transform.user_to_board(radius)); - if (circle_radius > 0) - { - padstack_shapes[i] = new net.freerouting.geometry.planar.Circle(net.freerouting.geometry.planar.Point.ZERO, circle_radius); + if (circle_radius > 0) { + padstack_shapes[i] = new net.freerouting.geometry.planar.Circle(net.freerouting.geometry.planar.Point.ZERO, circle_radius); shape_exists = true; } } - if (!shape_exists) - { + if (!shape_exists) { return; } net.freerouting.library.Padstack new_padstack = pcb.library.padstacks.add(padstack_name, padstack_shapes, true, true); pcb.library.add_via_padstack(new_padstack); } } - - - /** Internal class used in AddPadstackListener */ - private class PadstackInputPanel extends javax.swing.JPanel - { - PadstackInputPanel(Layer p_from_layer, Layer p_to_layer, Double p_default_radius) - { + + + /** + * Internal class used in AddPadstackListener + */ + private class PadstackInputPanel extends javax.swing.JPanel { + private final javax.swing.JLabel[] layer_names; + private final javax.swing.JFormattedTextField[] circle_radius; + PadstackInputPanel(Layer p_from_layer, Layer p_to_layer, Double p_default_radius) { java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); this.setLayout(gridbag); java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); - + net.freerouting.board.LayerStructure layer_structure = board_frame.board_panel.board_handling.get_routing_board().layer_structure; - int from_layer_no = layer_structure.get_no(p_from_layer); + int from_layer_no = layer_structure.get_no(p_from_layer); int to_layer_no = layer_structure.get_no(p_to_layer); int layer_count = to_layer_no - from_layer_no + 1; layer_names = new javax.swing.JLabel[layer_count]; - circle_radius = new javax.swing.JFormattedTextField [layer_count]; - for (int i = 0; i < layer_count; ++i) - { + circle_radius = new javax.swing.JFormattedTextField[layer_count]; + for (int i = 0; i < layer_count; ++i) { String label_string = resources.getString("radius_on_layer") + " " + layer_structure.arr[from_layer_no + i].name + ": "; layer_names[i] = new javax.swing.JLabel(label_string); java.text.NumberFormat number_format = java.text.NumberFormat.getInstance(board_frame.get_locale()); @@ -392,53 +356,41 @@ private class PadstackInputPanel extends javax.swing.JPanel this.add(circle_radius[i], gridbag_constraints); } } - - private final javax.swing.JLabel [] layer_names; - private final javax.swing.JFormattedTextField [] circle_radius; } - - private class RemovePadstackListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class RemovePadstackListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { net.freerouting.board.BasicBoard pcb = board_frame.board_panel.board_handling.get_routing_board(); net.freerouting.library.Padstack[] via_padstacks = pcb.library.get_via_padstacks(); Object selected_value = javax.swing.JOptionPane.showInputDialog(null, resources.getString("choose_padstack_to_remove"), resources.getString("remove_via_padstack"), javax.swing.JOptionPane.INFORMATION_MESSAGE, null, via_padstacks, via_padstacks[0]); - if (selected_value == null) - { + if (selected_value == null) { return; } - net.freerouting.library.Padstack selected_padstack = (net.freerouting.library.Padstack)selected_value; + net.freerouting.library.Padstack selected_padstack = (net.freerouting.library.Padstack) selected_value; net.freerouting.rules.ViaInfo via_with_selected_padstack = null; - for (int i = 0; i < pcb.rules.via_infos.count(); ++i) - { - if (pcb.rules.via_infos.get(i).get_padstack() == selected_padstack) - { + for (int i = 0; i < pcb.rules.via_infos.count(); ++i) { + if (pcb.rules.via_infos.get(i).get_padstack() == selected_padstack) { via_with_selected_padstack = pcb.rules.via_infos.get(i); break; } } - if (via_with_selected_padstack != null) - { + if (via_with_selected_padstack != null) { String message = - resources.getString("message_4") + " " + via_with_selected_padstack.get_name(); + resources.getString("message_4") + " " + via_with_selected_padstack.get_name(); board_frame.screen_messages.set_status_message(message); return; } pcb.library.remove_via_padstack(selected_padstack, pcb); } } - - private class ShowViasListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class ShowViasListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { java.util.Collection object_list = new java.util.LinkedList(); net.freerouting.rules.ViaInfos via_infos = board_frame.board_panel.board_handling.get_routing_board().rules.via_infos; - for (int i = 0; i < via_infos.count(); ++i) - { + for (int i = 0; i < via_infos.count(); ++i) { object_list.add(via_infos.get(i)); } net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; @@ -451,28 +403,22 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) subwindows.add(new_window); } } - - private class EditViasListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class EditViasListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { board_frame.edit_vias_window.setVisible(true); } } - - private class ShowViaRuleListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class ShowViaRuleListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { Object[] selected_objects = rule_list.getSelectedValues(); - if (selected_objects.length <= 0) - { + if (selected_objects.length <= 0) { return; } java.util.Collection object_list = new java.util.LinkedList(); - for (int i = 0; i < selected_objects.length; ++i) - { - object_list.add((WindowObjectInfo.Printable)(selected_objects[i])); + for (int i = 0; i < selected_objects.length; ++i) { + object_list.add((WindowObjectInfo.Printable) (selected_objects[i])); } net.freerouting.board.CoordinateTransform coordinate_transform = board_frame.board_panel.board_handling.coordinate_transform; WindowObjectInfo new_window = @@ -484,14 +430,11 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) subwindows.add(new_window); } } - - private class EditViaRuleListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class EditViaRuleListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { Object selected_object = rule_list.getSelectedValue(); - if (selected_object == null || !(selected_object instanceof ViaRule)) - { + if (selected_object == null || !(selected_object instanceof ViaRule)) { return; } net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; @@ -503,19 +446,15 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) subwindows.add(new_window); } } - - private class AddViaRuleListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class AddViaRuleListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { String new_name = javax.swing.JOptionPane.showInputDialog(resources.getString("message_5")); - if (new_name == null) - { + if (new_name == null) { return; } new_name = new_name.trim(); - if (new_name.equals("")) - { + if (new_name.equals("")) { return; } ViaRule new_via_rule = new ViaRule(new_name); @@ -525,20 +464,16 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) board_frame.refresh_windows(); } } - - private class RemoveViaRuleListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class RemoveViaRuleListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { Object selected_object = rule_list.getSelectedValue(); - if (selected_object == null || !(selected_object instanceof ViaRule)) - { + if (selected_object == null || !(selected_object instanceof ViaRule)) { return; } ViaRule selected_rule = (ViaRule) selected_object; String message = resources.getString("remove_via_rule") + " " + selected_rule.name + "?"; - if (WindowMessage.confirm(message)) - { + if (WindowMessage.confirm(message)) { net.freerouting.rules.BoardRules board_rules = board_frame.board_panel.board_handling.get_routing_board().rules; board_rules.via_rules.remove(selected_rule); rule_list_model.removeElement(selected_rule); diff --git a/src/main/java/net/freerouting/gui/WindowViaRule.java b/src/main/java/net/freerouting/gui/WindowViaRule.java index 7970dbf8..2255dbcb 100644 --- a/src/main/java/net/freerouting/gui/WindowViaRule.java +++ b/src/main/java/net/freerouting/gui/WindowViaRule.java @@ -20,136 +20,123 @@ package net.freerouting.gui; -import net.freerouting.rules.ViaRule; import net.freerouting.rules.ViaInfo; import net.freerouting.rules.ViaInfos; +import net.freerouting.rules.ViaRule; /** * Window for editing a single via rule. * * @author Alfons Wirtz */ -public class WindowViaRule extends javax.swing.JFrame -{ - - /** Creates a new instance of ViaRuleWindow */ - public WindowViaRule(ViaRule p_via_rule, ViaInfos p_via_list, BoardFrame p_board_frame) - { +public class WindowViaRule extends javax.swing.JFrame { + + private final ViaRule via_rule; + /** + * the list of possible vias in a rule + */ + private final ViaInfos via_list; + private final javax.swing.JPanel main_panel; + private final javax.swing.JList rule_list; + private final javax.swing.DefaultListModel rule_list_model; + private final java.util.ResourceBundle resources; + /** + * Creates a new instance of ViaRuleWindow + */ + public WindowViaRule(ViaRule p_via_rule, ViaInfos p_via_list, BoardFrame p_board_frame) { this.via_rule = p_via_rule; this.via_list = p_via_list; - + this.resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.WindowViaRule", p_board_frame.get_locale()); - this.setTitle(resources.getString("title") + " " + p_via_rule.name); - + this.setTitle(resources.getString("title") + " " + p_via_rule.name); + this.main_panel = new javax.swing.JPanel(); - main_panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(20,20,20,20)); + main_panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(20, 20, 20, 20)); main_panel.setLayout(new java.awt.BorderLayout()); - + this.rule_list_model = new javax.swing.DefaultListModel(); this.rule_list = new javax.swing.JList(this.rule_list_model); - + this.rule_list.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); this.rule_list.setVisibleRowCount(10); javax.swing.JScrollPane list_scroll_pane = new javax.swing.JScrollPane(this.rule_list); list_scroll_pane.setPreferredSize(new java.awt.Dimension(200, 100)); this.main_panel.add(list_scroll_pane, java.awt.BorderLayout.CENTER); - + // fill the list - for (int i = 0; i < p_via_rule.via_count(); ++i) - { + for (int i = 0; i < p_via_rule.via_count(); ++i) { this.rule_list_model.addElement(p_via_rule.get_via(i)); } - + // Add a panel with buttons for editing the via list. - + javax.swing.JPanel button_panel = new javax.swing.JPanel(); - this.main_panel.add(button_panel,java.awt.BorderLayout.SOUTH); + this.main_panel.add(button_panel, java.awt.BorderLayout.SOUTH); java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); button_panel.setLayout(gridbag); java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); - - final javax.swing.JButton add_button = new javax.swing.JButton(resources.getString("append")); + + final javax.swing.JButton add_button = new javax.swing.JButton(resources.getString("append")); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridbag.setConstraints(add_button, gridbag_constraints); add_button.setToolTipText(resources.getString("append_tooltip")); add_button.addActionListener(new AppendListener()); button_panel.add(add_button); - - final javax.swing.JButton delete_button = new javax.swing.JButton(resources.getString("remove")); + + final javax.swing.JButton delete_button = new javax.swing.JButton(resources.getString("remove")); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag.setConstraints(delete_button, gridbag_constraints); delete_button.setToolTipText(resources.getString("remove_tooltip")); delete_button.addActionListener(new DeleteListener()); button_panel.add(delete_button); - - final javax.swing.JButton move_up_button = new javax.swing.JButton(resources.getString("move_up")); + + final javax.swing.JButton move_up_button = new javax.swing.JButton(resources.getString("move_up")); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridbag.setConstraints(move_up_button, gridbag_constraints); move_up_button.setToolTipText(resources.getString("move_up_tooltip")); move_up_button.addActionListener(new MoveUpListener()); button_panel.add(move_up_button); - - final javax.swing.JButton move_down_button = new javax.swing.JButton(resources.getString("move_down")); + + final javax.swing.JButton move_down_button = new javax.swing.JButton(resources.getString("move_down")); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridbag.setConstraints(move_down_button, gridbag_constraints); move_down_button.setToolTipText(resources.getString("move_down_tooltip")); move_down_button.addActionListener(new MoveDownListener()); button_panel.add(move_down_button); - + p_board_frame.set_context_sensitive_help(this, "WindowVia_EditViaRule"); - + this.add(main_panel); this.pack(); - this.setDefaultCloseOperation(DISPOSE_ON_CLOSE ); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.setVisible(true); } - + /** * Swaps the position of the vias with index p_1 and p_2. */ - private void swap_position(int p_1, int p_2) - { + private void swap_position(int p_1, int p_2) { ViaInfo via_1 = (ViaInfo) this.rule_list_model.get(p_1); ViaInfo via_2 = (ViaInfo) this.rule_list_model.get(p_2); - if (via_1 == null || via_2 == null) - { + if (via_1 == null || via_2 == null) { return; } this.rule_list_model.set(p_1, via_2); this.rule_list_model.set(p_2, via_1); this.via_rule.swap(via_1, via_2); } - - - private final ViaRule via_rule; - - /** the list of possible vias in a rule */ - private final ViaInfos via_list; - - private final javax.swing.JPanel main_panel; - - private final javax.swing.JList rule_list; - private final javax.swing.DefaultListModel rule_list_model; - - private final java.util.ResourceBundle resources; - - private class AppendListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class AppendListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { Object[] possible_values = new Object[via_list.count() - via_rule.via_count()]; - if (possible_values.length <= 0) - { + if (possible_values.length <= 0) { return; } int curr_index = 0; - for (int i = 0; i < via_list.count(); ++i) - { + for (int i = 0; i < via_list.count(); ++i) { ViaInfo curr_via = via_list.get(i); - if (!via_rule.contains(curr_via)) - { - if (curr_index >= possible_values.length) - { + if (!via_rule.contains(curr_via)) { + if (curr_index >= possible_values.length) { System.out.println("ViaRuleWindow.AppendListener.actionPerformed: index inconsistent"); break; } @@ -161,54 +148,43 @@ public void actionPerformed(java.awt.event.ActionEvent p_evt) Object selected_value = javax.swing.JOptionPane.showInputDialog(null, resources.getString("choose_via_to_append"), resources.getString("append_via_to_rule"), javax.swing.JOptionPane.INFORMATION_MESSAGE, null, possible_values, possible_values[0]); - if (selected_value != null) - { - ViaInfo selected_via = (ViaInfo)selected_value; + if (selected_value != null) { + ViaInfo selected_via = (ViaInfo) selected_value; via_rule.append_via(selected_via); rule_list_model.addElement(selected_via); } } } - - private class DeleteListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class DeleteListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { ViaInfo selected_via = (ViaInfo) rule_list.getSelectedValue(); - if (selected_via != null) - { + if (selected_via != null) { String message = resources.getString("remove_2") + " " + selected_via.get_name() + " " + resources.getString("from_the_rule") + " " + via_rule.name + "?"; - if (WindowMessage.confirm(message)) - { + if (WindowMessage.confirm(message)) { rule_list_model.removeElement(selected_via); via_rule.remove_via(selected_via); } } } } - - private class MoveUpListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class MoveUpListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { int selected_index = rule_list.getSelectedIndex(); - if (selected_index <= 0) - { + if (selected_index <= 0) { return; } swap_position(selected_index - 1, selected_index); rule_list.setSelectedIndex(selected_index - 1); } } - - private class MoveDownListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class MoveDownListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { int selected_index = rule_list.getSelectedIndex(); - if (selected_index < 0 || selected_index >= rule_list_model.getSize() - 1) - { + if (selected_index < 0 || selected_index >= rule_list_model.getSize() - 1) { return; } swap_position(selected_index, selected_index + 1); diff --git a/src/main/java/net/freerouting/gui/WindowVisibility.java b/src/main/java/net/freerouting/gui/WindowVisibility.java index c2883658..44bb8192 100644 --- a/src/main/java/net/freerouting/gui/WindowVisibility.java +++ b/src/main/java/net/freerouting/gui/WindowVisibility.java @@ -23,21 +23,27 @@ /** * Interactive Frame to adjust the visibility of a set of objects * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public abstract class WindowVisibility extends BoardSavableSubWindow -{ - - /** Creates a new instance of VisibilityFrame */ - public WindowVisibility(BoardFrame p_board_frame, String p_title, String p_header_message, String[] p_message_arr) - { +public abstract class WindowVisibility extends BoardSavableSubWindow { + + private static final int MAX_SLIDER_VALUE = 100; + private final BoardPanel board_panel; + private final javax.swing.JLabel header_message; + private final javax.swing.JLabel[] message_arr; + private final javax.swing.JSlider[] slider_arr; + + /** + * Creates a new instance of VisibilityFrame + */ + public WindowVisibility(BoardFrame p_board_frame, String p_title, String p_header_message, String[] p_message_arr) { this.board_panel = p_board_frame.board_panel; this.setTitle(p_title); - + // create main panel final javax.swing.JPanel main_panel = new javax.swing.JPanel(); getContentPane().add(main_panel); - + java.awt.GridBagLayout gridbag = new java.awt.GridBagLayout(); main_panel.setLayout(gridbag); java.awt.GridBagConstraints gridbag_constraints = new java.awt.GridBagConstraints(); @@ -49,10 +55,9 @@ public WindowVisibility(BoardFrame p_board_frame, String p_title, String p_heade gridbag.setConstraints(header_message, gridbag_constraints); main_panel.add(header_message); slider_arr = new javax.swing.JSlider[p_message_arr.length]; - message_arr = new javax.swing.JLabel [p_message_arr.length]; + message_arr = new javax.swing.JLabel[p_message_arr.length]; gridbag_constraints.ipady = 0; - for (int i = 0; i < p_message_arr.length; ++i) - { + for (int i = 0; i < p_message_arr.length; ++i) { message_arr[i] = new javax.swing.JLabel(); message_arr[i].setText(p_message_arr[i]); gridbag_constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; @@ -68,7 +73,7 @@ public WindowVisibility(BoardFrame p_board_frame, String p_title, String p_heade gridbag.setConstraints(empty_label, gridbag_constraints); main_panel.add(empty_label); gridbag_constraints.gridwidth = 2; - java.util.ResourceBundle resources = + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.gui.Default", p_board_frame.get_locale()); javax.swing.JButton min_all_button = new javax.swing.JButton(resources.getString("minimum_all")); min_all_button.setToolTipText(resources.getString("minimum_all_tooltip")); @@ -83,90 +88,70 @@ public WindowVisibility(BoardFrame p_board_frame, String p_title, String p_heade this.pack(); this.setResizable(false); } - + + // private data + /** * Sets the values of the p_no-ths slider contained in this frame. */ - public void set_slider_value( int p_no, double p_value) - { + public void set_slider_value(int p_no, double p_value) { int visibility = (int) Math.round(p_value * MAX_SLIDER_VALUE); slider_arr[p_no].setValue(visibility); } - - protected net.freerouting.interactive.BoardHandling get_board_handling() - { + + protected net.freerouting.interactive.BoardHandling get_board_handling() { return board_panel.board_handling; } - - protected void set_all_minimum() - { - for (int i = 0; i < slider_arr.length; ++i) - { + + protected void set_all_minimum() { + for (int i = 0; i < slider_arr.length; ++i) { set_slider_value(i, 0); set_changed_value(i, 0); } } - - protected void set_all_maximum() - { - for (int i = 0; i < slider_arr.length; ++i) - { + + protected void set_all_maximum() { + for (int i = 0; i < slider_arr.length; ++i) { set_slider_value(i, MAX_SLIDER_VALUE); set_changed_value(i, 1); } } - + /** * Stores the new value in the board database, when a slider value was changed. */ protected abstract void set_changed_value(int p_index, double p_value); - - // private data - - private final BoardPanel board_panel; - - private final javax.swing.JLabel header_message; - private final javax.swing.JLabel [] message_arr; - private final javax.swing.JSlider [] slider_arr; - - private static final int MAX_SLIDER_VALUE = 100; - + // private classes - - private class MinAllButtonListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class MinAllButtonListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { set_all_minimum(); board_panel.repaint(); } } - - private class MaxAllButtonListener implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent p_evt) - { + + private class MaxAllButtonListener implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent p_evt) { set_all_maximum(); board_panel.repaint(); } } - + /** * p_slider_no is required to identify the number of the slider in slider_arr. */ - private class SliderChangeListener implements javax.swing.event.ChangeListener - { - public SliderChangeListener(int p_slider_no) - { + private class SliderChangeListener implements javax.swing.event.ChangeListener { + public int slider_no; + + public SliderChangeListener(int p_slider_no) { slider_no = p_slider_no; } - public void stateChanged(javax.swing.event.ChangeEvent evt) - { + + public void stateChanged(javax.swing.event.ChangeEvent evt) { int new_visibility = slider_arr[slider_no].getValue(); - set_changed_value(slider_no, ((double) new_visibility) / ((double)MAX_SLIDER_VALUE)); + set_changed_value(slider_no, ((double) new_visibility) / ((double) MAX_SLIDER_VALUE)); board_panel.repaint(); } - - public int slider_no; } } diff --git a/src/main/java/net/freerouting/gui/package.html b/src/main/java/net/freerouting/gui/package.html index 5a7008cc..fcb16ea5 100644 --- a/src/main/java/net/freerouting/gui/package.html +++ b/src/main/java/net/freerouting/gui/package.html @@ -1,5 +1,6 @@ -java.text package -Contains functionality of the graphical user interface based on javax.swing. \ No newline at end of file +Contains functionality of the graphical user interface based on javax.swing. + \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/HelpIndex.xml b/src/main/java/net/freerouting/helpset/de/HelpIndex.xml index 54841ef9..1ed451e1 100644 --- a/src/main/java/net/freerouting/helpset/de/HelpIndex.xml +++ b/src/main/java/net/freerouting/helpset/de/HelpIndex.xml @@ -1,187 +1,188 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/HelpTOC.xml b/src/main/java/net/freerouting/helpset/de/HelpTOC.xml index 7a6ea469..3e355d58 100644 --- a/src/main/java/net/freerouting/helpset/de/HelpTOC.xml +++ b/src/main/java/net/freerouting/helpset/de/HelpTOC.xml @@ -1,157 +1,159 @@ - + - - - + + + - + - + - - - + + + - - - + + + - + - - - - - + + + + + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - - - + + + - + - + - + - - - + + + - + - + - + - - - + + + - + - + - + - + - + - + - + - - - + + + - - - - - + + + + + - - + + - - + + - - + + - - - + + + - - + + - + - - - + + + - - - + + + - - - + + + - + - + - + - + - + - + - - - + + + - + - + - + - - + + \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/Map.jhm b/src/main/java/net/freerouting/helpset/de/Map.jhm index 655583cd..82e6aaae 100644 --- a/src/main/java/net/freerouting/helpset/de/Map.jhm +++ b/src/main/java/net/freerouting/helpset/de/Map.jhm @@ -1,193 +1,206 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/FileMenu.html b/src/main/java/net/freerouting/helpset/de/html_files/FileMenu.html index ceb3905b..c5514659 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/FileMenu.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/FileMenu.html @@ -2,55 +2,101 @@ - - - - Das Datei-Menü - + + + + Das Datei-Menü + - -

Die Einträge im Dateimenü

-
-

speichern

-
-

Der aktuelle Stand des Designs wird im internen .bin-Dateiformat gespeichert. Nicht verfügbar in der Web-Version weil Designs im .bin-Format im allgemeinen zwischen verschiedenen Versionen des Routers nicht kompatibel sind.

-
-

speichern und beenden

-
-

Das Programm wird beendet, nachdem der aktuelle Stand der Design-Datei im internen .bin-Format gespeichert wurde. Nicht verfügbar in der Web-Version weil Designs im .bin-Format im allgemeinen zwischen verschiedenen Versionen des Routers nicht kompatibel sind.

-
-

abbrechen und beenden

-
-

Das Programm wird beendet. Dabei werden alle interaktiven Änderungen nach dem letzten Speichern verworfen.

-
-

speichern unter

-
-

Hier können Sie den aktuellen Stand des Designs in einer Datei mit einem von Ihnen gewählten Namen speichern. Erlaubt sind die Dateiendungen .bin und .dsn. Wenn Sie die Endung .bin wählen, wird die Datei im internen Binär-Format abgespeichert. Dabei wird der aktuelle interaktive Zustand des Programms mit abgespeichert. Da in diesem Format abgespeicherte Designs i. a. mit einer späteren Version der Software nicht mehr eingelesen werden können, steht das .bin-Format nur in der Offline-Version des Routers zur Verfügung. Wenn Sie möchten, dass die abgespeicherte Design-Datei mit jeder späteren Version der Software wieder eingelesen werden kann, müssen Sie die Dateiendung .dsn wählen. Die Datei wird dann in einem Textformat abgespeichert, das eine Erweiterung des Specctra-dsn-Formats ist.

-
-

Log-Datei erzeugen

-
-

Schreibt ab jetzt alle interaktiven Aktionen in eine Log-Datei, so dass diese Abfolge später mit Log-Datei abspielen wiederholt werden kann. Es werden nur Aktionen abgespeichert, die eine Veränderung des Designs zur Folge haben. Dieser Eintrag ist dafür vorgesehen, kurze interaktive Abfolgen zum Debuggen wiederholbar zu machen. Für die genaue Wiederholbarkeit längerer interaktiver Abfolgen wird keine Garantie übernommen. Der Name einer solchen Log-Datei muss mit .log enden. Nicht verfügbar in der Web-Version.

-
-

Log-Datei abspielen

-
-

Die Abfolge der Aktionen in einer mit Log-Datei erzeugen generierten Datei mit der Endung .log wird wiederholt. Das Design muss sich dabei im gleichen Zustand wie vor dem Erzeugen der Log-Datei befinden. Nicht verfügbar in der Web-Version.

-
-

GUI-Einstellungen als Default speichern

-
-

Die aktuellen interaktiven Einstellungen werden in einer Datei mit Namen gui_defaults.par abgespeichert. In der Web-Version ist diese Datei im Java-Control-Panel-Cache versteckt. Sie können sie löschen mit "System-Defaults wiederherstellen" im Startfenster des Routers. Wenn später beim Einlesen eines Designs im .dsn-Format eine Datei mit Namen gui_defaults.par vorgefunden wird, werden die dort abgespeicherten Einstellungen wiederhergestellt. Damit können Sie design-unabhängig Ihre persönlichen Vorlieben für die interaktiven Einstellungen abspeichern. Wenn Sie z. B. andere Objektfarben bevorzugen, oder wenn Sie zwei Bildschirme haben und die Position der Unterfenster auf den zweiten Bildschirm verlegen möchten, brauchen Sie das nicht jedes mal neu einzustellen. Es empfiehlt sich, diese Abspeicherung auf einem Design mit möglichst vielen Lagen vorzunehmen. Sonst würden sich die lagenabhängigen Farben der einzelnen Objekttypen wiederholen, da die Datei gui_defaults.par aus einem Design mit weniger Lagen als dem aktuellen Design erzeugt wurde.

-
-

Specctra-Session-Datei exportieren

-
-

Um die mit dieser Software erzeugten Änderungen an der Design-Datei in das Host-System zurück zu übertragen, können Sie hier können Sie eine Session-Datei im Specctra-.ses-Format schreiben. Diese Datei können Sie dann im Host-System so importieren, wie Sie das bei Verwendung des Specctra- oder des Electra-Autorouters machen würden. Nach dem Schreiben der Session-Datei werden Sie gefragt, ob Sie die in diesem Programm erzeugten Regeln zur späteren Wiederverwendung speichern möchten. Antworten Sie mit Ja, falls Sie z. B. Via-Regeln definiert haben, die Sie nach dem Hin- und Herwechseln zum Host-System und wieder zurück wieder verwenden wollen. Dabei können allerdings im Host-System neu definierte Regeln unter Umständen überschrieben werden.

-

Wenn die ursprüngliche Designdatei von Cadsoft-Eagle erzeugt wurde sehen Sie statt diesem Eintrag den folgenden Menü-Eintrag:

-
-

Eagle-Session-Script exportieren

-
-

Es wird eine Textdatei mit dem Namen des Designs und der Endung .scr geschrieben. Damit können Sie die Änderungen des Designs nach Cadsoft-Eagle importieren, indem Sie dort im Datei-Pulldown-Menü Script ausführen wählen und diese Textdatei einlesen. Nach dem Schreiben der Textdatei werden Sie gefragt, ob Sie die in diesem Programm erzeugten Regeln zur späteren Wiederverwendung speichern möchten. Antworten Sie mit Ja, wenn Sie z. B. Via-Regeln definiert haben, die Sie nach dem Hin- und Herwechseln nach Eagle und wieder zurück wieder verwenden wollen. Dabei können allerdings in Eagle neu definierte Regeln unter Umständen überschrieben werden.

-

-

-
-
- + +

Die Einträge im Dateimenü

+
+

speichern

+
+

Der aktuelle Stand des Designs wird im internen .bin-Dateiformat gespeichert. Nicht verfügbar in der + Web-Version weil Designs im .bin-Format im allgemeinen zwischen verschiedenen Versionen des Routers nicht + kompatibel sind.

+
+

speichern und beenden

+
+

Das Programm wird beendet, nachdem der aktuelle Stand der Design-Datei im internen .bin-Format gespeichert + wurde. Nicht verfügbar in der Web-Version weil Designs im .bin-Format im allgemeinen zwischen + verschiedenen Versionen des Routers nicht kompatibel sind.

+
+

abbrechen und beenden

+
+

Das Programm wird beendet. Dabei werden alle interaktiven Änderungen nach dem letzten Speichern + verworfen.

+
+

speichern unter

+
+

Hier können Sie den aktuellen Stand des Designs in einer Datei mit einem von Ihnen gewählten Namen + speichern. Erlaubt sind die Dateiendungen .bin und .dsn. Wenn Sie die Endung .bin wählen, wird die + Datei im internen Binär-Format abgespeichert. Dabei wird der aktuelle interaktive Zustand des Programms + mit abgespeichert. Da in diesem Format abgespeicherte Designs i. a. mit einer späteren Version der + Software nicht mehr eingelesen werden können, steht das .bin-Format nur in der Offline-Version des + Routers zur Verfügung. Wenn Sie möchten, dass die abgespeicherte Design-Datei mit jeder späteren + Version der Software wieder eingelesen werden kann, müssen Sie die Dateiendung .dsn wählen. Die + Datei wird dann in einem Textformat abgespeichert, das eine Erweiterung des Specctra-dsn-Formats ist.

+
+

Log-Datei erzeugen

+
+

Schreibt ab jetzt alle interaktiven Aktionen in eine Log-Datei, so dass diese Abfolge später mit Log-Datei + abspielen wiederholt werden kann. Es werden nur Aktionen abgespeichert, die eine Veränderung des + Designs zur Folge haben. Dieser Eintrag ist dafür vorgesehen, kurze interaktive Abfolgen zum Debuggen + wiederholbar zu machen. Für die genaue Wiederholbarkeit längerer interaktiver Abfolgen wird keine + Garantie übernommen. Der Name einer solchen Log-Datei muss mit .log enden. Nicht verfügbar in der + Web-Version.

+
+

Log-Datei abspielen

+
+

Die Abfolge der Aktionen in einer mit Log-Datei erzeugen generierten Datei mit der Endung .log wird + wiederholt. Das Design muss sich dabei im gleichen Zustand wie vor dem Erzeugen der Log-Datei befinden. + Nicht verfügbar in der Web-Version.

+
+

GUI-Einstellungen als Default speichern

+
+

Die aktuellen interaktiven Einstellungen werden in einer Datei mit Namen gui_defaults.par abgespeichert. In + der Web-Version ist diese Datei im Java-Control-Panel-Cache versteckt. Sie können sie löschen mit + "System-Defaults wiederherstellen" im Startfenster des Routers. Wenn später beim Einlesen + eines Designs im .dsn-Format eine Datei mit Namen gui_defaults.par vorgefunden wird, werden die dort + abgespeicherten Einstellungen wiederhergestellt. Damit können Sie design-unabhängig Ihre persönlichen + Vorlieben für die interaktiven Einstellungen abspeichern. Wenn Sie z. B. andere Objektfarben + bevorzugen, oder wenn Sie zwei Bildschirme haben und die Position der Unterfenster auf den zweiten + Bildschirm verlegen möchten, brauchen Sie das nicht jedes mal neu einzustellen. Es empfiehlt sich, + diese Abspeicherung auf einem Design mit möglichst vielen Lagen vorzunehmen. Sonst würden sich die + lagenabhängigen Farben der einzelnen Objekttypen wiederholen, da die Datei gui_defaults.par aus einem + Design mit weniger Lagen als dem aktuellen Design erzeugt wurde.

+
+

Specctra-Session-Datei exportieren

+
+

Um die mit dieser Software erzeugten Änderungen an der Design-Datei in das Host-System zurück + zu übertragen, können Sie hier können Sie eine Session-Datei im Specctra-.ses-Format + schreiben. Diese Datei können Sie dann im Host-System so importieren, wie Sie das bei Verwendung des + Specctra- oder des Electra-Autorouters machen würden. Nach dem Schreiben der Session-Datei werden Sie + gefragt, ob Sie die in diesem Programm erzeugten Regeln zur späteren Wiederverwendung speichern möchten. + Antworten Sie mit Ja, falls Sie z. B. Via-Regeln definiert haben, die Sie nach dem Hin- und Herwechseln zum + Host-System und wieder zurück wieder verwenden wollen. Dabei können allerdings im Host-System neu + definierte Regeln unter Umständen überschrieben werden.

+ +

Wenn die ursprüngliche Designdatei von Cadsoft-Eagle erzeugt wurde sehen Sie statt diesem Eintrag den + folgenden Menü-Eintrag:

+
+

Eagle-Session-Script exportieren

+
+

Es wird eine Textdatei mit dem Namen des Designs und der Endung .scr geschrieben. Damit können + Sie die Änderungen des Designs nach Cadsoft-Eagle importieren, indem Sie dort im Datei-Pulldown-Menü + Script ausführen wählen und diese Textdatei einlesen. Nach dem Schreiben der Textdatei + werden Sie gefragt, ob Sie die in diesem Programm erzeugten Regeln zur späteren Wiederverwendung + speichern möchten. Antworten Sie mit Ja, wenn Sie z. B. Via-Regeln definiert haben, die Sie nach dem + Hin- und Herwechseln nach Eagle und wieder zurück wieder verwenden wollen. Dabei können allerdings + in Eagle neu definierte Regeln unter Umständen überschrieben werden.

+ +

+ +

+
+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/MenuState.html b/src/main/java/net/freerouting/helpset/de/html_files/MenuState.html index 337c5236..ffa76281 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/MenuState.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/MenuState.html @@ -2,86 +2,126 @@ - - - - Menü-Zustand - + + + + Menü-Zustand + - -

Die Menü-Zustände

- Das Programm hat die folgenden drei Menü-Zustände: Selektieren, Routen und Ziehen. Durch Selektieren eines der drei Buttons links oben auf dem Toolbar können Sie zwischen diesen Zuständen hin- und herschalten. Am Anfang befindet sich das Programm im Select-Menü-Zustand. -

Allen drei Zuständen sind der Toolbar und das Popup-Menü unter der rechten Maustaste gemeinsam.

-

Die weiteren Toolbar-Einträge:

-
- Autorouter -
-

Den Batch-Autorouter auf dem gesamten Board aufrufen.

-
-
-
- Undo, Redo -
-

Das Programm hat unbegrenzte Undo-Redo-Fähigkeiten. In der Offline-Version geht der Undo-Stack selbst nach Speichern des Designs und Neustart des Programms nicht verloren. Shortcuts sind u für Undo und b für Redo

-
-

Incompletes

-
-

Hier können Sie das Zeigen der offenen Verbindungen als Luftlinien ein- oder ausschalten. Wenn die Luftlinien vorher ausgeschaltet waren, werden sie eingeschaltet und umgekehrt. Shortcut ist g.

-
-

Verletzungen

-
-

Hier können Sie das Zeigen der Abstandsverletzungen an- oder abschalten. Wenn die Abstandsverletzungen vorher abgeschaltet waren, werden sie eingeschaltet und umgekehrt. Shortcut ist v.

-
-

Alles abbilden

-
-

Zum Abbilden der gesamten Platine. Shortcut ist a.

-
-

Ausschnitt abbilden

-
-

Nachdem Sie diesen Eintrag angewählt haben, können Sie durch Ziehen der Maus mit gedrückter linker Maustaste ein abzubildendes Rechteck auswählen. Shortcut ist f. Zoomen können Sie auch durch Drehen des Mausrads und Pannen durch Ziehen der Maus mit gedrücktem Mausrad.

-
-

Unit

-
-

Hier kann die Maßeinheit und der Maßeinheits-Faktor eingestellt werden. Sie können auswählen zwischen mil, inch, mm und um. Wenn Sie z. B. 0.1 mm einstellen, werden alle Koordinaten auf der Benutzeroberfläche als vielfache von 0,1 mm angezeigt.

-
-
-

Die Popup-Menü-Einträge:

-
- Objekt selektieren -
-

Zum Selektieren von Objekten unter dem Cursor. Dabei werden die Einstellungen aus dem Fenster Select-Einstellungen ausgewertet. Wurden Objekte zum Auswählen gefunden, befindet sich das Programm danach im Auswahl-Zustand. Im Select-Menü-Zustand könne Sie auch mit der linken Maustaste Objekte selektieren.

-
- Route starten -
Vom Objekt unter dem Mauszeiger aus wird eine neue Bahn begonnen. Dabei werden die Einstellungen aus dem Fenster Select-Einstellungen ausgewertet. Wurde ein geeignetes Objekt gefunden, befindet sich das Programm danach im Route-Zustand. Im Route-Menü-Zustand reicht dazu das Klicken mit der linken Maustaste,
- Sperrfläche konstruieren -
Hiermit können Sie auf der aktuellen Lage eine Sperrfläche konstruieren. Dabei kann es sich um einen Kreis, ein Polygon, oder um ein Loch in einer existierenden polygonalen Sperrfläche handeln.
- Pin tauschen -
Dieser Menü-Eintrag erscheint nur, wenn es auf der Platine tauschbare Pins gibt. Ist der Pin unter dem Cursor tauschbar, können Sie hier die Netz-Zugehörigkeit dieses Pins mit einem anderen Pin tauschen.
-

Die Zeichen in Klammern hinter den Popup-Menü-Einträgen bezeichnen die Shortcuts für die entsprechenden Aktionen.

-
-

Die Funktion des Mausrad:

-
-

Durch Drehen mit dem Mausrad können Sie den abgebildeten Ausschnitt der Platine vergrößern oder verkleinern, und durch Ziehen der Maus mit gedrücktem Mausrad können Sie das abgebildete Rechteck verschieben.

-

-
-

-

Der Selektions-Menü-Zustand

- - Ist oben links auf der Werkzeugleiste der Button Selektieren angewählt, befindet sich das Programm im Selektions-Menü-Zustand. Die linke Maustaste dient hier als Shortcut für die Aktion Objekt selektieren im Popup-Menü. Außer dem können Sie durch Ziehen der Maus mit gedrückter linker Taste alle Objekte in einem Rechteck selektieren. - -

zurück

-

-

Der Route-Menü-Zustand

- - Ist oben links auf der Werkzeugleiste der Button Routen angewählt, befindet sich das Programm im Route-Menü-Zustand. Die linke Maustaste dient hier als Shortcut für die Aktion Route starten im Popup-Menü. - -

zurück

-

-

Der Zieh-Menü-Zustand

- - Ist oben links auf der Werkzeugleiste der Button Ziehen angewählt, befindet sich das Programm im Zieh-Menü-Zustand. Hier können Sie mit gedrückter linker Maustaste Vias oder Bauteile ziehen und so ihre Position verändern. Dabei werden die angeschlossenen Bahnen automatisch mit verändert. Weiter können Sie mit gedrückter linker Maustaste aus dem leeren Raum heraus Bahnen beiseite schieben und sich so Platz schaffen z. B. für das Einfügen eines weiteren Bauteils. Diese Aktion wird auf der Aktuellen Lage ausgeführt, die im Fenster mit den Select-Einstellungen eingestellt werden kann. - -

zurück

- + +

Die Menü-Zustände

+Das Programm hat die folgenden drei Menü-Zustände: Selektieren, Routen und Ziehen. Durch Selektieren eines +der drei Buttons links oben auf dem Toolbar können Sie zwischen diesen Zuständen hin- und herschalten. Am +Anfang befindet sich das Programm im Select-Menü-Zustand. +

Allen drei Zuständen sind der Toolbar und das Popup-Menü unter der rechten Maustaste gemeinsam.

+

Die weiteren Toolbar-Einträge:

+
+ Autorouter +
+

Den Batch-Autorouter auf dem gesamten Board aufrufen.

+
+
+
+ Undo, Redo +
+

Das Programm hat unbegrenzte Undo-Redo-Fähigkeiten. In der Offline-Version geht der Undo-Stack selbst + nach Speichern des Designs und Neustart des Programms nicht verloren. Shortcuts sind u für Undo + und b für Redo

+
+

Incompletes

+
+

Hier können Sie das Zeigen der offenen Verbindungen als Luftlinien ein- oder ausschalten. Wenn die + Luftlinien vorher ausgeschaltet waren, werden sie eingeschaltet und umgekehrt. Shortcut ist g.

+
+

Verletzungen

+
+

Hier können Sie das Zeigen der Abstandsverletzungen an- oder abschalten. Wenn die Abstandsverletzungen + vorher abgeschaltet waren, werden sie eingeschaltet und umgekehrt. Shortcut ist v.

+
+

Alles abbilden

+
+

Zum Abbilden der gesamten Platine. Shortcut ist a.

+
+

Ausschnitt abbilden

+
+

Nachdem Sie diesen Eintrag angewählt haben, können Sie durch Ziehen der Maus mit gedrückter + linker Maustaste ein abzubildendes Rechteck auswählen. Shortcut ist f. Zoomen können Sie + auch durch Drehen des Mausrads und Pannen durch Ziehen der Maus mit gedrücktem Mausrad.

+
+

Unit

+
+

Hier kann die Maßeinheit und der Maßeinheits-Faktor eingestellt werden. Sie können auswählen + zwischen mil, inch, mm und um. Wenn Sie z. B. 0.1 mm einstellen, werden + alle Koordinaten auf der Benutzeroberfläche als vielfache von 0,1 mm angezeigt.

+
+
+

Die Popup-Menü-Einträge:

+
+ Objekt selektieren +
+

Zum Selektieren von Objekten unter dem Cursor. Dabei werden die Einstellungen aus dem Fenster Select-Einstellungen ausgewertet. Wurden Objekte zum Auswählen + gefunden, befindet sich das Programm danach im Auswahl-Zustand. Im Select-Menü-Zustand könne Sie auch mit der linken Maustaste + Objekte selektieren.

+
+ Route starten +
Vom Objekt unter dem Mauszeiger aus wird eine neue Bahn begonnen. Dabei werden die Einstellungen aus dem + Fenster Select-Einstellungen ausgewertet. Wurde ein geeignetes Objekt + gefunden, befindet sich das Programm danach im Route-Zustand. Im Route-Menü-Zustand reicht dazu das Klicken mit der linken Maustaste, +
+ Sperrfläche konstruieren +
Hiermit können Sie auf der aktuellen Lage eine Sperrfläche konstruieren. Dabei kann es sich um + einen Kreis, ein Polygon, oder um ein Loch in einer existierenden polygonalen Sperrfläche handeln. +
+ Pin tauschen +
Dieser Menü-Eintrag erscheint nur, wenn es auf der Platine tauschbare Pins gibt. Ist der Pin unter + dem Cursor tauschbar, können Sie hier die Netz-Zugehörigkeit dieses Pins mit einem anderen Pin + tauschen. +
+

Die Zeichen in Klammern hinter den Popup-Menü-Einträgen bezeichnen die Shortcuts für die + entsprechenden Aktionen.

+
+

Die Funktion des Mausrad:

+
+

Durch Drehen mit dem Mausrad können Sie den abgebildeten Ausschnitt der Platine + vergrößern oder verkleinern, und durch Ziehen der Maus mit gedrücktem Mausrad können Sie + das abgebildete Rechteck verschieben.

+ +

+
+

+ +

Der Selektions-Menü-Zustand

+ +Ist oben links auf der Werkzeugleiste der Button Selektieren angewählt, befindet sich das Programm im +Selektions-Menü-Zustand. Die linke Maustaste dient hier als Shortcut für die Aktion Objekt selektieren +im Popup-Menü. Außer dem können Sie durch Ziehen der Maus mit gedrückter linker Taste alle Objekte +in einem Rechteck selektieren. + +

zurück

+

+ +

Der Route-Menü-Zustand

+ +Ist oben links auf der Werkzeugleiste der Button Routen angewählt, befindet sich das Programm im Route-Menü-Zustand. +Die linke Maustaste dient hier als Shortcut für die Aktion Route starten im Popup-Menü. + +

zurück

+

+ +

Der Zieh-Menü-Zustand

+ +Ist oben links auf der Werkzeugleiste der Button Ziehen angewählt, befindet sich das Programm im Zieh-Menü-Zustand. +Hier können Sie mit gedrückter linker Maustaste Vias oder Bauteile ziehen und so ihre Position verändern. +Dabei werden die angeschlossenen Bahnen automatisch mit verändert. Weiter können Sie mit gedrückter +linker Maustaste aus dem leeren Raum heraus Bahnen beiseite schieben und sich so Platz schaffen z. B. für das Einfügen +eines weiteren Bauteils. Diese Aktion wird auf der Aktuellen Lage ausgeführt, die im Fenster mit den Select-Einstellungen eingestellt werden kann. + +

zurück

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/MoveItemState.html b/src/main/java/net/freerouting/helpset/de/html_files/MoveItemState.html index fd4eed21..b69d14f5 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/MoveItemState.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/MoveItemState.html @@ -2,47 +2,63 @@ - - - - Move-Zustand - + + + + Move-Zustand + - -

Der Move-Zustand

- Hierher gelangen Sie, nachdem Sie in Auswahl-Zustand im Popup-Menü verschieben gewählt haben. Die selektierten Objekte folgen jetzt dem Cursor. -

Wenn Teile der sich bewegenden Objekte rot markiert sind, würde beim Einfügen an dieser Stelle eine Clearance-Verletzung entstehen.

-

Es können mehrere Bauteile gleichzeitig verschoben werden. Der interne Route wird mitgenommen, insofern er komplett zum Verschieben markiert ist. Bauteile können nicht verschoben werden, wenn sie mit Objekten verbunden sind, die nicht zum Verschieben markiert sind. Solche Bauteile können Sie evtl. im Drag-Menü-Zustand durch Ziehen mit der linken Maustaste bewegen. Ansonsten müssen Sie vorher den Route entfernen.

-

Es werden die Einstellungen im Fenster mit den Platzierungs-Parametern ausgewertet.

-

Die Einträge im Popup-Menü unter der rechten Maustaste:

-
- drehen -
-

Hier können Sie die ausgewählten Bauteile um vielfache von 45 Grad um den Cursor drehen. Für Drehungen um 90, 180, und -90 Grad gibt es die Shortcuts +, * und - auf der Tastatur rechts vom Ziffernblock. Wenn Sie um einen Winkel drehen möchten, der kein vielfaches von 45 Grad ist, können Sie das durch Drehen mit dem Mausrad, nachdem Sie im Fenster mit den Platzierungs-Parametern die Funktion des Mausrads von zoomen auf drehen umgestellt haben.

-
-

Seite wechseln

-
-

Hier können Sie die Platzierungsseite der ausgewählten Bauteile wechseln. Shortcut ist /.

-
-

Rotation zurücksetzen

-
-

Hier können Sie die Rotation der selektierten Bauteile auf 0 Grad zurücksetzen, nachdem Sie sie vorher durch Drehen mit dem Mausrad verändert hatten.

-
-

einfügen

-
-

Zum Einfügen der am Cursor hängenden Bauteile. Wenn dabei Clearance-Verletzungen entstehen würden, wird das Einfügen verweigert. Shortcut ist die linke Maustaste.

-
-

abbrechen

-
-

Zum Abrechen der Verschiebe-Aktion. Die selektierten Bauteile springen an ihren Ausgangspunkt zurück. Shortcut ist die Esc-Taste.

-
-
-

zurück

-
-
-

-
-
- + +

Der Move-Zustand

+Hierher gelangen Sie, nachdem Sie in Auswahl-Zustand im Popup-Menü verschieben +gewählt haben. Die selektierten Objekte folgen jetzt dem Cursor. +

Wenn Teile der sich bewegenden Objekte rot markiert sind, würde beim Einfügen an dieser Stelle eine + Clearance-Verletzung entstehen.

+ +

Es können mehrere Bauteile gleichzeitig verschoben werden. Der interne Route wird mitgenommen, insofern er + komplett zum Verschieben markiert ist. Bauteile können nicht verschoben werden, wenn sie mit Objekten verbunden + sind, die nicht zum Verschieben markiert sind. Solche Bauteile können Sie evtl. im Drag-Menü-Zustand durch Ziehen mit der linken Maustaste + bewegen. Ansonsten müssen Sie vorher den Route entfernen.

+ +

Es werden die Einstellungen im Fenster mit den Platzierungs-Parametern + ausgewertet.

+

Die Einträge im Popup-Menü unter der rechten Maustaste:

+
+ drehen +
+

Hier können Sie die ausgewählten Bauteile um vielfache von 45 Grad um den Cursor drehen. Für + Drehungen um 90, 180, und -90 Grad gibt es die Shortcuts +, * und - auf der Tastatur rechts vom + Ziffernblock. Wenn Sie um einen Winkel drehen möchten, der kein vielfaches von 45 Grad ist, können + Sie das durch Drehen mit dem Mausrad, nachdem Sie im Fenster mit den Platzierungs-Parametern die + Funktion des Mausrads von zoomen auf drehen umgestellt haben.

+
+

Seite wechseln

+
+

Hier können Sie die Platzierungsseite der ausgewählten Bauteile wechseln. Shortcut ist /.

+
+

Rotation zurücksetzen

+
+

Hier können Sie die Rotation der selektierten Bauteile auf 0 Grad zurücksetzen, nachdem Sie sie + vorher durch Drehen mit dem Mausrad verändert hatten.

+
+

einfügen

+
+

Zum Einfügen der am Cursor hängenden Bauteile. Wenn dabei Clearance-Verletzungen entstehen würden, + wird das Einfügen verweigert. Shortcut ist die linke Maustaste.

+
+

abbrechen

+
+

Zum Abrechen der Verschiebe-Aktion. Die selektierten Bauteile springen an ihren Ausgangspunkt zurück. + Shortcut ist die Esc-Taste.

+
+
+

zurück

+
+
+

+
+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/RouteState.html b/src/main/java/net/freerouting/helpset/de/html_files/RouteState.html index 6c4562b5..4da4716f 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/RouteState.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/RouteState.html @@ -2,63 +2,97 @@ - - - - Route-Zustand - + + + + Route-Zustand + - -

Die Route-Zustände

- Nachdem Sie im Grundzustand einen Route gestartet haben, befindet sich das Programm in einem Route-Zustand., und zwar im Dynamic-Route-Zustand oder im Stitching-Route-Zustand, abhängig davon ob im Route-Parameter-Fenster der Route-Modus auf dynamisch oder stitching eingestellt ist. -

Je nachdem ob die Regel-Auswahl auf automatisch oder manuell eingestellt ist, werden die Regeln zum Routen wie Bahnbreite, Clearance-Klasse und Via-Regel durch die Netzklasse des aktiven Netz oder durch die Einstellungen im Fenster für die manuellen Regeln bestimmt. + +

Die Route-Zustände

+Nachdem Sie im Grundzustand einen Route gestartet haben, befindet sich das +Programm in einem Route-Zustand., und zwar im Dynamic-Route-Zustand oder im Stitching-Route-Zustand, abhängig davon ob im Route-Parameter-Fenster der +Route-Modus auf dynamisch oder stitching eingestellt +ist. +

Je nachdem ob die Regel-Auswahl auf automatisch oder + manuell eingestellt ist, werden die Regeln zum Routen wie Bahnbreite, Clearance-Klasse und Via-Regel durch die + Netzklasse des aktiven Netz oder durch die Einstellungen im Fenster für die manuellen Regeln bestimmt.

-

Nähert sich die neu geroutete Bahn einem noch nicht verbundenen Objekt vom gleichen Netz auf der gleichen Lage, wird dort automatisch angeschlossen. Danach kehrt das Programm in den interaktiven Zustand vor dem Routen zurück.

-

zurück

-

Der Dynamic-Route-Zustand

- - In diesem Route-Zustand wird bei jeder Bewegung des Cursors automatisch ein Stück Bahn von der letzten Cursor-Position zur aktuellen Cursor-Position eingefügt. Abhängig von der Einstellung für den Glattzieh-Bereich im Route-Parameter-Fenster wird die Bahn danach sofort glatt gezogen.

Die Einträge im Popup-Menü unter der rechten Maustaste im Dynamic-Route-Zustand:

-
- Lage wechseln -
-

Zum Wechseln auf eine andere Lage. Das zugehörige Via wird folgendermaßen aus der eingestellten Via-Regel bestimmt: Die Vias in der Via-Regel werden von oben nach unten durchprobiert, ob sie die alte und die neue Lage umfassen, und ob ein Einfügen ohne Clearance-Verletzungen möglich ist. Das erste dabei gefundene Via wird eingesetzt. Shortcut sind die Zifferntasten 1-9 und die Tasten + und -. Mit "+" können Sie zur nächst größeren Lage wechseln und mit "-" zur nächst kleineren.

-
-

Route beenden

-
-

Das Routen wird beendet und das Programm kehrt in den vorherigen Zustand zurück. Shortcut ist die linke Maustaste

-
-

Route abbrechen

-
-

Die zuletzt geroutete Bahn wird weggeworfen und das Programm kehrt in den vorherigen Zustand zurück. Shortcut ist die Esc-Taste.

-
-

Snapshot erzeugen

-
-

Das Programm erzeugt einen Snapshot, so dass Sie später die Situation zum Zeitpunkt des Snapshots mit Undo wiederherstellen können. Sonst können Sie mit Undo nur die Situation vor dem Beginn der letzten Bahn wiederherstellen. Shortcut ist s.

-
-
-

zurück

-
-
-

-
-
-

Der Stitching-Route-Zustand

In diesem Route-Zustand wird bei Klicken der linken Maustaste ein Stück Bahn von der letzten Klick-Position zur aktuellen Cursor-Position eingefügt. Abhängig von der Einstellung für den Glattzieh-Bereich im Route-Parameter-Fenster wird die Bahn danach glatt gezogen. -

Die Einträge im Popup-Menü unter der rechten Maustaste im Stitching-Route-Zustand:

-
-

einfügen

-
-

Vom letzten Einfügepunkt zum aktuellen Einfügepunkt wird eine Bahn gezogen und abhängig von der Einstellung für den Glattzieh-Bereich im Route-Parameter-Fenster glatt gezogen. Shortcut ist die linke Maustaste

-
-

beenden

-
-

Das Programm kehrt in den Zustand vor dem Routen zurück. Shortcut ist die Esc-Taste.

-
-

Lage wechseln

-
-

Zum Wechseln auf eine andere Lage. Das zugehörige Via wird folgendermaßen aus der eingestellten Via-Regel bestimmt: Die Vias in der Via-Regel werden von oben nach unten durchprobiert, ob sie die alte und die neue Lage umfassen, und ob ein Einfügen ohne Clearance-Verletzungen möglich ist. Das erste dabei gefundene Via wird eingesetzt. Shortcut sind die Zifferntasten 1-9 und die Tasten + und -. Mit "+" können Sie zur nächst größeren Lage wechseln und mit "-" zur nächst kleineren.

-
-
-

zurück

- + +

Nähert sich die neu geroutete Bahn einem noch nicht verbundenen Objekt vom gleichen Netz auf der gleichen Lage, + wird dort automatisch angeschlossen. Danach kehrt das Programm in den interaktiven Zustand vor dem Routen zurück.

+ +

zurück

+ +

Der Dynamic-Route-Zustand

+ +In diesem Route-Zustand wird bei jeder Bewegung des Cursors automatisch ein Stück Bahn von der letzten +Cursor-Position zur aktuellen Cursor-Position eingefügt. Abhängig von der Einstellung für den Glattzieh-Bereich im Route-Parameter-Fenster wird die Bahn +danach sofort glatt gezogen.

Die Einträge im Popup-Menü unter der rechten Maustaste im + Dynamic-Route-Zustand:

+
+ Lage wechseln +
+

Zum Wechseln auf eine andere Lage. Das zugehörige Via wird folgendermaßen aus der eingestellten Via-Regel bestimmt: Die Vias in der Via-Regel werden von + oben nach unten durchprobiert, ob sie die alte und die neue Lage umfassen, und ob ein Einfügen ohne + Clearance-Verletzungen möglich ist. Das erste dabei gefundene Via wird eingesetzt. Shortcut sind die + Zifferntasten 1-9 und die Tasten + und -. Mit "+" können Sie zur nächst größeren + Lage wechseln und mit "-" zur nächst kleineren.

+
+

Route beenden

+
+

Das Routen wird beendet und das Programm kehrt in den vorherigen Zustand zurück. Shortcut ist die linke + Maustaste

+
+

Route abbrechen

+
+

Die zuletzt geroutete Bahn wird weggeworfen und das Programm kehrt in den vorherigen Zustand zurück. + Shortcut ist die Esc-Taste.

+
+

Snapshot erzeugen

+
+

Das Programm erzeugt einen Snapshot, so dass Sie später die Situation zum Zeitpunkt des Snapshots mit + Undo wiederherstellen können. Sonst können Sie mit Undo nur die Situation vor dem Beginn der + letzten Bahn wiederherstellen. Shortcut ist s.

+
+
+

zurück

+
+
+

+
+
+

Der Stitching-Route-Zustand

In diesem Route-Zustand wird bei Klicken der +linken Maustaste ein Stück Bahn von der letzten Klick-Position zur aktuellen Cursor-Position eingefügt. Abhängig +von der Einstellung für den Glattzieh-Bereich im +Route-Parameter-Fenster wird die Bahn danach glatt gezogen. +

Die Einträge im Popup-Menü unter der rechten Maustaste im Stitching-Route-Zustand:

+
+

einfügen

+
+

Vom letzten Einfügepunkt zum aktuellen Einfügepunkt wird eine Bahn gezogen und abhängig von + der Einstellung für den Glattzieh-Bereich im + Route-Parameter-Fenster glatt gezogen. Shortcut ist die linke Maustaste

+
+

beenden

+
+

Das Programm kehrt in den Zustand vor dem Routen zurück. Shortcut ist die Esc-Taste.

+
+

Lage wechseln

+
+

Zum Wechseln auf eine andere Lage. Das zugehörige Via wird folgendermaßen aus der eingestellten Via-Regel bestimmt: Die Vias in der Via-Regel werden von oben + nach unten durchprobiert, ob sie die alte und die neue Lage umfassen, und ob ein Einfügen ohne + Clearance-Verletzungen möglich ist. Das erste dabei gefundene Via wird eingesetzt. Shortcut sind die + Zifferntasten 1-9 und die Tasten + und -. Mit "+" können Sie zur nächst größeren + Lage wechseln und mit "-" zur nächst kleineren.

+
+
+

zurück

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/SelectedItemState.html b/src/main/java/net/freerouting/helpset/de/html_files/SelectedItemState.html index 7d6cc50c..c1c233c9 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/SelectedItemState.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/SelectedItemState.html @@ -2,92 +2,116 @@ - - - - Auswahl-Zustand - + + + + Auswahl-Zustand + - -

Der Auswahl-Zustand

- Nachdem Sie im Grundzustand Objekte selektiert haben, befindet sich das Programm im Auswahl-Zustand. Die selektierten Objekte werden gehighlightet und es erscheint am oberen Rand ein neuer Toolbar. Mit der linken Maustaste können Sie weitere Objekte selektieren oder schon selektierte Objekte wieder abwählen.

Der Toolbar im Auswahl-Zustand

-
- Abbrechen -
-

Das Programm kehrt in den interaktiven Zustand vor dem Selektieren zurück. Shortcut ist die Esc-Taste.

-
-

Info

-
-

In einem Fenster werden Informationen über die selektierten Objekte ausgegeben. Über die dort blau markierten Begriffe können Sie sich durch Klicken mit der linken Maustaste weitere Informationen besorgen. Shortcut ist i.

-
-

Löschen

-
-

Die markierten Objekte werden gelöscht, sofern sie nicht gefixt sind. Shortcut ist die Entf-Taste.

-
-

Ausschneiden

-
-

Durch Ziehen der Maus mit gedrückter linker Taste können Sie ein Rechteck definieren, aus dem die selektierten Bahnen und Vias ausgeschnitten werden. Shortcut ist d.

-
-

Fix

-
-

Die selektierten Objekte fixieren, so dass sie nicht mehr verschoben oder gelöscht werden können. Shortcut ist f.

-
-

Unfix

-
-

Die Fixierung der selektierten Objekte aufheben. Shortcut ist u.

-
-

Autoroute

-
-

Die selektierten Objekte automatisch routen. Shortcut ist a.

-
-

Glätten

-
-

Die selektierten Bahnen glatt ziehen. Shortcut ist p.

-
-

Fanout

-
-

Die selektierten SMD-Pins automatisch bis zum ersten Via routen.

-
-

Clearance

-
-

Den selektierten Objekten eine neue Clearance-Klasse zuweisen.

-

Beispiel: Wenn Sie in einem bestimmten Bereich der Platine einen größeren Mindestabstand brauchen, können Sie alle Pins in einem Rechteck selektieren und ihnen eine neue Clearance-Klasse zuweisen.

-
-

Netze

-
-

Die Auswahl auf alle selektierbaren Objekte ausdehnen, die das gleiche Netz wie ein schon ausgewähltes Objekt haben. Shortcut ist n.

-
-

Zush.

-
-

Die Auswahl auf alle selektierbaren Objekte ausdehnen, die mit einem schon ausgewählten Objekt elektrisch verbunden sind. Shortcut ist s.

-
-

Verb.

-
-

Die Auswahl auf alle Bahnen und Vias ausdehnen, die zur gleichen Verbindung wie ein schon ausgewählten Objekts gehören. Shortcut ist e.

-

Beispiel: Sie möchten eine komplette Verbindung löschen. Selektieren Sie eine Bahn der Verbindung. Drücken Sie zuerst auf den Button Verb. um die Auswahl auf die ganze Verbindung auszudehnen, und dann auf den Button Löschen.

-
-

Bauteile

-
-

Die Auswahl auf alle selektierbaren Objekte ausdehnen, die zum gleichen Bauteil wie ein schon ausgewähltes Objekt gehören. Shortcut ist b.

-
-

Verletzungen

-
-

Hier können Sie das Zeigen der Abstandsverletzungen der selektierten Objekte an- oder abschalten. Wenn die Abstandsverletzungen vorher abgeschaltet waren, werden sie eingeschaltet und umgekehrt. Shortcut ist v.

-
-

Auswahl abbilden

-
-

Bildet ein umgebendes Rechteck um alle selektierten Objekte ab.

-
-
-

Das Popup-Menü unter der rechten Maustaste

-
- verschieben -
Hier werden die selektierten Objekte zum Verschieben vorbereitet. Der Dreh- und Angelpunkt beim Verschieben ist die aktuelle Cursor-Position. Es können mehrere Bauteile gleichzeitig verschoben werden. Nach dieser Aktion befindet sich das Programm im Move-Zustand. Shortcut is m.
-
-

zurück

-
-

-
- + +

Der Auswahl-Zustand

+Nachdem Sie im Grundzustand Objekte selektiert haben, befindet sich das +Programm im Auswahl-Zustand. Die selektierten Objekte werden gehighlightet und es erscheint am oberen Rand ein neuer +Toolbar. Mit der linken Maustaste können Sie weitere Objekte selektieren oder schon selektierte Objekte wieder abwählen. +

Der Toolbar im Auswahl-Zustand

+
+ Abbrechen +
+

Das Programm kehrt in den interaktiven Zustand vor dem Selektieren zurück. Shortcut ist die Esc-Taste. +

+
+

Info

+
+

In einem Fenster werden Informationen über die selektierten Objekte ausgegeben. Über die dort blau + markierten Begriffe können Sie sich durch Klicken mit der linken Maustaste weitere Informationen + besorgen. Shortcut ist i.

+
+

Löschen

+
+

Die markierten Objekte werden gelöscht, sofern sie nicht gefixt sind. Shortcut ist die Entf-Taste. +

+
+

Ausschneiden

+
+

Durch Ziehen der Maus mit gedrückter linker Taste können Sie ein Rechteck definieren, aus dem die + selektierten Bahnen und Vias ausgeschnitten werden. Shortcut ist d.

+
+

Fix

+
+

Die selektierten Objekte fixieren, so dass sie nicht mehr verschoben oder gelöscht werden können. + Shortcut ist f.

+
+

Unfix

+
+

Die Fixierung der selektierten Objekte aufheben. Shortcut ist u.

+
+

Autoroute

+
+

Die selektierten Objekte automatisch routen. Shortcut ist a.

+
+

Glätten

+
+

Die selektierten Bahnen glatt ziehen. Shortcut ist p.

+
+

Fanout

+
+

Die selektierten SMD-Pins automatisch bis zum ersten Via routen.

+
+

Clearance

+
+

Den selektierten Objekten eine neue Clearance-Klasse zuweisen.

+ +

Beispiel: Wenn Sie in einem bestimmten Bereich der Platine einen größeren Mindestabstand brauchen, + können Sie alle Pins in einem Rechteck selektieren und ihnen eine neue Clearance-Klasse zuweisen.

+
+

Netze

+
+

Die Auswahl auf alle selektierbaren Objekte ausdehnen, die das gleiche Netz wie ein schon ausgewähltes + Objekt haben. Shortcut ist n.

+
+

Zush.

+
+

Die Auswahl auf alle selektierbaren Objekte ausdehnen, die mit einem schon ausgewählten Objekt + elektrisch verbunden sind. Shortcut ist s.

+
+

Verb.

+
+

Die Auswahl auf alle Bahnen und Vias ausdehnen, die zur gleichen Verbindung wie ein schon ausgewählten + Objekts gehören. Shortcut ist e.

+ +

Beispiel: Sie möchten eine komplette Verbindung löschen. Selektieren Sie eine Bahn der Verbindung. + Drücken Sie zuerst auf den Button Verb. um die Auswahl auf die ganze Verbindung auszudehnen, und + dann auf den Button Löschen.

+
+

Bauteile

+
+

Die Auswahl auf alle selektierbaren Objekte ausdehnen, die zum gleichen Bauteil wie ein schon ausgewähltes + Objekt gehören. Shortcut ist b.

+
+

Verletzungen

+
+

Hier können Sie das Zeigen der Abstandsverletzungen der selektierten Objekte an- oder abschalten. Wenn + die Abstandsverletzungen vorher abgeschaltet waren, werden sie eingeschaltet und umgekehrt. Shortcut ist v. +

+
+

Auswahl abbilden

+
+

Bildet ein umgebendes Rechteck um alle selektierten Objekte ab.

+
+
+

Das Popup-Menü unter der rechten Maustaste

+
+ verschieben +
Hier werden die selektierten Objekte zum Verschieben vorbereitet. Der Dreh- und Angelpunkt beim + Verschieben ist die aktuelle Cursor-Position. Es können mehrere Bauteile gleichzeitig verschoben werden. + Nach dieser Aktion befindet sich das Programm im Move-Zustand. Shortcut is + m. +
+
+

zurück

+
+

+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteDetailParameter.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteDetailParameter.html index ab450bef..5d76c51f 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteDetailParameter.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteDetailParameter.html @@ -1,36 +1,42 @@ - + - - - - Detailierte Autoroute-Einstellungen - + + + + Detailierte Autoroute-Einstellungen + - -

Detailierte Autoroute-Einstellungen

- Beschreibung des Fensters mit den detailierten Autoroute-Einstellungen: -

Via-Kosten:

-
-
-

Zum Einstellen der Kosten für Vias im Autoroute-Algorithmus. Wenn Sie den Wert vergrößern, wird der Autorouter versuchen, mit weniger Durchkontaktierungen auszukommen. Ein zu hoher Wert beeintächtigt die Auflösung des Autoroute-Algorithmus,

-
-
-

Start-Pass:

-
-

Zum Einstellen der Nummer des ersten Pass im Batch-Autorouter. Diese Pass-Nummer beinflusst die Ripup-Kosten. Die Ripup-Kosten steigen bei Passes mit höherer Nummer.

-
-

Ripup-Anfangskosten:

-
-

Zum Einstellen der Ripup-Kosten im Pass mit der Nummer 1. Die Ripup-Kosten im Pass mit der Nummer N betragen (N * Ripup-Anfangskosten).

-
-

Trace-Kosten auf Lage:

-
-

Hier können Sie für jede Signallage die Kosten für Traces in und gegen die Vorzugsrichtung einstellen.

-
-

zurück

-

- + +

Detailierte Autoroute-Einstellungen

+Beschreibung des Fensters mit den detailierten Autoroute-Einstellungen: +

Via-Kosten:

+
+
+

Zum Einstellen der Kosten für Vias im Autoroute-Algorithmus. Wenn Sie den Wert vergrößern, wird der + Autorouter versuchen, mit weniger Durchkontaktierungen auszukommen. Ein zu hoher Wert beeintächtigt die + Auflösung des Autoroute-Algorithmus,

+
+
+

Start-Pass:

+
+

Zum Einstellen der Nummer des ersten Pass im Batch-Autorouter. Diese Pass-Nummer beinflusst die Ripup-Kosten. Die + Ripup-Kosten steigen bei Passes mit höherer Nummer.

+
+

Ripup-Anfangskosten:

+
+

Zum Einstellen der Ripup-Kosten im Pass mit der Nummer 1. Die Ripup-Kosten im Pass mit der Nummer N + betragen (N * Ripup-Anfangskosten).

+
+

Trace-Kosten auf Lage:

+
+

Hier können Sie für jede Signallage die Kosten für Traces in und gegen die Vorzugsrichtung einstellen.

+
+

zurück

+ +

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteParameter.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteParameter.html index f68de7dd..e51b1757 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteParameter.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowAutorouteParameter.html @@ -1,21 +1,31 @@ - + - - - - Autoroute-Einstellungen - - - -

Autoroute-Einstellungen

Hier können Sie die Lagen definieren, die der Autorouter benutzen darf, die Vorzugsrichtung für Bahnen auf jeder Lage, und ob der Autorouter Vias setzen darf. -

Außerdem können Sie festlegen, ob vor dem Autorouten ein Fanout Pass und ob nach dem Autorouten ein Postroute Pass zum Reduzieren der Via-Anzahl und der Gesamtbahnlänge laufen soll.

-

Der Postroute Pass kann sehr lange dauern und jederzeit durch Klicken der linken Maustaste beendet werden.

-

Beim Fanout Pass werden die Verbindungen nur bis zum ersten Via geroutet. Das kann bei Platinen und vielen Lagen und Ball Grid Arrays sinnvoll sein.

-

-

Der Button Detail-Einstellungen öffnet ein Fenster, in dem Sie die im Autoroute-Algorithmus verwendeten Kosten ändern können.

-

zurück

- + + + + Autoroute-Einstellungen + + + +

Autoroute-Einstellungen

Hier können Sie die Lagen definieren, die der Autorouter benutzen darf, die +Vorzugsrichtung für Bahnen auf jeder Lage, und ob der Autorouter Vias setzen darf. +

Außerdem können Sie festlegen, ob vor dem Autorouten ein Fanout Pass und ob nach dem Autorouten ein Postroute Pass + zum Reduzieren der Via-Anzahl und der Gesamtbahnlänge laufen soll.

+ +

Der Postroute Pass kann sehr lange dauern und jederzeit durch Klicken der linken Maustaste beendet werden.

+ +

Beim Fanout Pass werden die Verbindungen nur bis zum ersten Via geroutet. Das kann bei Platinen und vielen Lagen und + Ball Grid Arrays sinnvoll sein.

+ +

+ +

Der Button Detail-Einstellungen öffnet ein Fenster, in dem + Sie die im Autoroute-Algorithmus verwendeten Kosten ändern können.

+ +

zurück

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowClearanceMatrix.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowClearanceMatrix.html index d2589c7b..84c636e8 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowClearanceMatrix.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowClearanceMatrix.html @@ -2,21 +2,44 @@ - - - - Clearance-Matrix - + + + + Clearance-Matrix + - -

Die Clearance-Matrix

-

Im Fenster mit der Clearance-Matrix können Sie die Mindestabstandsregeln zwischen Objekten festlegen. Das geschieht mittels Clearance-Klassen. Eine Objekt-Clearance-Klasse ist durch die Festlegung eines Mindestabstand zu Objekten von allen vorhandenen Clearance-Klasssen definiert. Diese Werte können in der Clearance-Matrix eingesehen und editiert werden.

-

Vordefiniert sind die Clearance-Klassen null und default. Objekte der Clearance-Klasse null haben einen Mindestabstand von 0 zu allen anderen Objekten. Dieser Wert kann in der Clearance-Matrix nicht verändert werden.

-

Das Specctra-DSN-Format kennt nur die hard-codierten Clearance-Klassen pin, smd, via, wire, area und testpoint. Beim Einlesen des DSN-Files nach dem Start des Programms werden die Clearance-Klassen aus dem Hostsystem übernommen. Dabei wird die Clearance-Klasse wire in default umbenannt. Die anderen hard-codierten Clearance-Klassen werden nur dann beim Einlesen erzeugt, wenn dafür eigene Werte im DSN-File gefunden werden.

-

Eine neue Clearance-Klasse hinzufügen

- Drücken Sie den Button Klasse hinzufügen und geben Sie im daraufhin erscheinenden Dialogfeld den Namen der neuen Klasse ein. Die Matrix wird um eine Zeile und eine Spalte mit den Werten für die neue Clearance-Klasse erweitert. Ändern Sie die voreingestellten Werte in der neuen Zeile nach Ihren Anforderungen.

Redundante Clearance-Klassen entfernen

- Indem Sie den Button Trimmen drücken, können Sie Clearance-Klassen, deren Matrixeinträge mit den Werten einer anderen Clearance-Klasse genau übereinstimmen, als redundant entfernen. Alle Objekte, die zu der gelöschten Clearance-Klasse gehörten, werden dann dieser anderen Clearance-Klasse zugewiesen.

Lagenabhängige Clearance-Werte

- Das Lagenfeld oben am Fenster gibt an, auf welchen Lagen die Clearance-Werte in der Matrix gelten sollen. Bei der voreingestellten Auswahl von alle gelten die Werte auf allen Lagen. Ob für ein bestimmtes Feld lagenabhängige Clearance-Werte definiert sind, sehen Sie daran, dass bei der Einstellung von alle in diesem Feld der Wert -1 erscheint. (Es kann nämlich kein für alle Lagen gültiger Wert ausgegeben werden.) Analoges gilt bei der Auswahl von innere, die für alle Innenlagen gilt. Einen lagenabhängigen Wert können Sie ansehen oder ändern, nachdem Sie im Lagenfeld den Namen Ihrer gewünschten Lage eingestellt haben.

- + +

Die Clearance-Matrix

+ +

Im Fenster mit der Clearance-Matrix können Sie die Mindestabstandsregeln zwischen Objekten festlegen. Das + geschieht mittels Clearance-Klassen. Eine Objekt-Clearance-Klasse ist durch die Festlegung eines Mindestabstand zu + Objekten von allen vorhandenen Clearance-Klasssen definiert. Diese Werte können in der Clearance-Matrix + eingesehen und editiert werden.

+ +

Vordefiniert sind die Clearance-Klassen null und default. Objekte der Clearance-Klasse null + haben einen Mindestabstand von 0 zu allen anderen Objekten. Dieser Wert kann in der Clearance-Matrix nicht verändert + werden.

+ +

Das Specctra-DSN-Format kennt nur die hard-codierten Clearance-Klassen pin, smd, via, wire, area und testpoint. + Beim Einlesen des DSN-Files nach dem Start des Programms werden die Clearance-Klassen aus dem Hostsystem übernommen. + Dabei wird die Clearance-Klasse wire in default umbenannt. Die anderen hard-codierten + Clearance-Klassen werden nur dann beim Einlesen erzeugt, wenn dafür eigene Werte im DSN-File gefunden werden. +

+

Eine neue Clearance-Klasse hinzufügen

+Drücken Sie den Button Klasse hinzufügen und geben Sie im daraufhin erscheinenden Dialogfeld den Namen +der neuen Klasse ein. Die Matrix wird um eine Zeile und eine Spalte mit den Werten für die neue Clearance-Klasse +erweitert. Ändern Sie die voreingestellten Werte in der neuen Zeile nach Ihren Anforderungen.

Redundante + Clearance-Klassen entfernen

+Indem Sie den Button Trimmen drücken, können Sie Clearance-Klassen, deren Matrixeinträge mit den +Werten einer anderen Clearance-Klasse genau übereinstimmen, als redundant entfernen. Alle Objekte, die zu der gelöschten +Clearance-Klasse gehörten, werden dann dieser anderen Clearance-Klasse zugewiesen.

Lagenabhängige + Clearance-Werte

+Das Lagenfeld oben am Fenster gibt an, auf welchen Lagen die Clearance-Werte in der Matrix gelten sollen. Bei der +voreingestellten Auswahl von alle gelten die Werte auf allen Lagen. Ob für ein bestimmtes Feld lagenabhängige +Clearance-Werte definiert sind, sehen Sie daran, dass bei der Einstellung von alle in diesem Feld der Wert -1 +erscheint. (Es kann nämlich kein für alle Lagen gültiger Wert ausgegeben werden.) Analoges gilt bei der +Auswahl von innere, die für alle Innenlagen gilt. Einen lagenabhängigen Wert können Sie ansehen +oder ändern, nachdem Sie im Lagenfeld den Namen Ihrer gewünschten Lage eingestellt haben.

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowDisplay.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowDisplay.html index c3f8e20e..1594b007 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowDisplay.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowDisplay.html @@ -2,47 +2,62 @@ - - - - Display-Einstellungen - + + + + Display-Einstellungen + - -

Display-Einstellungen

- Beschreibung der Fenster für die Display-Einstellungen. -
-

Objekt-Sichtbarkeit

-
Mit den Schiebereglern in diesem Fenster können Sie die Intensität einstellen, mit denen die einzelnen Objekttypen abgebildet werden. Die Werte gehen kontinuierlich von alles überdeckender Sichtbarkeit ganz rechts bis zu völliger Unsichtbarkeit ganz links über. Es empfiehlt sich die Sichtbarkeit für Flächen-Objekte (Leitungsflächen, Sperrflächen) nicht zu groß einzustellen.
-

Lagen-Sichtbarkeit

-
-

Mit diesen Schiebereglern können Sie für jede einzelne Lage einstellen, mit welcher Intensität Objekte auf dieser Lage abgebildet werden sollen. Ziehen Sie einen Schieberegler ganz links, werden die Objekte auf der entsprechenden Lage unsichtbar.

-
-

Farben

-
-

Hier können Sie die Farben festlegen, mit denen Objekte auf der Platine abgebildet werden, indem Sie mit der linken Maustaste auf das entsprechende Farbfeld klicken. Für die Objekttypen in der oberen Tabelle kann die Farbe für jede Lage einzeln eingestellt werden.

-
-

sonstiges

-
-

Crosshair-Cursor

-
-

Hier können Sie vom normalen kleinem Crosshair-Cursor zu einem großen 45-Grad Crosshair-Cursor umschalten. Das Verwenden des großen Crosshair-Cursors kann die Display-Performance erheblich beeinträchtigen. Shortcut ist die Komma-Taste.

-
-

Platinenrotation

-
-

Hier können Sie die Platine um vielfache von 90 Grad drehen.

-
-

Platinenspiegelung

-
-

Hier können Sie die Platine an der horizontalen oder vertikalen Achse spiegeln.

-
-

automatisches Lagen-Dimmen

-
-

mit dem Schieberegler können Sie einstellen, wie stark Objekte auf der in den Select-Einstellungen beschriebenen aktuellen Lage hervorgehoben werden sollen. Wenn Sie den Regler ganz nach links schieben, wird das automatische Lagen-Dimmen komplett abgeschaltet, schieben Sie ihn ganz nach rechts, werden alle Lagen bis auf die aktuelle Lage unsichtbar.

-
-

-
-
- + +

Display-Einstellungen

+Beschreibung der Fenster für die Display-Einstellungen. +
+

Objekt-Sichtbarkeit

+
Mit den Schiebereglern in diesem Fenster können Sie die Intensität einstellen, mit denen die + einzelnen Objekttypen abgebildet werden. Die Werte gehen kontinuierlich von alles überdeckender + Sichtbarkeit ganz rechts bis zu völliger Unsichtbarkeit ganz links über. Es empfiehlt sich die + Sichtbarkeit für Flächen-Objekte (Leitungsflächen, Sperrflächen) nicht zu groß + einzustellen. +
+

Lagen-Sichtbarkeit

+
+

Mit diesen Schiebereglern können Sie für jede einzelne Lage einstellen, mit welcher Intensität + Objekte auf dieser Lage abgebildet werden sollen. Ziehen Sie einen Schieberegler ganz links, werden die + Objekte auf der entsprechenden Lage unsichtbar.

+
+

Farben

+
+

Hier können Sie die Farben festlegen, mit denen Objekte auf der Platine abgebildet werden, indem Sie mit + der linken Maustaste auf das entsprechende Farbfeld klicken. Für die Objekttypen in der oberen Tabelle + kann die Farbe für jede Lage einzeln eingestellt werden.

+
+

sonstiges

+
+

Crosshair-Cursor

+
+

Hier können Sie vom normalen kleinem Crosshair-Cursor zu einem großen 45-Grad Crosshair-Cursor + umschalten. Das Verwenden des großen Crosshair-Cursors kann die Display-Performance erheblich + beeinträchtigen. Shortcut ist die Komma-Taste.

+
+

Platinenrotation

+
+

Hier können Sie die Platine um vielfache von 90 Grad drehen.

+
+

Platinenspiegelung

+
+

Hier können Sie die Platine an der horizontalen oder vertikalen Achse spiegeln.

+
+

automatisches Lagen-Dimmen

+
+

mit dem Schieberegler können Sie einstellen, wie stark Objekte auf der in den Select-Einstellungen beschriebenen aktuellen Lage + hervorgehoben werden sollen. Wenn Sie den Regler ganz nach links schieben, wird das automatische + Lagen-Dimmen komplett abgeschaltet, schieben Sie ihn ganz nach rechts, werden alle Lagen bis auf die + aktuelle Lage unsichtbar.

+
+

+
+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowManualRules.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowManualRules.html index 52c09392..fd31115a 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowManualRules.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowManualRules.html @@ -2,29 +2,38 @@ - - - - Manuelle Regeln - + + + + Manuelle Regeln + - -

Manuelle Regeln

Fenster mit den Regeln, die beim interaktiven Routen verwendet werden, wenn der Route-Modus in den Route-Einstellungen auf manuell gesetzt ist. + +

Manuelle Regeln

Fenster mit den Regeln, die beim interaktiven Routen verwendet werden, wenn der Route-Modus in +den Route-Einstellungen auf manuell gesetzt ist. -

Via-Regel:

-
- Hier können Sie die beim interaktiven Routen zu verwendende Via-Regel einstellen.
-

Clearance-Klasse für Bahnen:

-
- Stellen Sie hier die Clearance-Klasse ein, die für neu geroutete Bahnen gelten soll.
-

Bahnbreite:

-
- Stellen Sie hier die Bahnbreite für die neu zu routenden Bahnen ein.
-

auf Lage:

-
-

Gibt an, auf welchen Lagen die im Feld darüber eingestellte Bahnbreite gelten soll. Bei Auswahl von alle gilt die eingestellte Bahnbreite auf allen Lagen. Bei Auswahl von innere gilt die eingestellte Bahnbreite auf allen Innenlagen. Sonst gilt die Bahnbreite nur für die Lage mit dem ausgewählten Namen. Ist die Bahnbreite lagenabhängig, bleibt das Bahnbreitenfeld bei Einstellung von alle leer. Analog für die Innenlagen.

-
-

zurück

- +

Via-Regel:

+
+ Hier können Sie die beim interaktiven Routen zu verwendende Via-Regel einstellen. +
+

Clearance-Klasse für Bahnen:

+
+ Stellen Sie hier die Clearance-Klasse ein, die für neu geroutete + Bahnen gelten soll. +
+

Bahnbreite:

+
+ Stellen Sie hier die Bahnbreite für die neu zu routenden Bahnen ein. +
+

auf Lage:

+
+

Gibt an, auf welchen Lagen die im Feld darüber eingestellte Bahnbreite gelten soll. Bei Auswahl von + alle gilt die eingestellte Bahnbreite auf allen Lagen. Bei Auswahl von innere gilt die + eingestellte Bahnbreite auf allen Innenlagen. Sonst gilt die Bahnbreite nur für die Lage mit dem ausgewählten + Namen. Ist die Bahnbreite lagenabhängig, bleibt das Bahnbreitenfeld bei Einstellung von alle leer. + Analog für die Innenlagen.

+
+

zurück

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowMoveParameter.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowMoveParameter.html index 4a653671..77f3ccee 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowMoveParameter.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowMoveParameter.html @@ -2,18 +2,22 @@ - - - - Plazierungs-Parameter - + + + + Plazierungs-Parameter + - -

Platzierungs-Parameter

- Die Parameter in diesem Fenster werden beim Verschieben von Bauteilen ausgewertet. -

Hier können Sie einen horizontales und vertikales Raster einstellen, Die Bauteile springen dann beim Verschieben auf Koordinaten, die vielfache von diesem Raster sind.

-

Außerdem können sie die Funktion des Mausrads von Zoomen auf Drehen umstellen. Diese Funktionalität brauchen Sie, wenn Sie Bauteile um Winkel Drehen möchten, die keine vielfachen von 90 Grad sind.

-

zurück

- + +

Platzierungs-Parameter

+Die Parameter in diesem Fenster werden beim Verschieben von Bauteilen ausgewertet. +

Hier können Sie einen horizontales und vertikales Raster einstellen, Die Bauteile springen dann beim Verschieben + auf Koordinaten, die vielfache von diesem Raster sind.

+ +

Außerdem können sie die Funktion des Mausrads von Zoomen auf Drehen umstellen. Diese Funktionalität + brauchen Sie, wenn Sie Bauteile um Winkel Drehen möchten, die keine vielfachen von 90 Grad sind.

+ +

zurück

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowNetClasses.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowNetClasses.html index 50d2ec36..59fad529 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowNetClasses.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowNetClasses.html @@ -2,83 +2,119 @@ - - - - Netzklassen - + + + + Netzklassen + - -

Netzklassen

-

Eine Netzklasse besteht aus einem Satz von Regeln, die standardmäßig beim Routen von Netzen aus dieser Netzklasse verwendet werden. Diese Regeln können in der Tabelle im Netzklassen-Fenster editiert werden. Im Folgenden werden die Spalteneinträge in dieser Tabelle beschrieben:

-

Die Netzklassentabelle:

-
-

Name

-
-

Hier steht der Name der Netzklasse, deren Regeln in dieser Zeile beschrieben sind.

-
-

Via-Regel

-
-

Hier können Sie die Via-Regel einstellen, die beim Routen eines Netz aus dieser Klasse verwendet werden soll.

-
-

Clearance-Klasse

-
-

Dieses Feld ist zum Einstellen der Clearance-Klasse für die neu gerouteten Bahnen eines Netz aus dieser Klasse.

-
-

Bahnbreite

-
-

Hier können Sie die Bahnbreite für die neu gerouteten Bahnen eines Netz aus dieser Klasse einstellen.

-

Wenn Sie die Bahnbreite auf 0 setzen, werden beim automatischen und interaktiven Routen auf den im folgenden Feld eingestellten Lagen für diese Netzklasse keine Bahnen zugelassen.

-
-

auf Lage

-
-

Geben Sie hier an, für welchen Lagen der im Bahnbreitenfeld eingestellte Wert gelten soll. Wenn alle eingestellt ist, gilt der Wert auf allen Lagen. Bei der Einstellung von innere gilt der Wert auf allen Innenlagen. Sonst gilt der Wert nur auf der Lage mit dem ausgewählten Namen. Wenn die Bahnbreite lagenabhängig ist, wird bei Einstellung von alle im Bahnbreitenfeld der Wert -1 angezeigt. (Es kann nämlich kein für alle Lagen gültiger Wert ausgegeben werden.)

-
-

schiebe-fixiert

-
-

Wenn dieses Feld angewählt ist, können Bahnen aus dieser Netzklasse beim Routen nicht verschoben oder glatt gezogen werden.

-
-

Zyklen mit Flächen

-
-

Normalerweise werden beim Routen entstehende geschlossene Zyklen automatisch entfernt. Wenn dieses Feld angewählt ist, geschieht das nur, wenn dabei keine Leitungsflächen involviert sind. So können Sie zum Beispiel Objekte mehrfach mit einer Kupferfläche verbinden, ohne dass dabei die redundanten Anschlüsse automatisch entfernt werden.

-
-

min. Länge

-
-

Hier können Sie einen Minimalwert für die kumulative Bahnlänge eines Netz aus dieser Klasse angeben. Beim Routen erscheint dann eine Ellipse. Ob die Minimallänge unterschritten wurde sehen Sie daran, dass sich der Cursor beim Anschließen außerhalb dieser Ellipse befindet. Diese Software bietet allerdings noch keine gute Unterstützung beim Routen mit Minimallängen. Es empfiehlt sich, in den Route-Parametern den Route-Modus auf stitching zu stellen und den Wert für den Glattzieh-Bereich auf 0 zu setzen.

-
-

max. Länge

-
-

Hier können Sie einen Maximalwert für die kumulative Bahnlänge eines Netz aus dieser Klasse angeben. Beim Routen erscheint dann ein Ellipsen-Ring. Ob die Maximallänge eingehalten wurde sehen Sie daran, dass sich der Cursor beim Anschließen innerhalb dieses Ellipsenring befindet.

-
-
-

Die Buttons im Netzklassen-Fenster:

-
-

Hinzufügen

-
-

Wenn Sie den Button Hinzufügen drücken, wird am Ende der Netzklassen-Tabelle eine neue Zeile mit Default-Werten angehängt. Dort können Sie in der ersten Spalte den vordefinierten Namen der neuen Netzklasse ändern, und danach die Einträge in den anderen Spalten an Ihre Erfordernisse anpassen.

-
-

Löschen

-
-

Nachdem Sie mit der linken Maustaste eine Zeile in der Netzklassen-Tabelle ausgewählt haben, können Sie die zugehörige Netzklasse durch Drücken dieses Buttons löschen. Das Löschen wird verweigert, wenn es noch Netze gibt, die an diese Netzklasse zugewiesen sind.

-
-

Zuweisen

-
-

Nach Drücken dieses Buttons erscheint ein Fenster mit einer Tabelle, wo Sie den Netzen in der ersten Spalte einzeln eine Netzklasse in der zweiten Spalte neu zuweisen können.

-
-

Selektieren

-
-

Auf der Platine werden alle Objekte von allen Netzen selektiert, die zu der in der Tabelle ausgewählten Netzklasse gehören. Anschließend befindet sich das Programm im Auswahl-Zustand.

-
-

Netze anzeigen

-
-

Öffnet eine Liste mit allen in den selektierten Klassen enthaltenen Netzen.

-
-

Incompletes filtern

-
-

Es werden nur die Luftlinien der offenen Verbindungen abgebildet, die zu Netzen aus der ausgewählten Netzklasse gehören. Diese Möglichkeit ist als Hilfe gedacht, wenn Sie die Netze einer bestimmten Klasse zuerst routen wollen.

-

-
-
- + +

Netzklassen

+ +

Eine Netzklasse besteht aus einem Satz von Regeln, die standardmäßig beim Routen von Netzen aus dieser + Netzklasse verwendet werden. Diese Regeln können in der Tabelle im Netzklassen-Fenster editiert werden. Im + Folgenden werden die Spalteneinträge in dieser Tabelle beschrieben:

+

Die Netzklassentabelle:

+
+

Name

+
+

Hier steht der Name der Netzklasse, deren Regeln in dieser Zeile beschrieben sind.

+
+

Via-Regel

+
+

Hier können Sie die Via-Regel einstellen, die beim Routen eines Netz aus + dieser Klasse verwendet werden soll.

+
+

Clearance-Klasse

+
+

Dieses Feld ist zum Einstellen der Clearance-Klasse für die neu + gerouteten Bahnen eines Netz aus dieser Klasse.

+
+

Bahnbreite

+
+

Hier können Sie die Bahnbreite für die neu gerouteten Bahnen eines Netz aus dieser Klasse + einstellen.

+ +

Wenn Sie die Bahnbreite auf 0 setzen, werden beim automatischen und interaktiven Routen auf den im folgenden + Feld eingestellten Lagen für diese Netzklasse keine Bahnen zugelassen.

+
+

auf Lage

+
+

Geben Sie hier an, für welchen Lagen der im Bahnbreitenfeld eingestellte Wert gelten soll. Wenn + alle eingestellt ist, gilt der Wert auf allen Lagen. Bei der Einstellung von innere gilt der + Wert auf allen Innenlagen. Sonst gilt der Wert nur auf der Lage mit dem ausgewählten Namen. Wenn die + Bahnbreite lagenabhängig ist, wird bei Einstellung von alle im Bahnbreitenfeld der Wert -1 + angezeigt. (Es kann nämlich kein für alle Lagen gültiger Wert ausgegeben werden.)

+
+

schiebe-fixiert

+
+

Wenn dieses Feld angewählt ist, können Bahnen aus dieser Netzklasse beim Routen nicht verschoben + oder glatt gezogen werden.

+
+

Zyklen mit Flächen

+
+

Normalerweise werden beim Routen entstehende geschlossene Zyklen automatisch entfernt. Wenn dieses Feld angewählt + ist, geschieht das nur, wenn dabei keine Leitungsflächen involviert sind. So können Sie zum + Beispiel Objekte mehrfach mit einer Kupferfläche verbinden, ohne dass dabei die redundanten Anschlüsse + automatisch entfernt werden.

+
+

min. Länge

+
+

Hier können Sie einen Minimalwert für die kumulative Bahnlänge eines Netz aus dieser Klasse + angeben. Beim Routen erscheint dann eine Ellipse. Ob die Minimallänge unterschritten wurde sehen Sie + daran, dass sich der Cursor beim Anschließen außerhalb dieser Ellipse befindet. Diese Software + bietet allerdings noch keine gute Unterstützung beim Routen mit Minimallängen. Es empfiehlt sich, + in den Route-Parametern den Route-Modus auf stitching zu stellen und den + Wert für den Glattzieh-Bereich auf 0 zu setzen. +

+
+

max. Länge

+
+

Hier können Sie einen Maximalwert für die kumulative Bahnlänge eines Netz aus dieser Klasse + angeben. Beim Routen erscheint dann ein Ellipsen-Ring. Ob die Maximallänge eingehalten wurde sehen Sie + daran, dass sich der Cursor beim Anschließen innerhalb dieses Ellipsenring befindet.

+
+
+

Die Buttons im Netzklassen-Fenster:

+
+

Hinzufügen

+
+

Wenn Sie den Button Hinzufügen drücken, wird am Ende der Netzklassen-Tabelle eine neue Zeile + mit Default-Werten angehängt. Dort können Sie in der ersten Spalte den vordefinierten Namen der + neuen Netzklasse ändern, und danach die Einträge in den anderen Spalten an Ihre Erfordernisse + anpassen.

+
+

Löschen

+
+

Nachdem Sie mit der linken Maustaste eine Zeile in der Netzklassen-Tabelle ausgewählt haben, können + Sie die zugehörige Netzklasse durch Drücken dieses Buttons löschen. Das Löschen wird + verweigert, wenn es noch Netze gibt, die an diese Netzklasse zugewiesen sind.

+
+

Zuweisen

+
+

Nach Drücken dieses Buttons erscheint ein Fenster mit einer Tabelle, wo Sie den Netzen in der ersten + Spalte einzeln eine Netzklasse in der zweiten Spalte neu zuweisen können.

+
+

Selektieren

+
+

Auf der Platine werden alle Objekte von allen Netzen selektiert, die zu der in der Tabelle ausgewählten + Netzklasse gehören. Anschließend befindet sich das Programm im Auswahl-Zustand. +

+
+

Netze anzeigen

+
+

Öffnet eine Liste mit allen in den selektierten Klassen enthaltenen Netzen.

+
+

Incompletes filtern

+
+

Es werden nur die Luftlinien der offenen Verbindungen abgebildet, die zu Netzen aus der ausgewählten + Netzklasse gehören. Diese Möglichkeit ist als Hilfe gedacht, wenn Sie die Netze einer bestimmten + Klasse zuerst routen wollen.

+ +

+
+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowObjectList.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowObjectList.html index 543d0831..9499a752 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowObjectList.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowObjectList.html @@ -2,88 +2,124 @@ - - - - Die Objektlisten - + + + + Die Objektlisten + - -

Die Objektlisten

- Hier werden die Fenster mit den Objektlisten dokumentiert, wie sie in der Menüleiste unter Info zu finden sind. -

Die Objekte in einer solchen Liste können mit der linken Maustaste selektiert werden. Wenn Sie die Strg- oder Ctrl-Taste dabei gedrückt halten, können Sie auch mehrere Objekte auswählen. Mit gedrückter Shift-Taste können Sie alle Objekte zwischen dem zuerst selektierten und dem zuletzt selektierten Objekt ausgewählen.

-

Die Buttons im Objektlisten-Fenster:

-
-

Info

-
-

Öffnet ein Textfenster mit Informationen über die selektierten Objekte. Über die blau markierten Ausdrücke in diesem Textfenster können Sie sich durch Klicken mit der linken Maustaste weitere Informationen besorgen.

-
-

Anzeigen

-
-

Es wird ein Ausschnitt der Platine mit den ausgewählten Objekten abgebildet. Die selektierten Objekte werden dabei gehighlighted. Danach befindet sich das Programm im Auswahlzustand.

-
-

Invertieren

-
-

Selektierte Objekte in der Liste werden deselektiert und umgekehrt.

-
-

Neu berechnen

-
-

Die Objektliste wird neu berechnet.

-
-

Filter

-
-

Hier können Sie eine Zeichenfolge zum Filtern der Objekte in der Liste angeben. Wenn Sie danach auf Neu berechnen drücken, werden nur noch die Objekte ausgegeben, die diese Zeichenfolge enthalten.

-
-
-

Es gibt Objektlisten für offene Verbindungen, Längenverletzungen, Clearance-Verletzungen, Bibliotheks-Packages, Bibliotheks-Padstacks, platzierte Bauteile und Netze. Es folgt eine kurze Beschreibung dieser Listen.

-

Die einzelnen Objektlisten:

-
-

Clearance-Verletzungen

-
-

Es werden die Objektpaare ausgegeben, wo der für diese Objekte geltende Mindestabstand nicht eingehalten wurde. Durch Drücken des Buttons Anzeigen können diese auf der Platine leicht gefunden werden.

-
-

Bibliotheks-Packages

-
-

Es werden alle in der Bibliothek vorkommenden Packages ausgegeben. Nach Drücken des Buttons Anzeigen sehen Sie sich alle Bauteile auf der Platine, in denen die selektierten Packages verwendet werden.

-
-

Bibliotheks-Padstacks

-
-

Es werden alle in der Bibliothek vorkommenden Padstacks ausgegeben. Nach Drücken des Buttons Anzeigen sehen Sie sich alle Pins und Vias auf der Platine, in denen die selektierten Padstacks verwendet werden.

-
-

platzierte Bauteile

-
-

Es werden alle auf der Platine platzierten Bauteile ausgegeben. Nach Drücken des Buttons Anzeigen sehen Sie sich die selektierten Bauteile auf der Platine.

-
-
-
-

offene Verbindungen

-
-

Es werden alle noch zu routenden offenen Verbindungen ausgegeben. Die Einträge enthalten den Netznamen gefolgt von Bauteil-Name und Pin-Name der beiden End-Objekte der offenen Verbindung. Wenn es nur noch wenige offene Verbindungen gibt, können diese durch Drücken des Buttons Anzeigen auf der Platine leicht gefunden werden.

-
-

Längenverletzungen

-
-

Es werden die gerouteten Verbindungen ausgegeben, bei denen die erlaubte Mindestlänge unterschritten oder die erlaubte Maximallänge überschritten wurde. Bei Unterschreiten der Mindestlänge wird auf der Platine an den Endpunkten der Verbindung ein Kreis mit einem "-" abgebildet, bei Überschreiten der Maximallänge ein Kreis mit einem "+". Die Größe eines solchen Kreis entspricht der Größe der Längenverletzung.

-
-

Clearance-Verletzungen

-
-

Es werden die Objektpaare ausgegeben, wo der für diese Objekte geltende Mindestabstand nicht eingehalten wurde. Durch Drücken des Buttons Anzeigen können diese auf der Platine leicht gefunden werden.

-
-

nicht verbundener Route

-
-

Es werden die elektrisch verbundenen Traces und Vias ausgegeben, die nicht an Pins oder Leitungsflächen angeschlossen sind und somit in der Luft hängen.. Durch Drücken des Buttons Anzeigen können die selektierten Objekte auf der Platine leicht gefunden werden. Anschließend können Sie diese durch Drücken des Buttons Löschen im Toolbar entfernen.

-
-

Route-Stummel

-
-

Es werden Trace-Stummel und und Vias mit nur einem Kontakt ausgegeben. Durch Drücken des Buttons Anzeigen können die selektierten Stummel auf der Platine leicht gefunden werden. Anschließend können Sie die Stummel durch Drücken des Buttons Verb. auf die dazugehörigen Verbindungen erweitern und diese dann durch Drücken des Buttons Löschen im Toolbar entfernen.

-
-

Netze

-
-

Es werden alle auf der Platine verwendeten Netze ausgegeben. Dieses Fenster enthält zwei weitere Buttons. Mit dem Button Klasse zuweisen können Sie den ausgewählten Netzen eine neue Netzklasse zuweisen. Nach Drücken des Button Incompletes filtern werden nur die Luftlinien der offenen Verbindungen abgebildet, die zu einem selektierten Netz gehören.

-
-

-
-

-

- + +

Die Objektlisten

+Hier werden die Fenster mit den Objektlisten dokumentiert, wie sie in der Menüleiste unter Info zu finden +sind. +

Die Objekte in einer solchen Liste können mit der linken Maustaste selektiert werden. Wenn Sie die Strg- oder + Ctrl-Taste dabei gedrückt halten, können Sie auch mehrere Objekte auswählen. Mit gedrückter + Shift-Taste können Sie alle Objekte zwischen dem zuerst selektierten und dem zuletzt selektierten Objekt ausgewählen.

+

Die Buttons im Objektlisten-Fenster:

+
+

Info

+
+

Öffnet ein Textfenster mit Informationen über die selektierten Objekte. Über die blau + markierten Ausdrücke in diesem Textfenster können Sie sich durch Klicken mit der linken Maustaste + weitere Informationen besorgen.

+
+

Anzeigen

+
+

Es wird ein Ausschnitt der Platine mit den ausgewählten Objekten abgebildet. Die selektierten Objekte + werden dabei gehighlighted. Danach befindet sich das Programm im Auswahlzustand. +

+
+

Invertieren

+
+

Selektierte Objekte in der Liste werden deselektiert und umgekehrt.

+
+

Neu berechnen

+
+

Die Objektliste wird neu berechnet.

+
+

Filter

+
+

Hier können Sie eine Zeichenfolge zum Filtern der Objekte in der Liste angeben. Wenn Sie danach auf Neu + berechnen drücken, werden nur noch die Objekte ausgegeben, die diese Zeichenfolge enthalten.

+
+
+

Es gibt Objektlisten für offene Verbindungen, Längenverletzungen, Clearance-Verletzungen, + Bibliotheks-Packages, Bibliotheks-Padstacks, platzierte Bauteile und Netze. Es folgt eine kurze Beschreibung dieser + Listen.

+

Die einzelnen Objektlisten:

+
+

Clearance-Verletzungen

+
+

Es werden die Objektpaare ausgegeben, wo der für diese Objekte geltende Mindestabstand nicht eingehalten + wurde. Durch Drücken des Buttons Anzeigen können diese auf der Platine leicht gefunden + werden.

+
+

Bibliotheks-Packages

+
+

Es werden alle in der Bibliothek vorkommenden Packages ausgegeben. Nach Drücken des Buttons + Anzeigen sehen Sie sich alle Bauteile auf der Platine, in denen die selektierten Packages verwendet + werden.

+
+

Bibliotheks-Padstacks

+
+

Es werden alle in der Bibliothek vorkommenden Padstacks ausgegeben. Nach Drücken des Buttons + Anzeigen sehen Sie sich alle Pins und Vias auf der Platine, in denen die selektierten Padstacks + verwendet werden.

+
+

platzierte Bauteile

+
+

Es werden alle auf der Platine platzierten Bauteile ausgegeben. Nach Drücken des Buttons + Anzeigen sehen Sie sich die selektierten Bauteile auf der Platine.

+
+
+
+

offene Verbindungen

+
+

Es werden alle noch zu routenden offenen Verbindungen ausgegeben. Die Einträge enthalten den Netznamen + gefolgt von Bauteil-Name und Pin-Name der beiden End-Objekte der offenen Verbindung. Wenn es nur noch wenige + offene Verbindungen gibt, können diese durch Drücken des Buttons Anzeigen auf der Platine + leicht gefunden werden.

+
+

Längenverletzungen

+
+

Es werden die gerouteten Verbindungen ausgegeben, bei denen die erlaubte Mindestlänge unterschritten + oder die erlaubte Maximallänge überschritten wurde. Bei Unterschreiten der Mindestlänge wird + auf der Platine an den Endpunkten der Verbindung ein Kreis mit einem "-" abgebildet, bei Überschreiten + der Maximallänge ein Kreis mit einem "+". Die Größe eines solchen Kreis entspricht + der Größe der Längenverletzung.

+
+

Clearance-Verletzungen

+
+

Es werden die Objektpaare ausgegeben, wo der für diese Objekte geltende Mindestabstand nicht eingehalten + wurde. Durch Drücken des Buttons Anzeigen können diese auf der Platine leicht gefunden + werden.

+
+

nicht verbundener Route

+
+

Es werden die elektrisch verbundenen Traces und Vias ausgegeben, die nicht an Pins oder Leitungsflächen + angeschlossen sind und somit in der Luft hängen.. Durch Drücken des Buttons Anzeigen können + die selektierten Objekte auf der Platine leicht gefunden werden. Anschließend können Sie diese + durch Drücken des Buttons Löschen im Toolbar entfernen.

+
+

Route-Stummel

+
+

Es werden Trace-Stummel und und Vias mit nur einem Kontakt ausgegeben. Durch Drücken des Buttons Anzeigen + können die selektierten Stummel auf der Platine leicht gefunden werden. Anschließend können + Sie die Stummel durch Drücken des Buttons Verb. auf die dazugehörigen Verbindungen + erweitern und diese dann durch Drücken des Buttons Löschen im Toolbar entfernen.

+
+

Netze

+
+

Es werden alle auf der Platine verwendeten Netze ausgegeben. Dieses Fenster enthält zwei weitere + Buttons. Mit dem Button Klasse zuweisen können Sie den ausgewählten Netzen eine neue + Netzklasse zuweisen. Nach Drücken des Button Incompletes filtern werden nur die Luftlinien der + offenen Verbindungen abgebildet, die zu einem selektierten Netz gehören.

+
+

+
+

+ +

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowRouteParameter.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowRouteParameter.html index 3862d8b5..87e6cdac 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowRouteParameter.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowRouteParameter.html @@ -2,77 +2,95 @@ - - - - Route-Einstellungen - + + + + Route-Einstellungen + - -

Route-Einstellungen

- Beschreibung des Fensters mit den Route-Einstellungen -

Winkel-Einschränkung:

-
- 90 Grad: -
-

Beim interaktiven Routen entstehen nur horizontale und vertikale Bahnen.

-
-

45 Grad:

-
-

Die Winkel der beim interaktiven Routen entstehenden Bahnen sind auf vielfache von 45 Grad beschränkt.

-
-

keine:

-
-

Es gibt keine Winkelbeschränkungen beim interaktiven Routen.

-
-
-

Route-Modus:

-
- dynamisch: -
-

Bahn wird eingefügt bei jeder Bewegung des Cursors.

-
-

stitching:

-
-

Bahn wird eingefügt beim Klicken der linken Maustaste.

-
-
-

Regel-Auswahl:

-
- automatisch: -
-

Die beim Routen verwendeten Regeln werden durch die Netzklasse des zu routenden Netz bestimmt.

-
-

manuell:

-
-

Die beim Routen verwendeten Regeln werden im Fenster Manuelle Regeln festgelegt. Das Fenster öffnet sich automatisch beim Anwählen von manuell.

-
-
-

schieben erlaubt

-
- Hier können sie einstellen, ob fremde Bahnen beim Routen verschoben werden dürfen.
-

ziehen von Bauteilen erlaubt

-
Hier können Sie einstellen, ob Bauteile mit gedrückter linker Maustaste gezogen werden dürfen. Die schon gerouteten Verbindungen des entsprechenden Bauteils werden automatisch mitgezogen.
-

Vias schnappen zum SMD-Zentrum

-
- Stellen Sie hier ein, ob Vias, für die Bohren auf SMD-Pins erlaubt ist, in diesem Fall automatisch zum Zentrum des Pins schnappen sollen.
-

Highlight Route-Hindernis

-
Wenn eingeschaltet, wird das Objekt gehighlighted, das ein Weiterrouten verhindert.
-

Leitungsflächen ignorieren

-
- Wenn eingeschaltet, werden Leitungsflächen (z. B. Kupferflächen) von fremden Netzen nicht als Hindernis betrachtet. Damit können sie z.B. im Hostsystem automatisch ausgespart werden.
-

automatisches Neckdown

-
- Wenn eingeschaltet, wird beim Starten oder Anschließen an Pins, die schmaler als die beim Routen verwendete Bahnbreite sind und dadurch ein Weiterrouten verhindern, die Bahnbreite automatisch auf die Pinbreite reduziert.
-

Exit-Richtungen bei Pins einschränken

-
- Hier können Sie festlegen, ob bei länglichen Pins Bahnen nur an den Schmalseiten angeschlossen werden dürfen.
-

Pad-Abbiege-Abstand

-
- Geben Sie hier den Mindestabstand vom Pad-Rand der Pins mit Exitbeschränkungen an, ab denen Bahnen die Richtung ändern dürfen.
-

Glattzieh-Bereich

-
Hier können Sie den Bereich um den Cursor einschränken, in dem die Bahnen beim Routen glatt gezogen werden. Bei 0 ist das Glattziehen vollständig abgeschaltet, bei 999 gibt es keine Einschränkung des Glattziehbereichs. Ein Wert von 0 ist nur sinnvoll, wenn der Route-Modus auf stitching geschaltet ist.
-

back

- + +

Route-Einstellungen

+Beschreibung des Fensters mit den Route-Einstellungen +

Winkel-Einschränkung:

+
+ 90 Grad: +
+

Beim interaktiven Routen entstehen nur horizontale und vertikale Bahnen.

+
+

45 Grad:

+
+

Die Winkel der beim interaktiven Routen entstehenden Bahnen sind auf vielfache von 45 Grad + beschränkt.

+
+

keine:

+
+

Es gibt keine Winkelbeschränkungen beim interaktiven Routen.

+
+
+

Route-Modus:

+
+ dynamisch: +
+

Bahn wird eingefügt bei jeder Bewegung des Cursors.

+
+

stitching:

+
+

Bahn wird eingefügt beim Klicken der linken Maustaste.

+
+
+

Regel-Auswahl:

+
+ automatisch: +
+

Die beim Routen verwendeten Regeln werden durch die Netzklasse des zu + routenden Netz bestimmt.

+
+

manuell:

+
+

Die beim Routen verwendeten Regeln werden im Fenster Manuelle Regeln + festgelegt. Das Fenster öffnet sich automatisch beim Anwählen von manuell.

+
+
+

schieben erlaubt

+
+ Hier können sie einstellen, ob fremde Bahnen beim Routen verschoben werden dürfen. +
+

ziehen von Bauteilen erlaubt

+
Hier können Sie einstellen, ob Bauteile mit gedrückter linker Maustaste gezogen werden dürfen. + Die schon gerouteten Verbindungen des entsprechenden Bauteils werden automatisch mitgezogen. +
+

Vias schnappen zum SMD-Zentrum

+
+ Stellen Sie hier ein, ob Vias, für die Bohren auf SMD-Pins erlaubt ist, in diesem Fall automatisch zum Zentrum + des Pins schnappen sollen. +
+

Highlight Route-Hindernis

+
Wenn eingeschaltet, wird das Objekt gehighlighted, das ein Weiterrouten verhindert.
+

Leitungsflächen ignorieren

+
+ Wenn eingeschaltet, werden Leitungsflächen (z. B. Kupferflächen) von fremden Netzen nicht als Hindernis + betrachtet. Damit können sie z.B. im Hostsystem automatisch ausgespart werden. +
+

automatisches Neckdown

+
+ Wenn eingeschaltet, wird beim Starten oder Anschließen an Pins, die schmaler als die beim Routen verwendete + Bahnbreite sind und dadurch ein Weiterrouten verhindern, die Bahnbreite automatisch auf die Pinbreite reduziert. +
+

Exit-Richtungen bei Pins einschränken

+
+ Hier können Sie festlegen, ob bei länglichen Pins Bahnen nur an den Schmalseiten angeschlossen werden dürfen. +
+

Pad-Abbiege-Abstand

+
+ Geben Sie hier den Mindestabstand vom Pad-Rand der Pins mit Exitbeschränkungen an, ab denen Bahnen die + Richtung ändern dürfen. +
+

Glattzieh-Bereich

+
Hier können Sie den Bereich um den Cursor einschränken, in dem die Bahnen beim Routen glatt + gezogen werden. Bei 0 ist das Glattziehen vollständig abgeschaltet, bei 999 gibt es keine Einschränkung + des Glattziehbereichs. Ein Wert von 0 ist nur sinnvoll, wenn der Route-Modus auf stitching geschaltet ist. +
+

back

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowSelectParameter.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowSelectParameter.html index 829d53b8..ea9cec45 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowSelectParameter.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowSelectParameter.html @@ -2,34 +2,35 @@ - - - - Select-Einstellungen - + + + + Select-Einstellungen + - -

Select-Einstellungen

- Beschreibung des Fensters mit den Select-Einstellungen -

Selektions-Lagen:

-
- alle sichtbaren: -
-

Es wird auf allen Lagen mit Sichtbarkeitsfaktor > 0 selektiert (siehe auch Lagensichtbarkeit). Die aktuelle Lage wird bevorzugt.

-
-

nur aktuelle:

-
-

Es wird nur auf der unter aktuelle Lage eingestellten Lage selektiert.

-
-
-

Selektierbare Objekte:

-
Nur die angewählten Objekttypen werden beim Selektieren berücksichtigt.
-

Aktuelle Lage:

-
Hier können Sie die Lage einstellen, die bei interaktiven Aktionen verwendet werden soll.

-
-

-
-
- + +

Select-Einstellungen

+Beschreibung des Fensters mit den Select-Einstellungen +

Selektions-Lagen:

+
+ alle sichtbaren: +
+

Es wird auf allen Lagen mit Sichtbarkeitsfaktor > 0 selektiert (siehe auch Lagensichtbarkeit). Die aktuelle Lage wird bevorzugt.

+
+

nur aktuelle:

+
+

Es wird nur auf der unter aktuelle Lage eingestellten Lage selektiert.

+
+
+

Selektierbare Objekte:

+
Nur die angewählten Objekttypen werden beim Selektieren berücksichtigt.
+

Aktuelle Lage:

+
Hier können Sie die Lage einstellen, die bei interaktiven Aktionen verwendet werden soll.

+
+

+
+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowSnapshots.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowSnapshots.html index ef4743c6..0ac3a975 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowSnapshots.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowSnapshots.html @@ -2,114 +2,135 @@ - - - - Snapshots - + + + + Snapshots + - -

Snapshots

-

Im Snapshots-Fenster können Sie den aktuellen interaktiven Zustand des Programms abspeichern, um ihn später bei Bedarf wiederherzustellen.

-

Beschreibung der Buttons:

-
-

Gehe zu ausgewähltem Snapshot

-
-

Stellt den Interaktiven Zustand wieder her, der in dem ausgewählten Snapshot abgespeichert ist. Alternativ können Sie einen Snapshot in der Liste doppelklicken.

-

Um ständigesWechseln zwischen dem Hauptfenster und dem Snapshot-Fenster zu vermeiden, können Sie statt dessen auch die j-Taste drücken. Mit der h-Taste können Sie den vorherigen und mit der k-Taste den nächsten Snapshot selektieren.

-
-

Neuer Snapshot

-
-

Hier können Sie den aktuellen interaktiven Zustand in einem neuen Snapshot abspeichern, nachdem Sie den voreingestellten Namen in einen aussagekräftigeren Namen umgeändert haben.

-
-

Ausgewählten Snapshot löschen

-
-

Löscht den mit der linken Maustaste ausgewählten Snapshot.

-
-

Alle Snapshots löschen

-
-

Entfernt alle Snapshots aus der Liste.

-
-

Snapshot-Einstellungen

-
-

Öffnet ein Fenster mit den Snapshot-Einstellungen. Dort können Sie die Attribute abwählen, die nicht mit abgespeichert werden sollen.

-
-
-

Beschreibung der Felder im Fenster mit den Snapshot-Einstellungen:

-
- Objekt-Farben -
-

Die aktuellen Farbeinstellungen für die Objekttypen werden mit abgespeichert.

-
-

Objekt-Sichtbarkeit

-
-

Die aktuell eingestellte Intensität für die Abbildung der einzelnen Objekttypen wird mit abgespeichert.

-
-

Lagen-Sichtbarkeit

-
-

Die aktuell eingestellte Intensität für die Abbildung der Objekttypen auf den einzelnen Lagen wird mit abgespeichert.

-
-

Abbildungs-Ausschnitt

-
-

Der zurzeit abgebildete Ausschnitt der Platine wird mit abgespeichert.

-
-

interaktiver Zustand

-
-

Es wird mit abgespeichert, ob sich das Programm zurzeit im Select- Route- oder Drag-Zustand befindet.

-
-

Selektions-Lagen

-
-

Es wird mit abgespeichert, ob im Fenster mit den Select-Einstellungen die Selektions-Lagen auf alle sichtbaren oder auf nur aktuelle geschaltet sind.

-
-

selektierbare Objekte

-
-

Die im Fenster mit den Select-Einstellungen unter Selektierbare Objekte eingestellten Werte werden mit abgespeichert.

-
-

aktuelle Lage

-
-

Die im Fenster mit den Select-Einstellungen unter Aktuelle-Lage eingestellte Lage wird mit abgespeichert.

-
-

Regel-Auswahl

-
-

Es wird mit abgespeichert, ob im Fenster mit den Route-Einstellungen die Regel-Auswahl auf automatisch oder manuell eingestellt ist.

-
-

manuelle Regel-Einstellungen

-
-

Die Einstellungen im Fenster mit den manuellen Regeln werden mit abgespeichert.

-
-

schieben erlaubt

-
-

Es wird mit abgespeichert, ob im Fenster mit den Route-Einstellungen schieben erlaubt angewählt ist.

-
-

Bauteil-Ziehen erlaubt

-
-

Es wird mit abgespeichert, ob im Fenster mit den Route-Einstellungen Bauteil-Ziehen erlaubt angewählt ist.

-
-

Glattzieh-Bereich

-
-

Der im Fenster mit den Route-Einstellungen eingestellte Wert für den Glattzieh-Bereich beim Routen wird mit abgespeichert.

-
-

Bauteil-Raster

-
-

Der im Fenster mit den Platzierungs-Parametern eingestellte Wert für das Bauteil-Raster beim Verschieben von Bauteilen wird mit abgespeichert.

-
-

Info-Listen-Selektion

-
-

Die selektierten Indizes und die Filter-Strings in den Fenstern offene Verbindungen, Bibliotheks-Packages, Bibliotheks-Padstacks, platzierte Bauteile und Netze werden mit abgespeichert.

-
-
-
-
-

-
-
-
-
-

-

-

-
-
- + +

Snapshots

+ +

Im Snapshots-Fenster können Sie den aktuellen interaktiven Zustand des Programms abspeichern, um ihn später + bei Bedarf wiederherzustellen.

+

Beschreibung der Buttons:

+
+

Gehe zu ausgewähltem Snapshot

+
+

Stellt den Interaktiven Zustand wieder her, der in dem ausgewählten Snapshot abgespeichert ist. + Alternativ können Sie einen Snapshot in der Liste doppelklicken.

+ +

Um ständigesWechseln zwischen dem Hauptfenster und dem Snapshot-Fenster zu vermeiden, können Sie + statt dessen auch die j-Taste drücken. Mit der h-Taste können Sie den vorherigen und + mit der k-Taste den nächsten Snapshot selektieren.

+
+

Neuer Snapshot

+
+

Hier können Sie den aktuellen interaktiven Zustand in einem neuen Snapshot abspeichern, nachdem Sie den + voreingestellten Namen in einen aussagekräftigeren Namen umgeändert haben.

+
+

Ausgewählten Snapshot löschen

+
+

Löscht den mit der linken Maustaste ausgewählten Snapshot.

+
+

Alle Snapshots löschen

+
+

Entfernt alle Snapshots aus der Liste.

+
+

Snapshot-Einstellungen

+
+

Öffnet ein Fenster mit den Snapshot-Einstellungen. Dort können + Sie die Attribute abwählen, die nicht mit abgespeichert werden sollen.

+
+
+

Beschreibung der Felder im Fenster mit den Snapshot-Einstellungen:

+
+ Objekt-Farben +
+

Die aktuellen Farbeinstellungen für die Objekttypen werden mit abgespeichert.

+
+

Objekt-Sichtbarkeit

+
+

Die aktuell eingestellte Intensität für die Abbildung der einzelnen Objekttypen wird mit + abgespeichert.

+
+

Lagen-Sichtbarkeit

+
+

Die aktuell eingestellte Intensität für die Abbildung der Objekttypen auf den einzelnen Lagen wird + mit abgespeichert.

+
+

Abbildungs-Ausschnitt

+
+

Der zurzeit abgebildete Ausschnitt der Platine wird mit abgespeichert.

+
+

interaktiver Zustand

+
+

Es wird mit abgespeichert, ob sich das Programm zurzeit im Select- Route- oder Drag-Zustand befindet.

+
+

Selektions-Lagen

+
+

Es wird mit abgespeichert, ob im Fenster mit den Select-Einstellungen die Selektions-Lagen auf alle + sichtbaren oder auf nur aktuelle geschaltet sind.

+
+

selektierbare Objekte

+
+

Die im Fenster mit den Select-Einstellungen unter Selektierbare Objekte eingestellten Werte werden mit + abgespeichert.

+
+

aktuelle Lage

+
+

Die im Fenster mit den Select-Einstellungen unter Aktuelle-Lage eingestellte Lage wird mit + abgespeichert.

+
+

Regel-Auswahl

+
+

Es wird mit abgespeichert, ob im Fenster mit den Route-Einstellungen die Regel-Auswahl auf automatisch + oder manuell eingestellt ist.

+
+

manuelle Regel-Einstellungen

+
+

Die Einstellungen im Fenster mit den manuellen Regeln werden mit abgespeichert.

+
+

schieben erlaubt

+
+

Es wird mit abgespeichert, ob im Fenster mit den Route-Einstellungen schieben erlaubt angewählt + ist.

+
+

Bauteil-Ziehen erlaubt

+
+

Es wird mit abgespeichert, ob im Fenster mit den Route-Einstellungen Bauteil-Ziehen erlaubt angewählt + ist.

+
+

Glattzieh-Bereich

+
+

Der im Fenster mit den Route-Einstellungen eingestellte Wert für den Glattzieh-Bereich beim + Routen wird mit abgespeichert.

+
+

Bauteil-Raster

+
+

Der im Fenster mit den Platzierungs-Parametern eingestellte Wert für das Bauteil-Raster beim + Verschieben von Bauteilen wird mit abgespeichert.

+
+

Info-Listen-Selektion

+
+

Die selektierten Indizes und die Filter-Strings in den Fenstern offene Verbindungen, Bibliotheks-Packages, + Bibliotheks-Padstacks, platzierte Bauteile und Netze werden mit abgespeichert.

+
+
+
+
+

+
+
+
+
+

+ +

+ +

+
+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/html_files/WindowVia.html b/src/main/java/net/freerouting/helpset/de/html_files/WindowVia.html index bc6db19e..21551611 100644 --- a/src/main/java/net/freerouting/helpset/de/html_files/WindowVia.html +++ b/src/main/java/net/freerouting/helpset/de/html_files/WindowVia.html @@ -2,76 +2,116 @@ - - - - Via-Regeln - + + + + Via-Regeln + - -

Die Via-Regeln

-

Eine Via-Regel besteht aus einem Satz von Vias, die bei einer bestimmten Route-Einstellung verwendet werden dürfen. Wenn beim Lagenwechsel mehrere Vias die alte und die neue Lage umfassen und keine Clearance-Verletzungen verursachen würden, werden die Vias weiter vorne in der Regel werden gegenüber Vias weiter hinten in der Regel bevorzugt.

-

Vias

-

Ein Via besteht aus einem Namen, einem Via-Padstack, einer Clearance-Klasse und einem Eintrag, ob Überlappungen mit SMD-Pins vom gleichen Netz erlaubt sind oder nicht.

-

Via-Padstacks

-

Ein Via-Padstack besteht aus einer Anfangs- und einer Endlage, sowie aus einem kreisförmigen Shape auf jeder Lage zwischen Anfangs- und Endlage.

-

Es folgt eine Beschreibung der Funktionalität im Fenster mit den Via-Regeln.

-

Verfügbare Via-Padstacks

- Hier sehen Sie die drei Buttons Info, Neu und Löschen. -

Mit Info können Sie sich alle verfügbaren Via-Padstacks anzeigen lassen.

-

Mit Neu könne Sie einen neuen Via-Padstack anlegen. Geben Sie den Namen des neuen Via-Padstacks in das erscheinende Eingabefeld ein. Danach werden Sie aufgefordert, die erste und die letzte Lage des neuen Padstacks auszuwählen. In das darauf erscheinende Eingabefeld geben Sie bitte den Default-Radius für die kreisförmigen Shapes des neuen Padstacks ein. Im nachfolgenden Fenster können diesen Radius auf jeder einzelnen Lage verändern, falls die Shapes des neuen Padstacks lagenabhängig sein sollen.

-

Mit Löschen können Sie einen existierenden Via-Padstack löschen. Das Löschen wird verweigert, wenn der Padstack in einer Via-Definition oder an anderer Stelle verwendet wird.

-

Verfügbare Vias

- Beschreibung der Buttons: -
-

Info

-
-

Gibt alle Vias aus, die für das Routen zur Verfügung stehen.

-
-

Editieren

-
-

Wenn Sie diesen Button drücken, erscheint ein neues Fenster mit einer Tabelle zum Editieren der Vias. Hier können Sie Namen, Padstack, Clearance-Klasse und die SMD-Überlappungseigenschaft gemäß Ihren Anforderungen verändern. Unten an diesem Fenster befinden sich zwei Buttons, mit denen Sie neue Vias hinzufügen oder existierende Vias löschen können.

-
-
-

Via-Regeln

Unterhalb befindet sich ein Fenster, in dem alle Via-Regeln namentlich aufgelistet sind. Im Folgenden wird die Funktion der vier Buttons am unteren Rand beschrieben: -
-

Info

-
-

Nachdem Sie mit der linken Maustaste eine Via-Regel ausgewählt haben, können Sie sich diese mit Info anzeigen lassen. Die Vias weiter oben in der dann erscheinenden Liste werden gegenüber den Vias weiter unten beim Routen bevorzugt.

-
-

Neu

-
-

Wenn Sie den Button Neu drücken, werden Sie nach dem Namen der neuen Via-Regel gefragt. Nachdem Sie diesen angegeben haben, wird im Fenster oberhalb eine leere Regel mit dem neuen Namen hinzugefügt. Wählen Sie jetzt die neue Regel mit der linken Maustaste aus und drücken Sie den Button Editieren, um Vias in die neue Regel einzufügen.

-
-

Editieren

-
-

Wenn Sie eine Via-Regel mit der linken Maustaste auswählen und danach den Button Editieren drücken, erscheint ein neues Fenster, in dem Sie die Via-Regel verändern können. Weiteres finden Sie unter Via-Regel editieren.

-
-

Löschen

-
-

Mit diesem Button können Sie die ausgewählte Via-Regel löschen.

-
-
-

Via-Regel editieren

-
Wenn Sie eine Via-Regel zum Editieren ausgewählt haben, erscheint ein neues Fenster, in dem alle Vias aufgelistet sind, die in der selektierten Regel vorkommen. Vias weiter oben in dieser Liste werden gegenüber Vias weiter unten beim Routen bevorzugt. Im Folgenden wird die Funktion der Buttons in diesem neuen Fenster beschrieben.

Hinzufügen

-
-

Es erscheint ein Fenster in dem Sie ein Via aus allen zur Verfügung stehenden Vias auswählen können. Nachdem Sie das Via ausgewählt haben und den OK-Button gedrückt haben, wird das ausgewählte Via an das Ende der Liste angehängt.

-
-

Löschen

-
-

Nachdem Sie mit der linken Maustaste ein Via ausgewählt haben, können Sie es durch Drücken des Button Löschen aus der Liste entfernen.

-
-

Aufwärts

-
-

Nachdem Sie mit der linken Maustaste ein Via ausgewählt haben, können Sie durch Drücken des Button Aufwärts die Position des Vias in der Liste um einen Platz nach oben verschieben. Dadurch wird die Priorität dieses Vias beim Routen erhöht. Vias weiter oben in der Liste werden gegenüber Vias weiter unten bevorzugt.

-
-

Abwärts

-
-

Nachdem Sie mit der linken Maustaste ein Via ausgewählt haben, können Sie durch Drücken des Button Abwärts die Position des Vias in der Liste um einen Platz nach unten verschieben. Dadurch wird die Priorität dieses Vias beim Routen verringert. Vias weiter oben in der Liste werden gegenüber Vias weiter unten bevorzugt.

-

-
-
-

- + +

Die Via-Regeln

+ +

Eine Via-Regel besteht aus einem Satz von Vias, die bei einer bestimmten Route-Einstellung + verwendet werden dürfen. Wenn beim Lagenwechsel mehrere Vias die alte und die neue Lage umfassen und keine + Clearance-Verletzungen verursachen würden, werden die Vias weiter vorne in der Regel werden gegenüber Vias + weiter hinten in der Regel bevorzugt.

+

Vias

+ +

Ein Via besteht aus einem Namen, einem Via-Padstack, einer Clearance-Klasse und einem Eintrag, ob Überlappungen + mit SMD-Pins vom gleichen Netz erlaubt sind oder nicht.

+

Via-Padstacks

+ +

Ein Via-Padstack besteht aus einer Anfangs- und einer Endlage, sowie aus einem kreisförmigen Shape auf jeder + Lage zwischen Anfangs- und Endlage.

+ +

Es folgt eine Beschreibung der Funktionalität im Fenster mit den Via-Regeln.

+

Verfügbare Via-Padstacks

+Hier sehen Sie die drei Buttons Info, Neu und Löschen. +

Mit Info können Sie sich alle verfügbaren Via-Padstacks anzeigen lassen.

+ +

Mit Neu könne Sie einen neuen Via-Padstack anlegen. Geben Sie den Namen des neuen Via-Padstacks in das + erscheinende Eingabefeld ein. Danach werden Sie aufgefordert, die erste und die letzte Lage des neuen Padstacks + auszuwählen. In das darauf erscheinende Eingabefeld geben Sie bitte den Default-Radius für die kreisförmigen + Shapes des neuen Padstacks ein. Im nachfolgenden Fenster können diesen Radius auf jeder einzelnen Lage verändern, + falls die Shapes des neuen Padstacks lagenabhängig sein sollen.

+ +

Mit Löschen können Sie einen existierenden Via-Padstack löschen. Das Löschen wird + verweigert, wenn der Padstack in einer Via-Definition oder an anderer Stelle verwendet wird.

+

Verfügbare Vias

+Beschreibung der Buttons: +
+

Info

+
+

Gibt alle Vias aus, die für das Routen zur Verfügung stehen.

+
+

Editieren

+
+

Wenn Sie diesen Button drücken, erscheint ein neues Fenster mit einer Tabelle zum Editieren der Vias. + Hier können Sie Namen, Padstack, Clearance-Klasse und die SMD-Überlappungseigenschaft gemäß + Ihren Anforderungen verändern. Unten an diesem Fenster befinden sich zwei Buttons, mit denen Sie neue + Vias hinzufügen oder existierende Vias löschen können.

+
+
+

Via-Regeln

Unterhalb befindet sich ein Fenster, in dem alle Via-Regeln namentlich aufgelistet sind. Im Folgenden +wird die Funktion der vier Buttons am unteren Rand beschrieben: +
+

Info

+
+

Nachdem Sie mit der linken Maustaste eine Via-Regel ausgewählt haben, können Sie sich diese mit + Info anzeigen lassen. Die Vias weiter oben in der dann erscheinenden Liste werden gegenüber den + Vias weiter unten beim Routen bevorzugt.

+
+

Neu

+
+

Wenn Sie den Button Neu drücken, werden Sie nach dem Namen der neuen Via-Regel gefragt. Nachdem + Sie diesen angegeben haben, wird im Fenster oberhalb eine leere Regel mit dem neuen Namen hinzugefügt. + Wählen Sie jetzt die neue Regel mit der linken Maustaste aus und drücken Sie den Button Editieren, + um Vias in die neue Regel einzufügen.

+
+

Editieren

+
+

Wenn Sie eine Via-Regel mit der linken Maustaste auswählen und danach den Button Editieren drücken, + erscheint ein neues Fenster, in dem Sie die Via-Regel verändern können. Weiteres finden Sie unter + Via-Regel editieren.

+
+

Löschen

+
+

Mit diesem Button können Sie die ausgewählte Via-Regel löschen.

+
+
+

Via-Regel editieren

+
Wenn Sie eine Via-Regel zum Editieren ausgewählt haben, erscheint ein neues Fenster, in dem alle Vias + aufgelistet sind, die in der selektierten Regel vorkommen. Vias weiter oben in dieser Liste werden gegenüber + Vias weiter unten beim Routen bevorzugt. Im Folgenden wird die Funktion der Buttons in diesem neuen Fenster + beschrieben.

Hinzufügen

+
+

Es erscheint ein Fenster in dem Sie ein Via aus allen zur Verfügung stehenden Vias auswählen können. + Nachdem Sie das Via ausgewählt haben und den OK-Button gedrückt haben, wird das ausgewählte + Via an das Ende der Liste angehängt.

+
+

Löschen

+
+

Nachdem Sie mit der linken Maustaste ein Via ausgewählt haben, können Sie es durch Drücken des + Button Löschen aus der Liste entfernen.

+
+

Aufwärts

+
+

Nachdem Sie mit der linken Maustaste ein Via ausgewählt haben, können Sie durch Drücken des + Button Aufwärts die Position des Vias in der Liste um einen Platz nach oben verschieben. Dadurch + wird die Priorität dieses Vias beim Routen erhöht. Vias weiter oben in der Liste werden gegenüber + Vias weiter unten bevorzugt.

+
+

Abwärts

+
+

Nachdem Sie mit der linken Maustaste ein Via ausgewählt haben, können Sie durch Drücken des + Button Abwärts die Position des Vias in der Liste um einen Platz nach unten verschieben. Dadurch + wird die Priorität dieses Vias beim Routen verringert. Vias weiter oben in der Liste werden gegenüber + Vias weiter unten bevorzugt.

+ +

+
+
+

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/de/index.html b/src/main/java/net/freerouting/helpset/de/index.html index 9af3e4fc..557ff80b 100644 --- a/src/main/java/net/freerouting/helpset/de/index.html +++ b/src/main/java/net/freerouting/helpset/de/index.html @@ -2,21 +2,34 @@ - - - - Bedienungsanleitung - - - -

Bedienungsanleitung für die Online-Hilfe

-

Das Inhaltsverzeichnis

- Im linken Fenster dieser Online-Hilfe sehen Sie das Inhaltsverzeichnis. Es enthält die drei Ordner Menüleiste, Interaktive Zustände und Fenster. Im Ordner Menüleiste finden Sie Hilfe zu den einzelnen Einträgen im Pulldown-Menü. Der Ordner Interaktive Zustände enthält Hilfe über die möglichen interaktiven Zustände des Programms. Im Ordner mit dem Namen Fenster erhalten Sie Hilfe zur Funktionalität der einzelnen Zusatzfenster des Programms.

Kontextsensitive Hilfe

Wenn Sie im Hilfe-Menü kontextsensitive Hilfe gewählt haben, erscheint ein Frageteichen rechts vom Cursor. Drücken Sie in diesem Zustand die linke Maustaste im Grafikbereich des Hauptfensters, um Hilfe über den aktuellen interaktiven Zustand des Programms zu bekommen, oder in einem Zusatzfenster, um sich die die dortige Funktionalität beschreiben zu lassen. In der Offline-Version können Sie stattdessen auch die F1-Taste benutzen.

Die Online-Hilfe durchsuchen

-

Für eine Volltextsuche in der Online-Hilfe klicken Sie im linken Fenster die Spalte Suchen und geben Sie den gesuchten Begriff in das Textfeld ein.

-

Den Index verwenden

- - Klicken Sie einen Eintrag in der Spalte Index im linken Fenster, um Auskunft über das entsprechende Thema zu erhalten. Durch mehrfaches Drücken der Return-Taste erhalten sie alle Einträge zum gesuchten Thema. -

- + + + + Bedienungsanleitung + + + +

Bedienungsanleitung für die Online-Hilfe

+ +

Das Inhaltsverzeichnis

+Im linken Fenster dieser Online-Hilfe sehen Sie das Inhaltsverzeichnis. Es enthält die drei Ordner Menüleiste, +Interaktive Zustände und Fenster. Im Ordner Menüleiste finden Sie Hilfe zu den einzelnen +Einträgen im Pulldown-Menü. Der Ordner Interaktive Zustände enthält Hilfe über die möglichen +interaktiven Zustände des Programms. Im Ordner mit dem Namen Fenster erhalten Sie Hilfe zur Funktionalität +der einzelnen Zusatzfenster des Programms.

Kontextsensitive Hilfe

Wenn Sie im Hilfe-Menü kontextsensitive +Hilfe gewählt haben, erscheint ein Frageteichen rechts vom Cursor. Drücken Sie in diesem Zustand die linke +Maustaste im Grafikbereich des Hauptfensters, um Hilfe über den aktuellen interaktiven Zustand des Programms zu +bekommen, oder in einem Zusatzfenster, um sich die die dortige Funktionalität beschreiben zu lassen. In der +Offline-Version können Sie stattdessen auch die F1-Taste benutzen.

Die Online-Hilfe durchsuchen

+ +

Für eine Volltextsuche in der Online-Hilfe klicken Sie im linken Fenster die Spalte Suchen und geben Sie + den gesuchten Begriff in das Textfeld ein.

+ +

Den Index verwenden

+ +Klicken Sie einen Eintrag in der Spalte Index im linken Fenster, um Auskunft über das entsprechende Thema zu +erhalten. Durch mehrfaches Drücken der Return-Taste erhalten sie alle Einträge zum gesuchten Thema. +

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/HelpIndex.xml b/src/main/java/net/freerouting/helpset/en/HelpIndex.xml index 6574e6b9..fa9c743e 100644 --- a/src/main/java/net/freerouting/helpset/en/HelpIndex.xml +++ b/src/main/java/net/freerouting/helpset/en/HelpIndex.xml @@ -1,179 +1,180 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/HelpTOC.xml b/src/main/java/net/freerouting/helpset/en/HelpTOC.xml index 42f6d4b8..3f722e7a 100644 --- a/src/main/java/net/freerouting/helpset/en/HelpTOC.xml +++ b/src/main/java/net/freerouting/helpset/en/HelpTOC.xml @@ -1,157 +1,158 @@ - + - - - + + + - + - + - - - + + + - - - + + + - + - - - - - + + + + + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - - - + + + - + - + - + - - - + + + - + - + - + - - - + + + - + - + - + - + - + - + - + - - - + + + - - - - - + + + + + - - + + - - + + - - + + - - - + + + - - + + - + - - - + + + - - - + + + - - - + + + - + - + - + - + - + - + - - - + + + - + - + - + - - + + \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/Map.jhm b/src/main/java/net/freerouting/helpset/en/Map.jhm index f97d8ee6..4b6cd9d3 100644 --- a/src/main/java/net/freerouting/helpset/en/Map.jhm +++ b/src/main/java/net/freerouting/helpset/en/Map.jhm @@ -1,197 +1,210 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/FileMenu.html b/src/main/java/net/freerouting/helpset/en/html_files/FileMenu.html index 218e3989..73421f17 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/FileMenu.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/FileMenu.html @@ -2,55 +2,94 @@ - - - - Das Datei-Menü - + + + + Das Datei-Menü + - -

The File Menu Entries

-
-

Save

-
-

The current state of the design will be saved in the internal .bin file format. Not available in the web-based version because designs in the .bin format may be not compatible acrosss different versions of the router.

-
-

Save and Exit

-
-

The program exits after saving the current state of the design in the internal .bin file format.Not available in the web-based version because designs in the .bin format may be not compatible across different versions of the router.

-
-

Cancel and Exit

-
-

The program exits discarding the changes in the design.

-
-

Save as

-
-

Here you can save the current state of the design in a file with a file name of your choice. Allowed are the extensions .bin and .dsn. If you choose the extension .bin, the design will be saved in the internal binary format. In this case the current state of the IDE will also be saved. Because a design saved in this file format cannot be read in general by a later version of the router, the .bin-format is only available in the offline version. If you want to be able to read the saved design with a later version of this software, you have to select the extension .dsn.The design will then be saved in a text file format which is an extension of the Specctra-dsn format.

-
-

Generate Logfile

-
-

From now on all interactive actions are written to a log-file, so that this sequence can be repeated later on with Replay Logfile. Only actions, where the design is changed, are saved. This menu entry is provided in order to make short interactive actions repeatable for debugging. There is no warranty that it will work correctly on long interactive sequences. The name of such a log-file must have the extension .log. Not available in the web-based version.

-
-

Replay Logfile

-
-

The sequence of actions in a file with the extension .log generated by Generate Logfile will be repeated. The design must be in the same state as it was before generating the log-file. Not available in the web-based version.

-
-

Save GUI Settings as Default

-
-

The current interactive settings will be saved in a file with name gui_defaults.par. In the web-based version this file is hidden in the the Java Control Panel cache. You can delete it with Restore System Defaults in the router control panel. When you open later on a design in the .dsn format and a file with name gui_defaults.par is found, the saved settings are restored. In this way you can save your personal preferences for the GUI independent of the design. If you prefer different colors for the object types, or if you have two display screens and want to move the positions of the subwindows to the second screen, you do not have to make this change each time you open a new design. It is recommended to create the file gui_defaults.par from a design with as many layers as possible. Otherwise the layer dependent colors of the single object types would repeat, if this file was created from a design with fewer layers than the current design.

-
-

Export Specctra Session File

-
-

If you want to transfer the changes of the design created by this software back to the host system, you can write here a session file in the Specctra .ses format. You can then import this file into the host system, as you would do it when using the Specctra or Electra autorouter. After the session file is written, you will be asked if you also want to save the rules created inside this program for later reuse. Answer with yes, if for example you have created Via Rules, which you want to reuse after switching forth and back to the host system. However a new created rule in the host system might be overwritten by a saved rule in this case.

-

If the original design file was created by Cadsoft-Eagle, you will see the following entry instead:

-
-

Export Eagle Session Script

-
-

A text file with the same name as the design file and the extension .scr will be written. You can import the changes of the design to Cadsoft Eagle by selecting in the Files pull down menu of Eagle script... and choosing this text file. After the text file is written, you will be asked if you also want to save the rules created inside this program for later reuse. Answer with yes, if for example you have created Via Rules, which you want to reuse after switching forth and back to Eagle. However a new created rule in the Eagle might be overwritten by a saved rule in this case

-

-

-
-
- + +

The File Menu Entries

+
+

Save

+
+

The current state of the design will be saved in the internal .bin file format. Not available in the + web-based version because designs in the .bin format may be not compatible acrosss different versions of the + router.

+
+

Save and Exit

+
+

The program exits after saving the current state of the design in the internal .bin file format.Not available + in the web-based version because designs in the .bin format may be not compatible across different versions + of the router.

+
+

Cancel and Exit

+
+

The program exits discarding the changes in the design.

+
+

Save as

+
+

Here you can save the current state of the design in a file with a file name of your choice. Allowed are the + extensions .bin and .dsn. If you choose the extension .bin, the design will be saved in the internal binary + format. In this case the current state of the IDE will also be saved. Because a design saved in this file + format cannot be read in general by a later version of the router, the .bin-format is only available in the + offline version. If you want to be able to read the saved design with a later version of this software, you + have to select the extension .dsn.The design will then be saved in a text file format which is an extension + of the Specctra-dsn format.

+
+

Generate Logfile

+
+

From now on all interactive actions are written to a log-file, so that this sequence can be repeated later on + with Replay Logfile. Only actions, where the design is changed, are saved. This menu entry is + provided in order to make short interactive actions repeatable for debugging. There is no warranty that it + will work correctly on long interactive sequences. The name of such a log-file must have the extension .log. + Not available in the web-based version.

+
+

Replay Logfile

+
+

The sequence of actions in a file with the extension .log generated by Generate Logfile will be + repeated. The design must be in the same state as it was before generating the log-file. Not available in + the web-based version.

+
+

Save GUI Settings as Default

+
+

The current interactive settings will be saved in a file with name gui_defaults.par. In the web-based version + this file is hidden in the the Java Control Panel cache. You can delete it with Restore System Defaults in + the router control panel. When you open later on a design in the .dsn format and a file with name + gui_defaults.par is found, the saved settings are restored. In this way you can save your personal + preferences for the GUI independent of the design. If you prefer different colors for the object types, or + if you have two display screens and want to move the positions of the subwindows to the second screen, you + do not have to make this change each time you open a new design. It is recommended to create the file + gui_defaults.par from a design with as many layers as possible. Otherwise the layer dependent colors of the + single object types would repeat, if this file was created from a design with fewer layers than the current + design.

+
+

Export Specctra Session File

+
+

If you want to transfer the changes of the design created by this software back to the host system, you can + write here a session file in the Specctra .ses format. You can then import this file into the host system, + as you would do it when using the Specctra or Electra autorouter. After the session file is written, you + will be asked if you also want to save the rules created inside this program for later reuse. Answer with + yes, if for example you have created Via Rules, which you want to reuse after switching forth and back to + the host system. However a new created rule in the host system might be overwritten by a saved rule in this + case.

+ +

If the original design file was created by Cadsoft-Eagle, you will see the following entry instead:

+
+

Export Eagle Session Script

+
+

A text file with the same name as the design file and the extension .scr will be written. You can + import the changes of the design to Cadsoft Eagle by selecting in the Files pull down menu of Eagle script... + and choosing this text file. After the text file is written, you will be asked if you also want to save the + rules created inside this program for later reuse. Answer with yes, if for example you have created Via + Rules, which you want to reuse after switching forth and back to Eagle. However a new created rule in the + Eagle might be overwritten by a saved rule in this case

+ +

+ +

+
+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/MenuState.html b/src/main/java/net/freerouting/helpset/en/html_files/MenuState.html index f1e5b17b..d1101fec 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/MenuState.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/MenuState.html @@ -2,82 +2,117 @@ - - - - Menü-Zustand - + + + + Menü-Zustand + - -

The Menu States

- The program contains the following three Menu States: Select, Route and Drag. By selecting one of the three buttons on the upper left side of the tool bar you can switch between this states. In the beginning the program will be in the Select Menu State.

The three states have a common tool bar and a common popup menu under the right mouse button.

-

Further Entries in the Tool Bar:

-
- Autorouter -
-

To start the batch autorouter on the whole board.

-
-

Undo, Redo

-
-

The program has unlimited Undo Redo capability. In the offline version the Undo stack does not get lost even after saving the design and restarting the program. Shortcuts are u for Undo and b for Redo.

-
-

Incompletes

-
-

Here you can switch on or off displaying the open connections as air lines. If the airlines were switched off before, they will be switched on and vice versa. Shortcut is g.

-
-

Violations

-
-

Here you can switch on or off displaying the clearance violations. If the violations were switched off before, they will be switched on and vice versa. Shortcut is v.

-
-

Zoom All

-
-

To display the whole board. Shortcut is a.

-
-

Zoom Region

-
-

After selecting this button you can choose a display rectangle by dragging the mouse with the left button pressed. Shortcut is f. You can also zoom by turning the mouse wheel and pan by dragging the mouse with the mouse wheel pressed.

-
-

Unit

-
-

To change the Unit or the Unit Factor. Possible choices are mil, inch, mm and um. After selecting for example 0.1 mm all coordinates in the IDE are displayed as multiples of 0.1 mm.

-
-
-

The Entries in the Popup Menu:

-
- select item -
-

To select the items under the cursor. Only items switched on in the Select Parameter window can be selected. After selecting some items the current interactive state will change to the Selected Item State. In the Select Menu State you can select items also with the left mouse button.

-
- start route -
A new trace will be started beginning at the item under the cursor. For the selection of the start item the settings in the Select Parameter window are evaluated . If a suitable item was found the interactive state will change to the Route State. In the Route Menu State you can do this also by clicking the left mouse button.
- create keepout -
- To create a keepout on the current layer. You can create a circle, a polygons or a hole into an existing polygonal keepout.
- swap pin -
- This menu entry appears only if the board contains swappable pins. If the pin under the cursor is swappable, you can change the net of this pin with a suitable other pin.
-

The letters in brackets behind the Popup Menu entries describe the shortcuts for the corresponding actions.

-
-

The Function of the Mouse Wheel:

-
-

By rotating the mouse wheel you can zoom in or out and by dragging the mouse with the mouse wheel pressed you can change the displayed section of the board.

-

-
-

-

The Select Menu State

- If on the upper left side in the tool bar the button Select is selected, the program will be in the Select Menu State. Here you can use the left mouse button as a shortcut for the action select item in the popup menu. You also can select all items in a rectangle by dragging the mouse with the left button pressed. - -

back

-

-

The Route Menu State

- If on the upper left side in the tool bar the button Route is selected, the program will be in the Route Menu State. Here you can use the left mouse button as a shortcut for the action start route in the popup menu. - -

back

-

-

The Drag Menu State

- If on the upper left side in the tool bar the button Drag is selected, the program will be in the Drag Menu State Here you can drag vias or components with the left button pressed. The connected traces will be adjusted automatically. You can also out of the empty space shove traces aside with the left button pressed This way you can for example make space for inserting another component. This action will be performed on the current layer, which can be set in the Select Parameter window. - -

back

- + +

The Menu States

+The program contains the following three Menu States: Select, Route and Drag. By selecting one of the three +buttons on the upper left side of the tool bar you can switch between this states. In the beginning the program will be +in the Select Menu State.

The three states have a common tool bar and a common popup menu under the right mouse + button.

+

Further Entries in the Tool Bar:

+
+ Autorouter +
+

To start the batch autorouter on the whole board.

+
+

Undo, Redo

+
+

The program has unlimited Undo Redo capability. In the offline version the Undo stack does not get lost even + after saving the design and restarting the program. Shortcuts are u for Undo and b for Redo. +

+
+

Incompletes

+
+

Here you can switch on or off displaying the open connections as air lines. If the airlines were switched off + before, they will be switched on and vice versa. Shortcut is g.

+
+

Violations

+
+

Here you can switch on or off displaying the clearance violations. If the violations were switched off + before, they will be switched on and vice versa. Shortcut is v.

+
+

Zoom All

+
+

To display the whole board. Shortcut is a.

+
+

Zoom Region

+
+

After selecting this button you can choose a display rectangle by dragging the mouse with the left button + pressed. Shortcut is f. You can also zoom by turning the mouse wheel and pan by dragging the mouse + with the mouse wheel pressed.

+
+

Unit

+
+

To change the Unit or the Unit Factor. Possible choices are mil, inch, mm and + um. After selecting for example 0.1 mm all coordinates in the IDE are displayed as multiples of + 0.1 mm.

+
+
+

The Entries in the Popup Menu:

+
+ select item +
+

To select the items under the cursor. Only items switched on in the Select + Parameter window can be selected. After selecting some items the current interactive state will change + to the Selected Item State. In the Select + Menu State you can select items also with the left mouse button.

+
+ start route +
A new trace will be started beginning at the item under the cursor. For the selection of the start item + the settings in the Select Parameter window are evaluated . If a + suitable item was found the interactive state will change to the Route State. In + the Route Menu State you can do this also by clicking the left mouse button. +
+ create keepout +
+ To create a keepout on the current layer. You can create a circle, a polygons or a hole into an existing + polygonal keepout. +
+ swap pin +
+ This menu entry appears only if the board contains swappable pins. If the pin under the cursor is swappable, you + can change the net of this pin with a suitable other pin. +
+

The letters in brackets behind the Popup Menu entries describe the shortcuts for the corresponding actions.

+
+

The Function of the Mouse Wheel:

+
+

By rotating the mouse wheel you can zoom in or out and by dragging the mouse with the + mouse wheel pressed you can change the displayed section of the board.

+ +

+
+

+ +

The Select Menu State

+If on the upper left side in the tool bar the button Select is selected, the program will be in the Select Menu +State. Here you can use the left mouse button as a shortcut for the action select item in the popup menu. You +also can select all items in a rectangle by dragging the mouse with the left button pressed. + +

back

+

+ +

The Route Menu State

+If on the upper left side in the tool bar the button Route is selected, the program will be in the Route Menu +State. Here you can use the left mouse button as a shortcut for the action start route in the popup menu. + +

back

+

+ +

The Drag Menu State

+If on the upper left side in the tool bar the button Drag is selected, the program will be in the Drag Menu State +Here you can drag vias or components with the left button pressed. The connected traces will be adjusted automatically. +You can also out of the empty space shove traces aside with the left button pressed This way you can for example make +space for inserting another component. This action will be performed on the current layer, which can be set in +the Select Parameter window. + +

back

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/MoveItemState.html b/src/main/java/net/freerouting/helpset/en/html_files/MoveItemState.html index 0496eec3..699875b3 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/MoveItemState.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/MoveItemState.html @@ -2,41 +2,57 @@ - - - - Move-Zustand - + + + + Move-Zustand + - -

The Move State

You will get into this state after selecting in the popup menu of the Selected Item State the menu entry move. The selected items are now following the cursor.

If parts of the moving items are marked red, inserting at the current location would cause a clearance violation.

-

Several components can be moved at once. The internal route will also change location, if he is completely marked for moving. Components connected to items, which are not marked for moving, will not change location. Such components can eventually be moved in the Drag Menu State by dragging them with the left mouse button. If that does not work, you have to remove the route first.

-

The settings in the Move Parameter window are evaluated while moving components.

-

The entries in the popup menu under the left mouse button:

-
- turn -
-

Here you can rotate the selected components by multiples of 45 degree around the cursor location. For turning by 90, 180, and -90 degree there are the shortcuts +, * and - on the right of the number key block. If you want to rotate by an angle, which is not a multiple of 45 degree, you can do that with the mouse wheel after first changing in the Move Parameter window the wheel function from zoom to rotate.

-
-

change side

-
-

Here you can change the placement side of the selected components. Shortcut is /.

-
-

reset rotation

-
-

Here you can reset the rotation of the selected components, which you have changed with the mouse wheel, to 0 degree.

-
-

insert

-
-

To insert the moving components. If there would occur clearance violations, he insertion will be rejected. Shortcut is the left mouse button.

-
-

cancel

-
-

To cancel the move action. The selected components will spring back to their location before the moving. Shortcut is the Esc-key.

-
-
- - + +

The Move State

You will get into this state after selecting in the popup menu of the Selected Item State the menu entry move. The selected items are now +following the cursor.

If parts of the moving items are marked red, inserting at the current location would cause a + clearance violation.

+ +

Several components can be moved at once. The internal route will also change location, if he is completely marked for + moving. Components connected to items, which are not marked for moving, will not change location. Such components + can eventually be moved in the Drag Menu State by dragging them with the + left mouse button. If that does not work, you have to remove the route first.

+ +

The settings in the Move Parameter window are evaluated while moving + components.

+

The entries in the popup menu under the left mouse button:

+
+ turn +
+

Here you can rotate the selected components by multiples of 45 degree around the cursor location. For turning + by 90, 180, and -90 degree there are the shortcuts +, * and - on the right of the number key block. If you + want to rotate by an angle, which is not a multiple of 45 degree, you can do that with the mouse wheel after + first changing in the Move Parameter window the wheel function from + zoom to rotate.

+
+

change side

+
+

Here you can change the placement side of the selected components. Shortcut is /.

+
+

reset rotation

+
+

Here you can reset the rotation of the selected components, which you have changed with the mouse wheel, to 0 + degree.

+
+

insert

+
+

To insert the moving components. If there would occur clearance violations, he insertion will be rejected. + Shortcut is the left mouse button.

+
+

cancel

+
+

To cancel the move action. The selected components will spring back to their location before the moving. + Shortcut is the Esc-key.

+
+
+ + \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/RouteState.html b/src/main/java/net/freerouting/helpset/en/html_files/RouteState.html index 08b4d5d6..c7a759f4 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/RouteState.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/RouteState.html @@ -2,56 +2,88 @@ - - - - Route-Zustand - - - -

The Route States

After you have started a new route in a basic state, the IDE will change to the Dynamic Route State or to the Stitching Route State depending on your selection for the route mode in the Route Parameter window. -

If rule selection is set to automatic, the routing rules such as trace width, trace clearance class and via rule are defined by the net class of the current net, if it is set to manual, the routing rules are defined by the settings in the Manual Rules window.

-

If the new trace gets near to a not yet connected item of the same net on the same layer, the connection will be completed automatically. After completion the IDE will return to the state before routing.

-

back

-

The Dynamic Route State

If the IDE is in this route state, at each change of the cursor location a piece of trace will be inserted automatically from the previous cursor location to the current cursor location. The new trace piece will then immediately be optimized depending on the settings for the pull tight region in the Route Parameter window.

The entries in the popup menu under the left mouse button in the Dynamic Route state:

-
- change layer -
-

To change to a different layer. The corresponding via will be selected from the selected via rule in the following way. The vias in the via rules will be tried from top to bottom, if they contain the old and the new layer, and if inserting would be possible without clearance violations. The first via found in this way will be inserted. Shortcuts are the number keys 1-9 and the keys "+" and "-". With "+" you can change to the next bigger layer and with "-" to the next smaller layer.

-
-

end route

-
-

The routing will be finished and the IDE changes back to the previous state. Shortcut is the left mouse button.

-
-

cancel route

-
-

The last routed trace will be discarded and the IDE changes back to the previous state Shortcut is the Esc-key.

-
-

generate snapshot

-
-

The program generates a snapshot, so that the current situation can be restored later on with Undo. Otherwise you could only restore the situation before starting the last trace with Undo.

-
-
-

back

-

Der Stitching Route State

- - In this route state a piece of trace will be inserted from the previous click position to the current cursor position, when you click the left mouse key. The new trace piece will then be optimized depending on the settings for the pull tight region in the Route Parameter window. -

The entries in the popup menu under the left mouse button in the Stitching Route state:

-
-

insert

-
-

A trace will be inserted from the previous insert position to the current position and then be optimized depending on the settings for the pull tight region in the Route Parameter window.

-
-

done

-
-

The program returns to the state before routing. Shortcut is the Esc-key.

-
-

change layer

-
-

To change to a different layer. The corresponding via will be selected from the selected via rule in the following way. The vias in the via rules will be tried from top to bottom, if they contain the old and the new layer, and if inserting would be possible without clearance violations. The first via found in this way will be inserted. Shortcuts are the number keys 1-9 and the keys "+" and "-". With "+" you can change to the next bigger layer and with "-" to the next smaller layer.

-
-
-

back

- + + + + Route-Zustand + + + +

The Route States

After you have started a new route in a basic state, +the IDE will change to the Dynamic Route State or to the Stitching Route State depending on your selection for the route mode in the Route Parameter window. +

If rule selection is set to automatic, the routing rules + such as trace width, trace clearance class and via rule are defined by the net + class of the current net, if it is set to manual, the routing rules are defined by the settings in + the Manual Rules window.

+ +

If the new trace gets near to a not yet connected item of the same net on the same layer, the connection will be + completed automatically. After completion the IDE will return to the state before routing.

+ +

back

+ +

The Dynamic Route State

If the IDE is in this route state, at each change of the +cursor location a piece of trace will be inserted automatically from the previous cursor location to the current cursor +location. The new trace piece will then immediately be optimized depending on the settings for the pull tight region in the Route Parameter window.

The + entries in the popup menu under the left mouse button in the Dynamic Route state:

+
+ change layer +
+

To change to a different layer. The corresponding via will be selected from the selected via rule in the following way. The vias in the via rules will be tried from + top to bottom, if they contain the old and the new layer, and if inserting would be possible without + clearance violations. The first via found in this way will be inserted. Shortcuts are the number keys 1-9 + and the keys "+" and "-". With "+" you can change to the next bigger layer and + with "-" to the next smaller layer.

+
+

end route

+
+

The routing will be finished and the IDE changes back to the previous state. Shortcut is the left mouse + button.

+
+

cancel route

+
+

The last routed trace will be discarded and the IDE changes back to the previous state Shortcut is the + Esc-key.

+
+

generate snapshot

+
+

The program generates a snapshot, so that the current situation can be restored later on with Undo. Otherwise + you could only restore the situation before starting the last trace with Undo.

+
+
+

back

+ +

Der Stitching Route State

+ +In this route state a piece of trace will be inserted from the previous click position to the current cursor position, +when you click the left mouse key. The new trace piece will then be optimized depending on the settings for the pull tight region in the Route Parameter window. +

The entries in the popup menu under the left mouse button in the Stitching Route state:

+
+

insert

+
+

A trace will be inserted from the previous insert position to the current position and then be optimized + depending on the settings for the pull tight region + in the Route Parameter window.

+
+

done

+
+

The program returns to the state before routing. Shortcut is the Esc-key.

+
+

change layer

+
+

To change to a different layer. The corresponding via will be selected from the selected via rule in the following way. The vias in the via rules will be tried from + top to bottom, if they contain the old and the new layer, and if inserting would be possible without + clearance violations. The first via found in this way will be inserted. Shortcuts are the number keys 1-9 + and the keys "+" and "-". With "+" you can change to the next bigger layer and + with "-" to the next smaller layer.

+
+
+

back

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/SelectedItemState.html b/src/main/java/net/freerouting/helpset/en/html_files/SelectedItemState.html index b8af3c26..e96dd747 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/SelectedItemState.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/SelectedItemState.html @@ -2,91 +2,107 @@ - - - - Auswahl-Zustand - + + + + Auswahl-Zustand + - -

The Selected Item State

After you have selected items in a basic state, the IDE will change to the Selected Item State. The selected items get highlighted and a new tool bar appears at the upper border. With the left button you can select more items or deselect already selected items.

The toolbar in the Selected Item State

-
- Cancel -
-

The IDE returns to the interactive state before selecting. Shortcut is the Esc-key.

-
-

Info

-
-

Information about the selected items will be printed to a new window. The blue marked words in this window can be clicked for more information. Shortcut is i.

-
-

Delete

-
-

The selected items will be deleted, if they are not fixed. Shortcut is the Delete-key.

-
-

Cutout

-
-

By dragging the mouse with the left button pressed you can select a rectangle, from which the selected trace and vias will be cut out. Shortcut is d.

-
-

Fix

-
-

To fix the selected items, so that they cannot be pushed or deleted any more. Shortcut is f.

-
-

Unfix

-
-

To unfix the selected items. Shortcut is u.

-
-

Autoroute

-
-

To route the selected items automatically. Shortcut is a.

-
-

Pull Tight

-
-

To optimize the selected traces by pulling them tight. Shortcut is p.

-
-

Fanout

-
-

To autoroute the selected SMD-Pins until the next via.

-
-

Clearance

-
-

To assign a new clearance class to the selected items.

-

Example: If you need in a special area of the board a different spacing, you can select all pins in a rectangle and assign to them a new clearance class.

-
-

Nets

-
-

To extend the selection to all items with the same net as an already selected item. Shortcut is n.

-
-

Conn. Sets

-
-

To extend the selection to all items, which belong to the same connected set as an already selected item. Shortcut is s.

-
-

Connections

-
-

To extend the selection to all traces and vias, which belong to the same connection as an already selected item. Shortcut is e.

-

Example: You want to delete a whole connection. Select a trace of the connection, push the Connections button to extend the selection to the whole connection and push then the Delete button.

-
-

Components

-
-

To extend the selection to all items, which belong to the same component as an already selected item. Shortcut is b.

-
-

Violations

-
-

Here you can switch on or off displaying the clearance violations. If the violations were switched off before, they will be switched on and vice versa. Shortcut is v.

-
-

Zoom Selection

-
-

To display a rectangle containing all selected items.

-
-
-

The popup menu below the left mouse button

-
- move -
The selected items will be prepared for moving. The pivot for rotating and moving is the current cursor position. Several components can be moved at once. After this action the IDE will be in the Move State.
-
-

back

-
-

-
- + +

The Selected Item State

After you have selected items in a basic +state, the IDE will change to the Selected Item State. The selected items get highlighted and a new tool bar appears at +the upper border. With the left button you can select more items or deselect already selected items.

The toolbar in + the Selected Item State

+
+ Cancel +
+

The IDE returns to the interactive state before selecting. Shortcut is the Esc-key.

+
+

Info

+
+

Information about the selected items will be printed to a new window. The blue marked words in this window + can be clicked for more information. Shortcut is i.

+
+

Delete

+
+

The selected items will be deleted, if they are not fixed. Shortcut is the Delete-key.

+
+

Cutout

+
+

By dragging the mouse with the left button pressed you can select a rectangle, from which the selected trace + and vias will be cut out. Shortcut is d.

+
+

Fix

+
+

To fix the selected items, so that they cannot be pushed or deleted any more. Shortcut is f.

+
+

Unfix

+
+

To unfix the selected items. Shortcut is u.

+
+

Autoroute

+
+

To route the selected items automatically. Shortcut is a.

+
+

Pull Tight

+
+

To optimize the selected traces by pulling them tight. Shortcut is p.

+
+

Fanout

+
+

To autoroute the selected SMD-Pins until the next via.

+
+

Clearance

+
+

To assign a new clearance class to the selected items.

+ +

Example: If you need in a special area of the board a different spacing, you can select all pins in a + rectangle and assign to them a new clearance class.

+
+

Nets

+
+

To extend the selection to all items with the same net as an already selected item. Shortcut is n.

+
+

Conn. Sets

+
+

To extend the selection to all items, which belong to the same connected set as an already selected item. + Shortcut is s.

+
+

Connections

+
+

To extend the selection to all traces and vias, which belong to the same connection as an already selected + item. Shortcut is e.

+ +

Example: You want to delete a whole connection. Select a trace of the connection, push the Connections + button to extend the selection to the whole connection and push then the Delete button.

+
+

Components

+
+

To extend the selection to all items, which belong to the same component as an already selected item. + Shortcut is b.

+
+

Violations

+
+

Here you can switch on or off displaying the clearance violations. If the violations were switched off + before, they will be switched on and vice versa. Shortcut is v.

+
+

Zoom Selection

+
+

To display a rectangle containing all selected items.

+
+
+

The popup menu below the left mouse button

+
+ move +
The selected items will be prepared for moving. The pivot for rotating and moving is the current cursor + position. Several components can be moved at once. After this action the IDE will be in the Move State. +
+
+

back

+
+

+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteDetailParameter.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteDetailParameter.html index 8bd4e996..4a3d47c0 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteDetailParameter.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteDetailParameter.html @@ -1,37 +1,41 @@ - + - - - - Detail Autoroute Parameter - + + + + Detail Autoroute Parameter + - -

Detail Autoroute Parameter

Description of the window with the detailed autoroute parameter:

Via costs:

-
-
-

To adjust the costs for vias in the autoroute algorithm. If you increase the value, the autorouter will try to insert less vias. If the value is to high, the autorouter may not be able to complete 100%.

-
-
-

Start pass:

-
-

To adjust the number of the first pass in the batch autorouter. The ripup-costs increase in passes with higher pass number.

-
-

Ripup start costs:

-
-

To define the ripup costs in the pass with number 1. The ripup costs in the pass with the number N are (N * (Ripup start costs)).

-
-

Trace costs on layer:

-
-

To adjust for each signal layer the costs for traces in and against the preferred direction.

-
-

back

-
-

-
-

- + +

Detail Autoroute Parameter

Description of the window with the detailed autoroute parameter:

Via costs:

+
+
+

To adjust the costs for vias in the autoroute algorithm. If you increase the value, the autorouter will try + to insert less vias. If the value is to high, the autorouter may not be able to complete 100%.

+
+
+

Start pass:

+
+

To adjust the number of the first pass in the batch autorouter. The ripup-costs increase in passes with higher + pass number.

+
+

Ripup start costs:

+
+

To define the ripup costs in the pass with number 1. The ripup costs in the pass with the number N are (N + * (Ripup start costs)).

+
+

Trace costs on layer:

+
+

To adjust for each signal layer the costs for traces in and against the preferred direction.

+
+

back

+
+

+
+

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteParameter.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteParameter.html index 5bfe5160..28d851db 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteParameter.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowAutorouteParameter.html @@ -1,22 +1,31 @@ - + - - - - Autoroute Parameter - - - -

Autoroute Parameter

- Here you can define the layers which may be used by the autorouter, the preferred direction for traces on each layer, and if vias may be inserted by the autorouter. - -

You can also define, if before autorouting a fanout pass and after autorouting a postroute pass for reducing the via count and the cumulative trace length should run.

-

The postroute pass may take a very long time and can be stopped by clicking the left mouse button.

-

In a fanout pass the connections will be routed only till the first via. That may be useful on boards with many layers and ball grid arrrays.

-

The detail parameter button opens a window, where you can adjust the individual costs used in the autoroute algorithm.

-

back

- + + + + Autoroute Parameter + + + +

Autoroute Parameter

+Here you can define the layers which may be used by the autorouter, the preferred direction for traces on each layer, +and if vias may be inserted by the autorouter. + +

You can also define, if before autorouting a fanout pass and after autorouting a postroute pass for reducing the via + count and the cumulative trace length should run.

+ +

The postroute pass may take a very long time and can be stopped by clicking the left mouse button.

+ +

In a fanout pass the connections will be routed only till the first via. That may be useful on boards with many + layers and ball grid arrrays.

+ +

The detail parameter button opens a window, where you can + adjust the individual costs used in the autoroute algorithm.

+ +

back

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowClearanceMatrix.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowClearanceMatrix.html index 30502f36..d3007e78 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowClearanceMatrix.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowClearanceMatrix.html @@ -2,22 +2,39 @@ - - - - Clearance-Matrix - + + + + Clearance-Matrix + - -

The Clearance Matrix

-

In the window with the Clearance Matrix you can define the spacing rules between the object types. This is done via clearance classes. An Item clearance class is described by the definition of a minimal spacing to items of all existing clearance classes. These values can be looked up and changed in the Clearance Matrix

-

Predefined are the clearance classes null and default. Items of the clearance class null have a minimal spacing of 0 to all other items. This value cannot be changed in the Clearance Matrix.

-

In the Specctra-DSN-Format there exist only the hard coded clearance classes pin, smd, via, wire, area and testpoint. When reading the DSN-file at the program start the clearance classes of the host system will be taken over. The class wire will be renamed to default. The rest of the hard coded clearance classes will only be generated, if values for these classes are found in the DSN-file.

-

To add a new clearance class

- Press the button Add Class and enter the name of the new class into the dialog field, which is popping up. The Clearance Matrix will be extended by a row and a column with the values for the new class. Change the predefined values in the new row according to your needs. -

To remove redundant clearance classes

By pushing the Trim Button you can remove classes as redundant, whose entries in the Clearance Matrix are exact equal to the entries of an other class. All items belonging to the deleted clearance class will then be assigned to this other clearance class.

Layer dependent clearance classes

- In the layer field on top of the window you see the layers, for which the entries in the Clearance Matrix are valid. When all is selected in the combo box, the matrix entries are valid on all layers. If in this case layer dependent clearance values are defined for a special field, the value -1 is displayed, because it is not possible to output a value, which is valid on all layers. Analog if inner is selected in the combo box. You can view or edit a layer dependent clearance value after selecting the name of the layer of your choice in the layer combo box. -

- + +

The Clearance Matrix

+ +

In the window with the Clearance Matrix you can define the spacing rules between the object types. This is done via + clearance classes. An Item clearance class is described by the definition of a minimal spacing to items of all + existing clearance classes. These values can be looked up and changed in the Clearance Matrix

+ +

Predefined are the clearance classes null and default. Items of the clearance class null have a + minimal spacing of 0 to all other items. This value cannot be changed in the Clearance Matrix.

+ +

In the Specctra-DSN-Format there exist only the hard coded clearance classes pin, smd, via, wire, area and testpoint. + When reading the DSN-file at the program start the clearance classes of the host system will be taken over. The + class wire will be renamed to default. The rest of the hard coded clearance classes will only be + generated, if values for these classes are found in the DSN-file.

+

To add a new clearance class

+Press the button Add Class and enter the name of the new class into the dialog field, which is popping up. The +Clearance Matrix will be extended by a row and a column with the values for the new class. Change the predefined values +in the new row according to your needs. +

To remove redundant clearance classes

By pushing the Trim Button you can remove classes as redundant, +whose entries in the Clearance Matrix are exact equal to the entries of an other class. All items belonging to the +deleted clearance class will then be assigned to this other clearance class.

Layer dependent clearance classes

+In the layer field on top of the window you see the layers, for which the entries in the Clearance Matrix are valid. +When all is selected in the combo box, the matrix entries are valid on all layers. If in this case layer +dependent clearance values are defined for a special field, the value -1 is displayed, because it is not possible to +output a value, which is valid on all layers. Analog if inner is selected in the combo box. You can view or edit +a layer dependent clearance value after selecting the name of the layer of your choice in the layer combo box. +

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowDisplay.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowDisplay.html index 5b3d5bdc..bacff900 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowDisplay.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowDisplay.html @@ -2,48 +2,59 @@ - - - - Display-Einstellungen - + + + + Display-Einstellungen + - -

Display Settings

- Describes the windows with the display parameters + +

Display Settings

+Describes the windows with the display parameters -
-

Object Visibility

-
With the sliders in this window you can adjust the intensity for displaying the single object types. If you push the slider for an object type is to the right, objects of this type will get displayed with full intensity, if you push it to the left, objects of this type will become invisible.
-

Layer Visibility

-
-

With the sliders in this window you can adjust the intensity for displaying objects on each layer individually. If you push a slider to the left, all objects on the corresponding layer will get invisible.

-
-

Colors

-
-

Here you can define the colors for displaying objects on the board by clicking the corresponding color field with the left button. For the object types in the upper table you can choose the color for each layer individually.

-
-

Miscellaneous

-
-

crosshair cursor

-
-

Here you can change from the standard small crosshair cursor to a big 45-degree crosshair cursor. Using the big crosshair cursor may slow down the display performance a lot. Shortcut is the comma-key.

-
-

board rotation

-
-

To turn the board by multiples of 90 degree.

-
-

board mirroring

-
-

For horizontal or vertical mirroring of the board.

-
-

automatic layer dimming

-
-

With this slider you can increase the intensity of the items on the current layer. If you push the slider to the left, the automatic layer dimming will get switched off, if you push it to the right, all layers beside the current layer will become invisible.

-
-

-
-
- +
+

Object Visibility

+
With the sliders in this window you can adjust the intensity for displaying the single object types. If + you push the slider for an object type is to the right, objects of this type will get displayed with full + intensity, if you push it to the left, objects of this type will become invisible. +
+

Layer Visibility

+
+

With the sliders in this window you can adjust the intensity for displaying objects on each layer + individually. If you push a slider to the left, all objects on the corresponding layer will get + invisible.

+
+

Colors

+
+

Here you can define the colors for displaying objects on the board by clicking the corresponding color field + with the left button. For the object types in the upper table you can choose the color for each layer + individually.

+
+

Miscellaneous

+
+

crosshair cursor

+
+

Here you can change from the standard small crosshair cursor to a big 45-degree crosshair cursor. Using + the big crosshair cursor may slow down the display performance a lot. Shortcut is the comma-key.

+
+

board rotation

+
+

To turn the board by multiples of 90 degree.

+
+

board mirroring

+
+

For horizontal or vertical mirroring of the board.

+
+

automatic layer dimming

+
+

With this slider you can increase the intensity of the items on the current layer. If you push the slider to the + left, the automatic layer dimming will get switched off, if you push it to the right, all layers beside + the current layer will become invisible.

+
+

+
+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowManualRules.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowManualRules.html index c1021d04..1401c8f9 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowManualRules.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowManualRules.html @@ -2,30 +2,40 @@ - - - - Manuelle Regeln - + + + + Manuelle Regeln + - -

Manual Rules

- Window for the rules used in interactive routing when the route mode in the Route Parameter window is set to manual. -

via rule

-
- - In this combo box you can choose the via rule which you want to use currently in interactive routing.
-

trace clearance class:

-
- Use this combo box for selecting the clearance class which you want to use currently in interactive routing for traces.
-

trace width:

-
- Here you can edit the trace width you want to use currently in interactive routing.
-

on layer:

-
-

Defines the layers, for which the trace width in the field above is valid. If all is selected in the combo box, the value in the trace width field is valid on all layers. If inner is selected, it is valid on all inner layers. Otherwise the value is valid only on the layer with the selected name in the combo box. The trace width field remains empty, if the trace width is layer dependent and all is selected in the combo box. Analog if inner is selected.

-
-

back

- + +

Manual Rules

+Window for the rules used in interactive routing when the route mode in the Route + Parameter window is set to manual. +

via rule

+
+ + In this combo box you can choose the via rule which you want to use currently in + interactive routing. +
+

trace clearance class:

+
+ Use this combo box for selecting the clearance class which you want to use + currently in interactive routing for traces. +
+

trace width:

+
+ Here you can edit the trace width you want to use currently in interactive routing. +
+

on layer:

+
+

Defines the layers, for which the trace width in the field above is valid. If all is selected in the combo + box, the value in the trace width field is valid on all layers. If inner is selected, it is valid on all + inner layers. Otherwise the value is valid only on the layer with the selected name in the combo box. The trace + width field remains empty, if the trace width is layer dependent and all is selected in the combo box. + Analog if inner is selected.

+
+

back

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowMoveParameter.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowMoveParameter.html index 0fedfa34..c59fd08f 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowMoveParameter.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowMoveParameter.html @@ -2,18 +2,22 @@ - - - - Plazierungs-Parameter - + + + + Plazierungs-Parameter + - -

Move Parameter

- The parameter in this window are used when moving components. -

Here you can define a horizontal and vertical component grid. The components will then snap while moving to coordinates, which are multiples of the chosen grid.

-

You can also change the function of the mouse wheel from zooming to rotating. You will need this functionality, if you want to rotate components by angles, which are not multiples of 90 degree.

-

back

- + +

Move Parameter

+The parameter in this window are used when moving components. +

Here you can define a horizontal and vertical component grid. The components will then snap while moving to + coordinates, which are multiples of the chosen grid.

+ +

You can also change the function of the mouse wheel from zooming to rotating. You will need this functionality, if + you want to rotate components by angles, which are not multiples of 90 degree.

+ +

back

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowNetClasses.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowNetClasses.html index b685169b..fea1d0eb 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowNetClasses.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowNetClasses.html @@ -2,83 +2,111 @@ - - - - Netzklassen - + + + + Netzklassen + - -

Net Classes

-

A net class consists of a rule set, which is used by default when routing nets of this class. These rules can be edited in the table in the Net Classes window. The following is a description of the columns of this table.

-

The net class table:

-
-

name

-
-

Contains the name of the net class, whose rules are described in the corresponding row.

-
-

via rule

-
-

In this combo box you can select the via rule you want to use when routing a net of this class.

-
-

clearance class

-
-

Combo box to select the clearance class for routing traces of nets of this class.

-
-

trace width

-
-

To define the trace width for new routed traces of nets of this class.

-

You can set the value to 0 to disallow traces of this net class in automatic and interactive routing on the layers defined in the following field.

-
-

on layer

-
-

In this combo box you can select the layers for which the value in the trace width field is valid. If all is selected, the value is valid on all layers. If you select inner, the value is valid on all inner layers. Otherwise the value in the trace width field is only valid on the layer with the selected name. If the trace width of this net class is layer dependent and all is selected in this combo box, in the trace width field appears the value -1, because it is not possible to output a value which is valid on all layers.

-
-

shove fixed

-
-

If this field is selected, traces of this net class cannot be shoved or pulled tight while routing.

-
-

cycles with areas

-
-

Normally closed cycles created while routing will be removed automatically. If this field is selected, that will only happen, if no conduction areas are involved. In that way you can for example connect items several times to a copper area without the redundant connections being removed automatically.

-
-

min. length

-
-

Here you can define a minimal value for the cumulative trace length of the nets from this class. In interactive routing than appears an ellipse. If the actual trace length is smaller than allowed, the cursor will be on the outside of this ellipse. This software however has no good support for routing nets with minimal lengths. We suggest to switch the route mode in the Route Parameter window to stitching and to set the value in the pull tight region to 0 .

-
-

max. length

-
-

Here you can define a maximal value for the cumulative trace length of the nets from this class. In interactive routing than appears an elliptic ring. If the cursor is outside this ring when connecting a trace, the actual trace length is smaller than allowed.

-
-
-

The buttons in the net class window:

-
-

Add

-
-

When you press the Add button, a new row with default values will be appended to the table. After changing the predefined name of the new class in the first column you can adjust the values in the other columns according to your needs.

-
-

Remove

-
-

After selecting a row in the table with the left button, you can delete the corresponding net class by pushing the Remove button. The deletion will be refused, if there are still nets assigned to this class.

-
-

Assign

-
-

After pushing this button a window with a table will appear, where you can assign to a each net in the first row a new class with the combo box in the second row.

-
-

Select

-
-

All items of all nets belonging to the selected net class will be highlighted on the board. The IDE then changes to the Selected Item State.

-
-

Show Nets

-
-

Displays a list with all nets contained in the selected classes.

-
-

Filter Incompletes

-
-

Only airlines of the open connections belonging to nets of the selected class will be displayed. This possibility is meant as an aid, if you want to route the nets of a certain class first.

-

-
-
- + +

Net Classes

+ +

A net class consists of a rule set, which is used by default when routing nets of this class. These rules can be + edited in the table in the Net Classes window. The following is a description of the columns of this table.

+

The net class table:

+
+

name

+
+

Contains the name of the net class, whose rules are described in the corresponding row.

+
+

via rule

+
+

In this combo box you can select the via rule you want to use when routing a net + of this class.

+
+

clearance class

+
+

Combo box to select the clearance class for routing traces of nets + of this class.

+
+

trace width

+
+

To define the trace width for new routed traces of nets of this class.

+ +

You can set the value to 0 to disallow traces of this net class in automatic and interactive routing on the + layers defined in the following field.

+
+

on layer

+
+

In this combo box you can select the layers for which the value in the trace width field is valid. If + all is selected, the value is valid on all layers. If you select inner, the value is valid on + all inner layers. Otherwise the value in the trace width field is only valid on the layer with the selected + name. If the trace width of this net class is layer dependent and all is selected in this combo box, + in the trace width field appears the value -1, because it is not possible to output a value which is valid + on all layers.

+
+

shove fixed

+
+

If this field is selected, traces of this net class cannot be shoved or pulled tight while routing.

+
+

cycles with areas

+
+

Normally closed cycles created while routing will be removed automatically. If this field is selected, that + will only happen, if no conduction areas are involved. In that way you can for example connect items several + times to a copper area without the redundant connections being removed automatically.

+
+

min. length

+
+

Here you can define a minimal value for the cumulative trace length of the nets from this class. In + interactive routing than appears an ellipse. If the actual trace length is smaller than allowed, the cursor + will be on the outside of this ellipse. This software however has no good support for routing nets with + minimal lengths. We suggest to switch the route mode in + the Route Parameter window to stitching and to set the value in the pull tight region to 0 .

+
+

max. length

+
+

Here you can define a maximal value for the cumulative trace length of the nets from this class. In + interactive routing than appears an elliptic ring. If the cursor is outside this ring when connecting a + trace, the actual trace length is smaller than allowed.

+
+
+

The buttons in the net class window:

+
+

Add

+
+

When you press the Add button, a new row with default values will be appended to the table. After + changing the predefined name of the new class in the first column you can adjust the values in the other + columns according to your needs.

+
+

Remove

+
+

After selecting a row in the table with the left button, you can delete the corresponding net class by + pushing the Remove button. The deletion will be refused, if there are still nets assigned to this + class.

+
+

Assign

+
+

After pushing this button a window with a table will appear, where you can assign to a each net in the first + row a new class with the combo box in the second row.

+
+

Select

+
+

All items of all nets belonging to the selected net class will be highlighted on the board. The IDE then + changes to the Selected Item State.

+
+

Show Nets

+
+

Displays a list with all nets contained in the selected classes.

+
+

Filter Incompletes

+
+

Only airlines of the open connections belonging to nets of the selected class will be displayed. This + possibility is meant as an aid, if you want to route the nets of a certain class first.

+ +

+
+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowObjectList.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowObjectList.html index 716a483d..249cd721 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowObjectList.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowObjectList.html @@ -2,83 +2,107 @@ - - - - Die Objektlisten - + + + + Die Objektlisten + - -

The Object Lists

- Here the windows with the object lists are documented, as they can be found in the Info menu of the menu bar. -

The objects in such a list can be selected with the left button. If you hold the Ctrl-key pressed you can select several objects at once. With pressed Shift-key you can choose all objects between the first and last selected object.

-

The buttons in an object list window:

-
-

Info

-
-

Opens a text window with information about the selected objects. By clicking a blue marked word you can get more information about the corresponding object.

-
-

Show

-
-

Displays rectangle on the board containing the selected objects. The selected objects get highlighted and the IDE changes to the Selected Item State.

-
-

Invert

-
-

Selected objects will be deselected and vice versa.

-
-

Recalculate

-
-

The object list will be recalculated.

-
-

Filter

-
-

Were you can input a pattern in order to filter the objects in the list. After pushing the Recalculate button only the objects matching this pattern will be displayed.

-
-
-

There are object lists for incomplete connections, length violations, clearance violations, library packages, library padstacks, board components and nets. The following contains a short description of these lists.

-

The individual object lists:

-
-

-

Library Packages

-
-

All packages in the library will be output. After pushing the Show button you will see all components on the board containing the selected packages.

-
-

Library Padstacks

-
-

Outputs all padstacks in the library. After pushing the Show button you will see all pins and vias on the board using the selected padstack.

-
-

Placed Components

-
-

Outputs all components placed on the board. After pushing the Show button you will see the selected components on the board.

-
-

Incompletes

-
-

All open connections will be displayed. The entries contain the net name followed by component and pin name of both end items of the incomplete. If there are only a few open connections left on the board, you can find them easily by pushing the Show button.

-
-

Length Violations

-
-

Outputs the routed connections, which are shorter than the minimal allowed length or longer than the maximal allowed length. If the minimum length is violated, at the end points of the connection appears a circle containing a "-". If the maximum length is violated, at the end points of the connection appears a circle containing a "+". The size of such a circle corresponds to the size of the length violation.

-
-

Clearance Violations

-
-

Outputs the item pairs where the the minimal allowed spacing is violated. By pushing the Show button you can find the selected violations easily on the board.

-
-

Unconnected Route

-
-

Outputs the sets of electrically connected traces and vias without contact to a terminal item. By pushing the Show button you can find the selected unconnected items on the board. Then you can remove them by pushing the Delete button in the board toolbar.

-
-

Route Stubs

-
-

Outputs unsufficiantly connected traces and vias. By pushing the Show button you can find the selected stubs on the board. After that you can remove the whole connections containing the stubs by pushing first the Connections button and then the Delete button in the board toolbar.

-
-

Nets

-
-

All nets of the design will be output. This window contains two more buttons. With the Assign Class button you can assign a new net class to the selected nets. After pushing the Filter Incompletes button only the airlines of open connections belonging to a selected net will be displayed.

-
-

-
-

-

- + +

The Object Lists

+Here the windows with the object lists are documented, as they can be found in the Info menu of the menu bar. +

The objects in such a list can be selected with the left button. If you hold the Ctrl-key pressed you can select + several objects at once. With pressed Shift-key you can choose all objects between the first and last selected + object.

+

The buttons in an object list window:

+
+

Info

+
+

Opens a text window with information about the selected objects. By clicking a blue marked word you can get + more information about the corresponding object.

+
+

Show

+
+

Displays rectangle on the board containing the selected objects. The selected objects get highlighted and the + IDE changes to the Selected Item State.

+
+

Invert

+
+

Selected objects will be deselected and vice versa.

+
+

Recalculate

+
+

The object list will be recalculated.

+
+

Filter

+
+

Were you can input a pattern in order to filter the objects in the list. After pushing the Recalculate + button only the objects matching this pattern will be displayed.

+
+
+

There are object lists for incomplete connections, length violations, clearance violations, library packages, library + padstacks, board components and nets. The following contains a short description of these lists.

+

The individual object lists:

+
+

+ +

Library Packages

+
+

All packages in the library will be output. After pushing the Show button you will see all components + on the board containing the selected packages.

+
+

Library Padstacks

+
+

Outputs all padstacks in the library. After pushing the Show button you will see all pins and vias on + the board using the selected padstack.

+
+

Placed Components

+
+

Outputs all components placed on the board. After pushing the Show button you will see the selected + components on the board.

+
+

Incompletes

+
+

All open connections will be displayed. The entries contain the net name followed by component and pin name + of both end items of the incomplete. If there are only a few open connections left on the board, you can + find them easily by pushing the Show button.

+
+

Length Violations

+
+

Outputs the routed connections, which are shorter than the minimal allowed length or longer than the maximal + allowed length. If the minimum length is violated, at the end points of the connection appears a circle + containing a "-". If the maximum length is violated, at the end points of the connection appears a + circle containing a "+". The size of such a circle corresponds to the size of the length + violation.

+
+

Clearance Violations

+
+

Outputs the item pairs where the the minimal allowed spacing is violated. By pushing the Show button + you can find the selected violations easily on the board.

+
+

Unconnected Route

+
+

Outputs the sets of electrically connected traces and vias without contact to a terminal item. By pushing the + Show button you can find the selected unconnected items on the board. Then you can remove them by + pushing the Delete button in the board toolbar.

+
+

Route Stubs

+
+

Outputs unsufficiantly connected traces and vias. By pushing the Show button you can find the selected + stubs on the board. After that you can remove the whole connections containing the stubs by pushing first + the Connections button and then the Delete button in the board toolbar.

+
+

Nets

+
+

All nets of the design will be output. This window contains two more buttons. With the Assign Class + button you can assign a new net class to the selected nets. After pushing the Filter Incompletes button + only the airlines of open connections belonging to a selected net will be displayed.

+
+

+
+

+ +

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowRouteParameter.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowRouteParameter.html index 9156e837..e23ffe61 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowRouteParameter.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowRouteParameter.html @@ -2,65 +2,82 @@ - - - - Route Parameter - + + + + Route Parameter + - -

Route Parameter

Description of the Route Parameter window.

snap angle:

-
90 degree:
-

Only orthogonal traces are created in interactive routing.

-
-

45 Grad:

-
-

The angles of the traces created in interactive routing are restricted to multiples of 45 degree.

-
-

none:

-
-

There are no angle restrictions in interactive routing.

-
-
-

route mode:

-
dynamic:
-

Trace will be inserted when the cursor position changes.

-
-

stitching:

-
-

Trace will be inserted after clicking the left button.

-
-
-

rule selection:

-
automatic:
-

The routing rules are defined by the net class of the current net.

-
-

manual:

-
-

The routing rules are defined in the Manual Rules window. The window opens automatically after selecting manual.

-
-
-

push and shove enabled

-
To define, if foreign traces can be pushed aside in interactive routing.
-

drag components enabled

-
Here you can define, if components can be dragged with the left button pressed. The already routed connections of the component will be adjusted automatically.
-

vias snap to the smd center

-
- Here you can define, if vias, for which attaching smd pins is allowed, should snap automatically to the pin center in this case.
-

highlight routing obstacle

-
If selected, the current routing obstacle will be highlighted.
-

ignore conduction areas

-
If selected, conduction areas of foreign nets will not be treated as obstacles. The host system can for example automatically create gaps for traces overlapping with such a conduction area.
-

automatic neckdown

-
When starting on pins or connecting to pins smaller than the current routing trace width, the trace width will be automatically reduced to the pin width, if connecting is not possible otherwise.
-

restrict pin exit directions

-
Here you can define, if connecting to rectangular pins is only allowed on the smaller sides.
-

pad to turn gap

-
To define the minimum distance from the pad border of a pin with exit restriction, where connecting traces are allowed to change direction.
-

pull tight region

-
- To restrict the region around the cursor, where traces are pulled tight while routing. If the value is 0, the pull tight algorithm is switched off, if the value is 999, the pull tight region is unrestricted. Setting the value to 0 makes only sense in the stitching route mode.
-

back

- + +

Route Parameter

Description of the Route Parameter window.

snap angle:

+
90 degree: +
+

Only orthogonal traces are created in interactive routing.

+
+

45 Grad:

+
+

The angles of the traces created in interactive routing are restricted to multiples of 45 degree.

+
+

none:

+
+

There are no angle restrictions in interactive routing.

+
+
+

route mode:

+
dynamic: +
+

Trace will be inserted when the cursor position changes.

+
+

stitching:

+
+

Trace will be inserted after clicking the left button.

+
+
+

rule selection:

+
automatic: +
+

The routing rules are defined by the net class of the current net.

+
+

manual:

+
+

The routing rules are defined in the Manual Rules window. The + window opens automatically after selecting manual.

+
+
+

push and shove enabled

+
To define, if foreign traces can be pushed aside in interactive routing.
+

drag components enabled

+
Here you can define, if components can be dragged with the left button pressed. The already routed + connections of the component will be adjusted automatically. +
+

vias snap to the smd center

+
+ Here you can define, if vias, for which attaching smd pins is allowed, should snap automatically to the pin center + in this case. +
+

highlight routing obstacle

+
If selected, the current routing obstacle will be highlighted.
+

ignore conduction areas

+
If selected, conduction areas of foreign nets will not be treated as obstacles. The host system can for + example automatically create gaps for traces overlapping with such a conduction area. +
+

automatic neckdown

+
When starting on pins or connecting to pins smaller than the current routing trace width, the trace width + will be automatically reduced to the pin width, if connecting is not possible otherwise. +
+

restrict pin exit directions

+
Here you can define, if connecting to rectangular pins is only allowed on the smaller sides.
+

pad to turn gap

+
To define the minimum distance from the pad border of a pin with exit restriction, where connecting traces + are allowed to change direction. +
+

pull tight region

+
+ To restrict the region around the cursor, where traces are pulled tight while routing. If the value is 0, the pull + tight algorithm is switched off, if the value is 999, the pull tight region is unrestricted. Setting the value to 0 + makes only sense in the stitching route mode. +
+

back

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowSelectParameter.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowSelectParameter.html index 3fe255b7..a386adcc 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowSelectParameter.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowSelectParameter.html @@ -2,36 +2,39 @@ - - - - Select-Einstellungen - + + + + Select-Einstellungen + - -

Select Parameter

- Description of the Select Parameter window. -

Selections Layers:

-
all visible: -
-

Items are selected on all layers with visibility factor > 0 (see also Layer Visibility). Objects on the current layer are preferred.

-
-

current only:

-
-

Items can be selected only on the current layer.

-
-
-

Selectable Items:

-
To define the selectable item types.
-

Current Layer:

-
- Here you can change the layer, which is used in interactive actions.
-
-

-
-

-
-
- + +

Select Parameter

+Description of the Select Parameter window. +

Selections Layers:

+
all visible: +
+

Items are selected on all layers with visibility factor > 0 (see also Layer Visibility). Objects on the current layer are + preferred.

+
+

current only:

+
+

Items can be selected only on the current layer.

+
+
+

Selectable Items:

+
To define the selectable item types.
+

Current Layer:

+
+ Here you can change the layer, which is used in interactive actions. +
+
+

+
+

+
+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowSnapshots.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowSnapshots.html index c853b091..6edefa3e 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowSnapshots.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowSnapshots.html @@ -2,103 +2,114 @@ - - - - Snapshots - + + + + Snapshots + - -

Snapshots

-

In the Snapshot window the current interactive situation of the IDE can be saved for restoring it later on.

-

Description of the buttons:

-
-

Goto Selected Snapshot

-
-

Restores the interactive situation, when the selected snapshot was saved. You can also double click a snapshot in the list instead.

-

To avoid frequent changing between the main window and the Snapshots window, you can use the j-key instead. With the h-key you can select the previous snapshot and with the k-key the next snapshot.

-
-

Create

-
-

Here you can store current interactive situation after changing the predefined name.

-
-

Remove Selected Snapshot

-
-

Removes the selected snapshot from the list.

-
-

Remove All Snapshots

-
-

Removes all snapshots from the list.

-
-

Snapshot Settings

-
-

Opens a window with the Snapshot Settings. There you can deselect attributes, which you do not want to be saved in a snapshot.

-
-
-

Description of the fields in the Snapshot Settings window:

-
- object colors -
-

The current color settings of the object types will be saved in the snapshots.

-
-

object visibility

-
-

The current color intensity of the single object types will be saved.

-
-

layer visibility

-
-

The current intensity for displaying objects on the individual layers is saved.

-
-

display region

-
-

The currently displayed region of the board will be saved.

-
-

interactive state

-
-

In the snapshots will be saved, if the IDE is currently in the Select- Route- or Drag-State.

-
-

selection layers

-
-

In the snapshots will be saved, if in the Select Parameter window selection layers is set to all visible or to current only.

-
-

selectable items

-
-

The settings for the Selectable Items in the Select Parameter window will be saved in the snapshots.

-
-

current layer

-
-

The Current Layer in the Select Parameter window will be saved.

-
-

rule selection

-
-

In the snapshots will be saved, if in the Route Parameter Window the rule selection is set to automatic or to manual.

-
-

manual rule settings

-
-

The settings in the Manual Rules window will be saved.

-
-

push&shove enabled

-
-

In the snapshots will be saved, if in the Route Parameter push&shove enabled is selected.

-
-

drag components enabled

-
-

In the snapshots will be saved, if in the Route Parameter drag components enabled is selected.

-
-

pull tight region

-
-

The value for the pull tight region in the Route Parameter window will be saved.

-
-

component grid

-
-

The value for the component grid in the Move Parameter window will be saved.

-
-

info list selections

-
-

The selected indices and the filter strings in the windows for Incompletes, Library Packages, Library Padstacks, Placed Components and Nets will be saved.

-

-
-
- + +

Snapshots

+ +

In the Snapshot window the current interactive situation of the IDE can be saved for restoring it later on.

+

Description of the buttons:

+
+

Goto Selected Snapshot

+
+

Restores the interactive situation, when the selected snapshot was saved. You can also double click a + snapshot in the list instead.

+ +

To avoid frequent changing between the main window and the Snapshots window, you can use the j-key + instead. With the h-key you can select the previous snapshot and with the k-key the next + snapshot.

+
+

Create

+
+

Here you can store current interactive situation after changing the predefined name.

+
+

Remove Selected Snapshot

+
+

Removes the selected snapshot from the list.

+
+

Remove All Snapshots

+
+

Removes all snapshots from the list.

+
+

Snapshot Settings

+
+

Opens a window with the Snapshot Settings. There you can deselect + attributes, which you do not want to be saved in a snapshot.

+
+
+

Description of the fields in the Snapshot Settings window:

+
+ object colors +
+

The current color settings of the object types will be saved in the snapshots.

+
+

object visibility

+
+

The current color intensity of the single object types will be saved.

+
+

layer visibility

+
+

The current intensity for displaying objects on the individual layers is saved.

+
+

display region

+
+

The currently displayed region of the board will be saved.

+
+

interactive state

+
+

In the snapshots will be saved, if the IDE is currently in the Select- Route- or Drag-State.

+
+

selection layers

+
+

In the snapshots will be saved, if in the Select Parameter window selection layers is set to all + visible or to current only.

+
+

selectable items

+
+

The settings for the Selectable Items in the Select Parameter window will be saved in the snapshots. +

+
+

current layer

+
+

The Current Layer in the Select Parameter window will be saved.

+
+

rule selection

+
+

In the snapshots will be saved, if in the Route Parameter Window the rule selection is set to automatic + or to manual.

+
+

manual rule settings

+
+

The settings in the Manual Rules window will be saved.

+
+

push&shove enabled

+
+

In the snapshots will be saved, if in the Route Parameter push&shove enabled is selected.

+
+

drag components enabled

+
+

In the snapshots will be saved, if in the Route Parameter drag components enabled is selected.

+
+

pull tight region

+
+

The value for the pull tight region in the Route Parameter window will be saved.

+
+

component grid

+
+

The value for the component grid in the Move Parameter window will be saved.

+
+

info list selections

+
+

The selected indices and the filter strings in the windows for Incompletes, Library Packages, Library + Padstacks, Placed Components and Nets will be saved.

+ +

+
+
+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/html_files/WindowVia.html b/src/main/java/net/freerouting/helpset/en/html_files/WindowVia.html index bff2922a..596133dc 100644 --- a/src/main/java/net/freerouting/helpset/en/html_files/WindowVia.html +++ b/src/main/java/net/freerouting/helpset/en/html_files/WindowVia.html @@ -2,74 +2,107 @@ - - - - Via-Regeln - + + + + Via-Regeln + - -

The Via Rules

-

A via rule consists of a ordered set of vias, which is used in the routing . If a layer is changed while routing and several vias would contain the previous and the next layer and would cause no clearance violations, vias earlier in the rule will be preferred to vias later on in the rule.

-

Vias

-

A via consists of a name, a via padstack, a clearance class and a switch, if attaching smd-pins of the same net is allowed or not.

-

Via Padstacks

-

A via padstack consists of a begin layer and an end layer and of a circle shape on each layer between the begin and the end layer.

-

The following is a description of the window with the via rules.

-

Available Via Padstacks

Here you see the three buttons Info, Create and Remove. -

After pushing the Info button a list with all available via padstacks will be displayed.

-

With the Create Button you can create a new via padstack. You you will be asked to provide the name of the new via padstack, the start and the end layer, and the default radius of the circle shape. In the following input window you can adjust this radius on each single layer, if you want the shapes of the new via padstack to be layer dependent

-

With the Remove button you can delete an existing via padstack in the database. The deletion will be refused, if the padstack is still used in a via definition or somewhere else.

-

Available Vias

Description of the buttons:
-

Info

-
-

Outputs a list of all vias available for routing.

-
-

Edit

-
-

If you push this button, a window with a table for editing the vias will appear. Here you can adjust the name, the padstack, the clearance class and the attach smd property of the via according to your needs. Below this window are two buttons for adding new vias or removing existing vias.

-
-
-

Via Rules

Below the Via Rules label is a window with a list of the names of all existing via rules. The following is a description of the four buttons at the lower border.
-

Info

-
-

After selecting a via rule with the left button, you can output the rule with Info to a new window. In routing the vias earlier in the list in this window are preferred to vias later on in the list

-
-

Create

-
-

If you push the Create button you will be asks for the name of the new via rule. After you have provided this name, a new empty via rule with the new name will be appended to the list above. Select the new rule with the left button and push the Edit to insert vias into the new rule.

-
-

Edit

-
-

After selecting a via rule with the left mouse button and pushing Edit, a new window appears where you can change the selected via rule. For a detailed description see Edit Via Rule below.

-
-

Remove

-
-

To delete the selected via rule.

-
-
-

Edit Via Rule

-
- After selecting a via rule for editing, a new window appears with a list of all vias contained in the selected rule. In routing the vias earlier in this list are preferred to vias later on in the list. The following is a description of the buttons in this new window. -

Append

-
-

A window with a combo box with all available vias not yet contained in the rule appears. After you have selected a via and pushed the OK button, the selected via will be appended to the end of the list..

-
-

Remove

-
-

After selecting a via with the left mouse button you can remove it from the via rule by pushing the Remove button.

-
-

Move Up

-
-

After selecting a via with the left mouse button you can exchange its position with the previous via in the list by pushing the Move Up button. That increases the priority of the selected via. In routing vias earlier in the list are preferred to vias later on in the list.

-
-

Move Down

-
-

After selecting a via with the left mouse button you can exchange its position with the next via in the list by pushing the Move Down button. That decreases the priority of the selected via. In routing vias earlier in the list are preferred to vias later on in the list.

-

-
-
-

- + +

The Via Rules

+ +

A via rule consists of a ordered set of vias, which is used in the routing . If a layer is changed + while routing and several vias would contain the previous and the next layer and would cause no clearance + violations, vias earlier in the rule will be preferred to vias later on in the rule.

+

Vias

+ +

A via consists of a name, a via padstack, a clearance class and a switch, if attaching smd-pins of the same net is + allowed or not.

+

Via Padstacks

+ +

A via padstack consists of a begin layer and an end layer and of a circle shape on each layer between the begin and + the end layer.

+ +

The following is a description of the window with the via rules.

+

Available Via Padstacks

Here you see the three buttons Info, Create and Remove. +

After pushing the Info button a list with all available via padstacks will be displayed.

+ +

With the Create Button you can create a new via padstack. You you will be asked to provide the name of the new + via padstack, the start and the end layer, and the default radius of the circle shape. In the following input window + you can adjust this radius on each single layer, if you want the shapes of the new via padstack to be layer + dependent

+ +

With the Remove button you can delete an existing via padstack in the database. The deletion will be refused, + if the padstack is still used in a via definition or somewhere else.

+

Available Vias

Description of the buttons: +
+

Info

+
+

Outputs a list of all vias available for routing.

+
+

Edit

+
+

If you push this button, a window with a table for editing the vias will appear. Here you can adjust the name, + the padstack, the clearance class and the attach smd property of the via according to + your needs. Below this window are two buttons for adding new vias or removing existing vias.

+
+
+

Via Rules

Below the Via Rules label is a window with a list of the names of all existing via rules. The +following is a description of the four buttons at the lower border. +
+

Info

+
+

After selecting a via rule with the left button, you can output the rule with Info to a new window. In + routing the vias earlier in the list in this window are preferred to vias later on in the list

+
+

Create

+
+

If you push the Create button you will be asks for the name of the new via rule. After you have + provided this name, a new empty via rule with the new name will be appended to the list above. Select the + new rule with the left button and push the Edit to insert vias into the new rule.

+
+

Edit

+
+

After selecting a via rule with the left mouse button and pushing Edit, a new window appears where you + can change the selected via rule. For a detailed description see Edit Via Rule below. +

+
+

Remove

+
+

To delete the selected via rule.

+
+
+

Edit Via Rule

+
+ After selecting a via rule for editing, a new window appears with a list of all vias contained in the selected rule. + In routing the vias earlier in this list are preferred to vias later on in the list. The following is a description + of the buttons in this new window. +

Append

+
+

A window with a combo box with all available vias not yet contained in the rule appears. After you have + selected a via and pushed the OK button, the selected via will be appended to the end of the list..

+
+

Remove

+
+

After selecting a via with the left mouse button you can remove it from the via rule by pushing the + Remove button.

+
+

Move Up

+
+

After selecting a via with the left mouse button you can exchange its position with the previous via in the + list by pushing the Move Up button. That increases the priority of the selected via. In routing vias + earlier in the list are preferred to vias later on in the list.

+
+

Move Down

+
+

After selecting a via with the left mouse button you can exchange its position with the next via in the list + by pushing the Move Down button. That decreases the priority of the selected via. In routing vias + earlier in the list are preferred to vias later on in the list.

+ +

+
+
+

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/helpset/en/index.html b/src/main/java/net/freerouting/helpset/en/index.html index cddcef0d..9ba71bf0 100644 --- a/src/main/java/net/freerouting/helpset/en/index.html +++ b/src/main/java/net/freerouting/helpset/en/index.html @@ -2,20 +2,32 @@ - - - - Bedienungsanleitung - + + + + Bedienungsanleitung + - -

Using the IDE Help System

-

The Contents Tab

- The Contents tab contains the three folders MenuBar, Interactive States and Windows. In the Menu Bar folder you find help about the entries in the Pull Down Menus. The folder Interactive States contains help for the possible states of the program in interactive action. In the folder Windows you can get help about the contents of the additional windows of the IDE.

Getting Help for IDE Windows and Interactive States

After selecting Help Context in the help menu a question mark appears on the right side of the cursor. In this state push the left button in the graphics area of the main window to open a help topic that is specific to the task you are currrently doing or in an additional window to get help about the contents of that specific window. In the offline version you can use the F1-key as a shortcut for Help Context.

Searching the Online Help

-

To perform a full-text search of all IDE help topics, click the Search tab and type a keyword in the Find text box.

-

Using the Index

- Click any entry in the Index tab to view the topic. To search the index, enter a term in the search field and press Enter. Press Enter multiple times to cycle through all occurrences of the term in the index. -

- + +

Using the IDE Help System

+ +

The Contents Tab

+The Contents tab contains the three folders MenuBar, Interactive States and Windows. In the Menu + Bar folder you find help about the entries in the Pull Down Menus. The folder Interactive States contains +help for the possible states of the program in interactive action. In the folder Windows you can get help about +the contents of the additional windows of the IDE.

Getting Help for IDE Windows and Interactive States

After +selecting Help Context in the help menu a question mark appears on the right side of the cursor. In this state push the +left button in the graphics area of the main window to open a help topic that is specific to the task you are currrently +doing or in an additional window to get help about the contents of that specific window. In the offline version you can +use the F1-key as a shortcut for Help Context.

Searching the Online Help

+ +

To perform a full-text search of all IDE help topics, click the Search tab and type a keyword in the Find text + box.

+ +

Using the Index

+Click any entry in the Index tab to view the topic. To search the index, enter a term in the search field and press +Enter. Press Enter multiple times to cycle through all occurrences of the term in the index. +

+ \ No newline at end of file diff --git a/src/main/java/net/freerouting/interactive/AutorouteSettings.java b/src/main/java/net/freerouting/interactive/AutorouteSettings.java index 20da8002..50bd2765 100644 --- a/src/main/java/net/freerouting/interactive/AutorouteSettings.java +++ b/src/main/java/net/freerouting/interactive/AutorouteSettings.java @@ -20,29 +20,43 @@ */ package net.freerouting.interactive; -import net.freerouting.board.RoutingBoard; import net.freerouting.autoroute.AutorouteControl.ExpansionCostFactor; +import net.freerouting.board.RoutingBoard; /** * Contains the interactive settings for the autorouter. * * @author Alfons Wirtz */ -public class AutorouteSettings implements java.io.Serializable -{ +public class AutorouteSettings implements java.io.Serializable { + + private final boolean[] layer_active_arr; + private final boolean[] preferred_direction_is_horizontal_arr; + private final double[] preferred_direction_trace_cost_arr; + private final double[] against_preferred_direction_trace_cost_arr; + private boolean with_fanout; + private boolean with_autoroute; + private boolean with_postroute; + private boolean vias_allowed; + private int via_costs; + private int plane_via_costs; + private int start_ripup_costs; + private int start_pass_no; - /** Creates a new instance of AutorouteSettings */ - public AutorouteSettings(int p_layer_count) - { + /** + * Creates a new instance of AutorouteSettings + */ + public AutorouteSettings(int p_layer_count) { layer_active_arr = new boolean[p_layer_count]; preferred_direction_is_horizontal_arr = new boolean[p_layer_count]; preferred_direction_trace_cost_arr = new double[p_layer_count]; against_preferred_direction_trace_cost_arr = new double[p_layer_count]; } - /** Creates a new instance of AutorouteSettings */ - public AutorouteSettings(RoutingBoard p_board) - { + /** + * Creates a new instance of AutorouteSettings + */ + public AutorouteSettings(RoutingBoard p_board) { this(p_board.get_layer_count()); // set default values @@ -69,28 +83,22 @@ public AutorouteSettings(RoutingBoard p_board) // make more horizontal pefered direction, if the board is horizontal. boolean curr_preferred_direction_is_horizontal = horizontal_width < vertical_width; - for (int i = 0; i < layer_count; ++i) - { + for (int i = 0; i < layer_count; ++i) { layer_active_arr[i] = p_board.layer_structure.arr[i].is_signal; - if (p_board.layer_structure.arr[i].is_signal) - { + if (p_board.layer_structure.arr[i].is_signal) { curr_preferred_direction_is_horizontal = !curr_preferred_direction_is_horizontal; } preferred_direction_is_horizontal_arr[i] = curr_preferred_direction_is_horizontal; preferred_direction_trace_cost_arr[i] = 1; against_preferred_direction_trace_cost_arr[i] = 1; - if (curr_preferred_direction_is_horizontal) - { + if (curr_preferred_direction_is_horizontal) { against_preferred_direction_trace_cost_arr[i] += horizontal_add_costs_against_preferred_dir; - } - else - { + } else { against_preferred_direction_trace_cost_arr[i] += vertical_add_costs_against_preferred_dir; } } int signal_layer_count = p_board.layer_structure.signal_layer_count(); - if (signal_layer_count > 2) - { + if (signal_layer_count > 2) { double outer_add_costs = 0.2 * signal_layer_count; // increase costs on the outer layers. preferred_direction_trace_cost_arr[0] += outer_add_costs; @@ -103,8 +111,7 @@ public AutorouteSettings(RoutingBoard p_board) /** * Copy constructor */ - public AutorouteSettings(AutorouteSettings p_settings) - { + public AutorouteSettings(AutorouteSettings p_settings) { start_ripup_costs = p_settings.start_ripup_costs; start_pass_no = p_settings.start_pass_no; via_costs = p_settings.via_costs; @@ -122,230 +129,172 @@ public AutorouteSettings(AutorouteSettings p_settings) against_preferred_direction_trace_cost_arr.length); } - public void set_start_ripup_costs(int p_value) - { + public int get_start_ripup_costs() { + return start_ripup_costs; + } + + public void set_start_ripup_costs(int p_value) { start_ripup_costs = Math.max(p_value, 1); } - public int get_start_ripup_costs() - { - return start_ripup_costs; + public int get_pass_no() { + return start_pass_no; } - public void set_pass_no(int p_value) - { + public void set_pass_no(int p_value) { start_pass_no = Math.max(p_value, 1); start_pass_no = Math.min(start_pass_no, 99); } - public int get_pass_no() - { - return start_pass_no; + public void increment_pass_no() { + ++start_pass_no; } - public void increment_pass_no() - { - ++start_pass_no; + public boolean get_with_fanout() { + return with_fanout; } - public void set_with_fanout(boolean p_value) - { + public void set_with_fanout(boolean p_value) { with_fanout = p_value; } - public boolean get_with_fanout() - { - return with_fanout; + public boolean get_with_autoroute() { + return with_autoroute; } - public void set_with_autoroute(boolean p_value) - { + public void set_with_autoroute(boolean p_value) { with_autoroute = p_value; } - public boolean get_with_autoroute() - { - return with_autoroute; + public boolean get_with_postroute() { + return with_postroute; } - public void set_with_postroute(boolean p_value) - { + public void set_with_postroute(boolean p_value) { with_postroute = p_value; } - public boolean get_with_postroute() - { - return with_postroute; + public boolean get_vias_allowed() { + return vias_allowed; } - public void set_vias_allowed(boolean p_value) - { + public void set_vias_allowed(boolean p_value) { vias_allowed = p_value; } - public boolean get_vias_allowed() - { - return vias_allowed; + public int get_via_costs() { + return via_costs; } - public void set_via_costs(int p_value) - { + public void set_via_costs(int p_value) { via_costs = Math.max(p_value, 1); } - public int get_via_costs() - { - return via_costs; + public int get_plane_via_costs() { + return plane_via_costs; } - public void set_plane_via_costs(int p_value) - { + public void set_plane_via_costs(int p_value) { plane_via_costs = Math.max(p_value, 1); } - public int get_plane_via_costs() - { - return plane_via_costs; - } - - public void set_layer_active(int p_layer, boolean p_value) - { - if (p_layer < 0 || p_layer >= layer_active_arr.length) - { + public void set_layer_active(int p_layer, boolean p_value) { + if (p_layer < 0 || p_layer >= layer_active_arr.length) { System.out.println("AutorouteSettings.set_layer_active: p_layer out of range"); return; } layer_active_arr[p_layer] = p_value; } - public boolean get_layer_active(int p_layer) - { - if (p_layer < 0 || p_layer >= layer_active_arr.length) - { + public boolean get_layer_active(int p_layer) { + if (p_layer < 0 || p_layer >= layer_active_arr.length) { System.out.println("AutorouteSettings.get_layer_active: p_layer out of range"); return false; } return layer_active_arr[p_layer]; } - public void set_preferred_direction_is_horizontal(int p_layer, boolean p_value) - { - if (p_layer < 0 || p_layer >= layer_active_arr.length) - { + public void set_preferred_direction_is_horizontal(int p_layer, boolean p_value) { + if (p_layer < 0 || p_layer >= layer_active_arr.length) { System.out.println("AutorouteSettings.set_preferred_direction_is_horizontal: p_layer out of range"); return; } preferred_direction_is_horizontal_arr[p_layer] = p_value; } - public boolean get_preferred_direction_is_horizontal(int p_layer) - { - if (p_layer < 0 || p_layer >= layer_active_arr.length) - { + public boolean get_preferred_direction_is_horizontal(int p_layer) { + if (p_layer < 0 || p_layer >= layer_active_arr.length) { System.out.println("AutorouteSettings.get_preferred_direction_is_horizontal: p_layer out of range"); return false; } return preferred_direction_is_horizontal_arr[p_layer]; } - public void set_preferred_direction_trace_costs(int p_layer, double p_value) - { - if (p_layer < 0 || p_layer >= layer_active_arr.length) - { + public void set_preferred_direction_trace_costs(int p_layer, double p_value) { + if (p_layer < 0 || p_layer >= layer_active_arr.length) { System.out.println("AutorouteSettings.set_preferred_direction_trace_costs: p_layer out of range"); return; } preferred_direction_trace_cost_arr[p_layer] = Math.max(p_value, 0.1); } - public double get_preferred_direction_trace_costs(int p_layer) - { - if (p_layer < 0 || p_layer >= layer_active_arr.length) - { + public double get_preferred_direction_trace_costs(int p_layer) { + if (p_layer < 0 || p_layer >= layer_active_arr.length) { System.out.println("AutorouteSettings.get_preferred_direction_trace_costs: p_layer out of range"); return 0; } return preferred_direction_trace_cost_arr[p_layer]; } - public double get_against_preferred_direction_trace_costs(int p_layer) - { - if (p_layer < 0 || p_layer >= layer_active_arr.length) - { + public double get_against_preferred_direction_trace_costs(int p_layer) { + if (p_layer < 0 || p_layer >= layer_active_arr.length) { System.out.println("AutorouteSettings.get_against_preferred_direction_trace_costs: p_layer out of range"); return 0; } return against_preferred_direction_trace_cost_arr[p_layer]; } - public double get_horizontal_trace_costs(int p_layer) - { - if (p_layer < 0 || p_layer >= layer_active_arr.length) - { + public double get_horizontal_trace_costs(int p_layer) { + if (p_layer < 0 || p_layer >= layer_active_arr.length) { System.out.println("AutorouteSettings.get_preferred_direction_trace_costs: p_layer out of range"); return 0; } double result; - if (preferred_direction_is_horizontal_arr[p_layer]) - { + if (preferred_direction_is_horizontal_arr[p_layer]) { result = preferred_direction_trace_cost_arr[p_layer]; - } - else - { + } else { result = against_preferred_direction_trace_cost_arr[p_layer]; } return result; } - public void set_against_preferred_direction_trace_costs(int p_layer, double p_value) - { - if (p_layer < 0 || p_layer >= layer_active_arr.length) - { + public void set_against_preferred_direction_trace_costs(int p_layer, double p_value) { + if (p_layer < 0 || p_layer >= layer_active_arr.length) { System.out.println("AutorouteSettings.set_against_preferred_direction_trace_costs: p_layer out of range"); return; } against_preferred_direction_trace_cost_arr[p_layer] = Math.max(p_value, 0.1); } - public double get_vertical_trace_costs(int p_layer) - { - if (p_layer < 0 || p_layer >= layer_active_arr.length) - { + public double get_vertical_trace_costs(int p_layer) { + if (p_layer < 0 || p_layer >= layer_active_arr.length) { System.out.println("AutorouteSettings.get_against_preferred_direction_trace_costs: p_layer out of range"); return 0; } double result; - if (preferred_direction_is_horizontal_arr[p_layer]) - { + if (preferred_direction_is_horizontal_arr[p_layer]) { result = against_preferred_direction_trace_cost_arr[p_layer]; - } - else - { + } else { result = preferred_direction_trace_cost_arr[p_layer]; } return result; } - public ExpansionCostFactor[] get_trace_cost_arr() - { + public ExpansionCostFactor[] get_trace_cost_arr() { ExpansionCostFactor[] result = new ExpansionCostFactor[preferred_direction_trace_cost_arr.length]; - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = new ExpansionCostFactor(get_horizontal_trace_costs(i), get_vertical_trace_costs(i)); } return result; } - - private boolean with_fanout; - private boolean with_autoroute; - private boolean with_postroute; - private boolean vias_allowed; - private int via_costs; - private int plane_via_costs; - private int start_ripup_costs; - private int start_pass_no; - private final boolean[] layer_active_arr; - private final boolean[] preferred_direction_is_horizontal_arr; - private final double[] preferred_direction_trace_cost_arr; - private final double[] against_preferred_direction_trace_cost_arr; } diff --git a/src/main/java/net/freerouting/interactive/BatchAutorouterThread.java b/src/main/java/net/freerouting/interactive/BatchAutorouterThread.java index 41cb8eae..1df61e4d 100644 --- a/src/main/java/net/freerouting/interactive/BatchAutorouterThread.java +++ b/src/main/java/net/freerouting/interactive/BatchAutorouterThread.java @@ -20,26 +20,27 @@ */ package net.freerouting.interactive; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.FloatLine; - -import net.freerouting.board.Unit; - import net.freerouting.autoroute.BatchAutorouter; import net.freerouting.autoroute.BatchFanout; import net.freerouting.autoroute.BatchOptRoute; +import net.freerouting.board.Unit; +import net.freerouting.geometry.planar.FloatLine; +import net.freerouting.geometry.planar.FloatPoint; /** * Thread for the batch autorouter. * * @author Alfons Wirtz */ -public class BatchAutorouterThread extends InteractiveActionThread -{ +public class BatchAutorouterThread extends InteractiveActionThread { - /** Creates a new instance of BatchAutorouterThread */ - protected BatchAutorouterThread(BoardHandling p_board_handling) - { + private final BatchAutorouter batch_autorouter; + private final BatchOptRoute batch_opt_route; + + /** + * Creates a new instance of BatchAutorouterThread + */ + protected BatchAutorouterThread(BoardHandling p_board_handling) { super(p_board_handling); AutorouteSettings autoroute_settings = p_board_handling.settings.autoroute_settings; this.batch_autorouter = new BatchAutorouter(this, !autoroute_settings.get_with_fanout(), true, autoroute_settings.get_start_ripup_costs()); @@ -47,60 +48,46 @@ protected BatchAutorouterThread(BoardHandling p_board_handling) } - protected void thread_action() - { - try - { + protected void thread_action() { + try { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", hdlg.get_locale()); boolean saved_board_read_only = hdlg.is_board_read_only(); hdlg.set_board_read_only(true); boolean ratsnest_hidden_before = hdlg.get_ratsnest().is_hidden(); - if (!ratsnest_hidden_before) - { + if (!ratsnest_hidden_before) { hdlg.get_ratsnest().hide(); } String start_message = resources.getString("batch_autorouter") + " " + resources.getString("stop_message"); hdlg.screen_messages.set_status_message(start_message); boolean fanout_first = hdlg.settings.autoroute_settings.get_with_fanout() && - hdlg.settings.autoroute_settings.get_pass_no() <= 1; - if (fanout_first) - { + hdlg.settings.autoroute_settings.get_pass_no() <= 1; + if (fanout_first) { BatchFanout.fanout_board(this); } - if (hdlg.settings.autoroute_settings.get_with_autoroute() && !this.is_stop_requested()) - { + if (hdlg.settings.autoroute_settings.get_with_autoroute() && !this.is_stop_requested()) { batch_autorouter.autoroute_passes(); } hdlg.get_routing_board().finish_autoroute(); - if (hdlg.settings.autoroute_settings.get_with_postroute() && !this.is_stop_requested()) - { + if (hdlg.settings.autoroute_settings.get_with_postroute() && !this.is_stop_requested()) { String opt_message = resources.getString("batch_optimizer") + " " + resources.getString("stop_message"); hdlg.screen_messages.set_status_message(opt_message); this.batch_opt_route.optimize_board(); String curr_message; - if (this.is_stop_requested()) - { + if (this.is_stop_requested()) { curr_message = resources.getString("interrupted"); - } - else - { + } else { curr_message = resources.getString("completed"); } String end_message = resources.getString("postroute") + " " + curr_message; hdlg.screen_messages.set_status_message(end_message); - } - else - { + } else { hdlg.screen_messages.clear(); String curr_message; - if (this.is_stop_requested()) - { + if (this.is_stop_requested()) { curr_message = resources.getString("interrupted"); - } - else - { + } else { curr_message = resources.getString("completed"); } Integer incomplete_count = hdlg.get_ratsnest().incomplete_count(); @@ -111,39 +98,33 @@ protected void thread_action() hdlg.set_board_read_only(saved_board_read_only); hdlg.update_ratsnest(); - if (!ratsnest_hidden_before) - { + if (!ratsnest_hidden_before) { hdlg.get_ratsnest().show(); } hdlg.get_panel().board_frame.refresh_windows(); - if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE && hdlg.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) - { + if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE && hdlg.get_routing_board().get_test_level() != net.freerouting.board.TestLevel.RELEASE_VERSION) { net.freerouting.tests.Validate.multiple_of_45_degree("after autoroute: ", hdlg.get_routing_board()); } - } catch (Exception e) - { + } catch (Exception e) { } } - public void draw(java.awt.Graphics p_graphics) - { + public void draw(java.awt.Graphics p_graphics) { FloatLine curr_air_line = batch_autorouter.get_air_line(); - if (curr_air_line != null) - { + if (curr_air_line != null) { FloatPoint[] draw_line = new FloatPoint[2]; draw_line[0] = curr_air_line.a; draw_line[1] = curr_air_line.b; // draw the incomplete java.awt.Color draw_color = this.hdlg.graphics_context.get_incomplete_color(); - double draw_width = Math.min (this.hdlg.get_routing_board().communication.get_resolution(Unit.MIL) * 3, 300); // problem with low resolution on Kicad300; + double draw_width = Math.min(this.hdlg.get_routing_board().communication.get_resolution(Unit.MIL) * 3, 300); // problem with low resolution on Kicad300; this.hdlg.graphics_context.draw(draw_line, draw_width, draw_color, p_graphics, 1); } FloatPoint current_opt_position = batch_opt_route.get_current_position(); int radius = 10 * this.hdlg.get_routing_board().rules.get_default_trace_half_width(0); - if (current_opt_position != null) - { + if (current_opt_position != null) { final int draw_width = 1; java.awt.Color draw_color = this.hdlg.graphics_context.get_incomplete_color(); FloatPoint[] draw_points = new FloatPoint[2]; @@ -156,6 +137,4 @@ public void draw(java.awt.Graphics p_graphics) this.hdlg.graphics_context.draw_circle(current_opt_position, radius, draw_width, draw_color, p_graphics, 1); } } - private final BatchAutorouter batch_autorouter; - private final BatchOptRoute batch_opt_route; } diff --git a/src/main/java/net/freerouting/interactive/BoardHandling.java b/src/main/java/net/freerouting/interactive/BoardHandling.java index 2a6cdd48..f256a5f1 100644 --- a/src/main/java/net/freerouting/interactive/BoardHandling.java +++ b/src/main/java/net/freerouting/interactive/BoardHandling.java @@ -20,52 +20,97 @@ */ package net.freerouting.interactive; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.geom.Point2D; - -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Collection; -import java.util.Set; - +import net.freerouting.board.*; +import net.freerouting.boardgraphics.GraphicsContext; +import net.freerouting.designformats.specctra.DsnFile; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntBox; import net.freerouting.geometry.planar.IntPoint; import net.freerouting.geometry.planar.PolylineShape; - import net.freerouting.rules.BoardRules; -import net.freerouting.board.LayerStructure; -import net.freerouting.board.RoutingBoard; -import net.freerouting.board.Item; -import net.freerouting.board.PolylineTrace; -import net.freerouting.board.FixedState; -import net.freerouting.board.ItemSelectionFilter; - -import net.freerouting.boardgraphics.GraphicsContext; -import net.freerouting.board.CoordinateTransform; -import net.freerouting.board.Unit; -import net.freerouting.board.TestLevel; -import net.freerouting.designformats.specctra.DsnFile; +import java.awt.*; +import java.awt.geom.Point2D; +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Collection; +import java.util.Set; /** - * * Central connection class between the graphical user interface and * the board database. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class BoardHandling -{ +public class BoardHandling { + + /** + * The text message fields displayed on the screen + */ + public final ScreenMessages screen_messages; + /** + * The file used for logging interactive action, + * so that they can be replayed later + */ + public final Logfile logfile; + /** + * The graphical panel used for displaying the board. + */ + private final net.freerouting.gui.BoardPanel panel; + private final java.util.ResourceBundle resources; + private final java.util.Locale locale; + /** + * The graphical context for drawing the board. + */ + public GraphicsContext graphics_context = null; + /** + * For ransforming coordinates between the user and the board coordinate space + */ + public CoordinateTransform coordinate_transform = null; + /** + * The current settings for interactive actions on the board + */ + public Settings settings = null; + /** + * The currently active interactive state. + */ + InteractiveState interactive_state = null; + /** + * To repaint the board immediately for example when reading a logfile. + */ + boolean paint_immediately = false; + /** + * Used for running an interactive action in a seperate thread. + */ + private InteractiveActionThread interactive_action_thread = null; + /** + * To display all incomplete connections on the screen. + */ + private RatsNest ratsnest = null; + /** + * To display all clearance violations between items on the screen. + */ + private ClearanceViolations clearance_violations = null; + /** + * The board database used in this interactive handling. + */ + private RoutingBoard board = null; + /** + * True if currently a logfile is being processed. + * Used to prevent interactive changes of the board database + * in this case. + */ + private boolean board_is_read_only = false; + /** + * The current position of the mouse pointer. + */ + private FloatPoint current_mouse_position = null; /** * Creates a new BoardHandling */ - public BoardHandling(net.freerouting.gui.BoardPanel p_panel, java.util.Locale p_locale) - { + public BoardHandling(net.freerouting.gui.BoardPanel p_panel, java.util.Locale p_locale) { this.locale = p_locale; this.panel = p_panel; this.screen_messages = p_panel.screen_messages; @@ -75,38 +120,33 @@ public BoardHandling(net.freerouting.gui.BoardPanel p_panel, java.util.Locale p_ } /** - * Sets the board to read only for example when running a seperate action thread - * to avoid unsynchronized change of the board. + * Return true, if the board is set to read only. */ - public void set_board_read_only(boolean p_value) - { - this.board_is_read_only = p_value; - this.settings.set_read_only(p_value); + public boolean is_board_read_only() { + return this.board_is_read_only; } /** - * Return true, if the board is set to read only. + * Sets the board to read only for example when running a seperate action thread + * to avoid unsynchronized change of the board. */ - public boolean is_board_read_only() - { - return this.board_is_read_only; + public void set_board_read_only(boolean p_value) { + this.board_is_read_only = p_value; + this.settings.set_read_only(p_value); } /** * Return the current language for the GUI messages. */ - public java.util.Locale get_locale() - { + public java.util.Locale get_locale() { return this.locale; } /** * returns the number of layers of the board design. */ - public int get_layer_count() - { - if (board == null) - { + public int get_layer_count() { + if (board == null) { return 0; } return board.get_layer_count(); @@ -115,16 +155,14 @@ public int get_layer_count() /** * Gets the routing board of this board handling. */ - public RoutingBoard get_routing_board() - { + public RoutingBoard get_routing_board() { return this.board; } /** * Returns the current position of the mouse pointer. */ - public FloatPoint get_current_mouse_position() - { + public FloatPoint get_current_mouse_position() { return this.current_mouse_position; } @@ -132,18 +170,15 @@ public FloatPoint get_current_mouse_position() * Sets the current mouse position to the input point. * Used while reading a logfile. */ - void set_current_mouse_position(FloatPoint p_point) - { + void set_current_mouse_position(FloatPoint p_point) { this.current_mouse_position = p_point; } /** * * Tells the router, if conduction areas should be ignored.. */ - public void set_ignore_conduction(boolean p_value) - { - if (board_is_read_only) - { + public void set_ignore_conduction(boolean p_value) { + if (board_is_read_only) { return; } board.change_conduction_is_obstacle(!p_value); @@ -151,28 +186,20 @@ public void set_ignore_conduction(boolean p_value) logfile.start_scope(LogfileScope.SET_IGNORE_CONDUCTION, p_value); } - public void set_pin_edge_to_turn_dist(double p_value) - { - if (board_is_read_only) - { + public void set_pin_edge_to_turn_dist(double p_value) { + if (board_is_read_only) { return; } double edge_to_turn_dist = this.coordinate_transform.user_to_board(p_value); - if (edge_to_turn_dist != board.rules.get_pin_edge_to_turn_dist()) - { + if (edge_to_turn_dist != board.rules.get_pin_edge_to_turn_dist()) { // unfix the pin exit stubs Collection pin_list = board.get_pins(); - for (net.freerouting.board.Pin curr_pin : pin_list) - { - if (curr_pin.has_trace_exit_restrictions()) - { + for (net.freerouting.board.Pin curr_pin : pin_list) { + if (curr_pin.has_trace_exit_restrictions()) { Collection contact_list = curr_pin.get_normal_contacts(); - for (Item curr_contact : contact_list) - { - if ((curr_contact instanceof PolylineTrace) && curr_contact.get_fixed_state() == FixedState.SHOVE_FIXED) - { - if (((PolylineTrace) curr_contact).corner_count() == 2) - { + for (Item curr_contact : contact_list) { + if ((curr_contact instanceof PolylineTrace) && curr_contact.get_fixed_state() == FixedState.SHOVE_FIXED) { + if (((PolylineTrace) curr_contact).corner_count() == 2) { curr_contact.set_fixed_state(FixedState.UNFIXED); } } @@ -187,20 +214,15 @@ public void set_pin_edge_to_turn_dist(double p_value) * Changes the visibility of the input layer to the input value. * p_value is expected between 0 and 1 */ - public void set_layer_visibility(int p_layer, double p_value) - { - if (p_layer >= 0 && p_layer < graphics_context.layer_count()) - { + public void set_layer_visibility(int p_layer, double p_value) { + if (p_layer >= 0 && p_layer < graphics_context.layer_count()) { graphics_context.set_layer_visibility(p_layer, p_value); - if (p_value == 0 && settings.layer == p_layer) - { + if (p_value == 0 && settings.layer == p_layer) { // change the current layer to the best visible layer, if it becomes invisible; double best_visibility = 0; int best_visible_layer = 0; - for (int i = 0; i < graphics_context.layer_count(); ++i) - { - if (graphics_context.get_layer_visibility(i) > best_visibility) - { + for (int i = 0; i < graphics_context.layer_count(); ++i) { + if (graphics_context.get_layer_visibility(i) > best_visibility) { best_visibility = graphics_context.get_layer_visibility(i); best_visible_layer = i; } @@ -213,67 +235,56 @@ public void set_layer_visibility(int p_layer, double p_value) /** * Gets the trace half width used in interactive routing for the input net on the input layer. */ - public int get_trace_halfwidth(int p_net_no, int p_layer) - { + public int get_trace_halfwidth(int p_net_no, int p_layer) { int result; - if (settings.manual_rule_selection) - { + if (settings.manual_rule_selection) { result = settings.manual_trace_half_width_arr[p_layer]; - } - else - { + } else { result = board.rules.get_trace_half_width(p_net_no, p_layer); } return result; } /** - * Returns if p_layer is active for interactive routing of traces. + * Returns if p_layer is active for interactive routing of traces. */ - public boolean is_active_routing_layer(int p_net_no, int p_layer) - { - if (settings.manual_rule_selection) - { + public boolean is_active_routing_layer(int p_net_no, int p_layer) { + if (settings.manual_rule_selection) { return true; } net.freerouting.rules.Net curr_net = this.board.rules.nets.get(p_net_no); - if (curr_net == null) - { + if (curr_net == null) { return true; } net.freerouting.rules.NetClass curr_net_class = curr_net.get_class(); - if (curr_net_class == null) - { + if (curr_net_class == null) { return true; } return curr_net_class.is_active_routing_layer(p_layer); } - /** Gets the trace clearance class used in interactive routing. */ - public int get_trace_clearance_class(int p_net_no) - { + /** + * Gets the trace clearance class used in interactive routing. + */ + public int get_trace_clearance_class(int p_net_no) { int result; - if (settings.manual_rule_selection) - { + if (settings.manual_rule_selection) { result = settings.manual_trace_clearance_class; - } - else - { + } else { result = board.rules.nets.get(p_net_no).get_class().get_trace_clearance_class(); } return result; } - /** Gets the via rule used in interactive routing. */ - public net.freerouting.rules.ViaRule get_via_rule(int p_net_no) - { + /** + * Gets the via rule used in interactive routing. + */ + public net.freerouting.rules.ViaRule get_via_rule(int p_net_no) { net.freerouting.rules.ViaRule result = null; - if (settings.manual_rule_selection) - { + if (settings.manual_rule_selection) { result = board.rules.via_rules.get(this.settings.manual_via_rule_index); } - if (result == null) - { + if (result == null) { result = board.rules.nets.get(p_net_no).get_class().get_via_rule(); } return result; @@ -282,14 +293,11 @@ public net.freerouting.rules.ViaRule get_via_rule(int p_net_no) /** * Changes the default trace halfwidth currently used in interactive routing on the input layer. */ - public void set_default_trace_halfwidth(int p_layer, int p_value) - { - if (board_is_read_only) - { + public void set_default_trace_halfwidth(int p_layer, int p_value) { + if (board_is_read_only) { return; } - if (p_layer >= 0 && p_layer <= board.get_layer_count()) - { + if (p_layer >= 0 && p_layer <= board.get_layer_count()) { board.rules.set_default_trace_half_width(p_layer, p_value); logfile.start_scope(LogfileScope.SET_TRACE_HALF_WIDTH, p_layer); logfile.add_int(p_value); @@ -299,10 +307,8 @@ public void set_default_trace_halfwidth(int p_layer, int p_value) /** * Switches clearance compansation on or off. */ - public void set_clearance_compensation(boolean p_value) - { - if (board_is_read_only) - { + public void set_clearance_compensation(boolean p_value) { + if (board_is_read_only) { return; } board.search_tree_manager.set_clearance_compensation_used(p_value); @@ -312,10 +318,8 @@ public void set_clearance_compensation(boolean p_value) /** * Changes the current snap angle in the interactive board handling. */ - public void set_current_snap_angle(net.freerouting.board.AngleRestriction p_snap_angle) - { - if (board_is_read_only) - { + public void set_current_snap_angle(net.freerouting.board.AngleRestriction p_snap_angle) { + if (board_is_read_only) { return; } board.rules.set_trace_angle_restriction(p_snap_angle); @@ -325,10 +329,8 @@ public void set_current_snap_angle(net.freerouting.board.AngleRestriction p_snap /** * Changes the current layer in the interactive board handling. */ - public void set_current_layer(int p_layer) - { - if (board_is_read_only) - { + public void set_current_layer(int p_layer) { + if (board_is_read_only) { return; } int layer = Math.max(p_layer, 0); @@ -341,22 +343,19 @@ public void set_current_layer(int p_layer) * Changes the current layer without saving the change to logfile. * Only for internal use inside this package. */ - void set_layer(int p_layer_no) - { + void set_layer(int p_layer_no) { net.freerouting.board.Layer curr_layer = board.layer_structure.arr[p_layer_no]; screen_messages.set_layer(curr_layer.name); settings.layer = p_layer_no; // Change the selected layer in the select parameter window. int signal_layer_no = board.layer_structure.get_signal_layer_no(curr_layer); - if (!this.board_is_read_only) - { + if (!this.board_is_read_only) { this.panel.set_selected_signal_layer(signal_layer_no); } // make the layer visible, if it is invisible - if (graphics_context.get_layer_visibility(p_layer_no) == 0) - { + if (graphics_context.get_layer_visibility(p_layer_no) == 0) { graphics_context.set_layer_visibility(p_layer_no, 1); panel.board_frame.refresh_windows(); } @@ -365,11 +364,10 @@ void set_layer(int p_layer_no) } /** - * Displays the current layer in the layer message field, - * and clears the field for the additional message. + * Displays the current layer in the layer message field, + * and clears the field for the additional message. */ - public void display_layer_messsage() - { + public void display_layer_messsage() { screen_messages.clear_add_field(); net.freerouting.board.Layer curr_layer = board.layer_structure.arr[this.settings.layer]; screen_messages.set_layer(curr_layer.name); @@ -378,10 +376,8 @@ public void display_layer_messsage() /** * Initializes the manual trace widths from the default trace widths in the board rules. */ - public void initialize_manual_trace_half_widths() - { - for (int i = 0; i < settings.manual_trace_half_width_arr.length; ++i) - { + public void initialize_manual_trace_half_widths() { + for (int i = 0; i < settings.manual_trace_half_width_arr.length; ++i) { settings.manual_trace_half_width_arr[i] = this.board.rules.get_default_net_class().get_trace_half_width(i); } } @@ -390,24 +386,16 @@ public void initialize_manual_trace_half_widths() * Sets the manual trace half width used in interactive routing. * If p_layer_no < 0, the manual trace half width is changed on all layers. */ - public void set_manual_trace_half_width(int p_layer_no, int p_value) - { - if (p_layer_no == net.freerouting.gui.ComboBoxLayer.ALL_LAYER_INDEX) - { - for (int i = 0; i < settings.manual_trace_half_width_arr.length; ++i) - { + public void set_manual_trace_half_width(int p_layer_no, int p_value) { + if (p_layer_no == net.freerouting.gui.ComboBoxLayer.ALL_LAYER_INDEX) { + for (int i = 0; i < settings.manual_trace_half_width_arr.length; ++i) { this.settings.set_manual_trace_half_width(i, p_value); } - } - else if (p_layer_no == net.freerouting.gui.ComboBoxLayer.INNER_LAYER_INDEX) - { - for (int i = 1; i < settings.manual_trace_half_width_arr.length - 1; ++i) - { + } else if (p_layer_no == net.freerouting.gui.ComboBoxLayer.INNER_LAYER_INDEX) { + for (int i = 1; i < settings.manual_trace_half_width_arr.length - 1; ++i) { this.settings.set_manual_trace_half_width(i, p_value); } - } - else - { + } else { this.settings.set_manual_trace_half_width(p_layer_no, p_value); } } @@ -415,11 +403,9 @@ else if (p_layer_no == net.freerouting.gui.ComboBoxLayer.INNER_LAYER_INDEX) /** * Changes the interactive selectability of p_item_type. */ - public void set_selectable(ItemSelectionFilter.SelectableChoices p_item_type, boolean p_value) - { + public void set_selectable(ItemSelectionFilter.SelectableChoices p_item_type, boolean p_value) { settings.set_selectable(p_item_type, p_value); - if (!p_value && this.interactive_state instanceof SelectedItemState) - { + if (!p_value && this.interactive_state instanceof SelectedItemState) { set_interactive_state(((SelectedItemState) interactive_state).filter()); } } @@ -428,30 +414,22 @@ public void set_selectable(ItemSelectionFilter.SelectableChoices p_item_type, bo * Displays all incomplete connections, if they are not visible, * or hides them, if they are visible. */ - public void toggle_ratsnest() - { - if (ratsnest == null || ratsnest.is_hidden()) - { + public void toggle_ratsnest() { + if (ratsnest == null || ratsnest.is_hidden()) { create_ratsnest(); - } - else - { + } else { ratsnest = null; } repaint(); } - public void toggle_clearance_violations() - { - if (clearance_violations == null) - { + public void toggle_clearance_violations() { + if (clearance_violations == null) { clearance_violations = new ClearanceViolations(this.board.get_items()); Integer violation_count = new Integer((clearance_violations.list.size() + 1) / 2); String curr_message = violation_count.toString() + " " + resources.getString("clearance_violations_found"); screen_messages.set_status_message(curr_message); - } - else - { + } else { clearance_violations = null; screen_messages.set_status_message(""); } @@ -461,18 +439,14 @@ public void toggle_clearance_violations() /** * Displays all incomplete connections. */ - public void create_ratsnest() - { + public void create_ratsnest() { ratsnest = new RatsNest(this.board, this.locale); Integer incomplete_count = ratsnest.incomplete_count(); Integer length_violation_count = ratsnest.length_violation_count(); String curr_message; - if (length_violation_count == 0) - { + if (length_violation_count == 0) { curr_message = incomplete_count.toString() + " " + resources.getString("incomplete_connections_to_route"); - } - else - { + } else { curr_message = incomplete_count.toString() + " " + resources.getString("incompletes") + " " + length_violation_count.toString() + " " + resources.getString("length_violations"); } screen_messages.set_status_message(curr_message); @@ -481,10 +455,8 @@ public void create_ratsnest() /** * Recalculates the incomplete connections for the input net. */ - void update_ratsnest(int p_net_no) - { - if (ratsnest != null && p_net_no > 0) - { + void update_ratsnest(int p_net_no) { + if (ratsnest != null && p_net_no > 0) { ratsnest.recalculate(p_net_no, this.board); ratsnest.show(); } @@ -493,10 +465,8 @@ void update_ratsnest(int p_net_no) /** * Recalculates the incomplete connections for the input net for the items in p_item_list. */ - void update_ratsnest(int p_net_no, Collection p_item_list) - { - if (ratsnest != null && p_net_no > 0) - { + void update_ratsnest(int p_net_no, Collection p_item_list) { + if (ratsnest != null && p_net_no > 0) { ratsnest.recalculate(p_net_no, p_item_list, this.board); ratsnest.show(); } @@ -505,32 +475,26 @@ void update_ratsnest(int p_net_no, Collection p_item_list) /** * Recalculates the incomplete connections, if the ratsnest is active. */ - void update_ratsnest() - { - if (ratsnest != null) - { + void update_ratsnest() { + if (ratsnest != null) { ratsnest = new RatsNest(this.board, this.locale); } } /** - * Hides the incomplete connections on the screen. + * Hides the incomplete connections on the screen. */ - public void hide_ratsnest() - { - if (ratsnest != null) - { + public void hide_ratsnest() { + if (ratsnest != null) { ratsnest.hide(); } } /** - * Shows the incomplete connections on the screen, if the ratsnest is active. + * Shows the incomplete connections on the screen, if the ratsnest is active. */ - public void show_ratsnest() - { - if (ratsnest != null) - { + public void show_ratsnest() { + if (ratsnest != null) { ratsnest.show(); } } @@ -538,31 +502,24 @@ public void show_ratsnest() /** * Removes the incomplete connections. */ - public void remove_ratsnest() - { + public void remove_ratsnest() { ratsnest = null; } /** * Returns the ratsnest with the information about the incomplete connections. */ - public RatsNest get_ratsnest() - { - if (ratsnest == null) - { + public RatsNest get_ratsnest() { + if (ratsnest == null) { ratsnest = new RatsNest(this.board, this.locale); } return this.ratsnest; } - public void recalculate_length_violations() - { - if (this.ratsnest != null) - { - if (this.ratsnest.recalculate_length_violations()) - { - if (!this.ratsnest.is_hidden()) - { + public void recalculate_length_violations() { + if (this.ratsnest != null) { + if (this.ratsnest.recalculate_length_violations()) { + if (!this.ratsnest.is_hidden()) { this.repaint(); } } @@ -572,10 +529,8 @@ public void recalculate_length_violations() /** * Sets the visibility filter for the incompletes of the input net. */ - public void set_incompletes_filter(int p_net_no, boolean p_value) - { - if (ratsnest != null) - { + public void set_incompletes_filter(int p_net_no, boolean p_value) { + if (ratsnest != null) { ratsnest.set_filter(p_net_no, p_value); } } @@ -585,30 +540,24 @@ public void set_incompletes_filter(int p_net_no, boolean p_value) */ public void create_board(IntBox p_bounding_box, LayerStructure p_layer_structure, PolylineShape[] p_outline_shapes, String p_outline_clearance_class_name, - BoardRules p_rules, net.freerouting.board.Communication p_board_communication, TestLevel p_test_level) - { - if (this.board != null) - { + BoardRules p_rules, net.freerouting.board.Communication p_board_communication, TestLevel p_test_level) { + if (this.board != null) { System.out.println(" BoardHandling.create_board: board already created"); } int outline_cl_class_no = 0; - if (p_rules != null) - { - if (p_outline_clearance_class_name != null && p_rules.clearance_matrix != null) - { + if (p_rules != null) { + if (p_outline_clearance_class_name != null && p_rules.clearance_matrix != null) { outline_cl_class_no = p_rules.clearance_matrix.get_no(p_outline_clearance_class_name); outline_cl_class_no = Math.max(outline_cl_class_no, 0); - } - else - { + } else { outline_cl_class_no = p_rules.get_default_net_class().default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.AREA); } } this.board = new RoutingBoard(p_bounding_box, p_layer_structure, p_outline_shapes, outline_cl_class_no, - p_rules, p_board_communication, p_test_level); + p_rules, p_board_communication, p_test_level); // create the interactive settings with default double unit_factor = p_board_communication.coordinate_transform.board_to_dsn(1); @@ -623,32 +572,28 @@ public void create_board(IntBox p_bounding_box, LayerStructure p_layer_structure /** * Changes the factor of the user unit. */ - public void change_user_unit_factor(double p_new_factor) - { + public void change_user_unit_factor(double p_new_factor) { CoordinateTransform old_transform = this.coordinate_transform; this.coordinate_transform = new CoordinateTransform(p_new_factor, old_transform.user_unit, - old_transform.board_unit_factor, old_transform.board_unit); + old_transform.board_unit_factor, old_transform.board_unit); } /** * Changes the user unit. */ - public void change_user_unit(Unit p_unit) - { + public void change_user_unit(Unit p_unit) { CoordinateTransform old_transform = this.coordinate_transform; this.coordinate_transform = new CoordinateTransform(old_transform.user_unit_factor, p_unit, - old_transform.board_unit_factor, old_transform.board_unit); + old_transform.board_unit_factor, old_transform.board_unit); } /** * From here on the interactive actions are written to a logfile. */ - public void start_logfile(File p_filename) - { - if (board_is_read_only) - { + public void start_logfile(File p_filename) { + if (board_is_read_only) { return; } logfile.start_write(p_filename); @@ -657,15 +602,11 @@ public void start_logfile(File p_filename) /** * Repaints the board panel on the screen. */ - public void repaint() - { - if (this.paint_immediately) - { + public void repaint() { + if (this.paint_immediately) { final Rectangle MAX_RECTAMGLE = new Rectangle(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE); panel.paintImmediately(MAX_RECTAMGLE); - } - else - { + } else { panel.repaint(); } } @@ -673,14 +614,10 @@ public void repaint() /** * Repaints a rectangle of board panel on the screen. */ - public void repaint(Rectangle p_rect) - { - if (this.paint_immediately) - { + public void repaint(Rectangle p_rect) { + if (this.paint_immediately) { panel.paintImmediately(p_rect); - } - else - { + } else { panel.repaint(p_rect); } } @@ -688,8 +625,7 @@ public void repaint(Rectangle p_rect) /** * Gets the panel for graphical display of the board. */ - net.freerouting.gui.BoardPanel get_panel() - { + net.freerouting.gui.BoardPanel get_panel() { return this.panel; } @@ -697,15 +633,11 @@ net.freerouting.gui.BoardPanel get_panel() * Gets the popup menu used in the current interactive state. * Returns null, if the current state uses no popup menu. */ - public javax.swing.JPopupMenu get_current_popup_menu() - { + public javax.swing.JPopupMenu get_current_popup_menu() { javax.swing.JPopupMenu result; - if (interactive_state != null) - { + if (interactive_state != null) { result = interactive_state.get_popup_menu(); - } - else - { + } else { result = null; } return result; @@ -715,36 +647,28 @@ public javax.swing.JPopupMenu get_current_popup_menu() * Draws the board and all temporary construction graphics in the * current interactive state. */ - public void draw(Graphics p_graphics) - { - if (board == null) - { + public void draw(Graphics p_graphics) { + if (board == null) { return; } board.draw(p_graphics, graphics_context); - if (ratsnest != null) - { + if (ratsnest != null) { ratsnest.draw(p_graphics, graphics_context); } - if (clearance_violations != null) - { + if (clearance_violations != null) { clearance_violations.draw(p_graphics, graphics_context); } - if (interactive_state != null) - { + if (interactive_state != null) { interactive_state.draw(p_graphics); } - if (interactive_action_thread != null) - { + if (interactive_action_thread != null) { interactive_action_thread.draw(p_graphics); } } - public void generate_snapshot() - { - if (board_is_read_only) - { + public void generate_snapshot() { + if (board_is_read_only) { return; } board.generate_snapshot(); @@ -754,29 +678,22 @@ public void generate_snapshot() /** * Restores the situation before the previous snapshot. */ - public void undo() - { - if (board_is_read_only || !(interactive_state instanceof MenuState)) - { + public void undo() { + if (board_is_read_only || !(interactive_state instanceof MenuState)) { return; } java.util.Set changed_nets = new java.util.TreeSet(); - if (board.undo(changed_nets)) - { - for (Integer changed_net : changed_nets) - { + if (board.undo(changed_nets)) { + for (Integer changed_net : changed_nets) { this.update_ratsnest(changed_net); } - if (changed_nets.size() > 0) - { + if (changed_nets.size() > 0) { // reset the start pass number in the autorouter in case // a batch autorouter is undone. this.settings.autoroute_settings.set_pass_no(1); } screen_messages.set_status_message(resources.getString("undo")); - } - else - { + } else { screen_messages.set_status_message(resources.getString("no_more_undo_possible")); } logfile.start_scope(LogfileScope.UNDO); @@ -786,23 +703,17 @@ public void undo() /** * Restores the sitiation before the last undo. */ - public void redo() - { - if (board_is_read_only || !(interactive_state instanceof MenuState)) - { + public void redo() { + if (board_is_read_only || !(interactive_state instanceof MenuState)) { return; } java.util.Set changed_nets = new java.util.TreeSet(); - if (board.redo(changed_nets)) - { - for (Integer changed_net : changed_nets) - { + if (board.redo(changed_nets)) { + for (Integer changed_net : changed_nets) { this.update_ratsnest(changed_net); } screen_messages.set_status_message(resources.getString("redo")); - } - else - { + } else { screen_messages.set_status_message(resources.getString("no_more_redo_possible")); } logfile.start_scope(LogfileScope.REDO); @@ -813,25 +724,20 @@ public void redo() * Actions to be taken in the current interactive state * when the left mouse butten is clicked. */ - public void left_button_clicked(Point2D p_point) - { - if (board_is_read_only) - { - if (this.interactive_action_thread != null) - { + public void left_button_clicked(Point2D p_point) { + if (board_is_read_only) { + if (this.interactive_action_thread != null) { // The left button is used to stop the interactive action thread. this.interactive_action_thread.request_stop(); } return; } - if (interactive_state != null && graphics_context != null) - { + if (interactive_state != null && graphics_context != null) { FloatPoint location = graphics_context.coordinate_transform.screen_to_board(p_point); InteractiveState return_state = interactive_state.left_button_clicked(location); - if (return_state != interactive_state && return_state != null) - { + if (return_state != interactive_state && return_state != null) { set_interactive_state(return_state); repaint(); } @@ -842,15 +748,12 @@ public void left_button_clicked(Point2D p_point) * Actions to be taken in the current interactive state * when the mouse pointer has moved. */ - public void mouse_moved(Point2D p_point) - { - if (board_is_read_only) - { + public void mouse_moved(Point2D p_point) { + if (board_is_read_only) { // no interactive action when logfile is running return; } - if (interactive_state != null && graphics_context != null) - { + if (interactive_state != null && graphics_context != null) { this.current_mouse_position = graphics_context.coordinate_transform.screen_to_board(p_point); InteractiveState return_state = interactive_state.mouse_moved(); @@ -858,8 +761,7 @@ public void mouse_moved(Point2D p_point) // performance in interactive route. // If a repaint is necessary, it should be done in the individual mouse_moved // method of the class derived from InteractiveState - if (return_state != this.interactive_state) - { + if (return_state != this.interactive_state) { set_interactive_state(return_state); repaint(); } @@ -869,10 +771,8 @@ public void mouse_moved(Point2D p_point) /** * Actions to be taken when the mouse button is pressed. */ - public void mouse_pressed(Point2D p_point) - { - if (interactive_state != null && graphics_context != null) - { + public void mouse_pressed(Point2D p_point) { + if (interactive_state != null && graphics_context != null) { this.current_mouse_position = graphics_context.coordinate_transform.screen_to_board(p_point); set_interactive_state(interactive_state.mouse_pressed(this.current_mouse_position)); @@ -883,16 +783,13 @@ public void mouse_pressed(Point2D p_point) * Actions to be taken in the current interactive state * when the mouse is dragged. */ - public void mouse_dragged(Point2D p_point) - { - if (interactive_state != null && graphics_context != null) - { + public void mouse_dragged(Point2D p_point) { + if (interactive_state != null && graphics_context != null) { this.current_mouse_position = graphics_context.coordinate_transform.screen_to_board(p_point); InteractiveState return_state = interactive_state.mouse_dragged(this.current_mouse_position); - if (return_state != interactive_state) - { + if (return_state != interactive_state) { set_interactive_state(return_state); repaint(); } @@ -903,13 +800,10 @@ public void mouse_dragged(Point2D p_point) * Actions to be taken in the current interactive state * when a mouse button is released. */ - public void button_released() - { - if (interactive_state != null) - { + public void button_released() { + if (interactive_state != null) { InteractiveState return_state = interactive_state.button_released(); - if (return_state != interactive_state) - { + if (return_state != interactive_state) { set_interactive_state(return_state); repaint(); } @@ -920,13 +814,10 @@ public void button_released() * Actions to be taken in the current interactive state * when the mouse wheel is moved */ - public void mouse_wheel_moved(int p_rotation) - { - if (interactive_state != null) - { + public void mouse_wheel_moved(int p_rotation) { + if (interactive_state != null) { InteractiveState return_state = interactive_state.mouse_wheel_moved(p_rotation); - if (return_state != interactive_state) - { + if (return_state != interactive_state) { set_interactive_state(return_state); repaint(); } @@ -937,16 +828,13 @@ public void mouse_wheel_moved(int p_rotation) * Action to be taken in the current interactive state * when a key on the keyboard is typed. */ - public void key_typed_action(char p_key_char) - { - if (board_is_read_only) - { + public void key_typed_action(char p_key_char) { + if (board_is_read_only) { // no interactive action when logfile is running return; } InteractiveState return_state = interactive_state.key_typed(p_key_char); - if (return_state != null && return_state != interactive_state) - { + if (return_state != null && return_state != interactive_state) { set_interactive_state(return_state); panel.board_frame.hilight_selected_button(); repaint(); @@ -958,18 +846,15 @@ public void key_typed_action(char p_key_char) * Completes the curreent interactive state and returns to * its return state. */ - public void return_from_state() - { - if (board_is_read_only) - { + public void return_from_state() { + if (board_is_read_only) { // no interactive action when logfile is running return; } InteractiveState new_state = interactive_state.complete(); { - if (new_state != interactive_state) - { + if (new_state != interactive_state) { set_interactive_state(new_state); repaint(); } @@ -979,18 +864,15 @@ public void return_from_state() /** * Cancels the current interactive state. */ - public void cancel_state() - { - if (board_is_read_only) - { + public void cancel_state() { + if (board_is_read_only) { // no interactive action when logfile is running return; } InteractiveState new_state = interactive_state.cancel(); { - if (new_state != interactive_state) - { + if (new_state != interactive_state) { set_interactive_state(new_state); repaint(); } @@ -1002,11 +884,9 @@ public void cancel_state() * the current board layer is changed. * Returns false, if the layer change failed. */ - public boolean change_layer_action(int p_new_layer) - { + public boolean change_layer_action(int p_new_layer) { boolean result = true; - if (interactive_state != null && !board_is_read_only) - { + if (interactive_state != null && !board_is_read_only) { result = interactive_state.change_layer_action(p_new_layer); } return result; @@ -1015,8 +895,7 @@ public boolean change_layer_action(int p_new_layer) /** * Sets the interactive state to SelectMenuState */ - public void set_select_menu_state() - { + public void set_select_menu_state() { this.interactive_state = SelectMenuState.get_instance(this, logfile); screen_messages.set_status_message(resources.getString("select_menu")); } @@ -1024,8 +903,7 @@ public void set_select_menu_state() /** * Sets the interactive state to RouteMenuState */ - public void set_route_menu_state() - { + public void set_route_menu_state() { this.interactive_state = RouteMenuState.get_instance(this, logfile); screen_messages.set_status_message(resources.getString("route_menu")); } @@ -1033,8 +911,7 @@ public void set_route_menu_state() /** * Sets the interactive state to DragMenuState */ - public void set_drag_menu_state() - { + public void set_drag_menu_state() { this.interactive_state = DragMenuState.get_instance(this, logfile); screen_messages.set_status_message(resources.getString("drag_menu")); } @@ -1043,18 +920,14 @@ public void set_drag_menu_state() * Reads an existing board design from the input stream. * Returns false, if the input stream does not contains a legal board design. */ - public boolean read_design(java.io.ObjectInputStream p_design, TestLevel p_test_level) - { - try - { + public boolean read_design(java.io.ObjectInputStream p_design, TestLevel p_test_level) { + try { board = (RoutingBoard) p_design.readObject(); settings = (Settings) p_design.readObject(); settings.set_logfile(this.logfile); coordinate_transform = (CoordinateTransform) p_design.readObject(); graphics_context = (GraphicsContext) p_design.readObject(); - } - catch (Exception e) - { + } catch (Exception e) { return false; } board.set_test_level(p_test_level); @@ -1070,42 +943,31 @@ public boolean read_design(java.io.ObjectInputStream p_design, TestLevel p_test_ */ public DsnFile.ReadResult import_design(java.io.InputStream p_design, net.freerouting.board.BoardObservers p_observers, - net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, TestLevel p_test_level) - { - if (p_design == null) - { + net.freerouting.datastructures.IdNoGenerator p_item_id_no_generator, TestLevel p_test_level) { + if (p_design == null) { return DsnFile.ReadResult.ERROR; } DsnFile.ReadResult read_result; - try - { + try { read_result = DsnFile.read(p_design, this, p_observers, - p_item_id_no_generator, p_test_level); - } - catch (Exception e) - { + p_item_id_no_generator, p_test_level); + } catch (Exception e) { read_result = DsnFile.ReadResult.ERROR; } - if (read_result == DsnFile.ReadResult.OK) - { + if (read_result == DsnFile.ReadResult.OK) { this.board.reduce_nets_of_route_items(); this.set_layer(0); - for (int i = 0; i < board.get_layer_count(); ++i) - { - if (!settings.autoroute_settings.get_layer_active(i)) - { + for (int i = 0; i < board.get_layer_count(); ++i) { + if (!settings.autoroute_settings.get_layer_active(i)) { graphics_context.set_layer_visibility(i, 0); } } } - try - { + try { p_design.close(); - } - catch (java.io.IOException e) - { + } catch (java.io.IOException e) { read_result = DsnFile.ReadResult.ERROR; } return read_result; @@ -1116,10 +978,8 @@ public DsnFile.ReadResult import_design(java.io.InputStream p_design, * If p_compat_mode is true, only standard speecctra dsn scopes are written, so that any * host system with an specctra interface can read them. */ - public boolean export_to_dsn_file(OutputStream p_output_stream, String p_design_name, boolean p_compat_mode) - { - if (board_is_read_only || p_output_stream == null) - { + public boolean export_to_dsn_file(OutputStream p_output_stream, String p_design_name, boolean p_compat_mode) { + if (board_is_read_only || p_output_stream == null) { return false; } return net.freerouting.designformats.specctra.DsnFile.write(this, p_output_stream, p_design_name, p_compat_mode); @@ -1128,10 +988,8 @@ public boolean export_to_dsn_file(OutputStream p_output_stream, String p_design_ /** * Writes a session file ins the Eaglea scr format. */ - public boolean export_eagle_session_file(java.io.InputStream p_input_stream, OutputStream p_output_stream) - { - if (board_is_read_only) - { + public boolean export_eagle_session_file(java.io.InputStream p_input_stream, OutputStream p_output_stream) { + if (board_is_read_only) { return false; } return net.freerouting.designformats.specctra.SessionToEagle.get_instance(p_input_stream, p_output_stream, this.board); @@ -1140,10 +998,8 @@ public boolean export_eagle_session_file(java.io.InputStream p_input_stream, Out /** * Writes a session file ins the Specctra ses-format. */ - public boolean export_specctra_session_file(String p_design_name, OutputStream p_output_stream) - { - if (board_is_read_only) - { + public boolean export_specctra_session_file(String p_design_name, OutputStream p_output_stream) { + if (board_is_read_only) { return false; } return net.freerouting.designformats.specctra.SessionFile.write(this.get_routing_board(), p_output_stream, p_design_name); @@ -1152,18 +1008,14 @@ public boolean export_specctra_session_file(String p_design_name, OutputStream p /** * Saves the currently edited board design to p_design_file. */ - public boolean save_design_file(java.io.ObjectOutputStream p_object_stream) - { + public boolean save_design_file(java.io.ObjectOutputStream p_object_stream) { boolean result = true; - try - { + try { p_object_stream.writeObject(board); p_object_stream.writeObject(settings); p_object_stream.writeObject(coordinate_transform); p_object_stream.writeObject(graphics_context); - } - catch (Exception e) - { + } catch (Exception e) { screen_messages.set_status_message(resources.getString("save_error")); result = false; } @@ -1173,10 +1025,8 @@ public boolean save_design_file(java.io.ObjectOutputStream p_object_stream) /** * Processes the actions stored in the input logfile. */ - public void read_logfile(InputStream p_input_stream) - { - if (board_is_read_only || !(interactive_state instanceof MenuState)) - { + public void read_logfile(InputStream p_input_stream) { + if (board_is_read_only || !(interactive_state instanceof MenuState)) { return; } this.interactive_action_thread = InteractiveActionThread.get_read_logfile_instance(this, p_input_stream); @@ -1186,10 +1036,8 @@ public void read_logfile(InputStream p_input_stream) /** * Closes all currently used files so that the file buffers are written to disk. */ - public void close_files() - { - if (logfile != null) - { + public void close_files() { + if (logfile != null) { logfile.close_output(); } } @@ -1197,10 +1045,8 @@ public void close_files() /** * Starts interactive routing at the input location. */ - public void start_route(Point2D p_point) - { - if (board_is_read_only) - { + public void start_route(Point2D p_point) { + if (board_is_read_only) { // no interactive action when logfile is running return; } @@ -1213,10 +1059,8 @@ public void start_route(Point2D p_point) /** * Selects board items at the input location. */ - public void select_items(Point2D p_point) - { - if (board_is_read_only || !(this.interactive_state instanceof MenuState)) - { + public void select_items(Point2D p_point) { + if (board_is_read_only || !(this.interactive_state instanceof MenuState)) { return; } FloatPoint location = @@ -1229,10 +1073,8 @@ public void select_items(Point2D p_point) /** * Selects all items in an interactive defined rectangle. */ - public void select_items_in_region() - { - if (board_is_read_only || !(this.interactive_state instanceof MenuState)) - { + public void select_items_in_region() { + if (board_is_read_only || !(this.interactive_state instanceof MenuState)) { return; } set_interactive_state(SelectItemsInRegionState.get_instance(this.interactive_state, this, logfile)); @@ -1241,20 +1083,15 @@ public void select_items_in_region() /** * Selects all items in the input collection. */ - public void select_items(Set p_items) - { - if (board_is_read_only) - { + public void select_items(Set p_items) { + if (board_is_read_only) { // no interactive action when logfile is running return; } this.display_layer_messsage(); - if (interactive_state instanceof MenuState) - { + if (interactive_state instanceof MenuState) { set_interactive_state(SelectedItemState.get_instance(p_items, interactive_state, this, logfile)); - } - else if (interactive_state instanceof SelectedItemState) - { + } else if (interactive_state instanceof SelectedItemState) { ((SelectedItemState) interactive_state).get_item_list().addAll(p_items); repaint(); } @@ -1264,10 +1101,8 @@ else if (interactive_state instanceof SelectedItemState) * Looks for a swappable pin at p_location. * Prepares for pin swap if a swappable pin was found. */ - public void swap_pin(Point2D p_location) - { - if (board_is_read_only || !(this.interactive_state instanceof MenuState)) - { + public void swap_pin(Point2D p_location) { + if (board_is_read_only || !(this.interactive_state instanceof MenuState)) { return; } FloatPoint location = graphics_context.coordinate_transform.screen_to_board(p_location); @@ -1278,10 +1113,8 @@ public void swap_pin(Point2D p_location) /** * Displays a window containing all selected items. */ - public void zoom_selection() - { - if (!(interactive_state instanceof SelectedItemState)) - { + public void zoom_selection() { + if (!(interactive_state instanceof SelectedItemState)) { return; } IntBox bounding_box = this.board.get_bounding_box(((SelectedItemState) interactive_state).get_item_list()); @@ -1297,18 +1130,15 @@ public void zoom_selection() * otherwise adds it to the list. * Changes to the selected items state, if something was selected. */ - public void toggle_select_action(Point2D p_point) - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void toggle_select_action(Point2D p_point) { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } FloatPoint location = graphics_context.coordinate_transform.screen_to_board(p_point); InteractiveState return_state = ((SelectedItemState) interactive_state).toggle_select(location); - if (return_state != this.interactive_state) - { + if (return_state != this.interactive_state) { set_interactive_state(return_state); repaint(); } @@ -1317,10 +1147,8 @@ public void toggle_select_action(Point2D p_point) /** * Fixes the selected items. */ - public void fix_selected_items() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void fix_selected_items() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } ((SelectedItemState) interactive_state).fix_items(); @@ -1329,10 +1157,8 @@ public void fix_selected_items() /** * Unfixes the selected items. */ - public void unfix_selected_items() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void unfix_selected_items() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } ((SelectedItemState) interactive_state).unfix_items(); @@ -1341,10 +1167,8 @@ public void unfix_selected_items() /** * Displays information about the selected item into a graphical text window. */ - public void display_selected_item_info() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void display_selected_item_info() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } ((SelectedItemState) interactive_state).info(); @@ -1354,10 +1178,8 @@ public void display_selected_item_info() * Makes all selected items connectable and assigns * them to a new net. */ - public void assign_selected_to_new_net() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void assign_selected_to_new_net() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } InteractiveState new_state = @@ -1368,10 +1190,8 @@ public void assign_selected_to_new_net() /** * Assigns all selected items to a new group ( new component for example) */ - public void assign_selected_to_new_group() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void assign_selected_to_new_group() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } InteractiveState new_state = ((SelectedItemState) interactive_state).assign_items_to_new_group(); @@ -1381,10 +1201,8 @@ public void assign_selected_to_new_group() /** * Deletes all unfixed selected items. */ - public void delete_selected_items() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void delete_selected_items() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } InteractiveState new_state = ((SelectedItemState) interactive_state).delete_items(); @@ -1394,10 +1212,8 @@ public void delete_selected_items() /** * Deletes all unfixed selected traces and vias inside a rectangle. */ - public void cutout_selected_items() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void cutout_selected_items() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } InteractiveState new_state = ((SelectedItemState) interactive_state).cutout_items(); @@ -1407,10 +1223,8 @@ public void cutout_selected_items() /** * Assigns the input clearance class to the selected items */ - public void assign_clearance_classs_to_selected_items(int p_cl_class_index) - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void assign_clearance_classs_to_selected_items(int p_cl_class_index) { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } InteractiveState new_state = ((SelectedItemState) interactive_state).assign_clearance_class(p_cl_class_index); @@ -1420,10 +1234,8 @@ public void assign_clearance_classs_to_selected_items(int p_cl_class_index) /** * Moves or rotates the selected items */ - public void move_selected_items(Point2D p_from_location) - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void move_selected_items(Point2D p_from_location) { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } SelectedItemState curr_state = (SelectedItemState) interactive_state; @@ -1438,10 +1250,8 @@ public void move_selected_items(Point2D p_from_location) /** * Copies all selected items. */ - public void copy_selected_items(Point2D p_from_location) - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void copy_selected_items(Point2D p_from_location) { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } SelectedItemState curr_state = (SelectedItemState) interactive_state; @@ -1456,10 +1266,8 @@ public void copy_selected_items(Point2D p_from_location) /** * Optimizes the selected items. */ - public void optimize_selected_items() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void optimize_selected_items() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } board.generate_snapshot(); @@ -1470,10 +1278,8 @@ public void optimize_selected_items() /** * Autoroute the selected items. */ - public void autoroute_selected_items() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void autoroute_selected_items() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } board.generate_snapshot(); @@ -1484,10 +1290,8 @@ public void autoroute_selected_items() /** * Fanouts the selected items. */ - public void fanout_selected_items() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void fanout_selected_items() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } board.generate_snapshot(); @@ -1498,10 +1302,8 @@ public void fanout_selected_items() /** * Start the batch autorouter on the whole Board */ - public void start_batch_autorouter() - { - if (board_is_read_only) - { + public void start_batch_autorouter() { + if (board_is_read_only) { return; } board.generate_snapshot(); @@ -1512,10 +1314,8 @@ public void start_batch_autorouter() /** * Selects also all items belonging to a net of a currently selecte item. */ - public void extend_selection_to_whole_nets() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void extend_selection_to_whole_nets() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } set_interactive_state(((SelectedItemState) interactive_state).extent_to_whole_nets()); @@ -1524,10 +1324,8 @@ public void extend_selection_to_whole_nets() /** * Selects also all items belonging to a component of a currently selecte item. */ - public void extend_selection_to_whole_components() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void extend_selection_to_whole_components() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } set_interactive_state(((SelectedItemState) interactive_state).extent_to_whole_components()); @@ -1536,10 +1334,8 @@ public void extend_selection_to_whole_components() /** * Selects also all items belonging to a connected set of a currently selecte item. */ - public void extend_selection_to_whole_connected_sets() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void extend_selection_to_whole_connected_sets() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } set_interactive_state(((SelectedItemState) interactive_state).extent_to_whole_connected_sets()); @@ -1548,10 +1344,8 @@ public void extend_selection_to_whole_connected_sets() /** * Selects also all items belonging to a connection of a currently selecte item. */ - public void extend_selection_to_whole_connections() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void extend_selection_to_whole_connections() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } set_interactive_state(((SelectedItemState) interactive_state).extent_to_whole_connections()); @@ -1560,29 +1354,23 @@ public void extend_selection_to_whole_connections() /** * Shows or hides the clearance violations of the selected items. */ - public void toggle_selected_item_violations() - { - if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) - { + public void toggle_selected_item_violations() { + if (board_is_read_only || !(interactive_state instanceof SelectedItemState)) { return; } ((SelectedItemState) interactive_state).toggle_clearance_violations(); } - public void turn_45_degree(int p_factor) - { - if (board_is_read_only || !(interactive_state instanceof MoveItemState)) - { + public void turn_45_degree(int p_factor) { + if (board_is_read_only || !(interactive_state instanceof MoveItemState)) { // no interactive action when logfile is running return; } ((MoveItemState) interactive_state).turn_45_degree(p_factor); } - public void change_placement_side() - { - if (board_is_read_only || !(interactive_state instanceof MoveItemState)) - { + public void change_placement_side() { + if (board_is_read_only || !(interactive_state instanceof MoveItemState)) { // no interactive action when logfile is running return; } @@ -1592,18 +1380,15 @@ public void change_placement_side() /** * Zooms display to an interactive defined rectangle. */ - public void zoom_region() - { + public void zoom_region() { interactive_state = ZoomRegionState.get_instance(this.interactive_state, this, this.logfile); } /** * Start interactively creating a circle obstacle. */ - public void start_circle(Point2D p_point) - { - if (board_is_read_only) - { + public void start_circle(Point2D p_point) { + if (board_is_read_only) { // no interactive action when logfile is running return; } @@ -1614,10 +1399,8 @@ public void start_circle(Point2D p_point) /** * Start interactively creating a tile shaped obstacle. */ - public void start_tile(Point2D p_point) - { - if (board_is_read_only) - { + public void start_tile(Point2D p_point) { + if (board_is_read_only) { // no interactive action when logfile is running return; } @@ -1628,10 +1411,8 @@ public void start_tile(Point2D p_point) /** * Start interactively creating a polygon shaped obstacle. */ - public void start_polygonshape_item(Point2D p_point) - { - if (board_is_read_only) - { + public void start_polygonshape_item(Point2D p_point) { + if (board_is_read_only) { // no interactive action when logfile is running return; } @@ -1644,10 +1425,8 @@ public void start_polygonshape_item(Point2D p_point) * Actions to be taken, when adding a hole to an existing obstacle shape * on the board is started. */ - public void start_adding_hole(Point2D p_point) - { - if (board_is_read_only) - { + public void start_adding_hole(Point2D p_point) { + if (board_is_read_only) { // no interactive action when logfile is running return; } @@ -1661,16 +1440,12 @@ public void start_adding_hole(Point2D p_point) * Gets a surrounding rectangle of the area, where an update of the * graphics is needed caused by the previous interactive actions. */ - Rectangle get_graphics_update_rectangle() - { + Rectangle get_graphics_update_rectangle() { Rectangle result; IntBox update_box = board.get_graphics_update_box(); - if (update_box == null || update_box.is_empty()) - { + if (update_box == null || update_box.is_empty()) { result = new Rectangle(0, 0, 0, 0); - } - else - { + } else { IntBox offset_box = update_box.offset(board.get_max_trace_half_width()); result = graphics_context.coordinate_transform.board_to_screen(offset_box); } @@ -1682,8 +1457,7 @@ Rectangle get_graphics_update_rectangle() * If nothing is found on the active layer and settings.select_on_all_layers * is true, all layers are selected. */ - java.util.Set pick_items(FloatPoint p_location) - { + java.util.Set pick_items(FloatPoint p_location) { return pick_items(p_location, settings.item_selection_filter); } @@ -1692,16 +1466,12 @@ java.util.Set pick_items(FloatPoint p_location) * If nothing is found on the active layer and settings.select_on_all_layers * is true, all layers are selected. */ - java.util.Set pick_items(FloatPoint p_location, ItemSelectionFilter p_item_filter) - { + java.util.Set pick_items(FloatPoint p_location, ItemSelectionFilter p_item_filter) { IntPoint location = p_location.round(); java.util.Set result = board.pick_items(location, settings.layer, p_item_filter); - if (result.size() == 0 && settings.select_on_all_visible_layers) - { - for (int i = 0; i < graphics_context.layer_count(); ++i) - { - if (i == settings.layer || graphics_context.get_layer_visibility(i) <= 0) - { + if (result.size() == 0 && settings.select_on_all_visible_layers) { + for (int i = 0; i < graphics_context.layer_count(); ++i) { + if (i == settings.layer || graphics_context.get_layer_visibility(i) <= 0) { continue; } result.addAll(board.pick_items(location, i, p_item_filter)); @@ -1713,10 +1483,8 @@ java.util.Set pick_items(FloatPoint p_location, ItemSelectionFilter p_item /** * Moves the mouse pointer to p_to_location. */ - void move_mouse(FloatPoint p_to_location) - { - if (!board_is_read_only) - { + void move_mouse(FloatPoint p_to_location) { + if (!board_is_read_only) { panel.move_mouse(graphics_context.coordinate_transform.board_to_screen(p_to_location)); } } @@ -1724,18 +1492,14 @@ void move_mouse(FloatPoint p_to_location) /** * Gets the current interactive state. */ - public InteractiveState get_interactive_state() - { + public InteractiveState get_interactive_state() { return this.interactive_state; } - public void set_interactive_state(InteractiveState p_state) - { - if (p_state != null && p_state != interactive_state) - { + public void set_interactive_state(InteractiveState p_state) { + if (p_state != null && p_state != interactive_state) { this.interactive_state = p_state; - if (!this.board_is_read_only) - { + if (!this.board_is_read_only) { p_state.set_toolbar(); this.panel.board_frame.set_context_sensitive_help(this.panel, p_state.get_help_id()); } @@ -1746,15 +1510,12 @@ public void set_interactive_state(InteractiveState p_state) * Adjust the design bounds, so that also all items being still placed outside the * board outline are contained in the new bounds. */ - public void adjust_design_bounds() - { + public void adjust_design_bounds() { IntBox new_bounding_box = this.board.get_bounding_box(); Collection board_items = this.board.get_items(); - for (Item curr_item : board_items) - { + for (Item curr_item : board_items) { IntBox curr_bounding_box = curr_item.bounding_box(); - if (curr_bounding_box.ur.x < Integer.MAX_VALUE) - { + if (curr_bounding_box.ur.x < Integer.MAX_VALUE) { new_bounding_box = new_bounding_box.union(curr_bounding_box); } } @@ -1765,8 +1526,7 @@ public void adjust_design_bounds() * Sets all references inside this class to null, so that it can be recycled * by the garbage collector. */ - public void dispose() - { + public void dispose() { close_files(); graphics_context = null; coordinate_transform = null; @@ -1776,45 +1536,4 @@ public void dispose() clearance_violations = null; board = null; } - /** The graphical context for drawing the board. */ - public GraphicsContext graphics_context = null; - /** For ransforming coordinates between the user and the board coordinate space */ - public CoordinateTransform coordinate_transform = null; - /** The text message fields displayed on the screen */ - public final ScreenMessages screen_messages; - /** The current settings for interactive actions on the board*/ - public Settings settings = null; - /** The currently active interactive state. */ - InteractiveState interactive_state = null; - /** - * Used for running an interactive action in a seperate thread. - */ - private InteractiveActionThread interactive_action_thread = null; - /** To display all incomplete connections on the screen. */ - private RatsNest ratsnest = null; - /** To display all clearance violations between items on the screen. */ - private ClearanceViolations clearance_violations = null; - /** The board database used in this interactive handling. */ - private RoutingBoard board = null; - /** The graphical panel used for displaying the board. */ - private final net.freerouting.gui.BoardPanel panel; - /** - * The file used for logging interactive action, - * so that they can be replayed later - */ - public final Logfile logfile; - /** - * True if currently a logfile is being processed. - * Used to prevent interactive changes of the board database - * in this case. - */ - private boolean board_is_read_only = false; - /** The current position of the mouse pointer. */ - private FloatPoint current_mouse_position = null; - /** - * To repaint the board immediately for example when reading a logfile. - */ - boolean paint_immediately = false; - private final java.util.ResourceBundle resources; - private final java.util.Locale locale; } diff --git a/src/main/java/net/freerouting/interactive/CircleConstructionState.java b/src/main/java/net/freerouting/interactive/CircleConstructionState.java index c0977d2d..26332818 100644 --- a/src/main/java/net/freerouting/interactive/CircleConstructionState.java +++ b/src/main/java/net/freerouting/interactive/CircleConstructionState.java @@ -20,155 +20,131 @@ package net.freerouting.interactive; +import net.freerouting.board.AngleRestriction; +import net.freerouting.board.FixedState; +import net.freerouting.board.RoutingBoard; import net.freerouting.geometry.planar.Circle; import net.freerouting.geometry.planar.ConvexShape; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntPoint; - import net.freerouting.rules.BoardRules; -import net.freerouting.board.AngleRestriction; -import net.freerouting.board.RoutingBoard; -import net.freerouting.board.FixedState; - /** * Interactive creation of a circle obstacle * * @author Alfons Wirtz */ -public class CircleConstructionState extends InteractiveState -{ +public class CircleConstructionState extends InteractiveState { + private final FloatPoint circle_center; + private double circle_radius = 0; + private boolean observers_activated = false; + + /** + * Creates a new instance of CircleConstructionState + */ + private CircleConstructionState(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + super(p_parent_state, p_board_handling, p_logfile); + circle_center = p_location; + if (this.logfile != null) { + logfile.start_scope(LogfileScope.CREATING_CIRCLE, p_location); + } + } + /** * Returns a new instance of this class. * If p_logfile != null; the creation of this item is stored in a logfile */ public static CircleConstructionState get_instance(FloatPoint p_location, - InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { + InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { p_board_handling.remove_ratsnest(); // inserting a circle may change the connectivity. return new CircleConstructionState(p_location, p_parent_state, p_board_handling, p_logfile); } - - /** Creates a new instance of CircleConstructionState */ - private CircleConstructionState(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_parent_state, p_board_handling, p_logfile); - circle_center = p_location; - if (this.logfile != null) - { - logfile.start_scope(LogfileScope.CREATING_CIRCLE, p_location); - } - } - - public InteractiveState left_button_clicked(FloatPoint p_location) - { - if (logfile != null) - { + + public InteractiveState left_button_clicked(FloatPoint p_location) { + if (logfile != null) { logfile.add_corner(p_location); } return this.complete(); } - - public InteractiveState mouse_moved() - { + + public InteractiveState mouse_moved() { super.mouse_moved(); hdlg.repaint(); return this; } - + /** * completes the circle construction state */ - public InteractiveState complete() - { + public InteractiveState complete() { IntPoint center = this.circle_center.round(); - int radius = (int)Math.round(this.circle_radius); + int radius = (int) Math.round(this.circle_radius); int layer = hdlg.settings.layer; int cl_class; RoutingBoard board = hdlg.get_routing_board(); cl_class = BoardRules.clearance_class_none(); boolean construction_succeeded = (this.circle_radius > 0); ConvexShape obstacle_shape = null; - if (construction_succeeded) - { - + if (construction_succeeded) { + obstacle_shape = new Circle(center, radius); - if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { obstacle_shape = obstacle_shape.bounding_box(); - } - else if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) { obstacle_shape = obstacle_shape.bounding_octagon(); } construction_succeeded = board.check_shape(obstacle_shape, layer, new int[0], cl_class); } - if (construction_succeeded) - { + if (construction_succeeded) { hdlg.screen_messages.set_status_message(resources.getString("keepout_successful_completed")); - + // insert the new shape as keepout this.observers_activated = !hdlg.get_routing_board().observers_active(); - if (this.observers_activated) - { + if (this.observers_activated) { hdlg.get_routing_board().start_notify_observers(); } board.generate_snapshot(); board.insert_obstacle(obstacle_shape, layer, cl_class, FixedState.UNFIXED); - if (this.observers_activated) - { + if (this.observers_activated) { hdlg.get_routing_board().end_notify_observers(); this.observers_activated = false; } - } - else - { + } else { hdlg.screen_messages.set_status_message(resources.getString("keepout_cancelled_because_of_overlaps")); } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.COMPLETE_SCOPE); } hdlg.repaint(); return this.return_state; } - + /** * Used when reading the next point from a logfile. * Calls complete, because only 1 additional point is stored in the logfile. */ - public InteractiveState process_logfile_point(FloatPoint p_point) - { + public InteractiveState process_logfile_point(FloatPoint p_point) { this.circle_radius = circle_center.distance(p_point); return this; } - + /** * draws the graphic construction aid for the circle */ - public void draw(java.awt.Graphics p_graphics) - { + public void draw(java.awt.Graphics p_graphics) { FloatPoint current_mouse_position = hdlg.get_current_mouse_position(); - if (current_mouse_position == null) - { + if (current_mouse_position == null) { return; } this.circle_radius = circle_center.distance(current_mouse_position); hdlg.graphics_context.draw_circle(circle_center, circle_radius, 300, java.awt.Color.white, p_graphics, 1); } - - public javax.swing.JPopupMenu get_popup_menu() - { + + public javax.swing.JPopupMenu get_popup_menu() { return hdlg.get_panel().popup_menu_insert_cancel; } - - public void display_default_message() - { + + public void display_default_message() { hdlg.screen_messages.set_status_message(resources.getString("creating_circle")); } - - private final FloatPoint circle_center; - private double circle_radius = 0; - - private boolean observers_activated = false; } diff --git a/src/main/java/net/freerouting/interactive/ClearanceViolations.java b/src/main/java/net/freerouting/interactive/ClearanceViolations.java index 3b87df32..c0452529 100644 --- a/src/main/java/net/freerouting/interactive/ClearanceViolations.java +++ b/src/main/java/net/freerouting/interactive/ClearanceViolations.java @@ -20,55 +20,50 @@ package net.freerouting.interactive; -import java.util.Collection; -import java.util.LinkedList; -import java.util.Iterator; - - -import java.awt.Graphics; - +import net.freerouting.board.ClearanceViolation; +import net.freerouting.board.Item; import net.freerouting.boardgraphics.GraphicsContext; -import net.freerouting.board.Item; -import net.freerouting.board.ClearanceViolation; +import java.awt.*; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; /** * To display the clearance violations between items on the screen. * - * @author alfons + * @author alfons */ -public class ClearanceViolations -{ - - /** Creates a new instance of ClearanceViolations */ - public ClearanceViolations(Collection p_item_list) - { +public class ClearanceViolations { + + /** + * The list of clearance violations. + */ + public final Collection list; + + /** + * Creates a new instance of ClearanceViolations + */ + public ClearanceViolations(Collection p_item_list) { this.list = new LinkedList(); Iterator it = p_item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); this.list.addAll(curr_item.clearance_violations()); } } - - public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) - { - java.awt.Color draw_color = p_graphics_context.get_violations_color(); - Iterator it = list.iterator(); - while (it.hasNext()) - { - ClearanceViolation curr_violation = it.next(); - double intensity = p_graphics_context.get_layer_visibility(curr_violation.layer); - p_graphics_context.fill_area(curr_violation.shape, p_graphics, draw_color, intensity); - // draw a circle around the violation. - double draw_radius = curr_violation.first_item.board.rules.get_min_trace_half_width() * 5; - p_graphics_context.draw_circle(curr_violation.shape.centre_of_gravity(), draw_radius, 0.1 * draw_radius, draw_color, - p_graphics, intensity); - } + + public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) { + java.awt.Color draw_color = p_graphics_context.get_violations_color(); + Iterator it = list.iterator(); + while (it.hasNext()) { + ClearanceViolation curr_violation = it.next(); + double intensity = p_graphics_context.get_layer_visibility(curr_violation.layer); + p_graphics_context.fill_area(curr_violation.shape, p_graphics, draw_color, intensity); + // draw a circle around the violation. + double draw_radius = curr_violation.first_item.board.rules.get_min_trace_half_width() * 5; + p_graphics_context.draw_circle(curr_violation.shape.centre_of_gravity(), draw_radius, 0.1 * draw_radius, draw_color, + p_graphics, intensity); + } } - - - /** The list of clearance violations. */ - public final Collection list; } diff --git a/src/main/java/net/freerouting/interactive/CopyItemState.java b/src/main/java/net/freerouting/interactive/CopyItemState.java index 4aec7832..7756d246 100644 --- a/src/main/java/net/freerouting/interactive/CopyItemState.java +++ b/src/main/java/net/freerouting/interactive/CopyItemState.java @@ -20,95 +20,110 @@ package net.freerouting.interactive; +import net.freerouting.board.*; +import net.freerouting.geometry.planar.ConvexShape; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.Point; import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.ConvexShape; - -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import java.util.TreeMap; - -import net.freerouting.library.Padstack; import net.freerouting.library.Package; +import net.freerouting.library.Padstack; -import net.freerouting.board.Item; -import net.freerouting.board.DrillItem; -import net.freerouting.board.ObstacleArea; -import net.freerouting.board.Via; -import net.freerouting.board.Component; -import net.freerouting.board.RoutingBoard; +import java.util.*; /** * Interactive copying of items. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class CopyItemState extends InteractiveState -{ +public class CopyItemState extends InteractiveState { + private Collection item_list; + private Point start_position; + private Point current_position; + private int current_layer; + private boolean layer_changed; + private Point previous_position; + /** - * Returns a new instance of CopyItemState or null, if p_item_list is empty. + * Creates a new instance of CopyItemState */ - public static CopyItemState get_instance(FloatPoint p_location, Collection p_item_list, - InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - if (p_item_list.size() == 0) - { - return null; - } - p_board_handling.remove_ratsnest(); // copying an item may change the connectivity. - return new CopyItemState(p_location, p_item_list, p_parent_state, p_board_handling, p_logfile); - } - - /** Creates a new instance of CopyItemState */ private CopyItemState(FloatPoint p_location, Collection p_item_list, - InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { + InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { super(p_parent_state, p_board_handling, p_logfile); item_list = new LinkedList(); - + start_position = p_location.round(); - current_layer = p_board_handling.settings.layer; + current_layer = p_board_handling.settings.layer; layer_changed = false; current_position = start_position; previous_position = current_position; Iterator it = p_item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_item instanceof DrillItem || curr_item instanceof ObstacleArea) - { + if (curr_item instanceof DrillItem || curr_item instanceof ObstacleArea) { Item new_item = curr_item.copy(0); item_list.add(new_item); } } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.COPYING_ITEMS, p_location); } } - - public InteractiveState mouse_moved() - { + + /** + * Returns a new instance of CopyItemState or null, if p_item_list is empty. + */ + public static CopyItemState get_instance(FloatPoint p_location, Collection p_item_list, + InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + if (p_item_list.size() == 0) { + return null; + } + p_board_handling.remove_ratsnest(); // copying an item may change the connectivity. + return new CopyItemState(p_location, p_item_list, p_parent_state, p_board_handling, p_logfile); + } + + /** + * Creates a new padstack from p_old_pastack with a layer range starting at p_new_layer. + */ + private static Padstack change_padstack_layers(Padstack p_old_padstack, int p_new_layer, + RoutingBoard p_board, Map p_padstack_pairs) { + Padstack new_padstack; + int old_layer = p_old_padstack.from_layer(); + if (old_layer == p_new_layer) { + new_padstack = p_old_padstack; + } else if (p_padstack_pairs.containsKey(p_old_padstack)) { + // New padstack already created, assign it to the via. + new_padstack = p_padstack_pairs.get(p_old_padstack); + } else { + // Create a new padstack. + ConvexShape[] new_shapes = new ConvexShape[p_board.get_layer_count()]; + int layer_diff = old_layer - p_new_layer; + for (int i = 0; i < new_shapes.length; ++i) { + int new_layer_no = i + layer_diff; + if (new_layer_no >= 0 && new_layer_no < new_shapes.length) { + new_shapes[i] = p_old_padstack.get_shape(i + layer_diff); + } + } + new_padstack = p_board.library.padstacks.add(new_shapes); + p_padstack_pairs.put(p_old_padstack, new_padstack); + } + return new_padstack; + } + + public InteractiveState mouse_moved() { super.mouse_moved(); change_position(hdlg.get_current_mouse_position()); return this; } - + /** * Changes the position for inserting the copied items to p_new_location. */ - private void change_position(FloatPoint p_new_position) - { + private void change_position(FloatPoint p_new_position) { current_position = p_new_position.round(); - if (!current_position.equals(previous_position)) - { + if (!current_position.equals(previous_position)) { Vector translate_vector = current_position.difference_by(previous_position); Iterator it = item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { net.freerouting.board.Item curr_item = it.next(); curr_item.translate_by(translate_vector); } @@ -116,14 +131,12 @@ private void change_position(FloatPoint p_new_position) hdlg.repaint(); } } - + /** * Changes the first layer of the items in the copy list to p_new_layer. */ - public boolean change_layer_action(int p_new_layer) - { - if (logfile != null) - { + public boolean change_layer_action(int p_new_layer) { + if (logfile != null) { logfile.start_scope(LogfileScope.CHANGE_LAYER, p_new_layer); } current_layer = p_new_layer; @@ -131,95 +144,79 @@ public boolean change_layer_action(int p_new_layer) hdlg.set_layer(p_new_layer); return true; } - + /** * Inserts the items in the copy list into the board. * Items, which would produce a clearance violation, are not inserted. */ - public void insert() - { - if (item_list == null) - { + public void insert() { + if (item_list == null) { return; } Map padstack_pairs = new TreeMap(); // Contains old and new padstacks after layer change. - + RoutingBoard board = hdlg.get_routing_board(); - if (layer_changed) - { + if (layer_changed) { // create new via padstacks Iterator it = item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if (curr_ob instanceof Via) - { + if (curr_ob instanceof Via) { Via curr_via = (Via) curr_ob; - Padstack new_padstack = change_padstack_layers( curr_via.get_padstack(), current_layer, board, padstack_pairs); + Padstack new_padstack = change_padstack_layers(curr_via.get_padstack(), current_layer, board, padstack_pairs); curr_via.set_padstack(new_padstack); } } } // Copy the components of the old items and assign the new items to the copied components. - + /** Contailns the old and new id no of a copied component. */ Map cmp_no_pairs = new TreeMap(); - + /** Contains the new created components after copying. */ Collection copied_components = new LinkedList(); - + Vector translate_vector = current_position.difference_by(start_position); Iterator it = item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); int curr_cmp_no = curr_item.get_component_no(); - if (curr_cmp_no > 0) - { + if (curr_cmp_no > 0) { //This item belongs to a component int new_cmp_no; Integer curr_key = new Integer(curr_cmp_no); - if (cmp_no_pairs.containsKey(curr_key)) - { + if (cmp_no_pairs.containsKey(curr_key)) { // the new component for this pin is already created Integer curr_value = cmp_no_pairs.get(curr_key); new_cmp_no = curr_value.intValue(); - } - else - { + } else { Component old_component = board.components.get(curr_cmp_no); - if (old_component == null) - { + if (old_component == null) { System.out.println("CopyItemState: component not found"); continue; } Point new_location = old_component.get_location().translate_by(translate_vector); Package new_package; - if (layer_changed) - { + if (layer_changed) { // create a new package with changed layers of the padstacks. - Package.Pin [] new_pin_arr = new Package.Pin[ old_component.get_package().pin_count()]; - for (int i = 0; i < new_pin_arr.length; ++i) - { + Package.Pin[] new_pin_arr = new Package.Pin[old_component.get_package().pin_count()]; + for (int i = 0; i < new_pin_arr.length; ++i) { Package.Pin old_pin = old_component.get_package().get_pin(i); Padstack old_padstack = board.library.padstacks.get(old_pin.padstack_no); - if (old_padstack == null) - { + if (old_padstack == null) { System.out.println("CopyItemState.insert: package padstack not found"); return; } - Padstack new_padstack = change_padstack_layers( old_padstack, current_layer, board, padstack_pairs); + Padstack new_padstack = change_padstack_layers(old_padstack, current_layer, board, padstack_pairs); new_pin_arr[i] = new Package.Pin(old_pin.name, new_padstack.no, old_pin.relative_location, old_pin.rotation_in_degree); } new_package = board.library.packages.add(new_pin_arr); - } - else - { + } else { new_package = old_component.get_package(); } Component new_component = - board.components.add(new_location, old_component.get_rotation_in_degree(), - old_component.placed_on_front(), new_package); + board.components.add(new_location, old_component.get_rotation_in_degree(), + old_component.placed_on_front(), new_package); copied_components.add(new_component); new_cmp_no = new_component.no; cmp_no_pairs.put(new Integer(curr_cmp_no), new Integer(new_cmp_no)); @@ -230,114 +227,56 @@ public void insert() boolean all_items_inserted = true; it = item_list.iterator(); boolean first_time = true; - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_item.board != null && curr_item.clearance_violation_count() == 0) - { - if (first_time) - { + if (curr_item.board != null && curr_item.clearance_violation_count() == 0) { + if (first_time) { // make the current situation restorable by undo board.generate_snapshot(); first_time = false; } board.insert_item(curr_item.copy(0)); - } - else - { + } else { all_items_inserted = false; } } - if (all_items_inserted) - { + if (all_items_inserted) { hdlg.screen_messages.set_status_message(resources.getString("all_items_inserted")); - } - else - { + } else { hdlg.screen_messages.set_status_message(resources.getString("some_items_not_inserted_because_of_obstacles")); } - if (logfile != null) - { + if (logfile != null) { logfile.add_corner(this.current_position.to_float()); } start_position = current_position; layer_changed = false; hdlg.repaint(); } - - public InteractiveState left_button_clicked(FloatPoint p_location) - { + + public InteractiveState left_button_clicked(FloatPoint p_location) { insert(); return this; } - - public InteractiveState process_logfile_point(FloatPoint p_location) - { + + public InteractiveState process_logfile_point(FloatPoint p_location) { change_position(p_location); insert(); return this; } - - public void draw(java.awt.Graphics p_graphics) - { - if (item_list == null) - { + + public void draw(java.awt.Graphics p_graphics) { + if (item_list == null) { return; } Iterator it = item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); curr_item.draw(p_graphics, hdlg.graphics_context, hdlg.graphics_context.get_hilight_color(), - hdlg.graphics_context.get_hilight_color_intensity()); + hdlg.graphics_context.get_hilight_color_intensity()); } } - - public javax.swing.JPopupMenu get_popup_menu() - { + + public javax.swing.JPopupMenu get_popup_menu() { return hdlg.get_panel().popup_menu_copy; } - - /** - * Creates a new padstack from p_old_pastack with a layer range starting at p_new_layer. - */ - private static Padstack change_padstack_layers(Padstack p_old_padstack, int p_new_layer, - RoutingBoard p_board, Map p_padstack_pairs) - { - Padstack new_padstack; - int old_layer = p_old_padstack.from_layer(); - if (old_layer == p_new_layer) - { - new_padstack = p_old_padstack; - } - else if (p_padstack_pairs.containsKey(p_old_padstack)) - { - // New padstack already created, assign it to the via. - new_padstack = p_padstack_pairs.get(p_old_padstack); - } - else - { - // Create a new padstack. - ConvexShape[] new_shapes = new ConvexShape[p_board.get_layer_count()]; - int layer_diff = old_layer - p_new_layer; - for (int i = 0; i < new_shapes.length; ++i) - { - int new_layer_no = i + layer_diff; - if (new_layer_no >= 0 && new_layer_no < new_shapes.length) - { - new_shapes[i] = p_old_padstack.get_shape(i + layer_diff); - } - } - new_padstack = p_board.library.padstacks.add(new_shapes); - p_padstack_pairs.put(p_old_padstack, new_padstack); - } - return new_padstack; - } - - private Collection item_list; - private Point start_position; - private Point current_position; - private int current_layer; - private boolean layer_changed; - private Point previous_position; } diff --git a/src/main/java/net/freerouting/interactive/CornerItemConstructionState.java b/src/main/java/net/freerouting/interactive/CornerItemConstructionState.java index a4567007..5012c948 100644 --- a/src/main/java/net/freerouting/interactive/CornerItemConstructionState.java +++ b/src/main/java/net/freerouting/interactive/CornerItemConstructionState.java @@ -20,155 +20,129 @@ package net.freerouting.interactive; +import net.freerouting.board.AngleRestriction; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.board.AngleRestriction; /** * Common class for constructing an obstacle with a polygonal shape. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class CornerItemConstructionState extends InteractiveState -{ - - /** Creates a new instance of CornerItemConstructionState */ - protected CornerItemConstructionState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { +public class CornerItemConstructionState extends InteractiveState { + + /** + * stored corners of the shape of the item under construction + */ + protected java.util.LinkedList corner_list = new java.util.LinkedList(); + protected FloatPoint snapped_mouse_position; + protected boolean observers_activated = false; + + /** + * Creates a new instance of CornerItemConstructionState + */ + protected CornerItemConstructionState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { super(p_parent_state, p_board_handling, p_logfile); p_board_handling.remove_ratsnest(); // Constructing an item may change the connectivity. } - + /** * adds a corner to the polygon of the item under construction */ - public InteractiveState left_button_clicked(FloatPoint p_location) - { + public InteractiveState left_button_clicked(FloatPoint p_location) { return add_corner(p_location); } - + /** * adds a corner to the polygon of the item under construction */ - public InteractiveState add_corner(FloatPoint p_location) - { + public InteractiveState add_corner(FloatPoint p_location) { IntPoint location = this.snap(p_location.round()); // make shure that the coordinates are integer this.corner_list.add(location); hdlg.repaint(); - if (logfile != null) - { + if (logfile != null) { logfile.add_corner(p_location); } return this; } - - public InteractiveState process_logfile_point(FloatPoint p_point) - { + + public InteractiveState process_logfile_point(FloatPoint p_point) { return add_corner(p_point); } - + /** * stores the location of the mouse pointer after snapping it to the snap_angle */ - public InteractiveState mouse_moved() - { + public InteractiveState mouse_moved() { super.mouse_moved(); IntPoint curr_mouse_pos = hdlg.get_current_mouse_position().round(); this.snapped_mouse_position = (this.snap(curr_mouse_pos)).to_float(); hdlg.repaint(); return this; } - - - public javax.swing.JPopupMenu get_popup_menu() - { + + public javax.swing.JPopupMenu get_popup_menu() { return hdlg.get_panel().popup_menu_corneritem_construction; } - + /** * draws the polygon constructed so far as a visual aid */ - public void draw(java.awt.Graphics p_graphics) - { + public void draw(java.awt.Graphics p_graphics) { int corner_count = corner_list.size(); - if (this.snapped_mouse_position != null) - { + if (this.snapped_mouse_position != null) { ++corner_count; } - FloatPoint [] corners = new FloatPoint [corner_count]; + FloatPoint[] corners = new FloatPoint[corner_count]; java.util.Iterator it = corner_list.iterator(); - for (int i = 0; i < corners.length - 1; ++i) - { + for (int i = 0; i < corners.length - 1; ++i) { corners[i] = (it.next()).to_float(); } - if (this.snapped_mouse_position == null) - { + if (this.snapped_mouse_position == null) { corners[corners.length - 1] = it.next().to_float(); - } - else - { + } else { corners[corners.length - 1] = this.snapped_mouse_position; } hdlg.graphics_context.draw(corners, 300, java.awt.Color.white, p_graphics, 0.5); } - + /** * add a corner to make the last lines fulfil the snap angle restrictions */ - protected void add_corner_for_snap_angle() - { - if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NONE) - { + protected void add_corner_for_snap_angle() { + if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NONE) { return; } - IntPoint first_corner = corner_list.getFirst(); - IntPoint last_corner = corner_list.getLast(); + IntPoint first_corner = corner_list.getFirst(); + IntPoint last_corner = corner_list.getLast(); IntPoint add_corner = null; - if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { add_corner = last_corner.ninety_degree_corner(first_corner, true); - } - else if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) { add_corner = last_corner.fortyfive_degree_corner(first_corner, true); } - if (add_corner != null) - { + if (add_corner != null) { corner_list.add(add_corner); } } - + /** * snaps the line from the last point in the corner_list to * the input point according to this.mouse_snap_angle */ - private IntPoint snap(IntPoint p_point) - { + private IntPoint snap(IntPoint p_point) { IntPoint result; boolean list_empty = (corner_list.size() == 0); - if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE && !list_empty) - { + if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE && !list_empty) { IntPoint last_corner = corner_list.getLast(); result = p_point.orthogonal_projection(last_corner); - } - else if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE && !list_empty) - { + } else if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE && !list_empty) { IntPoint last_corner = corner_list.getLast(); result = p_point.fortyfive_degree_projection(last_corner); - } - else - { + } else { result = p_point; } return result; } - - /** - * stored corners of the shape of the item under construction - */ - protected java.util.LinkedList corner_list = new java.util.LinkedList(); - - protected FloatPoint snapped_mouse_position; - protected boolean observers_activated = false; } diff --git a/src/main/java/net/freerouting/interactive/CutoutRouteState.java b/src/main/java/net/freerouting/interactive/CutoutRouteState.java index 77090574..b1f37545 100644 --- a/src/main/java/net/freerouting/interactive/CutoutRouteState.java +++ b/src/main/java/net/freerouting/interactive/CutoutRouteState.java @@ -21,134 +21,116 @@ package net.freerouting.interactive; +import net.freerouting.board.Item; +import net.freerouting.board.PolylineTrace; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntBox; +import net.freerouting.geometry.planar.IntPoint; + import java.util.Collection; import java.util.LinkedList; import java.util.Set; import java.util.TreeSet; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.IntBox; - -import net.freerouting.board.Item; -import net.freerouting.board.PolylineTrace; - /** - * * @author Alfons Wirtz */ -public class CutoutRouteState extends SelectRegionState -{ - +public class CutoutRouteState extends SelectRegionState { + + private final Collection trace_list; + + /** + * Creates a new instance of CutoutRouteState + */ + private CutoutRouteState(Collection p_item_list, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + super(p_parent_state, p_board_handling, p_logfile); + if (logfile != null) { + logfile.start_scope(LogfileScope.CUTOUT_ROUTE); + } + this.trace_list = p_item_list; + } + /** * Returns a new instance of this class. */ - public static CutoutRouteState get_instance( Collection p_item_list, InteractiveState p_parent_state, - BoardHandling p_board_handling, Logfile p_logfile) - { - return get_instance(p_item_list, null, p_parent_state, p_board_handling, p_logfile); + public static CutoutRouteState get_instance(Collection p_item_list, InteractiveState p_parent_state, + BoardHandling p_board_handling, Logfile p_logfile) { + return get_instance(p_item_list, null, p_parent_state, p_board_handling, p_logfile); } - + /** * Returns a new instance of this class. */ - public static CutoutRouteState get_instance( Collection p_item_list, FloatPoint p_location, InteractiveState p_parent_state, - BoardHandling p_board_handling, Logfile p_logfile) - { + public static CutoutRouteState get_instance(Collection p_item_list, FloatPoint p_location, InteractiveState p_parent_state, + BoardHandling p_board_handling, Logfile p_logfile) { p_board_handling.display_layer_messsage(); // filter items, whichh cannnot be cutout Collection item_list = new LinkedList(); - - for (Item curr_item : p_item_list) - { - if (!curr_item.is_user_fixed() && curr_item instanceof PolylineTrace) - { + + for (Item curr_item : p_item_list) { + if (!curr_item.is_user_fixed() && curr_item instanceof PolylineTrace) { item_list.add((PolylineTrace) curr_item); } } - - CutoutRouteState new_instance = new CutoutRouteState(item_list, p_parent_state, p_board_handling, p_logfile); + + CutoutRouteState new_instance = new CutoutRouteState(item_list, p_parent_state, p_board_handling, p_logfile); new_instance.corner1 = p_location; - if (p_location != null && new_instance.logfile != null) - { + if (p_location != null && new_instance.logfile != null) { new_instance.logfile.add_corner(p_location); } new_instance.hdlg.screen_messages.set_status_message(new_instance.resources.getString("drag_left_mouse_button_to_select_cutout_rectangle")); return new_instance; } - - /** Creates a new instance of CutoutRouteState */ - private CutoutRouteState(Collection p_item_list, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_parent_state, p_board_handling, p_logfile); - if (logfile != null) - { - logfile.start_scope(LogfileScope.CUTOUT_ROUTE); - } - this.trace_list = p_item_list; - } - - public InteractiveState complete() - { + + public InteractiveState complete() { hdlg.screen_messages.set_status_message(""); corner2 = hdlg.get_current_mouse_position(); - if (logfile != null) - { + if (logfile != null) { logfile.add_corner(corner2); } this.cutout_route(); return this.return_state; } - + /** * Selects all items in the rectangle defined by corner1 and corner2. */ - private void cutout_route() - { - if (this.corner1 == null || this.corner2 == null) - { + private void cutout_route() { + if (this.corner1 == null || this.corner2 == null) { return; } - + hdlg.get_routing_board().generate_snapshot(); - - IntPoint p1 = this.corner1.round() ; - IntPoint p2 = this.corner2.round() ; - - IntBox cut_box = new IntBox(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y), Math.max(p1.x, p2.x), Math.max(p1.y, p2.y)) ; - + + IntPoint p1 = this.corner1.round(); + IntPoint p2 = this.corner2.round(); + + IntBox cut_box = new IntBox(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y), Math.max(p1.x, p2.x), Math.max(p1.y, p2.y)); + Set changed_nets = new TreeSet(); - - for (PolylineTrace curr_trace : this.trace_list) - { + + for (PolylineTrace curr_trace : this.trace_list) { net.freerouting.board.ShapeTraceEntries.cutout_trace(curr_trace, cut_box, 0); - for (int i = 0; i < curr_trace.net_count(); ++i) - { + for (int i = 0; i < curr_trace.net_count(); ++i) { changed_nets.add(curr_trace.get_net_no(i)); } } - - for (Integer changed_net : changed_nets) - { + + for (Integer changed_net : changed_nets) { hdlg.update_ratsnest(changed_net); } } - - public void draw(java.awt.Graphics p_graphics) - { - if (trace_list == null) - { + + public void draw(java.awt.Graphics p_graphics) { + if (trace_list == null) { return; } - - for (PolylineTrace curr_trace : this.trace_list) - { - + + for (PolylineTrace curr_trace : this.trace_list) { + curr_trace.draw(p_graphics, hdlg.graphics_context, hdlg.graphics_context.get_hilight_color(), hdlg.graphics_context.get_hilight_color_intensity()); } super.draw(p_graphics); } - - private final Collection trace_list; } diff --git a/src/main/java/net/freerouting/interactive/DragItemState.java b/src/main/java/net/freerouting/interactive/DragItemState.java index d5f877db..2c9edd7e 100644 --- a/src/main/java/net/freerouting/interactive/DragItemState.java +++ b/src/main/java/net/freerouting/interactive/DragItemState.java @@ -20,62 +20,57 @@ package net.freerouting.interactive; -import java.util.Collection; -import java.util.Set; -import java.util.TreeSet; -import java.util.Iterator; - -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Vector; import net.freerouting.board.AngleRestriction; import net.freerouting.board.Item; import net.freerouting.board.MoveComponent; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.IntPoint; +import net.freerouting.geometry.planar.Vector; + +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; +import java.util.TreeSet; /** * Class for interactive dragging items with the mouse on a routing board * * @author Alfons Wirtz */ -public class DragItemState extends DragState -{ - - /** Creates a new instance of MoveItemState */ - protected DragItemState(Item p_item_to_move, FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { +public class DragItemState extends DragState { + + private Item item_to_move = null; + + + /** + * Creates a new instance of MoveItemState + */ + protected DragItemState(Item p_item_to_move, FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { super(p_location, p_parent_state, p_board_handling, p_logfile); item_to_move = p_item_to_move; } - - - public void display_default_message() - { + + public void display_default_message() { hdlg.screen_messages.set_status_message(resources.getString("dragging_item")); } - + /** * Moves the items of the group to p_to_location. * Return this.return_state, if an error eccured while moving, * so that an undo may be necessary. */ - public InteractiveState move_to(FloatPoint p_to_location) - { + public InteractiveState move_to(FloatPoint p_to_location) { IntPoint to_location = p_to_location.round(); IntPoint from_location = this.previous_location.round(); - if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { to_location = to_location.orthogonal_projection(from_location); - } - else if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.FORTYFIVE_DEGREE) { to_location = to_location.fortyfive_degree_projection(from_location); } - if (to_location.equals(from_location)) - { + if (to_location.equals(from_location)) { return this; } - if (item_to_move.is_user_fixed()) - { + if (item_to_move.is_user_fixed()) { hdlg.screen_messages.set_status_message("Please unfix item before dragging"); return this; } @@ -83,40 +78,32 @@ else if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRe Vector rel_coor = to_location.difference_by(from_location); double length = rel_coor.length_approx(); boolean shove_ok = false; - for (int i = 0; i < 2; ++i) - { + for (int i = 0; i < 2; ++i) { move_component = new MoveComponent(item_to_move, rel_coor, 99, 5); - if (move_component.check()) - { + if (move_component.check()) { shove_ok = true; break; } - if (i == 0) - { + if (i == 0) { // reduce evtl. the shove distance to make the check shove function // work properly, if more than 1 trace have to be shoved. double sample_width = 2 * hdlg.get_routing_board().get_min_trace_half_width(); - if (length > sample_width) - { + if (length > sample_width) { rel_coor = rel_coor.change_length_approx(sample_width); } } } - - if (shove_ok) - { - if (!this.something_dragged) - { + + if (shove_ok) { + if (!this.something_dragged) { // initialisitions for the first time dragging this.observers_activated = !hdlg.get_routing_board().observers_active(); - if (this.observers_activated) - { + if (this.observers_activated) { hdlg.get_routing_board().start_notify_observers(); } // make the situation restorable by undo hdlg.get_routing_board().generate_snapshot(); - if (logfile != null) - { + if (logfile != null) { // Delayed till here because otherwise the mouse // might have been only clicked for selecting // and not pressed for moving. @@ -125,8 +112,7 @@ else if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRe this.something_dragged = true; } if (!move_component.insert(hdlg.settings.trace_pull_tight_region_width, - hdlg.settings.trace_pull_tight_accuracy)) - { + hdlg.settings.trace_pull_tight_accuracy)) { // an insert error occured, end the drag state return this.return_state; } @@ -135,54 +121,39 @@ else if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRe this.previous_location = p_to_location;//(IntPoint)this.curr_location.translate_by(rel_coor); return this; } - - public InteractiveState button_released() - { - if (this.observers_activated) - { + + public InteractiveState button_released() { + if (this.observers_activated) { hdlg.get_routing_board().end_notify_observers(); this.observers_activated = false; } - if (logfile != null && something_dragged) - { + if (logfile != null && something_dragged) { logfile.start_scope(LogfileScope.COMPLETE_SCOPE); } - if (something_dragged) - { + if (something_dragged) { // Update the incompletes for the nets of the moved items. - if (item_to_move.get_component_no() == 0) - { - for (int i = 0; i < item_to_move.net_count(); ++i) - { + if (item_to_move.get_component_no() == 0) { + for (int i = 0; i < item_to_move.net_count(); ++i) { hdlg.update_ratsnest(item_to_move.get_net_no(i)); } - } - else - { - Collection moved_items = hdlg.get_routing_board().get_component_items(item_to_move.get_component_no()); + } else { + Collection moved_items = hdlg.get_routing_board().get_component_items(item_to_move.get_component_no()); Set changed_nets = new TreeSet(); Iterator it = moved_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_moved_item = it.next(); - for (int i = 0; i < curr_moved_item.net_count(); ++i) - { + for (int i = 0; i < curr_moved_item.net_count(); ++i) { changed_nets.add(new Integer(curr_moved_item.get_net_no(i))); } } - for (Integer curr_net_no : changed_nets) - { + for (Integer curr_net_no : changed_nets) { hdlg.update_ratsnest(curr_net_no.intValue()); } } - } - else - { + } else { hdlg.show_ratsnest(); } hdlg.screen_messages.set_status_message(""); return this.return_state; } - - private Item item_to_move = null; } diff --git a/src/main/java/net/freerouting/interactive/DragMenuState.java b/src/main/java/net/freerouting/interactive/DragMenuState.java index 2519a663..8a53ca3d 100644 --- a/src/main/java/net/freerouting/interactive/DragMenuState.java +++ b/src/main/java/net/freerouting/interactive/DragMenuState.java @@ -25,30 +25,29 @@ /** * Class implementing the different functionality in the drag menu * - * @author alfons + * @author alfons */ -public class DragMenuState extends MenuState -{ - /** Returns a new instance of DragMenuState */ - public static DragMenuState get_instance(BoardHandling p_board_handling, Logfile p_logfile) - { +public class DragMenuState extends MenuState { + /** + * Creates a new instance of DragMenuState + */ + public DragMenuState(BoardHandling p_board_handling, Logfile p_logfile) { + super(p_board_handling, p_logfile); + } + + /** + * Returns a new instance of DragMenuState + */ + public static DragMenuState get_instance(BoardHandling p_board_handling, Logfile p_logfile) { DragMenuState new_state = new DragMenuState(p_board_handling, p_logfile); return new_state; } - - /** Creates a new instance of DragMenuState */ - public DragMenuState(BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_board_handling, p_logfile); - } - - public InteractiveState mouse_pressed(FloatPoint p_point) - { + + public InteractiveState mouse_pressed(FloatPoint p_point) { return DragState.get_instance(p_point, this, hdlg, logfile); } - - public String get_help_id() - { + + public String get_help_id() { return "MenuState_DragMenuState"; } } diff --git a/src/main/java/net/freerouting/interactive/DragState.java b/src/main/java/net/freerouting/interactive/DragState.java index 2b161c53..07133f55 100644 --- a/src/main/java/net/freerouting/interactive/DragState.java +++ b/src/main/java/net/freerouting/interactive/DragState.java @@ -20,68 +20,70 @@ package net.freerouting.interactive; +import net.freerouting.board.DrillItem; +import net.freerouting.board.Item; +import net.freerouting.board.Trace; import net.freerouting.geometry.planar.FloatPoint; import java.util.Iterator; -import net.freerouting.board.Trace; -import net.freerouting.board.DrillItem; -import net.freerouting.board.Item; - /** * Class implementing functionality when the mouse is dragged on a routing board * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public abstract class DragState extends InteractiveState -{ +public abstract class DragState extends InteractiveState { + protected FloatPoint previous_location; + protected boolean something_dragged = false; + protected boolean observers_activated = false; + + + /** + * Creates a new instance of DragState + */ + protected DragState(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + super(p_parent_state, p_board_handling, p_logfile); + previous_location = p_location; + } + /** * Returns a new instance of this state, if a item to drag was found at the input * location; null otherwise. */ public static DragState get_instance(FloatPoint p_location, InteractiveState p_parent_state, - BoardHandling p_board_handling, Logfile p_logfile) - { + BoardHandling p_board_handling, Logfile p_logfile) { p_board_handling.display_layer_messsage(); Item item_to_move = null; int try_count = 1; - if (p_board_handling.settings.select_on_all_visible_layers) - { + if (p_board_handling.settings.select_on_all_visible_layers) { try_count += p_board_handling.get_layer_count(); } int curr_layer = p_board_handling.settings.layer; int pick_layer = curr_layer; boolean item_found = false; - - for (int i = 0; i < try_count; ++i) - { - if (i == 0 || pick_layer != curr_layer && - (p_board_handling.graphics_context.get_layer_visibility(pick_layer)) > 0) - { + + for (int i = 0; i < try_count; ++i) { + if (i == 0 || pick_layer != curr_layer && + (p_board_handling.graphics_context.get_layer_visibility(pick_layer)) > 0) { java.util.Collection found_items = p_board_handling.get_routing_board().pick_items(p_location.round(), - pick_layer, p_board_handling.settings.item_selection_filter); + pick_layer, p_board_handling.settings.item_selection_filter); Iterator it = found_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { item_found = true; Item curr_item = it.next(); - if (curr_item instanceof Trace) - { + if (curr_item instanceof Trace) { continue; // traces are not moved } - if (!p_board_handling.settings.drag_components_enabled && curr_item.get_component_no() != 0) - { + if (!p_board_handling.settings.drag_components_enabled && curr_item.get_component_no() != 0) { continue; } item_to_move = curr_item; - if (curr_item instanceof DrillItem) - { + if (curr_item instanceof DrillItem) { break; // drill items are preferred } } - if (item_to_move != null) - { + if (item_to_move != null) { break; } } @@ -89,71 +91,44 @@ public static DragState get_instance(FloatPoint p_location, InteractiveState p_p pick_layer = i; } DragState result; - if (item_to_move != null) - { + if (item_to_move != null) { result = new DragItemState(item_to_move, p_location, p_parent_state, p_board_handling, p_logfile); - } - else if (!item_found) - { + } else if (!item_found) { result = new MakeSpaceState(p_location, p_parent_state, p_board_handling, p_logfile); - } - else - { + } else { result = null; } - if (result != null) - { + if (result != null) { p_board_handling.hide_ratsnest(); } return result; } - - /** Creates a new instance of DragState */ - protected DragState(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_parent_state, p_board_handling, p_logfile); - previous_location = p_location; - } - + public abstract InteractiveState move_to(FloatPoint p_to_location); - - - public InteractiveState mouse_dragged(FloatPoint p_point) - { + + public InteractiveState mouse_dragged(FloatPoint p_point) { InteractiveState result = this.move_to(p_point); - if (result != this) - { + if (result != this) { // an error occured java.util.Set changed_nets = new java.util.TreeSet(); hdlg.get_routing_board().undo(changed_nets); - for (Integer changed_net : changed_nets) - { + for (Integer changed_net : changed_nets) { hdlg.update_ratsnest(changed_net); } } - if (this.something_dragged) - { - if (logfile != null ) - { + if (this.something_dragged) { + if (logfile != null) { logfile.add_corner(p_point); } } return result; } - - public InteractiveState complete() - { + + public InteractiveState complete() { return this.button_released(); } - - - public InteractiveState process_logfile_point(FloatPoint p_point) - { + + public InteractiveState process_logfile_point(FloatPoint p_point) { return move_to(p_point); } - - - protected FloatPoint previous_location; - protected boolean something_dragged = false; - protected boolean observers_activated = false; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/interactive/DynamicRouteState.java b/src/main/java/net/freerouting/interactive/DynamicRouteState.java index 1a7e2c0c..697db543 100644 --- a/src/main/java/net/freerouting/interactive/DynamicRouteState.java +++ b/src/main/java/net/freerouting/interactive/DynamicRouteState.java @@ -25,68 +25,57 @@ /** * State for dynamic interactive routing, which is routing while moving the mouse pointer. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class DynamicRouteState extends RouteState -{ - - /** Creates a new instance of DynamicRouteState */ - protected DynamicRouteState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { +public class DynamicRouteState extends RouteState { + + /** + * Creates a new instance of DynamicRouteState + */ + protected DynamicRouteState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { super(p_parent_state, p_board_handling, p_logfile); } - - public InteractiveState mouse_moved() - { + + public InteractiveState mouse_moved() { super.mouse_moved(); return add_corner(hdlg.get_current_mouse_position()); } - + /** * ends routing */ - public InteractiveState left_button_clicked(FloatPoint p_location) - { - if (this.observers_activated) - { + public InteractiveState left_button_clicked(FloatPoint p_location) { + if (this.observers_activated) { hdlg.get_routing_board().end_notify_observers(); this.observers_activated = false; } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.COMPLETE_SCOPE); } - for (int curr_net_no : this.route.net_no_arr) - { + for (int curr_net_no : this.route.net_no_arr) { hdlg.update_ratsnest(curr_net_no); } return this.return_state; } - + /** * Action to be taken when a key is pressed (Shortcut). */ - public InteractiveState key_typed(char p_key_char) - { + public InteractiveState key_typed(char p_key_char) { InteractiveState curr_return_state = this; - if (p_key_char == 's') - { + if (p_key_char == 's') { hdlg.generate_snapshot(); - } - else - { + } else { curr_return_state = super.key_typed(p_key_char); } return curr_return_state; } - - public javax.swing.JPopupMenu get_popup_menu() - { + + public javax.swing.JPopupMenu get_popup_menu() { return hdlg.get_panel().popup_menu_dynamic_route; } - - public String get_help_id() - { + + public String get_help_id() { return "RouteState_DynamicRouteState"; } } diff --git a/src/main/java/net/freerouting/interactive/ExpandTestState.java b/src/main/java/net/freerouting/interactive/ExpandTestState.java index 0b88dc5d..9f04844d 100644 --- a/src/main/java/net/freerouting/interactive/ExpandTestState.java +++ b/src/main/java/net/freerouting/interactive/ExpandTestState.java @@ -19,70 +19,55 @@ */ package net.freerouting.interactive; +import net.freerouting.autoroute.*; +import net.freerouting.board.Item; +import net.freerouting.board.RoutingBoard; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.TileShape; -import java.util.Collection; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.Iterator; - -import net.freerouting.autoroute.AutorouteControl; -import net.freerouting.autoroute.CompleteFreeSpaceExpansionRoom; -import net.freerouting.autoroute.IncompleteFreeSpaceExpansionRoom; -import net.freerouting.autoroute.InsertFoundConnectionAlgo; -import net.freerouting.autoroute.LocateFoundConnectionAlgo; -import net.freerouting.autoroute.MazeSearchAlgo; -import net.freerouting.autoroute.AutorouteEngine; - -import net.freerouting.board.Item; -import net.freerouting.board.RoutingBoard; +import java.util.*; /** * State for testing the expanding algorithm of the autorouter. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class ExpandTestState extends InteractiveState -{ +public class ExpandTestState extends InteractiveState { - public static ExpandTestState get_instance(FloatPoint p_location, InteractiveState p_return_state, BoardHandling p_board_handling) - { - ExpandTestState result = new ExpandTestState(p_location, p_return_state, p_board_handling); - return result; - } + private boolean in_autoroute = false; + private MazeSearchAlgo maze_search_algo = null; + private LocateFoundConnectionAlgo autoroute_result = null; + private AutorouteControl control_settings; + private AutorouteEngine autoroute_engine; - /** Creates a new instance of ExpandTestState */ - private ExpandTestState(FloatPoint p_location, InteractiveState p_return_state, BoardHandling p_board_handling) - { + /** + * Creates a new instance of ExpandTestState + */ + private ExpandTestState(FloatPoint p_location, InteractiveState p_return_state, BoardHandling p_board_handling) { super(p_return_state, p_board_handling, null); init(p_location); } - public InteractiveState key_typed(char p_key_char) - { + public static ExpandTestState get_instance(FloatPoint p_location, InteractiveState p_return_state, BoardHandling p_board_handling) { + ExpandTestState result = new ExpandTestState(p_location, p_return_state, p_board_handling); + return result; + } + + public InteractiveState key_typed(char p_key_char) { InteractiveState result; - if (p_key_char == 'n') - { - if (in_autoroute) - { - if (!this.maze_search_algo.occupy_next_element()) - { + if (p_key_char == 'n') { + if (in_autoroute) { + if (!this.maze_search_algo.occupy_next_element()) { // to display the backtack rooms complete_autoroute(); hdlg.screen_messages.set_status_message("expansion completed"); } - } - else - { + } else { boolean completing_succeeded = false; - while (!completing_succeeded) - { + while (!completing_succeeded) { IncompleteFreeSpaceExpansionRoom next_room = this.autoroute_engine.get_first_incomplete_expansion_room(); - if (next_room == null) - { + if (next_room == null) { hdlg.screen_messages.set_status_message("expansion completed"); break; } @@ -91,59 +76,43 @@ public InteractiveState key_typed(char p_key_char) } //hdlg.get_routing_board().autoroute_data().validate(); result = this; - } - else if (p_key_char == 'a') - { - if (in_autoroute) - { + } else if (p_key_char == 'a') { + if (in_autoroute) { complete_autoroute(); - } - else - { + } else { IncompleteFreeSpaceExpansionRoom next_room = this.autoroute_engine.get_first_incomplete_expansion_room(); - while (next_room != null) - { + while (next_room != null) { complete_expansion_room(next_room); next_room = this.autoroute_engine.get_first_incomplete_expansion_room(); } } result = this; - //hdlg.get_routing_board().autoroute_data().validate(); - } - else if (Character.isDigit(p_key_char)) - { + //hdlg.get_routing_board().autoroute_data().validate(); + } else if (Character.isDigit(p_key_char)) { // next 10^p_key_char expansions int d = Character.digit(p_key_char, 10); final int max_count = (int) Math.pow(10, d); - if (in_autoroute) - { - for (int i = 0; i < max_count; ++i) - { - if (!this.maze_search_algo.occupy_next_element()) - { + if (in_autoroute) { + for (int i = 0; i < max_count; ++i) { + if (!this.maze_search_algo.occupy_next_element()) { // to display the backtack rooms complete_autoroute(); hdlg.screen_messages.set_status_message("expansion completed"); break; } } - } - else - { + } else { int curr_count = 0; IncompleteFreeSpaceExpansionRoom next_room = this.autoroute_engine.get_first_incomplete_expansion_room(); - while (next_room != null && curr_count < max_count) - { + while (next_room != null && curr_count < max_count) { complete_expansion_room(next_room); next_room = this.autoroute_engine.get_first_incomplete_expansion_room(); ++curr_count; } } result = this; - //hdlg.get_routing_board().autoroute_data().validate(); - } - else - { + //hdlg.get_routing_board().autoroute_data().validate(); + } else { autoroute_engine.clear(); result = super.key_typed(p_key_char); } @@ -151,33 +120,27 @@ else if (Character.isDigit(p_key_char)) return result; } - public InteractiveState left_button_clicked(FloatPoint p_location) - { + public InteractiveState left_button_clicked(FloatPoint p_location) { return cancel(); } - public InteractiveState cancel() - { + public InteractiveState cancel() { autoroute_engine.clear(); return this.return_state; } - public InteractiveState complete() - { + public InteractiveState complete() { return cancel(); } - public void draw(java.awt.Graphics p_graphics) - { + public void draw(java.awt.Graphics p_graphics) { autoroute_engine.draw(p_graphics, hdlg.graphics_context, 0.1); - if (this.autoroute_result != null) - { + if (this.autoroute_result != null) { this.autoroute_result.draw(p_graphics, hdlg.graphics_context); } } - private void init(FloatPoint p_location) - { + private void init(FloatPoint p_location) { // look if an autoroute can be started at the input location RoutingBoard board = hdlg.get_routing_board(); int layer = hdlg.settings.layer; @@ -185,14 +148,11 @@ private void init(FloatPoint p_location) Item route_item = null; int route_net_no = 0; Iterator it = found_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if (curr_ob instanceof net.freerouting.board.Connectable) - { + if (curr_ob instanceof net.freerouting.board.Connectable) { Item curr_item = curr_ob; - if (curr_item.net_count() == 1 && curr_item.get_net_no(0) > 0) - { + if (curr_item.net_count() == 1 && curr_item.get_net_no(0) > 0) { route_item = curr_item; route_net_no = curr_item.get_net_no(0); break; @@ -207,8 +167,7 @@ private void init(FloatPoint p_location) this.control_settings.vias_allowed = false; this.autoroute_engine = new AutorouteEngine(board, this.control_settings.trace_clearance_class_no, false); this.autoroute_engine.init_connection(route_net_no, null, null); - if (route_item == null) - { + if (route_item == null) { // create an expansion room in the empty space TileShape contained_shape = TileShape.get_instance(p_location.round()); IncompleteFreeSpaceExpansionRoom expansion_room = @@ -219,8 +178,7 @@ private void init(FloatPoint p_location) } Set route_start_set = route_item.get_connected_set(route_net_no); Set route_dest_set = route_item.get_unconnected_set(route_net_no); - if (route_dest_set.size() > 0) - { + if (route_dest_set.size() > 0) { hdlg.screen_messages.set_status_message("autoroute test started"); this.maze_search_algo = MazeSearchAlgo.get_instance(route_start_set, route_dest_set, autoroute_engine, control_settings); @@ -228,21 +186,18 @@ private void init(FloatPoint p_location) } } - private void complete_autoroute() - { + private void complete_autoroute() { MazeSearchAlgo.Result search_result = this.maze_search_algo.find_connection(); - if (search_result != null) - { + if (search_result != null) { SortedSet ripped_item_list = new TreeSet(); this.autoroute_result = LocateFoundConnectionAlgo.get_instance(search_result, control_settings, - this.autoroute_engine.autoroute_search_tree, - hdlg.get_routing_board().rules.get_trace_angle_restriction(), - ripped_item_list, net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT); + this.autoroute_engine.autoroute_search_tree, + hdlg.get_routing_board().rules.get_trace_angle_restriction(), + ripped_item_list, net.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT); hdlg.get_routing_board().generate_snapshot(); SortedSet ripped_connections = new TreeSet(); - for (Item curr_ripped_item : ripped_item_list) - { + for (Item curr_ripped_item : ripped_item_list) { ripped_connections.addAll(curr_ripped_item.get_connection_items(Item.StopConnectionOption.VIA)); } hdlg.get_routing_board().remove_items(ripped_connections, false); @@ -253,14 +208,8 @@ private void complete_autoroute() /** * Returns true, if the completion succeeded. */ - private boolean complete_expansion_room(IncompleteFreeSpaceExpansionRoom p_incomplete_room) - { + private boolean complete_expansion_room(IncompleteFreeSpaceExpansionRoom p_incomplete_room) { Collection completed_rooms = autoroute_engine.complete_expansion_room(p_incomplete_room); return (completed_rooms.size() > 0); } - private boolean in_autoroute = false; - private MazeSearchAlgo maze_search_algo = null; - private LocateFoundConnectionAlgo autoroute_result = null; - private AutorouteControl control_settings; - private AutorouteEngine autoroute_engine; } diff --git a/src/main/java/net/freerouting/interactive/HoleConstructionState.java b/src/main/java/net/freerouting/interactive/HoleConstructionState.java index 6fc59c6e..a129342c 100644 --- a/src/main/java/net/freerouting/interactive/HoleConstructionState.java +++ b/src/main/java/net/freerouting/interactive/HoleConstructionState.java @@ -20,196 +20,158 @@ package net.freerouting.interactive; -import net.freerouting.geometry.planar.Area; -import net.freerouting.geometry.planar.Circle; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.PolygonShape; -import net.freerouting.geometry.planar.PolylineArea; -import net.freerouting.geometry.planar.PolylineShape; -import net.freerouting.geometry.planar.Shape; +import net.freerouting.board.ItemSelectionFilter; +import net.freerouting.board.ObstacleArea; +import net.freerouting.geometry.planar.*; import java.util.Iterator; -import net.freerouting.board.ObstacleArea; -import net.freerouting.board.ItemSelectionFilter; - /** * Interactive cutting a hole into an obstacle shape * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class HoleConstructionState extends CornerItemConstructionState -{ +public class HoleConstructionState extends CornerItemConstructionState { + private ObstacleArea item_to_modify = null; + + /** + * Creates a new instance of HoleConstructionState + */ + private HoleConstructionState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + super(p_parent_state, p_board_handling, p_logfile); + } + /** * Returns a new instance of this class or null, * if that was not possible with the input parameters. * If p_logfile != null, the construction of this hole is stored in a logfile. */ - public static HoleConstructionState get_instance(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { + public static HoleConstructionState get_instance(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { HoleConstructionState new_instance = new HoleConstructionState(p_parent_state, p_board_handling, p_logfile); - if (!new_instance.start_ok(p_location)) - { + if (!new_instance.start_ok(p_location)) { new_instance = null; } - return new_instance; + return new_instance; } - - /** Creates a new instance of HoleConstructionState */ - private HoleConstructionState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_parent_state, p_board_handling, p_logfile); - } - + /** * Looks for an obstacle area to modify * Returns false, if it cannot find one. */ - private boolean start_ok(FloatPoint p_location) - { + private boolean start_ok(FloatPoint p_location) { IntPoint pick_location = p_location.round(); - ItemSelectionFilter.SelectableChoices[] selectable_choices = - { ItemSelectionFilter.SelectableChoices.KEEPOUT, - ItemSelectionFilter.SelectableChoices.VIA_KEEPOUT, - ItemSelectionFilter.SelectableChoices.CONDUCTION - }; + ItemSelectionFilter.SelectableChoices[] selectable_choices = + {ItemSelectionFilter.SelectableChoices.KEEPOUT, + ItemSelectionFilter.SelectableChoices.VIA_KEEPOUT, + ItemSelectionFilter.SelectableChoices.CONDUCTION + }; ItemSelectionFilter selection_filter = new ItemSelectionFilter(selectable_choices); java.util.Collection found_items = hdlg.get_routing_board().pick_items(pick_location, hdlg.settings.layer, selection_filter); - if (found_items.size() != 1) - { + if (found_items.size() != 1) { hdlg.screen_messages.set_status_message(resources.getString("no_item_found_for_adding_hole")); return false; } net.freerouting.board.Item found_item = found_items.iterator().next(); - if (!(found_item instanceof ObstacleArea)) - { + if (!(found_item instanceof ObstacleArea)) { hdlg.screen_messages.set_status_message(resources.getString("no_obstacle_area_found_for_adding_hole")); return false; } - this.item_to_modify = (ObstacleArea)found_item; - if (item_to_modify.get_area() instanceof Circle) - { + this.item_to_modify = (ObstacleArea) found_item; + if (item_to_modify.get_area() instanceof Circle) { hdlg.screen_messages.set_status_message(resources.getString("adding_hole_to_circle_not_yet_implemented")); return false; } - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.ADDING_HOLE); } this.add_corner(p_location); return true; } - + /** * Adds a corner to the polygon of the the hole under construction. */ - public InteractiveState left_button_clicked(FloatPoint p_next_corner) - { - if (item_to_modify == null) - { + public InteractiveState left_button_clicked(FloatPoint p_next_corner) { + if (item_to_modify == null) { return this.return_state; } - if(item_to_modify.get_area().contains(p_next_corner)) - { + if (item_to_modify.get_area().contains(p_next_corner)) { super.add_corner(p_next_corner); hdlg.repaint(); } return this; } - + /** * adds the just constructed hole to the item under modification, * if that is possible without clearance violations */ - public InteractiveState complete() - { - if (item_to_modify == null) - { + public InteractiveState complete() { + if (item_to_modify == null) { return this.return_state; } add_corner_for_snap_angle(); int corner_count = corner_list.size(); boolean construction_succeeded = (corner_count > 2); - PolylineShape [] new_holes = null; + PolylineShape[] new_holes = null; PolylineShape new_border = null; - if (construction_succeeded) - { + if (construction_succeeded) { Area obs_area = item_to_modify.get_area(); Shape[] old_holes = obs_area.get_holes(); - new_border = (PolylineShape)obs_area.get_border(); - if (new_border == null) - { + new_border = (PolylineShape) obs_area.get_border(); + if (new_border == null) { construction_succeeded = false; - } - else - { + } else { new_holes = new PolylineShape[old_holes.length + 1]; - for (int i = 0; i < old_holes.length; ++i) - { - new_holes[i] = (PolylineShape)old_holes[i]; - if (new_holes[i] == null) - { + for (int i = 0; i < old_holes.length; ++i) { + new_holes[i] = (PolylineShape) old_holes[i]; + if (new_holes[i] == null) { construction_succeeded = false; break; } } } } - if (construction_succeeded) - { - IntPoint [] new_hole_corners = new IntPoint[corner_count]; + if (construction_succeeded) { + IntPoint[] new_hole_corners = new IntPoint[corner_count]; Iterator it = corner_list.iterator(); - for (int i = 0; i < corner_count ; ++i) - { + for (int i = 0; i < corner_count; ++i) { new_hole_corners[i] = it.next(); } new_holes[new_holes.length - 1] = new PolygonShape(new_hole_corners); PolylineArea new_obs_area = new PolylineArea(new_border, new_holes); - - if (new_obs_area.split_to_convex() == null) - { + + if (new_obs_area.split_to_convex() == null) { // shape is invalid, maybe it has selfintersections construction_succeeded = false; - } - else - { + } else { this.observers_activated = !hdlg.get_routing_board().observers_active(); - if (this.observers_activated) - { + if (this.observers_activated) { hdlg.get_routing_board().start_notify_observers(); } hdlg.get_routing_board().generate_snapshot(); - hdlg.get_routing_board().remove_item( item_to_modify); + hdlg.get_routing_board().remove_item(item_to_modify); hdlg.get_routing_board().insert_obstacle(new_obs_area, item_to_modify.get_layer(), item_to_modify.clearance_class_no(), net.freerouting.board.FixedState.UNFIXED); - if (this.observers_activated) - { + if (this.observers_activated) { hdlg.get_routing_board().end_notify_observers(); this.observers_activated = false; } } } - if (construction_succeeded) - { + if (construction_succeeded) { hdlg.screen_messages.set_status_message(resources.getString("adding_hole_completed")); - } - else - { + } else { hdlg.screen_messages.set_status_message(resources.getString("adding_hole_failed")); } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.COMPLETE_SCOPE); } return this.return_state; } - - public void display_default_message() - { + + public void display_default_message() { hdlg.screen_messages.set_status_message(resources.getString("adding_hole_to_obstacle_area")); } - - private ObstacleArea item_to_modify = null; } diff --git a/src/main/java/net/freerouting/interactive/InteractiveActionThread.java b/src/main/java/net/freerouting/interactive/InteractiveActionThread.java index eed00d27..e1e10736 100644 --- a/src/main/java/net/freerouting/interactive/InteractiveActionThread.java +++ b/src/main/java/net/freerouting/interactive/InteractiveActionThread.java @@ -26,77 +26,65 @@ * * @author Alfons Wirtz */ -public abstract class InteractiveActionThread extends Thread implements net.freerouting.datastructures.Stoppable -{ +public abstract class InteractiveActionThread extends Thread implements net.freerouting.datastructures.Stoppable { - public static InteractiveActionThread get_autoroute_instance(BoardHandling p_board_handling) - { + public final BoardHandling hdlg; + private boolean stop_requested = false; + + /** + * Creates a new instance of InteractiveActionThread + */ + protected InteractiveActionThread(BoardHandling p_board_handling) { + this.hdlg = p_board_handling; + } + + public static InteractiveActionThread get_autoroute_instance(BoardHandling p_board_handling) { return new AutorouteThread(p_board_handling); } - public static InteractiveActionThread get_batch_autorouter_instance(BoardHandling p_board_handling) - { + public static InteractiveActionThread get_batch_autorouter_instance(BoardHandling p_board_handling) { return new BatchAutorouterThread(p_board_handling); } - public static InteractiveActionThread get_fanout_instance(BoardHandling p_board_handling) - { + public static InteractiveActionThread get_fanout_instance(BoardHandling p_board_handling) { return new FanoutThread(p_board_handling); } - public static InteractiveActionThread get_pull_tight_instance(BoardHandling p_board_handling) - { + public static InteractiveActionThread get_pull_tight_instance(BoardHandling p_board_handling) { return new PullTightThread(p_board_handling); } - public static InteractiveActionThread get_read_logfile_instance(BoardHandling p_board_handling, java.io.InputStream p_input_stream) - { + public static InteractiveActionThread get_read_logfile_instance(BoardHandling p_board_handling, java.io.InputStream p_input_stream) { return new ReadLogfileThread(p_board_handling, p_input_stream); } - /** Creates a new instance of InteractiveActionThread */ - protected InteractiveActionThread(BoardHandling p_board_handling) - { - this.hdlg = p_board_handling; - } - protected abstract void thread_action(); - public void run() - { + public void run() { thread_action(); hdlg.repaint(); } - public synchronized void request_stop() - { + public synchronized void request_stop() { stop_requested = true; } - public synchronized boolean is_stop_requested() - { + public synchronized boolean is_stop_requested() { return stop_requested; } - public synchronized void draw(java.awt.Graphics p_graphics) - { - // Can be overwritten in derived classes. + public synchronized void draw(java.awt.Graphics p_graphics) { + // Can be overwritten in derived classes. } - private boolean stop_requested = false; - public final BoardHandling hdlg; - private static class AutorouteThread extends InteractiveActionThread - { + private static class AutorouteThread extends InteractiveActionThread { - private AutorouteThread(BoardHandling p_board_handling) - { + private AutorouteThread(BoardHandling p_board_handling) { super(p_board_handling); } - protected void thread_action() - { - if (!(hdlg.interactive_state instanceof SelectedItemState)) - { + protected void thread_action() { + if (!(hdlg.interactive_state instanceof SelectedItemState)) { return; } InteractiveState return_state = ((SelectedItemState) hdlg.interactive_state).autoroute(this); @@ -104,18 +92,14 @@ protected void thread_action() } } - private static class FanoutThread extends InteractiveActionThread - { + private static class FanoutThread extends InteractiveActionThread { - private FanoutThread(BoardHandling p_board_handling) - { + private FanoutThread(BoardHandling p_board_handling) { super(p_board_handling); } - protected void thread_action() - { - if (!(hdlg.interactive_state instanceof SelectedItemState)) - { + protected void thread_action() { + if (!(hdlg.interactive_state instanceof SelectedItemState)) { return; } InteractiveState return_state = ((SelectedItemState) hdlg.interactive_state).fanout(this); @@ -123,18 +107,14 @@ protected void thread_action() } } - private static class PullTightThread extends InteractiveActionThread - { + private static class PullTightThread extends InteractiveActionThread { - private PullTightThread(BoardHandling p_board_handling) - { + private PullTightThread(BoardHandling p_board_handling) { super(p_board_handling); } - protected void thread_action() - { - if (!(hdlg.interactive_state instanceof SelectedItemState)) - { + protected void thread_action() { + if (!(hdlg.interactive_state instanceof SelectedItemState)) { return; } InteractiveState return_state = ((SelectedItemState) hdlg.interactive_state).pull_tight(this); @@ -142,17 +122,16 @@ protected void thread_action() } } - private static class ReadLogfileThread extends InteractiveActionThread - { + private static class ReadLogfileThread extends InteractiveActionThread { - private ReadLogfileThread(BoardHandling p_board_handling, java.io.InputStream p_input_stream) - { + private final java.io.InputStream input_stream; + + private ReadLogfileThread(BoardHandling p_board_handling, java.io.InputStream p_input_stream) { super(p_board_handling); this.input_stream = p_input_stream; } - protected void thread_action() - { + protected void thread_action() { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", hdlg.get_locale()); @@ -163,64 +142,51 @@ protected void thread_action() hdlg.screen_messages.set_write_protected(true); boolean done = false; InteractiveState previous_state = hdlg.interactive_state; - if (!hdlg.logfile.start_read(this.input_stream)) - { + if (!hdlg.logfile.start_read(this.input_stream)) { done = true; } boolean interrupted = false; int debug_counter = 0; hdlg.get_panel().board_frame.refresh_windows(); hdlg.paint_immediately = true; - while (!done) - { - if (is_stop_requested()) - { + while (!done) { + if (is_stop_requested()) { interrupted = true; done = true; } ++debug_counter; LogfileScope logfile_scope = hdlg.logfile.start_read_scope(); - if (logfile_scope == null) - { + if (logfile_scope == null) { done = true; // end of logfile } - if (!done) - { - try - { + if (!done) { + try { InteractiveState new_state = logfile_scope.read_scope(hdlg.logfile, hdlg.interactive_state, hdlg); - if (new_state == null) - { + if (new_state == null) { System.out.println("BoardHandling:read_logfile: inconsistent logfile scope"); new_state = previous_state; } hdlg.repaint(); hdlg.set_interactive_state(new_state); - } catch (Exception e) - { + } catch (Exception e) { done = true; } } } hdlg.paint_immediately = false; - try - { + try { this.input_stream.close(); - } catch (java.io.IOException e) - { + } catch (java.io.IOException e) { System.out.println("ReadLogfileThread: unable to close input stream"); } hdlg.get_panel().board_frame.refresh_windows(); hdlg.screen_messages.set_write_protected(false); String curr_message; - if (interrupted) - { + if (interrupted) { curr_message = resources.getString("interrupted"); - } - else - { + } else { curr_message = resources.getString("completed"); } String end_message = resources.getString("logfile") + " " + curr_message; @@ -228,6 +194,5 @@ protected void thread_action() hdlg.set_board_read_only(saved_board_read_only); hdlg.get_panel().board_frame.repaint_all(); } - private final java.io.InputStream input_stream; } } diff --git a/src/main/java/net/freerouting/interactive/InteractiveState.java b/src/main/java/net/freerouting/interactive/InteractiveState.java index 9755aebb..cb00d5d6 100644 --- a/src/main/java/net/freerouting/interactive/InteractiveState.java +++ b/src/main/java/net/freerouting/interactive/InteractiveState.java @@ -22,157 +22,143 @@ import net.freerouting.geometry.planar.FloatPoint; -import java.awt.Graphics; +import java.awt.*; /** * Common base class of all interaction states with the graphical interface * - * @author Alfons Wirtz - * + * @author Alfons Wirtz */ -public class InteractiveState -{ - /** Creates a new instance of InteractiveState */ - protected InteractiveState(InteractiveState p_return_state, BoardHandling p_board_handling, Logfile p_logfile) - { +public class InteractiveState { + /** + * board setting access handler for the derived classes + */ + protected final BoardHandling hdlg; + /** + * if logfile != null, the interactive actions are stored in a logfile + */ + protected final Logfile logfile; + /** + * Contains the files with the language dependent messages + */ + protected final java.util.ResourceBundle resources; + /** + * The intended state after this state is finished + */ + protected InteractiveState return_state; + + /** + * Creates a new instance of InteractiveState + */ + protected InteractiveState(InteractiveState p_return_state, BoardHandling p_board_handling, Logfile p_logfile) { this.return_state = p_return_state; this.hdlg = p_board_handling; this.logfile = p_logfile; this.resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", p_board_handling.get_locale()); } - + /** * default draw function to be overwritten in derived classes */ - public void draw(Graphics p_graphics) - { + public void draw(Graphics p_graphics) { } - + /** * Default function to be overwritten in derived classes. * Returns the return_state of this state, if the state is left * after the method, or else this state. */ - public InteractiveState left_button_clicked(FloatPoint p_location) - { + public InteractiveState left_button_clicked(FloatPoint p_location) { return this; } - + /* * Actions to be taken when a mouse button is released. * Default function to be overwritten in derived classes. * Returns the return_state of this state, if the state is left * after the method, or else this state. */ - public InteractiveState button_released() - { + public InteractiveState button_released() { return this; } - + /** * Actions to be taken, when the location of the mouse pointer changes. * Default function to be overwritten in derived classes. * Returns the return_state of this state, if the state ends * after the method, or else this state. */ - public InteractiveState mouse_moved() - { + public InteractiveState mouse_moved() { FloatPoint mouse_position = hdlg.coordinate_transform.board_to_user(hdlg.get_current_mouse_position()); hdlg.screen_messages.set_mouse_position(mouse_position); return this; } - + /** * Actions to be taken when the mouse moves with a button pressed down. * Default function to be overwritten in derived classes. * Returns the return_state of this state, if the state is left * after the method, or else this state. */ - public InteractiveState mouse_dragged(FloatPoint p_point) - { + public InteractiveState mouse_dragged(FloatPoint p_point) { return this; } - + /** * Actions to be taken when the left mouse button is pressed down. * Default function to be overwritten in derived classes. * Returns the return_state of this state, if the state is left * after the method, or else this state. */ - public InteractiveState mouse_pressed(FloatPoint p_point) - { + public InteractiveState mouse_pressed(FloatPoint p_point) { return this; } - + /** * Action to be taken, when the mouse wheel was turned.. */ - public InteractiveState mouse_wheel_moved(int p_rotation) - { + public InteractiveState mouse_wheel_moved(int p_rotation) { java.awt.geom.Point2D screen_mouse_pos = hdlg.graphics_context.coordinate_transform.board_to_screen(hdlg.get_current_mouse_position()); hdlg.get_panel().zoom_with_mouse_wheel(screen_mouse_pos, p_rotation); return this; } - + /** * Default actions when a key shortcut is pressed. * Overwritten in derived classes for other key shortcut actions. */ - public InteractiveState key_typed(char p_key_char) - { + public InteractiveState key_typed(char p_key_char) { InteractiveState result = this; java.awt.geom.Point2D screen_mouse_pos = hdlg.graphics_context.coordinate_transform.board_to_screen(hdlg.get_current_mouse_position()); - if (p_key_char == 'a') - { + if (p_key_char == 'a') { hdlg.get_panel().board_frame.zoom_all(); - } - else if (p_key_char == 'c') - { + } else if (p_key_char == 'c') { hdlg.get_panel().center_display(screen_mouse_pos); - } - else if (p_key_char == 'f') - { + } else if (p_key_char == 'f') { result = ZoomRegionState.get_instance(hdlg.get_current_mouse_position(), this, hdlg, logfile); - } - else if (p_key_char =='h') - { + } else if (p_key_char == 'h') { hdlg.get_panel().board_frame.select_previous_snapshot(); } - if (p_key_char == 'j') - { + if (p_key_char == 'j') { hdlg.get_panel().board_frame.goto_selected_snapshot(); - } - else if (p_key_char =='k') - { + } else if (p_key_char == 'k') { hdlg.get_panel().board_frame.select_next_snapshot(); - } - else if (p_key_char == 'o') - { + } else if (p_key_char == 'o') { hdlg.get_panel().zoom_out(screen_mouse_pos); - } - else if (p_key_char == 'z') - { + } else if (p_key_char == 'z') { hdlg.get_panel().zoom_in(screen_mouse_pos); - } - else if (p_key_char == ',') - { + } else if (p_key_char == ',') { // toggle the crosshair cursor hdlg.get_panel().set_custom_crosshair_cursor(!hdlg.get_panel().is_custom_cross_hair_cursor()); - } - else if (p_key_char == '\n' || p_key_char == ' ') - { + } else if (p_key_char == '\n' || p_key_char == ' ') { result = this.complete(); - } - else if (p_key_char == java.awt.event.KeyEvent.VK_ESCAPE) - { + } else if (p_key_char == java.awt.event.KeyEvent.VK_ESCAPE) { result = this.cancel(); - } - else if (Character.isDigit(p_key_char)) - { + } else if (Character.isDigit(p_key_char)) { // change the current layer to the p_key_char-ths signal layer net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int d = Character.digit(p_key_char, 10); @@ -184,95 +170,73 @@ else if (Character.isDigit(p_key_char)) } return result; } - + /** * Action to be taken, when this state is completed and exited. * Default function to be overwritten in derived classes. * Returns the return_state of this state. */ - public InteractiveState complete() - { - if (this.return_state != this &&logfile != null) - { + public InteractiveState complete() { + if (this.return_state != this && logfile != null) { logfile.start_scope(LogfileScope.COMPLETE_SCOPE); } return this.return_state; } - + /** * Actions to be taken, when this state gets cancelled. * Default function to be overwritten in derived classes. * Returns the parent state of this state. */ - public InteractiveState cancel() - { - if (this.return_state != this && logfile != null) - { + public InteractiveState cancel() { + if (this.return_state != this && logfile != null) { logfile.start_scope(LogfileScope.CANCEL_SCOPE); } return this.return_state; } - + /** * Action to be taken, when the current layer is changed. * returns false, if the layer could not be changed, * Default function to be overwritten in derived classes. */ - public boolean change_layer_action(int p_new_layer) - { + public boolean change_layer_action(int p_new_layer) { hdlg.set_layer(p_new_layer); return true; } - + /** * Used when reading the next point from a logfile. * Default function to be overwritten in derived classes. */ - public InteractiveState process_logfile_point(FloatPoint p_point) - { + public InteractiveState process_logfile_point(FloatPoint p_point) { return this; } - + /** * The default message displayed, when this state is active. */ - public void display_default_message() - { + public void display_default_message() { } - + /** * Gets the identifier for displaying help for the user about this state. */ - public String get_help_id() - { + public String get_help_id() { return "MenuState"; } - - + /** * Returns the popup menu from board_panel, which is used in this interactive state. * Default function to be overwritten in derived classes. */ - public javax.swing.JPopupMenu get_popup_menu() - { + public javax.swing.JPopupMenu get_popup_menu() { return null; } + /** * A state using toolbar must overwrite this function. */ - public void set_toolbar() - { + public void set_toolbar() { } - - /** board setting access handler for the derived classes */ - protected final BoardHandling hdlg; - - /** The intended state after this state is finished */ - protected InteractiveState return_state; - - /** if logfile != null, the interactive actions are stored in a logfile */ - protected final Logfile logfile; - - /** Contains the files with the language dependent messages */ - protected final java.util.ResourceBundle resources; } diff --git a/src/main/java/net/freerouting/interactive/Logfile.java b/src/main/java/net/freerouting/interactive/Logfile.java index f66321da..253fe5da 100644 --- a/src/main/java/net/freerouting/interactive/Logfile.java +++ b/src/main/java/net/freerouting/interactive/Logfile.java @@ -24,164 +24,135 @@ import java.io.InputStream; /** - * Logfile to track the actions in the interactive board handling - * for automatic replay. + * Logfile to track the actions in the interactive board handling + * for automatic replay. * * @author Alfons Wirtz - * */ -public class Logfile -{ +public class Logfile { + private LogfileScanner scanner = null; + private FileWriter file_writer = null; + private boolean write_enabled = false; + private Object pending_token = null; + /** * opens the logfile for reading */ - public boolean start_read(InputStream p_input_stream) - { + public boolean start_read(InputStream p_input_stream) { this.scanner = new LogfileScanner(p_input_stream); return (this.scanner != null); } - + /** * Reads the next corner from the logfile. * Return null, if no valid corner is found. */ - public FloatPoint read_corner() - { - + public FloatPoint read_corner() { + double x = 0; double y = 0; - for (int i = 0; i < 2; ++i) - { + for (int i = 0; i < 2; ++i) { Object curr_ob = this.next_token(); - if (!(curr_ob instanceof Double)) - { + if (!(curr_ob instanceof Double)) { this.pending_token = curr_ob; return null; } double f = ((Double) curr_ob).doubleValue(); - if (i == 0) - { + if (i == 0) { x = f; - } - else - { + } else { y = f; } } return new FloatPoint(x, y); } - + /** * closes the logfile after writing */ - public void close_output() - { - if (this.file_writer != null) - { - try - { + public void close_output() { + if (this.file_writer != null) { + try { this.file_writer.close(); - } - catch (IOException e) - { + } catch (IOException e) { System.out.println("unable to close logfile"); } } this.write_enabled = false; } - + /** * opens a logfile for writing */ - public boolean start_write(File p_file) - { - try - { + public boolean start_write(File p_file) { + try { this.file_writer = new FileWriter(p_file); - } - catch (IOException e) - { + } catch (IOException e) { System.out.println("unable to create logfile"); return false; } write_enabled = true; return true; } - + /** * Marks the beginning of a new item in the olutput stream */ - public void start_scope(LogfileScope p_logfile_scope) - { - if (write_enabled) - { - try - { + public void start_scope(LogfileScope p_logfile_scope) { + if (write_enabled) { + try { this.file_writer.write(p_logfile_scope.name); this.file_writer.write("\n"); - } - catch (IOException e2) - { + } catch (IOException e2) { System.out.println("Logfile.start_scope: write failed"); } } } - + /** * Marks the beginning of a new scope in the olutput stream * Writes also an integer value. */ - public void start_scope(LogfileScope p_logfile_scope, int p_int_value) - { + public void start_scope(LogfileScope p_logfile_scope, int p_int_value) { start_scope(p_logfile_scope); add_int(p_int_value); } - + /** * Marks the beginning of a new scope in the olutput stream * Writes also 1, if p_boolean_value is true, or 0, if p_boolean_value is false; */ - public void start_scope(LogfileScope p_logfile_scope, boolean p_boolean_value) - { + public void start_scope(LogfileScope p_logfile_scope, boolean p_boolean_value) { start_scope(p_logfile_scope); int int_value; - if (p_boolean_value) - { + if (p_boolean_value) { int_value = 1; - } - else - { + } else { int_value = 0; } add_int(int_value); } - + /** * Marks the beginning of a new item in the olutput stream * Writes also the start corner. */ - public void start_scope(LogfileScope p_logfile_scope, FloatPoint p_start_corner) - { + public void start_scope(LogfileScope p_logfile_scope, FloatPoint p_start_corner) { start_scope(p_logfile_scope); add_corner(p_start_corner); } - - - + /** * Reads the next scope iidentifier from the logfile. * Returns null if no more item scope was found. */ - public LogfileScope start_read_scope() - { + public LogfileScope start_read_scope() { Object curr_ob = this.next_token(); - if (curr_ob == null) - { + if (curr_ob == null) { return null; } - if (!(curr_ob instanceof String)) - { + if (!(curr_ob instanceof String)) { System.out.println("Logfile.start_read_scope: String expected"); this.pending_token = curr_ob; return null; @@ -189,91 +160,68 @@ public LogfileScope start_read_scope() LogfileScope result = LogfileScope.get_scope((String) curr_ob); return result; } - + /** * adds an int to the logfile */ - public void add_int(int p_int) - { - - if (write_enabled) - { - try - { + public void add_int(int p_int) { + + if (write_enabled) { + try { this.file_writer.write((new Integer(p_int)).toString()); this.file_writer.write("\n"); - } - catch (IOException e2) - { + } catch (IOException e2) { System.out.println("unable to write integer to logfile"); } } } - + /** * Reads the next int from the logfile. * Returns -1, if no valid integer was found. */ - public int read_int() - { + public int read_int() { Object curr_ob = this.next_token(); - if (!(curr_ob instanceof Integer)) - { + if (!(curr_ob instanceof Integer)) { System.out.println("Logfile.read_int: Integer expected"); this.pending_token = curr_ob; return -1; } return (((Integer) curr_ob).intValue()); } - + /** * adds a FloatPoint to the logfile */ - public void add_corner(FloatPoint p_corner) - { - if (write_enabled) - { - if (p_corner == null) - { + public void add_corner(FloatPoint p_corner) { + if (write_enabled) { + if (p_corner == null) { System.out.println("logfile.add_corner: p_corner is null"); return; } - try - { + try { this.file_writer.write((new Double(p_corner.x)).toString()); this.file_writer.write(" "); this.file_writer.write((new Double(p_corner.y)).toString()); this.file_writer.write("\n"); - } - catch (IOException e2) - { + } catch (IOException e2) { System.out.println("unable to write to logfile while adding corner"); } } } - - private Object next_token() - { - if (this.pending_token != null) - { + + private Object next_token() { + if (this.pending_token != null) { Object result = this.pending_token; this.pending_token = null; return result; } - try - { + try { Object result = this.scanner.next_token(); return result; - } - catch (IOException e) - { + } catch (IOException e) { System.out.println("Logfile.next_token: IO error scanning file"); return null; } } - - private LogfileScanner scanner = null; - private FileWriter file_writer = null; - private boolean write_enabled = false; - private Object pending_token = null; } \ No newline at end of file diff --git a/src/main/java/net/freerouting/interactive/LogfileScanner.java b/src/main/java/net/freerouting/interactive/LogfileScanner.java index fea60b12..62e1085e 100644 --- a/src/main/java/net/freerouting/interactive/LogfileScanner.java +++ b/src/main/java/net/freerouting/interactive/LogfileScanner.java @@ -1,6 +1,7 @@ /* The following code was generated by JFlex 1.4 on 06.07.05 18:12 */ package net.freerouting.interactive; + @SuppressWarnings("all") /** @@ -11,532 +12,530 @@ */ class LogfileScanner { - /** This character denotes the end of file */ - public static final int YYEOF = -1; - - /** initial size of the lookahead buffer */ - private static final int ZZ_BUFFERSIZE = 16384; - - /** lexical states */ - public static final int YYINITIAL = 0; - - /** - * Translates characters to character classes - */ - private static final String ZZ_CMAP_PACKED = - "\11\0\1\3\1\2\1\0\1\3\1\1\22\0\1\3\2\0\1\6"+ - "\1\7\5\0\1\5\1\14\1\0\1\12\1\11\1\4\1\13\11\10"+ - "\7\0\32\7\4\0\1\7\1\0\32\7\uff85\0"; - - /** - * Translates characters to character classes - */ - private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); - - /** - * Translates DFA states to action switch labels. - */ - private static final int [] ZZ_ACTION = zzUnpackAction(); - - private static final String ZZ_ACTION_PACKED_0 = - "\1\0\1\1\2\2\3\3\1\4\1\1\1\4\1\1"+ - "\3\0\1\5\2\0\1\5\1\0"; - - private static int [] zzUnpackAction() { - int [] result = new int[19]; - int offset = 0; - offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAction(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); + /** + * This character denotes the end of file + */ + public static final int YYEOF = -1; + /** + * lexical states + */ + public static final int YYINITIAL = 0; + /** + * initial size of the lookahead buffer + */ + private static final int ZZ_BUFFERSIZE = 16384; + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\0\1\3\1\2\1\0\1\3\1\1\22\0\1\3\2\0\1\6" + + "\1\7\5\0\1\5\1\14\1\0\1\12\1\11\1\4\1\13\11\10" + + "\7\0\32\7\4\0\1\7\1\0\32\7\uff85\0"; + + /** + * Translates characters to character classes + */ + private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + private static final String ZZ_ACTION_PACKED_0 = + "\1\0\1\1\2\2\3\3\1\4\1\1\1\4\1\1" + + "\3\0\1\5\2\0\1\5\1\0"; + /** + * Translates DFA states to action switch labels. + */ + private static final int[] ZZ_ACTION = zzUnpackAction(); + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\15\0\32\0\15\0\47\0\64\0\101\0\116" + + "\0\133\0\150\0\165\0\202\0\217\0\234\0\150\0\251" + + "\0\266\0\234\0\303"; + /** + * Translates a state to a row index in the transition table + */ + private static final int[] ZZ_ROWMAP = zzUnpackRowMap(); + private static final String ZZ_TRANS_PACKED_0 = + "\1\2\1\3\2\4\1\5\1\2\1\6\1\7\1\10" + + "\1\7\1\11\1\12\1\13\17\0\1\4\16\0\1\7" + + "\1\14\4\7\1\0\1\7\1\0\1\15\1\3\1\4" + + "\1\15\1\6\1\15\4\6\1\15\1\6\1\15\4\0" + + "\1\7\1\0\4\7\1\0\1\7\11\0\1\10\1\16" + + "\1\0\1\10\11\0\1\10\2\0\1\12\11\0\1\17" + + "\1\16\1\0\1\17\11\0\1\17\2\0\1\17\1\0" + + "\5\20\1\21\7\20\1\15\1\3\1\4\12\15\10\0" + + "\1\22\2\0\1\22\1\0\5\20\1\23\7\20\4\0" + + "\1\4\1\21\7\0\4\20\1\4\1\23\7\20"; + /** + * The transition table of the DFA + */ + private static final int[] ZZ_TRANS = zzUnpackTrans(); + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\1\0\1\11\1\1\1\11\7\1\3\0\1\1\2\0" + + "\1\1\1\0"; + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState + */ + private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute(); + /** + * the input device + */ + private java.io.Reader zzReader; + /** + * the current state of the DFA + */ + private int zzState; + /** + * the current lexical state + */ + private int zzLexicalState = YYINITIAL; + /** + * this buffer contains the current text to be matched and is + * the source of the yytext() string + */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + /** + * the textposition at the last accepting state + */ + private int zzMarkedPos; + /** + * the textposition at the last state to be included in yytext + */ + private int zzPushbackPos; + /** + * the current text position in the buffer + */ + private int zzCurrentPos; + /** + * startRead marks the beginning of the yytext() string in the buffer + */ + private int zzStartRead; + /** + * endRead marks the last character in the buffer, that has been read + * from input + */ + private int zzEndRead; + /** + * number of newlines encountered up to the start of the matched text + */ + private int yyline; + /** + * the number of characters up to the start of the matched text + */ + private int yychar; + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + /** + * zzAtEOF == true <=> the scanner is at the EOF + */ + private boolean zzAtEOF; + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + LogfileScanner(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + LogfileScanner(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); } - return j; - } - - - /** - * Translates a state to a row index in the transition table - */ - private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); - - private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\15\0\32\0\15\0\47\0\64\0\101\0\116"+ - "\0\133\0\150\0\165\0\202\0\217\0\234\0\150\0\251"+ - "\0\266\0\234\0\303"; - - private static int [] zzUnpackRowMap() { - int [] result = new int[19]; - int offset = 0; - offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackRowMap(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int high = packed.charAt(i++) << 16; - result[j++] = high | packed.charAt(i++); + + private static int[] zzUnpackAction() { + int[] result = new int[19]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; } - return j; - } - - /** - * The transition table of the DFA - */ - private static final int [] ZZ_TRANS = zzUnpackTrans(); - - private static final String ZZ_TRANS_PACKED_0 = - "\1\2\1\3\2\4\1\5\1\2\1\6\1\7\1\10"+ - "\1\7\1\11\1\12\1\13\17\0\1\4\16\0\1\7"+ - "\1\14\4\7\1\0\1\7\1\0\1\15\1\3\1\4"+ - "\1\15\1\6\1\15\4\6\1\15\1\6\1\15\4\0"+ - "\1\7\1\0\4\7\1\0\1\7\11\0\1\10\1\16"+ - "\1\0\1\10\11\0\1\10\2\0\1\12\11\0\1\17"+ - "\1\16\1\0\1\17\11\0\1\17\2\0\1\17\1\0"+ - "\5\20\1\21\7\20\1\15\1\3\1\4\12\15\10\0"+ - "\1\22\2\0\1\22\1\0\5\20\1\23\7\20\4\0"+ - "\1\4\1\21\7\0\4\20\1\4\1\23\7\20"; - - private static int [] zzUnpackTrans() { - int [] result = new int[208]; - int offset = 0; - offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackTrans(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - value--; - do result[j++] = value; while (--count > 0); + + private static int zzUnpackAction(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; } - return j; - } - - - /* error codes */ - private static final int ZZ_UNKNOWN_ERROR = 0; - private static final int ZZ_NO_MATCH = 1; - private static final int ZZ_PUSHBACK_2BIG = 2; - - /* error messages for the codes above */ - private static final String ZZ_ERROR_MSG[] = { - "Unkown internal scanner error", - "Error: could not match input", - "Error: pushback value was too large" - }; - - /** - * ZZ_ATTRIBUTE[aState] contains the attributes of state aState - */ - private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); - - private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\1\0\1\11\1\1\1\11\7\1\3\0\1\1\2\0"+ - "\1\1\1\0"; - - private static int [] zzUnpackAttribute() { - int [] result = new int[19]; - int offset = 0; - offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAttribute(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); + + private static int[] zzUnpackRowMap() { + int[] result = new int[19]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; } - return j; - } - - /** the input device */ - private java.io.Reader zzReader; - - /** the current state of the DFA */ - private int zzState; - - /** the current lexical state */ - private int zzLexicalState = YYINITIAL; - - /** this buffer contains the current text to be matched and is - the source of the yytext() string */ - private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; - - /** the textposition at the last accepting state */ - private int zzMarkedPos; - - /** the textposition at the last state to be included in yytext */ - private int zzPushbackPos; - - /** the current text position in the buffer */ - private int zzCurrentPos; - - /** startRead marks the beginning of the yytext() string in the buffer */ - private int zzStartRead; - - /** endRead marks the last character in the buffer, that has been read - from input */ - private int zzEndRead; - - /** number of newlines encountered up to the start of the matched text */ - private int yyline; - - /** the number of characters up to the start of the matched text */ - private int yychar; - - /** - * the number of characters from the last newline up to the start of the - * matched text - */ - private int yycolumn; - - /** - * zzAtBOL == true <=> the scanner is currently at the beginning of a line - */ - private boolean zzAtBOL = true; - - /** zzAtEOF == true <=> the scanner is at the EOF */ - private boolean zzAtEOF; - - - /** - * Creates a new scanner - * There is also a java.io.InputStream version of this constructor. - * - * @param in the java.io.Reader to read input from. - */ - LogfileScanner(java.io.Reader in) { - this.zzReader = in; - } - - /** - * Creates a new scanner. - * There is also java.io.Reader version of this constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - LogfileScanner(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } - - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table - */ - private static char [] zzUnpackCMap(String packed) { - char [] map = new char[0x10000]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 54) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do map[j++] = value; while (--count > 0); + + private static int zzUnpackRowMap(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; } - return map; - } + private static int[] zzUnpackTrans() { + int[] result = new int[208]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } - /** - * Refills the input buffer. - * - * @return false, iff there was new input. - * - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean zzRefill() throws java.io.IOException { + private static int zzUnpackTrans(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + private static int[] zzUnpackAttribute() { + int[] result = new int[19]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char[] zzUnpackCMap(String packed) { + char[] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 54) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * @throws java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { /* first: make room (if you can) */ - if (zzStartRead > 0) { - System.arraycopy(zzBuffer, zzStartRead, - zzBuffer, 0, - zzEndRead-zzStartRead); + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead - zzStartRead); /* translate stored positions */ - zzEndRead-= zzStartRead; - zzCurrentPos-= zzStartRead; - zzMarkedPos-= zzStartRead; - zzPushbackPos-= zzStartRead; - zzStartRead = 0; - } + zzEndRead -= zzStartRead; + zzCurrentPos -= zzStartRead; + zzMarkedPos -= zzStartRead; + zzPushbackPos -= zzStartRead; + zzStartRead = 0; + } /* is the buffer big enough? */ - if (zzCurrentPos >= zzBuffer.length) { + if (zzCurrentPos >= zzBuffer.length) { /* if not: blow it up */ - char newBuffer[] = new char[zzCurrentPos*2]; - System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); - zzBuffer = newBuffer; - } + char newBuffer[] = new char[zzCurrentPos * 2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } /* finally: fill the buffer with new input */ - int numRead = zzReader.read(zzBuffer, zzEndRead, - zzBuffer.length-zzEndRead); + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length - zzEndRead); + + if (numRead < 0) { + return true; + } else { + zzEndRead += numRead; + return false; + } + } + - if (numRead < 0) { - return true; + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); } - else { - zzEndRead+= numRead; - return false; + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + *

+ * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to ZZ_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; } - } - - - /** - * Closes the input stream. - */ - public final void yyclose() throws java.io.IOException { - zzAtEOF = true; /* indicate end of file */ - zzEndRead = zzStartRead; /* invalidate buffer */ - - if (zzReader != null) - zzReader.close(); - } - - - /** - * Resets the scanner to read from a new input stream. - * Does not close the old reader. - * - * All internal variables are reset, the old input stream - * cannot be reused (internal buffer is discarded and lost). - * Lexical state is set to ZZ_INITIAL. - * - * @param reader the new input stream - */ - public final void yyreset(java.io.Reader reader) { - zzReader = reader; - zzAtBOL = true; - zzAtEOF = false; - zzEndRead = zzStartRead = 0; - zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; - yyline = yychar = yycolumn = 0; - zzLexicalState = YYINITIAL; - } - - - /** - * Returns the current lexical state. - */ - public final int yystate() { - return zzLexicalState; - } - - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - public final void yybegin(int newState) { - zzLexicalState = newState; - } - - - /** - * Returns the text matched by the current regular expression. - */ - public final String yytext() { - return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); - } - - - /** - * Returns the character at position pos from the - * matched text. - * - * It is equivalent to yytext().charAt(pos), but faster - * - * @param pos the position of the character to fetch. - * A value from 0 to yylength()-1. - * - * @return the character at position pos - */ - public final char yycharat(int pos) { - return zzBuffer[zzStartRead+pos]; - } - - - /** - * Returns the length of the matched text region. - */ - public final int yylength() { - return zzMarkedPos-zzStartRead; - } - - - /** - * Reports an error that occured while scanning. - * - * In a wellformed scanner (no or only correct usage of - * yypushback(int) and a match-all fallback rule) this method - * will only be called with things that "Can't Possibly Happen". - * If this method is called, something is seriously wrong - * (e.g. a JFlex bug producing a faulty scanner etc.). - * - * Usual syntax/scanner level error handling should be done - * in error fallback rules. - * - * @param errorCode the code of the errormessage to display - */ - private void zzScanError(int errorCode) { - String message; - try { - message = ZZ_ERROR_MSG[errorCode]; + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; } - catch (ArrayIndexOutOfBoundsException e) { - message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; } - throw new Error(message); - } + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); + } - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. - * This number must not be greater than yylength()! - */ - public void yypushback(int number) { - if ( number > yylength() ) - zzScanError(ZZ_PUSHBACK_2BIG); - zzMarkedPos -= number; - } + /** + * Returns the character at position pos from the + * matched text. + *

+ * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead + pos]; + } - /** - * Resumes scanning until the next regular expression is matched, - * the end of input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception java.io.IOException if any I/O-Error occurs - */ - public Object next_token() throws java.io.IOException { - int zzInput; - int zzAction; + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos - zzStartRead; + } - // cached fields: - int zzCurrentPosL; - int zzMarkedPosL; - int zzEndReadL = zzEndRead; - char [] zzBufferL = zzBuffer; - char [] zzCMapL = ZZ_CMAP; - int [] zzTransL = ZZ_TRANS; - int [] zzRowMapL = ZZ_ROWMAP; - int [] zzAttrL = ZZ_ATTRIBUTE; + /** + * Reports an error that occured while scanning. + *

+ * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + *

+ * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } - while (true) { - zzMarkedPosL = zzMarkedPos; + throw new Error(message); + } - zzAction = -1; - zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; - - zzState = zzLexicalState; + /** + * Pushes the specified amount of characters back into the input stream. + *

+ * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if (number > yylength()) + zzScanError(ZZ_PUSHBACK_2BIG); + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @throws java.io.IOException if any I/O-Error occurs + */ + public Object next_token() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char[] zzBufferL = zzBuffer; + char[] zzCMapL = ZZ_CMAP; + + int[] zzTransL = ZZ_TRANS; + int[] zzRowMapL = ZZ_ROWMAP; + int[] zzAttrL = ZZ_ATTRIBUTE; - zzForAction: { while (true) { - - if (zzCurrentPosL < zzEndReadL) - zzInput = zzBufferL[zzCurrentPosL++]; - else if (zzAtEOF) { - zzInput = YYEOF; - break zzForAction; - } - else { - // store back cached positions - zzCurrentPos = zzCurrentPosL; - zzMarkedPos = zzMarkedPosL; - boolean eof = zzRefill(); - // get translated positions and possibly new buffer - zzCurrentPosL = zzCurrentPos; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - zzEndReadL = zzEndRead; - if (eof) { - zzInput = YYEOF; - break zzForAction; + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = zzLexicalState; + + + zzForAction: + { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[zzRowMapL[zzState] + zzCMapL[zzInput]]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ((zzAttributes & 1) == 1) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ((zzAttributes & 8) == 8) break zzForAction; + } + + } } - else { - zzInput = zzBufferL[zzCurrentPosL++]; - } - } - int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; - if (zzNext == -1) break zzForAction; - zzState = zzNext; - - int zzAttributes = zzAttrL[zzState]; - if ( (zzAttributes & 1) == 1 ) { - zzAction = zzState; - zzMarkedPosL = zzCurrentPosL; - if ( (zzAttributes & 8) == 8 ) break zzForAction; - } + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 3: { + return yytext(); + } + case 6: + break; + case 4: { + return new Integer(yytext()); + } + case 7: + break; + case 2: { /* ignore */ + } + case 8: + break; + case 5: { + return new Double(yytext()); + } + case 9: + break; + case 1: { + throw new Error("Illegal character <" + + yytext() + ">"); + } + case 10: + break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + return null; + } else { + zzScanError(ZZ_NO_MATCH); + } + } } - } - - // store back cached position - zzMarkedPos = zzMarkedPosL; - - switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 3: - { return yytext(); - } - case 6: break; - case 4: - { return new Integer(yytext()); - } - case 7: break; - case 2: - { /* ignore */ - } - case 8: break; - case 5: - { return new Double(yytext()); - } - case 9: break; - case 1: - { throw new Error("Illegal character <"+ - yytext()+">"); - } - case 10: break; - default: - if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { - zzAtEOF = true; - return null; - } - else { - zzScanError(ZZ_NO_MATCH); - } - } } - } } diff --git a/src/main/java/net/freerouting/interactive/LogfileScope.java b/src/main/java/net/freerouting/interactive/LogfileScope.java index e87c5e06..2af718b2 100644 --- a/src/main/java/net/freerouting/interactive/LogfileScope.java +++ b/src/main/java/net/freerouting/interactive/LogfileScope.java @@ -27,19 +27,18 @@ * Enumeration class defining scopes in a logfile, * Each Object of the class must implement the read_scope method. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public abstract class LogfileScope -{ +public abstract class LogfileScope { /** * The only instances of the internal classes: */ - + // scpopes logging undo and redo public static final LogfileScope UNDO = new UndoScope("undo"); public static final LogfileScope REDO = new RedoScope("redo"); public static final LogfileScope GENERATE_SNAPSHOT = new GenerateSnapshotScope("generate_snapshot"); - + // Scopes for logging changes in the interactive setting: public static final LogfileScope SET_CLEARANCE_COMPENSATION = new SetClearanceCompensationScope("set_clearance_compensation"); public static final LogfileScope SET_DRAG_COMPONENTS_ENABLED = new SetDragComponentsEnabledScope("set_drag_componente_enabled"); @@ -56,7 +55,7 @@ public abstract class LogfileScope public static final LogfileScope SET_STITCH_ROUTE = new SetStitchRouteScope(" set_stitch_route"); public static final LogfileScope SET_TRACE_HALF_WIDTH = new SetTraceHalfWidthScope("set_trace_halfwidth"); public static final LogfileScope SET_IGNORE_CONDUCTION = new SetIgnoreConductionScope("set_ignore_conduction"); - + // scopes for logging changes in the interactively selected set of items: public static final LogfileScope START_SELECT = new StartSelectScope("start_select"); public static final LogfileScope TOGGLE_SELECT = new ToggleSelectScope("toggle_select"); @@ -65,10 +64,10 @@ public abstract class LogfileScope public static final LogfileScope EXTEND_TO_WHOLE_CONNECTIONS = new ExtendToWholeConnectionsScope("extend_to_whole_connections"); public static final LogfileScope EXTEND_TO_WHOLE_COMPONENTS = new ExtendToWholeComponentsScope("extend_to_whole_components"); public static final LogfileScope EXTEND_TO_WHOLE_NETS = new ExtendToWholeNetsScope("extend_to_whole_nets"); - + // scopes for logging actions on the interactively selected set of items: - public static final LogfileScope ASSIGN_CLEARANCE_CLASS = new AssignClearanceClassScope("assign_clearance_class"); - public static final LogfileScope ASSIGN_SELECTED_TO_NEW_NET = new AssignSelectedToNewNetScope("assign_selected_to_new_net"); + public static final LogfileScope ASSIGN_CLEARANCE_CLASS = new AssignClearanceClassScope("assign_clearance_class"); + public static final LogfileScope ASSIGN_SELECTED_TO_NEW_NET = new AssignSelectedToNewNetScope("assign_selected_to_new_net"); public static final LogfileScope ASSIGN_SELECTED_TO_NEW_GROUP = new AssignSelectedToNewGroupScope("assign_selected_to_new_group"); public static final LogfileScope FIX_SELECTED_ITEMS = new FixSelectedScope("fix_selected_items"); public static final LogfileScope UNFIX_SELECTED_ITEMS = new UnfixSelectedScope("unfix_selected_items"); @@ -77,7 +76,7 @@ public abstract class LogfileScope public static final LogfileScope OPTIMIZE_SELECTED = new OptimizeSelectedScope("optmize_selected"); public static final LogfileScope AUTOROUTE_SELECTED = new AutorouteSelectedScope("autoroute_selected"); public static final LogfileScope FANOUT_SELECTED = new FanoutSelectedScope("fanout_selected"); - + // scopes for logging interactive creating or moving items. public static final LogfileScope COMPLETE_SCOPE = new CompleteScope("complete_scope"); public static final LogfileScope CANCEL_SCOPE = new CancelScope("cancel_scope"); @@ -95,129 +94,111 @@ public abstract class LogfileScope public static final LogfileScope ROTATE = new RotateScope("rotate"); public static final LogfileScope CHANGE_PLACEMENT_SIDE = new ChangePlacementSideScope("change_placement_side"); public static final LogfileScope SET_ZOOM_WITH_WHEEL = new SetZoomWithWheelScope("set_zoom_with_wheel"); - + // scopes for logging displax changes public static final LogfileScope CENTER_DISPLAY = new CenterDisplayScope("center_display"); public static final LogfileScope ZOOM_FRAME = new ZoomFrameScope("zoom_frame"); - - - - + + /** * This array contains all (above) created objects of this class. * Initialializing this static array automatically by the program * did not work correctly, so the programmer has to keep it uptodate by hand. */ private static LogfileScope[] arr = - { - UNDO, REDO, GENERATE_SNAPSHOT, SET_CLEARANCE_COMPENSATION, SET_LAYER, SET_MANUAL_TRACE_CLEARANCE_CLASS, - SET_MANUAL_TRACE_HALF_WIDTH, SET_MANUAL_TRACEWITH_SELECTION, SET_SNAP_ANGLE, - SET_SELECTABLE, SET_SELECT_ON_ALL_LAYER, SET_STITCH_ROUTE, SET_TRACE_HALF_WIDTH, - SET_PULL_TIGHT_REGION_WIDTH, SET_PULL_TIGHT_ACCURACY, SET_PUSH_ENABLED, SET_IGNORE_CONDUCTION, - START_SELECT, TOGGLE_SELECT, SELECT_REGION, EXTEND_TO_WHOLE_CONNECTED_SETS, - EXTEND_TO_WHOLE_CONNECTIONS, EXTEND_TO_WHOLE_COMPONENTS, EXTEND_TO_WHOLE_NETS, - ASSIGN_SELECTED_TO_NEW_NET, ASSIGN_SELECTED_TO_NEW_GROUP, FIX_SELECTED_ITEMS, - UNFIX_SELECTED_ITEMS, DELETE_SELECTED, CUTOUT_ROUTE, OPTIMIZE_SELECTED, AUTOROUTE_SELECTED, - FANOUT_SELECTED, COMPLETE_SCOPE, CANCEL_SCOPE, CREATING_TILE, CREATING_CIRCLE, CREATING_POLYGONSHAPE, - ADDING_HOLE, CREATING_TRACE, CHANGE_LAYER, DRAGGING_ITEMS, MAKING_SPACE, COPYING_ITEMS, - MOVE_ITEMS, TURN_90_DEGREE, ROTATE, CHANGE_PLACEMENT_SIDE, SET_ZOOM_WITH_WHEEL, - ASSIGN_CLEARANCE_CLASS, CENTER_DISPLAY, ZOOM_FRAME - }; - + { + UNDO, REDO, GENERATE_SNAPSHOT, SET_CLEARANCE_COMPENSATION, SET_LAYER, SET_MANUAL_TRACE_CLEARANCE_CLASS, + SET_MANUAL_TRACE_HALF_WIDTH, SET_MANUAL_TRACEWITH_SELECTION, SET_SNAP_ANGLE, + SET_SELECTABLE, SET_SELECT_ON_ALL_LAYER, SET_STITCH_ROUTE, SET_TRACE_HALF_WIDTH, + SET_PULL_TIGHT_REGION_WIDTH, SET_PULL_TIGHT_ACCURACY, SET_PUSH_ENABLED, SET_IGNORE_CONDUCTION, + START_SELECT, TOGGLE_SELECT, SELECT_REGION, EXTEND_TO_WHOLE_CONNECTED_SETS, + EXTEND_TO_WHOLE_CONNECTIONS, EXTEND_TO_WHOLE_COMPONENTS, EXTEND_TO_WHOLE_NETS, + ASSIGN_SELECTED_TO_NEW_NET, ASSIGN_SELECTED_TO_NEW_GROUP, FIX_SELECTED_ITEMS, + UNFIX_SELECTED_ITEMS, DELETE_SELECTED, CUTOUT_ROUTE, OPTIMIZE_SELECTED, AUTOROUTE_SELECTED, + FANOUT_SELECTED, COMPLETE_SCOPE, CANCEL_SCOPE, CREATING_TILE, CREATING_CIRCLE, CREATING_POLYGONSHAPE, + ADDING_HOLE, CREATING_TRACE, CHANGE_LAYER, DRAGGING_ITEMS, MAKING_SPACE, COPYING_ITEMS, + MOVE_ITEMS, TURN_90_DEGREE, ROTATE, CHANGE_PLACEMENT_SIDE, SET_ZOOM_WITH_WHEEL, + ASSIGN_CLEARANCE_CLASS, CENTER_DISPLAY, ZOOM_FRAME + }; + public final String name; + /** - * Reads the scope from the input logfile. - * Returns the active interactive state after reading the scope. + * prevents creating more instances */ - public abstract InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling); - + private LogfileScope(String p_name) { + name = p_name; + } + /** * Returns the LogfileScope with name p_name if it exists, else null. */ - public static LogfileScope get_scope(String p_name) - { - for (int i = 0; i < arr.length; ++i) - { - if (arr[i].name.compareTo(p_name) == 0) - { + public static LogfileScope get_scope(String p_name) { + for (int i = 0; i < arr.length; ++i) { + if (arr[i].name.compareTo(p_name) == 0) { return arr[i]; } } return null; } - - /** prevents creating more instances */ - private LogfileScope(String p_name) - { - name = p_name; - } - + + /** + * Reads the scope from the input logfile. + * Returns the active interactive state after reading the scope. + */ + public abstract InteractiveState read_scope(Logfile p_logfile, + InteractiveState p_return_state, BoardHandling p_board_handling); + /** * Scopes marking the end of a cornerlist scope. */ - private boolean is_end_scope() - { + private boolean is_end_scope() { return this == COMPLETE_SCOPE || this == CANCEL_SCOPE; } - - public final String name; - + /** * A logfile scope containing a list of points. */ - private static abstract class CornerlistScope extends LogfileScope - { - public CornerlistScope(String p_name) - { - super( p_name); + private static abstract class CornerlistScope extends LogfileScope { + public CornerlistScope(String p_name) { + super(p_name); } - + /** * Reads the next corner list scope togethet with its * interiour scopes (layer change for example) from the input logfile. * Returns the active interactive state after reading the scope. */ - public InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + public InteractiveState read_scope(Logfile p_logfile, + InteractiveState p_return_state, BoardHandling p_board_handling) { FloatPoint location = p_logfile.read_corner(); - if (location == null) - { + if (location == null) { return null; } InteractiveState interactive_state = this.start_scope(location, p_return_state, p_board_handling); - if (interactive_state == null) - { + if (interactive_state == null) { return null; } p_board_handling.interactive_state = interactive_state; InteractiveState return_state = p_return_state; - for (;;) - { + for (; ; ) { location = p_logfile.read_corner(); - if (location != null) - { + if (location != null) { // process corner list InteractiveState new_state = interactive_state.process_logfile_point(location); - if (new_state != interactive_state) - { + if (new_state != interactive_state) { // state ended return_state = new_state; break; } - } - else - { + } else { // end of corner list, process the next interiour scope LogfileScope next_scope = p_logfile.start_read_scope(); - if (next_scope == null) - { + if (next_scope == null) { break; // end of logfile } InteractiveState new_state = next_scope.read_scope(p_logfile, interactive_state, p_board_handling); - if(next_scope.is_end_scope()) - { + if (next_scope.is_end_scope()) { return_state = new_state; break; } @@ -225,361 +206,288 @@ public InteractiveState read_scope(Logfile p_logfile, } return return_state; } - + /** * Used for beginning a new CornerlistScope. */ - public abstract InteractiveState start_scope( FloatPoint p_location, - InteractiveState p_return_state, BoardHandling p_board_handling); + public abstract InteractiveState start_scope(FloatPoint p_location, + InteractiveState p_return_state, BoardHandling p_board_handling); } - - private static class CreateTraceScope extends CornerlistScope - { - public CreateTraceScope(String p_name) - { - super( p_name); - } - - public InteractiveState start_scope( FloatPoint p_location, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class CreateTraceScope extends CornerlistScope { + public CreateTraceScope(String p_name) { + super(p_name); + } + + public InteractiveState start_scope(FloatPoint p_location, + InteractiveState p_return_state, BoardHandling p_board_handling) { return RouteState.get_instance(p_location, p_return_state, p_board_handling, null); } } - - private static class CreateTileScope extends CornerlistScope - { - public CreateTileScope(String p_name) - { - super( p_name); - } - - public InteractiveState start_scope( FloatPoint p_location, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class CreateTileScope extends CornerlistScope { + public CreateTileScope(String p_name) { + super(p_name); + } + + public InteractiveState start_scope(FloatPoint p_location, + InteractiveState p_return_state, BoardHandling p_board_handling) { return TileConstructionState.get_instance(p_location, p_return_state, p_board_handling, null); } } - - private static class CreateCircleScope extends CornerlistScope - { - public CreateCircleScope(String p_name) - { - super( p_name); - } - - public InteractiveState start_scope( FloatPoint p_location, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class CreateCircleScope extends CornerlistScope { + public CreateCircleScope(String p_name) { + super(p_name); + } + + public InteractiveState start_scope(FloatPoint p_location, + InteractiveState p_return_state, BoardHandling p_board_handling) { return CircleConstructionState.get_instance(p_location, p_return_state, p_board_handling, null); } } - - private static class CreatePolygonShapeScope extends CornerlistScope - { - public CreatePolygonShapeScope(String p_name) - { - super( p_name); - } - - public InteractiveState start_scope( FloatPoint p_location, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class CreatePolygonShapeScope extends CornerlistScope { + public CreatePolygonShapeScope(String p_name) { + super(p_name); + } + + public InteractiveState start_scope(FloatPoint p_location, + InteractiveState p_return_state, BoardHandling p_board_handling) { return PolygonShapeConstructionState.get_instance(p_location, p_return_state, p_board_handling, null); } } - - private static class AddHoleScope extends CornerlistScope - { - public AddHoleScope(String p_name) - { - super( p_name); - } - - public InteractiveState start_scope( FloatPoint p_location, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class AddHoleScope extends CornerlistScope { + public AddHoleScope(String p_name) { + super(p_name); + } + + public InteractiveState start_scope(FloatPoint p_location, + InteractiveState p_return_state, BoardHandling p_board_handling) { return HoleConstructionState.get_instance(p_location, p_return_state, p_board_handling, null); } } - - private static class DragItemScope extends CornerlistScope - { - public DragItemScope(String p_name) - { - super( p_name); - } - - public InteractiveState start_scope( FloatPoint p_location, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class DragItemScope extends CornerlistScope { + public DragItemScope(String p_name) { + super(p_name); + } + + public InteractiveState start_scope(FloatPoint p_location, + InteractiveState p_return_state, BoardHandling p_board_handling) { return DragItemState.get_instance(p_location, p_return_state, p_board_handling, null); } } - - private static class MakeSpaceScope extends CornerlistScope - { - public MakeSpaceScope(String p_name) - { - super( p_name); - } - - public InteractiveState start_scope( FloatPoint p_location, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class MakeSpaceScope extends CornerlistScope { + public MakeSpaceScope(String p_name) { + super(p_name); + } + + public InteractiveState start_scope(FloatPoint p_location, + InteractiveState p_return_state, BoardHandling p_board_handling) { return MakeSpaceState.get_instance(p_location, p_return_state, p_board_handling, null); } } - - private static class CopyItemScope extends CornerlistScope - { - public CopyItemScope(String p_name) - { - super( p_name); - } - - public InteractiveState start_scope( FloatPoint p_location, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class CopyItemScope extends CornerlistScope { + public CopyItemScope(String p_name) { + super(p_name); + } + + public InteractiveState start_scope(FloatPoint p_location, + InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState result; - if (p_return_state instanceof SelectedItemState) - { + if (p_return_state instanceof SelectedItemState) { java.util.Collection item_list = ((SelectedItemState) p_return_state).get_item_list(); - result = CopyItemState.get_instance(p_location, item_list, p_return_state.return_state, p_board_handling, null); - } - else - { + result = CopyItemState.get_instance(p_location, item_list, p_return_state.return_state, p_board_handling, null); + } else { System.out.println("CopyItemScope.start_scope: unexpected p_return_state"); result = null; - + } return result; } } - - private static class MoveItemScope extends CornerlistScope - { - public MoveItemScope(String p_name) - { - super( p_name); - } - - public InteractiveState start_scope( FloatPoint p_location, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class MoveItemScope extends CornerlistScope { + public MoveItemScope(String p_name) { + super(p_name); + } + + public InteractiveState start_scope(FloatPoint p_location, + InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState result; - if (p_return_state instanceof SelectedItemState) - { + if (p_return_state instanceof SelectedItemState) { java.util.Collection item_list = ((SelectedItemState) p_return_state).get_item_list(); - result = MoveItemState.get_instance(p_location, item_list, p_return_state.return_state, p_board_handling, null); - } - else - { + result = MoveItemState.get_instance(p_location, item_list, p_return_state.return_state, p_board_handling, null); + } else { System.out.println("MoveComponent.start_scope: unexpected p_return_state"); result = null; - + } return result; } - + public InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState new_state = super.read_scope(p_logfile, p_return_state, p_board_handling); - if (new_state == null) - { + if (new_state == null) { return null; } return new_state.return_state; } } - - private static class Turn90DegreeScope extends LogfileScope - { - public Turn90DegreeScope(String p_name) - { - super( p_name); - } - + + private static class Turn90DegreeScope extends LogfileScope { + public Turn90DegreeScope(String p_name) { + super(p_name); + } + public InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling) - { - if (p_return_state instanceof MoveItemState) - { + InteractiveState p_return_state, BoardHandling p_board_handling) { + if (p_return_state instanceof MoveItemState) { int factor = p_logfile.read_int(); - ((MoveItemState)p_return_state).turn_90_degree(factor); + ((MoveItemState) p_return_state).turn_90_degree(factor); return p_return_state; } - + System.out.println("Turn90DegreeScope.read_scope: unexpected p_return_state"); return null; } } - - private static class RotateScope extends LogfileScope - { - public RotateScope(String p_name) - { - super( p_name); - } - + + private static class RotateScope extends LogfileScope { + public RotateScope(String p_name) { + super(p_name); + } + public InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling) - { - if (p_return_state instanceof MoveItemState) - { + InteractiveState p_return_state, BoardHandling p_board_handling) { + if (p_return_state instanceof MoveItemState) { int angle = p_logfile.read_int(); - ((MoveItemState)p_return_state).rotate(angle); + ((MoveItemState) p_return_state).rotate(angle); return p_return_state; } - + System.out.println("RotateScope.read_scope: unexpected p_return_state"); return null; } } - - private static class ChangePlacementSideScope extends LogfileScope - { - public ChangePlacementSideScope(String p_name) - { - super( p_name); - } - + + private static class ChangePlacementSideScope extends LogfileScope { + public ChangePlacementSideScope(String p_name) { + super(p_name); + } + public InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling) - { - if (p_return_state instanceof MoveItemState) - { - ((MoveItemState)p_return_state).change_placement_side(); + InteractiveState p_return_state, BoardHandling p_board_handling) { + if (p_return_state instanceof MoveItemState) { + ((MoveItemState) p_return_state).change_placement_side(); return p_return_state; } - + System.out.println("ChangePlacementSideScope.read_scope: unexpected p_return_state"); return null; } } - - private static class SetZoomWithWheelScope extends LogfileScope - { - public SetZoomWithWheelScope(String p_name) - { - super( p_name); - } - + + private static class SetZoomWithWheelScope extends LogfileScope { + public SetZoomWithWheelScope(String p_name) { + super(p_name); + } + public InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling) - { - if (p_return_state instanceof MoveItemState) - { + InteractiveState p_return_state, BoardHandling p_board_handling) { + if (p_return_state instanceof MoveItemState) { int int_value = p_logfile.read_int(); - if (int_value == 0) - { + if (int_value == 0) { p_board_handling.settings.set_zoom_with_wheel(false); - } - else - { + } else { p_board_handling.settings.set_zoom_with_wheel(true); } return p_return_state; } - + System.out.println("SetRotateWithWheelScope.read_scope: unexpected p_return_state"); return null; } } - - private static class ChangeLayerScope extends LogfileScope - { - public ChangeLayerScope(String p_name) - { - super( p_name); - } - + + private static class ChangeLayerScope extends LogfileScope { + public ChangeLayerScope(String p_name) { + super(p_name); + } + public InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling) - { + InteractiveState p_return_state, BoardHandling p_board_handling) { int new_layer = p_logfile.read_int(); p_return_state.change_layer_action(new_layer); return p_return_state; } } - - private static class StartSelectScope extends LogfileScope - { - public StartSelectScope(String p_name) - { - super( p_name); - } - + + private static class StartSelectScope extends LogfileScope { + public StartSelectScope(String p_name) { + super(p_name); + } + public InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling) - { - while (!(p_return_state instanceof MenuState)) - { + InteractiveState p_return_state, BoardHandling p_board_handling) { + while (!(p_return_state instanceof MenuState)) { System.out.println("StartSelectScope.read_scope: menu state expected"); p_return_state = p_return_state.return_state; } FloatPoint location = p_logfile.read_corner(); - if (location == null) - { + if (location == null) { System.out.println("StartSelectScope.read_scope: unable to read corner"); return null; } return ((MenuState) p_return_state).select_items(location); } } - - private static class ToggleSelectScope extends LogfileScope - { - public ToggleSelectScope(String p_name) - { - super( p_name); - } - + + private static class ToggleSelectScope extends LogfileScope { + public ToggleSelectScope(String p_name) { + super(p_name); + } + public InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling) - { - if (!(p_return_state instanceof SelectedItemState)) - { + InteractiveState p_return_state, BoardHandling p_board_handling) { + if (!(p_return_state instanceof SelectedItemState)) { System.out.println("ToggleSelectScope.read_scope: SelectedItemState expected"); return null; } FloatPoint location = p_logfile.read_corner(); - if (location == null) - { + if (location == null) { System.out.println("ToggleSelectScope.read_scope: unable to read corner"); return null; } - return ((SelectedItemState)p_return_state).toggle_select(location); + return ((SelectedItemState) p_return_state).toggle_select(location); } } - - private static class SelectRegionScope extends LogfileScope - { - public SelectRegionScope(String p_name) - { - super( p_name); - } - + + private static class SelectRegionScope extends LogfileScope { + public SelectRegionScope(String p_name) { + super(p_name); + } + public InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling) - { - if (!(p_return_state instanceof MenuState)) - { + InteractiveState p_return_state, BoardHandling p_board_handling) { + if (!(p_return_state instanceof MenuState)) { System.out.println("SelectRegionScope.read_scope: menu state expected"); } FloatPoint lower_left = p_logfile.read_corner(); - if (lower_left == null) - { + if (lower_left == null) { System.out.println("SelectRegionScope.read_scope: unable to read corner"); return null; } InteractiveState curr_state = SelectItemsInRegionState.get_instance(lower_left, p_return_state, p_board_handling, null); FloatPoint upper_right = p_logfile.read_corner(); - if (upper_right == null) - { + if (upper_right == null) { // user may have cancelled the state after the first corner return curr_state; } @@ -587,33 +495,27 @@ public InteractiveState read_scope(Logfile p_logfile, return curr_state.complete(); } } - - private static class CutoutRouteScope extends LogfileScope - { - public CutoutRouteScope(String p_name) - { - super( p_name); - } - + + private static class CutoutRouteScope extends LogfileScope { + public CutoutRouteScope(String p_name) { + super(p_name); + } + public InteractiveState read_scope(Logfile p_logfile, - InteractiveState p_return_state, BoardHandling p_board_handling) - { - if (!(p_return_state instanceof SelectedItemState)) - { + InteractiveState p_return_state, BoardHandling p_board_handling) { + if (!(p_return_state instanceof SelectedItemState)) { System.out.println("CutoutRouteScope.read_scope: electedItemState expected"); } java.util.Collection item_list = ((SelectedItemState) p_return_state).get_item_list(); FloatPoint lower_left = p_logfile.read_corner(); - if (lower_left == null) - { + if (lower_left == null) { System.out.println("CutoutRouteScope.read_scope: unable to read corner"); return null; } InteractiveState curr_state = CutoutRouteState.get_instance(item_list, lower_left, p_return_state.return_state, p_board_handling, null); FloatPoint upper_right = p_logfile.read_corner(); - if (upper_right == null) - { + if (upper_right == null) { // user may have cancelled the state after the first corner return curr_state; } @@ -621,681 +523,521 @@ public InteractiveState read_scope(Logfile p_logfile, return curr_state.complete(); } } - - private static class DeleteSelectedScope extends LogfileScope - { - public DeleteSelectedScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class DeleteSelectedScope extends LogfileScope { + public DeleteSelectedScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState result; - - if (p_return_state instanceof SelectedItemState) - { - result = ((SelectedItemState)p_return_state).delete_items(); - } - else - { + + if (p_return_state instanceof SelectedItemState) { + result = ((SelectedItemState) p_return_state).delete_items(); + } else { System.out.println("DeleteSelectedScope.read_scope: SelectedItemState expected"); result = null; } return result; } } - - private static class OptimizeSelectedScope extends LogfileScope - { - public OptimizeSelectedScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class OptimizeSelectedScope extends LogfileScope { + public OptimizeSelectedScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState result; - - if (p_return_state instanceof SelectedItemState) - { - result = ((SelectedItemState)p_return_state).pull_tight(null); - } - else - { + + if (p_return_state instanceof SelectedItemState) { + result = ((SelectedItemState) p_return_state).pull_tight(null); + } else { System.out.println("DeleteSelectedScope.read_scope: SelectedItemState expected"); result = null; } return result; } } - - private static class AutorouteSelectedScope extends LogfileScope - { - public AutorouteSelectedScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class AutorouteSelectedScope extends LogfileScope { + public AutorouteSelectedScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState result; - - if (p_return_state instanceof SelectedItemState) - { - result = ((SelectedItemState)p_return_state).autoroute(null); - } - else - { + + if (p_return_state instanceof SelectedItemState) { + result = ((SelectedItemState) p_return_state).autoroute(null); + } else { System.out.println("AutorouteSelectedScope.read_scope: SelectedItemState expected"); result = null; } return result; } } - - private static class FanoutSelectedScope extends LogfileScope - { - public FanoutSelectedScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class FanoutSelectedScope extends LogfileScope { + public FanoutSelectedScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState result; - - if (p_return_state instanceof SelectedItemState) - { - result = ((SelectedItemState)p_return_state).fanout(null); - } - else - { + + if (p_return_state instanceof SelectedItemState) { + result = ((SelectedItemState) p_return_state).fanout(null); + } else { System.out.println("FanoutSelectedScope.read_scope: SelectedItemState expected"); result = null; } return result; } } - + /** * Scope calling the single method SelectedItemState.assign_clearance_class */ - private static class AssignClearanceClassScope extends LogfileScope - { - public AssignClearanceClassScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + private static class AssignClearanceClassScope extends LogfileScope { + public AssignClearanceClassScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState result; - - if (p_return_state instanceof SelectedItemState) - { + + if (p_return_state instanceof SelectedItemState) { int int_value = p_logfile.read_int(); - result = ((SelectedItemState)p_return_state).assign_clearance_class(int_value); - } - else - { + result = ((SelectedItemState) p_return_state).assign_clearance_class(int_value); + } else { System.out.println("AssignSelectedToNewNetScope.read_scope: SelectedItemState expected"); result = null; } return result; } } - - + + /** * Scope calling the single method SelectedItemState.assign_items_to_new_net */ - private static class AssignSelectedToNewNetScope extends LogfileScope - { - public AssignSelectedToNewNetScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + private static class AssignSelectedToNewNetScope extends LogfileScope { + public AssignSelectedToNewNetScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState result; - - if (p_return_state instanceof SelectedItemState) - { - result = ((SelectedItemState)p_return_state).assign_items_to_new_net(); - } - else - { + + if (p_return_state instanceof SelectedItemState) { + result = ((SelectedItemState) p_return_state).assign_items_to_new_net(); + } else { System.out.println("AssignSelectedToNewNetScope.read_scope: SelectedItemState expected"); result = null; } return result; } } - + /** * Scope calling the single method SelectedItemState.assign_items_to_new_group */ - private static class AssignSelectedToNewGroupScope extends LogfileScope - { - public AssignSelectedToNewGroupScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + private static class AssignSelectedToNewGroupScope extends LogfileScope { + public AssignSelectedToNewGroupScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState result; - - if (p_return_state instanceof SelectedItemState) - { - result = ((SelectedItemState)p_return_state).assign_items_to_new_group(); - } - else - { + + if (p_return_state instanceof SelectedItemState) { + result = ((SelectedItemState) p_return_state).assign_items_to_new_group(); + } else { System.out.println("AssignSelectedToNewGroupScope.read_scope: SelectedItemState expected"); result = null; } return result; } } - - private static class ExtendToWholeConnectedSetsScope extends LogfileScope - { - public ExtendToWholeConnectedSetsScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class ExtendToWholeConnectedSetsScope extends LogfileScope { + public ExtendToWholeConnectedSetsScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState return_state = null; - if (p_return_state instanceof SelectedItemState) - { - return_state = ((SelectedItemState)p_return_state).extent_to_whole_connected_sets(); - } - else - { + if (p_return_state instanceof SelectedItemState) { + return_state = ((SelectedItemState) p_return_state).extent_to_whole_connected_sets(); + } else { System.out.println("ExtendToWholeConnectedSetsScope.read_scope: SelectedItemState expected"); } return return_state; } } - - private static class ExtendToWholeComponentsScope extends LogfileScope - { - public ExtendToWholeComponentsScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class ExtendToWholeComponentsScope extends LogfileScope { + public ExtendToWholeComponentsScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState return_state = null; - if (p_return_state instanceof SelectedItemState) - { - return_state = ((SelectedItemState)p_return_state).extent_to_whole_components(); - } - else - { + if (p_return_state instanceof SelectedItemState) { + return_state = ((SelectedItemState) p_return_state).extent_to_whole_components(); + } else { System.out.println("ExtendToWholeGroupsScope.read_scope: SelectedItemState expected"); } return return_state; } } - - private static class ExtendToWholeNetsScope extends LogfileScope - { - public ExtendToWholeNetsScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class ExtendToWholeNetsScope extends LogfileScope { + public ExtendToWholeNetsScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState return_state = null; - if (p_return_state instanceof SelectedItemState) - { - return_state = ((SelectedItemState)p_return_state).extent_to_whole_nets(); - } - else - { + if (p_return_state instanceof SelectedItemState) { + return_state = ((SelectedItemState) p_return_state).extent_to_whole_nets(); + } else { System.out.println("ExtendToWholeNetsScope.read_scope: SelectedItemState expected"); } return return_state; } } - - private static class ExtendToWholeConnectionsScope extends LogfileScope - { - public ExtendToWholeConnectionsScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class ExtendToWholeConnectionsScope extends LogfileScope { + public ExtendToWholeConnectionsScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { InteractiveState return_state = null; - if (p_return_state instanceof SelectedItemState) - { - return_state = ((SelectedItemState)p_return_state).extent_to_whole_connections(); - } - else - { + if (p_return_state instanceof SelectedItemState) { + return_state = ((SelectedItemState) p_return_state).extent_to_whole_connections(); + } else { System.out.println("ExtendToWholeConnectionsScope.read_scope: SelectedItemState expected"); } return return_state; } } - - private static class FixSelectedScope extends LogfileScope - { - public FixSelectedScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { - if (p_return_state instanceof SelectedItemState) - { - ((SelectedItemState)p_return_state).fix_items(); - } - else - { + + private static class FixSelectedScope extends LogfileScope { + public FixSelectedScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { + if (p_return_state instanceof SelectedItemState) { + ((SelectedItemState) p_return_state).fix_items(); + } else { System.out.println("FixSelectedScope.read_scope: SelectedItemState expected"); } return p_return_state; } } - - private static class UnfixSelectedScope extends LogfileScope - { - public UnfixSelectedScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { - if (p_return_state instanceof SelectedItemState) - { - ((SelectedItemState)p_return_state).unfix_items(); - } - else - { + + private static class UnfixSelectedScope extends LogfileScope { + public UnfixSelectedScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { + if (p_return_state instanceof SelectedItemState) { + ((SelectedItemState) p_return_state).unfix_items(); + } else { System.out.println("UnfixSelectedScope.read_scope: SelectedItemState expected"); } return p_return_state; } } - - private static class CompleteScope extends LogfileScope - { - public CompleteScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class CompleteScope extends LogfileScope { + public CompleteScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { return p_return_state.complete(); } } - - private static class CancelScope extends LogfileScope - { - public CancelScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class CancelScope extends LogfileScope { + public CancelScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { return p_return_state.cancel(); } } - - private static class SetTraceHalfWidthScope extends LogfileScope - { - public SetTraceHalfWidthScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetTraceHalfWidthScope extends LogfileScope { + public SetTraceHalfWidthScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int layer = p_logfile.read_int(); int new_half_width = p_logfile.read_int(); p_board_handling.get_routing_board().rules.set_default_trace_half_width(layer, new_half_width); return p_return_state; } } - - private static class SetPullTightRegionWidthScope extends LogfileScope - { - public SetPullTightRegionWidthScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetPullTightRegionWidthScope extends LogfileScope { + public SetPullTightRegionWidthScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int new_tidy_width = p_logfile.read_int(); p_board_handling.settings.trace_pull_tight_region_width = new_tidy_width; return p_return_state; } } - - private static class SetPushEnabledScope extends LogfileScope - { - public SetPushEnabledScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetPushEnabledScope extends LogfileScope { + public SetPushEnabledScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int int_value = p_logfile.read_int(); - if ( int_value == 0) - { + if (int_value == 0) { p_board_handling.settings.push_enabled = false; - } - else - { + } else { p_board_handling.settings.push_enabled = true; } return p_return_state; } } - - private static class SetDragComponentsEnabledScope extends LogfileScope - { - public SetDragComponentsEnabledScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetDragComponentsEnabledScope extends LogfileScope { + public SetDragComponentsEnabledScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int int_value = p_logfile.read_int(); - if ( int_value == 0) - { + if (int_value == 0) { p_board_handling.settings.drag_components_enabled = false; - } - else - { + } else { p_board_handling.settings.drag_components_enabled = true; } return p_return_state; } } - - private static class SetPullTightAccuracyScope extends LogfileScope - { - public SetPullTightAccuracyScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetPullTightAccuracyScope extends LogfileScope { + public SetPullTightAccuracyScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int new_accuracy = p_logfile.read_int(); p_board_handling.settings.trace_pull_tight_accuracy = new_accuracy; return p_return_state; } } - - private static class SetIgnoreConductionScope extends LogfileScope - { - public SetIgnoreConductionScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetIgnoreConductionScope extends LogfileScope { + public SetIgnoreConductionScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int int_value = p_logfile.read_int(); p_board_handling.get_routing_board().change_conduction_is_obstacle(int_value == 0); return p_return_state; } } - - private static class SetLayerScope extends LogfileScope - { - public SetLayerScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetLayerScope extends LogfileScope { + public SetLayerScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int new_layer = p_logfile.read_int(); p_board_handling.set_layer(new_layer); return p_return_state; } } - - private static class SetClearanceCompensationScope extends LogfileScope - { - public SetClearanceCompensationScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetClearanceCompensationScope extends LogfileScope { + public SetClearanceCompensationScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int new_clearance_type = p_logfile.read_int(); - if (new_clearance_type == 0) - { + if (new_clearance_type == 0) { p_board_handling.get_routing_board().search_tree_manager.set_clearance_compensation_used(false); - } - else - { + } else { p_board_handling.get_routing_board().search_tree_manager.set_clearance_compensation_used(true); } return p_return_state; } } - - private static class SetManualTraceHalfWidthScope extends LogfileScope - { - public SetManualTraceHalfWidthScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetManualTraceHalfWidthScope extends LogfileScope { + public SetManualTraceHalfWidthScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int layer = p_logfile.read_int(); int half_width = p_logfile.read_int(); p_board_handling.settings.manual_trace_half_width_arr[layer] = half_width; return p_return_state; } } - - private static class SetManualTraceClearanceClassScope extends LogfileScope - { - public SetManualTraceClearanceClassScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetManualTraceClearanceClassScope extends LogfileScope { + public SetManualTraceClearanceClassScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int index = p_logfile.read_int(); p_board_handling.settings.manual_trace_clearance_class = index; return p_return_state; } } - - private static class SetManualTraceWidthSelectionScope extends LogfileScope - { - public SetManualTraceWidthSelectionScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetManualTraceWidthSelectionScope extends LogfileScope { + public SetManualTraceWidthSelectionScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int manual_selection = p_logfile.read_int(); - if ( manual_selection == 0) - { + if (manual_selection == 0) { p_board_handling.settings.manual_rule_selection = false; - } - else - { + } else { p_board_handling.settings.manual_rule_selection = true; } return p_return_state; } } - - private static class SetSnapAngleScope extends LogfileScope - { - public SetSnapAngleScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetSnapAngleScope extends LogfileScope { + public SetSnapAngleScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int new_snap_angle_no = p_logfile.read_int(); p_board_handling.get_routing_board().rules.set_trace_angle_restriction(net.freerouting.board.AngleRestriction.arr[new_snap_angle_no]); return p_return_state; } } - - private static class SetSelectOnAllLayerScope extends LogfileScope - { - public SetSelectOnAllLayerScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetSelectOnAllLayerScope extends LogfileScope { + public SetSelectOnAllLayerScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int new_value = p_logfile.read_int(); p_board_handling.settings.select_on_all_visible_layers = (new_value != 0); return p_return_state; } } - - private static class SetStitchRouteScope extends LogfileScope - { - public SetStitchRouteScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class SetStitchRouteScope extends LogfileScope { + public SetStitchRouteScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int new_value = p_logfile.read_int(); p_board_handling.settings.is_stitch_route = (new_value != 0); return p_return_state; } } - - - private static class SetSelectableScope extends LogfileScope - { - public SetSelectableScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + + private static class SetSelectableScope extends LogfileScope { + public SetSelectableScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { int item_type_no = p_logfile.read_int(); int selection = p_logfile.read_int(); net.freerouting.board.ItemSelectionFilter.SelectableChoices item_type = net.freerouting.board.ItemSelectionFilter.SelectableChoices.values()[item_type_no]; - if (selection == 0) - { + if (selection == 0) { p_board_handling.settings.item_selection_filter.set_selected(item_type, false); - if (p_return_state instanceof SelectedItemState) - { + if (p_return_state instanceof SelectedItemState) { ((SelectedItemState) p_return_state).filter(); } - } - else - { + } else { p_board_handling.settings.item_selection_filter.set_selected(item_type, true); } return p_return_state; } } - - - private static class UndoScope extends LogfileScope - { - public UndoScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + + private static class UndoScope extends LogfileScope { + public UndoScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { p_board_handling.get_routing_board().undo(null); p_board_handling.repaint(); return p_return_state; } } - - private static class RedoScope extends LogfileScope - { - public RedoScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class RedoScope extends LogfileScope { + public RedoScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { p_board_handling.get_routing_board().redo(null); p_board_handling.repaint(); return p_return_state; } } - - private static class GenerateSnapshotScope extends LogfileScope - { - public GenerateSnapshotScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class GenerateSnapshotScope extends LogfileScope { + public GenerateSnapshotScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { p_board_handling.get_routing_board().generate_snapshot(); return p_return_state; } } - - private static class CenterDisplayScope extends LogfileScope - { - public CenterDisplayScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class CenterDisplayScope extends LogfileScope { + public CenterDisplayScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { FloatPoint curr_location = p_logfile.read_corner(); java.awt.geom.Point2D new_center = new java.awt.geom.Point2D.Double(curr_location.x, curr_location.y); p_board_handling.get_panel().center_display(new_center); return p_return_state; } } - - private static class ZoomFrameScope extends LogfileScope - { - public ZoomFrameScope(String p_name) - { - super( p_name); - } - - public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) - { + + private static class ZoomFrameScope extends LogfileScope { + public ZoomFrameScope(String p_name) { + super(p_name); + } + + public InteractiveState read_scope(Logfile p_logfile, InteractiveState p_return_state, BoardHandling p_board_handling) { java.awt.geom.Point2D lower_left = p_board_handling.graphics_context.coordinate_transform.board_to_screen(p_logfile.read_corner()); java.awt.geom.Point2D upper_right = p_board_handling.graphics_context.coordinate_transform.board_to_screen(p_logfile.read_corner()); diff --git a/src/main/java/net/freerouting/interactive/MakeSpaceState.java b/src/main/java/net/freerouting/interactive/MakeSpaceState.java index e4448cbc..0f77bac5 100644 --- a/src/main/java/net/freerouting/interactive/MakeSpaceState.java +++ b/src/main/java/net/freerouting/interactive/MakeSpaceState.java @@ -20,55 +20,52 @@ package net.freerouting.interactive; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.Point; import net.freerouting.board.AngleRestriction; import net.freerouting.board.BasicBoard; +import net.freerouting.geometry.planar.FloatPoint; +import net.freerouting.geometry.planar.Point; /** * Class for shoving items out of a region to make space to insert something else. * For that purpose traces of an unvisible net are created tempory for shoving. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class MakeSpaceState extends DragState -{ - - /** Creates a new instance of MakeSpaceState */ - public MakeSpaceState(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { +public class MakeSpaceState extends DragState { + + private Route route; + + /** + * Creates a new instance of MakeSpaceState + */ + public MakeSpaceState(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { super(p_location, p_parent_state, p_board_handling, p_logfile); - int [] shove_trace_width_arr = new int[hdlg.get_routing_board().get_layer_count()]; - boolean [] layer_active_arr = new boolean[shove_trace_width_arr.length]; - int shove_trace_width = Math.min (100, hdlg.get_routing_board().get_min_trace_half_width() / 10); - shove_trace_width = Math.max (shove_trace_width, 5); - for (int i = 0; i < shove_trace_width_arr.length; ++i) - { + int[] shove_trace_width_arr = new int[hdlg.get_routing_board().get_layer_count()]; + boolean[] layer_active_arr = new boolean[shove_trace_width_arr.length]; + int shove_trace_width = Math.min(100, hdlg.get_routing_board().get_min_trace_half_width() / 10); + shove_trace_width = Math.max(shove_trace_width, 5); + for (int i = 0; i < shove_trace_width_arr.length; ++i) { shove_trace_width_arr[i] = shove_trace_width; layer_active_arr[i] = true; } - int [] route_net_no_arr = new int[1]; + int[] route_net_no_arr = new int[1]; route_net_no_arr[0] = net.freerouting.rules.Nets.hidden_net_no; route = new Route(p_location.round(), hdlg.settings.layer, shove_trace_width_arr, layer_active_arr, route_net_no_arr, 0, net.freerouting.rules.ViaRule.EMPTY, true, hdlg.settings.trace_pull_tight_region_width, hdlg.settings.trace_pull_tight_accuracy, null, null, hdlg.get_routing_board(), false, false, false, hdlg.settings.hilight_routing_obstacle); } - - public InteractiveState move_to(FloatPoint p_to_location) - { - if (!something_dragged) - { + + public InteractiveState move_to(FloatPoint p_to_location) { + if (!something_dragged) { // initialisitions for the first time dragging this.observers_activated = !hdlg.get_routing_board().observers_active(); - if (this.observers_activated) - { + if (this.observers_activated) { hdlg.get_routing_board().start_notify_observers(); } // make the situation restorable by undo hdlg.get_routing_board().generate_snapshot(); - if (logfile != null) - { + if (logfile != null) { // Delayed till here because otherwise the mouse // might have been only clicked for selecting // and not pressed for moving. @@ -77,43 +74,35 @@ public InteractiveState move_to(FloatPoint p_to_location) something_dragged = true; } route.next_corner(p_to_location); - + Point route_end = route.get_last_corner(); if (hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NONE && - !route_end.equals(p_to_location.round())) - { + !route_end.equals(p_to_location.round())) { hdlg.move_mouse(route_end.to_float()); } hdlg.recalculate_length_violations(); hdlg.repaint(); return this; } - - public InteractiveState button_released() - { + + public InteractiveState button_released() { int delete_net_no = net.freerouting.rules.Nets.hidden_net_no; BasicBoard board = hdlg.get_routing_board(); board.remove_items(board.get_connectable_items(delete_net_no), false); - if (this.observers_activated) - { + if (this.observers_activated) { hdlg.get_routing_board().end_notify_observers(); this.observers_activated = false; } - if (logfile != null && something_dragged) - { + if (logfile != null && something_dragged) { logfile.start_scope(LogfileScope.COMPLETE_SCOPE); } hdlg.show_ratsnest(); return this.return_state; } - - public void draw(java.awt.Graphics p_graphics) - { - if (route != null) - { - route.draw(p_graphics, hdlg.graphics_context); + + public void draw(java.awt.Graphics p_graphics) { + if (route != null) { + route.draw(p_graphics, hdlg.graphics_context); } } - - private Route route; } diff --git a/src/main/java/net/freerouting/interactive/MenuState.java b/src/main/java/net/freerouting/interactive/MenuState.java index 667ee85d..9ad1aeee 100644 --- a/src/main/java/net/freerouting/interactive/MenuState.java +++ b/src/main/java/net/freerouting/interactive/MenuState.java @@ -20,206 +20,154 @@ package net.freerouting.interactive; -import net.freerouting.geometry.planar.FloatPoint; - -import java.util.Collection; - import net.freerouting.board.Item; import net.freerouting.board.ItemSelectionFilter; import net.freerouting.board.TestLevel; +import net.freerouting.geometry.planar.FloatPoint; + +import java.util.Collection; /** * Common base class for the main menus, which can be selected in the tool bar. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class MenuState extends InteractiveState -{ - - /** Creates a new instance of MenuState */ - MenuState(BoardHandling p_board_handle, Logfile p_logfile) - { +public class MenuState extends InteractiveState { + + /** + * Creates a new instance of MenuState + */ + MenuState(BoardHandling p_board_handle, Logfile p_logfile) { super(null, p_board_handle, p_logfile); this.return_state = this; } - - public javax.swing.JPopupMenu get_popup_menu() - { + + public javax.swing.JPopupMenu get_popup_menu() { return hdlg.get_panel().popup_menu_main; } - + /** * Selects items at p_location. * Returns a new instance of SelectedItemState with the selected items, * if somthing was selected. */ - public InteractiveState select_items(FloatPoint p_location) - { + public InteractiveState select_items(FloatPoint p_location) { this.hdlg.display_layer_messsage(); java.util.Set picked_items = hdlg.pick_items(p_location); boolean something_found = (picked_items.size() > 0); InteractiveState result; - if (something_found) - { + if (something_found) { result = SelectedItemState.get_instance(picked_items, this, hdlg, this.logfile); hdlg.screen_messages.set_status_message(resources.getString("in_select_mode")); - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.START_SELECT, p_location); } - } - else - { + } else { result = this; } hdlg.repaint(); return result; } - - public InteractiveState swap_pin(FloatPoint p_location) - { + + public InteractiveState swap_pin(FloatPoint p_location) { ItemSelectionFilter selection_filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.PINS); Collection picked_items = hdlg.pick_items(p_location, selection_filter); InteractiveState result = this; - if (picked_items.size() > 0) - { + if (picked_items.size() > 0) { Item first_item = picked_items.iterator().next(); - if (!(first_item instanceof net.freerouting.board.Pin)) - { + if (!(first_item instanceof net.freerouting.board.Pin)) { System.out.println("MenuState.swap_pin: Pin expected"); return this; } net.freerouting.board.Pin selected_pin = (net.freerouting.board.Pin) first_item; result = PinSwapState.get_instance(selected_pin, this, hdlg, this.logfile); - } - else - { + } else { hdlg.screen_messages.set_status_message(resources.getString("no_pin_selected")); } hdlg.repaint(); return result; } - + /** * Action to be taken when a key shortcut is pressed. */ - public InteractiveState key_typed(char p_key_char) - { + public InteractiveState key_typed(char p_key_char) { InteractiveState curr_return_state = this; - if (p_key_char == 'b') - { + if (p_key_char == 'b') { hdlg.redo(); - } - else if (p_key_char == 'd') - { + } else if (p_key_char == 'd') { curr_return_state = DragMenuState.get_instance(hdlg, logfile); - } - else if (p_key_char == 'e') - { - if (hdlg.get_routing_board().get_test_level() != TestLevel.RELEASE_VERSION) - { + } else if (p_key_char == 'e') { + if (hdlg.get_routing_board().get_test_level() != TestLevel.RELEASE_VERSION) { curr_return_state = ExpandTestState.get_instance(hdlg.get_current_mouse_position(), this, hdlg); } - } - else if (p_key_char == 'g') - { + } else if (p_key_char == 'g') { hdlg.toggle_ratsnest(); - } - else if (p_key_char == 'i') - { + } else if (p_key_char == 'i') { curr_return_state = this.select_items(hdlg.get_current_mouse_position()); - } - else if (p_key_char == 'p') - { + } else if (p_key_char == 'p') { hdlg.settings.set_push_enabled(!hdlg.settings.push_enabled); hdlg.get_panel().board_frame.refresh_windows(); - } - else if (p_key_char == 'r') - { + } else if (p_key_char == 'r') { curr_return_state = RouteMenuState.get_instance(hdlg, logfile); - } - else if (p_key_char == 's') - { + } else if (p_key_char == 's') { curr_return_state = SelectMenuState.get_instance(hdlg, logfile); - } - else if (p_key_char == 't') - { + } else if (p_key_char == 't') { curr_return_state = RouteState.get_instance(hdlg.get_current_mouse_position(), this, hdlg, logfile); - } - else if (p_key_char == 'u') - { + } else if (p_key_char == 'u') { hdlg.undo(); - } - else if (p_key_char == 'v') - { + } else if (p_key_char == 'v') { hdlg.toggle_clearance_violations(); - } - else if (p_key_char == 'w') - { + } else if (p_key_char == 'w') { curr_return_state = swap_pin(hdlg.get_current_mouse_position()); - } - else if (p_key_char == '+') - { + } else if (p_key_char == '+') { // increase the current layer to the next signal layer net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int current_layer_no = hdlg.settings.layer; - for(;;) - { + for (; ; ) { ++current_layer_no; - if (current_layer_no >= layer_structure.arr.length || layer_structure.arr[current_layer_no].is_signal) - { + if (current_layer_no >= layer_structure.arr.length || layer_structure.arr[current_layer_no].is_signal) { break; } } - if (current_layer_no < layer_structure.arr.length) - { + if (current_layer_no < layer_structure.arr.length) { hdlg.set_current_layer(current_layer_no); } - } - else if (p_key_char == '-') - { + } else if (p_key_char == '-') { // decrease the current layer to the previous signal layer net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int current_layer_no = hdlg.settings.layer; - for(;;) - { + for (; ; ) { --current_layer_no; - if (current_layer_no < 0 || layer_structure.arr[current_layer_no].is_signal) - { + if (current_layer_no < 0 || layer_structure.arr[current_layer_no].is_signal) { break; } } - if (current_layer_no >= 0) - { + if (current_layer_no >= 0) { hdlg.set_current_layer(current_layer_no); } - - } - else - { + + } else { curr_return_state = super.key_typed(p_key_char); } return curr_return_state; } - + /** * Do nothing on complete. */ - public InteractiveState complete() - { + public InteractiveState complete() { return this; } - + /** * Do nothing on cancel. */ - public InteractiveState cancel() - { + public InteractiveState cancel() { return this; } - - public void set_toolbar() - { + + public void set_toolbar() { hdlg.get_panel().board_frame.set_menu_toolbar(); } } diff --git a/src/main/java/net/freerouting/interactive/MoveItemState.java b/src/main/java/net/freerouting/interactive/MoveItemState.java index cd15c2b8..f14e5583 100644 --- a/src/main/java/net/freerouting/interactive/MoveItemState.java +++ b/src/main/java/net/freerouting/interactive/MoveItemState.java @@ -20,40 +20,79 @@ package net.freerouting.interactive; -import java.util.Collection; -import java.util.LinkedList; -import java.util.Set; -import java.util.TreeSet; - +import net.freerouting.board.*; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Vector; import net.freerouting.geometry.planar.Point; - +import net.freerouting.geometry.planar.Vector; import net.freerouting.library.BoardLibrary; -import net.freerouting.board.Component; -import net.freerouting.board.Item; -import net.freerouting.board.Via; -import net.freerouting.board.ClearanceViolation; -import net.freerouting.board.LayerStructure; +import java.util.Collection; +import java.util.LinkedList; +import java.util.Set; +import java.util.TreeSet; /** - * * @author Alfons Wirtz */ -public class MoveItemState extends InteractiveState -{ +public class MoveItemState extends InteractiveState { + private final Set item_list; + private final Set component_list; + /** + * In case of a component grid the first component is aligned to this grid. + */ + private final Component grid_snap_component; + private final Collection net_items_list; + private IntPoint current_position; + private IntPoint previous_position; + private Collection clearance_violations; + private boolean observers_activated = false; + + /** + * Creates a new instance of MoveComponentState + */ + private MoveItemState(FloatPoint p_location, Set p_item_list, Set p_component_list, + Component p_first_component, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + super(p_parent_state, p_board_handling, p_logfile); + this.component_list = p_component_list; + this.grid_snap_component = p_first_component; + this.current_position = p_location.round(); + this.previous_position = current_position; + if (logfile != null) { + logfile.start_scope(LogfileScope.MOVE_ITEMS, p_location); + } + net.freerouting.board.BasicBoard routing_board = hdlg.get_routing_board(); + this.observers_activated = !hdlg.get_routing_board().observers_active(); + if (this.observers_activated) { + hdlg.get_routing_board().start_notify_observers(); + } + // make the situation restorable by undo + routing_board.generate_snapshot(); + + for (Item curr_item : p_item_list) { + routing_board.remove_item(curr_item); + } + this.net_items_list = new LinkedList(); + this.item_list = new TreeSet(); + + for (Item curr_item : p_item_list) { + // Copy the items in p_item_list, because otherwise the undo algorithm will not work. + Item copied_item = curr_item.copy(0); + for (int i = 0; i < curr_item.net_count(); ++i) { + add_to_net_items_list(copied_item, curr_item.get_net_no(i)); + } + this.item_list.add(copied_item); + } + } + /** * Returns a new instance of MoveComponentState, or null, if the items of p_itemlist do not belong * to a single component. */ public static MoveItemState get_instance(FloatPoint p_location, Collection p_item_list, - InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { + InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.InteractiveState", p_board_handling.get_locale()); - if (p_item_list.isEmpty()) - { + if (p_item_list.isEmpty()) { p_board_handling.screen_messages.set_status_message(resources.getString("move_component_failed_because_no_item_selected")); return null; } @@ -62,34 +101,26 @@ public static MoveItemState get_instance(FloatPoint p_location, Collection Set component_list = new TreeSet(); net.freerouting.board.BasicBoard routing_board = p_board_handling.get_routing_board(); Component grid_snap_component = null; - for (Item curr_item : p_item_list) - { - if (curr_item.get_component_no() > 0) - { + for (Item curr_item : p_item_list) { + if (curr_item.get_component_no() > 0) { Component curr_component = routing_board.components.get(curr_item.get_component_no()); - if (curr_component == null) - { + if (curr_component == null) { System.out.println("MoveComponentState.get_instance inconsistant component number"); return null; } if (grid_snap_component == null && (p_board_handling.settings.horizontal_component_grid > 0 || - p_board_handling.settings.horizontal_component_grid > 0)) - { + p_board_handling.settings.horizontal_component_grid > 0)) { grid_snap_component = curr_component; } - if (!component_list.contains(curr_component)) - { + if (!component_list.contains(curr_component)) { java.util.Collection component_items = routing_board.get_component_items(curr_component.no); - for (Item curr_component_item : component_items) - { + for (Item curr_component_item : component_items) { component_list.add(curr_component); item_list.add(curr_component_item); } } - } - else - { + } else { item_list.add(curr_item); } } @@ -97,17 +128,13 @@ public static MoveItemState get_instance(FloatPoint p_location, Collection Set obstacle_items = new TreeSet(); Set add_items = new TreeSet(); boolean move_ok = true; - for (Item curr_item : item_list) - { - if (curr_item.is_user_fixed()) - { + for (Item curr_item : item_list) { + if (curr_item.is_user_fixed()) { p_board_handling.screen_messages.set_status_message(resources.getString("some_items_cannot_be_moved_because_they_are_fixed")); move_ok = false; obstacle_items.add(curr_item); fixed_items.add(curr_item); - } - else if (curr_item.is_connected()) - { + } else if (curr_item.is_connected()) { // Check if the whole connected set is inside the selected items, // and add the items of the connected set to the move list in this case. // Conduction areas are ignored, because otherwise components with @@ -115,55 +142,40 @@ else if (curr_item.is_connected()) boolean item_movable = true; Collection contacts = curr_item.get_connected_set(-1, true); { - for (Item curr_contact : contacts) - { - if (curr_contact instanceof net.freerouting.board.ConductionArea) - { - + for (Item curr_contact : contacts) { + if (curr_contact instanceof net.freerouting.board.ConductionArea) { + continue; } - if (curr_contact.is_user_fixed()) - { + if (curr_contact.is_user_fixed()) { item_movable = false; fixed_items.add(curr_contact); - } - else if (curr_contact.get_component_no() != 0) - { + } else if (curr_contact.get_component_no() != 0) { Component curr_component = routing_board.components.get(curr_contact.get_component_no()); - if (!component_list.contains(curr_component)) - { + if (!component_list.contains(curr_component)) { item_movable = false; } } - if (item_movable) - { + if (item_movable) { add_items.add(curr_contact); - } - else - { + } else { obstacle_items.add(curr_contact); } } } - if (!item_movable) - { + if (!item_movable) { move_ok = false; } - + } } - if (!move_ok) - { - if (p_parent_state instanceof SelectedItemState) - { - if (fixed_items.size() > 0) - { - ((SelectedItemState)p_parent_state).get_item_list().addAll(fixed_items); + if (!move_ok) { + if (p_parent_state instanceof SelectedItemState) { + if (fixed_items.size() > 0) { + ((SelectedItemState) p_parent_state).get_item_list().addAll(fixed_items); p_board_handling.screen_messages.set_status_message(resources.getString("please_unfix_selected_items_before_moving")); - } - else - { - ((SelectedItemState)p_parent_state).get_item_list().addAll(obstacle_items); + } else { + ((SelectedItemState) p_parent_state).get_item_list().addAll(obstacle_items); p_board_handling.screen_messages.set_status_message(resources.getString("please_unroute_or_extend_selection_before_moving")); } } @@ -173,56 +185,12 @@ else if (curr_contact.get_component_no() != 0) return new MoveItemState(p_location, item_list, component_list, grid_snap_component, p_parent_state.return_state, p_board_handling, p_logfile); } - - /** Creates a new instance of MoveComponentState */ - private MoveItemState(FloatPoint p_location, Set p_item_list, Set p_component_list, - Component p_first_component, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_parent_state, p_board_handling, p_logfile); - this.component_list = p_component_list; - this.grid_snap_component = p_first_component; - this.current_position = p_location.round(); - this.previous_position = current_position; - if (logfile != null) - { - logfile.start_scope(LogfileScope.MOVE_ITEMS, p_location); - } - net.freerouting.board.BasicBoard routing_board = hdlg.get_routing_board(); - this.observers_activated = !hdlg.get_routing_board().observers_active(); - if (this.observers_activated) - { - hdlg.get_routing_board().start_notify_observers(); - } - // make the situation restorable by undo - routing_board.generate_snapshot(); - - for (Item curr_item : p_item_list) - { - routing_board.remove_item(curr_item); - } - this.net_items_list = new LinkedList(); - this.item_list = new TreeSet(); - - for (Item curr_item : p_item_list) - { - // Copy the items in p_item_list, because otherwise the undo algorithm will not work. - Item copied_item = curr_item.copy(0); - for (int i = 0; i < curr_item.net_count(); ++i) - { - add_to_net_items_list(copied_item, curr_item.get_net_no(i)); - } - this.item_list.add(copied_item); - } - } - - private void add_to_net_items_list(Item p_item, int p_net_no) - { - for ( NetItems curr_items : this.net_items_list) - { - if (curr_items.net_no == p_net_no) - { + + private void add_to_net_items_list(Item p_item, int p_net_no) { + for (NetItems curr_items : this.net_items_list) { + if (curr_items.net_no == p_net_no) { // list for p_net_no exists already - curr_items.items.add(p_item) ; + curr_items.items.add(p_item); return; } } @@ -231,397 +199,290 @@ private void add_to_net_items_list(Item p_item, int p_net_no) NetItems new_net_items = new NetItems(p_net_no, new_item_list); this.net_items_list.add(new_net_items); } - - public InteractiveState mouse_moved() - { + + public InteractiveState mouse_moved() { super.mouse_moved(); move(hdlg.get_current_mouse_position()); - if (logfile != null) - { + if (logfile != null) { logfile.add_corner(this.current_position.to_float()); } return this; } - - public InteractiveState process_logfile_point(FloatPoint p_point) - { + + public InteractiveState process_logfile_point(FloatPoint p_point) { move(p_point); return this; } - - public InteractiveState left_button_clicked(FloatPoint p_location) - { + + public InteractiveState left_button_clicked(FloatPoint p_location) { return this.complete(); } - - public InteractiveState complete() - { - for (Item curr_item : this.item_list) - { - if (curr_item.clearance_violation_count() > 0) - { + + public InteractiveState complete() { + for (Item curr_item : this.item_list) { + if (curr_item.clearance_violation_count() > 0) { hdlg.screen_messages.set_status_message(resources.getString("insertion_failed_because_of_obstacles")); return this; } } net.freerouting.board.BasicBoard routing_board = hdlg.get_routing_board(); - for (Item curr_item : this.item_list) - { + for (Item curr_item : this.item_list) { routing_board.insert_item(curr_item); } - + // let the observers syncronize the moving - for (Component curr_component : this.component_list) - { + for (Component curr_component : this.component_list) { routing_board.communication.observers.notify_moved(curr_component); } - - for (NetItems curr_net_items : this.net_items_list) - { + + for (NetItems curr_net_items : this.net_items_list) { this.hdlg.update_ratsnest(curr_net_items.net_no); } - - if (logfile != null) - { + + if (logfile != null) { logfile.start_scope(LogfileScope.COMPLETE_SCOPE); } hdlg.screen_messages.set_status_message(resources.getString("move_completed")); hdlg.repaint(); return this.return_state; } - - public InteractiveState cancel() - { + + public InteractiveState cancel() { hdlg.get_routing_board().undo(null); - for (NetItems curr_net_items : this.net_items_list) - { + for (NetItems curr_net_items : this.net_items_list) { this.hdlg.update_ratsnest(curr_net_items.net_no); } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.CANCEL_SCOPE); } return this.return_state; } - - public InteractiveState mouse_wheel_moved(int p_rotation) - { - if (hdlg.settings.zoom_with_wheel) - { + + public InteractiveState mouse_wheel_moved(int p_rotation) { + if (hdlg.settings.zoom_with_wheel) { super.mouse_wheel_moved(p_rotation); - } - else - { + } else { this.rotate(-p_rotation); } return this; } - + /** * Changes the position of the items in the list to p_new_location. */ - private void move(FloatPoint p_new_position) - { + private void move(FloatPoint p_new_position) { current_position = p_new_position.round(); - if (!current_position.equals(previous_position)) - { + if (!current_position.equals(previous_position)) { Vector translate_vector = current_position.difference_by(previous_position); - if (this.grid_snap_component != null) - { + if (this.grid_snap_component != null) { translate_vector = adjust_to_placement_grid(translate_vector); } net.freerouting.board.Components components = hdlg.get_routing_board().components; - for (Component curr_component : this.component_list) - { + for (Component curr_component : this.component_list) { components.move(curr_component.no, translate_vector); } this.clearance_violations = new java.util.LinkedList(); - for (Item curr_item : this.item_list) - { + for (Item curr_item : this.item_list) { curr_item.translate_by(translate_vector); this.clearance_violations.addAll(curr_item.clearance_violations()); } previous_position = current_position; - for (NetItems curr_net_items : this.net_items_list) - { + for (NetItems curr_net_items : this.net_items_list) { this.hdlg.update_ratsnest(curr_net_items.net_no, curr_net_items.items); } hdlg.repaint(); } } - - private Vector adjust_to_placement_grid(Vector p_vector) - { + + private Vector adjust_to_placement_grid(Vector p_vector) { Point new_component_location = this.grid_snap_component.get_location().translate_by(p_vector); IntPoint rounded_component_location = new_component_location.to_float().round_to_grid(hdlg.settings.horizontal_component_grid, - hdlg.settings.vertical_component_grid); + hdlg.settings.vertical_component_grid); Vector adjustment = rounded_component_location.difference_by(new_component_location); Vector result = p_vector.add(adjustment); this.current_position = this.previous_position.translate_by(result).to_float().round(); return p_vector.add(adjustment); } - - + /** - * Turns the items in the list by p_factor times 90 degree around the current position. + * Turns the items in the list by p_factor times 90 degree around the current position. */ - public void turn_90_degree(int p_factor) - { - if (p_factor == 0) - { + public void turn_90_degree(int p_factor) { + if (p_factor == 0) { return; } net.freerouting.board.Components components = hdlg.get_routing_board().components; - for (Component curr_component : this.component_list) - { + for (Component curr_component : this.component_list) { components.turn_90_degree(curr_component.no, p_factor, current_position); } this.clearance_violations = new java.util.LinkedList(); - for (Item curr_item : this.item_list) - { - curr_item.turn_90_degree(p_factor, current_position); + for (Item curr_item : this.item_list) { + curr_item.turn_90_degree(p_factor, current_position); this.clearance_violations.addAll(curr_item.clearance_violations()); } - for (NetItems curr_net_items : this.net_items_list) - { + for (NetItems curr_net_items : this.net_items_list) { this.hdlg.update_ratsnest(curr_net_items.net_no, curr_net_items.items); } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.TURN_90_DEGREE, p_factor); } hdlg.repaint(); } - - - public void rotate(double p_angle_in_degree) - { - if (p_angle_in_degree == 0) - { + + public void rotate(double p_angle_in_degree) { + if (p_angle_in_degree == 0) { return; } net.freerouting.board.Components components = hdlg.get_routing_board().components; - for (Component curr_component : this.component_list) - { - components.rotate(curr_component.no, p_angle_in_degree, this.current_position); + for (Component curr_component : this.component_list) { + components.rotate(curr_component.no, p_angle_in_degree, this.current_position); } this.clearance_violations = new java.util.LinkedList(); FloatPoint float_position = this.current_position.to_float(); - for (Item curr_item : this.item_list) - { - curr_item.rotate_approx(p_angle_in_degree, float_position); + for (Item curr_item : this.item_list) { + curr_item.rotate_approx(p_angle_in_degree, float_position); this.clearance_violations.addAll(curr_item.clearance_violations()); } - for (NetItems curr_net_items : this.net_items_list) - { + for (NetItems curr_net_items : this.net_items_list) { this.hdlg.update_ratsnest(curr_net_items.net_no, curr_net_items.items); } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.ROTATE, (int) p_angle_in_degree); } hdlg.repaint(); } - - + /** - * Turns the items in the list by p_factor times 90 degree around the current position. + * Turns the items in the list by p_factor times 90 degree around the current position. */ - public void turn_45_degree(int p_factor) - { - if (p_factor % 2 == 0) - { + public void turn_45_degree(int p_factor) { + if (p_factor % 2 == 0) { turn_90_degree(p_factor / 2); - } - else - { + } else { rotate(p_factor * 45); } } - - + /** * Changes the placement side of the items in the list. */ - public void change_placement_side() - { + public void change_placement_side() { // Check, that all items can be mirrored LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; BoardLibrary board_library = hdlg.get_routing_board().library; boolean placement_side_changable = true; - for(Item curr_item : item_list) - { - if (curr_item instanceof Via) - { - if (board_library.get_mirrored_via_padstack(((Via)curr_item).get_padstack()) == null) - { + for (Item curr_item : item_list) { + if (curr_item instanceof Via) { + if (board_library.get_mirrored_via_padstack(((Via) curr_item).get_padstack()) == null) { placement_side_changable = false; break; } - } - else if (curr_item.first_layer() == curr_item.last_layer()) - { + } else if (curr_item.first_layer() == curr_item.last_layer()) { int new_layer_no = hdlg.get_layer_count() - curr_item.first_layer() - 1; - if (!layer_structure.arr[new_layer_no].is_signal) - { + if (!layer_structure.arr[new_layer_no].is_signal) { placement_side_changable = false; break; } } - - + + } - if (!placement_side_changable) - { + if (!placement_side_changable) { hdlg.screen_messages.set_status_message(resources.getString("cannot_change_placement_side")); return; } - + net.freerouting.board.Components components = hdlg.get_routing_board().components; - for (Component curr_component : this.component_list) - { + for (Component curr_component : this.component_list) { components.change_side(curr_component.no, current_position); } this.clearance_violations = new java.util.LinkedList(); - for (Item curr_item : this.item_list) - { + for (Item curr_item : this.item_list) { curr_item.change_placement_side(current_position); this.clearance_violations.addAll(curr_item.clearance_violations()); } - for (NetItems curr_net_items : this.net_items_list) - { + for (NetItems curr_net_items : this.net_items_list) { this.hdlg.update_ratsnest(curr_net_items.net_no, curr_net_items.items); } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.CHANGE_PLACEMENT_SIDE); } hdlg.repaint(); } - - - - public void reset_rotation() - { + + public void reset_rotation() { Component component_to_reset = null; - for (Component curr_component : this.component_list) - { - if (component_to_reset == null) - { + for (Component curr_component : this.component_list) { + if (component_to_reset == null) { component_to_reset = curr_component; - } - else if (component_to_reset.get_rotation_in_degree() != curr_component.get_rotation_in_degree()) - { + } else if (component_to_reset.get_rotation_in_degree() != curr_component.get_rotation_in_degree()) { hdlg.screen_messages.set_status_message(resources.getString("unable_to_reset_components_with_different_rotations")); return; } } - if (component_to_reset == null) - { + if (component_to_reset == null) { return; } double rotation = component_to_reset.get_rotation_in_degree(); - if (!hdlg.get_routing_board().components.get_flip_style_rotate_first() || component_to_reset.placed_on_front()) - { + if (!hdlg.get_routing_board().components.get_flip_style_rotate_first() || component_to_reset.placed_on_front()) { rotation = 360 - rotation; } rotate(rotation); } - - + /** * Action to be taken when a key is pressed (Shortcut). */ - public InteractiveState key_typed(char p_key_char) - { + public InteractiveState key_typed(char p_key_char) { InteractiveState curr_return_state = this; - if (p_key_char == '+') - { + if (p_key_char == '+') { turn_90_degree(1); - } - else if (p_key_char == '*') - { + } else if (p_key_char == '*') { turn_90_degree(2); - } - else if (p_key_char == '-') - { + } else if (p_key_char == '-') { turn_90_degree(3); - } - else if (p_key_char == '/') - { + } else if (p_key_char == '/') { change_placement_side(); - } - else if (p_key_char == 'r') - { + } else if (p_key_char == 'r') { hdlg.settings.set_zoom_with_wheel(false); - } - else if (p_key_char == 'z') - { + } else if (p_key_char == 'z') { hdlg.settings.set_zoom_with_wheel(true); - } - else - { + } else { curr_return_state = super.key_typed(p_key_char); } return curr_return_state; } - - public javax.swing.JPopupMenu get_popup_menu() - { + + public javax.swing.JPopupMenu get_popup_menu() { return hdlg.get_panel().popup_menu_move; } - - public String get_help_id() - { + + public String get_help_id() { return "MoveItemState"; } - - public void draw(java.awt.Graphics p_graphics) - { - if (this.item_list == null) - { + + public void draw(java.awt.Graphics p_graphics) { + if (this.item_list == null) { return; } - for (Item curr_item : this.item_list) - { + for (Item curr_item : this.item_list) { curr_item.draw(p_graphics, hdlg.graphics_context); } - if (this.clearance_violations != null) - { + if (this.clearance_violations != null) { java.awt.Color draw_color = hdlg.graphics_context.get_violations_color(); - for (ClearanceViolation curr_violation : this.clearance_violations) - { + for (ClearanceViolation curr_violation : this.clearance_violations) { hdlg.graphics_context.fill_area(curr_violation.shape, p_graphics, draw_color, 1); } } } - - private final Set item_list; - private final Set component_list; - - /** - * In case of a component grid the first component is aligned to this grid. - */ - private final Component grid_snap_component; - - private IntPoint current_position; - private IntPoint previous_position; - - private Collection clearance_violations; - - private final Collection net_items_list; - - private boolean observers_activated = false; - - private static class NetItems - { - NetItems(int p_net_no, Collection p_items) - { + + private static class NetItems { + final int net_no; + final Collection items; + NetItems(int p_net_no, Collection p_items) { net_no = p_net_no; items = p_items; } - final int net_no; - final Collection items; } } diff --git a/src/main/java/net/freerouting/interactive/NetIncompletes.java b/src/main/java/net/freerouting/interactive/NetIncompletes.java index 107acf41..a46eea27 100644 --- a/src/main/java/net/freerouting/interactive/NetIncompletes.java +++ b/src/main/java/net/freerouting/interactive/NetIncompletes.java @@ -20,227 +20,208 @@ package net.freerouting.interactive; -import java.awt.Graphics; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.SortedSet; -import java.util.TreeSet; - +import net.freerouting.board.BasicBoard; +import net.freerouting.board.Item; +import net.freerouting.boardgraphics.GraphicsContext; import net.freerouting.datastructures.PlanarDelaunayTriangulation; - import net.freerouting.datastructures.Signum; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.Point; - import net.freerouting.rules.Net; -import net.freerouting.board.Item; -import net.freerouting.board.BasicBoard; -import net.freerouting.boardgraphics.GraphicsContext; +import java.awt.*; +import java.util.*; /** * Creates the Incompletes (Ratsnest) of one net to display them on the screen. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class NetIncompletes -{ - - /** Creates a new instance of NetIncompletes */ - public NetIncompletes(int p_net_no, Collection p_net_items, BasicBoard p_board, java.util.Locale p_locale) - { +public class NetIncompletes { + + /** + * Collection of elements of class AirLine. + */ + final Collection incompletes; + private final Net net; + private final double draw_marker_radius; + /** + * The length of the violation of the length restriction of the net, + * > 0, if the cumulative trace length is to big, + * < 0, if the trace length is to smalll, + * 0, if the thace length is ok or the net has no length restrictions + */ + private double length_violation = 0; + + /** + * Creates a new instance of NetIncompletes + */ + public NetIncompletes(int p_net_no, Collection p_net_items, BasicBoard p_board, java.util.Locale p_locale) { this.draw_marker_radius = p_board.rules.get_min_trace_half_width() * 2; this.incompletes = new LinkedList(); this.net = p_board.rules.nets.get(p_net_no); - + // Create an array of Item-connected_set pairs. - NetItem [] net_items = calculate_net_items(p_net_items); - if (net_items.length <= 1) - { + NetItem[] net_items = calculate_net_items(p_net_items); + if (net_items.length <= 1) { return; } - + // create a Delauny Triangulation for the net_items Collection triangulation_objects = new LinkedList(); - for (PlanarDelaunayTriangulation.Storable curr_object : net_items) - { + for (PlanarDelaunayTriangulation.Storable curr_object : net_items) { triangulation_objects.add(curr_object); } PlanarDelaunayTriangulation triangulation = new PlanarDelaunayTriangulation(triangulation_objects); - + // sort the result edges of the triangulation by length in ascending order. Collection triangulation_lines = triangulation.get_edge_lines(); SortedSet sorted_edges = new TreeSet(); - - for (PlanarDelaunayTriangulation.ResultEdge curr_line : triangulation_lines) - { + + for (PlanarDelaunayTriangulation.ResultEdge curr_line : triangulation_lines) { Edge new_edge = new Edge((NetItem) curr_line.start_object, curr_line.start_point.to_float(), (NetItem) curr_line.end_object, curr_line.end_point.to_float()); sorted_edges.add(new_edge); } - + // Create the Airlines. Skip edges, whose from_item and to_item are already in the same connected set // or whose connected sets have already an airline. Net curr_net = p_board.rules.nets.get(p_net_no); - Iterator it = sorted_edges.iterator(); - while(it.hasNext()) - { + Iterator it = sorted_edges.iterator(); + while (it.hasNext()) { Edge curr_edge = it.next(); - if (curr_edge.from_item.connected_set == curr_edge.to_item.connected_set) - { + if (curr_edge.from_item.connected_set == curr_edge.to_item.connected_set) { continue; // airline exists already } - this.incompletes.add(new RatsNest.AirLine(curr_net, curr_edge.from_item.item, + this.incompletes.add(new RatsNest.AirLine(curr_net, curr_edge.from_item.item, curr_edge.from_corner, curr_edge.to_item.item, curr_edge.to_corner, p_locale)); join_connected_sets(net_items, curr_edge.from_item.connected_set, curr_edge.to_item.connected_set); } calc_length_violation(); } - - + + static void draw_layer_change_marker(FloatPoint p_location, double p_radius, Graphics p_graphics, GraphicsContext p_graphics_context) { + final int draw_width = 1; + java.awt.Color draw_color = p_graphics_context.get_incomplete_color(); + double draw_intensity = p_graphics_context.get_incomplete_color_intensity(); + FloatPoint[] draw_points = new FloatPoint[2]; + draw_points[0] = new FloatPoint(p_location.x - p_radius, p_location.y - p_radius); + draw_points[1] = new FloatPoint(p_location.x + p_radius, p_location.y + p_radius); + p_graphics_context.draw(draw_points, draw_width, draw_color, p_graphics, draw_intensity); + draw_points[0] = new FloatPoint(p_location.x + p_radius, p_location.y - p_radius); + draw_points[1] = new FloatPoint(p_location.x - p_radius, p_location.y + p_radius); + p_graphics_context.draw(draw_points, draw_width, draw_color, p_graphics, draw_intensity); + } + + static void draw_length_violation_marker(FloatPoint p_location, double p_diameter, Graphics p_graphics, GraphicsContext p_graphics_context) { + final int draw_width = 1; + java.awt.Color draw_color = p_graphics_context.get_incomplete_color(); + double draw_intensity = p_graphics_context.get_incomplete_color_intensity(); + double circle_radius = 0.5 * Math.abs(p_diameter); + p_graphics_context.draw_circle(p_location, circle_radius, draw_width, draw_color, p_graphics, draw_intensity); + FloatPoint[] draw_points = new FloatPoint[2]; + draw_points[0] = new FloatPoint(p_location.x - circle_radius, p_location.y); + draw_points[1] = new FloatPoint(p_location.x + circle_radius, p_location.y); + p_graphics_context.draw(draw_points, draw_width, draw_color, p_graphics, draw_intensity); + if (p_diameter > 0) { + // draw also the vertical diameter to create a "+" + draw_points[0] = new FloatPoint(p_location.x, p_location.y - circle_radius); + draw_points[1] = new FloatPoint(p_location.x, p_location.y + circle_radius); + p_graphics_context.draw(draw_points, draw_width, draw_color, p_graphics, draw_intensity); + } + } + /** * Returns the number of incompletes of this net. */ - public int count() - { + public int count() { return incompletes.size(); } - + /** * Recalculates the length violations. * Return false, if the lenght violation has not changed. */ - boolean calc_length_violation() - { + boolean calc_length_violation() { double old_violation = this.length_violation; double max_length = this.net.get_class().get_maximum_trace_length(); double min_length = this.net.get_class().get_minimum_trace_length(); - if (max_length <= 0 && min_length <= 0) - { + if (max_length <= 0 && min_length <= 0) { this.length_violation = 0; return false; } double new_violation = 0; double trace_length = this.net.get_trace_length(); - if (max_length > 0 && trace_length > max_length) - { + if (max_length > 0 && trace_length > max_length) { new_violation = trace_length - max_length; } - if (min_length > 0 && trace_length < min_length && this.incompletes.size() == 0) - { + if (min_length > 0 && trace_length < min_length && this.incompletes.size() == 0) { new_violation = trace_length - min_length; } this.length_violation = new_violation; boolean result = Math.abs(new_violation - old_violation) > 0.1; return result; } - + /** - * Returns the length of the violation of the length restriction of the net, - * > 0, if the cumulative trace length is to big, - * < 0, if the trace length is to smalll, - * 0, if the thace length is ok or the net has no length restrictions + * Returns the length of the violation of the length restriction of the net, + * > 0, if the cumulative trace length is to big, + * < 0, if the trace length is to smalll, + * 0, if the thace length is ok or the net has no length restrictions */ - double get_length_violation() - { + double get_length_violation() { return this.length_violation; } - - public void draw(Graphics p_graphics, GraphicsContext p_graphics_context, boolean p_length_violations_only) - { - if (!p_length_violations_only) - { + + public void draw(Graphics p_graphics, GraphicsContext p_graphics_context, boolean p_length_violations_only) { + if (!p_length_violations_only) { java.awt.Color draw_color = p_graphics_context.get_incomplete_color(); double draw_intensity = p_graphics_context.get_incomplete_color_intensity(); - if (draw_intensity <= 0) - { + if (draw_intensity <= 0) { return; } - FloatPoint [] draw_points = new FloatPoint[2]; + FloatPoint[] draw_points = new FloatPoint[2]; int draw_width = 1; Iterator it = incompletes.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { RatsNest.AirLine curr_incomplete = it.next(); draw_points[0] = curr_incomplete.from_corner; draw_points[1] = curr_incomplete.to_corner; p_graphics_context.draw(draw_points, draw_width, draw_color, p_graphics, draw_intensity); - if (!curr_incomplete.from_item.shares_layer(curr_incomplete.to_item)) - { + if (!curr_incomplete.from_item.shares_layer(curr_incomplete.to_item)) { draw_layer_change_marker(curr_incomplete.from_corner, this.draw_marker_radius, p_graphics, p_graphics_context); draw_layer_change_marker(curr_incomplete.to_corner, this.draw_marker_radius, p_graphics, p_graphics_context); } } } - if (this.length_violation == 0) - { + if (this.length_violation == 0) { return; } // draw the length violation around every Pin of the net. Collection net_pins = this.net.get_pins(); - for (net.freerouting.board.Pin curr_pin : net_pins) - { + for (net.freerouting.board.Pin curr_pin : net_pins) { draw_length_violation_marker(curr_pin.get_center().to_float(), this.length_violation, p_graphics, p_graphics_context); } } - - static void draw_layer_change_marker(FloatPoint p_location, double p_radius, Graphics p_graphics, GraphicsContext p_graphics_context) - { - final int draw_width = 1; - java.awt.Color draw_color = p_graphics_context.get_incomplete_color(); - double draw_intensity = p_graphics_context.get_incomplete_color_intensity(); - FloatPoint [] draw_points = new FloatPoint[2]; - draw_points[0] = new FloatPoint(p_location.x - p_radius, p_location.y - p_radius); - draw_points[1] = new FloatPoint(p_location.x + p_radius, p_location.y + p_radius); - p_graphics_context.draw(draw_points, draw_width, draw_color, p_graphics, draw_intensity); - draw_points[0] = new FloatPoint(p_location.x + p_radius, p_location.y - p_radius); - draw_points[1] = new FloatPoint(p_location.x - p_radius, p_location.y + p_radius); - p_graphics_context.draw(draw_points, draw_width, draw_color, p_graphics, draw_intensity); - } - - static void draw_length_violation_marker (FloatPoint p_location, double p_diameter, Graphics p_graphics, GraphicsContext p_graphics_context) - { - final int draw_width = 1; - java.awt.Color draw_color = p_graphics_context.get_incomplete_color(); - double draw_intensity = p_graphics_context.get_incomplete_color_intensity(); - double circle_radius = 0.5 * Math.abs(p_diameter); - p_graphics_context.draw_circle(p_location, circle_radius, draw_width, draw_color, p_graphics, draw_intensity); - FloatPoint [] draw_points = new FloatPoint[2]; - draw_points[0] = new FloatPoint(p_location.x - circle_radius, p_location.y); - draw_points[1] = new FloatPoint(p_location.x + circle_radius, p_location.y); - p_graphics_context.draw(draw_points, draw_width, draw_color, p_graphics, draw_intensity); - if (p_diameter > 0) - { - // draw also the vertical diameter to create a "+" - draw_points[0] = new FloatPoint(p_location.x, p_location.y - circle_radius); - draw_points[1] = new FloatPoint(p_location.x , p_location.y + circle_radius); - p_graphics_context.draw(draw_points, draw_width, draw_color, p_graphics, draw_intensity); - } - } - + /** * Calculates an array of Item-connected_set pairs for the items of this net. * Pairs belonging to the same connected set are located next to each other. */ - private NetItem[] calculate_net_items(Collection p_item_list) - { - NetItem [] result = new NetItem [p_item_list.size()]; + private NetItem[] calculate_net_items(Collection p_item_list) { + NetItem[] result = new NetItem[p_item_list.size()]; Collection handeled_items = new LinkedList(); int curr_index = 0; - while (!p_item_list.isEmpty()) - { + while (!p_item_list.isEmpty()) { Item start_item = p_item_list.iterator().next(); Collection curr_connected_set = start_item.get_connected_set(this.net.net_number); handeled_items.addAll(curr_connected_set); p_item_list.removeAll(curr_connected_set); Iterator it = curr_connected_set.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_index >= result.length) - { + if (curr_index >= result.length) { System.out.println("NetIncompletes.calculate_net_items: to many items"); return result; } @@ -248,99 +229,70 @@ private NetItem[] calculate_net_items(Collection p_item_list) ++curr_index; } } - if (curr_index < result.length) - { + if (curr_index < result.length) { System.out.println("NetIncompletes.calculate_net_items: to few items"); } return result; } - + /** * Joins p_from_connected_set to p_to_connected_set and updates the connected sets of the items in p_net_items. */ - private void join_connected_sets(NetItem [] p_net_items, Collection p_from_connected_set, Collection p_to_connected_set) - { - for (int i = 0; i < p_net_items.length; ++i) - { + private void join_connected_sets(NetItem[] p_net_items, Collection p_from_connected_set, Collection p_to_connected_set) { + for (int i = 0; i < p_net_items.length; ++i) { NetItem curr_item = p_net_items[i]; - if (curr_item.connected_set == p_from_connected_set) - { + if (curr_item.connected_set == p_from_connected_set) { p_to_connected_set.add(curr_item.item); curr_item.connected_set = p_to_connected_set; } } } - - /** Collection of elements of class AirLine. */ - final Collection incompletes; - - /** - * The length of the violation of the length restriction of the net, - * > 0, if the cumulative trace length is to big, - * < 0, if the trace length is to smalll, - * 0, if the thace length is ok or the net has no length restrictions - */ - private double length_violation = 0; - - private final Net net; - private final double draw_marker_radius; - - private static class Edge implements Comparable - { - private Edge(NetItem p_from_item, FloatPoint p_from_corner, NetItem p_to_item, FloatPoint p_to_corner) - { - from_item = p_from_item; - from_corner = p_from_corner; - to_item = p_to_item; - to_corner = p_to_corner; - length_square = p_to_corner.distance_square(p_from_corner); - } - + + private static class Edge implements Comparable { public final NetItem from_item; public final FloatPoint from_corner; public final NetItem to_item; public final FloatPoint to_corner; public final double length_square; - - public int compareTo(Edge p_other) - { + private Edge(NetItem p_from_item, FloatPoint p_from_corner, NetItem p_to_item, FloatPoint p_to_corner) { + from_item = p_from_item; + from_corner = p_from_corner; + to_item = p_to_item; + to_corner = p_to_corner; + length_square = p_to_corner.distance_square(p_from_corner); + } + + public int compareTo(Edge p_other) { double result = this.length_square - p_other.length_square; - if (result == 0) - { + if (result == 0) { // prevent result 0, so that edges with the same length as another edge are not skipped in the set result = this.from_corner.x - p_other.from_corner.x; - if (result == 0) - { + if (result == 0) { result = this.from_corner.y - p_other.from_corner.y; } - if (result == 0) - { + if (result == 0) { result = this.to_corner.x - p_other.to_corner.x; } - if (result == 0) - { + if (result == 0) { result = this.to_corner.y - p_other.to_corner.y; } } return Signum.as_int(result); } } - - private static class NetItem implements PlanarDelaunayTriangulation.Storable - { - NetItem(Item p_item, Collection p_connected_set) - { + + private static class NetItem implements PlanarDelaunayTriangulation.Storable { + final Item item; + Collection connected_set; + + NetItem(Item p_item, Collection p_connected_set) { item = p_item; connected_set = p_connected_set; } - - public Point[] get_triangulation_corners() - { + + public Point[] get_triangulation_corners() { return this.item.get_ratsnest_corners(); } - - final Item item; - Collection connected_set; - + } } diff --git a/src/main/java/net/freerouting/interactive/PinSwapState.java b/src/main/java/net/freerouting/interactive/PinSwapState.java index dacd8be2..a2536ead 100644 --- a/src/main/java/net/freerouting/interactive/PinSwapState.java +++ b/src/main/java/net/freerouting/interactive/PinSwapState.java @@ -20,128 +20,105 @@ package net.freerouting.interactive; -import net.freerouting.geometry.planar.FloatPoint; - -import net.freerouting.board.Pin; import net.freerouting.board.Item; import net.freerouting.board.ItemSelectionFilter; +import net.freerouting.board.Pin; +import net.freerouting.geometry.planar.FloatPoint; /** - * * @author Alfons Wirtz */ -public class PinSwapState extends InteractiveState -{ - public static InteractiveState get_instance(Pin p_pin_to_swap, InteractiveState p_return_state, BoardHandling p_board_handling, Logfile p_logfile) - { +public class PinSwapState extends InteractiveState { + private final Pin from_pin; + private Pin to_pin = null; + private java.util.Set swappable_pins; + + /** + * Creates a new instance of PinSwapState + */ + private PinSwapState(Pin p_pin_to_swap, InteractiveState p_return_state, BoardHandling p_board_handling, Logfile p_logfile) { + super(p_return_state, p_board_handling, p_logfile); + this.from_pin = p_pin_to_swap; + this.swappable_pins = p_pin_to_swap.get_swappable_pins(); + } + + public static InteractiveState get_instance(Pin p_pin_to_swap, InteractiveState p_return_state, BoardHandling p_board_handling, Logfile p_logfile) { PinSwapState new_state = new PinSwapState(p_pin_to_swap, p_return_state, p_board_handling, p_logfile); - if (new_state.swappable_pins.isEmpty()) - { + if (new_state.swappable_pins.isEmpty()) { new_state.hdlg.screen_messages.set_status_message(new_state.resources.getString("no_swappable_pin_found")); return p_return_state; } new_state.hdlg.screen_messages.set_status_message(new_state.resources.getString("please_click_second_pin_with_the_left_mouse_button")); return new_state; } - /** Creates a new instance of PinSwapState */ - private PinSwapState(Pin p_pin_to_swap, InteractiveState p_return_state, BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_return_state, p_board_handling, p_logfile); - this.from_pin = p_pin_to_swap; - this.swappable_pins = p_pin_to_swap.get_swappable_pins(); - } - - - public InteractiveState left_button_clicked(FloatPoint p_location) - { + + public InteractiveState left_button_clicked(FloatPoint p_location) { ItemSelectionFilter selection_filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.PINS); java.util.Collection picked_items = hdlg.pick_items(p_location, selection_filter); - if (picked_items.isEmpty()) - { + if (picked_items.isEmpty()) { this.hdlg.screen_messages.set_status_message(resources.getString("no_pin_selected")); return this.cancel(); } Item to_item = picked_items.iterator().next(); - if (!(to_item instanceof Pin)) - { + if (!(to_item instanceof Pin)) { hdlg.screen_messages.set_status_message(resources.getString("picked_pin_expected")); return this.cancel(); } - + this.to_pin = (Pin) to_item; - if (!swappable_pins.contains(this.to_pin)) - { + if (!swappable_pins.contains(this.to_pin)) { return cancel(); } return complete(); } - - public InteractiveState complete() - { - if (this.from_pin == null || this.to_pin == null) - { + + public InteractiveState complete() { + if (this.from_pin == null || this.to_pin == null) { hdlg.screen_messages.set_status_message(resources.getString("pin_to_swap_missing")); return this.cancel(); } - if (this.from_pin.net_count() > 1 || this.to_pin.net_count() > 1) - { + if (this.from_pin.net_count() > 1 || this.to_pin.net_count() > 1) { System.out.println("PinSwapState.complete: pin swap not yet implemented for pins belonging to more than 1 net "); return this.cancel(); } int from_net_no; - if (this.from_pin.net_count() > 0) - { - from_net_no = this.from_pin.get_net_no(0); - } - else - { + if (this.from_pin.net_count() > 0) { + from_net_no = this.from_pin.get_net_no(0); + } else { from_net_no = -1; } int to_net_no; - if (this.to_pin.net_count() > 0) - { - to_net_no = this.to_pin.get_net_no(0); - } - else - { + if (this.to_pin.net_count() > 0) { + to_net_no = this.to_pin.get_net_no(0); + } else { to_net_no = -1; } - if (!hdlg.get_routing_board().check_change_net(this.from_pin, to_net_no)) - { + if (!hdlg.get_routing_board().check_change_net(this.from_pin, to_net_no)) { hdlg.screen_messages.set_status_message(resources.getString("pin_not_swapped_because_it_is_already_connected")); return this.cancel(); } - if (!hdlg.get_routing_board().check_change_net(this.to_pin, from_net_no)) - { + if (!hdlg.get_routing_board().check_change_net(this.to_pin, from_net_no)) { hdlg.screen_messages.set_status_message(resources.getString("pin_not_swapped_because_second_pin_is_already_connected")); return this.cancel(); } hdlg.get_routing_board().generate_snapshot(); this.from_pin.swap(this.to_pin); - for (int i = 0; i < this.from_pin.net_count(); ++i) - { + for (int i = 0; i < this.from_pin.net_count(); ++i) { hdlg.update_ratsnest(this.from_pin.get_net_no(i)); } - for (int i = 0; i < this.to_pin.net_count(); ++i) - { + for (int i = 0; i < this.to_pin.net_count(); ++i) { hdlg.update_ratsnest(this.to_pin.get_net_no(i)); } hdlg.screen_messages.set_status_message(resources.getString("pin_swap_completed")); return this.return_state; } - - public void draw(java.awt.Graphics p_graphics) - { + + public void draw(java.awt.Graphics p_graphics) { java.awt.Color highlight_color = hdlg.graphics_context.get_hilight_color(); double highligt_color_intensity = hdlg.graphics_context.get_hilight_color_intensity(); from_pin.draw(p_graphics, hdlg.graphics_context, highlight_color, 0.5 * highligt_color_intensity); - for (Pin curr_pin: swappable_pins) - { + for (Pin curr_pin : swappable_pins) { curr_pin.draw(p_graphics, hdlg.graphics_context, highlight_color, highligt_color_intensity); } } - - private final Pin from_pin; - private Pin to_pin = null; - private java.util.Set swappable_pins; } diff --git a/src/main/java/net/freerouting/interactive/PolygonShapeConstructionState.java b/src/main/java/net/freerouting/interactive/PolygonShapeConstructionState.java index 121de0d7..ad7586e3 100644 --- a/src/main/java/net/freerouting/interactive/PolygonShapeConstructionState.java +++ b/src/main/java/net/freerouting/interactive/PolygonShapeConstructionState.java @@ -23,102 +23,85 @@ import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntPoint; import net.freerouting.geometry.planar.PolygonShape; +import net.freerouting.rules.BoardRules; import java.util.Iterator; -import net.freerouting.rules.BoardRules; - /** * Interactive state for constructing an obstacle with a polygon shape. * * @author Alfons Wirtz */ -public class PolygonShapeConstructionState extends CornerItemConstructionState -{ +public class PolygonShapeConstructionState extends CornerItemConstructionState { /** - * Returns a new instance of this class - * If p_logfile != null; the creation of this item is stored in a logfile + * Creates a new instance of PolygonShapeConstructionState */ - public static PolygonShapeConstructionState get_instance(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - return new PolygonShapeConstructionState(p_location, p_parent_state, p_board_handling, p_logfile); - } - - /** Creates a new instance of PolygonShapeConstructionState */ - private PolygonShapeConstructionState(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { + private PolygonShapeConstructionState(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { super(p_parent_state, p_board_handling, p_logfile); - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.CREATING_POLYGONSHAPE); } this.add_corner(p_location); } - + + /** + * Returns a new instance of this class + * If p_logfile != null; the creation of this item is stored in a logfile + */ + public static PolygonShapeConstructionState get_instance(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + return new PolygonShapeConstructionState(p_location, p_parent_state, p_board_handling, p_logfile); + } + /** * Inserts the polygon shape item into the board, if possible * and returns to the main state */ - public InteractiveState complete() - { + public InteractiveState complete() { add_corner_for_snap_angle(); int corner_count = corner_list.size(); boolean construction_succeeded = (corner_count > 2); - if (construction_succeeded) - { - IntPoint [] corner_arr = new IntPoint[corner_count]; + if (construction_succeeded) { + IntPoint[] corner_arr = new IntPoint[corner_count]; Iterator it = corner_list.iterator(); - for (int i = 0; i < corner_count ; ++i) - { + for (int i = 0; i < corner_count; ++i) { corner_arr[i] = it.next(); } PolygonShape obstacle_shape = new PolygonShape(corner_arr); int cl_class = BoardRules.clearance_class_none(); - if (obstacle_shape.split_to_convex() == null) - { + if (obstacle_shape.split_to_convex() == null) { // shape is invalid, maybe it has selfintersections construction_succeeded = false; - } - else - { + } else { construction_succeeded = hdlg.get_routing_board().check_shape(obstacle_shape, hdlg.settings.layer, new int[0], cl_class); } - if (construction_succeeded) - { + if (construction_succeeded) { this.observers_activated = !hdlg.get_routing_board().observers_active(); - if (this.observers_activated) - { + if (this.observers_activated) { hdlg.get_routing_board().start_notify_observers(); } hdlg.get_routing_board().generate_snapshot(); hdlg.get_routing_board().insert_obstacle(obstacle_shape, hdlg.settings.layer, cl_class, net.freerouting.board.FixedState.UNFIXED); hdlg.get_routing_board().end_notify_observers(); - if (this.observers_activated) - { - hdlg.get_routing_board().end_notify_observers(); - this.observers_activated = false; - } + if (this.observers_activated) { + hdlg.get_routing_board().end_notify_observers(); + this.observers_activated = false; + } } } - if (construction_succeeded) - { + if (construction_succeeded) { hdlg.screen_messages.set_status_message(resources.getString("keepout_successful_completed")); - } - else - { + } else { hdlg.screen_messages.set_status_message(resources.getString("keepout_cancelled_because_of_overlaps")); } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.COMPLETE_SCOPE); } return this.return_state; } - - public void display_default_message() - { + + public void display_default_message() { hdlg.screen_messages.set_status_message(resources.getString("creating_polygonshape")); } - + } diff --git a/src/main/java/net/freerouting/interactive/RatsNest.java b/src/main/java/net/freerouting/interactive/RatsNest.java index 68915c7e..50477614 100644 --- a/src/main/java/net/freerouting/interactive/RatsNest.java +++ b/src/main/java/net/freerouting/interactive/RatsNest.java @@ -20,284 +20,238 @@ package net.freerouting.interactive; -import java.util.Collection; -import java.util.LinkedList; -import java.util.Iterator; -import java.util.Vector; - -import java.awt.Graphics; - +import net.freerouting.board.BasicBoard; +import net.freerouting.board.Connectable; +import net.freerouting.board.Item; +import net.freerouting.boardgraphics.GraphicsContext; import net.freerouting.datastructures.UndoableObjects; - import net.freerouting.geometry.planar.FloatPoint; - import net.freerouting.rules.Net; -import net.freerouting.board.BasicBoard; -import net.freerouting.board.Item; -import net.freerouting.board.Connectable; -import net.freerouting.boardgraphics.GraphicsContext; +import java.awt.*; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Vector; /** * Creates all Incompletes (Ratsnest) to display them on the screen * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class RatsNest -{ - - /** Creates a new instance of RatsNest */ - public RatsNest(BasicBoard p_board, java.util.Locale p_locale) - { +public class RatsNest { + + private final NetIncompletes[] net_incompletes; + private final boolean[] is_filtered; + private final java.util.Locale locale; + public boolean hidden = false; + + /** + * Creates a new instance of RatsNest + */ + public RatsNest(BasicBoard p_board, java.util.Locale p_locale) { this.locale = p_locale; int max_net_no = p_board.rules.nets.max_net_no(); // Create the net item lists at once for performance reasons. - Vector> net_item_lists = new Vector>(max_net_no); - for (int i = 0; i < max_net_no; ++i) - { + Vector> net_item_lists = new Vector>(max_net_no); + for (int i = 0; i < max_net_no; ++i) { net_item_lists.add(new LinkedList()); } Iterator it = p_board.item_list.start_read_object(); - for(;;) - { - Item curr_item = (Item)p_board.item_list.read_object(it); - if (curr_item == null) - { + for (; ; ) { + Item curr_item = (Item) p_board.item_list.read_object(it); + if (curr_item == null) { break; } - if (curr_item instanceof Connectable) - { - for (int i = 0; i < curr_item.net_count(); ++i) - { - net_item_lists.get(curr_item.get_net_no(i) -1).add(curr_item); + if (curr_item instanceof Connectable) { + for (int i = 0; i < curr_item.net_count(); ++i) { + net_item_lists.get(curr_item.get_net_no(i) - 1).add(curr_item); } } } this.net_incompletes = new NetIncompletes[max_net_no]; this.is_filtered = new boolean[max_net_no]; - for (int i = 0; i < net_incompletes.length; ++i) - { + for (int i = 0; i < net_incompletes.length; ++i) { net_incompletes[i] = new NetIncompletes(i + 1, net_item_lists.get(i), p_board, p_locale); is_filtered[i] = false; } } - + /** * Recalculates the incomplete connections for the input net */ - public void recalculate(int p_net_no, BasicBoard p_board) - { - if (p_net_no >= 1 && p_net_no <= net_incompletes.length) - { + public void recalculate(int p_net_no, BasicBoard p_board) { + if (p_net_no >= 1 && p_net_no <= net_incompletes.length) { Collection item_list = p_board.get_connectable_items(p_net_no); net_incompletes[p_net_no - 1] = new NetIncompletes(p_net_no, item_list, p_board, locale); } } - + /** * Recalculates the incomplete connections for the input net with the input item list. */ - public void recalculate(int p_net_no, Collection p_item_list, BasicBoard p_board) - { - if (p_net_no >= 1 && p_net_no <= net_incompletes.length) - { + public void recalculate(int p_net_no, Collection p_item_list, BasicBoard p_board) { + if (p_net_no >= 1 && p_net_no <= net_incompletes.length) { // copy p_item_list, because it will be changed inside the constructor of NetIncompletes Collection item_list = new LinkedList(p_item_list); net_incompletes[p_net_no - 1] = new NetIncompletes(p_net_no, item_list, p_board, locale); } } - - public int incomplete_count() - { + + public int incomplete_count() { int result = 0; - for (int i = 0; i < net_incompletes.length; ++i) - { - result += net_incompletes[i].count(); + for (int i = 0; i < net_incompletes.length; ++i) { + result += net_incompletes[i].count(); } return result; } - - public int incomplete_count(int p_net_no) - { - if (p_net_no <= 0 || p_net_no > net_incompletes.length) - { + + public int incomplete_count(int p_net_no) { + if (p_net_no <= 0 || p_net_no > net_incompletes.length) { return 0; } return net_incompletes[p_net_no - 1].count(); } - - public int length_violation_count() - { + + public int length_violation_count() { int result = 0; - for (int i = 0; i < net_incompletes.length; ++i) - { - if (net_incompletes[i].get_length_violation() != 0) - { + for (int i = 0; i < net_incompletes.length; ++i) { + if (net_incompletes[i].get_length_violation() != 0) { ++result; } } return result; } - + /** - * Returns the length of the violation of the length restriction of the net with number p_net_no, - * > 0, if the cumulative trace length is to big, - * < 0, if the trace length is to smalll, - * 0, if the thace length is ok or the net has no length restrictions + * Returns the length of the violation of the length restriction of the net with number p_net_no, + * > 0, if the cumulative trace length is to big, + * < 0, if the trace length is to smalll, + * 0, if the thace length is ok or the net has no length restrictions */ - public double get_length_violation(int p_net_no) - { - if (p_net_no <= 0 || p_net_no > net_incompletes.length) - { + public double get_length_violation(int p_net_no) { + if (p_net_no <= 0 || p_net_no > net_incompletes.length) { return 0; } return net_incompletes[p_net_no - 1].get_length_violation(); } - + /** * Returns all airlines of the ratsnest. */ - public AirLine [] get_airlines() - { + public AirLine[] get_airlines() { AirLine[] result = new AirLine[incomplete_count()]; int curr_index = 0; - for (int i = 0; i < net_incompletes.length; ++i) - { + for (int i = 0; i < net_incompletes.length; ++i) { Collection curr_list = net_incompletes[i].incompletes; - for (AirLine curr_line : curr_list) - { + for (AirLine curr_line : curr_list) { result[curr_index] = curr_line; ++curr_index; } } return result; } - - public void hide() - { + + public void hide() { hidden = true; } - - public void show() - { + + public void show() { hidden = false; } - + /** * Recalculate the length matching violations. * Return false, if the length violations have not changed. */ - public boolean recalculate_length_violations() - { + public boolean recalculate_length_violations() { boolean result = false; - for (int i = 0; i < net_incompletes.length; ++i) - { - if (net_incompletes[i].calc_length_violation()) - { + for (int i = 0; i < net_incompletes.length; ++i) { + if (net_incompletes[i].calc_length_violation()) { result = true; } } return result; } - + /** * Used for example to hide the incompletes during interactive routiing. */ - public boolean is_hidden() - { + public boolean is_hidden() { return hidden; } - - + /** * Sets the visibility filter for the incompletes of the input net. */ - public void set_filter(int p_net_no, boolean p_value) - { - if (p_net_no < 1 || p_net_no > is_filtered.length) - { + public void set_filter(int p_net_no, boolean p_value) { + if (p_net_no < 1 || p_net_no > is_filtered.length) { return; } is_filtered[p_net_no - 1] = p_value; } - - public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) - { + + public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) { boolean draw_length_violations_only = this.hidden; - - for (int i = 0; i < net_incompletes.length; ++i) - { - if (!is_filtered[i]) - { + + for (int i = 0; i < net_incompletes.length; ++i) { + if (!is_filtered[i]) { net_incompletes[i].draw(p_graphics, p_graphics_context, draw_length_violations_only); } } - + } - private final NetIncompletes [] net_incompletes; - private final boolean[] is_filtered; - public boolean hidden = false; - private final java.util.Locale locale; - + /** * Describes a single incomplete connection of the ratsnest. */ - public static class AirLine implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable - { - AirLine(Net p_net, Item p_from_item, FloatPoint p_from_corner, Item p_to_item, - FloatPoint p_to_corner, java.util.Locale p_locale) - { + public static class AirLine implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable { + public final Net net; + public final Item from_item; + public final FloatPoint from_corner; + public final Item to_item; + public final FloatPoint to_corner; + private final java.util.Locale locale; + AirLine(Net p_net, Item p_from_item, FloatPoint p_from_corner, Item p_to_item, + FloatPoint p_to_corner, java.util.Locale p_locale) { net = p_net; from_item = p_from_item; from_corner = p_from_corner; to_item = p_to_item; - to_corner = p_to_corner; + to_corner = p_to_corner; this.locale = p_locale; } - - public int compareTo(AirLine p_other) - { + + public int compareTo(AirLine p_other) { return this.net.name.compareTo(p_other.net.name); } - - public String toString() - { - + + public String toString() { + String result = this.net.name + ": " + item_info(from_item) + " - " + item_info(to_item); return result; } - - private String item_info(Item p_item) - { + + private String item_info(Item p_item) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.RatsNest", this.locale); String result; - if (p_item instanceof net.freerouting.board.Pin) - { + if (p_item instanceof net.freerouting.board.Pin) { net.freerouting.board.Pin curr_pin = (net.freerouting.board.Pin) p_item; result = curr_pin.component_name() + ", " + curr_pin.name(); - } - else if (p_item instanceof net.freerouting.board.Via) - { + } else if (p_item instanceof net.freerouting.board.Via) { result = resources.getString("via"); - } - else if (p_item instanceof net.freerouting.board.Trace) - { + } else if (p_item instanceof net.freerouting.board.Trace) { result = resources.getString("trace"); - } - else if (p_item instanceof net.freerouting.board.ConductionArea) - { + } else if (p_item instanceof net.freerouting.board.ConductionArea) { result = resources.getString("conduction_area"); - } - else - { + } else { result = resources.getString("unknown"); } return result; } - - public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) - { + + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.RatsNest", p_locale); p_window.append_bold(resources.getString("incomplete")); @@ -309,12 +263,5 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util p_window.append(to_corner); p_window.newline(); } - - public final Net net; - public final Item from_item; - public final FloatPoint from_corner; - public final Item to_item; - public final FloatPoint to_corner; - private final java.util.Locale locale; } } diff --git a/src/main/java/net/freerouting/interactive/Route.java b/src/main/java/net/freerouting/interactive/Route.java index 7fb5f7ec..4ad3d04c 100644 --- a/src/main/java/net/freerouting/interactive/Route.java +++ b/src/main/java/net/freerouting/interactive/Route.java @@ -15,73 +15,86 @@ */ package net.freerouting.interactive; +import net.freerouting.board.*; +import net.freerouting.boardgraphics.GraphicsContext; import net.freerouting.datastructures.TimeLimit; - -import net.freerouting.geometry.planar.Area; -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntBox; -import net.freerouting.geometry.planar.IntOctagon; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Vector; +import net.freerouting.geometry.planar.*; import net.freerouting.geometry.planar.Point; -import net.freerouting.geometry.planar.Polyline; -import net.freerouting.geometry.planar.Ellipse; +import net.freerouting.library.Padstack; +import net.freerouting.rules.Net; +import net.freerouting.rules.ViaInfo; +import net.freerouting.rules.ViaRule; -import java.awt.Graphics; +import java.awt.*; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.Set; -import net.freerouting.library.Padstack; - -import net.freerouting.rules.ViaRule; -import net.freerouting.rules.ViaInfo; -import net.freerouting.rules.Net; - -import net.freerouting.board.AngleRestriction; -import net.freerouting.board.Trace; -import net.freerouting.board.ConductionArea; -import net.freerouting.board.DrillItem; -import net.freerouting.board.Item; -import net.freerouting.board.PolylineTrace; -import net.freerouting.board.RoutingBoard; -import net.freerouting.board.ItemSelectionFilter; -import net.freerouting.board.TestLevel; -import net.freerouting.board.Unit; - -import net.freerouting.boardgraphics.GraphicsContext; - /** - * * Functionality for interactive routing. * * @author Alfons Wirtz */ -public class Route -{ +public class Route { + /** + * The time limit in milliseconds for the pull tight algorithm + */ + private static final int CHECK_FORCED_TRACE_TIME_LIMIT = 3000; + /** + * The time limit in milliseconds for the pull tight algorithm + */ + private static final int PULL_TIGHT_TIME_LIMIT = 2000; + /** + * The net numbers used for routing + */ + final int[] net_no_arr; + private final Item start_item; + private final Set target_set; + /** + * Pins, which can be reached by a pin swap by a target pin. + */ + private final Set swap_pin_infos; + private final int[] pen_half_width_arr; + private final boolean[] layer_active; + private final int clearance_class; + private final ViaRule via_rule; + private final int max_shove_trace_recursion_depth; + private final int max_shove_via_recursion_depth; + private final int max_spring_over_recursion_depth; + private final int trace_tidy_width; + private final int pull_tight_accuracy; + private final RoutingBoard board; + private final boolean is_stitch_mode; + private final boolean with_neckdown; + private final boolean via_snap_to_smd_center; + private final boolean hilight_shove_failing_obstacle; + private final int pull_tight_time_limit; + private Point prev_corner; + private int layer; + private Collection target_points; // from drill_items + private Collection target_traces_and_areas; // from traces and conduction areas + private FloatPoint nearest_target_point; + private Item nearest_target_item; + private Item shove_failing_obstacle = null; /** * Starts routing a connection. * p_pen_half_width_arr is provided because it may be different from * the half width array in p_board.rules. */ public Route(Point p_start_corner, int p_layer, int[] p_pen_half_width_arr, boolean[] p_layer_active_arr, int[] p_net_no_arr, - int p_clearance_class, ViaRule p_via_rule, boolean p_push_enabled, - int p_trace_tidy_width, int p_pull_tight_accuracy, Item p_start_item, Set p_target_set, - RoutingBoard p_board, boolean p_is_stitch_mode, boolean p_with_neckdown, boolean p_via_snap_to_smd_center, - boolean p_hilight_shove_failing_obstacle) - { + int p_clearance_class, ViaRule p_via_rule, boolean p_push_enabled, + int p_trace_tidy_width, int p_pull_tight_accuracy, Item p_start_item, Set p_target_set, + RoutingBoard p_board, boolean p_is_stitch_mode, boolean p_with_neckdown, boolean p_via_snap_to_smd_center, + boolean p_hilight_shove_failing_obstacle) { board = p_board; layer = p_layer; - if (p_push_enabled) - { + if (p_push_enabled) { max_shove_trace_recursion_depth = 20; max_shove_via_recursion_depth = 8; max_spring_over_recursion_depth = 5; - } - else - { + } else { max_shove_trace_recursion_depth = 0; max_shove_via_recursion_depth = 0; max_spring_over_recursion_depth = 0; @@ -100,12 +113,9 @@ public Route(Point p_start_corner, int p_layer, int[] p_pen_half_width_arr, bool with_neckdown = p_with_neckdown; via_snap_to_smd_center = p_via_snap_to_smd_center; hilight_shove_failing_obstacle = p_hilight_shove_failing_obstacle; - if (p_board.get_test_level() == TestLevel.RELEASE_VERSION) - { + if (p_board.get_test_level() == TestLevel.RELEASE_VERSION) { this.pull_tight_time_limit = PULL_TIGHT_TIME_LIMIT; - } - else - { + } else { this.pull_tight_time_limit = 0; } calculate_target_points_and_areas(); @@ -117,55 +127,42 @@ public Route(Point p_start_corner, int p_layer, int[] p_pen_half_width_arr, bool * Return true, if the route is completed by connecting * to a target. */ - public boolean next_corner(FloatPoint p_corner) - { - if (!this.layer_active[this.layer]) - { + public boolean next_corner(FloatPoint p_corner) { + if (!this.layer_active[this.layer]) { return false; } IntPoint curr_corner = p_corner.round(); - if (!(board.contains(prev_corner) && board.contains(curr_corner) && board.layer_structure.arr[this.layer].is_signal)) - { + if (!(board.contains(prev_corner) && board.contains(curr_corner) && board.layer_structure.arr[this.layer].is_signal)) { return false; } - if (curr_corner.equals(prev_corner)) - { + if (curr_corner.equals(prev_corner)) { return false; } - if (nearest_target_item instanceof DrillItem) - { + if (nearest_target_item instanceof DrillItem) { DrillItem target = (DrillItem) nearest_target_item; - if (this.prev_corner.equals(target.get_center())) - { + if (this.prev_corner.equals(target.get_center())) { return true; // connection already completed at prev_corner. } } this.shove_failing_obstacle = null; AngleRestriction angle_restriction = this.board.rules.get_trace_angle_restriction(); - if (angle_restriction != AngleRestriction.NONE && !(prev_corner instanceof IntPoint)) - { + if (angle_restriction != AngleRestriction.NONE && !(prev_corner instanceof IntPoint)) { return false; } - if (angle_restriction == AngleRestriction.NINETY_DEGREE) - { + if (angle_restriction == AngleRestriction.NINETY_DEGREE) { curr_corner = curr_corner.orthogonal_projection((IntPoint) prev_corner); - } - else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) { curr_corner = curr_corner.fortyfive_degree_projection((IntPoint) prev_corner); } Item end_routing_item = board.pick_nearest_routing_item(prev_corner, this.layer, null); // look for a nearby item of this net, which is not connected to end_routing_item. nearest_target_item = board.pick_nearest_routing_item(curr_corner, this.layer, end_routing_item); TimeLimit check_forced_trace_time_limit; - if (is_stitch_mode || this.board.get_test_level() != TestLevel.RELEASE_VERSION) - { + if (is_stitch_mode || this.board.get_test_level() != TestLevel.RELEASE_VERSION) { // because no check before inserting in this case check_forced_trace_time_limit = null; - } - else - { + } else { check_forced_trace_time_limit = new TimeLimit(CHECK_FORCED_TRACE_TIME_LIMIT); } @@ -176,67 +173,50 @@ else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) max_shove_trace_recursion_depth, max_shove_via_recursion_depth, max_spring_over_recursion_depth, trace_tidy_width, pull_tight_accuracy, !is_stitch_mode, check_forced_trace_time_limit); // tests.Validate.check("after insert", board); - if (ok_point == prev_corner && this.with_neckdown) - { + if (ok_point == prev_corner && this.with_neckdown) { ok_point = try_neckdown_at_start(curr_corner); } - if (ok_point == prev_corner && this.with_neckdown) - { + if (ok_point == prev_corner && this.with_neckdown) { ok_point = try_neckdown_at_end(this.prev_corner, curr_corner); } - if (ok_point == null) - { + if (ok_point == null) { // database may be damaged, restore previous situation board.undo(null); // end routing in case it is dynamic return (!is_stitch_mode); } - if (ok_point == prev_corner) - { + if (ok_point == prev_corner) { set_shove_failing_obstacle(board.get_shove_failing_obstacle()); return false; } this.prev_corner = ok_point; // check, if a target is reached boolean route_completed = false; - if (ok_point == curr_corner) - { + if (ok_point == curr_corner) { route_completed = connect_to_target(curr_corner); } IntOctagon tidy_clip_shape; - if (trace_tidy_width == Integer.MAX_VALUE) - { + if (trace_tidy_width == Integer.MAX_VALUE) { tidy_clip_shape = null; - } - else if (trace_tidy_width == 0) - { + } else if (trace_tidy_width == 0) { tidy_clip_shape = IntOctagon.EMPTY; - } - else - { + } else { tidy_clip_shape = ok_point.surrounding_octagon().enlarge(trace_tidy_width); } int[] opt_net_no_arr; - if (max_shove_trace_recursion_depth <= 0) - { + if (max_shove_trace_recursion_depth <= 0) { opt_net_no_arr = net_no_arr; - } - else - { + } else { opt_net_no_arr = new int[0]; } - if (route_completed) - { + if (route_completed) { this.board.reduce_nets_of_route_items(); - for (int curr_net_no : this.net_no_arr) - { + for (int curr_net_no : this.net_no_arr) { this.board.combine_traces(curr_net_no); } - } - else - { + } else { calc_nearest_target_point(this.prev_corner.to_float()); } board.opt_changed_area(opt_net_no_arr, tidy_clip_shape, pull_tight_accuracy, @@ -246,33 +226,26 @@ else if (trace_tidy_width == 0) /** * Changing the layer in interactive route and inserting a via. - * Returns false, if changing the layer was not possible. + * Returns false, if changing the layer was not possible. */ - public boolean change_layer(int p_to_layer) - { - if (this.layer == p_to_layer) - { + public boolean change_layer(int p_to_layer) { + if (this.layer == p_to_layer) { return true; } - if (p_to_layer < 0 || p_to_layer >= this.layer_active.length) - { + if (p_to_layer < 0 || p_to_layer >= this.layer_active.length) { System.out.println("Route.change_layer: p_to_layer out of range"); return false; } - if (!this.layer_active[p_to_layer]) - { + if (!this.layer_active[p_to_layer]) { return false; } - if (this.via_rule == null) - { + if (this.via_rule == null) { return false; } this.shove_failing_obstacle = null; - if (this.via_snap_to_smd_center) - { + if (this.via_snap_to_smd_center) { boolean snapped_to_smd_center = snap_to_smd_center(p_to_layer); - if (!snapped_to_smd_center) - { + if (!snapped_to_smd_center) { snap_to_smd_center(this.layer); } } @@ -280,12 +253,10 @@ public boolean change_layer(int p_to_layer) int min_layer = Math.min(this.layer, p_to_layer); int max_layer = Math.max(this.layer, p_to_layer); boolean via_found = false; - for (int i = 0; i < this.via_rule.via_count(); ++i) - { + for (int i = 0; i < this.via_rule.via_count(); ++i) { ViaInfo curr_via_info = this.via_rule.get_via(i); Padstack curr_via_padstack = curr_via_info.get_padstack(); - if (min_layer < curr_via_padstack.from_layer() || max_layer > curr_via_padstack.to_layer()) - { + if (min_layer < curr_via_padstack.from_layer() || max_layer > curr_via_padstack.to_layer()) { continue; } // make the current situation restorable by undo @@ -293,16 +264,14 @@ public boolean change_layer(int p_to_layer) result = board.forced_via(curr_via_info, this.prev_corner, this.net_no_arr, clearance_class, pen_half_width_arr, max_shove_trace_recursion_depth, 0, this.trace_tidy_width, this.pull_tight_accuracy, pull_tight_time_limit); - if (result) - { + if (result) { via_found = true; break; } set_shove_failing_obstacle(board.get_shove_failing_obstacle()); board.undo(null); } - if (via_found) - { + if (via_found) { this.layer = p_to_layer; } return result; @@ -311,35 +280,28 @@ public boolean change_layer(int p_to_layer) /** * Snaps to the center of an smd pin, if the location location on p_layer is inside an smd pin of the own net, */ - private boolean snap_to_smd_center(int p_layer) - { + private boolean snap_to_smd_center(int p_layer) { ItemSelectionFilter selection_filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.PINS); java.util.Collection picked_items = board.pick_items(this.prev_corner, p_layer, selection_filter); net.freerouting.board.Pin found_smd_pin = null; - for (Item curr_item : picked_items) - { - if (curr_item instanceof net.freerouting.board.Pin && curr_item.shares_net_no(this.net_no_arr)) - { + for (Item curr_item : picked_items) { + if (curr_item instanceof net.freerouting.board.Pin && curr_item.shares_net_no(this.net_no_arr)) { net.freerouting.board.Pin curr_pin = (net.freerouting.board.Pin) curr_item; - if (curr_pin.first_layer() == p_layer && curr_pin.last_layer() == p_layer) - { + if (curr_pin.first_layer() == p_layer && curr_pin.last_layer() == p_layer) { found_smd_pin = curr_pin; break; } } } - if (found_smd_pin == null) - { + if (found_smd_pin == null) { return false; } Point pin_center = found_smd_pin.get_center(); - if (!(pin_center instanceof IntPoint)) - { + if (!(pin_center instanceof IntPoint)) { return false; } IntPoint to_corner = (IntPoint) pin_center; - if (this.connect(this.prev_corner, to_corner)) - { + if (this.connect(this.prev_corner, to_corner)) { this.prev_corner = to_corner; } return true; @@ -349,34 +311,25 @@ private boolean snap_to_smd_center(int p_layer) * If p_from_point is already on a target item, a connection * to the target is made and true returned. */ - private boolean connect_to_target(IntPoint p_from_point) - { - if (nearest_target_item != null && target_set != null && !target_set.contains(nearest_target_item)) - { + private boolean connect_to_target(IntPoint p_from_point) { + if (nearest_target_item != null && target_set != null && !target_set.contains(nearest_target_item)) { nearest_target_item = null; } - if (nearest_target_item == null || !nearest_target_item.shares_net_no(this.net_no_arr)) - { + if (nearest_target_item == null || !nearest_target_item.shares_net_no(this.net_no_arr)) { return false; } boolean route_completed = false; Point connection_point = null; - if (nearest_target_item instanceof DrillItem) - { + if (nearest_target_item instanceof DrillItem) { DrillItem target = (DrillItem) nearest_target_item; connection_point = target.get_center(); - } - else if (nearest_target_item instanceof PolylineTrace) - { + } else if (nearest_target_item instanceof PolylineTrace) { return board.connect_to_trace(p_from_point, (PolylineTrace) nearest_target_item, this.pen_half_width_arr[layer], this.clearance_class); - } - else if (nearest_target_item instanceof ConductionArea) - { + } else if (nearest_target_item instanceof ConductionArea) { connection_point = p_from_point; } - if (connection_point != null && connection_point instanceof IntPoint) - { + if (connection_point != null && connection_point instanceof IntPoint) { route_completed = connect(p_from_point, (IntPoint) connection_point); } return route_completed; @@ -386,34 +339,28 @@ else if (nearest_target_item instanceof ConductionArea) * Tries to make a trace connection from p_from_point to p_to_point according to the angle restriction. * Returns true, if the connection succeeded. */ - private boolean connect(Point p_from_point, IntPoint p_to_point) - { + private boolean connect(Point p_from_point, IntPoint p_to_point) { Point[] corners = angled_connection(p_from_point, p_to_point); boolean connection_succeeded = true; - for (int i = 1; i < corners.length; ++i) - { + for (int i = 1; i < corners.length; ++i) { Point from_corner = corners[i - 1]; Point to_corner = corners[i]; TimeLimit time_limit = new TimeLimit(CHECK_FORCED_TRACE_TIME_LIMIT); - while (!from_corner.equals(to_corner)) - { + while (!from_corner.equals(to_corner)) { Point curr_ok_point = board.insert_forced_trace_segment(from_corner, to_corner, pen_half_width_arr[layer], this.layer, net_no_arr, clearance_class, max_shove_trace_recursion_depth, max_shove_via_recursion_depth, max_spring_over_recursion_depth, trace_tidy_width, pull_tight_accuracy, !is_stitch_mode, time_limit); - if (curr_ok_point == null) - { + if (curr_ok_point == null) { // database may be damaged, restore previous situation board.undo(null); return true; } - if (curr_ok_point.equals(from_corner) && this.with_neckdown) - { + if (curr_ok_point.equals(from_corner) && this.with_neckdown) { curr_ok_point = try_neckdown_at_end(from_corner, to_corner); } - if (curr_ok_point.equals(from_corner)) - { + if (curr_ok_point.equals(from_corner)) { this.prev_corner = from_corner; connection_succeeded = false; break; @@ -424,28 +371,22 @@ private boolean connect(Point p_from_point, IntPoint p_to_point) return connection_succeeded; } - /** Calculates the nearest layer of the nearest target item + /** + * Calculates the nearest layer of the nearest target item * to this.layer. */ - public int nearest_target_layer() - { - if (nearest_target_item == null) - { + public int nearest_target_layer() { + if (nearest_target_item == null) { return this.layer; } int result; int first_layer = nearest_target_item.first_layer(); int last_layer = nearest_target_item.last_layer(); - if (this.layer < first_layer) - { + if (this.layer < first_layer) { result = first_layer; - } - else if (this.layer > last_layer) - { + } else if (this.layer > last_layer) { result = last_layer; - } - else - { + } else { result = this.layer; } return result; @@ -454,20 +395,15 @@ else if (this.layer > last_layer) /** * Returns all pins, which can be reached by a pin swap from a srtart or target pin. */ - private Set calculate_swap_pin_infos() - { + private Set calculate_swap_pin_infos() { Set result = new java.util.TreeSet(); - if (this.target_set == null) - { + if (this.target_set == null) { return result; } - for (Item curr_item : this.target_set) - { - if (curr_item instanceof net.freerouting.board.Pin) - { + for (Item curr_item : this.target_set) { + if (curr_item instanceof net.freerouting.board.Pin) { Collection curr_swapppable_pins = ((net.freerouting.board.Pin) curr_item).get_swappable_pins(); - for (net.freerouting.board.Pin curr_swappable_pin : curr_swapppable_pins) - { + for (net.freerouting.board.Pin curr_swappable_pin : curr_swapppable_pins) { result.add(new SwapPinInfo(curr_swappable_pin)); } } @@ -475,13 +411,10 @@ private Set calculate_swap_pin_infos() // add the from item, if it is a pin ItemSelectionFilter selection_filter = new ItemSelectionFilter(ItemSelectionFilter.SelectableChoices.PINS); java.util.Collection picked_items = board.pick_items(this.prev_corner, this.layer, selection_filter); - for (Item curr_item : picked_items) - { - if (curr_item instanceof net.freerouting.board.Pin) - { + for (Item curr_item : picked_items) { + if (curr_item instanceof net.freerouting.board.Pin) { Collection curr_swapppable_pins = ((net.freerouting.board.Pin) curr_item).get_swappable_pins(); - for (net.freerouting.board.Pin curr_swappable_pin : curr_swapppable_pins) - { + for (net.freerouting.board.Pin curr_swappable_pin : curr_swapppable_pins) { result.add(new SwapPinInfo(curr_swappable_pin)); } } @@ -492,19 +425,15 @@ private Set calculate_swap_pin_infos() /** * Hilights the targets and draws the incomplete. */ - public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) - { - if (this.hilight_shove_failing_obstacle && this.shove_failing_obstacle != null) - { + public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) { + if (this.hilight_shove_failing_obstacle && this.shove_failing_obstacle != null) { this.shove_failing_obstacle.draw(p_graphics, p_graphics_context, p_graphics_context.get_violations_color(), 1); } - if (target_set == null || net_no_arr.length < 1) - { + if (target_set == null || net_no_arr.length < 1) { return; } Net curr_net = board.rules.nets.get(net_no_arr[0]); - if (curr_net == null) - { + if (curr_net == null) { return; } java.awt.Color highlight_color = p_graphics_context.get_hilight_color(); @@ -512,11 +441,9 @@ public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) // hilight the swapppable pins and their incompletes - for (SwapPinInfo curr_info : this.swap_pin_infos) - { + for (SwapPinInfo curr_info : this.swap_pin_infos) { curr_info.pin.draw(p_graphics, p_graphics_context, highlight_color, 0.3 * highligt_color_intensity); - if (curr_info.incomplete != null) - { + if (curr_info.incomplete != null) { // draw the swap pin incomplete FloatPoint[] draw_points = new FloatPoint[2]; draw_points[0] = curr_info.incomplete.a; @@ -527,36 +454,30 @@ public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) } // hilight the target set - for (Item curr_item : target_set) - { - if (!(curr_item instanceof ConductionArea)) - { + for (Item curr_item : target_set) { + if (!(curr_item instanceof ConductionArea)) { curr_item.draw(p_graphics, p_graphics_context, highlight_color, highligt_color_intensity); } } FloatPoint from_corner = this.prev_corner.to_float(); - if (nearest_target_point != null && prev_corner != null) - { + if (nearest_target_point != null && prev_corner != null) { boolean curr_length_matching_ok = true; // used for drawing the incomplete as violation double max_trace_length = curr_net.get_class().get_maximum_trace_length(); double min_trace_length = curr_net.get_class().get_minimum_trace_length(); double length_matching_color_intensity = p_graphics_context.get_length_matching_area_color_intensity(); - if (max_trace_length > 0 || min_trace_length > 0 && length_matching_color_intensity > 0) - { + if (max_trace_length > 0 || min_trace_length > 0 && length_matching_color_intensity > 0) { // draw the length matching area double trace_length_add = from_corner.distance(this.prev_corner.to_float()); // trace_length_add is != 0 only in stitching mode. - if (max_trace_length <= 0) - { + if (max_trace_length <= 0) { // max_trace_length not provided. Create an ellipse containing the whole board. max_trace_length = 0.3 * net.freerouting.geometry.planar.Limits.CRIT_INT; } double curr_max_trace_length = max_trace_length - (curr_net.get_trace_length() + trace_length_add); double curr_min_trace_length = min_trace_length - (curr_net.get_trace_length() + trace_length_add); double incomplete_length = nearest_target_point.distance(from_corner); - if (incomplete_length < curr_max_trace_length && min_trace_length <= max_trace_length) - { + if (incomplete_length < curr_max_trace_length && min_trace_length <= max_trace_length) { Vector delta = nearest_target_point.round().difference_by(prev_corner); double rotation = delta.angle_approx(); FloatPoint center = from_corner.middle_point(nearest_target_point); @@ -564,12 +485,9 @@ public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) // dist_focus_to_center^2 = bigger_radius^2 - smaller_radius^2 double smaller_radius = 0.5 * Math.sqrt(curr_max_trace_length * curr_max_trace_length - incomplete_length * incomplete_length); int ellipse_count; - if (min_trace_length <= 0 || incomplete_length >= curr_min_trace_length) - { + if (min_trace_length <= 0 || incomplete_length >= curr_min_trace_length) { ellipse_count = 1; - } - else - { + } else { // display an ellipse ring. ellipse_count = 2; } @@ -578,17 +496,14 @@ public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) IntBox bounding_box = new IntBox(prev_corner.to_float().round(), nearest_target_point.round()); bounding_box = bounding_box.offset(curr_max_trace_length - incomplete_length); board.join_graphics_update_box(bounding_box); - if (ellipse_count == 2) - { + if (ellipse_count == 2) { bigger_radius = 0.5 * curr_min_trace_length; smaller_radius = 0.5 * Math.sqrt(curr_min_trace_length * curr_min_trace_length - incomplete_length * incomplete_length); ellipse_arr[1] = new Ellipse(center, rotation, bigger_radius, smaller_radius); } p_graphics_context.fill_ellipse_arr(ellipse_arr, p_graphics, p_graphics_context.get_length_matching_area_color(), length_matching_color_intensity); - } - else - { + } else { curr_length_matching_ok = false; } } @@ -598,15 +513,13 @@ public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) draw_points[0] = from_corner; draw_points[1] = nearest_target_point; java.awt.Color draw_color = p_graphics_context.get_incomplete_color(); - double draw_width = Math.min (this.board.communication.get_resolution(Unit.MIL), 100); // problem with low resolution on Kicad - if (!curr_length_matching_ok) - { + double draw_width = Math.min(this.board.communication.get_resolution(Unit.MIL), 100); // problem with low resolution on Kicad + if (!curr_length_matching_ok) { draw_color = p_graphics_context.get_violations_color(); draw_width *= 3; } p_graphics_context.draw(draw_points, draw_width, draw_color, p_graphics, highligt_color_intensity); - if (this.nearest_target_item != null && !this.nearest_target_item.is_on_layer(this.layer)) - { + if (this.nearest_target_item != null && !this.nearest_target_item.is_on_layer(this.layer)) { // draw a marker to indicate the layer change. NetIncompletes.draw_layer_change_marker(draw_points[0], 4 * pen_half_width_arr[0], p_graphics, p_graphics_context); } @@ -618,30 +531,23 @@ public void draw(Graphics p_graphics, GraphicsContext p_graphics_context) * Makes a connection polygon from p_from_point to p_to_point * whose lines fulfill the angle restriction. */ - private Point[] angled_connection(Point p_from_point, Point p_to_point) - { + private Point[] angled_connection(Point p_from_point, Point p_to_point) { IntPoint add_corner = null; - if (p_from_point instanceof IntPoint && p_to_point instanceof IntPoint) - { + if (p_from_point instanceof IntPoint && p_to_point instanceof IntPoint) { AngleRestriction angle_restriction = this.board.rules.get_trace_angle_restriction(); - if (angle_restriction == AngleRestriction.NINETY_DEGREE) - { + if (angle_restriction == AngleRestriction.NINETY_DEGREE) { add_corner = ((IntPoint) p_from_point).ninety_degree_corner((IntPoint) p_to_point, true); - } - else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) - { + } else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) { add_corner = ((IntPoint) p_from_point).fortyfive_degree_corner((IntPoint) p_to_point, true); } } int new_corner_count = 2; - if (add_corner != null) - { + if (add_corner != null) { ++new_corner_count; } Point[] result = new Point[new_corner_count]; result[0] = p_from_point; - if (add_corner != null) - { + if (add_corner != null) { result[1] = add_corner; } result[result.length - 1] = p_to_point; @@ -652,39 +558,30 @@ else if (angle_restriction == AngleRestriction.FORTYFIVE_DEGREE) * Calculates a list of the center points of DrillItems, * end points of traces and areas of ConductionAreas in the target set. */ - private void calculate_target_points_and_areas() - { + private void calculate_target_points_and_areas() { target_points = new LinkedList(); target_traces_and_areas = new LinkedList(); - if (target_set == null) - { + if (target_set == null) { return; } Iterator it = target_set.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if (curr_ob instanceof DrillItem) - { + if (curr_ob instanceof DrillItem) { Point curr_point = ((DrillItem) curr_ob).get_center(); target_points.add(new TargetPoint(curr_point.to_float(), curr_ob)); - } - else if (curr_ob instanceof Trace || curr_ob instanceof ConductionArea) - { + } else if (curr_ob instanceof Trace || curr_ob instanceof ConductionArea) { target_traces_and_areas.add(curr_ob); } } } - public Point get_last_corner() - { + public Point get_last_corner() { return prev_corner; } - public boolean is_layer_active(int p_layer) - { - if (p_layer < 0 || p_layer >= layer_active.length) - { + public boolean is_layer_active(int p_layer) { + if (p_layer < 0 || p_layer >= layer_active.length) { return false; } return layer_active[p_layer]; @@ -693,51 +590,40 @@ public boolean is_layer_active(int p_layer) /** * The nearest point is used for drowing the incomplete */ - void calc_nearest_target_point(FloatPoint p_from_point) - { + void calc_nearest_target_point(FloatPoint p_from_point) { double min_dist = Double.MAX_VALUE; FloatPoint nearest_point = null; Item nearest_item = null; - for (TargetPoint curr_target_point : target_points) - { + for (TargetPoint curr_target_point : target_points) { double curr_dist = p_from_point.distance(curr_target_point.location); - if (curr_dist < min_dist) - { + if (curr_dist < min_dist) { min_dist = curr_dist; nearest_point = curr_target_point.location; nearest_item = curr_target_point.item; } } Iterator it = target_traces_and_areas.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_item instanceof PolylineTrace) - { + if (curr_item instanceof PolylineTrace) { PolylineTrace curr_trace = (PolylineTrace) curr_item; Polyline curr_polyline = curr_trace.polyline(); - if (curr_polyline.bounding_box().distance(p_from_point) < min_dist) - { + if (curr_polyline.bounding_box().distance(p_from_point) < min_dist) { FloatPoint curr_nearest_point = curr_polyline.nearest_point_approx(p_from_point); double curr_dist = p_from_point.distance(curr_nearest_point); - if (curr_dist < min_dist) - { + if (curr_dist < min_dist) { min_dist = curr_dist; nearest_point = curr_nearest_point; nearest_item = curr_trace; } } - } - else if (curr_item instanceof ConductionArea && curr_item.tile_shape_count() > 0) - { + } else if (curr_item instanceof ConductionArea && curr_item.tile_shape_count() > 0) { ConductionArea curr_conduction_area = (ConductionArea) curr_item; Area curr_area = curr_conduction_area.get_area(); - if (curr_area.bounding_box().distance(p_from_point) < min_dist) - { + if (curr_area.bounding_box().distance(p_from_point) < min_dist) { FloatPoint curr_nearest_point = curr_area.nearest_point_approx(p_from_point); double curr_dist = p_from_point.distance(curr_nearest_point); - if (curr_dist < min_dist) - { + if (curr_dist < min_dist) { min_dist = curr_dist; nearest_point = curr_nearest_point; nearest_item = curr_conduction_area; @@ -745,8 +631,7 @@ else if (curr_item instanceof ConductionArea && curr_item.tile_shape_count() > 0 } } } - if (nearest_point == null) - { + if (nearest_point == null) { return; // target set is empty } nearest_target_point = nearest_point; @@ -756,11 +641,9 @@ else if (curr_item instanceof ConductionArea && curr_item.tile_shape_count() > 0 board.join_graphics_update_box(nearest_item.bounding_box()); } - private void set_shove_failing_obstacle(Item p_item) - { + private void set_shove_failing_obstacle(Item p_item) { this.shove_failing_obstacle = p_item; - if (p_item != null) - { + if (p_item != null) { this.board.join_graphics_update_box(p_item.bounding_box()); } } @@ -770,15 +653,12 @@ private void set_shove_failing_obstacle(Item p_item) * another try with the smalllest pin width is done. * Returns the ok_point of the try, which is this.prev_point, if the try failed. */ - private Point try_neckdown_at_start(IntPoint p_to_corner) - { - if (!(this.start_item instanceof net.freerouting.board.Pin)) - { + private Point try_neckdown_at_start(IntPoint p_to_corner) { + if (!(this.start_item instanceof net.freerouting.board.Pin)) { return this.prev_corner; } net.freerouting.board.Pin start_pin = (net.freerouting.board.Pin) this.start_item; - if (!start_pin.is_on_layer(this.layer)) - { + if (!start_pin.is_on_layer(this.layer)) { return this.prev_corner; } FloatPoint pin_center = start_pin.get_center().to_float(); @@ -786,25 +666,20 @@ private Point try_neckdown_at_start(IntPoint p_to_corner) this.board.rules.clearance_matrix.value(this.clearance_class, start_pin.clearance_class_no(), this.layer); double pin_neck_down_distance = 2 * (0.5 * start_pin.get_max_width(this.layer) + curr_clearance); - if (pin_center.distance(this.prev_corner.to_float()) >= pin_neck_down_distance) - { + if (pin_center.distance(this.prev_corner.to_float()) >= pin_neck_down_distance) { return this.prev_corner; } int neck_down_halfwidth = start_pin.get_trace_neckdown_halfwidth(this.layer); - if (neck_down_halfwidth >= this.pen_half_width_arr[this.layer]) - { + if (neck_down_halfwidth >= this.pen_half_width_arr[this.layer]) { return this.prev_corner; } // check, that the neck_down started inside the pin shape - if (!this.prev_corner.equals(start_pin.get_center())) - { + if (!this.prev_corner.equals(start_pin.get_center())) { Item picked_item = this.board.pick_nearest_routing_item(this.prev_corner, this.layer, null); - if (picked_item instanceof Trace) - { - if (((Trace) picked_item).get_half_width() > neck_down_halfwidth) - { + if (picked_item instanceof Trace) { + if (((Trace) picked_item).get_half_width() > neck_down_halfwidth) { return this.prev_corner; } } @@ -822,15 +697,12 @@ private Point try_neckdown_at_start(IntPoint p_to_corner) * another try with the smalllest pin width is done. * Returns the ok_point of the try, which is p_from_corner, if the try failed. */ - private Point try_neckdown_at_end(Point p_from_corner, Point p_to_corner) - { - if (!(this.nearest_target_item instanceof net.freerouting.board.Pin)) - { + private Point try_neckdown_at_end(Point p_from_corner, Point p_to_corner) { + if (!(this.nearest_target_item instanceof net.freerouting.board.Pin)) { return p_from_corner; } net.freerouting.board.Pin target_pin = (net.freerouting.board.Pin) this.nearest_target_item; - if (!target_pin.is_on_layer(this.layer)) - { + if (!target_pin.is_on_layer(this.layer)) { return p_from_corner; } FloatPoint pin_center = target_pin.get_center().to_float(); @@ -838,13 +710,11 @@ private Point try_neckdown_at_end(Point p_from_corner, Point p_to_corner) this.board.rules.clearance_matrix.value(this.clearance_class, target_pin.clearance_class_no(), this.layer); double pin_neck_down_distance = 2 * (0.5 * target_pin.get_max_width(this.layer) + curr_clearance); - if (pin_center.distance(p_from_corner.to_float()) >= pin_neck_down_distance) - { + if (pin_center.distance(p_from_corner.to_float()) >= pin_neck_down_distance) { return p_from_corner; } int neck_down_halfwidth = target_pin.get_trace_neckdown_halfwidth(this.layer); - if (neck_down_halfwidth >= this.pen_half_width_arr[this.layer]) - { + if (neck_down_halfwidth >= this.pen_half_width_arr[this.layer]) { return p_from_corner; } TimeLimit time_limit = new TimeLimit(CHECK_FORCED_TRACE_TIME_LIMIT); @@ -855,60 +725,26 @@ private Point try_neckdown_at_end(Point p_from_corner, Point p_to_corner) pull_tight_accuracy, !is_stitch_mode, time_limit); return ok_point; } - /** The net numbers used for routing */ - final int[] net_no_arr; - private Point prev_corner; - private int layer; - private final Item start_item; - private final Set target_set; - /** Pins, which can be reached by a pin swap by a target pin. */ - private final Set swap_pin_infos; - private Collection target_points; // from drill_items - private Collection target_traces_and_areas; // from traces and conduction areas - private FloatPoint nearest_target_point; - private Item nearest_target_item; - private final int[] pen_half_width_arr; - private final boolean[] layer_active; - private final int clearance_class; - private final ViaRule via_rule; - private final int max_shove_trace_recursion_depth; - private final int max_shove_via_recursion_depth; - private final int max_spring_over_recursion_depth; - private final int trace_tidy_width; - private final int pull_tight_accuracy; - private final RoutingBoard board; - private final boolean is_stitch_mode; - private final boolean with_neckdown; - private final boolean via_snap_to_smd_center; - private final boolean hilight_shove_failing_obstacle; - private final int pull_tight_time_limit; - private Item shove_failing_obstacle = null; - /** The time limit in milliseconds for the pull tight algorithm */ - private static final int CHECK_FORCED_TRACE_TIME_LIMIT = 3000; - /** The time limit in milliseconds for the pull tight algorithm */ - private static final int PULL_TIGHT_TIME_LIMIT = 2000; - private static class TargetPoint - { + private static class TargetPoint { - TargetPoint(FloatPoint p_location, Item p_item) - { + final FloatPoint location; + final Item item; + TargetPoint(FloatPoint p_location, Item p_item) { location = p_location; item = p_item; } - final FloatPoint location; - final Item item; } - private class SwapPinInfo implements Comparable - { + private class SwapPinInfo implements Comparable { + + final net.freerouting.board.Pin pin; + net.freerouting.geometry.planar.FloatLine incomplete; - SwapPinInfo(net.freerouting.board.Pin p_pin) - { + SwapPinInfo(net.freerouting.board.Pin p_pin) { pin = p_pin; incomplete = null; - if (p_pin.is_connected() || p_pin.net_count() != 1) - { + if (p_pin.is_connected() || p_pin.net_count() != 1) { return; } // calculate the incomplete of p_pin @@ -916,31 +752,24 @@ private class SwapPinInfo implements Comparable double min_dist = Double.MAX_VALUE; FloatPoint nearest_point = null; Collection net_items = board.get_connectable_items(p_pin.get_net_no(0)); - for (Item curr_item : net_items) - { - if (curr_item == this.pin || !(curr_item instanceof DrillItem)) - { + for (Item curr_item : net_items) { + if (curr_item == this.pin || !(curr_item instanceof DrillItem)) { continue; } FloatPoint curr_point = ((DrillItem) curr_item).get_center().to_float(); double curr_dist = pin_center.distance_square(curr_point); - if (curr_dist < min_dist) - { + if (curr_dist < min_dist) { min_dist = curr_dist; nearest_point = curr_point; } } - if (nearest_point != null) - { + if (nearest_point != null) { incomplete = new net.freerouting.geometry.planar.FloatLine(pin_center, nearest_point); } } - public int compareTo(SwapPinInfo p_other) - { + public int compareTo(SwapPinInfo p_other) { return this.pin.compareTo(p_other.pin); } - final net.freerouting.board.Pin pin; - net.freerouting.geometry.planar.FloatLine incomplete; } } \ No newline at end of file diff --git a/src/main/java/net/freerouting/interactive/RouteMenuState.java b/src/main/java/net/freerouting/interactive/RouteMenuState.java index 67a3b1de..6ddbae34 100644 --- a/src/main/java/net/freerouting/interactive/RouteMenuState.java +++ b/src/main/java/net/freerouting/interactive/RouteMenuState.java @@ -26,36 +26,34 @@ * Class implementing the different functionality in the route menu, * especially the different behaviour of the mouse button 1. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class RouteMenuState extends MenuState -{ - /** Returns a new instance of RouteMenuState */ - public static RouteMenuState get_instance(BoardHandling p_board_handling, Logfile p_logfile) - { +public class RouteMenuState extends MenuState { + /** + * Creates a new instance of RouteMenuState + */ + private RouteMenuState(BoardHandling p_board_handling, Logfile p_logfile) { + super(p_board_handling, p_logfile); + } + + /** + * Returns a new instance of RouteMenuState + */ + public static RouteMenuState get_instance(BoardHandling p_board_handling, Logfile p_logfile) { RouteMenuState new_state = new RouteMenuState(p_board_handling, p_logfile); return new_state; } - - /** Creates a new instance of RouteMenuState */ - private RouteMenuState(BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_board_handling, p_logfile); - } - - public InteractiveState left_button_clicked(FloatPoint p_location) - { + + public InteractiveState left_button_clicked(FloatPoint p_location) { return RouteState.get_instance(p_location, this, hdlg, logfile); } - - public void display_default_message() - { + + public void display_default_message() { hdlg.screen_messages.set_status_message(" in route menu"); } - - public String get_help_id() - { + + public String get_help_id() { return "MenuState_RouteMenuState"; } - + } diff --git a/src/main/java/net/freerouting/interactive/RouteState.java b/src/main/java/net/freerouting/interactive/RouteState.java index 90a2f6e7..8e9d4fea 100644 --- a/src/main/java/net/freerouting/interactive/RouteState.java +++ b/src/main/java/net/freerouting/interactive/RouteState.java @@ -19,6 +19,7 @@ */ package net.freerouting.interactive; +import net.freerouting.board.*; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntPoint; import net.freerouting.geometry.planar.Point; @@ -26,21 +27,25 @@ import java.util.Collection; import java.util.Set; -import net.freerouting.board.Trace; -import net.freerouting.board.Via; -import net.freerouting.board.PolylineTrace; -import net.freerouting.board.ConductionArea; -import net.freerouting.board.DrillItem; -import net.freerouting.board.Item; -import net.freerouting.board.ItemSelectionFilter; - /** * Interactive routing state. * * @author Alfons Wirtz */ -public class RouteState extends InteractiveState -{ +public class RouteState extends InteractiveState { + + protected Route route = null; + protected boolean observers_activated = false; + private Set routing_target_set = null; + + /** + * Creates a new instance of RouteState + * If p_logfile != null, the creation of the route is stored + * in the logfile. + */ + protected RouteState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + super(p_parent_state, p_board_handling, p_logfile); + } /** * Returns a new instance of this class or null, @@ -48,53 +53,41 @@ public class RouteState extends InteractiveState * If p_logfile != null, the creation of the route is stored * in the logfile. **/ - public static RouteState get_instance(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - if (!(p_parent_state instanceof MenuState)) - { + public static RouteState get_instance(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + if (!(p_parent_state instanceof MenuState)) { System.out.println("RouteState.get_instance: unexpected parent state"); } p_board_handling.display_layer_messsage(); IntPoint location = p_location.round(); Item picked_item = start_ok(location, p_board_handling); - if (picked_item == null) - { + if (picked_item == null) { return null; } int net_count = picked_item.net_count(); - if (net_count <= 0) - { + if (net_count <= 0) { return null; } int[] route_net_no_arr; - if (picked_item instanceof net.freerouting.board.Pin && net_count > 1) - { + if (picked_item instanceof net.freerouting.board.Pin && net_count > 1) { // tie pin, remove nets, which are already conneccted to this pin on the current layer. route_net_no_arr = get_route_net_numbers_at_tie_pin((net.freerouting.board.Pin) picked_item, p_board_handling.settings.layer); - } - else - { + } else { route_net_no_arr = new int[net_count]; - for (int i = 0; i < net_count; ++i) - { + for (int i = 0; i < net_count; ++i) { route_net_no_arr[i] = picked_item.get_net_no(i); } } - if (route_net_no_arr.length <= 0) - { + if (route_net_no_arr.length <= 0) { return null; } net.freerouting.board.RoutingBoard routing_board = p_board_handling.get_routing_board(); int[] trace_half_widths = new int[routing_board.get_layer_count()]; boolean[] layer_active_arr = new boolean[trace_half_widths.length]; - for (int i = 0; i < trace_half_widths.length; ++i) - { + for (int i = 0; i < trace_half_widths.length; ++i) { trace_half_widths[i] = p_board_handling.get_trace_halfwidth(route_net_no_arr[0], i); layer_active_arr[i] = false; - for (int j = 0; j < route_net_no_arr.length; ++j) - { - if (p_board_handling.is_active_routing_layer(route_net_no_arr[j], i)) - { + for (int j = 0; j < route_net_no_arr.length; ++j) { + if (p_board_handling.is_active_routing_layer(route_net_no_arr[j], i)) { layer_active_arr[i] = true; } } @@ -102,30 +95,23 @@ public static RouteState get_instance(FloatPoint p_location, InteractiveState p_ int trace_clearance_class = p_board_handling.get_trace_clearance_class(route_net_no_arr[0]); boolean start_ok = true; - if (picked_item instanceof Trace) - { + if (picked_item instanceof Trace) { Trace picked_trace = (Trace) picked_item; Point picked_corner = picked_trace.nearest_end_point(location); if (picked_corner instanceof IntPoint && - p_location.distance(picked_corner.to_float()) < 5 * picked_trace.get_half_width()) - { + p_location.distance(picked_corner.to_float()) < 5 * picked_trace.get_half_width()) { location = (IntPoint) picked_corner; - } - else - { - if (picked_trace instanceof PolylineTrace) - { + } else { + if (picked_trace instanceof PolylineTrace) { FloatPoint nearest_point = ((PolylineTrace) picked_trace).polyline().nearest_point_approx(p_location); location = nearest_point.round(); } if (!routing_board.connect_to_trace(location, picked_trace, - picked_trace.get_half_width(), picked_trace.clearance_class_no())) - { + picked_trace.get_half_width(), picked_trace.clearance_class_no())) { start_ok = false; } } - if (start_ok && !p_board_handling.settings.manual_rule_selection) - { + if (start_ok && !p_board_handling.settings.manual_rule_selection) { // Pick up the half with and the clearance class of the found trace. int[] new_trace_half_widths = new int[trace_half_widths.length]; System.arraycopy(trace_half_widths, 0, new_trace_half_widths, 0, trace_half_widths.length); @@ -134,37 +120,29 @@ public static RouteState get_instance(FloatPoint p_location, InteractiveState p_ trace_clearance_class = picked_trace.clearance_class_no(); } - } - else if (picked_item instanceof DrillItem) - { + } else if (picked_item instanceof DrillItem) { DrillItem drill_item = (DrillItem) picked_item; Point center = drill_item.get_center(); - if (center instanceof IntPoint) - { + if (center instanceof IntPoint) { location = (IntPoint) center; } } - if (!start_ok) - { + if (!start_ok) { return null; } net.freerouting.rules.Net curr_net = routing_board.rules.nets.get(route_net_no_arr[0]); - if (curr_net == null) - { + if (curr_net == null) { return null; } // Switch to stitch mode for nets, which are shove fixed. boolean is_stitch_route = p_board_handling.settings.is_stitch_route || curr_net.get_class().is_shove_fixed() || !curr_net.get_class().get_pull_tight(); routing_board.generate_snapshot(); RouteState new_instance; - if (is_stitch_route) - { + if (is_stitch_route) { new_instance = new StitchRouteState(p_parent_state, p_board_handling, p_logfile); - } - else - { + } else { new_instance = new DynamicRouteState(p_parent_state, p_board_handling, p_logfile); } new_instance.routing_target_set = picked_item.get_unconnected_set(-1); @@ -176,15 +154,12 @@ else if (picked_item instanceof DrillItem) is_stitch_route, p_board_handling.settings.automatic_neckdown, p_board_handling.settings.via_snap_to_smd_center, p_board_handling.settings.hilight_routing_obstacle); new_instance.observers_activated = !routing_board.observers_active(); - if (new_instance.observers_activated) - { + if (new_instance.observers_activated) { routing_board.start_notify_observers(); } p_board_handling.repaint(); - if (new_instance != null) - { - if (new_instance.logfile != null) - { + if (new_instance != null) { + if (new_instance.logfile != null) { new_instance.logfile.start_scope(LogfileScope.CREATING_TRACE, p_location); p_board_handling.hide_ratsnest(); } @@ -193,23 +168,12 @@ else if (picked_item instanceof DrillItem) return new_instance; } - /** - * Creates a new instance of RouteState - * If p_logfile != null, the creation of the route is stored - * in the logfile. - */ - protected RouteState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_parent_state, p_board_handling, p_logfile); - } - /** * Checks starting an interactive route at p_location. * Returns the picked start item of the routing at p_location, * or null, if no such item was found. */ - static protected Item start_ok(IntPoint p_location, BoardHandling p_hdlg) - { + static protected Item start_ok(IntPoint p_location, BoardHandling p_hdlg) { net.freerouting.board.RoutingBoard routing_board = p_hdlg.get_routing_board(); /** @@ -218,39 +182,29 @@ static protected Item start_ok(IntPoint p_location, BoardHandling p_hdlg) */ Item picked_item = routing_board.pick_nearest_routing_item(p_location, p_hdlg.settings.layer, null); int layer_count = routing_board.get_layer_count(); - if (picked_item == null && p_hdlg.settings.select_on_all_visible_layers) - { + if (picked_item == null && p_hdlg.settings.select_on_all_visible_layers) { // Nothing found on preferred layer, try the other visible layers. // Prefer the outer layers. picked_item = pick_routing_item(p_location, 0, p_hdlg); - if (picked_item == null) - { + if (picked_item == null) { picked_item = pick_routing_item(p_location, layer_count - 1, p_hdlg); } // prefer signal layers - if (picked_item == null) - { - for (int i = 1; i < layer_count - 1; ++i) - { - if (routing_board.layer_structure.arr[i].is_signal) - { + if (picked_item == null) { + for (int i = 1; i < layer_count - 1; ++i) { + if (routing_board.layer_structure.arr[i].is_signal) { picked_item = pick_routing_item(p_location, i, p_hdlg); - if (picked_item != null) - { + if (picked_item != null) { break; } } } } - if (picked_item == null) - { - for (int i = 1; i < layer_count - 1; ++i) - { - if (!routing_board.layer_structure.arr[i].is_signal) - { + if (picked_item == null) { + for (int i = 1; i < layer_count - 1; ++i) { + if (!routing_board.layer_structure.arr[i].is_signal) { picked_item = pick_routing_item(p_location, i, p_hdlg); - if (picked_item != null) - { + if (picked_item != null) { break; } } @@ -260,34 +214,53 @@ static protected Item start_ok(IntPoint p_location, BoardHandling p_hdlg) return picked_item; } - static private Item pick_routing_item(IntPoint p_location, int p_layer_no, BoardHandling p_hdlg) - { + static private Item pick_routing_item(IntPoint p_location, int p_layer_no, BoardHandling p_hdlg) { - if (p_layer_no == p_hdlg.settings.layer || (p_hdlg.graphics_context.get_layer_visibility(p_layer_no) <= 0)) - { + if (p_layer_no == p_hdlg.settings.layer || (p_hdlg.graphics_context.get_layer_visibility(p_layer_no) <= 0)) { return null; } Item picked_item = p_hdlg.get_routing_board().pick_nearest_routing_item(p_location, p_layer_no, null); - if (picked_item != null) - { + if (picked_item != null) { p_hdlg.set_layer(picked_item.first_layer()); } return picked_item; } - public InteractiveState process_logfile_point(FloatPoint p_point) - { + /** + * get nets of p_tie_pin except nets of traces, which are already conneccted to this pin on p_layer. + */ + static int[] get_route_net_numbers_at_tie_pin(net.freerouting.board.Pin p_pin, int p_layer) { + Set net_number_list = new java.util.TreeSet(); + for (int i = 0; i < p_pin.net_count(); ++i) { + net_number_list.add(p_pin.get_net_no(i)); + } + Set contacts = p_pin.get_normal_contacts(); + for (Item curr_contact : contacts) { + if (curr_contact.first_layer() <= p_layer && curr_contact.last_layer() >= p_layer) { + for (int i = 0; i < curr_contact.net_count(); ++i) { + net_number_list.remove(curr_contact.get_net_no(i)); + } + } + } + int[] result = new int[net_number_list.size()]; + int curr_ind = 0; + for (Integer curr_net_number : net_number_list) { + result[curr_ind] = curr_net_number; + ++curr_ind; + } + return result; + } + + public InteractiveState process_logfile_point(FloatPoint p_point) { return add_corner(p_point); } /** * Action to be taken when a key is pressed (Shortcut). */ - public InteractiveState key_typed(char p_key_char) - { + public InteractiveState key_typed(char p_key_char) { InteractiveState curr_return_state = this; - if (Character.isDigit(p_key_char)) - { + if (Character.isDigit(p_key_char)) { // change to the p_key_char-ths signal layer net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int d = Character.digit(p_key_char, 10); @@ -297,50 +270,37 @@ public InteractiveState key_typed(char p_key_char) net.freerouting.board.Layer new_layer = layer_structure.get_signal_layer(d); d = layer_structure.get_no(new_layer); - if (d >= 0) - { + if (d >= 0) { change_layer_action(d); } - } - else if (p_key_char == '+') - { + } else if (p_key_char == '+') { // change to the next signal layer net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int current_layer_no = hdlg.settings.layer; - for (;;) - { + for (; ; ) { ++current_layer_no; - if (current_layer_no >= layer_structure.arr.length || layer_structure.arr[current_layer_no].is_signal) - { + if (current_layer_no >= layer_structure.arr.length || layer_structure.arr[current_layer_no].is_signal) { break; } } - if (current_layer_no < layer_structure.arr.length) - { + if (current_layer_no < layer_structure.arr.length) { change_layer_action(current_layer_no); } - } - else if (p_key_char == '-') - { + } else if (p_key_char == '-') { // change to the to the previous signal layer net.freerouting.board.LayerStructure layer_structure = hdlg.get_routing_board().layer_structure; int current_layer_no = hdlg.settings.layer; - for (;;) - { + for (; ; ) { --current_layer_no; - if (current_layer_no < 0 || layer_structure.arr[current_layer_no].is_signal) - { + if (current_layer_no < 0 || layer_structure.arr[current_layer_no].is_signal) { break; } } - if (current_layer_no >= 0) - { + if (current_layer_no >= 0) { change_layer_action(current_layer_no); } - } - else - { + } else { curr_return_state = super.key_typed(p_key_char); } return curr_return_state; @@ -351,35 +311,27 @@ else if (p_key_char == '-') * Returns from state, if the route is completed by connecting * to a target. */ - public InteractiveState add_corner(FloatPoint p_location) - { + public InteractiveState add_corner(FloatPoint p_location) { boolean route_completed = route.next_corner(p_location); String layer_string = hdlg.get_routing_board().layer_structure.arr[route.nearest_target_layer()].name; hdlg.screen_messages.set_target_layer(layer_string); - if (this.logfile != null) - { + if (this.logfile != null) { this.logfile.add_corner(p_location); } - if (route_completed) - { - if (this.observers_activated) - { + if (route_completed) { + if (this.observers_activated) { hdlg.get_routing_board().end_notify_observers(); this.observers_activated = false; } } InteractiveState result; - if (route_completed) - { + if (route_completed) { result = this.return_state; hdlg.screen_messages.clear(); - for (int curr_net_no : this.route.net_no_arr) - { + for (int curr_net_no : this.route.net_no_arr) { hdlg.update_ratsnest(curr_net_no); } - } - else - { + } else { result = this; } hdlg.recalculate_length_violations(); @@ -387,52 +339,40 @@ public InteractiveState add_corner(FloatPoint p_location) return result; } - public InteractiveState cancel() - { + public InteractiveState cancel() { Trace tail = hdlg.get_routing_board().get_trace_tail(route.get_last_corner(), hdlg.settings.layer, route.net_no_arr); - if (tail != null) - { + if (tail != null) { Collection remove_items = tail.get_connection_items(Item.StopConnectionOption.VIA); - if (hdlg.settings.push_enabled) - { + if (hdlg.settings.push_enabled) { hdlg.get_routing_board().remove_items_and_pull_tight(remove_items, hdlg.settings.trace_pull_tight_region_width, hdlg.settings.trace_pull_tight_accuracy, false); - } - else - { + } else { hdlg.get_routing_board().remove_items(remove_items, false); } } - if (this.observers_activated) - { + if (this.observers_activated) { hdlg.get_routing_board().end_notify_observers(); this.observers_activated = false; } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.CANCEL_SCOPE); } hdlg.screen_messages.clear(); - for (int curr_net_no : this.route.net_no_arr) - { + for (int curr_net_no : this.route.net_no_arr) { hdlg.update_ratsnest(curr_net_no); } return this.return_state; } - public boolean change_layer_action(int p_new_layer) - { + public boolean change_layer_action(int p_new_layer) { boolean result = true; - if (p_new_layer >= 0 && p_new_layer < hdlg.get_routing_board().get_layer_count()) - { - if (this.route != null && !this.route.is_layer_active(p_new_layer)) - { + if (p_new_layer >= 0 && p_new_layer < hdlg.get_routing_board().get_layer_count()) { + if (this.route != null && !this.route.is_layer_active(p_new_layer)) { String layer_name = hdlg.get_routing_board().layer_structure.arr[p_new_layer].name; hdlg.screen_messages.set_status_message(resources.getString("layer_not_changed_because_layer") + " " + layer_name + " " + resources.getString("is_not_active_for_the_current_net")); } boolean change_layer_succeeded = route.change_layer(p_new_layer); - if (change_layer_succeeded) - { + if (change_layer_succeeded) { boolean connected_to_plane = false; // check, if the layer change resulted in a connection to a power plane. int old_layer = hdlg.settings.get_layer(); @@ -440,36 +380,27 @@ public boolean change_layer_action(int p_new_layer) Collection picked_items = hdlg.get_routing_board().pick_items(route.get_last_corner(), old_layer, selection_filter); Via new_via = null; - for (Item curr_via : picked_items) - { - if (curr_via.shares_net_no(route.net_no_arr)) - { + for (Item curr_via : picked_items) { + if (curr_via.shares_net_no(route.net_no_arr)) { new_via = (Via) curr_via; break; } } - if (new_via != null) - { + if (new_via != null) { int from_layer; int to_layer; - if (old_layer < p_new_layer) - { + if (old_layer < p_new_layer) { from_layer = old_layer + 1; to_layer = p_new_layer; - } - else - { + } else { from_layer = p_new_layer; to_layer = old_layer - 1; } Collection contacts = new_via.get_normal_contacts(); - for (Item curr_item : contacts) - { - if (curr_item instanceof ConductionArea) - { + for (Item curr_item : contacts) { + if (curr_item instanceof ConductionArea) { ConductionArea curr_area = (ConductionArea) curr_item; - if (curr_area.get_layer() >= from_layer && curr_area.get_layer() <= to_layer) - { + if (curr_area.get_layer() >= from_layer && curr_area.get_layer() <= to_layer) { connected_to_plane = true; break; } @@ -477,37 +408,27 @@ public boolean change_layer_action(int p_new_layer) } } - if (connected_to_plane) - { + if (connected_to_plane) { hdlg.set_interactive_state(this.return_state); - for (int curr_net_no : this.route.net_no_arr) - { + for (int curr_net_no : this.route.net_no_arr) { hdlg.update_ratsnest(curr_net_no); } - } - else - { + } else { hdlg.set_layer(p_new_layer); String layer_name = hdlg.get_routing_board().layer_structure.arr[p_new_layer].name; hdlg.screen_messages.set_status_message(resources.getString("layer_changed_to") + " " + layer_name); // make the current situation restorable by undo hdlg.get_routing_board().generate_snapshot(); } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.CHANGE_LAYER, p_new_layer); } - } - else - { + } else { int shove_failing_layer = hdlg.get_routing_board().get_shove_failing_layer(); - if (shove_failing_layer >= 0) - { + if (shove_failing_layer >= 0) { String layer_name = hdlg.get_routing_board().layer_structure.arr[hdlg.get_routing_board().get_shove_failing_layer()].name; hdlg.screen_messages.set_status_message(resources.getString("layer_not_changed_because_of_obstacle_on_layer") + " " + layer_name); - } - else - { + } else { System.out.println("RouteState.change_layer_action: shove_failing_layer not set"); } result = false; @@ -517,54 +438,16 @@ public boolean change_layer_action(int p_new_layer) return result; } - /** - * get nets of p_tie_pin except nets of traces, which are already conneccted to this pin on p_layer. - */ - static int[] get_route_net_numbers_at_tie_pin(net.freerouting.board.Pin p_pin, int p_layer) - { - Set net_number_list = new java.util.TreeSet(); - for (int i = 0; i < p_pin.net_count(); ++i) - { - net_number_list.add(p_pin.get_net_no(i)); - } - Set contacts = p_pin.get_normal_contacts(); - for (Item curr_contact : contacts) - { - if (curr_contact.first_layer() <= p_layer && curr_contact.last_layer() >= p_layer) - { - for (int i = 0; i < curr_contact.net_count(); ++i) - { - net_number_list.remove(curr_contact.get_net_no(i)); - } - } - } - int[] result = new int[net_number_list.size()]; - int curr_ind = 0; - for (Integer curr_net_number : net_number_list) - { - result[curr_ind] = curr_net_number; - ++curr_ind; - } - return result; - } - - public void draw(java.awt.Graphics p_graphics) - { - if (route != null) - { + public void draw(java.awt.Graphics p_graphics) { + if (route != null) { route.draw(p_graphics, hdlg.graphics_context); } } - public void display_default_message() - { - if (route != null) - { + public void display_default_message() { + if (route != null) { net.freerouting.rules.Net curr_net = hdlg.get_routing_board().rules.nets.get(route.net_no_arr[0]); hdlg.screen_messages.set_status_message(resources.getString("routing_net") + " " + curr_net.name); } } - protected Route route = null; - private Set routing_target_set = null; - protected boolean observers_activated = false; } diff --git a/src/main/java/net/freerouting/interactive/ScreenMessages.java b/src/main/java/net/freerouting/interactive/ScreenMessages.java index 9e509f9e..25461d27 100644 --- a/src/main/java/net/freerouting/interactive/ScreenMessages.java +++ b/src/main/java/net/freerouting/interactive/ScreenMessages.java @@ -20,20 +20,36 @@ package net.freerouting.interactive; -import javax.swing.JLabel; +import javax.swing.*; /** * Text fields to display messages on the screen. * - * @author arbeit + * @author arbeit */ -public class ScreenMessages -{ - - /** Creates a new instance of ScreenMessageFields */ +public class ScreenMessages { + + static private final String empty_string = " "; + private final java.util.ResourceBundle resources; + private final java.util.Locale locale; + private final String active_layer_string; + private final String target_layer_string; + /** + * The number format for displaying the trace lengtht + */ + private final java.text.NumberFormat number_format; + private JLabel add_field; + private JLabel status_field; + private JLabel layer_field; + private JLabel mouse_position; + private String prev_target_layer_name = empty_string; + private boolean write_protected = false; + + /** + * Creates a new instance of ScreenMessageFields + */ public ScreenMessages(JLabel p_status_field, JLabel p_add_field, - JLabel p_layer_field, JLabel p_mouse_position, java.util.Locale p_locale) - { + JLabel p_layer_field, JLabel p_mouse_position, java.util.Locale p_locale) { resources = java.util.ResourceBundle.getBundle("net.freerouting.interactive.ScreenMessages", p_locale); locale = p_locale; active_layer_string = resources.getString("current_layer") + " "; @@ -43,35 +59,30 @@ public ScreenMessages(JLabel p_status_field, JLabel p_add_field, layer_field = p_layer_field; mouse_position = p_mouse_position; add_field.setText(empty_string); - - this.number_format = java.text.NumberFormat.getInstance(p_locale); + + this.number_format = java.text.NumberFormat.getInstance(p_locale); this.number_format.setMaximumFractionDigits(4); } - + /** * Sets the message in the status field. */ - public void set_status_message(String p_message) - { - if (!this.write_protected) - { + public void set_status_message(String p_message) { + if (!this.write_protected) { status_field.setText(p_message); } } - + /** * Sets the displayed layer number on the screen. */ - public void set_layer(String p_layer_name) - { - if (!this.write_protected) - { + public void set_layer(String p_layer_name) { + if (!this.write_protected) { layer_field.setText(active_layer_string + p_layer_name); } } - - public void set_interactive_autoroute_info(int p_found, int p_not_found, int p_items_to_go) - { + + public void set_interactive_autoroute_info(int p_found, int p_not_found, int p_items_to_go) { Integer found = p_found; Integer failed = p_not_found; Integer items_to_go = p_items_to_go; @@ -80,103 +91,75 @@ public void set_interactive_autoroute_info(int p_found, int p_not_found, int p_i + resources.getString("failed") + " " + failed.toString()); } - public void set_batch_autoroute_info(int p_items_to_go, int p_routed, int p_ripped, int p_failed) - { + public void set_batch_autoroute_info(int p_items_to_go, int p_routed, int p_ripped, int p_failed) { Integer ripped = p_ripped; Integer routed = p_routed; Integer items_to_go = p_items_to_go; Integer failed = p_failed; - add_field.setText( resources.getString("to_route") + " " + items_to_go.toString() + ", " + add_field.setText(resources.getString("to_route") + " " + items_to_go.toString() + ", " + resources.getString("routed") + " " + routed.toString() + ", "); layer_field.setText(resources.getString("ripped") + " " + ripped.toString() + ", " + resources.getString("failed") + " " + failed.toString()); } - - public void set_batch_fanout_info(int p_pass_no, int p_components_to_go) - { + + public void set_batch_fanout_info(int p_pass_no, int p_components_to_go) { Integer components_to_go = p_components_to_go; - Integer pass_no = new Integer(p_pass_no); - add_field.setText(resources.getString("fanout_pass") + " " + pass_no.toString() + ": "); - layer_field.setText(resources.getString("still") + " " + Integer pass_no = new Integer(p_pass_no); + add_field.setText(resources.getString("fanout_pass") + " " + pass_no.toString() + ": "); + layer_field.setText(resources.getString("still") + " " + components_to_go.toString() + " " + resources.getString("components")); } - - public void set_post_route_info( int p_via_count, double p_trace_length) - { + + public void set_post_route_info(int p_via_count, double p_trace_length) { Integer via_count = p_via_count; add_field.setText(resources.getString("via_count") + " " + via_count.toString()); layer_field.setText(resources.getString("trace_length") + " " + this.number_format.format(p_trace_length)); } - + /** * Sets the displayed layer of the nearest target item * in interactive routing. */ - public void set_target_layer(String p_layer_name) - { - if (!(p_layer_name.equals(prev_target_layer_name) || this.write_protected)) - { - add_field.setText(target_layer_string + p_layer_name); + public void set_target_layer(String p_layer_name) { + if (!(p_layer_name.equals(prev_target_layer_name) || this.write_protected)) { + add_field.setText(target_layer_string + p_layer_name); prev_target_layer_name = p_layer_name; } } - - public void set_mouse_position(net.freerouting.geometry.planar.FloatPoint p_pos) - { - if (p_pos == null || this.mouse_position == null || this.write_protected) - { + + public void set_mouse_position(net.freerouting.geometry.planar.FloatPoint p_pos) { + if (p_pos == null || this.mouse_position == null || this.write_protected) { return; } this.mouse_position.setText(p_pos.to_string(this.locale)); } - + /** * Clears the additional field, which is among others used to * display the layer of the nearest target item. */ - public void clear_add_field() - { - if (!this.write_protected) - { + public void clear_add_field() { + if (!this.write_protected) { add_field.setText(empty_string); prev_target_layer_name = empty_string; } } - + /** * Clears the status field and the additional field. */ - public void clear() - { - if (!this.write_protected) - { + public void clear() { + if (!this.write_protected) { status_field.setText(empty_string); clear_add_field(); layer_field.setText(empty_string); } } - + /** * As long as write_protected is set to true, the set functions in this class will do nothing. */ - public void set_write_protected(boolean p_value) - { + public void set_write_protected(boolean p_value) { write_protected = p_value; } - - private final java.util.ResourceBundle resources; - private final java.util.Locale locale; - private final String active_layer_string; - private final String target_layer_string; - static private final String empty_string = " "; - - private JLabel add_field; - private JLabel status_field; - private JLabel layer_field; - private JLabel mouse_position; - private String prev_target_layer_name = empty_string; - private boolean write_protected = false; - - /** The number format for displaying the trace lengtht */ - private final java.text.NumberFormat number_format; } diff --git a/src/main/java/net/freerouting/interactive/SelectItemsInRegionState.java b/src/main/java/net/freerouting/interactive/SelectItemsInRegionState.java index 54be881c..07e966e8 100644 --- a/src/main/java/net/freerouting/interactive/SelectItemsInRegionState.java +++ b/src/main/java/net/freerouting/interactive/SelectItemsInRegionState.java @@ -19,6 +19,7 @@ */ package net.freerouting.interactive; +import net.freerouting.board.Item; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntBox; import net.freerouting.geometry.planar.IntPoint; @@ -27,22 +28,29 @@ import java.util.Set; import java.util.TreeSet; -import net.freerouting.board.Item; - /** * Interactive state for selecting all items in a rectangle. * * @author Alfons Wirtz */ -public class SelectItemsInRegionState extends SelectRegionState -{ +public class SelectItemsInRegionState extends SelectRegionState { + + /** + * Creates a new instance of SelectItemsInRegionState + */ + private SelectItemsInRegionState(InteractiveState p_parent_state, + BoardHandling p_board_handling, Logfile p_logfile) { + super(p_parent_state, p_board_handling, p_logfile); + if (logfile != null) { + logfile.start_scope(LogfileScope.SELECT_REGION); + } + } /** * Returns a new instance of this class. */ public static SelectItemsInRegionState get_instance(InteractiveState p_parent_state, - BoardHandling p_board_handling, Logfile p_logfile) - { + BoardHandling p_board_handling, Logfile p_logfile) { return get_instance(null, p_parent_state, p_board_handling, p_logfile); } @@ -50,39 +58,23 @@ public static SelectItemsInRegionState get_instance(InteractiveState p_parent_st * Returns a new instance of this class with first point p_location. */ public static SelectItemsInRegionState get_instance(FloatPoint p_location, InteractiveState p_parent_state, - BoardHandling p_board_handling, Logfile p_logfile) - { + BoardHandling p_board_handling, Logfile p_logfile) { p_board_handling.display_layer_messsage(); SelectItemsInRegionState new_instance = new SelectItemsInRegionState(p_parent_state, p_board_handling, p_logfile); new_instance.corner1 = p_location; - if (new_instance.logfile != null) - { + if (new_instance.logfile != null) { new_instance.logfile.add_corner(p_location); } new_instance.hdlg.screen_messages.set_status_message(new_instance.resources.getString("drag_left_mouse_button_to_selects_items_in_region")); return new_instance; } - /** Creates a new instance of SelectItemsInRegionState */ - private SelectItemsInRegionState(InteractiveState p_parent_state, - BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_parent_state, p_board_handling, p_logfile); - if (logfile != null) - { - logfile.start_scope(LogfileScope.SELECT_REGION); - } - } - - public InteractiveState complete() - { - if (!hdlg.is_board_read_only()) - { + public InteractiveState complete() { + if (!hdlg.is_board_read_only()) { hdlg.screen_messages.set_status_message(""); corner2 = hdlg.get_current_mouse_position(); - if (logfile != null) - { + if (logfile != null) { logfile.add_corner(corner2); } this.select_all_in_region(); @@ -93,34 +85,26 @@ public InteractiveState complete() /** * Selects all items in the rectangle defined by corner1 and corner2. */ - private void select_all_in_region() - { + private void select_all_in_region() { IntPoint p1 = this.corner1.round(); IntPoint p2 = this.corner2.round(); IntBox b = new IntBox(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y), Math.max(p1.x, p2.x), Math.max(p1.y, p2.y)); int select_layer; - if (hdlg.settings.select_on_all_visible_layers) - { + if (hdlg.settings.select_on_all_visible_layers) { select_layer = -1; - } - else - { + } else { select_layer = hdlg.settings.layer; } Set found_items = hdlg.settings.item_selection_filter.filter(hdlg.get_routing_board().overlapping_items(b, select_layer)); - if (hdlg.settings.select_on_all_visible_layers) - { + if (hdlg.settings.select_on_all_visible_layers) { // remove items, which are not visible Set visible_items = new TreeSet(); Iterator it = found_items.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - for (int i = curr_item.first_layer(); i <= curr_item.last_layer(); ++i) - { - if (hdlg.graphics_context.get_layer_visibility(i) > 0) - { + for (int i = curr_item.first_layer(); i <= curr_item.last_layer(); ++i) { + if (hdlg.graphics_context.get_layer_visibility(i) > 0) { visible_items.add(curr_item); break; } @@ -129,19 +113,13 @@ private void select_all_in_region() found_items = visible_items; } boolean something_found = (found_items.size() > 0); - if (something_found) - { - if (this.return_state instanceof SelectedItemState) - { + if (something_found) { + if (this.return_state instanceof SelectedItemState) { ((SelectedItemState) this.return_state).get_item_list().addAll(found_items); - } - else - { + } else { this.return_state = SelectedItemState.get_instance(found_items, this.return_state, hdlg, logfile); } - } - else - { + } else { hdlg.screen_messages.set_status_message(resources.getString("nothing_selected")); } } diff --git a/src/main/java/net/freerouting/interactive/SelectMenuState.java b/src/main/java/net/freerouting/interactive/SelectMenuState.java index 171bb5b7..56328058 100644 --- a/src/main/java/net/freerouting/interactive/SelectMenuState.java +++ b/src/main/java/net/freerouting/interactive/SelectMenuState.java @@ -26,41 +26,38 @@ * Class implementing the different functionality in the select menu, * especially the different behaviour of the mouse button 1. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class SelectMenuState extends MenuState -{ - /** Returns a new instance of SelectMenuState */ - public static SelectMenuState get_instance(BoardHandling p_board_handling, Logfile p_logfile) - { +public class SelectMenuState extends MenuState { + /** + * Creates a new instance of SelectMenuState + */ + private SelectMenuState(BoardHandling p_board_handling, Logfile p_logfile) { + super(p_board_handling, p_logfile); + } + + /** + * Returns a new instance of SelectMenuState + */ + public static SelectMenuState get_instance(BoardHandling p_board_handling, Logfile p_logfile) { SelectMenuState new_state = new SelectMenuState(p_board_handling, p_logfile); return new_state; } - - /** Creates a new instance of SelectMenuState */ - private SelectMenuState(BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_board_handling, p_logfile); - } - - public InteractiveState left_button_clicked(FloatPoint p_location) - { - InteractiveState result = select_items(p_location); + + public InteractiveState left_button_clicked(FloatPoint p_location) { + InteractiveState result = select_items(p_location); return result; } - - public InteractiveState mouse_dragged(FloatPoint p_point) - { + + public InteractiveState mouse_dragged(FloatPoint p_point) { return SelectItemsInRegionState.get_instance(hdlg.get_current_mouse_position(), this, hdlg, logfile); } - - public void display_default_message() - { + + public void display_default_message() { hdlg.screen_messages.set_status_message(resources.getString("in_select_menu")); } - - public String get_help_id() - { + + public String get_help_id() { return "MenuState_SelectMenuState"; } } diff --git a/src/main/java/net/freerouting/interactive/SelectRegionState.java b/src/main/java/net/freerouting/interactive/SelectRegionState.java index 32d074c6..cf32b26c 100644 --- a/src/main/java/net/freerouting/interactive/SelectRegionState.java +++ b/src/main/java/net/freerouting/interactive/SelectRegionState.java @@ -27,47 +27,41 @@ * * @author Alfons Wirtz */ -public class SelectRegionState extends InteractiveState -{ - - /** Creates a new instance of SelectRegionState */ - protected SelectRegionState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { +public class SelectRegionState extends InteractiveState { + + protected FloatPoint corner1 = null; + protected FloatPoint corner2 = null; + + /** + * Creates a new instance of SelectRegionState + */ + protected SelectRegionState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { super(p_parent_state, p_board_handling, p_logfile); } - - public InteractiveState button_released() - { + + public InteractiveState button_released() { hdlg.screen_messages.set_status_message(""); return complete(); } - - public InteractiveState mouse_dragged(FloatPoint p_point) - { - if (corner1 == null) - { + + public InteractiveState mouse_dragged(FloatPoint p_point) { + if (corner1 == null) { corner1 = p_point; - if (logfile != null) - { + if (logfile != null) { logfile.add_corner(corner1); } } hdlg.repaint(); return this; } - - public void draw(java.awt.Graphics p_graphics) - { + + public void draw(java.awt.Graphics p_graphics) { this.return_state.draw(p_graphics); FloatPoint current_mouse_position = hdlg.get_current_mouse_position(); - if (corner1 == null || current_mouse_position == null) - { + if (corner1 == null || current_mouse_position == null) { return; } corner2 = current_mouse_position; - hdlg.graphics_context.draw_rectangle(corner1, corner2, 1, java.awt.Color.white, p_graphics, 1) ; + hdlg.graphics_context.draw_rectangle(corner1, corner2, 1, java.awt.Color.white, p_graphics, 1); } - - protected FloatPoint corner1 = null; - protected FloatPoint corner2 = null; } diff --git a/src/main/java/net/freerouting/interactive/SelectedItemState.java b/src/main/java/net/freerouting/interactive/SelectedItemState.java index de65a9a9..a82d2b98 100644 --- a/src/main/java/net/freerouting/interactive/SelectedItemState.java +++ b/src/main/java/net/freerouting/interactive/SelectedItemState.java @@ -19,154 +19,104 @@ */ package net.freerouting.interactive; +import net.freerouting.autoroute.AutorouteEngine; +import net.freerouting.board.*; +import net.freerouting.datastructures.Stoppable; import net.freerouting.geometry.planar.FloatPoint; import net.freerouting.geometry.planar.IntPoint; import net.freerouting.geometry.planar.Point; import net.freerouting.geometry.planar.Vector; +import net.freerouting.library.Package; +import net.freerouting.rules.Net; import java.util.Collection; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; -import net.freerouting.datastructures.Stoppable; - -import net.freerouting.library.Package; - -import net.freerouting.rules.Net; - -import net.freerouting.autoroute.AutorouteEngine; - -import net.freerouting.board.Component; -import net.freerouting.board.Connectable; -import net.freerouting.board.DrillItem; -import net.freerouting.board.Via; -import net.freerouting.board.Pin; -import net.freerouting.board.Item; -import net.freerouting.board.ObstacleArea; -import net.freerouting.board.PolylineTrace; -import net.freerouting.board.RoutingBoard; -import net.freerouting.board.FixedState; -import net.freerouting.board.OptViaAlgo; -import net.freerouting.board.TestLevel; - /** - * Class implementing actions on the currently selected items. + * Class implementing actions on the currently selected items. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class SelectedItemState extends InteractiveState -{ +public class SelectedItemState extends InteractiveState { + + private Set item_list; + private ClearanceViolations clearance_violations = null; + + /** + * Creates a new instance of SelectedItemState + */ + private SelectedItemState(Set p_item_list, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + super(p_parent_state, p_board_handling, p_logfile); + item_list = p_item_list; + } /** * Creates a new SelectedItemState with with the items in p_item_list selected. * Returns null, if p_item_list is empty. */ - public static SelectedItemState get_instance(Set p_item_list, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - if (p_item_list.isEmpty()) - { + public static SelectedItemState get_instance(Set p_item_list, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + if (p_item_list.isEmpty()) { return null; } SelectedItemState new_state = new SelectedItemState(p_item_list, p_parent_state, p_board_handling, p_logfile); return new_state; } - /** Creates a new instance of SelectedItemState */ - private SelectedItemState(Set p_item_list, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_parent_state, p_board_handling, p_logfile); - item_list = p_item_list; - } - /** * Gets the list of the currently selected items. */ - public Collection get_item_list() - { + public Collection get_item_list() { return item_list; } - public InteractiveState left_button_clicked(FloatPoint p_location) - { + public InteractiveState left_button_clicked(FloatPoint p_location) { return toggle_select(p_location); } - public InteractiveState mouse_dragged(FloatPoint p_point) - { + public InteractiveState mouse_dragged(FloatPoint p_point) { return SelectItemsInRegionState.get_instance(hdlg.get_current_mouse_position(), this, hdlg, logfile); } /** * Action to be taken when a key is pressed (Shortcut). */ - public InteractiveState key_typed(char p_key_char) - { + public InteractiveState key_typed(char p_key_char) { InteractiveState result = this; - if (p_key_char == 'a') - { + if (p_key_char == 'a') { this.hdlg.autoroute_selected_items(); - } - else if (p_key_char == 'b') - { + } else if (p_key_char == 'b') { this.extent_to_whole_components(); - } - else if (p_key_char == 'd') - { + } else if (p_key_char == 'd') { result = this.cutout_items(); - } - else if (p_key_char == 'e') - { + } else if (p_key_char == 'e') { result = this.extent_to_whole_connections(); - } - else if (p_key_char == 'f') - { + } else if (p_key_char == 'f') { this.fix_items(); - } - else if (p_key_char == 'i') - { + } else if (p_key_char == 'i') { result = this.info(); - } - else if (p_key_char == 'm') - { + } else if (p_key_char == 'm') { result = MoveItemState.get_instance(hdlg.get_current_mouse_position(), item_list, this.return_state, hdlg, logfile); - } - else if (p_key_char == 'n') - { + } else if (p_key_char == 'n') { this.extent_to_whole_nets(); - } - else if (p_key_char == 'p') - { + } else if (p_key_char == 'p') { this.hdlg.optimize_selected_items(); - } - else if (p_key_char == 'r') - { + } else if (p_key_char == 'r') { result = ZoomRegionState.get_instance(hdlg.get_current_mouse_position(), this, hdlg, logfile); - } - else if (p_key_char == 's') - { + } else if (p_key_char == 's') { result = this.extent_to_whole_connected_sets(); - } - else if (p_key_char == 'u') - { + } else if (p_key_char == 'u') { this.unfix_items(); - } - else if (p_key_char == 'v') - { + } else if (p_key_char == 'v') { this.toggle_clearance_violations(); - } - else if (p_key_char == 'w') - { + } else if (p_key_char == 'w') { this.hdlg.zoom_selection(); - } - else if (p_key_char == java.awt.event.KeyEvent.VK_DELETE) - { + } else if (p_key_char == java.awt.event.KeyEvent.VK_DELETE) { result = delete_items(); - } - else - { + } else { result = super.key_typed(p_key_char); } return result; @@ -175,19 +125,15 @@ else if (p_key_char == java.awt.event.KeyEvent.VK_DELETE) /** * fixes all items in this selected set */ - public void fix_items() - { + public void fix_items() { java.util.Iterator it = item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if (curr_ob.get_fixed_state().ordinal() < FixedState.USER_FIXED.ordinal()) - { + if (curr_ob.get_fixed_state().ordinal() < FixedState.USER_FIXED.ordinal()) { curr_ob.set_fixed_state(FixedState.USER_FIXED); } } - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.FIX_SELECTED_ITEMS); } } @@ -195,16 +141,13 @@ public void fix_items() /** * unfixes all items in this selected set */ - public void unfix_items() - { + public void unfix_items() { java.util.Iterator it = item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); curr_ob.unfix(); } - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.UNFIX_SELECTED_ITEMS); } } @@ -213,44 +156,32 @@ public void unfix_items() * Makes all items in this selected_set connectable and assigns * them to a new net. */ - public InteractiveState assign_items_to_new_net() - { + public InteractiveState assign_items_to_new_net() { RoutingBoard board = hdlg.get_routing_board(); // make the situation restorable by undo board.generate_snapshot(); boolean items_already_connected = false; Net new_net = board.rules.nets.new_net(hdlg.get_locale()); java.util.Iterator it = item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_item instanceof ObstacleArea) - { + if (curr_item instanceof ObstacleArea) { board.make_conductive((ObstacleArea) curr_item, new_net.net_number); - } - else if (curr_item instanceof DrillItem) - { - if (curr_item.is_connected()) - { + } else if (curr_item instanceof DrillItem) { + if (curr_item.is_connected()) { items_already_connected = true; - } - else - { + } else { curr_item.assign_net_no(new_net.net_number); } } } - if (items_already_connected) - { + if (items_already_connected) { hdlg.screen_messages.set_status_message(resources.getString("some_items_are_not_changed_because_they_are_already_connected")); - } - else - { + } else { hdlg.screen_messages.set_status_message(resources.getString("new_net_created_from_selected_items")); } - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.ASSIGN_SELECTED_TO_NEW_NET); } hdlg.update_ratsnest(); @@ -261,8 +192,7 @@ else if (curr_item instanceof DrillItem) /** * Assigns all items in this selected_set to a new group( new component for example) */ - public InteractiveState assign_items_to_new_group() - { + public InteractiveState assign_items_to_new_group() { RoutingBoard board = hdlg.get_routing_board(); board.generate_snapshot(); // Take the gravity point of all item centers for the location of the new component. @@ -270,24 +200,19 @@ public InteractiveState assign_items_to_new_group() double gravity_y = 0; int pin_count = 0; java.util.Iterator it = item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if (curr_ob instanceof Via) - { + if (curr_ob instanceof Via) { FloatPoint curr_center = ((DrillItem) curr_ob).get_center().to_float(); gravity_x += curr_center.x; gravity_y += curr_center.y; ++pin_count; - } - else - { + } else { // currently only Vias can be aasigned to a new component it.remove(); } } - if (pin_count == 0) - { + if (pin_count == 0) { return this.return_state; } gravity_x /= pin_count; @@ -296,8 +221,7 @@ public InteractiveState assign_items_to_new_group() // create a new package Package.Pin[] pin_arr = new Package.Pin[item_list.size()]; it = item_list.iterator(); - for (int i = 0; i < pin_arr.length; ++i) - { + for (int i = 0; i < pin_arr.length; ++i) { Via curr_via = (Via) it.next(); Vector rel_coor = curr_via.get_center().difference_by(gravity_point); String pin_name = (new Integer(i + 1)).toString(); @@ -306,19 +230,16 @@ public InteractiveState assign_items_to_new_group() Package new_package = board.library.packages.add(pin_arr); Component new_component = board.components.add(gravity_point, 0, true, new_package); it = item_list.iterator(); - for (int i = 0; i < pin_arr.length; ++i) - { + for (int i = 0; i < pin_arr.length; ++i) { Via curr_via = (Via) it.next(); board.remove_item(curr_via); int[] net_no_arr = new int[curr_via.net_count()]; - for (int j = 0; j < net_no_arr.length; ++j) - { + for (int j = 0; j < net_no_arr.length; ++j) { net_no_arr[j] = curr_via.get_net_no(j); } board.insert_pin(new_component.no, i, net_no_arr, curr_via.clearance_class_no(), curr_via.get_fixed_state()); } - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.ASSIGN_SELECTED_TO_NEW_GROUP); } hdlg.repaint(); @@ -329,46 +250,36 @@ public InteractiveState assign_items_to_new_group() * Deletes all unfixed items in this selected set and * pulls tight the neighour traces. */ - public InteractiveState delete_items() - { + public InteractiveState delete_items() { hdlg.get_routing_board().generate_snapshot(); // calculate the changed nets for updating the ratsnest Set changed_nets = new TreeSet(); Iterator it = item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_item instanceof Connectable) - { - for (int i = 0; i < curr_item.net_count(); ++i) - { + if (curr_item instanceof Connectable) { + for (int i = 0; i < curr_item.net_count(); ++i) { changed_nets.add(curr_item.get_net_no(i)); } } } boolean with_delete_fixed = hdlg.get_routing_board().get_test_level() != TestLevel.RELEASE_VERSION; boolean all_items_removed; - if (hdlg.settings.push_enabled) - { + if (hdlg.settings.push_enabled) { all_items_removed = hdlg.get_routing_board().remove_items_and_pull_tight(item_list, hdlg.settings.trace_pull_tight_region_width, hdlg.settings.trace_pull_tight_accuracy, with_delete_fixed); - } - else - { + } else { all_items_removed = hdlg.get_routing_board().remove_items(item_list, with_delete_fixed); } - if (!all_items_removed) - { + if (!all_items_removed) { hdlg.screen_messages.set_status_message(resources.getString("some_items_are_fixed_and_could_therefore_not_be_removed")); } - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.DELETE_SELECTED); } - for (Integer curr_net_no : changed_nets) - { + for (Integer curr_net_no : changed_nets) { hdlg.update_ratsnest(curr_net_no.intValue()); } hdlg.repaint(); @@ -378,8 +289,7 @@ public InteractiveState delete_items() /** * Deletes all unfixed items in this selected set inside a rectangle */ - public InteractiveState cutout_items() - { + public InteractiveState cutout_items() { return CutoutRouteState.get_instance(this.item_list, this.return_state, hdlg, logfile); } @@ -387,12 +297,10 @@ public InteractiveState cutout_items() * Autoroutes the selected items. * If p_stoppable_thread != null, the algorithm can be requestet to terminate. */ - public InteractiveState autoroute(Stoppable p_stoppable_thread) - { + public InteractiveState autoroute(Stoppable p_stoppable_thread) { boolean saved_board_read_only = hdlg.is_board_read_only(); hdlg.set_board_read_only(true); - if (p_stoppable_thread != null) - { + if (p_stoppable_thread != null) { String start_message = resources.getString("autoroute") + " " + resources.getString("stop_message"); hdlg.screen_messages.set_status_message(start_message); } @@ -400,14 +308,10 @@ public InteractiveState autoroute(Stoppable p_stoppable_thread) Integer found_count = 0; boolean interrupted = false; Collection autoroute_item_list = new java.util.LinkedList(); - for (Item curr_item : item_list) - { - if (curr_item instanceof Connectable) - { - for (int i = 0; i < curr_item.net_count(); ++i) - { - if (!curr_item.get_unconnected_set(curr_item.get_net_no(i)).isEmpty()) - { + for (Item curr_item : item_list) { + if (curr_item instanceof Connectable) { + for (int i = 0; i < curr_item.net_count(); ++i) { + if (!curr_item.get_unconnected_set(curr_item.get_net_no(i)).isEmpty()) { autoroute_item_list.add(curr_item); } } @@ -418,61 +322,46 @@ public InteractiveState autoroute(Stoppable p_stoppable_thread) // Empty this.item_list to avoid displaying the seected items. this.item_list = new TreeSet(); boolean ratsnest_hidden_before = hdlg.get_ratsnest().is_hidden(); - if (!ratsnest_hidden_before) - { + if (!ratsnest_hidden_before) { hdlg.get_ratsnest().hide(); } - for (Item curr_item : autoroute_item_list) - { - if (p_stoppable_thread != null && p_stoppable_thread.is_stop_requested()) - { + for (Item curr_item : autoroute_item_list) { + if (p_stoppable_thread != null && p_stoppable_thread.is_stop_requested()) { interrupted = true; break; } - if (curr_item.net_count() != 1) - { + if (curr_item.net_count() != 1) { continue; } boolean contains_plane = false; net.freerouting.rules.Net route_net = hdlg.get_routing_board().rules.nets.get(curr_item.get_net_no(0)); - if (route_net != null) - { + if (route_net != null) { contains_plane = route_net.contains_plane(); } int via_costs; - if (contains_plane) - { + if (contains_plane) { via_costs = hdlg.settings.autoroute_settings.get_plane_via_costs(); - } - else - { + } else { via_costs = hdlg.settings.autoroute_settings.get_via_costs(); } hdlg.get_routing_board().start_marking_changed_area(); AutorouteEngine.AutorouteResult autoroute_result = hdlg.get_routing_board().autoroute(curr_item, hdlg.settings, via_costs, p_stoppable_thread, null); - if (autoroute_result == AutorouteEngine.AutorouteResult.ROUTED) - { + if (autoroute_result == AutorouteEngine.AutorouteResult.ROUTED) { ++found_count; hdlg.repaint(); - } - else if (autoroute_result != AutorouteEngine.AutorouteResult.ALREADY_CONNECTED) - { + } else if (autoroute_result != AutorouteEngine.AutorouteResult.ALREADY_CONNECTED) { ++not_found_count; } --items_to_go_count; hdlg.screen_messages.set_interactive_autoroute_info(found_count, not_found_count, items_to_go_count); } - if (p_stoppable_thread != null) - { + if (p_stoppable_thread != null) { hdlg.screen_messages.clear(); String curr_message; - if (interrupted) - { + if (interrupted) { curr_message = resources.getString("interrupted"); - } - else - { + } else { curr_message = resources.getString("completed"); } String end_message = resources.getString("autoroute") + " " + curr_message + ": " + found_count.toString() + @@ -481,13 +370,11 @@ else if (autoroute_result != AutorouteEngine.AutorouteResult.ALREADY_CONNECTED) hdlg.screen_messages.set_status_message(end_message); } hdlg.set_board_read_only(saved_board_read_only); - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.AUTOROUTE_SELECTED); } hdlg.update_ratsnest(); - if (!ratsnest_hidden_before) - { + if (!ratsnest_hidden_before) { hdlg.get_ratsnest().show(); } return this.return_state; @@ -497,12 +384,10 @@ else if (autoroute_result != AutorouteEngine.AutorouteResult.ALREADY_CONNECTED) * Fanouts the pins contained in the selected items. * If p_stoppable_thread != null, the algorithm can be requestet to terminate. */ - public InteractiveState fanout(Stoppable p_stoppable_thread) - { + public InteractiveState fanout(Stoppable p_stoppable_thread) { boolean saved_board_read_only = hdlg.is_board_read_only(); hdlg.set_board_read_only(true); - if (p_stoppable_thread != null) - { + if (p_stoppable_thread != null) { String start_message = resources.getString("fanout") + " " + resources.getString("stop_message"); hdlg.screen_messages.set_status_message(start_message); } @@ -511,10 +396,8 @@ public InteractiveState fanout(Stoppable p_stoppable_thread) int trace_pull_tight_accuracy = hdlg.settings.trace_pull_tight_accuracy; boolean interrupted = false; Collection fanout_list = new java.util.LinkedList(); - for (Item curr_item : item_list) - { - if (curr_item instanceof Pin) - { + for (Item curr_item : item_list) { + if (curr_item instanceof Pin) { fanout_list.add((Pin) curr_item); } } @@ -523,43 +406,33 @@ public InteractiveState fanout(Stoppable p_stoppable_thread) // Empty this.item_list to avoid displaying the seected items. this.item_list = new TreeSet(); boolean ratsnest_hidden_before = hdlg.get_ratsnest().is_hidden(); - if (!ratsnest_hidden_before) - { + if (!ratsnest_hidden_before) { hdlg.get_ratsnest().hide(); } - for (Pin curr_pin : fanout_list) - { - if (p_stoppable_thread != null && p_stoppable_thread.is_stop_requested()) - { + for (Pin curr_pin : fanout_list) { + if (p_stoppable_thread != null && p_stoppable_thread.is_stop_requested()) { interrupted = true; break; } hdlg.get_routing_board().start_marking_changed_area(); AutorouteEngine.AutorouteResult autoroute_result = hdlg.get_routing_board().fanout(curr_pin, hdlg.settings, -1, p_stoppable_thread, null); - if (autoroute_result == AutorouteEngine.AutorouteResult.ROUTED) - { + if (autoroute_result == AutorouteEngine.AutorouteResult.ROUTED) { ++found_count; hdlg.repaint(); - } - else if (autoroute_result != AutorouteEngine.AutorouteResult.ALREADY_CONNECTED) - { + } else if (autoroute_result != AutorouteEngine.AutorouteResult.ALREADY_CONNECTED) { ++not_found_count; } --items_to_go_count; hdlg.screen_messages.set_interactive_autoroute_info(found_count, not_found_count, items_to_go_count); } - if (p_stoppable_thread != null) - { + if (p_stoppable_thread != null) { hdlg.screen_messages.clear(); String curr_message; - if (interrupted) - { + if (interrupted) { curr_message = resources.getString("interrupted"); - } - else - { + } else { curr_message = resources.getString("completed"); } String end_message = resources.getString("fanout") + " " + curr_message + ": " + found_count.toString() + @@ -568,13 +441,11 @@ else if (autoroute_result != AutorouteEngine.AutorouteResult.ALREADY_CONNECTED) hdlg.screen_messages.set_status_message(end_message); } hdlg.set_board_read_only(saved_board_read_only); - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.FANOUT_SELECTED); } hdlg.update_ratsnest(); - if (!ratsnest_hidden_before) - { + if (!ratsnest_hidden_before) { hdlg.get_ratsnest().show(); } return this.return_state; @@ -584,69 +455,54 @@ else if (autoroute_result != AutorouteEngine.AutorouteResult.ALREADY_CONNECTED) * Optimizes the selected items. * If p_stoppable_thread != null, the algorithm can be requestet to terminate. */ - public InteractiveState pull_tight(Stoppable p_stoppable_thread) - { + public InteractiveState pull_tight(Stoppable p_stoppable_thread) { boolean saved_board_read_only = hdlg.is_board_read_only(); hdlg.set_board_read_only(true); - if (p_stoppable_thread != null) - { + if (p_stoppable_thread != null) { String start_message = resources.getString("pull_tight") + " " + resources.getString("stop_message"); hdlg.screen_messages.set_status_message(start_message); } hdlg.get_routing_board().start_marking_changed_area(); boolean interrupted = false; - for (Item curr_item : item_list) - { - if (p_stoppable_thread != null && p_stoppable_thread.is_stop_requested()) - { + for (Item curr_item : item_list) { + if (p_stoppable_thread != null && p_stoppable_thread.is_stop_requested()) { interrupted = true; break; } - if (curr_item.net_count() != 1) - { + if (curr_item.net_count() != 1) { continue; } - if (curr_item instanceof PolylineTrace) - { + if (curr_item instanceof PolylineTrace) { PolylineTrace curr_trace = (PolylineTrace) curr_item; boolean something_changed = curr_trace.pull_tight(!hdlg.settings.push_enabled, hdlg.settings.trace_pull_tight_accuracy, p_stoppable_thread); - if (!something_changed) - { + if (!something_changed) { curr_trace.smoothen_end_corners_fork(!hdlg.settings.push_enabled, hdlg.settings.trace_pull_tight_accuracy, p_stoppable_thread); } - } - else if (curr_item instanceof Via) - { + } else if (curr_item instanceof Via) { OptViaAlgo.opt_via_location(hdlg.get_routing_board(), (Via) curr_item, null, hdlg.settings.trace_pull_tight_accuracy, 10); } } String curr_message; - if (hdlg.settings.push_enabled && !interrupted) - { + if (hdlg.settings.push_enabled && !interrupted) { hdlg.get_routing_board().opt_changed_area(new int[0], null, hdlg.settings.trace_pull_tight_accuracy, null, p_stoppable_thread, 0); } - if (p_stoppable_thread != null) - { - if (interrupted) - { + if (p_stoppable_thread != null) { + if (interrupted) { curr_message = resources.getString("interrupted"); - } - else - { + } else { curr_message = resources.getString("completed"); } String end_message = resources.getString("pull_tight") + " " + curr_message; hdlg.screen_messages.set_status_message(end_message); } hdlg.set_board_read_only(saved_board_read_only); - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.OPTIMIZE_SELECTED); } hdlg.update_ratsnest(); @@ -656,24 +512,19 @@ else if (curr_item instanceof Via) /** * Assigns the input clearance class to the selected items. */ - public InteractiveState assign_clearance_class(int p_cl_class_index) - { + public InteractiveState assign_clearance_class(int p_cl_class_index) { net.freerouting.board.BasicBoard routing_board = this.hdlg.get_routing_board(); - if (p_cl_class_index < 0 || p_cl_class_index >= routing_board.rules.clearance_matrix.get_class_count()) - { + if (p_cl_class_index < 0 || p_cl_class_index >= routing_board.rules.clearance_matrix.get_class_count()) { return this.return_state; } - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.ASSIGN_CLEARANCE_CLASS); logfile.add_int(p_cl_class_index); } // make the situation restorable by undo routing_board.generate_snapshot(); - for (Item curr_item : this.item_list) - { - if (curr_item.clearance_class_no() == p_cl_class_index) - { + for (Item curr_item : this.item_list) { + if (curr_item.clearance_class_no() == p_cl_class_index) { continue; } curr_item.change_clearance_class(p_cl_class_index); @@ -684,37 +535,30 @@ public InteractiveState assign_clearance_class(int p_cl_class_index) /** * Select also all items belonging to any net of the current selected items. */ - public InteractiveState extent_to_whole_nets() - { + public InteractiveState extent_to_whole_nets() { // collect all net numbers of the selected items Set curr_net_no_set = new TreeSet(); Iterator it = item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_item instanceof Connectable) - { - for (int i = 0; i < curr_item.net_count(); ++i) - { + if (curr_item instanceof Connectable) { + for (int i = 0; i < curr_item.net_count(); ++i) { curr_net_no_set.add(curr_item.get_net_no(i)); } } } Set new_selected_items = new TreeSet(); Iterator it2 = curr_net_no_set.iterator(); - while (it2.hasNext()) - { + while (it2.hasNext()) { int curr_net_no = it2.next(); new_selected_items.addAll(hdlg.get_routing_board().get_connectable_items(curr_net_no)); } this.item_list = new_selected_items; - if (new_selected_items.isEmpty()) - { + if (new_selected_items.isEmpty()) { return this.return_state; } - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.EXTEND_TO_WHOLE_NETS); } filter(); @@ -725,35 +569,29 @@ public InteractiveState extent_to_whole_nets() /** * Select also all items belonging to any group of the current selected items. */ - public InteractiveState extent_to_whole_components() - { + public InteractiveState extent_to_whole_components() { // collect all group numbers of the selected items Set curr_group_no_set = new TreeSet(); Iterator it = item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_item.get_component_no() > 0) - { + if (curr_item.get_component_no() > 0) { curr_group_no_set.add(curr_item.get_component_no()); } } Set new_selected_items = new TreeSet(); new_selected_items.addAll(item_list); Iterator it2 = curr_group_no_set.iterator(); - while (it2.hasNext()) - { + while (it2.hasNext()) { int curr_group_no = it2.next(); new_selected_items.addAll(hdlg.get_routing_board().get_component_items(curr_group_no)); } - if (new_selected_items.isEmpty()) - { + if (new_selected_items.isEmpty()) { return this.return_state; } this.item_list = new_selected_items; - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.EXTEND_TO_WHOLE_COMPONENTS); } hdlg.repaint(); @@ -763,25 +601,20 @@ public InteractiveState extent_to_whole_components() /** * Select also all items belonging to any connected set of the current selected items. */ - public InteractiveState extent_to_whole_connected_sets() - { + public InteractiveState extent_to_whole_connected_sets() { Set new_selected_items = new TreeSet(); Iterator it = this.item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_item instanceof Connectable) - { + if (curr_item instanceof Connectable) { new_selected_items.addAll(curr_item.get_connected_set(-1)); } } - if (new_selected_items.isEmpty()) - { + if (new_selected_items.isEmpty()) { return this.return_state; } this.item_list = new_selected_items; - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.EXTEND_TO_WHOLE_CONNECTED_SETS); } filter(); @@ -792,25 +625,20 @@ public InteractiveState extent_to_whole_connected_sets() /** * Select also all items belonging to any connection of the current selected items. */ - public InteractiveState extent_to_whole_connections() - { + public InteractiveState extent_to_whole_connections() { Set new_selected_items = new TreeSet(); Iterator it = this.item_list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if (curr_item instanceof Connectable) - { + if (curr_item instanceof Connectable) { new_selected_items.addAll(curr_item.get_connection_items()); } } - if (new_selected_items.isEmpty()) - { + if (new_selected_items.isEmpty()) { return this.return_state; } this.item_list = new_selected_items; - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.EXTEND_TO_WHOLE_CONNECTIONS); } filter(); @@ -824,38 +652,28 @@ public InteractiveState extent_to_whole_connections() * otherwise adds it to the list. * Returns true (to change to the return_state) if nothing was picked. */ - public InteractiveState toggle_select(FloatPoint p_point) - { + public InteractiveState toggle_select(FloatPoint p_point) { Collection picked_items = hdlg.pick_items(p_point); boolean state_ended = (picked_items.isEmpty()); - if (picked_items.size() == 1) - { + if (picked_items.size() == 1) { Item picked_item = picked_items.iterator().next(); - if (this.item_list.contains(picked_item)) - { + if (this.item_list.contains(picked_item)) { this.item_list.remove(picked_item); - if (this.item_list.isEmpty()) - { + if (this.item_list.isEmpty()) { state_ended = true; } - } - else - { + } else { this.item_list.add(picked_item); } } hdlg.repaint(); InteractiveState result; - if (state_ended) - { + if (state_ended) { result = this.return_state; - } - else - { + } else { result = this; } - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.TOGGLE_SELECT, p_point); } return result; @@ -864,17 +682,13 @@ public InteractiveState toggle_select(FloatPoint p_point) /** * Shows or hides the clearance violations of the selected items.. */ - public void toggle_clearance_violations() - { - if (clearance_violations == null) - { + public void toggle_clearance_violations() { + if (clearance_violations == null) { clearance_violations = new ClearanceViolations(this.item_list); Integer violation_count = new Integer(clearance_violations.list.size()); String curr_message = violation_count.toString() + " " + resources.getString("clearance_violations_found"); hdlg.screen_messages.set_status_message(curr_message); - } - else - { + } else { clearance_violations = null; hdlg.screen_messages.set_status_message(""); } @@ -884,12 +698,10 @@ public void toggle_clearance_violations() /** * Removes items not selected by the current interactive filter from the selected item list. */ - public InteractiveState filter() - { + public InteractiveState filter() { item_list = hdlg.settings.item_selection_filter.filter(item_list); InteractiveState result = this; - if (item_list.isEmpty()) - { + if (item_list.isEmpty()) { result = this.return_state; } hdlg.repaint(); @@ -899,49 +711,38 @@ public InteractiveState filter() /** * Prints information about the selected item into a graphical text window. */ - public SelectedItemState info() - { + public SelectedItemState info() { net.freerouting.gui.WindowObjectInfo.display(this.item_list, hdlg.get_panel().board_frame, hdlg.coordinate_transform, new java.awt.Point(100, 100)); return this; } - public String get_help_id() - { + public String get_help_id() { return "SelectedItemState"; } - public void draw(java.awt.Graphics p_graphics) - { - if (item_list == null) - { + public void draw(java.awt.Graphics p_graphics) { + if (item_list == null) { return; } - for (net.freerouting.board.Item curr_item : item_list) - { + for (net.freerouting.board.Item curr_item : item_list) { curr_item.draw(p_graphics, hdlg.graphics_context, hdlg.graphics_context.get_hilight_color(), hdlg.graphics_context.get_hilight_color_intensity()); } - if (clearance_violations != null) - { + if (clearance_violations != null) { clearance_violations.draw(p_graphics, hdlg.graphics_context); } } - public javax.swing.JPopupMenu get_popup_menu() - { + public javax.swing.JPopupMenu get_popup_menu() { return hdlg.get_panel().popup_menu_select; } - public void set_toolbar() - { + public void set_toolbar() { hdlg.get_panel().board_frame.set_select_toolbar(); } - public void display_default_message() - { + public void display_default_message() { hdlg.screen_messages.set_status_message(resources.getString("in_select_item_mode")); } - private Set item_list; - private ClearanceViolations clearance_violations = null; } diff --git a/src/main/java/net/freerouting/interactive/Settings.java b/src/main/java/net/freerouting/interactive/Settings.java index b2ea3f48..943fd1ae 100644 --- a/src/main/java/net/freerouting/interactive/Settings.java +++ b/src/main/java/net/freerouting/interactive/Settings.java @@ -26,13 +26,102 @@ /** * Contains the values of the interactive settings of the board handling. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Settings implements java.io.Serializable -{ - /** Creates a new interactive settings variable. */ - public Settings(RoutingBoard p_board, Logfile p_logfile) - { +public class Settings implements java.io.Serializable { + /** + * The array of manual trace half widths, initially equal to the automatic trace half widths. + */ + final int[] manual_trace_half_width_arr; + public AutorouteSettings autoroute_settings; + /** + * the current layer + */ + int layer; + /** + * allows pushing obstacles aside + */ + boolean push_enabled; + /** + * allows dragging components with the route + */ + boolean drag_components_enabled; + /** + * indicates if interactive selections are made on all visible layers or only on the current layer. + */ + boolean select_on_all_visible_layers; + /** + * Route mode: stitching or dynamic + */ + boolean is_stitch_route; + /** + * The width of the pull tight region of traces around the cursor + */ + int trace_pull_tight_region_width; + /** + * The accuracy of the pull tight algorithm. + */ + int trace_pull_tight_accuracy; + /** + * Via snaps to smd center, if attach smd is alllowed. + */ + boolean via_snap_to_smd_center; + /** + * The horizontal placement grid when moving components, if > 0. + */ + int horizontal_component_grid; + /** + * The vertical placement grid when moving components, if > 0. + */ + int vertical_component_grid; + /** + * If true, the trace width at static pins smaller the the trace width will be lowered + * automatically to the pin with, if necessary. + */ + boolean automatic_neckdown; + /** + * Indicates if the routing rule selection is manual by the user or automatic by the net rules. + */ + boolean manual_rule_selection; + /** + * If true, the current routing obstacle is hilightet in dynamic routing. + */ + boolean hilight_routing_obstacle; + /** + * The index of the clearance class used for traces in interactive routing in the clearance matrix, + * if manual_route_selection is on. + */ + int manual_trace_clearance_class; + /** + * The index of the via rule used in routing in the board via rules if manual_route_selection is on. + */ + int manual_via_rule_index; + /** + * If true, the mouse wheel is used for zooming. + */ + boolean zoom_with_wheel; + /** + * The filter used in interactive selection of board items. + */ + ItemSelectionFilter item_selection_filter; + /** + * Defines the data of the snapshot selected for restoring. + */ + SnapShot.Attributes snapshot_attributes; + /** + * Indicates, if the data of this class are not allowed to be changed in ineractive board editing. + */ + private transient boolean read_only = false; + /** + * The file used for logging interactive action, + * so that they can be replayed later + */ + private transient Logfile logfile; + + /** + * Creates a new interactive settings variable. + */ + public Settings(RoutingBoard p_board, Logfile p_logfile) { this.logfile = p_logfile; // Initialise with default values. layer = 0; @@ -52,20 +141,18 @@ public Settings(RoutingBoard p_board, Logfile p_logfile) manual_via_rule_index = 0; zoom_with_wheel = true; manual_trace_half_width_arr = new int[p_board.get_layer_count()]; - for (int i = 0; i < manual_trace_half_width_arr.length; ++i) - { + for (int i = 0; i < manual_trace_half_width_arr.length; ++i) { manual_trace_half_width_arr[i] = 1000; } autoroute_settings = new AutorouteSettings(p_board); item_selection_filter = new ItemSelectionFilter(); snapshot_attributes = new SnapShot.Attributes(); } - + /** * Copy constructor */ - public Settings(Settings p_settings) - { + public Settings(Settings p_settings) { this.logfile = p_settings.logfile; this.read_only = p_settings.read_only; this.layer = p_settings.layer; @@ -84,501 +171,382 @@ public Settings(Settings p_settings) this.zoom_with_wheel = p_settings.zoom_with_wheel; this.manual_trace_clearance_class = p_settings.manual_trace_clearance_class; this.manual_via_rule_index = p_settings.manual_via_rule_index; - this.manual_trace_half_width_arr = new int [p_settings.manual_trace_half_width_arr.length]; + this.manual_trace_half_width_arr = new int[p_settings.manual_trace_half_width_arr.length]; System.arraycopy(p_settings.manual_trace_half_width_arr, 0, this.manual_trace_half_width_arr, 0, this.manual_trace_half_width_arr.length); this.autoroute_settings = new AutorouteSettings(p_settings.autoroute_settings); this.item_selection_filter = new ItemSelectionFilter(p_settings.item_selection_filter); this.snapshot_attributes = new SnapShot.Attributes(p_settings.snapshot_attributes); } - - public int get_layer() - { + + public int get_layer() { return this.layer; } - - /** allows pushing obstacles aside */ - public boolean get_push_enabled() - { + + /** + * allows pushing obstacles aside + */ + public boolean get_push_enabled() { return this.push_enabled; } - - /** Route mode: stitching or dynamic */ - public boolean get_is_stitch_route() - { + + /** + * Enables or disables pushing obstacles in interactive routing + */ + public void set_push_enabled(boolean p_value) { + if (read_only) { + return; + } + push_enabled = p_value; + logfile.start_scope(LogfileScope.SET_PUSH_ENABLED, p_value); + } + + /** + * Route mode: stitching or dynamic + */ + public boolean get_is_stitch_route() { return this.is_stitch_route; } - /** allows dragging components with the route */ - public boolean get_drag_components_enabled() - { + + /** + * allows dragging components with the route + */ + public boolean get_drag_components_enabled() { return this.drag_components_enabled; } - - /** indicates if interactive selections are made on all visible layers or only on the current layer.*/ - public boolean get_select_on_all_visible_layers() - { + + /** + * Enables or disables dragging components + */ + public void set_drag_components_enabled(boolean p_value) { + if (read_only) { + return; + } + drag_components_enabled = p_value; + logfile.start_scope(LogfileScope.SET_DRAG_COMPONENTS_ENABLED, p_value); + } + + /** + * indicates if interactive selections are made on all visible layers or only on the current layer. + */ + public boolean get_select_on_all_visible_layers() { return this.select_on_all_visible_layers; } - - /** Indicates if the routing rule selection is manual by the user or automatic by the net rules. */ - public boolean get_manual_rule_selection() - { + + /** + * Sets, if item selection is on all board layers or only + * on the current layer. + */ + public void set_select_on_all_visible_layers(boolean p_value) { + if (read_only) { + return; + } + select_on_all_visible_layers = p_value; + logfile.start_scope(LogfileScope.SET_SELECT_ON_ALL_LAYER, p_value); + } + + /** + * Indicates if the routing rule selection is manual by the user or automatic by the net rules. + */ + public boolean get_manual_rule_selection() { return this.manual_rule_selection; } - + /** * Via snaps to smd center, if attach smd is alllowed. */ - public boolean get_via_snap_to_smd_center() - { + public boolean get_via_snap_to_smd_center() { return this.via_snap_to_smd_center; } - - /** If true, the current routing obstacle is hilightet in dynamic routing. */ - public boolean get_hilight_routing_obstacle() - { + + /** + * Changes, if vias snap to smd center, if attach smd is allowed. + */ + public void set_via_snap_to_smd_center(boolean p_value) { + if (read_only) { + return; + } + via_snap_to_smd_center = p_value; + } + + /** + * If true, the current routing obstacle is hilightet in dynamic routing. + */ + public boolean get_hilight_routing_obstacle() { return this.hilight_routing_obstacle; } - + + /** + * If true, the current routing obstacle is hilightet in dynamic routing. + */ + public void set_hilight_routing_obstacle(boolean p_value) { + if (read_only) { + return; + } + this.hilight_routing_obstacle = p_value; + } + /** * If true, the trace width at static pins smaller the the trace width will be lowered * automatically to the pin with, if necessary. */ - public boolean get_automatic_neckdown() - { + public boolean get_automatic_neckdown() { return this.automatic_neckdown; } - - /** If true, the mouse wheel is used for zooming. */ - public boolean get_zoom_with_wheel() - { - return this.zoom_with_wheel; - } - - /** The filter used in interactive selection of board items. */ - public ItemSelectionFilter get_item_selection_filter() - { - return this.item_selection_filter; - } - - /** The width of the pull tight region of traces around the cursor */ - public int get_trace_pull_tight_region_width() - { - return this.trace_pull_tight_region_width; - } - + /** - * The horizontal placement grid when moving components, if > 0. + * If true, the trace width at static pins smaller the the trace width will be lowered + * automatically to the pin with, if necessary. */ - public int get_horizontal_component_grid() - { - return this.horizontal_component_grid; + public void set_automatic_neckdown(boolean p_value) { + if (read_only) { + return; + } + this.automatic_neckdown = p_value; } - + /** - * The vertical placement grid when moving components, if > 0. + * If true, the mouse wheel is used for zooming. */ - public int get_vertical_component_grid() - { - return this.vertical_component_grid; + public boolean get_zoom_with_wheel() { + return this.zoom_with_wheel; } - + /** - * The index of the clearance class used for traces in interactive routing in the clearance matrix, - * if manual_route_selection is on. + * If true, the wheel is used for zooming. */ - public int get_manual_trace_clearance_class() - { - return this.manual_trace_clearance_class; + public void set_zoom_with_wheel(boolean p_value) { + if (read_only) { + return; + } + if (zoom_with_wheel != p_value) { + zoom_with_wheel = p_value; + if (logfile != null) { + logfile.start_scope(LogfileScope.SET_ZOOM_WITH_WHEEL, p_value); + } + } } - + /** - * The index of the via rule used in routing in the board via rules if manual_route_selection is on. + * The filter used in interactive selection of board items. */ - public int get_manual_via_rule_index() - { - return this.manual_via_rule_index; - } - - /** The accuracy of the pull tight algorithm. */ - public int get_trace_pull_tight_accuracy() - { - return this.trace_pull_tight_accuracy; - } - - /** Defines the data of the snapshot selected for restoring. */ - public SnapShot.Attributes get_snapshot_attributes() - { - return this.snapshot_attributes; - } - - /** Get the trace half width in manual routing mode on layer p_layer_no */ - public int get_manual_trace_half_width( int p_layer_no) - { - if (p_layer_no < 0 || p_layer_no >= this.manual_trace_half_width_arr.length) - { - System.out.println("Settings.get_manual_trace_half_width p_layer_no out of range"); - return 0; - } - return this.manual_trace_half_width_arr[p_layer_no]; + public ItemSelectionFilter get_item_selection_filter() { + return this.item_selection_filter; } - + /** - * The index of the via rule used in routing in the board via rules if manual_route_selection is on. + * The filter used in interactive selection of board items. */ - public void set_manual_via_rule_index(int p_value) - { - if (read_only) - { + public void set_item_selection_filter(ItemSelectionFilter p_value) { + if (read_only) { return; } - this.manual_via_rule_index = p_value; + this.item_selection_filter = p_value; } - + + /** + * The width of the pull tight region of traces around the cursor + */ + public int get_trace_pull_tight_region_width() { + return this.trace_pull_tight_region_width; + } + /** * The horizontal placement grid when moving components, if > 0. */ - public void set_horizontal_component_grid(int p_value) - { - if (read_only) - { + public int get_horizontal_component_grid() { + return this.horizontal_component_grid; + } + + /** + * The horizontal placement grid when moving components, if > 0. + */ + public void set_horizontal_component_grid(int p_value) { + if (read_only) { return; } this.horizontal_component_grid = p_value; } - + + /** + * The vertical placement grid when moving components, if > 0. + */ + public int get_vertical_component_grid() { + return this.vertical_component_grid; + } + /** * The vertical placement grid when moving components, if > 0. */ - public void set_vertical_component_grid(int p_value) - { - if (read_only) - { + public void set_vertical_component_grid(int p_value) { + if (read_only) { return; } this.vertical_component_grid = p_value; } - - /** If true, the current routing obstacle is hilightet in dynamic routing. */ - public void set_hilight_routing_obstacle(boolean p_value) - { - if (read_only) - { - return; - } - this.hilight_routing_obstacle = p_value; + + /** + * The index of the clearance class used for traces in interactive routing in the clearance matrix, + * if manual_route_selection is on. + */ + public int get_manual_trace_clearance_class() { + return this.manual_trace_clearance_class; } - + /** - * If true, the trace width at static pins smaller the the trace width will be lowered - * automatically to the pin with, if necessary. + * The index of the clearance class used for traces in interactive routing in the clearance matrix, + * if manual_route_selection is on. */ - public void set_automatic_neckdown(boolean p_value) - { - if (read_only) - { + public void set_manual_trace_clearance_class(int p_index) { + if (read_only) { return; } - this.automatic_neckdown = p_value; + manual_trace_clearance_class = p_index; + logfile.start_scope(LogfileScope.SET_MANUAL_TRACE_CLEARANCE_CLASS, p_index); } - - /** The filter used in interactive selection of board items. */ - public void set_item_selection_filter(ItemSelectionFilter p_value) - { - if (read_only) - { - return; - } - this.item_selection_filter = p_value; + + /** + * The index of the via rule used in routing in the board via rules if manual_route_selection is on. + */ + public int get_manual_via_rule_index() { + return this.manual_via_rule_index; } - + /** - * Enables or disables pushing obstacles in interactive routing + * The index of the via rule used in routing in the board via rules if manual_route_selection is on. */ - public void set_push_enabled(boolean p_value) - { - if (read_only) - { + public void set_manual_via_rule_index(int p_value) { + if (read_only) { return; } - push_enabled = p_value; - logfile.start_scope(LogfileScope.SET_PUSH_ENABLED, p_value); + this.manual_via_rule_index = p_value; } - + /** - * Enables or disables dragging components + * The accuracy of the pull tight algorithm. */ - public void set_drag_components_enabled(boolean p_value) - { - if (read_only) - { - return; - } - drag_components_enabled = p_value; - logfile.start_scope(LogfileScope.SET_DRAG_COMPONENTS_ENABLED, p_value); + public int get_trace_pull_tight_accuracy() { + return this.trace_pull_tight_accuracy; } - - + /** - * Sets, if item selection is on all board layers or only - * on the current layer. + * Defines the data of the snapshot selected for restoring. */ - public void set_select_on_all_visible_layers(boolean p_value) - { - if (read_only) - { - return; + public SnapShot.Attributes get_snapshot_attributes() { + return this.snapshot_attributes; + } + + /** + * Get the trace half width in manual routing mode on layer p_layer_no + */ + public int get_manual_trace_half_width(int p_layer_no) { + if (p_layer_no < 0 || p_layer_no >= this.manual_trace_half_width_arr.length) { + System.out.println("Settings.get_manual_trace_half_width p_layer_no out of range"); + return 0; } - select_on_all_visible_layers = p_value; - logfile.start_scope(LogfileScope.SET_SELECT_ON_ALL_LAYER, p_value); + return this.manual_trace_half_width_arr[p_layer_no]; } - - /** Route mode: stitching or dynamic */ - public void set_stitch_route(boolean p_value) - { - if (read_only) - { + + /** + * Route mode: stitching or dynamic + */ + public void set_stitch_route(boolean p_value) { + if (read_only) { return; } is_stitch_route = p_value; - + logfile.start_scope(LogfileScope.SET_STITCH_ROUTE, p_value); } - + /** * Changes the current width of the tidy region for traces. */ - public void set_current_pull_tight_region_width(int p_value) - { - if (read_only) - { + public void set_current_pull_tight_region_width(int p_value) { + if (read_only) { return; } trace_pull_tight_region_width = p_value; logfile.start_scope(LogfileScope.SET_PULL_TIGHT_REGION_WIDTH, p_value); } - + /** * Changes the current width of the pull tight accuracy for traces. */ - public void set_current_pull_tight_accuracy(int p_value) - { - if (read_only) - { + public void set_current_pull_tight_accuracy(int p_value) { + if (read_only) { return; } trace_pull_tight_accuracy = p_value; logfile.start_scope(LogfileScope.SET_PULL_TIGHT_ACCURACY, p_value); } - - /** - * Changes, if vias snap to smd center, if attach smd is allowed. - */ - public void set_via_snap_to_smd_center(boolean p_value) - { - if (read_only) - { - return; - } - via_snap_to_smd_center = p_value; - } - - + /** * Sets the current trace width selection to manual or automatic. */ - public void set_manual_tracewidth_selection(boolean p_value) - { - if (read_only) - { + public void set_manual_tracewidth_selection(boolean p_value) { + if (read_only) { return; } manual_rule_selection = p_value; logfile.start_scope(LogfileScope.SET_MANUAL_TRACEWITH_SELECTION, p_value); } - + /** * Sets the manual trace half width used in interactive routing. */ - public void set_manual_trace_half_width( int p_layer_no, int p_value) - { - if (read_only) - { + public void set_manual_trace_half_width(int p_layer_no, int p_value) { + if (read_only) { return; } manual_trace_half_width_arr[p_layer_no] = p_value; logfile.start_scope(LogfileScope.SET_MANUAL_TRACE_HALF_WIDTH, p_layer_no); logfile.add_int(p_value); } - - - /** - * The index of the clearance class used for traces in interactive routing in the clearance matrix, - * if manual_route_selection is on. - */ - public void set_manual_trace_clearance_class(int p_index) - { - if (read_only) - { - return; - } - manual_trace_clearance_class = p_index; - logfile.start_scope(LogfileScope.SET_MANUAL_TRACE_CLEARANCE_CLASS, p_index); - } - - /** - * If true, the wheel is used for zooming. - */ - public void set_zoom_with_wheel(boolean p_value) - { - if (read_only) - { - return; - } - if (zoom_with_wheel != p_value) - { - zoom_with_wheel = p_value; - if (logfile != null) - { - logfile.start_scope(LogfileScope.SET_ZOOM_WITH_WHEEL, p_value); - } - } - } - + /** * Changes the interactive selectability of p_item_type. */ - public void set_selectable(ItemSelectionFilter.SelectableChoices p_item_type, boolean p_value) - { - if (read_only) - { + public void set_selectable(ItemSelectionFilter.SelectableChoices p_item_type, boolean p_value) { + if (read_only) { return; } item_selection_filter.set_selected(p_item_type, p_value); - + logfile.start_scope(LogfileScope.SET_SELECTABLE, p_item_type.ordinal()); int logged_value; - if (p_value) - { + if (p_value) { logged_value = 1; - } - else - { + } else { logged_value = 0; } logfile.add_int(logged_value); } - + /** * Defines, if the setting attributes are allowed to be changed interactively or not. */ - public void set_read_only(Boolean p_value) - { - this.read_only = p_value; + public void set_read_only(Boolean p_value) { + this.read_only = p_value; } - - void set_logfile(Logfile p_logfile) - { + + void set_logfile(Logfile p_logfile) { this.logfile = p_logfile; } - - /** Reads an instance of this class from a file */ + + /** + * Reads an instance of this class from a file + */ private void readObject(java.io.ObjectInputStream p_stream) - throws java.io.IOException, java.lang.ClassNotFoundException - { + throws java.io.IOException, java.lang.ClassNotFoundException { p_stream.defaultReadObject(); - if (this.item_selection_filter == null) - { + if (this.item_selection_filter == null) { System.out.println("Settings.readObject: item_selection_filter is null"); this.item_selection_filter = new ItemSelectionFilter(); } - if (this.snapshot_attributes == null) - { + if (this.snapshot_attributes == null) { System.out.println("Settings.readObject: snapshot_attributes is null"); this.snapshot_attributes = new SnapShot.Attributes(); } this.read_only = false; } - - - /** the current layer */ - int layer; - - /** allows pushing obstacles aside */ - boolean push_enabled; - - /** allows dragging components with the route */ - boolean drag_components_enabled; - - /** indicates if interactive selections are made on all visible layers or only on the current layer.*/ - boolean select_on_all_visible_layers ; - - /** Route mode: stitching or dynamic */ - boolean is_stitch_route; - - /** The width of the pull tight region of traces around the cursor */ - int trace_pull_tight_region_width; - - /** The accuracy of the pull tight algorithm. */ - int trace_pull_tight_accuracy; - - /** - * Via snaps to smd center, if attach smd is alllowed. - */ - boolean via_snap_to_smd_center; - - /** - * The horizontal placement grid when moving components, if > 0. - */ - int horizontal_component_grid; - - /** - * The vertical placement grid when moving components, if > 0. - */ - int vertical_component_grid; - - /** - * If true, the trace width at static pins smaller the the trace width will be lowered - * automatically to the pin with, if necessary. - */ - boolean automatic_neckdown; - - /** Indicates if the routing rule selection is manual by the user or automatic by the net rules. */ - boolean manual_rule_selection; - - /** If true, the current routing obstacle is hilightet in dynamic routing. */ - boolean hilight_routing_obstacle; - - /** - * The index of the clearance class used for traces in interactive routing in the clearance matrix, - * if manual_route_selection is on. - */ - int manual_trace_clearance_class; - - /** - * The index of the via rule used in routing in the board via rules if manual_route_selection is on. - */ - int manual_via_rule_index; - - /** If true, the mouse wheel is used for zooming. */ - boolean zoom_with_wheel; - - /** The array of manual trace half widths, initially equal to the automatic trace half widths. */ - final int [] manual_trace_half_width_arr; - - public AutorouteSettings autoroute_settings; - - /** The filter used in interactive selection of board items. */ - ItemSelectionFilter item_selection_filter; - - /** Defines the data of the snapshot selected for restoring. */ - SnapShot.Attributes snapshot_attributes; - - /** Indicates, if the data of this class are not allowed to be changed in ineractive board editing. */ - private transient boolean read_only = false; - - /** - * The file used for logging interactive action, - * so that they can be replayed later - */ - private transient Logfile logfile; } diff --git a/src/main/java/net/freerouting/interactive/SnapShot.java b/src/main/java/net/freerouting/interactive/SnapShot.java index 14e5ec49..0e405e2d 100644 --- a/src/main/java/net/freerouting/interactive/SnapShot.java +++ b/src/main/java/net/freerouting/interactive/SnapShot.java @@ -23,175 +23,156 @@ /** * Snapshot of the client situation in an interactive session. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class SnapShot implements java.io.Serializable -{ +public class SnapShot implements java.io.Serializable { + public final Settings settings; + public final net.freerouting.boardgraphics.GraphicsContext graphics_context; + public final net.freerouting.gui.BoardFrame.SubwindowSelections subwindow_filters; + private final String name; + private final int interactive_state_no; + private final java.awt.Point viewport_position; + + /** + * Creates a SnapShot of the display region and the interactive settings + */ + private SnapShot(String p_name, BoardHandling p_board_handling) { + this.name = p_name; + this.settings = new Settings(p_board_handling.settings); + this.interactive_state_no = get_no(p_board_handling.interactive_state); + this.graphics_context = new net.freerouting.boardgraphics.GraphicsContext(p_board_handling.graphics_context); + this.viewport_position = new java.awt.Point(p_board_handling.get_panel().get_viewport_position()); + this.subwindow_filters = p_board_handling.get_panel().board_frame.get_snapshot_subwindow_selections(); + } + /** * Returns a new snapshot or null, if the current interactive state * is not suitable to generate a snapshot. */ - public static SnapShot get_instance(String p_name, BoardHandling p_board_handling) - { + public static SnapShot get_instance(String p_name, BoardHandling p_board_handling) { InteractiveState interactive_state = p_board_handling.interactive_state; - if (!(interactive_state instanceof MenuState)) - { + if (!(interactive_state instanceof MenuState)) { return null; } return new SnapShot(p_name, p_board_handling); } - - /** Creates a SnapShot of the display region and the interactive settings */ - private SnapShot(String p_name, BoardHandling p_board_handling) - { - this.name = p_name; - this.settings = new Settings(p_board_handling.settings); - this.interactive_state_no = get_no(p_board_handling.interactive_state); - this.graphics_context = new net.freerouting.boardgraphics.GraphicsContext(p_board_handling.graphics_context); - this.viewport_position = new java.awt.Point(p_board_handling.get_panel().get_viewport_position()); - this.subwindow_filters = p_board_handling.get_panel().board_frame.get_snapshot_subwindow_selections(); + + /** + * Create a number for writing an interactive state to disk. + * Only MenuStates are saved. The default is SelectState. + */ + private static int get_no(InteractiveState p_interactive_state) { + int result; + if (p_interactive_state instanceof RouteMenuState) { + result = 1; + } else if (p_interactive_state instanceof DragMenuState) { + result = 2; + } else { + result = 0; + } + return result; } - - public String toString() - { + + public String toString() { return this.name; } - - - public java.awt.Point copy_viewport_position() - { - if (this.viewport_position == null) - { + + public java.awt.Point copy_viewport_position() { + if (this.viewport_position == null) { return null; } return new java.awt.Point(this.viewport_position); } - + /** * Goes to this shnapshot in interactive board etiting. */ - public void go_to(net.freerouting.interactive.BoardHandling p_board_handling) - { + public void go_to(net.freerouting.interactive.BoardHandling p_board_handling) { net.freerouting.interactive.SnapShot.Attributes snapshot_attributes = this.settings.snapshot_attributes; - if (snapshot_attributes.object_visibility) - { + if (snapshot_attributes.object_visibility) { p_board_handling.graphics_context.color_intensity_table = new net.freerouting.boardgraphics.ColorIntensityTable(this.graphics_context.color_intensity_table); } - if (snapshot_attributes.layer_visibility) - { + if (snapshot_attributes.layer_visibility) { p_board_handling.graphics_context.set_layer_visibility_arr(this.graphics_context.copy_layer_visibility_arr()); } - - if (snapshot_attributes.interactive_state) - { + + if (snapshot_attributes.interactive_state) { p_board_handling.set_interactive_state(this.get_interactive_state(p_board_handling, p_board_handling.logfile)); } - if (snapshot_attributes.selection_layers) - { + if (snapshot_attributes.selection_layers) { p_board_handling.settings.select_on_all_visible_layers = this.settings.select_on_all_visible_layers; } - if (snapshot_attributes.selectable_items) - { + if (snapshot_attributes.selectable_items) { p_board_handling.settings.item_selection_filter = new net.freerouting.board.ItemSelectionFilter(this.settings.item_selection_filter); } - if (snapshot_attributes.current_layer) - { + if (snapshot_attributes.current_layer) { p_board_handling.settings.layer = this.settings.layer; } - if (snapshot_attributes.rule_selection) - { + if (snapshot_attributes.rule_selection) { p_board_handling.settings.manual_rule_selection = this.settings.manual_rule_selection; } - if (snapshot_attributes.manual_rule_settings) - { + if (snapshot_attributes.manual_rule_settings) { p_board_handling.settings.manual_trace_clearance_class = this.settings.manual_trace_clearance_class; p_board_handling.settings.manual_via_rule_index = this.settings.manual_via_rule_index; System.arraycopy(this.settings.manual_trace_half_width_arr, 0, p_board_handling.settings.manual_trace_half_width_arr, 0, p_board_handling.settings.manual_trace_half_width_arr.length); } - if (snapshot_attributes.push_and_shove_enabled) - { + if (snapshot_attributes.push_and_shove_enabled) { p_board_handling.settings.push_enabled = this.settings.push_enabled; } - if (snapshot_attributes.drag_components_enabled) - { + if (snapshot_attributes.drag_components_enabled) { p_board_handling.settings.drag_components_enabled = this.settings.drag_components_enabled; } - if (snapshot_attributes.pull_tight_region) - { + if (snapshot_attributes.pull_tight_region) { p_board_handling.settings.trace_pull_tight_region_width = this.settings.trace_pull_tight_region_width; } - if (snapshot_attributes.component_grid) - { + if (snapshot_attributes.component_grid) { p_board_handling.settings.horizontal_component_grid = this.settings.horizontal_component_grid; p_board_handling.settings.vertical_component_grid = this.settings.vertical_component_grid; - } - if (snapshot_attributes.info_list_selections) - { + } + if (snapshot_attributes.info_list_selections) { p_board_handling.get_panel().board_frame.set_snapshot_subwindow_selections(this.subwindow_filters); } } - + /** * Returns a new InterativeState from the data of this instance. */ - public InteractiveState get_interactive_state(BoardHandling p_board_handling, Logfile p_logfile) - { + public InteractiveState get_interactive_state(BoardHandling p_board_handling, Logfile p_logfile) { InteractiveState result; - if (this.interactive_state_no == 1) - { + if (this.interactive_state_no == 1) { result = RouteMenuState.get_instance(p_board_handling, p_logfile); - } - else if (this.interactive_state_no == 2) - { + } else if (this.interactive_state_no == 2) { result = DragMenuState.get_instance(p_board_handling, p_logfile); - } - else - { + } else { result = SelectMenuState.get_instance(p_board_handling, p_logfile); } return result; } - - /** - * Create a number for writing an interactive state to disk. - * Only MenuStates are saved. The default is SelectState. - */ - private static int get_no(InteractiveState p_interactive_state) - { - int result; - if (p_interactive_state instanceof RouteMenuState) - { - result = 1; - } - else if (p_interactive_state instanceof DragMenuState) - { - result = 2; - } - else - { - result = 0; - } - return result; - } - - private final String name; - public final Settings settings; - private final int interactive_state_no; - public final net.freerouting.boardgraphics.GraphicsContext graphics_context; - private final java.awt.Point viewport_position; - public final net.freerouting.gui.BoardFrame.SubwindowSelections subwindow_filters; - + /** * Defines the data of the snapshot selected for restoring. */ - public static class Attributes implements java.io.Serializable - { - Attributes() - { + public static class Attributes implements java.io.Serializable { + public boolean object_colors; + public boolean object_visibility; + public boolean layer_visibility; + public boolean display_region; + public boolean interactive_state; + public boolean selection_layers; + public boolean selectable_items; + public boolean current_layer; + public boolean rule_selection; + public boolean manual_rule_settings; + public boolean push_and_shove_enabled; + public boolean drag_components_enabled; + public boolean pull_tight_region; + public boolean component_grid; + public boolean info_list_selections; + Attributes() { object_colors = true; object_visibility = true; layer_visibility = true; @@ -202,16 +183,16 @@ public static class Attributes implements java.io.Serializable current_layer = true; rule_selection = true; manual_rule_settings = true; - push_and_shove_enabled = true; - drag_components_enabled = true; + push_and_shove_enabled = true; + drag_components_enabled = true; pull_tight_region = true; component_grid = true; info_list_selections = true; } - - /** Copy constructor */ - Attributes(Attributes p_attributes) - { + /** + * Copy constructor + */ + Attributes(Attributes p_attributes) { object_colors = p_attributes.object_colors; object_visibility = p_attributes.object_visibility; layer_visibility = p_attributes.layer_visibility; @@ -228,21 +209,5 @@ public static class Attributes implements java.io.Serializable component_grid = p_attributes.component_grid; info_list_selections = p_attributes.info_list_selections; } - - public boolean object_colors; - public boolean object_visibility; - public boolean layer_visibility; - public boolean display_region; - public boolean interactive_state; - public boolean selection_layers; - public boolean selectable_items; - public boolean current_layer; - public boolean rule_selection; - public boolean manual_rule_settings; - public boolean push_and_shove_enabled; - public boolean drag_components_enabled; - public boolean pull_tight_region; - public boolean component_grid; - public boolean info_list_selections; } } diff --git a/src/main/java/net/freerouting/interactive/StitchRouteState.java b/src/main/java/net/freerouting/interactive/StitchRouteState.java index ca339064..0cfc9ed3 100644 --- a/src/main/java/net/freerouting/interactive/StitchRouteState.java +++ b/src/main/java/net/freerouting/interactive/StitchRouteState.java @@ -26,56 +26,49 @@ /** * State for interactive routing by adding corners with the left mouse button. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class StitchRouteState extends RouteState -{ - - /** Creates a new instance of StichRouteState */ - protected StitchRouteState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { +public class StitchRouteState extends RouteState { + + /** + * Creates a new instance of StichRouteState + */ + protected StitchRouteState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { super(p_parent_state, p_board_handling, p_logfile); } - - public InteractiveState left_button_clicked(FloatPoint p_location) - { + + public InteractiveState left_button_clicked(FloatPoint p_location) { return add_corner(p_location); } - - public InteractiveState add_corner(FloatPoint p_location) - { + + public InteractiveState add_corner(FloatPoint p_location) { // make the current situation restorable by undo hdlg.get_routing_board().generate_snapshot(); return super.add_corner(p_location); } - - public InteractiveState mouse_moved() - { + + public InteractiveState mouse_moved() { super.mouse_moved(); this.route.calc_nearest_target_point(hdlg.get_current_mouse_position()); hdlg.repaint(); return this; } - - public javax.swing.JPopupMenu get_popup_menu() - { + + public javax.swing.JPopupMenu get_popup_menu() { return hdlg.get_panel().popup_menu_stitch_route; } - - public String get_help_id() - { + + public String get_help_id() { return "RouteState_StitchingRouteState"; } - - public void draw(java.awt.Graphics p_graphics) - { + + public void draw(java.awt.Graphics p_graphics) { super.draw(p_graphics); - if (route == null) - { + if (route == null) { return; } // draw a line from the routing end point to the cursor - FloatPoint [] draw_points = new FloatPoint[2]; + FloatPoint[] draw_points = new FloatPoint[2]; draw_points[0] = route.get_last_corner().to_float(); draw_points[1] = hdlg.get_current_mouse_position(); java.awt.Color draw_color = hdlg.graphics_context.get_hilight_color(); @@ -84,7 +77,7 @@ public void draw(java.awt.Graphics p_graphics) double radius_with_clearance = display_width; net.freerouting.rules.NetClass default_net_class = hdlg.get_routing_board().rules.get_default_net_class(); int cl_class = default_net_class.default_item_clearance_classes.get(net.freerouting.rules.DefaultItemClearanceClasses.ItemClass.TRACE); - radius_with_clearance += hdlg.get_routing_board().clearance_value(cl_class, cl_class, hdlg.settings.layer); + radius_with_clearance += hdlg.get_routing_board().clearance_value(cl_class, cl_class, hdlg.settings.layer); hdlg.graphics_context.draw(draw_points, display_width, draw_color, p_graphics, 0.5); // draw the clearance boundary around the end point hdlg.graphics_context.draw_circle(draw_points[1], radius_with_clearance, clearance_draw_width, draw_color, p_graphics, 0.5); diff --git a/src/main/java/net/freerouting/interactive/TileConstructionState.java b/src/main/java/net/freerouting/interactive/TileConstructionState.java index 42b67f50..84359816 100644 --- a/src/main/java/net/freerouting/interactive/TileConstructionState.java +++ b/src/main/java/net/freerouting/interactive/TileConstructionState.java @@ -21,77 +21,64 @@ package net.freerouting.interactive; -import java.util.Iterator; - -import net.freerouting.geometry.planar.FloatPoint; -import net.freerouting.geometry.planar.IntPoint; -import net.freerouting.geometry.planar.Line; -import net.freerouting.geometry.planar.Side; -import net.freerouting.geometry.planar.TileShape; - -import net.freerouting.rules.BoardRules; - import net.freerouting.board.AngleRestriction; -import net.freerouting.board.RoutingBoard; import net.freerouting.board.FixedState; +import net.freerouting.board.RoutingBoard; +import net.freerouting.geometry.planar.*; +import net.freerouting.rules.BoardRules; + +import java.util.Iterator; /** * Class for interactive construction of a tile shaped obstacle * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class TileConstructionState extends CornerItemConstructionState -{ +public class TileConstructionState extends CornerItemConstructionState { /** - * Returns a new instance of this class - * If p_logfile != null; the creation of this item is stored in a logfile + * Creates a new instance of TileConstructionState */ - public static TileConstructionState get_instance(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - return new TileConstructionState(p_location, p_parent_state, p_board_handling, p_logfile); - } - - /** Creates a new instance of TileConstructionState */ - private TileConstructionState(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { + private TileConstructionState(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { super(p_parent_state, p_board_handling, p_logfile); - if (this.logfile != null) - { + if (this.logfile != null) { logfile.start_scope(LogfileScope.CREATING_TILE); } this.add_corner(p_location); } - + + /** + * Returns a new instance of this class + * If p_logfile != null; the creation of this item is stored in a logfile + */ + public static TileConstructionState get_instance(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + return new TileConstructionState(p_location, p_parent_state, p_board_handling, p_logfile); + } + /** * adds a corner to the tile under construction */ - public InteractiveState left_button_clicked(FloatPoint p_location) - { + public InteractiveState left_button_clicked(FloatPoint p_location) { super.left_button_clicked(p_location); remove_concave_corners(); hdlg.repaint(); return this; } - - public InteractiveState process_logfile_point(FloatPoint p_point) - { + + public InteractiveState process_logfile_point(FloatPoint p_point) { return left_button_clicked(p_point); } - - public InteractiveState complete() - { + + public InteractiveState complete() { remove_concave_corners_at_close(); int corner_count = corner_list.size(); boolean construction_succeeded = corner_count > 2; - if (construction_succeeded) - { + if (construction_succeeded) { // create the edgelines of the new tile Line[] edge_lines = new Line[corner_count]; Iterator it = corner_list.iterator(); IntPoint first_corner = it.next(); IntPoint prev_corner = first_corner; - for (int i = 0; i < corner_count - 1; ++i) - { + for (int i = 0; i < corner_count - 1; ++i) { IntPoint next_corner = it.next(); edge_lines[i] = new Line(prev_corner, next_corner); prev_corner = next_corner; @@ -101,70 +88,57 @@ public InteractiveState complete() RoutingBoard board = hdlg.get_routing_board(); int layer = hdlg.settings.layer; int cl_class = BoardRules.clearance_class_none(); - + construction_succeeded = board.check_shape(obstacle_shape, layer, new int[0], cl_class); - if (construction_succeeded) - { + if (construction_succeeded) { // insert the new shape as keepout this.observers_activated = !hdlg.get_routing_board().observers_active(); - if (this.observers_activated) - { + if (this.observers_activated) { hdlg.get_routing_board().start_notify_observers(); } board.generate_snapshot(); board.insert_obstacle(obstacle_shape, layer, cl_class, FixedState.UNFIXED); - if (this.observers_activated) - { + if (this.observers_activated) { hdlg.get_routing_board().end_notify_observers(); this.observers_activated = false; } } } - if (construction_succeeded) - { + if (construction_succeeded) { hdlg.screen_messages.set_status_message(resources.getString("keepout_successful_completed")); - } - else - { + } else { hdlg.screen_messages.set_status_message(resources.getString("keepout_cancelled_because_of_overlaps")); } - if (logfile != null) - { + if (logfile != null) { logfile.start_scope(LogfileScope.COMPLETE_SCOPE); } return this.return_state; } - + /** * skips concave corners at the end of the corner_list. **/ - private void remove_concave_corners() - { + private void remove_concave_corners() { IntPoint[] corner_arr = new IntPoint[corner_list.size()]; Iterator it = corner_list.iterator(); - for (int i = 0; i < corner_arr.length; ++i) - { + for (int i = 0; i < corner_arr.length; ++i) { corner_arr[i] = it.next(); } - + int new_length = corner_arr.length; - if (new_length < 3) - { + if (new_length < 3) { return; } - IntPoint last_corner = corner_arr[new_length - 1]; + IntPoint last_corner = corner_arr[new_length - 1]; IntPoint curr_corner = corner_arr[new_length - 2]; - while (new_length > 2) - { - IntPoint prev_corner = corner_arr[new_length - 3]; + while (new_length > 2) { + IntPoint prev_corner = corner_arr[new_length - 3]; Side last_corner_side = last_corner.side_of(prev_corner, curr_corner); - if (last_corner_side == Side.ON_THE_LEFT) - { + if (last_corner_side == Side.ON_THE_LEFT) { // side is ok, nothing to skip break; } - if (this.hdlg.get_routing_board().rules.get_trace_angle_restriction() != AngleRestriction.FORTYFIVE_DEGREE) - { + if (this.hdlg.get_routing_board().rules.get_trace_angle_restriction() != AngleRestriction.FORTYFIVE_DEGREE) { // skip concave corner corner_arr[new_length - 2] = last_corner; } @@ -172,80 +146,66 @@ private void remove_concave_corners() // In 45 degree case just skip last corner as nothing like the following // calculation for the 90 degree case to keep // the angle restrictions is implemented. - if (this.hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) - { + if (this.hdlg.get_routing_board().rules.get_trace_angle_restriction() == AngleRestriction.NINETY_DEGREE) { // prevent generating a non orthogonal line by changing the previous corner IntPoint prev_prev_corner = null; - if (new_length >= 3) - { + if (new_length >= 3) { prev_prev_corner = corner_arr[new_length - 3]; } - if (prev_prev_corner != null && prev_prev_corner.x == prev_corner.x) - { + if (prev_prev_corner != null && prev_prev_corner.x == prev_corner.x) { corner_arr[new_length - 2] = new IntPoint(prev_corner.x, last_corner.y); - } - else - { + } else { corner_arr[new_length - 2] = new IntPoint(last_corner.x, prev_corner.y); } } curr_corner = prev_corner; } - if (new_length < corner_arr.length) - { + if (new_length < corner_arr.length) { // somthing skipped, update corner_list corner_list = new java.util.LinkedList(); - for (int i = 0; i < new_length; ++i) - { + for (int i = 0; i < new_length; ++i) { corner_list.add(corner_arr[i]); } } } + /** * removes as many corners at the end of the corner list, so that * closing the polygon will not create a concave corner */ - private void remove_concave_corners_at_close() - { + private void remove_concave_corners_at_close() { add_corner_for_snap_angle(); - if (corner_list.size() < 4) - { + if (corner_list.size() < 4) { return; } IntPoint[] corner_arr = new IntPoint[corner_list.size()]; Iterator it = corner_list.iterator(); - for (int i = 0; i < corner_arr.length; ++i) - { + for (int i = 0; i < corner_arr.length; ++i) { corner_arr[i] = it.next(); } int new_length = corner_arr.length; - + IntPoint first_corner = corner_arr[0]; IntPoint second_corner = corner_arr[1]; - while (new_length > 3) - { - IntPoint last_corner = corner_arr[new_length - 1]; - if (last_corner.side_of(second_corner, first_corner) != Side.ON_THE_LEFT) - { + while (new_length > 3) { + IntPoint last_corner = corner_arr[new_length - 1]; + if (last_corner.side_of(second_corner, first_corner) != Side.ON_THE_LEFT) { break; } --new_length; } - - if (new_length != corner_arr.length) - { + + if (new_length != corner_arr.length) { // recalculate the corner_list corner_list = new java.util.LinkedList(); - for (int i = 0; i < new_length; ++i) - { + for (int i = 0; i < new_length; ++i) { corner_list.add(corner_arr[i]); } add_corner_for_snap_angle(); } } - - public void display_default_message() - { + + public void display_default_message() { hdlg.screen_messages.set_status_message(resources.getString("creatig_tile")); } } diff --git a/src/main/java/net/freerouting/interactive/ZoomRegionState.java b/src/main/java/net/freerouting/interactive/ZoomRegionState.java index 772f8bf3..285b9087 100644 --- a/src/main/java/net/freerouting/interactive/ZoomRegionState.java +++ b/src/main/java/net/freerouting/interactive/ZoomRegionState.java @@ -29,56 +29,49 @@ * * @author Alfons Wirtz */ -public class ZoomRegionState extends SelectRegionState -{ +public class ZoomRegionState extends SelectRegionState { + /** + * Creates a new instance of ZoomRegionState + */ + public ZoomRegionState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { + super(p_parent_state, p_board_handling, p_logfile); + if (this.logfile != null) { + logfile.start_scope(net.freerouting.interactive.LogfileScope.ZOOM_FRAME); + } + } + /** * Returns a new instance of this class. */ - public static ZoomRegionState get_instance(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { + public static ZoomRegionState get_instance(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { return get_instance(null, p_parent_state, p_board_handling, p_logfile); } - + /** * Returns a new instance of this class with first point p_location. */ - public static ZoomRegionState get_instance(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { + public static ZoomRegionState get_instance(FloatPoint p_location, InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) { ZoomRegionState new_instance = new ZoomRegionState(p_parent_state, p_board_handling, p_logfile); new_instance.corner1 = p_location; new_instance.hdlg.screen_messages.set_status_message(new_instance.resources.getString("drag_left_mouse_button_to_create_region_to_display")); return new_instance; } - - /** Creates a new instance of ZoomRegionState */ - public ZoomRegionState(InteractiveState p_parent_state, BoardHandling p_board_handling, Logfile p_logfile) - { - super(p_parent_state, p_board_handling, p_logfile); - if (this.logfile != null) - { - logfile.start_scope(net.freerouting.interactive.LogfileScope.ZOOM_FRAME); - } - } - - public InteractiveState complete() - { + + public InteractiveState complete() { corner2 = hdlg.get_current_mouse_position(); zoom_region(); - if (this.logfile != null) - { + if (this.logfile != null) { logfile.add_corner(corner2); } return this.return_state; } - - private void zoom_region() - { - if (corner1 == null || corner2 == null) - { + + private void zoom_region() { + if (corner1 == null || corner2 == null) { return; } - Point2D sc_corner1 = hdlg.graphics_context.coordinate_transform.board_to_screen(corner1) ; - Point2D sc_corner2 = hdlg.graphics_context.coordinate_transform.board_to_screen(corner2) ; - hdlg.get_panel().zoom_frame(sc_corner1, sc_corner2) ; + Point2D sc_corner1 = hdlg.graphics_context.coordinate_transform.board_to_screen(corner1); + Point2D sc_corner2 = hdlg.graphics_context.coordinate_transform.board_to_screen(corner2); + hdlg.get_panel().zoom_frame(sc_corner1, sc_corner2); } } diff --git a/src/main/java/net/freerouting/interactive/package.html b/src/main/java/net/freerouting/interactive/package.html index e5076e0b..b7ae98de 100644 --- a/src/main/java/net/freerouting/interactive/package.html +++ b/src/main/java/net/freerouting/interactive/package.html @@ -1,5 +1,6 @@ -java.text package - Contains functionality for interactive board handling, which is independent of the graphical user interface. - \ No newline at end of file +Contains functionality for interactive board handling, which is independent of the graphical user interface. + + \ No newline at end of file diff --git a/src/main/java/net/freerouting/library/BoardLibrary.java b/src/main/java/net/freerouting/library/BoardLibrary.java index 5eb924d6..d3e60114 100644 --- a/src/main/java/net/freerouting/library/BoardLibrary.java +++ b/src/main/java/net/freerouting/library/BoardLibrary.java @@ -26,179 +26,162 @@ /** * Describes a board library of packages and padstacks. * - * @author alfons + * @author alfons */ -public class BoardLibrary implements java.io.Serializable -{ - - /** Creates a new instance of BoardLibrary */ - public BoardLibrary(Padstacks p_padstacks, Packages p_packages) - { +public class BoardLibrary implements java.io.Serializable { + + public Padstacks padstacks = null; + public Packages packages = null; + /** + * Containes information for gate swap and pin swap in the Specctra-dsn format. + */ + public LogicalParts logical_parts = new LogicalParts(); + /** + * The subset of padstacks in the board library, which can be used in routing for inserting vias. + */ + private List via_padstacks = null; + + /** + * Creates a new instance of BoardLibrary + */ + public BoardLibrary(Padstacks p_padstacks, Packages p_packages) { padstacks = p_padstacks; packages = p_packages; logical_parts = new LogicalParts(); } - - /** Creates a new instance of BoardLibrary */ - public BoardLibrary() - { - - } - - /** Sets the subset of padstacks from this.padstacks, which can be used in routing for inserting vias. */ - public void set_via_padstacks(Padstack[] p_padstacks) - { - - this.via_padstacks = new Vector(); - for (int i = 0; i < p_padstacks.length; ++i) - { - this.via_padstacks.add(p_padstacks[i]); - } + + /** + * Creates a new instance of BoardLibrary + */ + public BoardLibrary() { + } - - /** The count of padstacks from this.padstacks, which can be used in routing */ - public int via_padstack_count() - { - if (this.via_padstacks == null) - { + + /** + * The count of padstacks from this.padstacks, which can be used in routing + */ + public int via_padstack_count() { + if (this.via_padstacks == null) { return 0; } return this.via_padstacks.size(); } - - /** Gets the via padstack for routing with index p_no */ - public Padstack get_via_padstack(int p_no) - { - if (this.via_padstacks == null || p_no < 0 || p_no >= this.via_padstacks.size()) - { + + /** + * Gets the via padstack for routing with index p_no + */ + public Padstack get_via_padstack(int p_no) { + if (this.via_padstacks == null || p_no < 0 || p_no >= this.via_padstacks.size()) { return null; } return this.via_padstacks.get(p_no); } - - /** Gets the via padstack with name p_name, or null, if no such padstack exists. */ - public Padstack get_via_padstack(String p_name) - { - if (this.via_padstacks == null) - { + + /** + * Gets the via padstack with name p_name, or null, if no such padstack exists. + */ + public Padstack get_via_padstack(String p_name) { + if (this.via_padstacks == null) { return null; } - for(Padstack curr_padstack : this.via_padstacks) - { - if (curr_padstack.name.equals(p_name)) - { + for (Padstack curr_padstack : this.via_padstacks) { + if (curr_padstack.name.equals(p_name)) { return curr_padstack; } } return null; } - + /** * Returns the via padstacks, which can be used for routing. */ - public Padstack[] get_via_padstacks() - { - if (this.via_padstacks == null) - { + public Padstack[] get_via_padstacks() { + if (this.via_padstacks == null) { return new Padstack[0]; } Padstack[] result = new Padstack[via_padstacks.size()]; - for (int i = 0; i < result.length; ++i) - { + for (int i = 0; i < result.length; ++i) { result[i] = via_padstacks.get(i); } return result; } - + + /** + * Sets the subset of padstacks from this.padstacks, which can be used in routing for inserting vias. + */ + public void set_via_padstacks(Padstack[] p_padstacks) { + + this.via_padstacks = new Vector(); + for (int i = 0; i < p_padstacks.length; ++i) { + this.via_padstacks.add(p_padstacks[i]); + } + } + /** * Apppends p_padstack to the list of via padstacks. * Returns false, if the list contains already a padstack with p_padstack.name. */ - public boolean add_via_padstack(Padstack p_padstack) - { - if (get_via_padstack(p_padstack.name) != null) - { - return false; - } - this.via_padstacks.add(p_padstack); - return true; + public boolean add_via_padstack(Padstack p_padstack) { + if (get_via_padstack(p_padstack.name) != null) { + return false; + } + this.via_padstacks.add(p_padstack); + return true; } - - /** - * Removes p_padstack from the via padstack list. + + /** + * Removes p_padstack from the via padstack list. * Returns false, if p_padstack was not found in the list. - * If the padstack is no more used on the board, it will also be removed from the board padstacks. + * If the padstack is no more used on the board, it will also be removed from the board padstacks. */ - public boolean remove_via_padstack(Padstack p_padstack, net.freerouting.board.BasicBoard p_board) - { + public boolean remove_via_padstack(Padstack p_padstack, net.freerouting.board.BasicBoard p_board) { boolean result = via_padstacks.remove(p_padstack); return result; } - - + /** * Gets the via padstack mirrored to the back side of the board. * Returns null, if no such via padstack exists. */ - public Padstack get_mirrored_via_padstack(Padstack p_via_padstack) - { + public Padstack get_mirrored_via_padstack(Padstack p_via_padstack) { int layer_count = this.padstacks.board_layer_structure.arr.length; - if (p_via_padstack.from_layer() == 0 && p_via_padstack.to_layer() == layer_count - 1) - { + if (p_via_padstack.from_layer() == 0 && p_via_padstack.to_layer() == layer_count - 1) { return p_via_padstack; } - int new_from_layer =layer_count - p_via_padstack.to_layer() - 1; + int new_from_layer = layer_count - p_via_padstack.to_layer() - 1; int new_to_layer = layer_count - p_via_padstack.from_layer() - 1; - for (Padstack curr_via_padstack : via_padstacks) - { - if (curr_via_padstack.from_layer() == new_from_layer && curr_via_padstack.to_layer() == new_to_layer) - { + for (Padstack curr_via_padstack : via_padstacks) { + if (curr_via_padstack.from_layer() == new_from_layer && curr_via_padstack.to_layer() == new_to_layer) { return curr_via_padstack; } } return null; } - + /** * Looks, if the input padstack is used on p_board in a Package or in drill. */ - public boolean is_used (Padstack p_padstack, net.freerouting.board.BasicBoard p_board) - { + public boolean is_used(Padstack p_padstack, net.freerouting.board.BasicBoard p_board) { java.util.Iterator it = p_board.item_list.start_read_object(); - for(;;) - { + for (; ; ) { net.freerouting.datastructures.UndoableObjects.Storable curr_item = p_board.item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof net.freerouting.board.DrillItem) - { - if (((net.freerouting.board.DrillItem) curr_item).get_padstack() == p_padstack) - { + if (curr_item instanceof net.freerouting.board.DrillItem) { + if (((net.freerouting.board.DrillItem) curr_item).get_padstack() == p_padstack) { return true; } } } - for (int i = 1; i <= this.packages.count(); ++i) - { + for (int i = 1; i <= this.packages.count(); ++i) { Package curr_package = this.packages.get(i); - for (int j = 0; j < curr_package.pin_count(); ++j) - { - if(curr_package.get_pin(j).padstack_no == p_padstack.no) - { + for (int j = 0; j < curr_package.pin_count(); ++j) { + if (curr_package.get_pin(j).padstack_no == p_padstack.no) { return true; } } } return false; } - - public Padstacks padstacks = null; - public Packages packages = null; - /** Containes information for gate swap and pin swap in the Specctra-dsn format. */ - public LogicalParts logical_parts = new LogicalParts(); - - /** The subset of padstacks in the board library, which can be used in routing for inserting vias. */ - private List via_padstacks = null; } diff --git a/src/main/java/net/freerouting/library/LogicalPart.java b/src/main/java/net/freerouting/library/LogicalPart.java index 171f487a..c849d0dc 100644 --- a/src/main/java/net/freerouting/library/LogicalPart.java +++ b/src/main/java/net/freerouting/library/LogicalPart.java @@ -25,45 +25,44 @@ * * @author Alfons Wirtz */ -public class LogicalPart implements net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable -{ - +public class LogicalPart implements net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { + + public final String name; + public final int no; + private final PartPin[] part_pin_arr; + /** * Creates a new instance of LogicalPart. * The part pins are sorted by pin_no. * The pin_no's of the part pins must be the same number as in the componnents library package. */ - public LogicalPart(String p_name, int p_no, PartPin[] p_part_pin_arr) - { + public LogicalPart(String p_name, int p_no, PartPin[] p_part_pin_arr) { name = p_name; no = p_no; part_pin_arr = p_part_pin_arr; } - - public int pin_count() - { + + public int pin_count() { return part_pin_arr.length; } - - /** Returns the pim with index p_no. Pin numbers are from 0 to pin_count - 1 */ - public PartPin get_pin(int p_no) - { - if (p_no < 0 || p_no >= part_pin_arr.length) - { + + /** + * Returns the pim with index p_no. Pin numbers are from 0 to pin_count - 1 + */ + public PartPin get_pin(int p_no) { + if (p_no < 0 || p_no >= part_pin_arr.length) { System.out.println("LogicalPart.get_pin: p_no out of range"); return null; } return part_pin_arr[p_no]; } - - public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("logical_part_2") + " "); p_window.append_bold(this.name); - for (int i = 0; i < this.part_pin_arr.length; ++i) - { + for (int i = 0; i < this.part_pin_arr.length; ++i) { PartPin curr_pin = this.part_pin_arr[i]; p_window.newline(); p_window.indent(); @@ -83,51 +82,47 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util p_window.newline(); p_window.newline(); } - - public final String name; - public final int no; - private final PartPin [] part_pin_arr; - - public static class PartPin implements Comparable, java.io.Serializable - { - public PartPin(int p_pin_no, String p_pin_name, String p_gate_name, int p_gate_swap_code, - String p_gate_pin_name, int p_gate_pin_swap_code) - { - pin_no = p_pin_no; - pin_name = p_pin_name; - gate_name = p_gate_name; - gate_swap_code = p_gate_swap_code; - gate_pin_name = p_gate_pin_name; - gate_pin_swap_code = p_gate_pin_swap_code; - } - - public int compareTo(PartPin p_other) - { - return this.pin_no - p_other.pin_no; - } - - /** The number of the part pin. Must be the same number as in the componnents library package. */ + + public static class PartPin implements Comparable, java.io.Serializable { + /** + * The number of the part pin. Must be the same number as in the componnents library package. + */ public final int pin_no; - - /** The name of the part pin. Must be the same name as in the componnents library package. */ + /** + * The name of the part pin. Must be the same name as in the componnents library package. + */ public final String pin_name; - - /** The name of the gate this pin belongs to. */ + /** + * The name of the gate this pin belongs to. + */ public final String gate_name; - /** * The gate swap code. Gates with the same gate swap code can be swapped. * Gates with swap code <= 0 are not swappable. */ public final int gate_swap_code; - - /** The identifier of the pin in the gate. */ + /** + * The identifier of the pin in the gate. + */ public final String gate_pin_name; - /** * The pin swap code of the gate. Pins with the same pin swap code can be swapped inside a gate. * Pins with swap code <= 0 are not swappable. */ public final int gate_pin_swap_code; + + public PartPin(int p_pin_no, String p_pin_name, String p_gate_name, int p_gate_swap_code, + String p_gate_pin_name, int p_gate_pin_swap_code) { + pin_no = p_pin_no; + pin_name = p_pin_name; + gate_name = p_gate_name; + gate_swap_code = p_gate_swap_code; + gate_pin_name = p_gate_pin_name; + gate_pin_swap_code = p_gate_pin_swap_code; + } + + public int compareTo(PartPin p_other) { + return this.pin_no - p_other.pin_no; + } } } diff --git a/src/main/java/net/freerouting/library/LogicalParts.java b/src/main/java/net/freerouting/library/LogicalParts.java index ee791e75..db01bdf9 100644 --- a/src/main/java/net/freerouting/library/LogicalParts.java +++ b/src/main/java/net/freerouting/library/LogicalParts.java @@ -27,53 +27,49 @@ * * @author Alfons Wirtz */ -public class LogicalParts implements java.io.Serializable -{ - /** Adds a logical part to the database. */ - public LogicalPart add(String p_name, LogicalPart.PartPin[] p_part_pin_arr) - { +public class LogicalParts implements java.io.Serializable { + /** + * The array of logical parts + */ + private Vector part_arr = new Vector(); + + /** + * Adds a logical part to the database. + */ + public LogicalPart add(String p_name, LogicalPart.PartPin[] p_part_pin_arr) { java.util.Arrays.sort(p_part_pin_arr); LogicalPart new_part = new LogicalPart(p_name, part_arr.size() + 1, p_part_pin_arr); part_arr.add(new_part); return new_part; } - + /** * Returns the logical part with the input name or null, if no such package exists. */ - public LogicalPart get(String p_name) - { - for (LogicalPart curr_part : this.part_arr) - { - if (curr_part != null && curr_part.name.compareToIgnoreCase(p_name) == 0) - { + public LogicalPart get(String p_name) { + for (LogicalPart curr_part : this.part_arr) { + if (curr_part != null && curr_part.name.compareToIgnoreCase(p_name) == 0) { return curr_part; } } return null; } - + /** * Returns the logical part with index p_part_no. Part numbers are from 1 to part count. */ - public LogicalPart get(int p_part_no) - { + public LogicalPart get(int p_part_no) { LogicalPart result = part_arr.elementAt(p_part_no - 1); - if (result != null && result.no != p_part_no) - { + if (result != null && result.no != p_part_no) { System.out.println("LogicalParts.get: inconsistent part number"); } return result; } - + /** * Returns the count of logical parts. */ - public int count() - { + public int count() { return part_arr.size(); } - - /** The array of logical parts */ - private Vector part_arr = new Vector(); } diff --git a/src/main/java/net/freerouting/library/Package.java b/src/main/java/net/freerouting/library/Package.java index 6bf82a1b..b34a9f31 100644 --- a/src/main/java/net/freerouting/library/Package.java +++ b/src/main/java/net/freerouting/library/Package.java @@ -20,27 +20,50 @@ package net.freerouting.library; -import net.freerouting.geometry.planar.Vector; -import net.freerouting.geometry.planar.Shape; import net.freerouting.geometry.planar.Area; +import net.freerouting.geometry.planar.Shape; +import net.freerouting.geometry.planar.Vector; /** * Component package templates describing the padstacks and * relative locations of the packege pins, * and optional other stuff like an outline package keepouts. * - * @author alfons + * @author alfons */ -public class Package implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable -{ - +public class Package implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { + + /** + * The name of the package. + */ + public final String name; + /** + * Internallly generated package number. + */ + public final int no; + /** + * The outline of the component, which may be null. + */ + public final Shape[] outline; + public final Keepout[] keepout_arr; + public final Keepout[] via_keepout_arr; + public final Keepout[] place_keepout_arr; + /** + * If false, the package is placed on the back side of the board + */ + public final boolean is_front; + /** + * The array of pins of this padstack. + */ + private final Pin[] pin_arr; + private final Packages package_list; + /** * Creates a new instance of Package. * p_package_list is the list of packages containing this package. */ public Package(String p_name, int p_no, Pin[] p_pin_arr, Shape[] p_outline, Keepout[] p_keepout_arr, - Keepout[] p_via_keepout_arr, Keepout[] p_place_keepout_arr, boolean p_is_front, Packages p_package_list) - { + Keepout[] p_via_keepout_arr, Keepout[] p_place_keepout_arr, boolean p_is_front, Packages p_package_list) { name = p_name; no = p_no; pin_arr = p_pin_arr; @@ -51,66 +74,56 @@ public Package(String p_name, int p_no, Pin[] p_pin_arr, Shape[] p_outline, Keep is_front = p_is_front; package_list = p_package_list; } - + /** * Compares 2 packages by name. * Useful for example to display packages in alphabetic order. */ - public int compareTo(Package p_other) - { + public int compareTo(Package p_other) { return this.name.compareToIgnoreCase(p_other.name); } - + /** * Returns the pin with the input number from this package. */ - public Pin get_pin(int p_no) - { - if (p_no < 0 || p_no >= pin_arr.length) - { + public Pin get_pin(int p_no) { + if (p_no < 0 || p_no >= pin_arr.length) { System.out.println("Package.get_pin: p_no out of range"); return null; } return pin_arr[p_no]; } - + /** * Returns the pin number of the pin with the input name from this package, or -1, if no such pin exists * Pin numbers are from 0 to pin_count - 1. */ - public int get_pin_no(String p_name) - { - for (int i = 0; i < pin_arr.length; ++i) - { - if (pin_arr[i].name.equals(p_name)) - { + public int get_pin_no(String p_name) { + for (int i = 0; i < pin_arr.length; ++i) { + if (pin_arr[i].name.equals(p_name)) { return i; } } return -1; } - + /** * Returns the pin count of this package. */ - public int pin_count() - { + public int pin_count() { return pin_arr.length; } - - public String toString() - { + + public String toString() { return this.name; } - - public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("package") + " "); p_window.append_bold(this.name); - for (int i = 0; i < this.pin_arr.length; ++i) - { + for (int i = 0; i < this.pin_arr.length; ++i) { Pin curr_pin = this.pin_arr[i]; p_window.newline(); p_window.indent(); @@ -121,76 +134,56 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util p_window.append(curr_padstack.name, resources.getString("padstack_info"), curr_padstack); p_window.append(" " + resources.getString("at") + " "); p_window.append(curr_pin.relative_location.to_float()); - p_window.append(", " + resources.getString("rotation") + " "); + p_window.append(", " + resources.getString("rotation") + " "); p_window.append_without_transforming(curr_pin.rotation_in_degree); } p_window.newline(); } - - /** The name of the package. */ - public final String name; - - /** Internallly generated package number. */ - public final int no; - - /** The array of pins of this padstack. */ - private final Pin [] pin_arr; - - /** The outline of the component, which may be null. */ - public final Shape[] outline; - - public final Keepout[] keepout_arr; - - public final Keepout[] via_keepout_arr; - - public final Keepout[] place_keepout_arr; - - /** If false, the package is placed on the back side of the board */ - public final boolean is_front; - - private final Packages package_list; - + /** * Describes a pin padstack of a package. */ - public static class Pin implements java.io.Serializable - { + public static class Pin implements java.io.Serializable { + /** + * The name of the pin. + */ + public final String name; + /** + * The number of the padstack mask of the pin. + */ + public final int padstack_no; + /** + * The location of the pin relative to its package. + */ + public final Vector relative_location; + /** + * the rotation of the pin padstack + */ + public final double rotation_in_degree; + /** * Creates a new package pin with the input coordinates relative * to the package location. */ - public Pin(String p_name, int p_padstack_no, Vector p_relative_location, double p_rotation_in_degree) - { + public Pin(String p_name, int p_padstack_no, Vector p_relative_location, double p_rotation_in_degree) { name = p_name; padstack_no = p_padstack_no; relative_location = p_relative_location; - rotation_in_degree = p_rotation_in_degree; + rotation_in_degree = p_rotation_in_degree; } - - /** The name of the pin. */ - public final String name; - - /** The number of the padstack mask of the pin. */ - public final int padstack_no; - - /** The location of the pin relative to its package. */ - public final Vector relative_location; - - /** the rotation of the pin padstack */ - public final double rotation_in_degree; } - - /** Deescribes a named keepout belonging to a package, */ - public static class Keepout implements java.io.Serializable - { - public Keepout(String p_name, Area p_area, int p_layer) - { + + /** + * Deescribes a named keepout belonging to a package, + */ + public static class Keepout implements java.io.Serializable { + public final String name; + public final Area area; + public final int layer; + public Keepout(String p_name, Area p_area, int p_layer) { name = p_name; area = p_area; layer = p_layer; } - public final String name; - public final Area area; - public final int layer; } } diff --git a/src/main/java/net/freerouting/library/Packages.java b/src/main/java/net/freerouting/library/Packages.java index 50ad3b67..4239075a 100644 --- a/src/main/java/net/freerouting/library/Packages.java +++ b/src/main/java/net/freerouting/library/Packages.java @@ -20,43 +20,43 @@ package net.freerouting.library; +import net.freerouting.geometry.planar.Shape; + import java.util.Iterator; import java.util.Vector; -import net.freerouting.geometry.planar.Shape; - /** * Describes a library of component packages. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Packages implements java.io.Serializable -{ +public class Packages implements java.io.Serializable { + final Padstacks padstack_list; + /** + * The array of packages in this object + */ + private Vector package_arr = new Vector(); + /** * Creates a new instance of Packages. * p_padstack_list is the list of padstacks used for the pins * of the packages in this data structure. */ - public Packages(Padstacks p_padstack_list) - { + public Packages(Padstacks p_padstack_list) { this.padstack_list = p_padstack_list; } - + /** * Returns the package with the input name and the input side or null, * if no such package exists. */ - public Package get(String p_name, boolean p_is_front) - { + public Package get(String p_name, boolean p_is_front) { Iterator it = package_arr.iterator(); Package other_side_package = null; - while(it.hasNext()) - { + while (it.hasNext()) { Package curr_package = it.next(); - if (curr_package != null && curr_package.name.compareToIgnoreCase(p_name) == 0) - { - if (curr_package.is_front == p_is_front) - { + if (curr_package != null && curr_package.name.compareToIgnoreCase(p_name) == 0) { + if (curr_package.is_front == p_is_front) { return curr_package; } other_side_package = curr_package; @@ -64,56 +64,46 @@ public Package get(String p_name, boolean p_is_front) } return other_side_package; } - + /** * Returns the package with index p_package_no. * Packages numbers are from 1 to package count. */ - public Package get(int p_package_no) - { + public Package get(int p_package_no) { Package result = package_arr.elementAt(p_package_no - 1); - if (result != null && result.no != p_package_no) - { + if (result != null && result.no != p_package_no) { System.out.println("Padstacks.get: inconsistent padstack number"); } return result; } - + /** * Returns the count of packages in this object. */ - public int count() - { + public int count() { return package_arr.size(); } - + /** * Appends a new package with the input data to this object. */ - public Package add(String p_name, Package.Pin [] p_pin_arr, Shape[] p_outline, - Package.Keepout [] p_keepout_arr, Package.Keepout [] p_via_keepout_arr, - Package.Keepout [] p_place_keepout_arr, boolean p_is_front) - { + public Package add(String p_name, Package.Pin[] p_pin_arr, Shape[] p_outline, + Package.Keepout[] p_keepout_arr, Package.Keepout[] p_via_keepout_arr, + Package.Keepout[] p_place_keepout_arr, boolean p_is_front) { Package new_package = new Package(p_name, package_arr.size() + 1, p_pin_arr, p_outline, p_keepout_arr, p_via_keepout_arr, p_place_keepout_arr, p_is_front, this); package_arr.add(new_package); return new_package; } - + /** * Appends a new package with pins p_pin_arr to this object. * The package name is generated internally. */ - public Package add(Package.Pin [] p_pin_arr) - { + public Package add(Package.Pin[] p_pin_arr) { String package_name = "Package#" + (new Integer(package_arr.size() + 1)).toString(); - - return add(package_name, p_pin_arr, null, new Package.Keepout [0], new Package.Keepout [0], - new Package.Keepout [0], true); + + return add(package_name, p_pin_arr, null, new Package.Keepout[0], new Package.Keepout[0], + new Package.Keepout[0], true); } - - /** The array of packages in this object */ - private Vector package_arr = new Vector(); - - final Padstacks padstack_list; } diff --git a/src/main/java/net/freerouting/library/Padstack.java b/src/main/java/net/freerouting/library/Padstack.java index f7507ee0..cfe1b777 100644 --- a/src/main/java/net/freerouting/library/Padstack.java +++ b/src/main/java/net/freerouting/library/Padstack.java @@ -28,11 +28,27 @@ /** * Describes padstack masks for pins or vias located at the origin. * - * @author alfons + * @author alfons */ -public class Padstack implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable -{ - +public class Padstack implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { + + public final String name; + public final int no; + /** + * true, if vias of the own net are allowed to overlap with this padstack + */ + public final boolean attach_allowed; + /** + * If false, the layers of the padstack are mirrored, if it is placed on the back side. + * The default is false. + */ + public final boolean placed_absolute; + private final ConvexShape[] shapes; + /** + * Pointer to the pacdstack list containing this padstack + */ + private final Padstacks padstack_list; + /** * Creates a new Padstack with shape p_shapes[i] on layer i (0 <= i < p_shapes.length). * p_is_drilllable indicates, if vias of the own net are allowed to overlap with this padstack @@ -40,8 +56,7 @@ public class Padstack implements Comparable, net.freerouting.board.Obj * p_padstack_list is the list, where this padstack belongs to. */ Padstack(String p_name, int p_no, ConvexShape[] p_shapes, boolean p_is_drilllable, - boolean p_placed_absolute, Padstacks p_padstack_list) - { + boolean p_placed_absolute, Padstacks p_padstack_list) { shapes = p_shapes; name = p_name; no = p_no; @@ -49,119 +64,102 @@ public class Padstack implements Comparable, net.freerouting.board.Obj placed_absolute = p_placed_absolute; padstack_list = p_padstack_list; } - + /** * Compares 2 padstacks by name. * Useful for example to display padstacks in alphabetic order. */ - public int compareTo(Padstack p_other) - { + public int compareTo(Padstack p_other) { return this.name.compareToIgnoreCase(p_other.name); } - + /** * Gets the shape of this padstack on layer p_layer */ - public ConvexShape get_shape(int p_layer) - { - if (p_layer < 0 || p_layer >= shapes.length) - { + public ConvexShape get_shape(int p_layer) { + if (p_layer < 0 || p_layer >= shapes.length) { System.out.println("Padstack.get_layer p_layer out of range"); return null; } return shapes[p_layer]; } - + /** * Returns the first layer of this padstack with a shape != null. */ - public int from_layer() - { + public int from_layer() { int result = 0; - while (result < shapes.length && shapes[result] == null) - { + while (result < shapes.length && shapes[result] == null) { ++result; } return result; } - + /** * Returns the last layer of this padstack with a shape != null. */ - public int to_layer() - { + public int to_layer() { int result = shapes.length - 1; - while (result >= 0 && shapes[result] == null) - { + while (result >= 0 && shapes[result] == null) { --result; } return result; } - - /** Returns the layer ciount of the board of this padstack. */ - public int board_layer_count() - { + + /** + * Returns the layer ciount of the board of this padstack. + */ + public int board_layer_count() { return shapes.length; } - - public String toString() - { + + public String toString() { return this.name; } - + /** * Calculates the allowed trace exit directions of the shape of this padstack on layer p_layer. * If the length of the pad is smaller than p_factor times the height of the pad, * connection also to the long side is allowed. */ - public java.util.Collection get_trace_exit_directions(int p_layer, double p_factor) - { + public java.util.Collection get_trace_exit_directions(int p_layer, double p_factor) { java.util.Collection result = new java.util.LinkedList(); - if (p_layer < 0 || p_layer >= shapes.length) - { + if (p_layer < 0 || p_layer >= shapes.length) { return result; } ConvexShape curr_shape = shapes[p_layer]; - if (curr_shape == null) - { + if (curr_shape == null) { return result; } - if (!(curr_shape instanceof IntBox || curr_shape instanceof IntOctagon)) - { + if (!(curr_shape instanceof IntBox || curr_shape instanceof IntOctagon)) { return result; } IntBox curr_box = curr_shape.bounding_box(); - + boolean all_dirs = false; - if (Math.max(curr_box.width(), curr_box.height()) < - p_factor * Math.min(curr_box.width(), curr_box.height())) - { + if (Math.max(curr_box.width(), curr_box.height()) < + p_factor * Math.min(curr_box.width(), curr_box.height())) { all_dirs = true; } - - if (all_dirs || curr_box.width() >= curr_box.height()) - { + + if (all_dirs || curr_box.width() >= curr_box.height()) { result.add(Direction.RIGHT); result.add(Direction.LEFT); } - if (all_dirs || curr_box.width() <= curr_box.height()) - { + if (all_dirs || curr_box.width() <= curr_box.height()) { result.add(Direction.UP); result.add(Direction.DOWN); } return result; } - - public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("padstack") + " "); p_window.append_bold(this.name); - for (int i = 0; i < shapes.length; ++i) - { - if (shapes[i] != null) - { + for (int i = 0; i < shapes.length; ++i) { + if (shapes[i] != null) { p_window.newline(); p_window.indent(); p_window.append(shapes[i], p_locale); @@ -171,20 +169,4 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util } p_window.newline(); } - - private final ConvexShape [] shapes; - public final String name; - public final int no; - - /** true, if vias of the own net are allowed to overlap with this padstack*/ - public final boolean attach_allowed; - - /** - * If false, the layers of the padstack are mirrored, if it is placed on the back side. - * The default is false. - */ - public final boolean placed_absolute; - - /** Pointer to the pacdstack list containing this padstack */ - private final Padstacks padstack_list; } diff --git a/src/main/java/net/freerouting/library/Padstacks.java b/src/main/java/net/freerouting/library/Padstacks.java index 8d568c9e..3ccec897 100644 --- a/src/main/java/net/freerouting/library/Padstacks.java +++ b/src/main/java/net/freerouting/library/Padstacks.java @@ -20,115 +20,107 @@ package net.freerouting.library; +import net.freerouting.geometry.planar.ConvexShape; + import java.util.Iterator; import java.util.Vector; -import net.freerouting.geometry.planar.ConvexShape; - /** * Describes a library of padstacks for pins or vias. * - * @author alfons + * @author alfons */ -public class Padstacks implements java.io.Serializable -{ - /** Creates a new instance of Padstacks */ - public Padstacks(net.freerouting.board.LayerStructure p_layer_structure) - { +public class Padstacks implements java.io.Serializable { + /** + * The layer structure of each padstack. + */ + public final net.freerouting.board.LayerStructure board_layer_structure; + /** + * The array of Padstacks in this object + */ + private Vector padstack_arr; + + /** + * Creates a new instance of Padstacks + */ + public Padstacks(net.freerouting.board.LayerStructure p_layer_structure) { board_layer_structure = p_layer_structure; padstack_arr = new Vector(); } - + /** * Returns the padstack with the input name or null, * if no such padstack exists. */ - public Padstack get(String p_name) - { + public Padstack get(String p_name) { Iterator it = padstack_arr.iterator(); - while(it.hasNext()) - { + while (it.hasNext()) { Padstack curr_padstack = it.next(); - if (curr_padstack != null && curr_padstack.name.compareToIgnoreCase(p_name) == 0) - { + if (curr_padstack != null && curr_padstack.name.compareToIgnoreCase(p_name) == 0) { return curr_padstack; } } return null; } - + /** * Returns the count of Padstacks in this object. */ - public int count() - { + public int count() { return padstack_arr.size(); } - + /** * Returns the padstack with index p_padstack_no for 1 <= p_padstack_no <= padstack_count */ - public Padstack get(int p_padstack_no) - { - if (p_padstack_no <= 0 || p_padstack_no > padstack_arr.size()) - { + public Padstack get(int p_padstack_no) { + if (p_padstack_no <= 0 || p_padstack_no > padstack_arr.size()) { Integer padstack_count = padstack_arr.size(); System.out.println("Padstacks.get: 1 <= p_padstack_no <= " + padstack_count.toString() + " expected"); return null; } Padstack result = padstack_arr.elementAt(p_padstack_no - 1); - if (result != null && result.no != p_padstack_no) - { + if (result != null && result.no != p_padstack_no) { System.out.println("Padstacks.get: inconsistent padstack number"); } return result; } - + /** * Appends a new padstack with the input shapes to this padstacks. * p_shapes is an array of dimension board layer_count. * p_drill_allowed indicates, if vias of the own net are allowed to overlap with this padstack * If p_placed_absolute is false, the layers of the padstack are mirrored, if it is placed on the back side. */ - public Padstack add(String p_name, ConvexShape [] p_shapes, boolean p_drill_allowed, boolean p_placed_absolute) - { + public Padstack add(String p_name, ConvexShape[] p_shapes, boolean p_drill_allowed, boolean p_placed_absolute) { Padstack new_padstack = new Padstack(p_name, padstack_arr.size() + 1, p_shapes, p_drill_allowed, p_placed_absolute, this); padstack_arr.add(new_padstack); return new_padstack; } - + /** * Appends a new padstack with the input shapes to this padstacks. * p_shapes is an array of dimension board layer_count. * The padatack name is generated internally. */ - public Padstack add(ConvexShape [] p_shapes) - { + public Padstack add(ConvexShape[] p_shapes) { String new_name = "padstack#" + (new Integer(padstack_arr.size() + 1).toString()); return add(new_name, p_shapes, false, false); } - + /** * Appends a new padstack withe the input shape from p_from_layer to p_to_layer * and null on the other layers. * The padatack name is generated internally. */ - public Padstack add(ConvexShape p_shape, int p_from_layer, int p_to_layer) - { + public Padstack add(ConvexShape p_shape, int p_from_layer, int p_to_layer) { ConvexShape[] shape_arr = new ConvexShape[board_layer_structure.arr.length]; int from_layer = Math.max(p_from_layer, 0); int to_layer = Math.min(p_to_layer, board_layer_structure.arr.length - 1); - for (int i = from_layer; i <= to_layer; ++i) - { + for (int i = from_layer; i <= to_layer; ++i) { shape_arr[i] = p_shape; } return add(shape_arr); } - - /** The array of Padstacks in this object */ - private Vector padstack_arr; - - /** The layer structure of each padstack. */ - public final net.freerouting.board.LayerStructure board_layer_structure; } diff --git a/src/main/java/net/freerouting/library/package.html b/src/main/java/net/freerouting/library/package.html index 5a207af9..d8c74545 100644 --- a/src/main/java/net/freerouting/library/package.html +++ b/src/main/java/net/freerouting/library/package.html @@ -1,5 +1,6 @@ -java.text package -Describes library objects of a printed circuit board such as padstacks and component packages. \ No newline at end of file +Describes library objects of a printed circuit board such as padstacks and component packages. + + \ No newline at end of file diff --git a/src/main/java/net/freerouting/rules/BoardRules.java b/src/main/java/net/freerouting/rules/BoardRules.java index 8f0f17d8..9ce2abb0 100644 --- a/src/main/java/net/freerouting/rules/BoardRules.java +++ b/src/main/java/net/freerouting/rules/BoardRules.java @@ -28,83 +28,126 @@ * * @author Alfons Wirtz */ -public class BoardRules implements java.io.Serializable -{ +public class BoardRules implements java.io.Serializable { + /** + * The matrix describing the spacing restrictions between + * item clearance classes. + */ + public final ClearanceMatrix clearance_matrix; + /** + * Describes the electrical nets on the board. + */ + public final Nets nets; + public final ViaInfos via_infos = new ViaInfos(); + public final java.util.Vector via_rules = new java.util.Vector(); + public final NetClasses net_classes = new NetClasses(); + private final net.freerouting.board.LayerStructure layer_structure; + /** + * The angle restriction for traces: 90 degree, 45 degree or none. + */ + private transient net.freerouting.board.AngleRestriction trace_angle_restriction; + /** + * If true, the router ignores conduction areas. + */ + private boolean ignore_conduction = true; + /** + * The smallest of all default trace half widths + */ + private int min_trace_half_width; + /** + * The biggest of all default trace half widths + */ + private int max_trace_half_width; + /** + * The minimum distance of the pad border to the first turn of a connected trace + * to a pin with restricted exit directions. + * If the value is <= 0, there are no exit restrictions. + */ + private double pin_edge_to_turn_dist; + private boolean slow_autoroute_algorithm = false; + /** * Creates a new instance of this class. */ - public BoardRules(net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) - { + public BoardRules(net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) { layer_structure = p_layer_structure; clearance_matrix = p_clearance_matrix; nets = new Nets(); this.trace_angle_restriction = net.freerouting.board.AngleRestriction.FORTYFIVE_DEGREE; - + this.min_trace_half_width = 100000; this.max_trace_half_width = 100; } - + + /** + * Gets the default item clearance class + */ + public static int default_clearance_class() { + return 1; + } + + /** + * For items with no clearances + */ + public static int clearance_class_none() { + return 0; + } + /** * Returns the trace halfwidth used for routing with the input net on the input layer. */ - public int get_trace_half_width( int p_net_no, int p_layer) - { + public int get_trace_half_width(int p_net_no, int p_layer) { Net curr_net = nets.get(p_net_no); return curr_net.get_class().get_trace_half_width(p_layer); } - + /** * Returns true, if the trace widths used for routing for the input net are equal on all layers. * If p_net_no < 0, the default trace widths for all nets are checked. */ - public boolean trace_widths_are_layer_dependent(int p_net_no) - { + public boolean trace_widths_are_layer_dependent(int p_net_no) { int compare_width = get_trace_half_width(p_net_no, 0); - for (int i = 1; i < this.layer_structure.arr.length; ++i) - { - if (get_trace_half_width(p_net_no, i) != compare_width) - { + for (int i = 1; i < this.layer_structure.arr.length; ++i) { + if (get_trace_half_width(p_net_no, i) != compare_width) { return true; } } return false; } - - /** Returns he smallest of all default trace half widths*/ - public int get_min_trace_half_width() - { + + /** + * Returns he smallest of all default trace half widths + */ + public int get_min_trace_half_width() { return min_trace_half_width; } - - /** Returns he biggest of all default trace half widths*/ - public int get_max_trace_half_width() - { + + /** + * Returns he biggest of all default trace half widths + */ + public int get_max_trace_half_width() { return max_trace_half_width; } - + /** - * Changes the default trace halfwidth used for routing on the input layer. + * Changes the default trace halfwidth used for routing on the input layer. */ - public void set_default_trace_half_width(int p_layer, int p_value) - { + public void set_default_trace_half_width(int p_layer, int p_value) { this.get_default_net_class().set_trace_half_width(p_layer, p_value); min_trace_half_width = Math.min(min_trace_half_width, p_value); max_trace_half_width = Math.max(max_trace_half_width, p_value); } - - public int get_default_trace_half_width (int p_layer) - { + + public int get_default_trace_half_width(int p_layer) { return this.get_default_net_class().get_trace_half_width(p_layer); } - + /** - * Changes the default trace halfwidth used for routing on all layers + * Changes the default trace halfwidth used for routing on all layers * to the input value. */ - public void set_default_trace_half_widths(int p_value) - { - if (p_value <= 0) - { + public void set_default_trace_half_widths(int p_value) { + if (p_value <= 0) { System.out.println("BoardRules.set_trace_half_widths: p_value out of range"); return; } @@ -112,92 +155,68 @@ public void set_default_trace_half_widths(int p_value) min_trace_half_width = Math.min(min_trace_half_width, p_value); max_trace_half_width = Math.max(max_trace_half_width, p_value); } - + /** * Returns the net rule used for all nets, for whichh no special rrule was set. */ - public NetClass get_default_net_class() - { - if (this.net_classes.count() <= 0) - { + public NetClass get_default_net_class() { + if (this.net_classes.count() <= 0) { // net rules not yet initialized this.create_default_net_class(); } return this.net_classes.get(0); } - - /** Gets the default item clearance class */ - public static int default_clearance_class() - { - return 1; - } - - /** For items with no clearances */ - public static int clearance_class_none() - { - return 0; - } - + /** * Returns an empty new net rule with an internally created name. */ - public NetClass get_new_net_class(java.util.Locale p_locale) - { + public NetClass get_new_net_class(java.util.Locale p_locale) { NetClass result = this.net_classes.append(this.layer_structure, this.clearance_matrix, p_locale); result.set_trace_clearance_class(this.get_default_net_class().get_trace_clearance_class()); result.set_via_rule(this.get_default_via_rule()); result.set_trace_half_width(this.get_default_net_class().get_trace_half_width(0)); return result; } - + /** * Returns an empty new net rule with an internally created name. */ - public NetClass get_new_net_class(String p_name) - { + public NetClass get_new_net_class(String p_name) { NetClass result = this.net_classes.append(p_name, this.layer_structure, this.clearance_matrix); result.set_trace_clearance_class(this.get_default_net_class().get_trace_clearance_class()); result.set_via_rule(this.get_default_via_rule()); result.set_trace_half_width(this.get_default_net_class().get_trace_half_width(0)); return result; } - + /** * Create a default via rule for p_net_class with name p_name. * If more than one via infos with the same layer range are found, * only the via info with the smmallest pad size is inserted. */ - public void create_default_via_rule(NetClass p_net_class, String p_name) - { - if (this.via_infos.count() == 0) - { + public void create_default_via_rule(NetClass p_net_class, String p_name) { + if (this.via_infos.count() == 0) { return; } // Add the rule containing all vias. ViaRule default_rule = new ViaRule(p_name); int default_via_cl_class = p_net_class.default_item_clearance_classes.get(DefaultItemClearanceClasses.ItemClass.VIA); - for (int i = 0; i < this.via_infos.count(); ++i) - { + for (int i = 0; i < this.via_infos.count(); ++i) { ViaInfo curr_via_info = this.via_infos.get(i); - if (curr_via_info.get_clearance_class() == default_via_cl_class) - { + if (curr_via_info.get_clearance_class() == default_via_cl_class) { net.freerouting.library.Padstack curr_padstack = curr_via_info.get_padstack(); int curr_from_layer = curr_padstack.from_layer(); int curr_to_layer = curr_padstack.to_layer(); ViaInfo existing_via = default_rule.get_layer_range(curr_from_layer, curr_to_layer); - if (existing_via != null) - { + if (existing_via != null) { ConvexShape new_shape = curr_padstack.get_shape(curr_from_layer); ConvexShape existing_shape = existing_via.get_padstack().get_shape(curr_from_layer); - if (new_shape.max_width() < existing_shape.max_width()) - { + if (new_shape.max_width() < existing_shape.max_width()) { // The via with the smallest pad shape is preferred default_rule.remove_via(existing_via); default_rule.append_via(curr_via_info); } - } - else - { + } else { default_rule.append_via(curr_via_info); } } @@ -205,21 +224,19 @@ public void create_default_via_rule(NetClass p_net_class, String p_name) this.via_rules.add(default_rule); p_net_class.set_via_rule(default_rule); } - - public void create_default_net_class() - { + + public void create_default_net_class() { // add the default net rule NetClass default_net_class = this.net_classes.append("default", this.layer_structure, this.clearance_matrix); int default_trace_half_width = 1500; default_net_class.set_trace_half_width(default_trace_half_width); default_net_class.set_trace_clearance_class(1); } - + /** * Appends a new net class initialized with default data and a default name. */ - public NetClass append_net_class(java.util.Locale p_locale) - { + public NetClass append_net_class(java.util.Locale p_locale) { NetClass new_class = this.net_classes.append(this.layer_structure, this.clearance_matrix, p_locale); NetClass default_class = this.net_classes.get(0); new_class.set_via_rule(default_class.get_via_rule()); @@ -227,16 +244,14 @@ public NetClass append_net_class(java.util.Locale p_locale) new_class.set_trace_clearance_class(default_class.get_trace_clearance_class()); return new_class; } - + /** * Appends a new net class initialized with default data and returns that class. * If a class with p_name exists, this class is returned withoout appending a new class. */ - public NetClass append_net_class(String p_name) - { + public NetClass append_net_class(String p_name) { NetClass found_class = this.net_classes.get(p_name); - if (found_class != null) - { + if (found_class != null) { return found_class; } NetClass new_class = this.net_classes.append(p_name, this.layer_structure, this.clearance_matrix); @@ -247,232 +262,191 @@ public NetClass append_net_class(String p_name) new_class.set_trace_clearance_class(default_class.get_trace_clearance_class()); return new_class; } - + /** * Returns the default via rule for routing or null, if no via rule exists. */ - public ViaRule get_default_via_rule() - { - if (this.via_rules.isEmpty()) - { + public ViaRule get_default_via_rule() { + if (this.via_rules.isEmpty()) { return null; } return this.via_rules.get(0); } - + /** * Returns the via rule wit name p_name, or null, if no such rule exists. */ - public ViaRule get_via_rule(String p_name) - { - for (ViaRule curr_rule : via_rules) - { - if(curr_rule.name.equals(p_name)) - { + public ViaRule get_via_rule(String p_name) { + for (ViaRule curr_rule : via_rules) { + if (curr_rule.name.equals(p_name)) { return curr_rule; } } return null; } - + /** * Changes the clearance class index of all objects on the board with index p_from_no * to p_to_no. */ - public void change_clearance_class_no(int p_from_no, int p_to_no, java.util.Collection p_board_items) - { - for(net.freerouting.board.Item curr_item : p_board_items) - { - if (curr_item.clearance_class_no() == p_from_no) - { + public void change_clearance_class_no(int p_from_no, int p_to_no, java.util.Collection p_board_items) { + for (net.freerouting.board.Item curr_item : p_board_items) { + if (curr_item.clearance_class_no() == p_from_no) { curr_item.set_clearance_class_no(p_to_no); } } - - for (int i = 0; i < this.net_classes.count(); ++i) - { + + for (int i = 0; i < this.net_classes.count(); ++i) { net.freerouting.rules.NetClass curr_net_class = this.net_classes.get(i); - if (curr_net_class.get_trace_clearance_class() == p_from_no) - { + if (curr_net_class.get_trace_clearance_class() == p_from_no) { curr_net_class.set_trace_clearance_class(p_to_no); } - for (DefaultItemClearanceClasses.ItemClass curr_item_class : DefaultItemClearanceClasses.ItemClass.values()) - { - if (curr_net_class.default_item_clearance_classes.get(curr_item_class) == p_from_no) - { + for (DefaultItemClearanceClasses.ItemClass curr_item_class : DefaultItemClearanceClasses.ItemClass.values()) { + if (curr_net_class.default_item_clearance_classes.get(curr_item_class) == p_from_no) { curr_net_class.default_item_clearance_classes.set(curr_item_class, p_to_no); } } } - - for (int i = 0; i < this.via_infos.count(); ++i) - { + + for (int i = 0; i < this.via_infos.count(); ++i) { net.freerouting.rules.ViaInfo curr_via = this.via_infos.get(i); - if (curr_via.get_clearance_class() == p_from_no) - { + if (curr_via.get_clearance_class() == p_from_no) { curr_via.set_clearance_class(p_to_no); } } } - - + /** * Removes the clearance class with number p_index. * Returns false, if that was not possible, because there were still items assigned to this class. */ - public boolean remove_clearance_class(int p_index, java.util.Collection p_board_items) - { - for(net.freerouting.board.Item curr_item : p_board_items) - { - if (curr_item.clearance_class_no() == p_index) - { + public boolean remove_clearance_class(int p_index, java.util.Collection p_board_items) { + for (net.freerouting.board.Item curr_item : p_board_items) { + if (curr_item.clearance_class_no() == p_index) { return false; } } - for (int i = 0; i < this.net_classes.count(); ++i) - { + for (int i = 0; i < this.net_classes.count(); ++i) { net.freerouting.rules.NetClass curr_net_class = this.net_classes.get(i); - if (curr_net_class.get_trace_clearance_class() == p_index) - { + if (curr_net_class.get_trace_clearance_class() == p_index) { return false; } - for (DefaultItemClearanceClasses.ItemClass curr_item_class : DefaultItemClearanceClasses.ItemClass.values()) - { - if (curr_net_class.default_item_clearance_classes.get(curr_item_class) == p_index) - { + for (DefaultItemClearanceClasses.ItemClass curr_item_class : DefaultItemClearanceClasses.ItemClass.values()) { + if (curr_net_class.default_item_clearance_classes.get(curr_item_class) == p_index) { return false; } } } - - for (int i = 0; i < this.via_infos.count(); ++i) - { + + for (int i = 0; i < this.via_infos.count(); ++i) { net.freerouting.rules.ViaInfo curr_via = this.via_infos.get(i); - if (curr_via.get_clearance_class() == p_index) - { + if (curr_via.get_clearance_class() == p_index) { return false; } } - - for(net.freerouting.board.Item curr_item : p_board_items) - { - if (curr_item.clearance_class_no() > p_index) - { + + for (net.freerouting.board.Item curr_item : p_board_items) { + if (curr_item.clearance_class_no() > p_index) { curr_item.set_clearance_class_no(curr_item.clearance_class_no() - 1); } } - - for (int i = 0; i < this.net_classes.count(); ++i) - { + + for (int i = 0; i < this.net_classes.count(); ++i) { net.freerouting.rules.NetClass curr_net_class = this.net_classes.get(i); - if (curr_net_class.get_trace_clearance_class() > p_index) - { + if (curr_net_class.get_trace_clearance_class() > p_index) { curr_net_class.set_trace_clearance_class(curr_net_class.get_trace_clearance_class() - 1); } - for (DefaultItemClearanceClasses.ItemClass curr_item_class : DefaultItemClearanceClasses.ItemClass.values()) - { + for (DefaultItemClearanceClasses.ItemClass curr_item_class : DefaultItemClearanceClasses.ItemClass.values()) { int curr_class_no = curr_net_class.default_item_clearance_classes.get(curr_item_class); - if (curr_class_no > p_index) - { + if (curr_class_no > p_index) { curr_net_class.default_item_clearance_classes.set(curr_item_class, curr_class_no - 1); } } } - - for (int i = 0; i < this.via_infos.count(); ++i) - { + + for (int i = 0; i < this.via_infos.count(); ++i) { net.freerouting.rules.ViaInfo curr_via = this.via_infos.get(i); - if (curr_via.get_clearance_class() > p_index) - { + if (curr_via.get_clearance_class() > p_index) { curr_via.set_clearance_class(curr_via.get_clearance_class() - 1); } } this.clearance_matrix.remove_class(p_index); return true; } - + /** * Returns the minimum distance between the pin border and the next corner * of a connected trace por a pin with connection restrictions. * If the result is <= 0, there are no exit restrictions. */ - public double get_pin_edge_to_turn_dist() - { + public double get_pin_edge_to_turn_dist() { return this.pin_edge_to_turn_dist; } - + /** * Sets he minimum distance between the pin border and the next corner * of a connected trace por a pin with connection restrictions. * if p_value is <= 0, there are no exit restrictions. */ - public void set_pin_edge_to_turn_dist(double p_value) - { + public void set_pin_edge_to_turn_dist(double p_value) { this.pin_edge_to_turn_dist = p_value; } - - + + /** + * If true, the router ignores conduction areas. + */ + public boolean get_ignore_conduction() { + return this.ignore_conduction; + } + /** * Tells the router, if conduction areas should be ignored.. */ - public void set_ignore_conduction(boolean p_value) - { + public void set_ignore_conduction(boolean p_value) { this.ignore_conduction = p_value; } - + /** - * If true, the router ignores conduction areas. + * The angle restriction for tracese: 90 degree, 45 degree or none. */ - public boolean get_ignore_conduction() - { - return this.ignore_conduction; - } - - /** The angle restriction for tracese: 90 degree, 45 degree or none. */ - public net.freerouting.board.AngleRestriction get_trace_angle_restriction() - { + public net.freerouting.board.AngleRestriction get_trace_angle_restriction() { return this.trace_angle_restriction; } - - /** Sets the angle restriction for tracese: 90 degree, 45 degree or none. */ - public void set_trace_angle_restriction(net.freerouting.board.AngleRestriction p_angle_restriction) - { + + /** + * Sets the angle restriction for tracese: 90 degree, 45 degree or none. + */ + public void set_trace_angle_restriction(net.freerouting.board.AngleRestriction p_angle_restriction) { this.trace_angle_restriction = p_angle_restriction; } - - + /** * If true, shapes of type Simplex are always used in the autorouter algorithm. * If false, shapes of type IntBox are used in 90 degree autorouting * and shapes of type IntOctagon are used in 45 degree autorouting. */ - public void set_slow_autoroute_algorithm(boolean p_value) - { - slow_autoroute_algorithm = p_value; + public boolean get_slow_autoroute_algorithm() { + return slow_autoroute_algorithm; } - + /** * If true, shapes of type Simplex are always used in the autorouter algorithm. * If false, shapes of type IntBox are used in 90 degree autorouting * and shapes of type IntOctagon are used in 45 degree autorouting. */ - public boolean get_slow_autoroute_algorithm() - { - return slow_autoroute_algorithm; + public void set_slow_autoroute_algorithm(boolean p_value) { + slow_autoroute_algorithm = p_value; } - + /** * Returns the Maximum of the diameter of the default via on its first and last layer. */ - public double get_default_via_diameter() - { + public double get_default_via_diameter() { ViaRule default_via_rule = this.get_default_via_rule(); - if (default_via_rule == null) - { + if (default_via_rule == null) { return 0; } - if (default_via_rule.via_count() <= 0) - { + if (default_via_rule.via_count() <= 0) { return 0; } net.freerouting.library.Padstack via_padstack = default_via_rule.get_via(0).get_padstack(); @@ -482,66 +456,23 @@ public double get_default_via_diameter() result = Math.max(result, curr_shape.max_width()); return result; } - - - /** Writes an instance of this class to a file */ + + /** + * Writes an instance of this class to a file + */ private void writeObject(java.io.ObjectOutputStream p_stream) - throws java.io.IOException - { + throws java.io.IOException { p_stream.defaultWriteObject(); p_stream.writeInt(trace_angle_restriction.get_no()); } - - /** Reads an instance of this class from a file */ + + /** + * Reads an instance of this class from a file + */ private void readObject(java.io.ObjectInputStream p_stream) - throws java.io.IOException, java.lang.ClassNotFoundException - { + throws java.io.IOException, java.lang.ClassNotFoundException { p_stream.defaultReadObject(); int snap_angle_no = p_stream.readInt(); this.trace_angle_restriction = net.freerouting.board.AngleRestriction.arr[snap_angle_no]; } - - /** - * The matrix describing the spacing restrictions between - * item clearance classes. - */ - public final ClearanceMatrix clearance_matrix; - - - /** - * Describes the electrical nets on the board. - */ - public final Nets nets; - - - /** The angle restriction for traces: 90 degree, 45 degree or none. */ - private transient net.freerouting.board.AngleRestriction trace_angle_restriction; - - /** - * If true, the router ignores conduction areas. - */ - private boolean ignore_conduction = true; - - private final net.freerouting.board.LayerStructure layer_structure; - - public final ViaInfos via_infos = new ViaInfos(); - - public final java.util.Vector via_rules = new java.util.Vector(); - - public final NetClasses net_classes = new NetClasses(); - - /** The smallest of all default trace half widths */ - private int min_trace_half_width; - - /** The biggest of all default trace half widths */ - private int max_trace_half_width; - - /** - * The minimum distance of the pad border to the first turn of a connected trace - * to a pin with restricted exit directions. - * If the value is <= 0, there are no exit restrictions. - */ - private double pin_edge_to_turn_dist; - - private boolean slow_autoroute_algorithm = false; } diff --git a/src/main/java/net/freerouting/rules/ClearanceMatrix.java b/src/main/java/net/freerouting/rules/ClearanceMatrix.java index 54a6b3f5..e70cfae4 100644 --- a/src/main/java/net/freerouting/rules/ClearanceMatrix.java +++ b/src/main/java/net/freerouting/rules/ClearanceMatrix.java @@ -17,133 +17,120 @@ package net.freerouting.rules; /** - * * NxN Matrix describing the spacing restrictions * between N clearance classes on a fixed set of layers. * - * * @author Alfons Wirtz */ -public class ClearanceMatrix implements java.io.Serializable -{ +public class ClearanceMatrix implements java.io.Serializable { + private final net.freerouting.board.LayerStructure layer_structure; /** - * Creates a new instance with the 2 clearance classes "none"and "default" - * ans initializes it with p_default_value. + * count of clearance classes */ - public static ClearanceMatrix get_default_instance(net.freerouting.board.LayerStructure p_layer_structure, int p_default_value) - { - String [] name_arr = new String [2]; - name_arr[0] = "null"; - name_arr[1] = "default"; - ClearanceMatrix result = new ClearanceMatrix(2, p_layer_structure, name_arr); - result.set_default_value(p_default_value); - return result; - } - + private int class_count; + private Row[] row; // vector of class_count rows of the clearance matrix + private int[] max_value_on_layer; // maximum clearance value for each layer + /** * Creates a new instance for p_class_count clearance classes on * p_layer_count layers. * p_names is an array of dimension p_class_count; */ - public ClearanceMatrix(int p_class_count, net.freerouting.board.LayerStructure p_layer_structure, String [] p_name_arr) - { + public ClearanceMatrix(int p_class_count, net.freerouting.board.LayerStructure p_layer_structure, String[] p_name_arr) { class_count = Math.max(p_class_count, 1); layer_structure = p_layer_structure; - row = new Row [class_count]; - for (int i = 0; i < class_count; ++i) - { + row = new Row[class_count]; + for (int i = 0; i < class_count; ++i) { row[i] = new Row(p_name_arr[i]); } this.max_value_on_layer = new int[layer_structure.arr.length]; } - + + /** + * Creates a new instance with the 2 clearance classes "none"and "default" + * ans initializes it with p_default_value. + */ + public static ClearanceMatrix get_default_instance(net.freerouting.board.LayerStructure p_layer_structure, int p_default_value) { + String[] name_arr = new String[2]; + name_arr[0] = "null"; + name_arr[1] = "default"; + ClearanceMatrix result = new ClearanceMatrix(2, p_layer_structure, name_arr); + result.set_default_value(p_default_value); + return result; + } + /** * Returns the number of the clearance class with the input name, * or -1, if no such clearance class exists. */ - public int get_no(String p_name) - { - for (int i = 0; i < class_count; ++i) - { - if (row[i].name.compareToIgnoreCase(p_name) == 0) - { + public int get_no(String p_name) { + for (int i = 0; i < class_count; ++i) { + if (row[i].name.compareToIgnoreCase(p_name) == 0) { return i; } } return -1; } - + /** * Gets the name of the clearance class with the input number. */ - public String get_name(int p_cl_class) - { - if (p_cl_class < 0 || p_cl_class >= row.length) - { + public String get_name(int p_cl_class) { + if (p_cl_class < 0 || p_cl_class >= row.length) { System.out.println("CleatranceMatrix.get_name: p_cl_class out of range"); return null; } return row[p_cl_class].name; } - + /** * Sets the value of all clearance classes with number >= 1 * to p_value on all layers. */ - public void set_default_value(int p_value) - { - for (int i = 0; i < layer_structure.arr.length; ++i) - { + public void set_default_value(int p_value) { + for (int i = 0; i < layer_structure.arr.length; ++i) { set_default_value(i, p_value); } } - + /** * Sets the value of all clearance classes with number >= 1 * to p_value on p_layer. */ - public void set_default_value(int p_layer, int p_value) - { - for (int i = 1; i < class_count; ++i) - { - for (int j = 1; j < class_count; ++j) - { - - set_value(i, j, p_layer, p_value); + public void set_default_value(int p_layer, int p_value) { + for (int i = 1; i < class_count; ++i) { + for (int j = 1; j < class_count; ++j) { + + set_value(i, j, p_layer, p_value); } } } - + /** * Sets the value of an entry in the clearance matrix to p_value * on all layers. */ - public void set_value(int p_i, int p_j, int p_value) - { - for (int layer = 0; layer < layer_structure.arr.length; ++layer) - { + public void set_value(int p_i, int p_j, int p_value) { + for (int layer = 0; layer < layer_structure.arr.length; ++layer) { set_value(p_i, p_j, layer, p_value); } } - + /** * Sets the value of an entry in the clearance matrix to p_value * on all inner layers. */ - public void set_inner_value(int p_i, int p_j, int p_value) - { - for (int layer = 1; layer < layer_structure.arr.length - 1; ++layer) - { + public void set_inner_value(int p_i, int p_j, int p_value) { + for (int layer = 1; layer < layer_structure.arr.length - 1; ++layer) { set_value(p_i, p_j, layer, p_value); } } - + /** * Sets the value of an entry in the clearance matrix to p_value. */ - public void set_value(int p_i, int p_j, int p_layer, int p_value) - { + public void set_value(int p_i, int p_j, int p_layer, int p_value) { Row curr_row = row[p_j]; MatrixEntry curr_entry = curr_row.column[p_i]; // assure, that the clearance value is even @@ -153,197 +140,169 @@ public void set_value(int p_i, int p_j, int p_layer, int p_value) curr_row.max_value[p_layer] = Math.max(curr_row.max_value[p_layer], p_value); this.max_value_on_layer[p_layer] = Math.max(this.max_value_on_layer[p_layer], p_value); } - + /** * Cets the required spacing of clearance classes with index p_i and p_j * on p_layer. This value will be always an even integer. */ - public int value(int p_i, int p_j, int p_layer) - { + public int value(int p_i, int p_j, int p_layer) { if (p_i < 0 || p_i >= class_count || p_j < 0 || p_j >= class_count - || p_layer < 0 || p_layer >= layer_structure.arr.length) - { + || p_layer < 0 || p_layer >= layer_structure.arr.length) { return 0; } return row[p_j].column[p_i].layer[p_layer]; } - + /** * Returns the maximal required spacing of clearance class with * index p_i to all other clearance classes on layer p_layer. */ - public int max_value(int p_i, int p_layer) - { + public int max_value(int p_i, int p_layer) { int i = Math.max(p_i, 0); i = Math.min(i, class_count - 1); int layer = Math.max(p_layer, 0); layer = Math.min(layer, layer_structure.arr.length - 1); return row[i].max_value[layer]; } - - public int max_value(int p_layer) - { + + public int max_value(int p_layer) { int layer = Math.max(p_layer, 0); layer = Math.min(layer, layer_structure.arr.length - 1); return this.max_value_on_layer[layer]; } - + /** * Returns true, if the values of the clearance matrix * in the p_i-th column and the p_j-th row are not equal on all layers. */ - public boolean is_layer_dependent(int p_i, int p_j) - { + public boolean is_layer_dependent(int p_i, int p_j) { int compare_value = row[p_j].column[p_i].layer[0]; - for (int l = 1; l < layer_structure.arr.length; ++l) - { - if (row[p_j].column[p_i].layer[l] != compare_value) - { + for (int l = 1; l < layer_structure.arr.length; ++l) { + if (row[p_j].column[p_i].layer[l] != compare_value) { return true; } } return false; } - + /** * Returns true, if the values of the clearance matrix * in the p_i-th column and the p_j-th row are not equal on all inner layers. */ - public boolean is_inner_layer_dependent(int p_i, int p_j) - { - if (layer_structure.arr.length <= 2) - { + public boolean is_inner_layer_dependent(int p_i, int p_j) { + if (layer_structure.arr.length <= 2) { return false; // no inner layers } int compare_value = row[p_j].column[p_i].layer[1]; - for (int l = 2; l < layer_structure.arr.length - 1; ++l) - { - if (row[p_j].column[p_i].layer[l] != compare_value) - { + for (int l = 2; l < layer_structure.arr.length - 1; ++l) { + if (row[p_j].column[p_i].layer[l] != compare_value) { return true; } } return false; } - + /** * Returns the row with index p_no */ - public Row get_row(int p_no) - { - if (p_no < 0 || p_no >= this.row.length) - { + public Row get_row(int p_no) { + if (p_no < 0 || p_no >= this.row.length) { System.out.println("ClearanceMatrix.get_row: p_no out of range"); return null; } return this.row[p_no]; } - - public int get_class_count() - { + + public int get_class_count() { return this.class_count; } - + /** * Return the layer count of this clearance matrix;# */ - public int get_layer_count() - { + public int get_layer_count() { return layer_structure.arr.length; } - + /** * Return the clearance compensation value of p_clearance_class_no on layer p_layer. */ - public int clearance_compensation_value(int p_clearance_class_no, int p_layer) - { - return (this.value(p_clearance_class_no, p_clearance_class_no, p_layer) + 1)/ 2; + public int clearance_compensation_value(int p_clearance_class_no, int p_layer) { + return (this.value(p_clearance_class_no, p_clearance_class_no, p_layer) + 1) / 2; } - + /** * Appends a new clearance class to the clearence matrix and * initializes it with the values of the default class. * Returns false, oif a clearance class with name p_class_name is already existing. */ - public boolean append_class(String p_class_name) - { - if (this.get_no(p_class_name) >= 0) - { + public boolean append_class(String p_class_name) { + if (this.get_no(p_class_name) >= 0) { return false; } int old_class_count = this.class_count; ++this.class_count; - - Row [] new_row = new Row [this.class_count]; - + + Row[] new_row = new Row[this.class_count]; + // append a matrix entry to each old row - for (int i = 0; i < old_class_count; ++i) - { + for (int i = 0; i < old_class_count; ++i) { Row curr_old_row = this.row[i]; new_row[i] = new Row(curr_old_row.name); Row curr_new_row = new_row[i]; curr_new_row.max_value = curr_old_row.max_value; - for (int j = 0; j < old_class_count; ++j) - { + for (int j = 0; j < old_class_count; ++j) { curr_new_row.column[j] = curr_old_row.column[j]; } - + curr_new_row.column[old_class_count] = new MatrixEntry(); } - + // append the new row - - new_row [old_class_count] = new Row(p_class_name); - + + new_row[old_class_count] = new Row(p_class_name); + this.row = new_row; - + // Set the new matrix elements to default values. - - for (int i = 0; i < old_class_count; ++i) - { - for (int j = 0; j < this.layer_structure.arr.length; ++j) - { + + for (int i = 0; i < old_class_count; ++i) { + for (int j = 0; j < this.layer_structure.arr.length; ++j) { int default_value = this.value(1, i, j); this.set_value(old_class_count, i, j, default_value); this.set_value(i, old_class_count, j, default_value); } } - - for (int j = 0; j < this.layer_structure.arr.length; ++j) - { + + for (int j = 0; j < this.layer_structure.arr.length; ++j) { int default_value = this.value(1, 1, j); this.set_value(old_class_count, old_class_count, j, default_value); } return true; } - + /** * Removes the class with index p_index from the clearance matrix. */ - void remove_class(int p_index) - { + void remove_class(int p_index) { int old_class_count = this.class_count; --this.class_count; - - Row [] new_row = new Row [this.class_count]; - + + Row[] new_row = new Row[this.class_count]; + // remove the matrix entry with inded p_index in to each old row int new_row_index = 0; - for (int i = 0; i < old_class_count; ++i) - { - if (i == p_index) - { + for (int i = 0; i < old_class_count; ++i) { + if (i == p_index) { continue; } Row curr_old_row = this.row[i]; new_row[new_row_index] = new Row(curr_old_row.name); Row curr_new_row = new_row[new_row_index]; - + int new_column_index = 0; - for (int j = 0; j < old_class_count; ++j) - { - if (j == p_index) - { + for (int j = 0; j < old_class_count; ++j) { + if (j == p_index) { continue; } curr_new_row.column[new_column_index] = curr_old_row.column[j]; @@ -353,77 +312,59 @@ void remove_class(int p_index) } this.row = new_row; } - + /** * Returns true, if all clearance values of the class with index p_1 are equal to * the clearance values of index p_2. */ - public boolean is_equal(int p_1, int p_2) - { - if (p_1 == p_2) - { + public boolean is_equal(int p_1, int p_2) { + if (p_1 == p_2) { return true; } - if (p_1 < 0 || p_2 < 0 || p_1 >= this.class_count || p_2 >= this.class_count) - { + if (p_1 < 0 || p_2 < 0 || p_1 >= this.class_count || p_2 >= this.class_count) { return false; } Row row_1 = this.row[p_1]; Row row_2 = this.row[p_2]; - for (int i = 1; i < class_count; ++i) - { - if (!row_1.column[i].equals(row_2.column[i])) - { + for (int i = 1; i < class_count; ++i) { + if (!row_1.column[i].equals(row_2.column[i])) { return false; } } return true; } - - /** - * count of clearance classes - */ - private int class_count; - - private final net.freerouting.board.LayerStructure layer_structure; - private Row [] row; // vector of class_count rows of the clearance matrix - private int [] max_value_on_layer; // maximum clearance value for each layer - - + /** * contains a row of entries of the clearance matrix */ - private class Row implements net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable - { - private Row(String p_name) - { + private class Row implements net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { + final String name; + final MatrixEntry[] column; + int[] max_value; + + private Row(String p_name) { name = p_name; - column = new MatrixEntry [class_count]; - for (int i = 0; i < class_count; ++i) - { + column = new MatrixEntry[class_count]; + for (int i = 0; i < class_count; ++i) { column[i] = new MatrixEntry(); } max_value = new int[layer_structure.arr.length]; } - - public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("spacing_from_clearance_class") + " "); p_window.append_bold(this.name); - for (int i = 1; i < this.column.length; ++i) - { + for (int i = 1; i < this.column.length; ++i) { p_window.newline(); p_window.indent(); p_window.append(" " + resources.getString("to_class") + " "); p_window.append(row[i].name); MatrixEntry curr_column = this.column[i]; - if (curr_column.is_layer_dependent()) - { + if (curr_column.is_layer_dependent()) { p_window.append(" " + resources.getString("on_layer") + " "); - for (int j = 0; j < layer_structure.arr.length; ++j) - { + for (int j = 0; j < layer_structure.arr.length; ++j) { p_window.newline(); p_window.indent(); p_window.indent(); @@ -431,65 +372,50 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util p_window.append(" = "); p_window.append(curr_column.layer[j]); } - } - else - { + } else { p_window.append(" = "); p_window.append(curr_column.layer[0]); } } } - - final String name; - - int [] max_value; - final MatrixEntry [] column; } - + /** * a single entry of the clearance matrix */ - private class MatrixEntry implements java.io.Serializable - { - private MatrixEntry() - { - layer = new int [layer_structure.arr.length]; - for (int i = 0; i < layer_structure.arr.length; ++i) - { + private class MatrixEntry implements java.io.Serializable { + int[] layer; + + private MatrixEntry() { + layer = new int[layer_structure.arr.length]; + for (int i = 0; i < layer_structure.arr.length; ++i) { layer[i] = 0; } } - + /** * Returns thrue of all clearances values of this and p_other are equal. */ - boolean equals(MatrixEntry p_other) - { - for (int i = 0; i < layer_structure.arr.length; ++i) - { - if (this.layer[i] != p_other.layer[i]) - { + boolean equals(MatrixEntry p_other) { + for (int i = 0; i < layer_structure.arr.length; ++i) { + if (this.layer[i] != p_other.layer[i]) { return false; } } return true; } - + /** * Return true, if not all layer values are equal. */ - boolean is_layer_dependent() - { + boolean is_layer_dependent() { int compare_value = layer[0]; - for (int i = 1; i < layer_structure.arr.length; ++i) - { - if (layer[i] != compare_value) - { + for (int i = 1; i < layer_structure.arr.length; ++i) { + if (layer[i] != compare_value) { return true; } } return false; } - int [] layer; } } \ No newline at end of file diff --git a/src/main/java/net/freerouting/rules/DefaultItemClearanceClasses.java b/src/main/java/net/freerouting/rules/DefaultItemClearanceClasses.java index 6d8764aa..ba04d1d7 100644 --- a/src/main/java/net/freerouting/rules/DefaultItemClearanceClasses.java +++ b/src/main/java/net/freerouting/rules/DefaultItemClearanceClasses.java @@ -22,65 +22,56 @@ package net.freerouting.rules; /** - * * @author Alfons Wirtz */ -public class DefaultItemClearanceClasses implements java.io.Serializable -{ - - /** Creates a new instance of DefaultItemClearancesClasses */ - public DefaultItemClearanceClasses() - { - for (int i = 1; i < ItemClass.values().length; ++i) - { +public class DefaultItemClearanceClasses implements java.io.Serializable { + + private final int[] arr = new int[ItemClass.values().length]; + + /** + * Creates a new instance of DefaultItemClearancesClasses + */ + public DefaultItemClearanceClasses() { + for (int i = 1; i < ItemClass.values().length; ++i) { arr[i] = 1; } } - - public DefaultItemClearanceClasses(DefaultItemClearanceClasses p_classes) - { - for (int i = 1; i < ItemClass.values().length; ++i) - { + + public DefaultItemClearanceClasses(DefaultItemClearanceClasses p_classes) { + for (int i = 1; i < ItemClass.values().length; ++i) { arr[i] = p_classes.arr[i]; } } - - /** - * Used in the function get_default_clearance_class to get the - * default claearance classes for item classes. - */ - public enum ItemClass - { - NONE, TRACE, VIA, PIN, SMD, AREA - } - + /** * Returns the number of the default clearance class for the input item class. */ - public int get(ItemClass p_item_class) - { + public int get(ItemClass p_item_class) { return this.arr[p_item_class.ordinal()]; } - + /** * Sets the index of the default clearance class of the input item class * in the clearance matrix to p_index. */ - public void set(ItemClass p_item_class, int p_index) - { + public void set(ItemClass p_item_class, int p_index) { this.arr[p_item_class.ordinal()] = p_index; } - + /** * Sets the indices of all default item clearance classes to p_index. */ - public void set_all(int p_index) - { - for (int i = 1; i < this.arr.length; ++i) - { + public void set_all(int p_index) { + for (int i = 1; i < this.arr.length; ++i) { arr[i] = p_index; } } - - private final int[] arr = new int[ItemClass.values().length]; + + /** + * Used in the function get_default_clearance_class to get the + * default claearance classes for item classes. + */ + public enum ItemClass { + NONE, TRACE, VIA, PIN, SMD, AREA + } } diff --git a/src/main/java/net/freerouting/rules/Net.java b/src/main/java/net/freerouting/rules/Net.java index 5da312bf..bfea4a43 100644 --- a/src/main/java/net/freerouting/rules/Net.java +++ b/src/main/java/net/freerouting/rules/Net.java @@ -21,23 +21,46 @@ import net.freerouting.board.Item; import net.freerouting.board.ObjectInfoPanel.Printable; - import net.freerouting.datastructures.UndoableObjects; /** * Describes properties for an individual electrical net. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Net implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable -{ +public class Net implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { + + /** + * The name of the net + */ + public final String name; + /** + * Used only if a net is divided internally because of fromto rules for example + * For normal nets it is always 1. + */ + public final int subnet_number; + /** + * The unique strict positive number of the net + */ + public final int net_number; + /** + * The net list, where this net belongs to. + */ + public final Nets net_list; + /** + * Indicates, if this net contains a power plane + */ + private boolean contains_plane; + /** + * The routing rule of this net + */ + private NetClass net_class; /** * Creates a new instance of Net. * p_net_list is the net list, where this net belongs to. */ - public Net(String p_name, int p_subnet_number, int p_no, Nets p_net_list, boolean p_contains_plane) - { + public Net(String p_name, int p_subnet_number, int p_no, Nets p_net_list, boolean p_contains_plane) { name = p_name; subnet_number = p_subnet_number; net_number = p_no; @@ -46,8 +69,7 @@ public Net(String p_name, int p_subnet_number, int p_no, Nets p_net_list, boolea net_class = p_net_list.get_board().rules.get_default_net_class(); } - public String toString() - { + public String toString() { return this.name; } @@ -55,42 +77,38 @@ public String toString() * Compares 2 nets by name. * Useful for example to display nets in alphabetic order. */ - public int compareTo(Net p_other) - { + public int compareTo(Net p_other) { return this.name.compareToIgnoreCase(p_other.name); } - /** Returns the class of this net. */ - public NetClass get_class() - { + /** + * Returns the class of this net. + */ + public NetClass get_class() { return this.net_class; } - /** Sets the class of this net */ - public void set_class(NetClass p_rule) - { + /** + * Sets the class of this net + */ + public void set_class(NetClass p_rule) { this.net_class = p_rule; } /** * Returns the pins and conduction areas of this net. */ - public java.util.Collection get_terminal_items() - { + public java.util.Collection get_terminal_items() { java.util.Collection result = new java.util.LinkedList(); net.freerouting.board.BasicBoard board = this.net_list.get_board(); java.util.Iterator it = board.item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) board.item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof net.freerouting.board.Connectable) - { - if (curr_item.contains_net(this.net_number) && !curr_item.is_route()) - { + if (curr_item instanceof net.freerouting.board.Connectable) { + if (curr_item.contains_net(this.net_number) && !curr_item.is_route()) { result.add(curr_item); } } @@ -101,22 +119,17 @@ public java.util.Collection get_terminal_items() /** * Returns the pins of this net. */ - public java.util.Collection get_pins() - { + public java.util.Collection get_pins() { java.util.Collection result = new java.util.LinkedList(); net.freerouting.board.BasicBoard board = this.net_list.get_board(); java.util.Iterator it = board.item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) board.item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item instanceof net.freerouting.board.Pin) - { - if (curr_item.contains_net(this.net_number)) - { + if (curr_item instanceof net.freerouting.board.Pin) { + if (curr_item.contains_net(this.net_number)) { result.add((net.freerouting.board.Pin) curr_item); } } @@ -127,20 +140,16 @@ public java.util.Collection get_pins() /** * Returns all items of this net. */ - public java.util.Collection get_items() - { + public java.util.Collection get_items() { java.util.Collection result = new java.util.LinkedList(); net.freerouting.board.BasicBoard board = this.net_list.get_board(); java.util.Iterator it = board.item_list.start_read_object(); - for (;;) - { + for (; ; ) { Item curr_item = (Item) board.item_list.read_object(it); - if (curr_item == null) - { + if (curr_item == null) { break; } - if (curr_item.contains_net(this.net_number)) - { + if (curr_item.contains_net(this.net_number)) { result.add(curr_item); } } @@ -150,15 +159,12 @@ public java.util.Collection get_items() /** * Returns the cumulative trace length of all traces on the board belonging to this net. */ - public double get_trace_length() - { + public double get_trace_length() { double cumulative_trace_length = 0; java.util.Collection net_items = net_list.get_board().get_connectable_items(this.net_number); - for (Item curr_item : net_items) - { + for (Item curr_item : net_items) { - if (curr_item instanceof net.freerouting.board.Trace) - { + if (curr_item instanceof net.freerouting.board.Trace) { cumulative_trace_length += ((net.freerouting.board.Trace) curr_item).get_length(); } } @@ -168,38 +174,32 @@ public double get_trace_length() /** * Returns the count of vias on the board belonging to this net. */ - public int get_via_count() - { + public int get_via_count() { int result = 0; java.util.Collection net_items = net_list.get_board().get_connectable_items(this.net_number); - for (Item curr_item : net_items) - { - if (curr_item instanceof net.freerouting.board.Via) - { + for (Item curr_item : net_items) { + if (curr_item instanceof net.freerouting.board.Via) { ++result; } } return result; } - public void set_contains_plane(boolean p_value) - { + public void set_contains_plane(boolean p_value) { contains_plane = p_value; } - /** + /** * Indicates, if this net contains a power plane. * Used by the autorouter for setting the via costs to the cheap plane via costs. * May also be true, if a layer covered with a conduction_area of this net is * is a signal layer. */ - public boolean contains_plane() - { + public boolean contains_plane() { return contains_plane; } - public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) - { + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { Integer via_count = this.get_via_count(); double cumulative_trace_length = this.get_trace_length(); java.util.Collection terminal_items = this.get_terminal_items(); @@ -224,19 +224,4 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util p_window.newline(); } - /** The name of the net */ - public final String name; - /** - * Used only if a net is divided internally because of fromto rules for example - * For normal nets it is always 1. - */ - public final int subnet_number; - /** The unique strict positive number of the net */ - public final int net_number; - /** Indicates, if this net contains a power plane */ - private boolean contains_plane; - /** The routing rule of this net */ - private NetClass net_class; - /** The net list, where this net belongs to. */ - public final Nets net_list; } diff --git a/src/main/java/net/freerouting/rules/NetClass.java b/src/main/java/net/freerouting/rules/NetClass.java index 931c06b7..1b50fcb4 100644 --- a/src/main/java/net/freerouting/rules/NetClass.java +++ b/src/main/java/net/freerouting/rules/NetClass.java @@ -24,60 +24,74 @@ * * @author Alfons Wirtz */ -public class NetClass implements java.io.Serializable, net.freerouting.board.ObjectInfoPanel.Printable -{ +public class NetClass implements java.io.Serializable, net.freerouting.board.ObjectInfoPanel.Printable { - /** Creates a new instance of NetClass */ - public NetClass(String p_name, net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) - { + private final ClearanceMatrix clearance_matrix; + private final net.freerouting.board.LayerStructure board_layer_structure; + /** + * The clearance classes of the item types, if this net class comes from a class in a Speccctra dsn-file + * Should evtl be moved to designformats.specctra.NetClass and used only when reading a dsn-file. + */ + public DefaultItemClearanceClasses default_item_clearance_classes = new DefaultItemClearanceClasses(); + private String name; + private ViaRule via_rule; + private int trace_clearance_class; + private int[] trace_half_width_arr; + private boolean[] active_routing_layer_arr; + /** + * if null, all signal layers may be used for routing + */ + private boolean shove_fixed = false; + private boolean pull_tight = true; + private boolean ignore_cycles_with_areas = false; + private double minimum_trace_length = 0; + private double maximum_trace_length = 0; + + /** + * Creates a new instance of NetClass + */ + public NetClass(String p_name, net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) { this.name = p_name; this.board_layer_structure = p_layer_structure; this.clearance_matrix = p_clearance_matrix; this.trace_half_width_arr = new int[p_layer_structure.arr.length]; this.active_routing_layer_arr = new boolean[p_layer_structure.arr.length]; - for (int i = 0; i < p_layer_structure.arr.length; ++i) - { + for (int i = 0; i < p_layer_structure.arr.length; ++i) { this.active_routing_layer_arr[i] = p_layer_structure.arr[i].is_signal; } } - public String toString() - { + public String toString() { return this.name; } /** - * Changes the name of this net class. + * Gets the name of this net class. */ - public void set_name(String p_name) - { - this.name = p_name; + public String get_name() { + return this.name; } /** - * Gets the name of this net class. + * Changes the name of this net class. */ - public String get_name() - { - return this.name; + public void set_name(String p_name) { + this.name = p_name; } /** * Sets the trace half width used for routing to p_value on all layers. */ - public void set_trace_half_width(int p_value) - { + public void set_trace_half_width(int p_value) { java.util.Arrays.fill(trace_half_width_arr, p_value); } /** * Sets the trace half width used for routing to p_value on all inner layers. */ - public void set_trace_half_width_on_inner(int p_value) - { - for (int i = 1; i < trace_half_width_arr.length - 1; ++i) - { + public void set_trace_half_width_on_inner(int p_value) { + for (int i = 1; i < trace_half_width_arr.length - 1; ++i) { trace_half_width_arr[i] = p_value; } } @@ -85,115 +99,100 @@ public void set_trace_half_width_on_inner(int p_value) /** * Sets the trace half width used for routing to p_value on the input layer. */ - public void set_trace_half_width(int p_layer, int p_value) - { + public void set_trace_half_width(int p_layer, int p_value) { trace_half_width_arr[p_layer] = p_value; } - public int layer_count() - { + public int layer_count() { return trace_half_width_arr.length; } /** * Gets the trace half width used for routing on the input layer. */ - public int get_trace_half_width(int p_layer) - { - if (p_layer < 0 || p_layer >= trace_half_width_arr.length) - { + public int get_trace_half_width(int p_layer) { + if (p_layer < 0 || p_layer >= trace_half_width_arr.length) { System.out.println(" NetClass.get_trace_half_width: p_layer out of range"); return 0; } return trace_half_width_arr[p_layer]; } - /** - * Sets the clearance class used for routing traces with this net rclass. - */ - public void set_trace_clearance_class(int p_clearance_class_no) - { - this.trace_clearance_class = p_clearance_class_no; - } - /** * Gets the clearance class used for routing traces with this net class. */ - public int get_trace_clearance_class() - { + public int get_trace_clearance_class() { return this.trace_clearance_class; } /** - * Sets the via rule of this net class. + * Sets the clearance class used for routing traces with this net rclass. */ - public void set_via_rule(ViaRule p_via_rule) - { - this.via_rule = p_via_rule; + public void set_trace_clearance_class(int p_clearance_class_no) { + this.trace_clearance_class = p_clearance_class_no; } /** * Gets the via rule of this net rule. */ - public ViaRule get_via_rule() - { + public ViaRule get_via_rule() { return this.via_rule; } /** - * Sets, if traces and vias of this net class can be pushed. + * Sets the via rule of this net class. */ - public void set_shove_fixed(boolean p_value) - { - this.shove_fixed = p_value; + public void set_via_rule(ViaRule p_via_rule) { + this.via_rule = p_via_rule; } /** * Returns, if traces and vias of this net class can be pushed. */ - public boolean is_shove_fixed() - { + public boolean is_shove_fixed() { return this.shove_fixed; } /** - * Sets, if traces of this nets class are pulled tight. + * Sets, if traces and vias of this net class can be pushed. */ - public void set_pull_tight(boolean p_value) - { - this.pull_tight = p_value; + public void set_shove_fixed(boolean p_value) { + this.shove_fixed = p_value; } /** * Returns, if traces of this nets class are pulled tight. */ - public boolean get_pull_tight() - { + public boolean get_pull_tight() { return this.pull_tight; } /** - * Sets, if the cycle remove algorithm ignores cycles, where conduction areas are involved + * Sets, if traces of this nets class are pulled tight. */ - public void set_ignore_cycles_with_areas(boolean p_value) - { - this.ignore_cycles_with_areas = p_value; + public void set_pull_tight(boolean p_value) { + this.pull_tight = p_value; } /** * Returns, if the cycle remove algorithm ignores cycles, where conduction areas are involved */ - public boolean get_ignore_cycles_with_areas() - { + public boolean get_ignore_cycles_with_areas() { return this.ignore_cycles_with_areas; } + /** + * Sets, if the cycle remove algorithm ignores cycles, where conduction areas are involved + */ + public void set_ignore_cycles_with_areas(boolean p_value) { + this.ignore_cycles_with_areas = p_value; + } + /** * Returns the minimum trace length of this net class. * If the result is <= 0, there is no minimal trace length restriction. */ - public double get_minimum_trace_length() - { + public double get_minimum_trace_length() { return minimum_trace_length; } @@ -201,8 +200,7 @@ public double get_minimum_trace_length() * Sets the minimum trace length of this net class to p_value. * If p_value is <= 0, there is no minimal trace length restriction. */ - public void set_minimum_trace_length(double p_value) - { + public void set_minimum_trace_length(double p_value) { minimum_trace_length = p_value; } @@ -210,8 +208,7 @@ public void set_minimum_trace_length(double p_value) * Returns the maximum trace length of this net class. * If the result is <= 0, there is no maximal trace length restriction. */ - public double get_maximum_trace_length() - { + public double get_maximum_trace_length() { return maximum_trace_length; } @@ -219,56 +216,47 @@ public double get_maximum_trace_length() * Sets the maximum trace length of this net class to p_value. * If p_value is <= 0, there is no maximal trace length restriction. */ - public void set_maximum_trace_length(double p_value) - { + public void set_maximum_trace_length(double p_value) { maximum_trace_length = p_value; } /** - * Returns if the layer with index p_layer_no is active for routing + * Returns if the layer with index p_layer_no is active for routing */ - public boolean is_active_routing_layer(int p_layer_no) - { - if (p_layer_no < 0 || p_layer_no >= this.active_routing_layer_arr.length) - { + public boolean is_active_routing_layer(int p_layer_no) { + if (p_layer_no < 0 || p_layer_no >= this.active_routing_layer_arr.length) { return false; } return this.active_routing_layer_arr[p_layer_no]; } /** - * Sets the layer with index p_layer_no to p_active. + * Sets the layer with index p_layer_no to p_active. */ - public void set_active_routing_layer(int p_layer_no, boolean p_active) - { - if (p_layer_no < 0 || p_layer_no >= this.active_routing_layer_arr.length) - { + public void set_active_routing_layer(int p_layer_no, boolean p_active) { + if (p_layer_no < 0 || p_layer_no >= this.active_routing_layer_arr.length) { return; } this.active_routing_layer_arr[p_layer_no] = p_active; } /** - * Activates or deactivates all layers for routing + * Activates or deactivates all layers for routing */ - public void set_all_layers_active(boolean p_value) - { + public void set_all_layers_active(boolean p_value) { java.util.Arrays.fill(this.active_routing_layer_arr, p_value); } /** - * Activates or deactivates all inner layers for routing + * Activates or deactivates all inner layers for routing */ - public void set_all_inner_layers_active(boolean p_value) - { - for (int i = 1; i < trace_half_width_arr.length - 1; ++i) - { + public void set_all_inner_layers_active(boolean p_value) { + for (int i = 1; i < trace_half_width_arr.length - 1; ++i) { active_routing_layer_arr[i] = p_value; } } - public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) - { + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("net_class_2") + " "); @@ -277,16 +265,13 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util p_window.append(" " + resources.getString("trace_clearance_class") + " "); String cl_name = clearance_matrix.get_name(this.trace_clearance_class); p_window.append(cl_name, resources.getString("trace_clearance_class_2"), clearance_matrix.get_row(this.trace_clearance_class)); - if (this.shove_fixed) - { + if (this.shove_fixed) { p_window.append(", " + resources.getString("shove_fixed")); } p_window.append(", " + resources.getString("via_rule") + " "); p_window.append(via_rule.name, resources.getString("via_rule_2"), via_rule); - if (trace_width_is_layer_dependent()) - { - for (int i = 0; i < trace_half_width_arr.length; ++i) - { + if (trace_width_is_layer_dependent()) { + for (int i = 0; i < trace_half_width_arr.length; ++i) { p_window.newline(); p_window.indent(); p_window.append(resources.getString("trace_width") + " "); @@ -294,9 +279,7 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util p_window.append(" " + resources.getString("on_layer") + " "); p_window.append(this.board_layer_structure.arr[i].name); } - } - else - { + } else { p_window.append(", " + resources.getString("trace_width") + " "); p_window.append(2 * trace_half_width_arr[0]); } @@ -304,16 +287,13 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util } /** - * Returns true, if the trace width of this class is not equal on all layers. */ - public boolean trace_width_is_layer_dependent() - { + * Returns true, if the trace width of this class is not equal on all layers. + */ + public boolean trace_width_is_layer_dependent() { int compare_value = trace_half_width_arr[0]; - for (int i = 1; i < trace_half_width_arr.length; ++i) - { - if (this.board_layer_structure.arr[i].is_signal) - { - if (trace_half_width_arr[i] != compare_value) - { + for (int i = 1; i < trace_half_width_arr.length; ++i) { + if (this.board_layer_structure.arr[i].is_signal) { + if (trace_half_width_arr[i] != compare_value) { return true; } } @@ -324,51 +304,26 @@ public boolean trace_width_is_layer_dependent() /** * Returns true, if the trace width of this class is not equal on all inner layers. */ - public boolean trace_width_is_inner_layer_dependent() - { + public boolean trace_width_is_inner_layer_dependent() { - if (trace_half_width_arr.length <= 3) - { + if (trace_half_width_arr.length <= 3) { return false; } int first_inner_layer_no = 1; - while (!this.board_layer_structure.arr[first_inner_layer_no].is_signal) - { + while (!this.board_layer_structure.arr[first_inner_layer_no].is_signal) { ++first_inner_layer_no; } - if (first_inner_layer_no >= trace_half_width_arr.length - 1) - { + if (first_inner_layer_no >= trace_half_width_arr.length - 1) { return false; } int compare_width = trace_half_width_arr[first_inner_layer_no]; - for (int i = first_inner_layer_no + 1; i < trace_half_width_arr.length - 1; ++i) - { - if (this.board_layer_structure.arr[i].is_signal) - { - if (trace_half_width_arr[i] != compare_width) - { + for (int i = first_inner_layer_no + 1; i < trace_half_width_arr.length - 1; ++i) { + if (this.board_layer_structure.arr[i].is_signal) { + if (trace_half_width_arr[i] != compare_width) { return true; } } } return false; } - private String name; - private ViaRule via_rule; - private int trace_clearance_class; - private int[] trace_half_width_arr; - private boolean[] active_routing_layer_arr; - /** if null, all signal layers may be used for routing */ - private boolean shove_fixed = false; - private boolean pull_tight = true; - private boolean ignore_cycles_with_areas = false; - private double minimum_trace_length = 0; - private double maximum_trace_length = 0; - private final ClearanceMatrix clearance_matrix; - private final net.freerouting.board.LayerStructure board_layer_structure; - /** - * The clearance classes of the item types, if this net class comes from a class in a Speccctra dsn-file - * Should evtl be moved to designformats.specctra.NetClass and used only when reading a dsn-file. - */ - public DefaultItemClearanceClasses default_item_clearance_classes = new DefaultItemClearanceClasses(); } diff --git a/src/main/java/net/freerouting/rules/NetClasses.java b/src/main/java/net/freerouting/rules/NetClasses.java index 66ad7e39..c815dfc0 100644 --- a/src/main/java/net/freerouting/rules/NetClasses.java +++ b/src/main/java/net/freerouting/rules/NetClasses.java @@ -26,139 +26,116 @@ * * @author Alfons Wirtz */ -public class NetClasses implements java.io.Serializable -{ +public class NetClasses implements java.io.Serializable { + private final java.util.Vector class_arr = new java.util.Vector(); + /** * Returns the number of classes in this array. */ - public int count() - { + public int count() { return class_arr.size(); } - + /** * Returns the net class with index p_index. */ - public NetClass get(int p_index) - { - assert p_index >= 0 && p_index <= class_arr.size() - 1; + public NetClass get(int p_index) { + assert p_index >= 0 && p_index <= class_arr.size() - 1; return class_arr.get(p_index); } - + /** * Returns the net class with name p_name, or null, if no such class exists. */ - public NetClass get(String p_name) - { - for (NetClass curr_class : this.class_arr) - { - if (curr_class.get_name().equals(p_name)) - { + public NetClass get(String p_name) { + for (NetClass curr_class : this.class_arr) { + if (curr_class.get_name().equals(p_name)) { return curr_class; } } return null; } - + /** * Appends a new empty class with name p_name to the class array */ - NetClass append(String p_name, net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) - { + NetClass append(String p_name, net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix) { NetClass new_class = new NetClass(p_name, p_layer_structure, p_clearance_matrix); class_arr.add(new_class); return new_class; } - + /** * Appends a new empty class to the class array. A name for the class is created internally */ - NetClass append(net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + NetClass append(net.freerouting.board.LayerStructure p_layer_structure, ClearanceMatrix p_clearance_matrix, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.rules.Default", p_locale); String name_front = resources.getString("class"); String new_name = null; Integer index = 0; - for (;;) - { + for (; ; ) { ++index; new_name = name_front + index.toString(); - if (this.get(new_name) == null) - { + if (this.get(new_name) == null) { break; } } return append(new_name, p_layer_structure, p_clearance_matrix); } - + /** * Looks, if the list contains a net class with trace half widths all equal to p_trace_half_width, * trace clearance class equal to p_trace_clearance_class and via rule equal to p_cia_rule. * Returns null, if no such net class was found. */ - public NetClass find(int p_trace_half_width, int p_trace_clearance_class, ViaRule p_via_rule) - { - for (NetClass curr_class : this.class_arr) - { - if (curr_class.get_trace_clearance_class() == p_trace_clearance_class && curr_class.get_via_rule() == p_via_rule) - { + public NetClass find(int p_trace_half_width, int p_trace_clearance_class, ViaRule p_via_rule) { + for (NetClass curr_class : this.class_arr) { + if (curr_class.get_trace_clearance_class() == p_trace_clearance_class && curr_class.get_via_rule() == p_via_rule) { boolean trace_widths_equal = true; - for (int i = 0; i < curr_class.layer_count(); ++i) - { - if (curr_class.get_trace_half_width(i) != p_trace_half_width) - { + for (int i = 0; i < curr_class.layer_count(); ++i) { + if (curr_class.get_trace_half_width(i) != p_trace_half_width) { trace_widths_equal = false; break; } } - if (trace_widths_equal) - { + if (trace_widths_equal) { return curr_class; } } } return null; } - + /** * Looks, if the list contains a net class with trace half width[i] all equal to p_trace_half_width_arr[i] * for 0 <= i < layer_count, trace clearance class equal to p_trace_clearance_class * and via rule equal to p_via_rule. Returns null, if no such net class was found. */ - public NetClass find(int[] p_trace_half_width_arr, int p_trace_clearance_class, ViaRule p_via_rule) - { - for (NetClass curr_class : this.class_arr) - { + public NetClass find(int[] p_trace_half_width_arr, int p_trace_clearance_class, ViaRule p_via_rule) { + for (NetClass curr_class : this.class_arr) { if (curr_class.get_trace_clearance_class() == p_trace_clearance_class && curr_class.get_via_rule() == p_via_rule - && p_trace_half_width_arr.length == curr_class.layer_count()) - { + && p_trace_half_width_arr.length == curr_class.layer_count()) { boolean trace_widths_equal = true; - for (int i = 0; i < curr_class.layer_count(); ++i) - { - if (curr_class.get_trace_half_width(i) != p_trace_half_width_arr[i]) - { + for (int i = 0; i < curr_class.layer_count(); ++i) { + if (curr_class.get_trace_half_width(i) != p_trace_half_width_arr[i]) { trace_widths_equal = false; break; } } - if (trace_widths_equal) - { + if (trace_widths_equal) { return curr_class; } } } return null; } - + /** * Removes p_net_class from this list. * Returns false, if p_net_class was not contained in the list. */ - public boolean remove(NetClass p_net_class) - { + public boolean remove(NetClass p_net_class) { return this.class_arr.remove(p_net_class); } - - private final java.util.Vector class_arr = new java.util.Vector(); } diff --git a/src/main/java/net/freerouting/rules/Nets.java b/src/main/java/net/freerouting/rules/Nets.java index 2de62295..f02ff4b6 100644 --- a/src/main/java/net/freerouting/rules/Nets.java +++ b/src/main/java/net/freerouting/rules/Nets.java @@ -19,40 +19,59 @@ */ package net.freerouting.rules; -import java.util.Vector; import java.util.Collection; +import java.util.Vector; /** * Describes the electrical Nets on a board. * - * @author alfons + * @author alfons */ -public class Nets implements java.io.Serializable -{ +public class Nets implements java.io.Serializable { + + /** + * The maximum legal net number for nets. + */ + public static final int max_legal_net_no = 9999999; + /** + * auxiliary net number for internal use + */ + public static final int hidden_net_no = 10000001; + /** + * The list of electrical nets on the board + */ + private Vector net_arr; + private net.freerouting.board.BasicBoard board; - /** Creates a new empty net list */ - public Nets() - { + /** + * Creates a new empty net list + */ + public Nets() { net_arr = new Vector(); } + /** + * Returns false, if p_net_no belongs to a net internally used + * for special purposes. + */ + public static boolean is_normal_net_no(int p_net_no) { + return (p_net_no > 0 && p_net_no <= max_legal_net_no); + } + /** * Returns the biggest net number on the board. */ - public int max_net_no() - { + public int max_net_no() { return net_arr.size(); } - /** Returns the net with the input name and subnet_number , or null, if no such net exists. */ - public Net get(String p_name, int p_subnet_number) - { - for (Net curr_net : net_arr) - { - if (curr_net != null && curr_net.name.compareToIgnoreCase(p_name) == 0) - { - if (curr_net.subnet_number == p_subnet_number) - { + /** + * Returns the net with the input name and subnet_number , or null, if no such net exists. + */ + public Net get(String p_name, int p_subnet_number) { + for (Net curr_net : net_arr) { + if (curr_net != null && curr_net.name.compareToIgnoreCase(p_name) == 0) { + if (curr_net.subnet_number == p_subnet_number) { return curr_net; } } @@ -61,15 +80,12 @@ public Net get(String p_name, int p_subnet_number) } /** - * Returns all subnets with the input name. + * Returns all subnets with the input name. */ - public Collection get(String p_name) - { + public Collection get(String p_name) { Collection result = new java.util.LinkedList(); - for (Net curr_net : net_arr) - { - if (curr_net != null && curr_net.name.compareToIgnoreCase(p_name) == 0) - { + for (Net curr_net : net_arr) { + if (curr_net != null && curr_net.name.compareToIgnoreCase(p_name) == 0) { result.add(curr_net); } } @@ -79,15 +95,12 @@ public Collection get(String p_name) /** * Returns the net with the input net number or null, if no such net exists. */ - public Net get(int p_net_no) - { - if (p_net_no < 1 || p_net_no > net_arr.size()) - { + public Net get(int p_net_no) { + if (p_net_no < 1 || p_net_no > net_arr.size()) { return null; } Net result = net_arr.elementAt(p_net_no - 1); - if (result != null && result.net_number != p_net_no) - { + if (result != null && result.net_number != p_net_no) { System.out.println("Nets.get: inconsistent net_no"); } return result; @@ -96,8 +109,7 @@ public Net get(int p_net_no) /** * Generates a new net number. */ - public Net new_net(java.util.Locale p_locale) - { + public Net new_net(java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.rules.Default", p_locale); String net_name = resources.getString("net#") + (new Integer(net_arr.size() + 1)).toString(); return add(net_name, 1, false); @@ -108,11 +120,9 @@ public Net new_net(java.util.Locale p_locale) * p_subnet_number is used only if a net is divided internally because of fromto rules for example. * For normal nets it is always 1. */ - public Net add(String p_name, int p_subnet_number, boolean p_contains_plane) - { + public Net add(String p_name, int p_subnet_number, boolean p_contains_plane) { int new_net_no = net_arr.size() + 1; - if (new_net_no >= max_legal_net_no) - { + if (new_net_no >= max_legal_net_no) { System.out.println("Nets.add_net: max_net_no out of range"); } Net new_net = new Net(p_name, p_subnet_number, new_net_no, this, p_contains_plane); @@ -121,39 +131,18 @@ public Net add(String p_name, int p_subnet_number, boolean p_contains_plane) } /** - * Returns false, if p_net_no belongs to a net internally used - * for special purposes. + * Gets the Board of this net list. + * Used for example to get access to the Items of the net. */ - public static boolean is_normal_net_no(int p_net_no) - { - return (p_net_no > 0 && p_net_no <= max_legal_net_no); + public net.freerouting.board.BasicBoard get_board() { + return this.board; } /** * Sets the Board of this net list. * Used for example to get access to the Items of the net. */ - public void set_board(net.freerouting.board.BasicBoard p_board) - { + public void set_board(net.freerouting.board.BasicBoard p_board) { this.board = p_board; } - - /** - * Gets the Board of this net list. - * Used for example to get access to the Items of the net. - */ - public net.freerouting.board.BasicBoard get_board() - { - return this.board; - } - - - - /** The maximum legal net number for nets. */ - public static final int max_legal_net_no = 9999999; - /** auxiliary net number for internal use */ - public static final int hidden_net_no = 10000001; - /** The list of electrical nets on the board */ - private Vector net_arr; - private net.freerouting.board.BasicBoard board; } diff --git a/src/main/java/net/freerouting/rules/ViaInfo.java b/src/main/java/net/freerouting/rules/ViaInfo.java index 01324d5d..6abded41 100644 --- a/src/main/java/net/freerouting/rules/ViaInfo.java +++ b/src/main/java/net/freerouting/rules/ViaInfo.java @@ -19,6 +19,7 @@ */ package net.freerouting.rules; + import net.freerouting.library.Padstack; /** @@ -27,73 +28,68 @@ * * @author Alfons Wirtz */ -public class ViaInfo implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable -{ - - /** Creates a new instance of ViaRule */ +public class ViaInfo implements Comparable, net.freerouting.board.ObjectInfoPanel.Printable, java.io.Serializable { + + private final BoardRules board_rules; + private String name; + private Padstack padstack; + private int clearance_class; + private boolean attach_smd_allowed; + + /** + * Creates a new instance of ViaRule + */ public ViaInfo(String p_name, Padstack p_padstack, int p_clearance_class, boolean p_drill_to_smd_allowed, - BoardRules p_board_rules) - { + BoardRules p_board_rules) { name = p_name; padstack = p_padstack; clearance_class = p_clearance_class; attach_smd_allowed = p_drill_to_smd_allowed; board_rules = p_board_rules; } - - public String get_name() - { + + public String get_name() { return name; } - - public void set_name(String p_name) - { + + public void set_name(String p_name) { name = p_name; } - - public String toString() - { + + public String toString() { return this.name; } - - public Padstack get_padstack() - { + + public Padstack get_padstack() { return padstack; } - - public void set_padstack(Padstack p_padstack) - { + + public void set_padstack(Padstack p_padstack) { padstack = p_padstack; } - - public int get_clearance_class() - { + + public int get_clearance_class() { return clearance_class; } - - public void set_clearance_class(int p_clearance_class) - { + + public void set_clearance_class(int p_clearance_class) { clearance_class = p_clearance_class; } - - public boolean attach_smd_allowed() - { + + public boolean attach_smd_allowed() { return attach_smd_allowed; } - - public void set_attach_smd_allowed(boolean p_attach_smd_allowed) - { + + public void set_attach_smd_allowed(boolean p_attach_smd_allowed) { attach_smd_allowed = p_attach_smd_allowed; } - - public int compareTo(ViaInfo p_other) - { + + public int compareTo(ViaInfo p_other) { return this.name.compareTo(p_other.name); } - - public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("via") + " "); p_window.append_bold(this.name); @@ -104,20 +100,11 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util String curr_name = board_rules.clearance_matrix.get_name(this.clearance_class); p_window.append(curr_name, resources.getString("clearance_class_2"), board_rules.clearance_matrix.get_row(this.clearance_class)); p_window.append(", " + resources.getString("attach_smd") + " "); - if (attach_smd_allowed) - { + if (attach_smd_allowed) { p_window.append(" " + resources.getString("on")); - } - else - { - p_window.append(" " + resources.getString("off") ); + } else { + p_window.append(" " + resources.getString("off")); } p_window.newline(); } - - private String name; - private Padstack padstack; - private int clearance_class; - private boolean attach_smd_allowed; - private final BoardRules board_rules; } diff --git a/src/main/java/net/freerouting/rules/ViaInfos.java b/src/main/java/net/freerouting/rules/ViaInfos.java index ded1c67b..e617c826 100644 --- a/src/main/java/net/freerouting/rules/ViaInfos.java +++ b/src/main/java/net/freerouting/rules/ViaInfos.java @@ -20,106 +20,90 @@ package net.freerouting.rules; -import java.util.List; import java.util.LinkedList; +import java.util.List; /** * Contains the lists of different ViaInfo's, which can be used in interactive and automatic routing. * * @author Alfons Wirtz */ -public class ViaInfos implements java.io.Serializable, net.freerouting.board.ObjectInfoPanel.Printable -{ +public class ViaInfos implements java.io.Serializable, net.freerouting.board.ObjectInfoPanel.Printable { + private List list = new LinkedList(); + /** * Adds a via info consisting of padstack, clearance class and drill_to_smd_allowed. * Return false, if the insertion failed, for example if the name existed already. */ - public boolean add(ViaInfo p_via_info) - { - if (name_exists(p_via_info.get_name())) - { + public boolean add(ViaInfo p_via_info) { + if (name_exists(p_via_info.get_name())) { return false; } this.list.add(p_via_info); return true; } - + /** * Returns the number of different vias, which can be used for routing. */ - public int count() - { + public int count() { return this.list.size(); } - + /** * Returns the p_no-th via af the via types, which can be used for routing. */ - public ViaInfo get(int p_no) - { + public ViaInfo get(int p_no) { assert p_no >= 0 && p_no < this.list.size(); return this.list.get(p_no); } - + /** * Returns the via info with name p_name, or null, if no such via exists. */ - public ViaInfo get(String p_name) - { - for (ViaInfo curr_via : this.list) - { - if (curr_via.get_name().equals(p_name)) - { + public ViaInfo get(String p_name) { + for (ViaInfo curr_via : this.list) { + if (curr_via.get_name().equals(p_name)) { return curr_via; } } return null; } - + /** * Returns true, if a via info with name p_name is already wyisting in the list. */ - public boolean name_exists(String p_name) - { - for (ViaInfo curr_via : this.list) - { - if (curr_via.get_name().equals(p_name)) - { + public boolean name_exists(String p_name) { + for (ViaInfo curr_via : this.list) { + if (curr_via.get_name().equals(p_name)) { return true; } } return false; } - + /** * Removes p_via_info from this list. * Returns false, if p_via_info was not contained in the list. */ - public boolean remove(ViaInfo p_via_info) - { + public boolean remove(ViaInfo p_via_info) { return this.list.remove(p_via_info); } - - public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) - { - java.util.ResourceBundle resources = + + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { + java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("vias") + ": "); int counter = 0; boolean first_time = true; final int max_vias_per_row = 5; - for (ViaInfo curr_via : this.list) - { - if (first_time) - { + for (ViaInfo curr_via : this.list) { + if (first_time) { first_time = false; - } - else - { + } else { p_window.append(", "); } - if (counter == 0) - { + if (counter == 0) { p_window.newline(); p_window.indent(); } @@ -127,5 +111,4 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util counter = (counter + 1) % max_vias_per_row; } } - private List list = new LinkedList(); } diff --git a/src/main/java/net/freerouting/rules/ViaRule.java b/src/main/java/net/freerouting/rules/ViaRule.java index 2cca28c8..fc4e7ad4 100644 --- a/src/main/java/net/freerouting/rules/ViaRule.java +++ b/src/main/java/net/freerouting/rules/ViaRule.java @@ -20,8 +20,8 @@ package net.freerouting.rules; -import java.util.List; import java.util.LinkedList; +import java.util.List; /** * Contains an array of vias used for routing. @@ -29,116 +29,100 @@ * * @author Alfons Wirtz */ -public class ViaRule implements java.io.Serializable, net.freerouting.board.ObjectInfoPanel.Printable -{ - - /** Empty via rule. Must nott be changed. */ +public class ViaRule implements java.io.Serializable, net.freerouting.board.ObjectInfoPanel.Printable { + + /** + * Empty via rule. Must nott be changed. + */ public static final ViaRule EMPTY = new ViaRule("empty"); - - public ViaRule (String p_name) - { + public final String name; + private List list = new LinkedList(); + + public ViaRule(String p_name) { name = p_name; } - - public void append_via(ViaInfo p_via) - { + + public void append_via(ViaInfo p_via) { list.add(p_via); } - + /** * Removes p_via from the rule. * Returns false, if p_via was not contained in the rule. */ - public boolean remove_via(ViaInfo p_via) - { + public boolean remove_via(ViaInfo p_via) { return list.remove(p_via); } - - public int via_count() - { + + public int via_count() { return list.size(); } - - public ViaInfo get_via(int p_index) - { - assert p_index >= 0 && p_index < list.size(); + + public ViaInfo get_via(int p_index) { + assert p_index >= 0 && p_index < list.size(); return list.get(p_index); } - - public String toString() - { + + public String toString() { return this.name; } - + /** * Returns true, if p_via_info is contained in the via list of this rule. */ - public boolean contains(ViaInfo p_via_info) - { - for (ViaInfo curr_info : this.list) - { - if (p_via_info == curr_info) - { + public boolean contains(ViaInfo p_via_info) { + for (ViaInfo curr_info : this.list) { + if (p_via_info == curr_info) { return true; } } return false; } - + /** * Returns true, if this rule contains a via with padstack p_padstack */ - public boolean contains_padstack(net.freerouting.library.Padstack p_padstack) - { - for (ViaInfo curr_info : this.list) - { - if (curr_info.get_padstack() == p_padstack) - { + public boolean contains_padstack(net.freerouting.library.Padstack p_padstack) { + for (ViaInfo curr_info : this.list) { + if (curr_info.get_padstack() == p_padstack) { return true; } } return false; } - + /** * Searchs a via in this rule with first layer = p_from_layer and last layer = p_to_layer. * Returns null, if no such via exists. */ - public ViaInfo get_layer_range(int p_from_layer, int p_to_layer) - { - for (ViaInfo curr_info : this.list) - { - if (curr_info.get_padstack().from_layer() == p_from_layer && curr_info.get_padstack().to_layer() == p_to_layer) - { + public ViaInfo get_layer_range(int p_from_layer, int p_to_layer) { + for (ViaInfo curr_info : this.list) { + if (curr_info.get_padstack().from_layer() == p_from_layer && curr_info.get_padstack().to_layer() == p_to_layer) { return curr_info; } } return null; } - + /** * Swaps the locations of p_1 and p_2 in the rule. * Returns false, if p_1 or p_2 were not found in the list. */ - public boolean swap(ViaInfo p_1, ViaInfo p_2) - { + public boolean swap(ViaInfo p_1, ViaInfo p_2) { int index_1 = this.list.indexOf(p_1); int index_2 = this.list.indexOf(p_2); - if (index_1 < 0 || index_2 < 0) - { + if (index_1 < 0 || index_2 < 0) { return false; } - if (index_1 == index_2) - { + if (index_1 == index_2) { return true; } this.list.set(index_1, p_2); this.list.set(index_2, p_1); return true; } - - public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) - { + + public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util.Locale p_locale) { java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("net.freerouting.board.ObjectInfoPanel", p_locale); p_window.append_bold(resources.getString("via_rule_2") + " "); @@ -147,18 +131,13 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util int counter = 0; boolean first_time = true; final int max_vias_per_row = 5; - for (ViaInfo curr_via : this.list) - { - if (first_time) - { + for (ViaInfo curr_via : this.list) { + if (first_time) { first_time = false; - } - else - { + } else { p_window.append(", "); } - if (counter == 0) - { + if (counter == 0) { p_window.newline(); p_window.indent(); } @@ -166,7 +145,4 @@ public void print_info(net.freerouting.board.ObjectInfoPanel p_window, java.util counter = (counter + 1) % max_vias_per_row; } } - - public final String name; - private List list = new LinkedList(); } diff --git a/src/main/java/net/freerouting/rules/package.html b/src/main/java/net/freerouting/rules/package.html index 9ecf25dd..ab9800af 100644 --- a/src/main/java/net/freerouting/rules/package.html +++ b/src/main/java/net/freerouting/rules/package.html @@ -1,5 +1,6 @@ -java.text package -Contains rules and restrictions for the items on a printed circuit board. \ No newline at end of file +Contains rules and restrictions for the items on a printed circuit board. + \ No newline at end of file diff --git a/src/main/java/net/freerouting/tests/Validate.java b/src/main/java/net/freerouting/tests/Validate.java index 808c1c9b..304a4eed 100644 --- a/src/main/java/net/freerouting/tests/Validate.java +++ b/src/main/java/net/freerouting/tests/Validate.java @@ -20,6 +20,10 @@ package net.freerouting.tests; +import net.freerouting.board.BasicBoard; +import net.freerouting.board.Item; +import net.freerouting.board.PolylineTrace; +import net.freerouting.board.SearchTreeObject; import net.freerouting.geometry.planar.IntOctagon; import net.freerouting.geometry.planar.IntPoint; import net.freerouting.geometry.planar.Polyline; @@ -28,100 +32,82 @@ import java.util.Collection; import java.util.Iterator; -import net.freerouting.board.Item; -import net.freerouting.board.BasicBoard; -import net.freerouting.board.PolylineTrace; -import net.freerouting.board.SearchTreeObject; - /** * Some consistancy checking on a routing board. * - * @author Alfons Wirtz + * @author Alfons Wirtz */ -public class Validate -{ +public class Validate { + static private int[] last_violation_count = null; + static private boolean first_time = true; + static private int prev_stub_count = 0; + /** * Does some consistancy checking on the routing board and may be some * other actions. * Returns false, if problems were detected. */ - public static boolean check(String p_s, BasicBoard p_board) - { - if (p_board.get_test_level() == net.freerouting.board.TestLevel.RELEASE_VERSION) - { + public static boolean check(String p_s, BasicBoard p_board) { + if (p_board.get_test_level() == net.freerouting.board.TestLevel.RELEASE_VERSION) { return true; } boolean result = true; - + IntOctagon surr_oct = p_board.bounding_box.to_IntOctagon(); int layer_count = p_board.get_layer_count(); - if (last_violation_count == null) - { - last_violation_count = new int [layer_count]; + if (last_violation_count == null) { + last_violation_count = new int[layer_count]; } - for (int layer = 0; layer < layer_count; ++layer) - { - if (first_time) - { + for (int layer = 0; layer < layer_count; ++layer) { + if (first_time) { System.out.println(" validate board is on "); first_time = false; } - Collection l = p_board.overlapping_objects(surr_oct, layer) ; + Collection l = p_board.overlapping_objects(surr_oct, layer); Iterator i = l.iterator(); int clearance_violation_count = 0; int conflict_ob_count = 0; int trace_count = 0; - while(i.hasNext()) - { + while (i.hasNext()) { Item curr_ob = (Item) i.next(); - if (!curr_ob.validate()) - { - System.out.println(p_s) ; + if (!curr_ob.validate()) { + System.out.println(p_s); } int cl_count = curr_ob.clearance_violation_count(); - if (cl_count > 0) - { + if (cl_count > 0) { ++conflict_ob_count; clearance_violation_count += cl_count; } - if (curr_ob instanceof PolylineTrace) - { - ++ trace_count; + if (curr_ob instanceof PolylineTrace) { + ++trace_count; } } - if (conflict_ob_count == 1) - { + if (conflict_ob_count == 1) { System.out.println("conflicts not symmetric"); } - if (clearance_violation_count != last_violation_count[layer]) - { + if (clearance_violation_count != last_violation_count[layer]) { result = false; System.out.print(clearance_violation_count); - System.out.print(" clearance violations on layer ") ; + System.out.print(" clearance violations on layer "); System.out.print(layer); - System.out.print(" ") ; + System.out.print(" "); System.out.println(p_s); - if (clearance_violation_count > 0) - { - System.out.print("with items of nets: ") ; + if (clearance_violation_count > 0) { + System.out.print("with items of nets: "); } i = l.iterator(); - while(i.hasNext()) - { + while (i.hasNext()) { Item curr_ob = (Item) i.next(); int cl_count = curr_ob.clearance_violation_count(); - if (cl_count == 0) - { + if (cl_count == 0) { continue; } - + int curr_net_no = 0; - if (curr_ob instanceof PolylineTrace) - { + if (curr_ob instanceof PolylineTrace) { PolylineTrace curr_trace = (PolylineTrace) curr_ob; - if (curr_trace.net_count() > 0) - { + if (curr_trace.net_count() > 0) { curr_net_no = curr_trace.get_net_no(0); } } @@ -130,31 +116,26 @@ public static boolean check(String p_s, BasicBoard p_board) } System.out.println(); } - if (clearance_violation_count != last_violation_count[layer]) - { + if (clearance_violation_count != last_violation_count[layer]) { last_violation_count[layer] = clearance_violation_count; } - + } return result; } - + static public boolean check(String p_s, BasicBoard p_board, Polyline p_polyline, - int p_layer, int p_half_width, int[] p_net_no_arr, int p_cl_type) - { - TileShape[] offset_shapes = p_polyline.offset_shapes(p_half_width, - 0, p_polyline.arr.length -1); - for (int i = 0; i < offset_shapes.length; ++i) - { + int p_layer, int p_half_width, int[] p_net_no_arr, int p_cl_type) { + TileShape[] offset_shapes = p_polyline.offset_shapes(p_half_width, + 0, p_polyline.arr.length - 1); + for (int i = 0; i < offset_shapes.length; ++i) { Collection obstacles = p_board.search_tree_manager.get_default_tree().overlapping_items_with_clearance(offset_shapes[i], - p_layer, p_net_no_arr, p_cl_type); + p_layer, p_net_no_arr, p_cl_type); Iterator it = obstacles.iterator(); - while(it.hasNext()) - { + while (it.hasNext()) { Item curr_obs = it.next(); - if (!curr_obs.shares_net_no(p_net_no_arr)) - { + if (!curr_obs.shares_net_no(p_net_no_arr)) { System.out.print(p_s); System.out.println(": cannot insert trace without violations"); return false; @@ -163,21 +144,17 @@ static public boolean check(String p_s, BasicBoard p_board, Polyline p_polyline, } return true; } - + /** * check, that all traces on p_board are orthogonal */ - static public void orthogonal(String p_s, BasicBoard p_board) - { + static public void orthogonal(String p_s, BasicBoard p_board) { Iterator it = p_board.get_items().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if(curr_ob instanceof PolylineTrace) - { + if (curr_ob instanceof PolylineTrace) { PolylineTrace curr_trace = (PolylineTrace) curr_ob; - if (!curr_trace.polyline().is_orthogonal()) - { + if (!curr_trace.polyline().is_orthogonal()) { System.out.print(p_s); System.out.println(": trace not orthogonal"); break; @@ -185,40 +162,32 @@ static public void orthogonal(String p_s, BasicBoard p_board) } } } - + /** * check, that all traces on p_board are multiples of 45 degree */ - static public void multiple_of_45_degree(String p_s, BasicBoard p_board) - { + static public void multiple_of_45_degree(String p_s, BasicBoard p_board) { int count = 0; Iterator it = p_board.get_items().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if(curr_ob instanceof PolylineTrace) - { + if (curr_ob instanceof PolylineTrace) { PolylineTrace curr_trace = (PolylineTrace) curr_ob; - if (!curr_trace.polyline().is_multiple_of_45_degree()) - { + if (!curr_trace.polyline().is_multiple_of_45_degree()) { ++count; } } } - if (count > 1) - { + if (count > 1) { System.out.print(p_s); System.out.print(count); System.out.println(" traces not 45 degree"); } } - - static public boolean corners_on_grid(String p_s, Polyline p_polyline) - { - for (int i = 0; i < p_polyline.corner_count(); ++i) - { - if (!(p_polyline.corner(i) instanceof IntPoint)) - { + + static public boolean corners_on_grid(String p_s, Polyline p_polyline) { + for (int i = 0; i < p_polyline.corner_count(); ++i) { + if (!(p_polyline.corner(i) instanceof IntPoint)) { System.out.print(p_s); System.out.println(": corner not on grid"); return false; @@ -226,57 +195,45 @@ static public boolean corners_on_grid(String p_s, Polyline p_polyline) } return true; } - - static public int stub_count(String p_s, BasicBoard p_board, int p_net_no) - { - if (first_time) - { + + static public int stub_count(String p_s, BasicBoard p_board, int p_net_no) { + if (first_time) { System.out.println(" stub_count is on "); first_time = false; } int result = 0; Iterator it = p_board.get_items().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if(curr_ob instanceof PolylineTrace) - { + if (curr_ob instanceof PolylineTrace) { PolylineTrace curr_trace = (PolylineTrace) curr_ob; - if(curr_trace.contains_net(p_net_no)) - { - if (curr_trace.get_start_contacts().size() == 0) - { + if (curr_trace.contains_net(p_net_no)) { + if (curr_trace.get_start_contacts().size() == 0) { ++result; } - if (curr_trace.get_end_contacts().size() == 0) - { + if (curr_trace.get_end_contacts().size() == 0) { ++result; } } } } - if (result != prev_stub_count) - { + if (result != prev_stub_count) { System.out.print(result + " stubs "); System.out.println(p_s); prev_stub_count = result; } return result; } - - static public boolean has_cycles(String p_s, BasicBoard p_board) - { + + static public boolean has_cycles(String p_s, BasicBoard p_board) { boolean result = false; Iterator it = p_board.get_items().iterator(); - while (it.hasNext()) - { - Item curr_item = it.next(); - if (!(curr_item instanceof net.freerouting.board.Trace)) - { + while (it.hasNext()) { + Item curr_item = it.next(); + if (!(curr_item instanceof net.freerouting.board.Trace)) { continue; } - if(((net.freerouting.board.Trace)curr_item).is_cycle()) - { + if (((net.freerouting.board.Trace) curr_item).is_cycle()) { System.out.print(p_s); System.out.println(": cycle found"); result = true; @@ -285,26 +242,23 @@ static public boolean has_cycles(String p_s, BasicBoard p_board) } return result; } - /** checks, if there are more than p_max_count traces with + + /** + * checks, if there are more than p_max_count traces with * net number p_net_no */ - static public boolean trace_count_exceeded(String p_s, BasicBoard p_board, int p_net_no, int p_max_count) - { + static public boolean trace_count_exceeded(String p_s, BasicBoard p_board, int p_net_no, int p_max_count) { int found_traces = 0; Iterator it = p_board.get_items().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_ob = it.next(); - if(curr_ob instanceof net.freerouting.board.Trace) - { - if (((net.freerouting.board.Trace)curr_ob).contains_net(p_net_no)) - { + if (curr_ob instanceof net.freerouting.board.Trace) { + if (((net.freerouting.board.Trace) curr_ob).contains_net(p_net_no)) { ++found_traces; } } } - if ( found_traces > p_max_count) - { + if (found_traces > p_max_count) { System.out.print(p_s); System.out.print(": "); System.out.print(p_max_count); @@ -313,21 +267,17 @@ static public boolean trace_count_exceeded(String p_s, BasicBoard p_board, int p } return false; } - + /** * checks, if there are unconnectedtraces ore vias on the board */ - static public boolean unconnnected_routing_items(String p_s, BasicBoard p_board) - { + static public boolean unconnnected_routing_items(String p_s, BasicBoard p_board) { Iterator it = p_board.get_items().iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Item curr_item = it.next(); - if(curr_item.is_route()) - { + if (curr_item.is_route()) { Collection contact_list = curr_item.get_normal_contacts(); - if (contact_list.size() == 0) - { + if (contact_list.size() == 0) { System.out.print(p_s); System.out.print(": uncontacted routing item found "); return true; @@ -336,8 +286,4 @@ static public boolean unconnnected_routing_items(String p_s, BasicBoard p_board) } return false; } - - static private int [] last_violation_count = null; - static private boolean first_time = true; - static private int prev_stub_count = 0; } diff --git a/src/main/java/net/freerouting/tests/package.html b/src/main/java/net/freerouting/tests/package.html index a54dc130..5f782905 100644 --- a/src/main/java/net/freerouting/tests/package.html +++ b/src/main/java/net/freerouting/tests/package.html @@ -1,5 +1,6 @@ -java.text package -Contains functions for testing and checking the consistancy of the board database. \ No newline at end of file +Contains functions for testing and checking the consistancy of the board database. + \ No newline at end of file From 472fdfecdc2d78a3a6e2fdd08e4032bf43793991 Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Mon, 21 Sep 2015 22:05:54 +0300 Subject: [PATCH 11/14] Small refactoring Inlined some variables --- .../net/freerouting/gui/BoardMenuBar.java | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/freerouting/gui/BoardMenuBar.java b/src/main/java/net/freerouting/gui/BoardMenuBar.java index b13bc2be..a1a4a62a 100644 --- a/src/main/java/net/freerouting/gui/BoardMenuBar.java +++ b/src/main/java/net/freerouting/gui/BoardMenuBar.java @@ -37,23 +37,12 @@ static BoardMenuBar get_instance(BoardFrame p_board_frame, BoardMenuBar menubar = new BoardMenuBar(); menubar.file_menu = BoardMenuFile.get_instance(p_board_frame, p_session_file_option); menubar.add(menubar.file_menu); - javax.swing.JMenu display_menu = BoardMenuDisplay.get_instance(p_board_frame); - menubar.add(display_menu); - javax.swing.JMenu parameter_menu = BoardMenuParameter.get_instance(p_board_frame); - menubar.add(parameter_menu); - javax.swing.JMenu rules_menu = BoardMenuRules.get_instance(p_board_frame); - menubar.add(rules_menu); - javax.swing.JMenu info_menu = BoardMenuInfo.get_instance(p_board_frame); - menubar.add(info_menu); - javax.swing.JMenu other_menu = BoardMenuOther.get_instance(p_board_frame); - menubar.add(other_menu); - if (p_help_system_used) { - javax.swing.JMenu help_menu = new BoardMenuHelp(p_board_frame); - menubar.add(help_menu); - } else { - javax.swing.JMenu help_menu = new BoardMenuHelpReduced(p_board_frame); - menubar.add(help_menu); - } + menubar.add(BoardMenuDisplay.get_instance(p_board_frame)); + menubar.add(BoardMenuParameter.get_instance(p_board_frame)); + menubar.add(BoardMenuRules.get_instance(p_board_frame)); + menubar.add(BoardMenuInfo.get_instance(p_board_frame)); + menubar.add(BoardMenuOther.get_instance(p_board_frame)); + menubar.add(p_help_system_used ? new BoardMenuHelp(p_board_frame) : new BoardMenuHelpReduced(p_board_frame)); return menubar; } From 9369477e50403da61bb004b13f7aebdc64275c98 Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Mon, 21 Sep 2015 22:06:19 +0300 Subject: [PATCH 12/14] Enabled checkstyle for maven project with default settings. --- pom.xml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pom.xml b/pom.xml index 1c5eac93..76079104 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,27 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.16 + + + validate + validate + + + UTF-8 + true + false + false + + + check + + + + From 0ba5f19add927f87f67fcfeb0c15a171a0a3ccaa Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Tue, 22 Sep 2015 21:01:51 +0300 Subject: [PATCH 13/14] Show stacktrace --- src/main/java/net/freerouting/autoroute/AutorouteEngine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/freerouting/autoroute/AutorouteEngine.java b/src/main/java/net/freerouting/autoroute/AutorouteEngine.java index adef2f14..b2417c39 100644 --- a/src/main/java/net/freerouting/autoroute/AutorouteEngine.java +++ b/src/main/java/net/freerouting/autoroute/AutorouteEngine.java @@ -398,7 +398,7 @@ public Collection complete_expansion_room(Incomp return result; } catch (Exception e) { System.out.print("AutorouteEngine.complete_expansion_room: "); - System.out.println(e); + e.printStackTrace(); return new LinkedList(); } From c447463244c18cb1bb4d090e4998afd0e4998350 Mon Sep 17 00:00:00 2001 From: Dmitry Olyenyov Date: Tue, 22 Sep 2015 21:15:16 +0300 Subject: [PATCH 14/14] Updated README.md. Added list of options --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ad690350..d84877ce 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,9 @@ Here are some instructions how to run the Freerouting project in the NetBeans ID 4) Add your downloaded Freerouting source code with Add Source Package. -5) Build your new project in NetBeans. +5) Build your new project in NetBeans. -6) To get rid of the undefined's download and unzip the attached library jh.jar. It is the system library of the Java Help system. +6) To get rid of the undefined's download and unzip the attached library jh.jar. It is the system library of the Java Help system. 7) Right click on the name of your new project on the left of NetBeans and select Properties. @@ -93,3 +93,10 @@ $ gradle build $ java -jar build/libs/FreeRouting.jar ``` +List of options: + +* -de — open design file +* -di — open directory +* -l de — set locale to German. Other values are currently ignored +* -s — Disable "Save/Save As/Generate Logfile/Replay Logfile" menu items from "File" menu. +* -test — Enable test version. Debug messages, no confirm on exit