aboutsummaryrefslogtreecommitdiff
path: root/apcs
diff options
context:
space:
mode:
Diffstat (limited to 'apcs')
-rw-r--r--apcs/.gitignore1
-rw-r--r--apcs/RoundedRectangleTest.java62
-rw-r--r--apcs/SongPlayer.java2
-rw-r--r--apcs/shadowtest.java26
4 files changed, 73 insertions, 18 deletions
diff --git a/apcs/.gitignore b/apcs/.gitignore
deleted file mode 100644
index 6b468b6..0000000
--- a/apcs/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.class
diff --git a/apcs/RoundedRectangleTest.java b/apcs/RoundedRectangleTest.java
index e506ec4..c24772c 100644
--- a/apcs/RoundedRectangleTest.java
+++ b/apcs/RoundedRectangleTest.java
@@ -3,6 +3,7 @@ package apcs;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.AffineTransform;
+import java.awt.geom.RoundRectangle2D;
import javax.swing.*;
@@ -15,42 +16,56 @@ public class RoundedRectangleTest extends JFrame {
setVisible(true);
}
public void paint(Graphics g) {
+ //DropShadowBorder shadow = new DropShadowBorder();
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint(Color.DARK_GRAY);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- /*
+ g2d.fillRoundRect(10, 50, 150, 150, 30, 30); // to draw a rounded rectangle.
+
+ /*Graphics2D g2d = (Graphics2D) g;
Color holdColor = g2d.getColor();
g2d.setColor(Color.black);
AffineTransform holdTransform = g2d.getTransform();
// want the shadow to be one line width pixel offset
- float lineWidth = g2d.getStroke() instanceof BasicStroke ? ((BasicStroke) (g2d.getStroke())).getLineWidth()
- : 1.0f;
+ float lineWidth;
+ if (g2d.getStroke() instanceof BasicStroke)
+ {
+ lineWidth = ((BasicStroke) (g2d.getStroke())).getLineWidth();
+ }
+ else
+ {
+ lineWidth = 1.0f;
+ }
//System.err.println("DrawingUtilities.drawShadowedShape(): lineWidth = "+lineWidth);
- g2d.translate(lineWidth, lineWidth);
- g2d.fillRoundRect(10, 50, 150, 150, 50, 50); // to draw a rounded rectangle.
- g2d.setColor(holdColor);
- g2d.setTransform(holdTransform);
+ //g2d.translate(lineWidth, lineWidth);
+ g2d.fillRoundRect(10, 50, 150, 150, 30, 30);
+ //g2d.setColor(holdColor);
+ //g2d.setTransform(holdTransform);
+ //g2d.drawRoundRect(10, 50, 150, 150, 30, 30);
*/
- g2d.fillRoundRect(10, 50, 150, 150, 50, 50); // to draw a rounded rectangle.
-
+
+
}
public static void main(String []args) {
new RoundedRectangleTest();
}
-
- /*/from www . j av a2 s .c o m
- * @param shape the shape to be drawn
- * @param g2d the drawing context
- */
+
public static void drawShadowedShape(Shape shape, Graphics2D g2d)
{
Color holdColor = g2d.getColor();
g2d.setColor(Color.black);
AffineTransform holdTransform = g2d.getTransform();
// want the shadow to be one line width pixel offset
- float lineWidth = g2d.getStroke() instanceof BasicStroke ? ((BasicStroke) (g2d.getStroke())).getLineWidth()
- : 1.0f;
+ float lineWidth;
+ if (g2d.getStroke() instanceof BasicStroke)
+ {
+ lineWidth = ((BasicStroke) (g2d.getStroke())).getLineWidth();
+ }
+ else
+ {
+ lineWidth = 1.0f;
+ }
//System.err.println("DrawingUtilities.drawShadowedShape(): lineWidth = "+lineWidth);
g2d.translate(lineWidth, lineWidth);
g2d.draw(shape);
@@ -58,4 +73,19 @@ public class RoundedRectangleTest extends JFrame {
g2d.setTransform(holdTransform);
g2d.draw(shape);
}
+
+ public static void drawShadowedShape2(Shape shape, Graphics2D g2d) {
+ Color holdColor = g2d.getColor();
+ g2d.setColor(Color.black);
+ AffineTransform holdTransform = g2d.getTransform();
+ // want the shadow to be one line width pixel offset
+ float lineWidth = g2d.getStroke() instanceof BasicStroke ? ((BasicStroke) (g2d.getStroke())).getLineWidth()
+ : 1.0f;
+ //System.err.println("DrawingUtilities.drawShadowedShape(): lineWidth = "+lineWidth);
+ g2d.translate(lineWidth, lineWidth);
+ g2d.draw(shape);
+ g2d.setColor(holdColor);
+ g2d.setTransform(holdTransform);
+ g2d.draw(shape);
+ }
} \ No newline at end of file
diff --git a/apcs/SongPlayer.java b/apcs/SongPlayer.java
index 50e06aa..686bc7c 100644
--- a/apcs/SongPlayer.java
+++ b/apcs/SongPlayer.java
@@ -4,7 +4,7 @@
*Teacher:
*Description:
*/
-package cs;
+package apcs;
import java.awt.*;
import java.awt.event.*;
diff --git a/apcs/shadowtest.java b/apcs/shadowtest.java
new file mode 100644
index 0000000..b6acba5
--- /dev/null
+++ b/apcs/shadowtest.java
@@ -0,0 +1,26 @@
+package apcs;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+
+import java.awt.Shape;
+
+import java.awt.geom.AffineTransform;
+
+public class shadowtest {
+ public static void drawShadowedShape(Shape shape, Graphics2D g2d) {
+ Color holdColor = g2d.getColor();
+ g2d.setColor(Color.black);
+ AffineTransform holdTransform = g2d.getTransform();
+ // want the shadow to be one line width pixel offset
+ float lineWidth = g2d.getStroke() instanceof BasicStroke ? ((BasicStroke) (g2d.getStroke())).getLineWidth()
+ : 1.0f;
+ //System.err.println("DrawingUtilities.drawShadowedShape(): lineWidth = "+lineWidth);
+ g2d.translate(lineWidth, lineWidth);
+ g2d.draw(shape);
+ g2d.setColor(holdColor);
+ g2d.setTransform(holdTransform);
+ g2d.draw(shape);
+ }
+} \ No newline at end of file