Skip to content

Commit

Permalink
meh
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Leiser authored and Kevin Leiser committed Jun 21, 2018
1 parent 11dd6e6 commit 2b0793e
Show file tree
Hide file tree
Showing 28 changed files with 319 additions and 326 deletions.
448 changes: 191 additions & 257 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified out/production/HW6/cs3500/animator/view/IView$ViewType.class
Binary file not shown.
Binary file modified out/production/HW6/cs3500/animator/view/InteractiveViewGUI.class
Binary file not shown.
Binary file modified out/production/HW6/cs3500/animator/view/ViewGUI.class
Binary file not shown.
Binary file modified out/production/HW6/cs3500/animator/view/ViewSVG.class
Binary file not shown.
Binary file modified out/production/HW6/cs3500/animator/view/ViewText.class
Binary file not shown.
11 changes: 10 additions & 1 deletion out/production/HW6/hw7 README
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
The following changes were made to our code from the previous assignment:
- Added functions of all views to IView and make unsupported functions throw
UnsupportedOperationException's.
UnsupportedOperationException's.
- Changed model to store shapes in LinkedHashMap rather than HashMap since draw order
wasn't conserved in HashMap.


The following classes were added:
-IGuiBasedView
-InteractiveViewGUI
-HybridController
-InteractiveController
2 changes: 2 additions & 0 deletions src/cs3500/animator/controller/ControllerGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import java.util.ArrayList;

import javax.swing.Timer;
import javax.swing.text.View;

import cs3500.animator.model.animation.IAnimatedShape;
import cs3500.animator.model.animation.IAnimationModel;
import cs3500.animator.util.AnimatedShapeToDrawableConverter;
import cs3500.animator.util.DrawableGUIShape;
import cs3500.animator.view.IGuiView;
import cs3500.animator.view.ViewGUI;

/**
Expand Down
4 changes: 4 additions & 0 deletions src/cs3500/animator/controller/HybridController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
import java.awt.event.ActionEvent;

import cs3500.animator.model.animation.IAnimationModel;
import cs3500.animator.view.IGuiInteractiveView;
import cs3500.animator.view.InteractiveViewGUI;
import cs3500.animator.view.TextBasedView;
import cs3500.animator.view.ViewSVG;

/**
*
*/
public class HybridController extends InteractiveController {
private ControllerText fileOutputController;

Expand Down
4 changes: 3 additions & 1 deletion src/cs3500/animator/controller/InteractiveController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import javax.swing.event.ChangeListener;

import cs3500.animator.model.animation.IAnimationModel;
import cs3500.animator.view.IGuiInteractiveView;
import cs3500.animator.view.IGuiView;
import cs3500.animator.view.InteractiveViewGUI;

public class InteractiveController extends ControllerGUI implements ActionListener, ChangeListener {
InteractiveViewGUI interactiveView;
IGuiInteractiveView interactiveView;

/**
* Constructor for the GUI controller. Reads data from model and tells the view what to print.
Expand Down
22 changes: 22 additions & 0 deletions src/cs3500/animator/view/IGuiInteractiveView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cs3500.animator.view;

import java.awt.event.ActionListener;
import javax.swing.event.ChangeListener;

/**
*
*/
public interface IGuiInteractiveView extends IView {

/**
*
* @param listener
*/
void setActionListener(ActionListener listener);

/**
*
* @param listener
*/
void setChangeListener(ChangeListener listener);
}
17 changes: 17 additions & 0 deletions src/cs3500/animator/view/IGuiView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cs3500.animator.view;

import java.util.ArrayList;

import cs3500.animator.util.DrawableGUIShape;

/**
*
*/
public interface IGuiView extends IView {

/**
*
* @param newShapes
*/
void setShapes(ArrayList<DrawableGUIShape> newShapes);
}
7 changes: 0 additions & 7 deletions src/cs3500/animator/view/IView.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ public interface IView {
*/
void setFilename(String filename);

/**
*
* @param s
* @return
*/
String printStartEndTimeSVGAnimations(IDrawableShape s);

/**
*
* @return
Expand Down
11 changes: 10 additions & 1 deletion src/cs3500/animator/view/InteractiveViewGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import javax.swing.*;
import javax.swing.event.ChangeListener;

public class InteractiveViewGUI extends ViewGUI {
/**
*
*/
public class InteractiveViewGUI extends ViewGUI implements IGuiInteractiveView {
private JSlider slider;
private JButton stopStartButton;
private JButton restartButton;
Expand All @@ -18,6 +21,10 @@ public class InteractiveViewGUI extends ViewGUI {
private final int FPS_MAX = 60;
private final int FPS_INIT = 30;

/**
* Creates a new InteractiveViewGUI object. This type of view can display animations whose
* settings can be adjusted by the client.
*/
public InteractiveViewGUI() {
super();

Expand All @@ -40,6 +47,7 @@ public InteractiveViewGUI() {
this.add(panel);
}

@Override
public void setActionListener(ActionListener listener) {
if (listener == null) {
throw new IllegalArgumentException("Invalid action listener");
Expand All @@ -51,6 +59,7 @@ public void setActionListener(ActionListener listener) {
exportButton.addActionListener(listener);
}

@Override
public void setChangeListener(ChangeListener listener) {
if (listener == null) {
throw new IllegalArgumentException("Invalid action listener");
Expand Down
2 changes: 0 additions & 2 deletions src/cs3500/animator/view/TextBasedView.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,4 @@ public void setShapes(ArrayList<DrawableTextShape> shapes) {
public ViewType getViewType() {
return viewType;
}

public abstract String printStartEndTimeSVGAnimations(DrawableTextShape s);
}
2 changes: 1 addition & 1 deletion src/cs3500/animator/view/ViewFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class ViewFactory {

/**
* THis method constructs a view based on the type provied. It accepts svg, text, or gui.
* This method constructs a view based on the type provided. It accepts svg, text, or gui.
* @param type the view type.
* @return the new {@link IView} object.
*/
Expand Down
30 changes: 14 additions & 16 deletions src/cs3500/animator/view/ViewGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
/**
* This class serves as both an IView object and a JFrame for cs3500.animator.model.animation.
*/
public class ViewGUI extends JFrame implements IView {
public class ViewGUI extends JFrame implements IGuiView {
private ShapePanel panel;
private JScrollPane scrollPane;
private ViewType viewType;

/**
* This is the defualt constructor.
* This is the default constructor.
*/
public ViewGUI() {
super();
Expand All @@ -36,23 +36,26 @@ public ViewGUI() {
this.pack();
}

/**
* This method sets the cs3500.animator.model.shapes to be animated on the next tic.
* @param newShapes The cs3500.animator.model.shapes to be painted.
*/
public void setShapes(ArrayList<DrawableGUIShape> newShapes) {
panel.setShapes(newShapes);
}

/**
* This method is called by the constructor and adds a panel with scroll bars to this object.
*/
public void addPanelWithScrollPane() {
private void addPanelWithScrollPane() {
this.panel = new ShapePanel();
this.add(panel);
this.add(new JScrollPane(panel));
}



/**
* This method sets the cs3500.animator.model.shapes to be animated on the next tic.
* @param newShapes The cs3500.animator.model.shapes to be painted.
*/
@Override
public void setShapes(ArrayList<DrawableGUIShape> newShapes) {
panel.setShapes(newShapes);
}

@Override
public void display() {
this.setVisible(true);
Expand All @@ -78,11 +81,6 @@ public void setFilename(String filename) {
throw new UnsupportedOperationException("ViewGUI object does not support this function");
}

@Override
public String printStartEndTimeSVGAnimations(IDrawableShape s) {
throw new UnsupportedOperationException("ViewGUI object does not support this function");
}

@Override
public String printSVGFromShapeList() {
throw new UnsupportedOperationException("ViewGUI object does not support this function");
Expand Down
68 changes: 34 additions & 34 deletions src/cs3500/animator/view/ViewSVG.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,40 @@ public ViewSVG() {
viewType = ViewType.SVG;
}

@Override
public void display() {
try {
ap.append("<svg xmlns=\"http://www.w3.org/2000/svg\" " +
"xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n\n");

ap.append(printSVGFromShapeList());

ap.append("\n</svg>");

ap.close();
} catch (IOException e) {
throw new IllegalArgumentException("Could not open file");
}
}

/**
* This method adds transformations for animating the appearance and disappearance of a shape.
* This must be done for every shape.
* @param s The shape being animated
* @return the svg description of the appearance/disappearance cs3500.animator.model.animation.
*/
public String printStartEndTimeSVGAnimations(DrawableTextShape s) {
StringBuilder stringBuilder = new StringBuilder();

stringBuilder.append("<set attributeName=\"fill-opacity\" attributeType=\"XML\"\n");
stringBuilder.append("to=\"1\"\nbegin=\"" + s.getStartTime() + "s\"/>\n");

stringBuilder.append("<set attributeName=\"fill-opacity\" attributeType=\"XML\"\n");
stringBuilder.append("to=\"0\"\nbegin=\"" + s.getEndTime() + "s\"/>");

return stringBuilder.toString();
}

/**
* This method writes an SVG style for a rectangle.
* @param x the x coordinate of the corner.
Expand Down Expand Up @@ -64,26 +98,6 @@ public String getEllipseDescription(double x, double y, double xRadius, double y
return strBuilder.toString();
}


/**
* This method adds transformations for animating the appearance and disappearance of a shape.
* This must be done for every shape.
* @param s The shape being animated
* @return the svg description of the appearance/disappearance cs3500.animator.model.animation.
*/
@Override
public String printStartEndTimeSVGAnimations(DrawableTextShape s) {
StringBuilder stringBuilder = new StringBuilder();

stringBuilder.append("<set attributeName=\"fill-opacity\" attributeType=\"XML\"\n");
stringBuilder.append("to=\"1\"\nbegin=\"" + s.getStartTime() + "s\"/>\n");

stringBuilder.append("<set attributeName=\"fill-opacity\" attributeType=\"XML\"\n");
stringBuilder.append("to=\"0\"\nbegin=\"" + s.getEndTime() + "s\"/>");

return stringBuilder.toString();
}

/**
* This function loops through the cs3500.animator.model.shapes and converts them to SVG.
* It only accepts cs3500.animator.model.shapes of type ellipse and rectangle.
Expand Down Expand Up @@ -188,19 +202,5 @@ public String printSVGFromShapeList() {
return strBuilder.toString();
}

@Override
public void display() {
try {
ap.append("<svg xmlns=\"http://www.w3.org/2000/svg\" " +
"xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n\n");

ap.append(printSVGFromShapeList());

ap.append("\n</svg>");

ap.close();
} catch (IOException e) {
throw new IllegalArgumentException("Could not open file");
}
}
}
6 changes: 1 addition & 5 deletions src/cs3500/animator/view/ViewText.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,8 @@ public void setFilename(String filename) {
throw new UnsupportedOperationException("ViewText object does not support this function");
}

@Override
public String printStartEndTimeSVGAnimations(IDrawableShape s) {
throw new UnsupportedOperationException("ViewText object does not support this function");
}

@Override
public String printSVGFromShapeList() {
throw new UnsupportedOperationException("ViewText object does not support this function");
}
}
11 changes: 10 additions & 1 deletion src/hw7 README
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
The following changes were made to our code from the previous assignment:
- Added functions of all views to IView and make unsupported functions throw
UnsupportedOperationException's.
UnsupportedOperationException's.
- Changed model to store shapes in LinkedHashMap rather than HashMap since draw order
wasn't conserved in HashMap.


The following classes were added:
-IGuiBasedView
-InteractiveViewGUI
-HybridController
-InteractiveController

0 comments on commit 2b0793e

Please sign in to comment.