From e916d170fcf454f70a4a3d9407c4b8047261a4ad Mon Sep 17 00:00:00 2001 From: Donna M Agogliati Date: Tue, 26 Mar 2019 13:20:50 -0400 Subject: [PATCH] Add files via upload --- Lab1App.class | Bin 0 -> 727 bytes Lab1App.ctxt | 7 +++++ Lab1App.java | 17 +++++++++++ README.TXT | 12 ++++++++ ShapesPanel.class | Bin 0 -> 1758 bytes ShapesPanel.ctxt | 7 +++++ ShapesPanel.java | 53 +++++++++++++++++++++++++++++++++++ SmartEllipse.class | Bin 0 -> 2205 bytes SmartEllipse.ctxt | 22 +++++++++++++++ SmartEllipse.java | 60 +++++++++++++++++++++++++++++++++++++++ SmartRectangle.class | Bin 0 -> 2215 bytes SmartRectangle.ctxt | 22 +++++++++++++++ SmartRectangle.java | 65 +++++++++++++++++++++++++++++++++++++++++++ package.bluej | 62 +++++++++++++++++++++++++++++++++++++++++ 14 files changed, 327 insertions(+) create mode 100644 Lab1App.class create mode 100644 Lab1App.ctxt create mode 100644 Lab1App.java create mode 100644 README.TXT create mode 100644 ShapesPanel.class create mode 100644 ShapesPanel.ctxt create mode 100644 ShapesPanel.java create mode 100644 SmartEllipse.class create mode 100644 SmartEllipse.ctxt create mode 100644 SmartEllipse.java create mode 100644 SmartRectangle.class create mode 100644 SmartRectangle.ctxt create mode 100644 SmartRectangle.java create mode 100644 package.bluej diff --git a/Lab1App.class b/Lab1App.class new file mode 100644 index 0000000000000000000000000000000000000000..09fbf06b158614f445b28a8d0755ae7ccfa657f4 GIT binary patch literal 727 zcmZ{i@oUpS6vw~Uq)nS<>)N?F=hRN!Ofy{=_*+Gg%3u;y$f!(zx~^w;k|rU!I`O~q zmlhoO2lz*c@0x&$O5ojl@7{gB_ul3EkFVbVJce(>z>bXuZdtgk*E<%vHmcaw!Ch_c zS-4-vo_2Q_YENV=)l-HIH~7FmazEnn#1B;_<4M0aWH1NGSTM8#8H<;*=}2U!d=ycp z6C~$68uCo)xJ;VrLgoyOAmF2;XKC7Js4A(7`oH)@pK=*9Y`X9Mqt3Gl@z(#b&0z2} zWw66!mYs`ZsYRSp_fTs&aIoTF9}noZI`PTRFR3s8#c{@`!hwq(Lo>YKsmNdRSVa1S z=imSj9X!GzgH`evR>|ugb;Bf@DVflntz4*3ekReXdvc;jwMCid;ys^5Y7iy4c$JEb z7saN#tT0?%XYlcu!7B&OFO@$?rfCw3SoM3w9R5sFlY}11TrMYXx^H_!?9u}o^y)wb z)Hqhiu2K|JwnFQ^cd!8S+9uit=BRkJIZW>g)w2c2wcdE<9Q7~D^DVO5sFAhkU#X)- z>}#;mMH73(UZb7Of{Hde6cHcmR6}o#4caTT2c>rN3XQXly+AYgC15WBEyAw-25jOw Swg_hv;s&7^ecKdQaPuei36HY? literal 0 HcmV?d00001 diff --git a/Lab1App.ctxt b/Lab1App.ctxt new file mode 100644 index 0000000..4c6daca --- /dev/null +++ b/Lab1App.ctxt @@ -0,0 +1,7 @@ +#BlueJ class context +comment0.target=Lab1App +comment1.params=title +comment1.target=Lab1App(java.lang.String) +comment2.params=args +comment2.target=void\ main(java.lang.String[]) +numComments=3 diff --git a/Lab1App.java b/Lab1App.java new file mode 100644 index 0000000..2eb0c76 --- /dev/null +++ b/Lab1App.java @@ -0,0 +1,17 @@ +import javax.swing.*; +import java.awt.*; + +public class Lab1App extends JFrame{ + + public Lab1App(String title){ + super(title); + this.setSize(1024, 768); + this.setDefaultCloseOperation(EXIT_ON_CLOSE); + this.add(new ShapesPanel()); + this.setVisible(true); + } + + public static void main (String[] args){ + Lab1App app = new Lab1App("Lab 1 Solution"); + } +} diff --git a/README.TXT b/README.TXT new file mode 100644 index 0000000..2bea2dd --- /dev/null +++ b/README.TXT @@ -0,0 +1,12 @@ +------------------------------------------------------------------------ +This is the project README file. Here, you should describe your project. +Tell the reader (someone who does not know anything about this project) +all he/she needs to know. The comments should usually include at least: +------------------------------------------------------------------------ + +PROJECT TITLE: +PURPOSE OF PROJECT: +VERSION or DATE: +HOW TO START THIS PROJECT: +AUTHORS: +USER INSTRUCTIONS: diff --git a/ShapesPanel.class b/ShapesPanel.class new file mode 100644 index 0000000000000000000000000000000000000000..dfae3c1f6673ba2e0a66ce9ad10504644f58c6a3 GIT binary patch literal 1758 zcmZuxZBrXn6n-`@8(0>)LV~om!HU+90BKXKwZxi20;Z;bNkJn@TwqI>5p9>^HPqW!k~u=`2=W1&N-(7B6G`5Sp{M=$H#7(=rzK zb~g;?p}xTf50>mry|JoOezJXM$gP_#3H_x?U2ht#W!*9wbjml%&^ioFcVc%yZanLU4@Aqjy+a!9XC`ou&cs?O@svWtm!J6jLhJsimzCk zX3arMh0Er_l*+;t5yuHNKJ1 z*F}X!!kZ7%tpn5APTv>Jr&7-{&e;vyp^46xRtkJ^{u`jS4RuXLfW=7qT87KBc1_!o z5KiRtJg5kHE9Mir2;oGr$ev)ikSA-QTqrD3WfU*luD>gk5Su~^<$G1C;E~yANEqol z?z|D=%$~$ram`CBAJI#&4B*((amw@< zX{4kDcxpn@%!H&?3rRy0lIA9)#J21P8lK@YzQ+~(fH;1{>v%zJ{{wH}Ph7+Mluh+o zhr9TIEQ#NQ*H-*Zg9(%GFqt~Ro2gU0^?*tYPqcB3WIxHbNydB`_vIK%`8TB+)Rd)a zNQ*92!&-c4(Q{?lm0?$Q=}w6Hm8ec$49O=LKSnb39H}-YQj|5>#^gEgTf`akkq%>= zKH1DTg-e(q7L#O6(WOZf|LdsIC90EU(1dPLyWe;Be&^nE?%m|Ce}4ZHz=vq1FoG|V7{sEOB{3y2 z%PE=_F{@(M#FWK+nZiS?i+Q9zAclNow;|@Sn6DCelE7vPc~oS-CFbh{b`)p_hqhBQ zoh7?rI|};OpBq0IGsdYq<9X&3qz;~0jfVd`dEnTt;aYY}fl}h}%GT!Nhsy^$<sHI$IB6c5&X#f5 zpeMg>SB=KD;aIZwoiVp=wH0L7D^0_3mm3Z1xNWjh)$ps#woP}jmzGAyO30#*TR$|- z{vCo&PT?YX&u#F zvJ(LnT<)R1>KMm$tJQP(WsUSyT*rRF+ymjM zu1nfhu}_?;N!Ak3tJJi#Si>!Rqu~ZdHC)CO4Ohin!*vbcVo$@qnD20);d@yb*h}D0 zLlrd*MT}`M@l3;g9BHV-QZN+E&7#q^s^^tyy@@5~a}6)h&@hjq1eyv)gL6lw-JJ28 zIa|6@vQNATP|p`yxz*yFHjH-LWcQ;55w7pZbbY<);6NtnIM-d;yy6&53Xovmx}A$L z;3<2;+b+j3NFU1GMfKIr7bZe+J)aDk_Yx3R6g1jBfptLJ!9g>Nytc0=|!Qa=^%eGfEXguNqOI-nckiKTS@&s^2e+5O4pCO_b&kz+8)3axY|Kc6HLwgk}ZJMc){A$P|!{k|}&EYPe40nO> zF2=bdBnrIvreGpSx4;-lr+QgJ?3CvnL>xmsSZaW!23Y!=v0|@d4HIkRf3P^pz6`5= zUFnd02$-ctLMKiMQhZB7vgx3}bWq?VrhL!^o|BWRK7K*SF4-Hz8|}gBB|FW|iEuM` z&&PT~$>YSz>Ejc6hmaj4I_L|F?1GN5AGbZwn_lW%P+$)4d!U5CELTwif53m7?if@E zFQpFX1WxiwU3+=`nxW`q5(D(7NpWs&xjwIMGc94El z)PF;)15NI6KchN?j9rz~yb|7~gItlDelP6wzvCte7pgIe1e58MtjH;yq>xkOI*lE! z_9$vdU_T(Rk5BL^%Z=kH=Gbl_Fdq>3+nao#9T12Lfer>Xihm%#n|Xzy4lcbNqv5w< zG$n8sY3ZCluzhj1E<-|jPxE_tK&6*iYMm6CB;k;NP}KRdvgCkbJD}L|DdzbL@EK%M UBlw)L5n}D~o+9}XY*UKlzhex4*8l(j literal 0 HcmV?d00001 diff --git a/SmartEllipse.ctxt b/SmartEllipse.ctxt new file mode 100644 index 0000000..f24a2a7 --- /dev/null +++ b/SmartEllipse.ctxt @@ -0,0 +1,22 @@ +#BlueJ class context +comment0.target=SmartEllipse +comment0.text=\r\n\ Chapter\ 9\:\ SmartEllipse.java\r\n\ Adds\ capabilities\ to\ the\ Java2D.Double\ ellipse.\r\n\ Same\ as\ the\ class\ defined\ in\ Chapter\ 7.\r\n +comment1.params=aColor +comment1.target=SmartEllipse(java.awt.Color) +comment2.params=aColor +comment2.target=void\ setBorderColor(java.awt.Color) +comment3.params=aColor +comment3.target=void\ setFillColor(java.awt.Color) +comment4.params=aColor +comment4.target=void\ setColor(java.awt.Color) +comment5.params=aRotation +comment5.target=void\ setRotation(double) +comment6.params=x\ y +comment6.target=void\ setLocation(double,\ double) +comment7.params=aWidth\ aHeight +comment7.target=void\ setSize(int,\ int) +comment8.params=aBrush +comment8.target=void\ fill(java.awt.Graphics2D) +comment9.params=aBrush +comment9.target=void\ draw(java.awt.Graphics2D) +numComments=10 diff --git a/SmartEllipse.java b/SmartEllipse.java new file mode 100644 index 0000000..4b198b9 --- /dev/null +++ b/SmartEllipse.java @@ -0,0 +1,60 @@ +/** + * Chapter 9: SmartEllipse.java + * Adds capabilities to the Java2D.Double ellipse. + * Same as the class defined in Chapter 7. + */ +public class SmartEllipse extends java.awt.geom.Ellipse2D.Double { + private java.awt.Color _borderColor, _fillColor; + private double _rotation; + private final int STROKE_WIDTH = 2; + + public SmartEllipse(java.awt.Color aColor){ + _borderColor = aColor; + _fillColor = aColor; // solid color to start + _rotation = 0; + } + + // methods not provided by Java + public void setBorderColor (java.awt.Color aColor) { + _borderColor = aColor; + } + public void setFillColor (java.awt.Color aColor) { + _fillColor = aColor; + } + public void setColor (java.awt.Color aColor) { + _borderColor = aColor; + _fillColor = aColor; + } + public void setRotation (double aRotation) { + _rotation = aRotation; + } + + // more readable versions of methods provided by Java + public void setLocation (double x, double y) { + this.setFrame (x, y, this.getWidth(), this.getHeight()); + } + public void setSize (int aWidth, int aHeight) { + this.setFrame(this.getX(), this.getY(), aWidth, aHeight); + } + + // not provided by Java + public void fill (java.awt.Graphics2D aBrush){ + java.awt.Color oldColor = aBrush.getColor(); + aBrush.setColor(_fillColor); + aBrush.rotate(_rotation, this.getX()+(this.getWidth()/2), this.getY()+(this.getHeight()/2)); + aBrush.fill(this); + aBrush.rotate(-_rotation, this.getX()+(this.getWidth()/2), this.getY()+(this.getHeight()/2)); + aBrush.setColor(oldColor); + } + public void draw (java.awt.Graphics2D aBrush) { + java.awt.Color oldColor = aBrush.getColor(); + aBrush.setColor(_borderColor); + java.awt.Stroke oldStroke = aBrush.getStroke(); + aBrush.setStroke(new java.awt.BasicStroke(STROKE_WIDTH)); + aBrush.rotate(_rotation, this.getX()+(this.getWidth()/2), this.getY()+(this.getHeight()/2)); + aBrush.draw(this); + aBrush.rotate(-_rotation, this.getX()+(this.getWidth()/2), this.getY()+(this.getHeight()/2)); + aBrush.setStroke(oldStroke); + aBrush.setColor(oldColor); + } +} diff --git a/SmartRectangle.class b/SmartRectangle.class new file mode 100644 index 0000000000000000000000000000000000000000..2cc7346714c76b53ddef61c234900c782c1fc6e1 GIT binary patch literal 2215 zcma)7jZzzB6g^9l4M`S40;Ppkgj!43v_!F56-q0FpIAyQK`091l5CT0lWb?Ri24G3 z9!E)MbjAnpC43Xdb2rOwU^-f6a`*f0e&4z0oO=`g`sepQ0o*|=iOcvRfnh93Se8(f zu##k0m9QpZT|!C1mq|RthJ;7z17gUZ>^3Dlmhe>^PvY20B8#%@w+{FqrI|`!9cGXmn-mqHc=5h1LbheG7 z1~b_WyJ9qU49AkapNzV7t1Vp1O~Y}w%nGa38Ya1_hR<`bZMsXn!ZapULmmCx`bSe- zZUv&ExuOtC7-32d2#v1lSgz=uP=2J`pA^LTwru@OuCZLHBzIL~*Q&a8zB1NLt5$cZ zPb^e$rAPdlW4x?emG)e5zI$oOId1dPrO=u;d@yb*pK5# zLj_e0d0f|E;+clKsA;IfQZN$C&XUo#DrejV&zF{}&o#V2L&E}UaWoZ71~+S_-7Ewx zoh#lb+Q;4`sAmhU)M{~F8%Dcratb0jv9G^oy1wg7a4-{0oVhQ}UUiHnZHTjb-Tp;+ z;3+%9#~$qo2!y70QGL&|xtY*nFDK*XeHjR=3as$x9q)48cxigg6*6aT4EF*By^7{m z<$6Mf$#3aM&#?IC5G{tk8TQu97n z(!#Do2Z4YCe1^|SH-@K}=j4ijg+RdH6cFXDb|4@k0y@ZS=Knx;Z{RgXI=J+9ibmf? z(QSb{FH7hAf$qlW>;S1{NqK^#ACT}0$<}cXO)SE}eNUp^r5s3X2NGMp#4LXS?(v5F U3fw1lAF=lMOj7)1?9htDzd>SzMF0Q* literal 0 HcmV?d00001 diff --git a/SmartRectangle.ctxt b/SmartRectangle.ctxt new file mode 100644 index 0000000..e679c58 --- /dev/null +++ b/SmartRectangle.ctxt @@ -0,0 +1,22 @@ +#BlueJ class context +comment0.target=SmartRectangle +comment0.text=\r\n\ Write\ a\ description\ of\ class\ SmartRectangle\ here.\r\n\r\n\ @author\ (your\ name)\r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n +comment1.params=aColor +comment1.target=SmartRectangle(java.awt.Color) +comment2.params=aColor +comment2.target=void\ setBorderColor(java.awt.Color) +comment3.params=aColor +comment3.target=void\ setFillColor(java.awt.Color) +comment4.params=aColor +comment4.target=void\ setColor(java.awt.Color) +comment5.params=aRotation +comment5.target=void\ setRotation(double) +comment6.params=x\ y +comment6.target=void\ setLocation(double,\ double) +comment7.params=aWidth\ aHeight +comment7.target=void\ setSize(int,\ int) +comment8.params=aBrush +comment8.target=void\ fill(java.awt.Graphics2D) +comment9.params=aBrush +comment9.target=void\ draw(java.awt.Graphics2D) +numComments=10 diff --git a/SmartRectangle.java b/SmartRectangle.java new file mode 100644 index 0000000..8ae8ed4 --- /dev/null +++ b/SmartRectangle.java @@ -0,0 +1,65 @@ + +/** + * Write a description of class SmartRectangle here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class SmartRectangle extends java.awt.geom.Rectangle2D.Double +{ + private java.awt.Color _borderColor, _fillColor; + private double _rotation; + private final int STROKE_WIDTH = 2; + + public SmartRectangle(java.awt.Color aColor){ + _borderColor = aColor; + _fillColor = aColor; // solid color to start + _rotation = 0; + } + + // methods not provided by Java + public void setBorderColor (java.awt.Color aColor) { + _borderColor = aColor; + } + public void setFillColor (java.awt.Color aColor) { + _fillColor = aColor; + } + public void setColor (java.awt.Color aColor) { + _borderColor = aColor; + _fillColor = aColor; + } + public void setRotation (double aRotation) { + _rotation = aRotation; + } + + + // more readable versions of methods provided by Java + public void setLocation (double x, double y) { + this.setFrame (x, y, this.getWidth(), this.getHeight()); + } + public void setSize (int aWidth, int aHeight) { + this.setFrame(this.getX(), this.getY(), aWidth, aHeight); + } + + // not provided by Java + public void fill (java.awt.Graphics2D aBrush){ + java.awt.Color oldColor = aBrush.getColor(); + aBrush.setColor(_fillColor); + aBrush.rotate(_rotation, this.getX()+(this.getWidth()/2), this.getY()+(this.getHeight()/2)); + aBrush.fill(this); + aBrush.rotate(-_rotation, this.getX()+(this.getWidth()/2), this.getY()+(this.getHeight()/2)); + aBrush.setColor(oldColor); + } + public void draw (java.awt.Graphics2D aBrush) { + java.awt.Color oldColor = aBrush.getColor(); + aBrush.setColor(_borderColor); + java.awt.Stroke oldStroke = aBrush.getStroke(); + aBrush.setStroke(new java.awt.BasicStroke(STROKE_WIDTH)); + aBrush.rotate(_rotation, this.getX()+(this.getWidth()/2), this.getY()+(this.getHeight()/2)); + aBrush.draw(this); + aBrush.rotate(-_rotation, this.getX()+(this.getWidth()/2), this.getY()+(this.getHeight()/2)); + aBrush.setStroke(oldStroke); + aBrush.setColor(oldColor); + } +} + diff --git a/package.bluej b/package.bluej new file mode 100644 index 0000000..a305f5a --- /dev/null +++ b/package.bluej @@ -0,0 +1,62 @@ +#BlueJ package file +dependency1.from=Lab1App +dependency1.to=ShapesPanel +dependency1.type=UsesDependency +dependency2.from=ShapesPanel +dependency2.to=SmartEllipse +dependency2.type=UsesDependency +dependency3.from=ShapesPanel +dependency3.to=SmartRectangle +dependency3.type=UsesDependency +editor.fx.0.height=744 +editor.fx.0.width=1382 +editor.fx.0.x=-8 +editor.fx.0.y=-8 +objectbench.height=157 +objectbench.width=1342 +package.divider.horizontal=0.6 +package.divider.vertical=0.7453416149068323 +package.editor.height=473 +package.editor.width=1252 +package.editor.x=-8 +package.editor.y=-8 +package.frame.height=744 +package.frame.width=1382 +package.numDependencies=3 +package.numTargets=4 +package.showExtends=true +package.showUses=true +project.charset=UTF-8 +readme.height=58 +readme.name=@README +readme.width=47 +readme.x=10 +readme.y=10 +target1.height=50 +target1.name=Lab1App +target1.showInterface=false +target1.type=ClassTarget +target1.width=80 +target1.x=130 +target1.y=90 +target2.height=50 +target2.name=ShapesPanel +target2.showInterface=false +target2.type=ClassTarget +target2.width=110 +target2.x=10 +target2.y=160 +target3.height=50 +target3.name=SmartEllipse +target3.showInterface=false +target3.type=ClassTarget +target3.width=100 +target3.x=270 +target3.y=210 +target4.height=50 +target4.name=SmartRectangle +target4.showInterface=false +target4.type=ClassTarget +target4.width=120 +target4.x=130 +target4.y=290