46 lines
1.4 KiB
Java
46 lines
1.4 KiB
Java
package ovh.gasser.newshapes;
|
|
|
|
import ovh.gasser.newshapes.shapes.SCircle;
|
|
import ovh.gasser.newshapes.shapes.SCollection;
|
|
import ovh.gasser.newshapes.shapes.SRectangle;
|
|
import ovh.gasser.newshapes.shapes.Shape;
|
|
import ovh.gasser.newshapes.ui.ShapesView;
|
|
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
|
|
public class App {
|
|
|
|
public static final Dimension WIN_SIZE = new Dimension(800, 600);
|
|
private Shape model;
|
|
|
|
private App() throws HeadlessException {
|
|
final JFrame frame = new JFrame("Reactive shapes");
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
buildModel();
|
|
final ShapesView view = new ShapesView(this.model);
|
|
view.setPreferredSize(WIN_SIZE);
|
|
frame.getContentPane().add(view, BorderLayout.CENTER);
|
|
frame.setContentPane(view);
|
|
frame.pack();
|
|
frame.setVisible(true);
|
|
}
|
|
|
|
private void buildModel() {
|
|
model = SCollection.of(
|
|
SRectangle.create(10, 10, 40, 60, Color.RED),
|
|
SRectangle.create(70, 10, 40, 60),
|
|
SCollection.of(
|
|
SRectangle.create(100, 200, 40, 60, Color.MAGENTA),
|
|
SRectangle.create(150, 200, 40, 60, Color.MAGENTA),
|
|
SCircle.create(200, 200, 60)
|
|
)
|
|
);
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
SwingUtilities.invokeLater(App::new);
|
|
}
|
|
|
|
}
|