Page:
CONTRIBUTING
Clone
1
CONTRIBUTING
Thibaud edited this page 2026-03-27 15:43:53 +01:00
Contributing Guide
Prerequisites
- Java 16 or later (uses switch expressions, records, etc.)
- Maven 3.6+
Building
mvn compile
Running
mvn exec:java -Dexec.mainClass=ovh.gasser.newshapes.App
Or run ovh.gasser.newshapes.App.main() from your IDE.
Testing
mvn test
Uses JUnit 5 (Jupiter). Tests are in src/test/java/ovh/gasser/newshapes/.
Current test coverage:
- Shape classes:
AbstractShapeTest,SRectangleTest,SCircleTest,STriangleTest,STextTest - Exporters:
SVGExporterTest,HTMLExporterTest - See
TESTING_HANDOFF.mdat the project root for detailed coverage analysis and recommendations.
Project Structure
src/
├── main/java/ovh/gasser/newshapes/ — Application source
│ ├── shapes/ — Shape hierarchy
│ ├── attributes/ — Attribute types
│ ├── ui/ — Swing UI (view, controller, listeners)
│ │ ├── listeners/ — Menu and selection listeners
│ │ └── visitors/ — HTML/SVG visitor implementations
│ └── util/ — Utility interfaces
└── test/java/ovh/gasser/newshapes/ — JUnit 5 tests
├── shapes/ — Shape unit tests
└── exporters/ — Exporter integration tests
Adding a New Shape
- Create a class extending
AbstractShapeinovh.gasser.newshapes.shapes. - Implement
accept(ShapeVisitor visitor)— callvisitor.visitYourShape(this). - Implement
clone()— return a deep copy. - Provide a static
create()factory method. - Optionally override
resize()if the shape needs custom resize behavior (e.g.,SCirclemaintains radius). - Add a
visitYourShape()method to theShapeVisitorinterface. - Implement the new visit method in all three visitors:
ShapeDraftman,HTMLDraftman,SVGDraftman. - Add a menu item in
App.buildFileMenu()with aMenuAddListener. - Write tests.
Adding a New Attribute
- Create a class implementing
Attributesinovh.gasser.newshapes.attributes. - Define a
public static final String IDconstant. - Implement
getID()returning the ID. - Use
shape.addAttributes(new YourAttribute(...))to attach, andshape.getAttributes(YourAttribute.ID)to retrieve.
Adding a New Exporter
- Create a visitor class implementing
ShapeVisitorinovh.gasser.newshapes.ui.visitors. - Implement all visit methods to generate the target format.
- Create an exporter class (like
HTMLExporter/SVGExporter) that uses the visitor and writes to a file. - Wire it up in
App.buildFileMenu().
Conventions
- Static factory methods (
create()) over public constructors. getBounds()always returns a defensive copy.- Shapes are cloneable via the
clone()method. - Attributes are keyed by string IDs and stored in a
TreeMap. - Logging via SLF4J (
LoggerFactory.getLogger(YourClass.class)).