Skip to content

Add Comments And Also the Select Tools By Kent #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: develop_smarttool
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<project name="JavaSketchPad" default="run" basedir=".">
<property name="build.dir" location="ant_build" />
<property name="src.dir" location="src" />

<target name="init" description="Creating directory">
<mkdir dir="${build.dir}" />
</target>

<target name="build" depends="init" description="Compiling Sources">
<javac srcdir="${src.dir}" destdir="${build.dir}" />
</target>

<target name="run" depends="build" description="Running the program">
</target>

<target name="clean">
<delete dir="${build.dir}" />
</target>
</project>
6 changes: 6 additions & 0 deletions src/actions/AddDataDisplayBoxAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
import paintcomponents.data.DataDisplayPaintComponent;
import ui.PaintPanel;

/**
* This action adds a data display box (Data > Display > Add)
* @author chenzb
*
*/
public class AddDataDisplayBoxAction extends PaintAction {

public AddDataDisplayBoxAction(PaintPanel panel) {
super(panel);
}


@Override
public boolean canPerformAction() {
return true;
Expand Down
5 changes: 5 additions & 0 deletions src/actions/AddDataInputBoxAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import paintcomponents.data.DataInputTextfieldPaintComponent;
import ui.PaintPanel;

/**
* Add Data Input Box Action
* @author chenzb
*
*/
public class AddDataInputBoxAction extends PaintAction {

public AddDataInputBoxAction(PaintPanel panel) {
Expand Down
5 changes: 5 additions & 0 deletions src/actions/AddHaskellComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import paintcomponents.haskell.HaskellExpressionPaintComponent;
import ui.PaintPanel;

/**
* Add a haskell expression component
* @author chenzb
*
*/
public class AddHaskellComponent extends PaintAction {

public AddHaskellComponent(PaintPanel panel) {
Expand Down
5 changes: 5 additions & 0 deletions src/actions/AddHaskellEvaluatorComponentAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import paintcomponents.haskell.EvaluateHaskellPaintComponent;
import ui.PaintPanel;

/**
* Haskell expression evaluator action
* @author chenzb
*
*/
public class AddHaskellEvaluatorComponentAction extends PaintAction {

public AddHaskellEvaluatorComponentAction(PaintPanel panel) {
Expand Down
5 changes: 5 additions & 0 deletions src/actions/AddLazyJavaClassAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
import ui.helper.ClassSearchFrame;
import ui.helper.ClassSearchFrameDelegateInterface;

/**
* Add a lazily evaluated java class component
* @author chenzb
*
*/
public class AddLazyJavaClassAction extends PaintAction {

public AddLazyJavaClassAction(PaintPanel panel) {
Expand Down
5 changes: 5 additions & 0 deletions src/actions/AddLazyJavaConstructorAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
import paintcomponents.java.lazy.ClassPaintComponent;
import ui.PaintPanel;

/**
* Add LazyJavaConstructorAction
* @author chenzb
*
*/
public class AddLazyJavaConstructorAction extends PaintAction {

public AddLazyJavaConstructorAction(PaintPanel panel) {
Expand Down
5 changes: 5 additions & 0 deletions src/actions/AddLazyJavaFieldsComponentAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
import paintcomponents.java.lazy.FieldsPaintComponent;
import ui.PaintPanel;

/**
* Add a Java Fileds Component
* @author chenzb
*
*/
public class AddLazyJavaFieldsComponentAction extends PaintAction {

public AddLazyJavaFieldsComponentAction(PaintPanel panel) {
Expand Down
8 changes: 7 additions & 1 deletion src/actions/RemovePaintComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public void performAction() {
for ( PaintComponent comp: panel.getSelectTool().getSelectedComponents()) {
comps.add(comp);
}


for( PaintComponent comp: comps ) comp.remove(panel);

//push action to the manager
Expand All @@ -45,12 +47,16 @@ public void redoAction() {
comp.remove(panel);
}
});

panel.repaint();
}

@Override
public String locationString() {
// TODO Auto-generated method stub
return ActionsMenuBarTitles.Data().Remove().toString(); }


public String toString() {
return "Remove";
}
}
7 changes: 7 additions & 0 deletions src/actions/edit/undoredo/SharedUndoRedoActionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
import java.util.Stack;

/**
*
* A manager for undo and redo in the program.
* Use getSharedInstance to retrieve such an instance.
*
* An undoable action should push an instance of the interface to this manger
* via pushUndoableAction method. Edit /Undo /Redo action should actively delgate this
* manager for the availability of undo and redoables.
*
* @author cs12wagn
* add to stack
Expand Down
7 changes: 7 additions & 0 deletions src/actions/edit/undoredo/UndoRedoableInterface.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package actions.edit.undoredo;

/**
* An interface for implementing undo and redos.
*
* Each undoable action should push an instance of this interface to the undo redo manger.
* @author chenzb
*
*/
public interface UndoRedoableInterface {
public void undoAction();
public void redoAction();
Expand Down
9 changes: 9 additions & 0 deletions src/actions/menu/ActionsMenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,21 @@
import actions.PaintAction;
import actions.RemovePaintComponent;
import actions.UpdateDataDisplayBoxAction;
import actions.singleinstanceoperations.SetLineSegmentWidthOperation;
import actions.singleinstanceoperations.SetPointSizeOperation;
import actions.singleinstanceoperations.UpdateFontSizeOperation;
import actions.ZoomInAction;
import actions.ZoomOutAction;
import actions.ZoomInAction;
import actions.ZoomOutAction;

/**
* The main menubar.
*
* Individual actions should register itself in the constructor of this method.
* @author chenzb
*
*/
public class ActionsMenuBar extends JMenuBar implements SelectionToolListener{

public ActionsMenuBar(PaintPanel panel){
Expand Down Expand Up @@ -78,6 +86,7 @@ public ActionsMenuBar(PaintPanel panel){
//edit
addAction(new UpdateFontSizeOperation(panel));
addAction(new SetPointSizeOperation(panel));
addAction(new SetLineSegmentWidthOperation(panel));

}

Expand Down
18 changes: 18 additions & 0 deletions src/actions/menu/ActionsMenuBarTitles.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package actions.menu;

/**
* The menubar titles.
*
* A paint action's get location should use this class for creating menubar titles.
*
* For example ActionsMenuBarTitles.Edit().Undo().toString();
*
*
*
*
* @author chenzb
*
*/
public class ActionsMenuBarTitles {

public String pending;
Expand Down Expand Up @@ -132,6 +145,11 @@ public ActionsMenuBarTitles Zoom_In() {
append("Zoom In");
return this;
}

public ActionsMenuBarTitles Line_Segment_Width() {
append("Line Segment Width...");
return this;
}

public ActionsMenuBarTitles Zoom_Out() {
append("Zoom Out");
Expand Down
17 changes: 13 additions & 4 deletions src/actions/menu/PaintActionMenuItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

import actions.PaintAction;

/**
* An action menu item is a JMenuItme associated with an action.
*
* The associated paint action is invoked on a mouse click.
*
* @author chenzb
*
*/
public class PaintActionMenuItem extends JMenuItem{


Expand All @@ -13,9 +21,10 @@ public class PaintActionMenuItem extends JMenuItem{
public PaintActionMenuItem(PaintAction associatedAction, ActionsMenuBar actionsMenuBar) {
this.setAssociatedAction(associatedAction);
this.actionsMenuBar = actionsMenuBar;

}

public PaintActionMenuItem(PaintAction associatedAction) {
this.setAssociatedAction(associatedAction);
}
public PaintAction getAssociatedAction() {
return associatedAction;
}
Expand All @@ -27,7 +36,7 @@ public void setAssociatedAction(PaintAction associatedAction) {
public void performAction() {
associatedAction.performAction();
//update menu bar status
actionsMenuBar.updateEnableStatusForAllMenuItems();

if(actionsMenuBar != null)
actionsMenuBar.updateEnableStatusForAllMenuItems();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package actions.singleinstanceoperations;

import javax.sound.sampled.Line;

import actions.menu.ActionsMenuBarTitles;
import paintcomponents.LineSegment;
import ui.PaintPanel;
import ui.general.InputManager;
import ui.general.InputManagerDelegate;

/**
* A single instance operation responsible for setting the line width
* @author chenzb
*
*/
public class SetLineSegmentWidthOperation extends SingleInstanceOperation<LineSegment> {

public SetLineSegmentWidthOperation(PaintPanel panel) {
super(panel);
}


@Override
public String locationString() {
return ActionsMenuBarTitles.Edit().Line_Segment_Width().toString();
}

@Override
protected void performActionOnInstance(LineSegment instance) {
InputManager.sharedInstance().askForDouble(panel, new InputManagerDelegate<Double>() {

@Override
public void didFinishInput(Double input) {
instance.setStrokeWidth(input);
}
});

}

@Override
protected Class<LineSegment> getGenericClassType() {
return LineSegment.class;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import ui.general.InputManager;
import ui.general.InputManagerDelegate;

/**
* A single instance operation responsible for setting the point size
* @author chenzb
*
*/
public class SetPointSizeOperation extends SingleInstanceOperation<SimplePoint> {

public SetPointSizeOperation(PaintPanel panel) {
Expand Down
13 changes: 13 additions & 0 deletions src/actions/singleinstanceoperations/SingleInstanceOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public SingleInstanceOperation(PaintPanel panel) {
super(panel);
}

/**
* The default behavior for a change method, only one component is selected
* and that component's type matchs the desired type
*/
@Override
public boolean canPerformAction() {
if (panel.getSelectTool().getSelectedComponents().size() != 1) {
Expand All @@ -41,6 +45,10 @@ public boolean canPerformAction() {

}

/**
* The implementation of this method delegates to the "PerformActionOnInstance"
*
*/
@Override
public void performAction() {
// TODO Auto-generated method stub
Expand All @@ -50,6 +58,11 @@ public void performAction() {
panel.repaint();
}

/**
* This method is called when the action is triggered.
* Subclasses need to override this method to do appropriate operations
* @param instance
*/
protected abstract void performActionOnInstance(T instance);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import ui.general.InputManager;
import ui.general.InputManagerDelegate;

/**
* Single instance operaiton responsible for updating the font size
* @author chenzb
*
*/
public class UpdateFontSizeOperation extends SingleInstanceOperation<TextPaintComponent>{

public UpdateFontSizeOperation(PaintPanel panel) {
Expand Down
6 changes: 6 additions & 0 deletions src/classpathutil/ClassFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
import java.util.jar.JarFile;

/**Take from
*
* This is a template class.
*
* Use ClassSearch instead.
*
* This class is copied from
*
* http://stackoverflow.com/questions/3222638/get-all-of-the-classes-in-the-classpath
*
Expand Down
Loading