Permalink
![Astute graphics plugins keygen Astute graphics plugins keygen](https://astutegraphics.com/wp-content/uploads/2016/06/ShortCuts-Blog-Image-17.png)
I need to use an optional argument to take a range and reverse it by using a main function to call the function containing the arguments. My output needs to have the original range, followed by the same list in reverse. Alignment Tools Mac Informer. Featured Alignment Tools free downloads and reviews. Latest updates on everything Alignment Tools Software related.
Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up Find file Copy path
Cannot retrieve contributors at this time
//UIUC CS125 FALL 2011 MP. File: Zen.java, CS125 Project: Pacmania, Version: 2011-10-18T07:44:38-0500.272378000 |
importjava.awt.Color; |
importjava.awt.Container; |
importjava.awt.Cursor; |
importjava.awt.Dimension; |
importjava.awt.Font; |
importjava.awt.Graphics; |
importjava.awt.Graphics2D; |
importjava.awt.GraphicsConfiguration; |
importjava.awt.GraphicsEnvironment; |
importjava.awt.Image; |
importjava.awt.event.KeyAdapter; |
importjava.awt.event.KeyEvent; |
importjava.awt.event.KeyListener; |
importjava.awt.event.MouseAdapter; |
importjava.awt.event.MouseEvent; |
importjava.awt.event.MouseListener; |
importjava.awt.event.MouseMotionAdapter; |
importjava.awt.event.MouseMotionListener; |
importjava.awt.image.BufferedImage; |
importjava.io.InputStream; |
importjava.lang.reflect.Method; |
importjava.util.Collections; |
importjava.util.HashMap; |
importjava.util.Map; |
importjavax.imageio.ImageIO; |
importjavax.swing.JApplet; |
importjavax.swing.JFrame; |
importjavax.swing.SwingUtilities; |
/** |
* Easy graphics for Java students and programmers interested in creating Java |
* graphical programs quickly. The more astute programmer may notice some odd |
* design choices - The design decisions (such as using class methods) is there |
* to simplify common use cases. This code is supplied 'as is' and no warranty |
* is provided. |
* |
* This code is copyright but free to use. It is provided under the scripts are |
* provided under the 'Attribution Creative Commons License' |
* http://creativecommons.org/licenses/by/3.0/ You may use it in any way |
* provided you preserve the following copyright statement and included it in |
* copyright information about your program. 'Zen Graphics' Copyright Lawrence |
* Angrave 2010. |
* |
* For an introduction to Zen Graphics Programming see the included examples. |
* |
* Notes for multi-threaded programmers (advanced). Zen Graphics uses |
* thread-local storage to tie a particular applet instance to a thread. Thus |
* beginning programmers can use static class methods Zen.drawText etc yet the |
* Zen Graphics will still function correctly in multi-threaded environments |
* such as web browser running multiple Zen applets. If you create a multi-threaded |
* programmer you must either always call Zen methods from the original main() thread |
* or, use the Zen.Master object returned by Zen.create(). |
* |
* Startup notes (advanced): If started as an applet the applet container |
* automatically calls init() and typically not in the GUI thread. The init |
* method notices that 'instance' is null and creates a new background thread to |
* call the 'main' method. |
* |
* If started from a main method. The user's program will at some point try to |
* draw something. This causes getInstance() to be invoked which lazily creates |
* an object instance and calls init. If the applet is stopped we should close |
* the main thread gracefully. |
* |
* @author angrave |
* |
*/ |
@SuppressWarnings('serial') |
publicclassZenextendsJApplet { |
publicstaticfinalDimensionDEFAULT_SIZE=newDimension(640, 480); |
publicstaticfinalStringDEFAULT_OPTIONS=''; |
protectedstaticfinalbooleanVERBOSE=false; |
publicstaticZenInstancecreate(intwidth, intheight, Stringoptions) { |
if (!mustBeAnWebApplet) |
mustBeAnApplication =true; |
synchronized (Zen.class) { |
ZenInstance instance = instanceMap.get(); |
if (instance null) { // no instance set for this thread |
JFrame frame =newJFrame(); |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
// System.err.println('Creating Instance'); |
Zen zen =newZen(); |
zen.bufferSize =newDimension(width, height); |
zen.bufferOptions = options; |
instanceMap.set(zen.master); |
Container pane = frame.getContentPane(); |
pane.add(zen); |
pane.setSize(zen.getSize()); |
pane.setMinimumSize(zen.getSize()); |
// frame.getContentPane().setIgnoreRepaint(true); |
zen.init(); |
frame.pack(); |
frame.setVisible(true); |
zen.start(); |
return zen.master; |
} |
return instance; |
} |
} |
publicstaticStringgetAboutMessage() { |
return'Zen Graphics (version 0.1) Copyright Lawrence Angrave, 2010'; |
} |
publicstaticvoidwaitForClick() { |
getInstanceFromThread().waitForClick(); |
} |
publicstaticintgetZenWidth() { |
return getInstanceFromThread().getZenWidth(); |
} |
publicstaticintgetZenHeight() { |
return getInstanceFromThread().getZenHeight(); |
} |
publicstaticintgetMouseClickX() { |
return getInstanceFromThread().getMouseClickX(); |
} |
publicstaticintgetMouseClickY() { |
return getInstanceFromThread().getMouseClickY(); |
} |
publicstaticlonggetMouseClickTime() { |
return getInstanceFromThread().getMouseClickTime(); |
} |
publicstaticvoidsetEditText(Strings) { |
getInstanceFromThread().setEditText(s); |
} |
publicstaticStringgetEditText() { |
return getInstanceFromThread().getEditText(); |
} |
publicstaticintgetMouseButtonsAndModifierKeys() { |
return getInstanceFromThread().getMouseButtonsAndModifierKeys(); |
} |
publicstaticintgetMouseX() { |
return getInstanceFromThread().getMouseX(); |
} |
publicstaticintgetMouseY() { |
return getInstanceFromThread().getMouseY(); |
} |
publicstaticvoidsleep(intmilliseconds) { |
try { |
Thread.sleep(milliseconds); |
} catch (Exception ignored) { |
} |
} |
publicstaticbooleanisKeyPressed(charkey) { |
return getInstanceFromThread().isKeyPressed(key); |
} |
publicstaticbooleanisVirtualKeyPressed(intkeyCode) { |
return getInstanceFromThread().isVirtualKeyPressed(keyCode); |
} |
publicstaticbooleanisRunning() { |
return getInstanceFromThread().isRunning(); |
} |
publicstaticGraphics2DgetBufferGraphics() { |
return getInstanceFromThread().getBufferGraphics(); |
} |
publicstaticvoiddrawImage(Stringfilename, intx, inty) { |
getInstanceFromThread().drawImage(filename, x, y); |
} |
publicstaticvoiddrawLine(intx1, inty1, intx2, inty2) { |
getInstanceFromThread().drawLine(x1, y1, x2, y2); |
} |
publicstaticvoiddrawText(Stringtext, intx, inty) { |
getInstanceFromThread().drawText(text, x, y); |
} |
publicstaticvoiddrawArc(intx, inty, intwidth, intheight, |
intstartAngle, intarcAngle) { |
getInstanceFromThread().drawArc(x, y, width, height, startAngle, |
arcAngle); |
} |
publicstaticvoidfillOval(intminX, intminY, intwidth, intheight) { |
getInstanceFromThread().fillOval(minX, minY, width, height); |
} |
publicstaticvoidfillRect(intx1, inty1, intwidth, intheight) { |
getInstanceFromThread().fillRect(x1, y1, width, height); |
} |
publicstaticvoidsetColor(intred, intgreen, intblue) { |
getInstanceFromThread().setColor(red, green, blue); |
} |
publicstaticintbound(intvalue, intmin, intmax) { |
if (value < min) |
return min; |
if (value > max) |
return max; |
return value; |
} |
publicstaticFontsetFont(Stringfontname) { |
return getInstanceFromThread().setFont(fontname); |
} |
publicstaticImagegetCachedImage(Stringfilename) { |
return getInstanceFromThread().getCachedImage(filename); |
} |
publicstaticvoidflipBuffer() { |
getInstanceFromThread().flipBuffer(); |
} |
/* |
* ----------------- Instance Methods ------------------------- |
*/ |
classZenInstance { |
publicvoidwaitForClick() { |
long t = mouseClickTime; |
// Todo: remove polling and use synchronization wait lock |
while (isRunning && t mouseClickTime) |
sleep(250); |
} |
publicintgetZenWidth() { |
return bufferSize.width; |
} |
publicintgetZenHeight() { |
return bufferSize.height; |
} |
publicintgetMouseClickX() { |
return mouseClickX; |
} |
publicintgetMouseClickY() { |
return mouseClickY; |
} |
publiclonggetMouseClickTime() { |
return mouseClickTime; |
} |
publicvoidsetEditText(Strings) { |
editText =newStringBuilder(s); |
} |
publicStringgetEditText() { |
return editText.toString(); |
} |
publicintgetMouseButtonsAndModifierKeys() { |
return mouseButtonsAndModifierKeys; |
} |
publicintgetMouseX() { |
return mouseX; |
} |
publicintgetMouseY() { |
return mouseY; |
} |
publicbooleanisKeyPressed(charkey) { |
return key >=0&& key < keyPressed.length ? keyPressed[key] |
:false; |
} |
publicbooleanisVirtualKeyPressed(intkeyCode) { |
return keyCode >=0&& keyCode < virtualKeyPressed.length ? virtualKeyPressed[keyCode] |
:false; |
} |
publicbooleanisRunning() { |
return isRunning; |
} |
publicGraphics2DgetBufferGraphics() { |
// getSingleton(); // ensure instance created |
while (g null) { |
System.err |
.println('Odd... graphics not yet ready! Sleeping...'); |
sleep(1000); // race-condition hack ; should never happen if the |
// container is correctly implemented |
} |
return g; |
} |
publicvoiddrawImage(Stringfilename, intx, inty) { |
Graphics2D g = getBufferGraphics(); |
Image img = getCachedImage(filename); |
if (img !=null) |
g.drawImage(img, x, y, null); |
else |
g.drawString(filename +'?', x, y); |
if (paintImmediately) |
paintWindowImmediately(); |
} |
publicvoiddrawLine(intx1, inty1, intx2, inty2) { |
getBufferGraphics().drawLine(x1, y1, x2, y2); |
if (paintImmediately) |
paintWindowImmediately(); |
} |
publicvoiddrawText(Stringtext, intx, inty) { |
getBufferGraphics().drawString(text, x, y); |
if (paintImmediately) |
paintWindowImmediately(); |
} |
publicvoiddrawArc(intx, inty, intwidth, intheight, |
intstartAngle, intarcAngle) { |
getBufferGraphics().drawArc(x, y, width, height, startAngle, |
arcAngle); |
if (paintImmediately) |
paintWindowImmediately(); |
} |
publicvoidfillOval(intminX, intminY, intwidth, intheight) { |
getBufferGraphics().fillOval(minX, minY, width, height); |
if (paintImmediately) |
paintWindowImmediately(); |
} |
publicvoidfillRect(intx1, inty1, intwidth, intheight) { |
getBufferGraphics().fillRect(x1, y1, width, height); |
if (paintImmediately) |
paintWindowImmediately(); |
} |
publicvoidsetColor(intred, intgreen, intblue) { |
currentColor =newColor(bound(red, 0, 255), bound(green, 0, 255), |
bound(blue, 0, 255)); |
getBufferGraphics().setColor(currentColor); |
} |
publicFontsetFont(Stringfont) { |
currentFont =Font.decode(font); |
getBufferGraphics().setFont(currentFont); |
return currentFont; |
} |
publicImagegetCachedImage(Stringfilename) { |
Image img = nameToImage.get(filename); |
if (img !=null) |
return img; |
try { |
InputStream is =Zen.class.getResourceAsStream(filename); |
img =ImageIO.read(is); |
is.close(); |
nameToImage.put(filename, img); |
return img; |
} catch (Exception ex) { |
// System.err.println('Can't load ' + filename + ' : ' |
// + ex.getMessage()); |
returnnull; |
} |
} |
publicvoidflipBuffer() { |
// Both flipBuffer and portions of paint() are synchronized |
// on the class object to ensure |
// that both cannot execute at the same time. |
paintImmediately =false; // user has called flipBuffer at least |
// once |
// getSingleton(); |
synchronized (Zen.this) { |
Image temp = backImageBuffer; |
backImageBuffer = frontImageBuffer; |
frontImageBuffer = temp; |
if (g !=null) |
g.dispose(); |
paintWindowImmediately(); // paint to Video |
g = (Graphics2D) backImageBuffer.getGraphics(); |
g.setColor(Color.BLACK); |
g.fillRect(0, 0, backImageBuffer.getWidth(null), |
backImageBuffer.getHeight(null)); |
g.setColor(currentColor); |
g.setFont(currentFont); |
} |
} |
voidcreateBuffers(intwidth, intheight, Stringoptions) { |
if (g !=null) |
g.dispose(); |
if (frontImageBuffer !=null) |
frontImageBuffer.flush(); |
if (backImageBuffer !=null) |
backImageBuffer.flush(); |
options = options !=null? options.toLowerCase() :''; |
bufferSize =newDimension(width, height); |
stretchToFit = options.contains('stretch'); |
// if buffers are requested _after_ the window has been realized |
// then faster volatile images are possible |
// BUT volatile images silently fail when tested Vista IE8 and |
// JRE1.6 |
boolean useVolatileImages =false; |
if (useVolatileImages) { |
try { |
// Paint silently fails when tested in IE8 Vista JRE1.6.0.14 |
backImageBuffer = createVolatileImage(width, height); |
frontImageBuffer = createVolatileImage(width, height); |
} catch (Exception ignored) { |
} |
} |
if (!GraphicsEnvironment.isHeadless()) { |
try { |
GraphicsConfiguration config =GraphicsEnvironment |
.getLocalGraphicsEnvironment() |
.getDefaultScreenDevice().getDefaultConfiguration(); |
backImageBuffer = config.createCompatibleImage(width, |
height); |
frontImageBuffer = config.createCompatibleImage(width, |
height); |
} catch (Exception ignored) { |
} |
} |
// as a fall-back we can still use slower BufferedImage with |
// arbitrary RGB model |
if (frontImageBuffer null) { |
// System.err.println('Creating BufferedImage buffers'); |
backImageBuffer =newBufferedImage(bufferSize.width, |
bufferSize.height, BufferedImage.TYPE_INT_RGB); |
frontImageBuffer =newBufferedImage(width, height, |
BufferedImage.TYPE_INT_RGB); |
} |
master.flipBuffer();// set up graphics, including font and color |
// state |
paintImmediately =true; // actually, user has not yet called |
// flipBuffer |
} |
}; // End class ZenMaster |
/* |
* --------------------- IMPLEMENTATION ---------------------- |
*/ |
privatestaticThreadLocal<ZenInstance> instanceMap =newThreadLocal<ZenInstance>(); |
privatestaticsynchronizedZenInstancegetInstanceFromThread() { |
ZenInstance instance = instanceMap.get(); |
return instance !=null? instance : create(DEFAULT_SIZE.width, |
DEFAULT_SIZE.height, DEFAULT_OPTIONS); |
} |
privatestaticboolean mustBeAnApplication; // true if create called init |
privatestaticboolean mustBeAnWebApplet; // true if init called before |
// create |
privateZenInstance master =newZenInstance(); |
privateGraphics2D g; |
privateImage backImageBuffer, frontImageBuffer; |
privateMap<String, Image> nameToImage =Collections |
.synchronizedMap(newHashMap<String, Image>()); |
privateboolean stretchToFit; |
privateboolean[] keyPressed =newboolean[256]; |
privateboolean[] virtualKeyPressed =newboolean[1024]; |
privateint mouseX, mouseY, mouseClickX, mouseClickY; |
privatelong mouseClickTime; |
privateStringBuilder editText =newStringBuilder(); |
privateDimension bufferSize =newDimension(DEFAULT_SIZE); |
privateString bufferOptions =DEFAULT_OPTIONS; |
privateColor currentColor =Color.WHITE; |
privateFont currentFont =Font.decode('Times-18'); |
privateint mouseButtonsAndModifierKeys; |
privateboolean isRunning =true; |
privateThread mainThread; |
privateint paintAtX, paintAtY, windowWidth, windowHeight; |
protectedboolean paintImmediately; |
publicDimensiongetMinimumSize() { |
return bufferSize; |
} |
publicfinalDimensiongetPreferredSize() { |
return getMinimumSize(); |
} |
// JApplet methods |
publicfinalvoidinit() { |
if (!mustBeAnApplication) |
mustBeAnWebApplet =true; |
instanceMap.set(master); |
setSize(bufferSize); |
SwingUtilities.invokeLater(newRunnable() { |
publicvoidrun() { |
addMouseListener(mouseListener); |
addMouseMotionListener(mouseMotionListener); |
addKeyListener(keyListener); |
setFocusTraversalKeysEnabled(false); |
setFocusable(true); |
setVisible(true); |
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); |
} // run |
}); |
} |
@SuppressWarnings('deprecation') |
publicfinalvoidstop() { |
isRunning =false; |
if (mainThread null) |
return; |
mainThread.interrupt(); |
sleep(500); |
if (mainThread.isAlive()) |
mainThread.stop(); |
mainThread =null; |
} |
@Override |
publicfinalvoidstart() { |
master |
.createBuffers(bufferSize.width, bufferSize.height, |
bufferOptions); |
isRunning =true; |
if (mustBeAnWebApplet) { |
mainThread =newThread('main') { |
publicvoidrun() { |
if (VERBOSE) |
System.out.println('Starting main thread...'); |
try { |
instanceMap.set(Zen.this.master); |
String paramKey ='zen-main-class'; |
String classNameToRunForApplet = getParameter(paramKey); |
if (classNameToRunForApplet null) { |
String mesg = paramKey |
+' parameter is not set; where is your main method?'; |
System.err.println(mesg); |
setFont('Courier-12'); |
drawText(mesg, 0, 10); |
return; |
} |
Class<?> clazz =Class.forName(classNameToRunForApplet); |
String[] argValue =newString[0]; |
Class<?>[] argTypes = { argValue.getClass() }; |
Method main = clazz.getMethod('main', argTypes); |
// System.err.println(clazz + '.main()...'); |
main.invoke(null, newObject[] { argValue }); |
} catch (ThreadDeath ignored) { |
} catch (Exception ex) { |
System.err.println('Exception:'+ ex.getMessage()); |
ex.printStackTrace(); |
setFont('Courier-12'); |
drawText(ex.toString(), 0, 12); |
} finally { |
instanceMap.remove(); |
} |
} // end method |
}; |
mainThread.start(); |
} |
} |
publicfinalvoiddestroy() { |
super.destroy(); |
} |
@Override |
publicvoidupdate(GraphicswindowGraphics) { |
paint(windowGraphics); |
} |
@Override |
publicvoidpaint(GraphicswindowGraphics) { |
if (windowGraphics null) |
return; |
windowWidth = getWidth(); |
windowHeight = getHeight(); |
if (frontImageBuffer null) { |
// no image to display |
windowGraphics.clearRect(0, 0, windowWidth, windowHeight); |
return; |
} |
synchronized (Zen.class) { |
Image image = paintImmediately ? backImageBuffer : frontImageBuffer; |
if (stretchToFit) { |
paintAtX = paintAtY =0; |
windowGraphics.drawImage(image, 0, 0, windowWidth, |
windowHeight, this); |
} else { // Blacken unused sides |
int x = windowWidth - bufferSize.width; |
int y = windowHeight - bufferSize.height; |
paintAtX = x /2; |
paintAtY = y /2; |
windowGraphics.setColor(Color.BLACK); |
// Notes: Some of the +1's may be unnecessary. |
// Notes: Actually there's some overlap in the 4 corners that |
// could |
// be removed |
if (y >0) { |
windowGraphics.fillRect(0, 0, windowWidth +1, paintAtY); |
windowGraphics.fillRect(0, windowHeight - paintAtY -1, |
windowWidth +1, paintAtY +1); |
} |
if (x >0) { |
windowGraphics.fillRect(0, 0, paintAtX +1, |
windowHeight +1); |
windowGraphics.fillRect(windowWidth - paintAtX -1, 0, |
paintAtX +1, windowHeight +1); |
} |
windowGraphics.drawImage(image, paintAtX, paintAtY, this); |
} |
} |
} // paint |
privatevoidpaintWindowImmediately() { |
Graphics windowGraphics = getGraphics(); |
// IE8 windowGraphics is not null |
if (VERBOSE) |
System.err.println('paintWindowImmediately graphics=' |
+ windowGraphics); |
if (windowGraphics !=null) |
paint(getGraphics()); |
else |
repaint(); |
} |
privateKeyListener keyListener =newKeyAdapter() { |
publicvoidkeyPressed(KeyEvente) { |
char c = e.getKeyChar(); // may be CHAR_UNDEFINED |
mouseButtonsAndModifierKeys = e.getModifiersEx(); |
if (c >=0&& c < keyPressed.length) |
keyPressed[c] =true; |
int vk = e.getKeyCode(); |
if (vk >=0&& vk < virtualKeyPressed.length) |
virtualKeyPressed[vk] =true; |
} |
publicvoidkeyReleased(KeyEvente) { |
char c = e.getKeyChar(); // may be CHAR_UNDEFINED |
mouseButtonsAndModifierKeys = e.getModifiersEx(); |
if (c >=0&& c < keyPressed.length) |
keyPressed[c] =false; |
int vk = e.getKeyCode(); |
if (vk >=0&& vk < virtualKeyPressed.length) |
virtualKeyPressed[vk] =false; |
} |
publicvoidkeyTyped(KeyEvente) { |
char typed = e.getKeyChar(); |
if (!Character.isISOControl(typed)) |
editText.append(typed); |
elseif (typed 8&& editText.length() >0) |
editText.deleteCharAt(editText.length() -1); |
} |
}; // KeyListener |
privateMouseListener mouseListener =newMouseAdapter() { |
@Override |
publicvoidmouseClicked(MouseEventme) { |
if (windowWidth 0|| windowHeight 0) |
return; // no display window yet |
mouseClickX = (stretchToFit ? (int) (0.5+ me.getX() |
* bufferSize.width / (double) windowWidth) : me.getX() |
- paintAtX); |
mouseClickY = (stretchToFit ? (int) (0.5+ me.getY() |
* bufferSize.height / (double) windowHeight) : me.getY() |
- paintAtY); |
mouseClickTime = me.getWhen(); |
} |
}; // MouseListener |
privateMouseMotionListener mouseMotionListener =newMouseMotionAdapter() { |
publicvoidmouseMoved(MouseEventme) { |
if (windowWidth 0|| windowHeight 0) |
return; // no display window yet |
mouseX = (stretchToFit ? (int) (0.5+ me.getX() * bufferSize.width |
/ (double) windowWidth) : me.getX() - paintAtX); |
mouseY = (stretchToFit ? (int) (0.5+ me.getY() * bufferSize.height |
/ (double) windowHeight) : me.getY() - paintAtY); |
mouseButtonsAndModifierKeys = me.getModifiersEx(); |
} |
publicvoidmouseDragged(MouseEvente) { |
mouseListener.mouseClicked(e); |
mouseMoved(e); |
} |
}; // MouseMotionListener |
};// End of class |
Copy lines Copy permalink
Posted by1 year ago
![Astute graphics plugins keygen Astute graphics plugins keygen](https://astutegraphics.com/wp-content/uploads/2016/06/ShortCuts-Blog-Image-17.png)
Archived
Hello! I'm studying to become a graphic designer (started at Uni this fall), and my teachers has encourage us experiment with Illustrator to get the hang of it. Especially the pen tool. The problem is that I don't really know what to do the get better at using all the tools?
Does anyone know any good sites that offer Illustrator exercises? I know about the Bezier Game but the site keeps bugging for me...
(Sorry if this breaks any rules, I'm new here! Also, sorry if my English is off, I'm from Sweden.)
93% Upvoted