Code of line drawing algorithm
anybody can tell me code of line drawing algorithm..if i hav two points a(x1,y1) and b(x2,y2) then
how kan i draw line using these points..
Use drawLine(int x1, int y1, int x2, int y2).
As I understand it you should only do the drawing in a paint method (or paintComponent method if you're using swing.) If you're wanting the lines to be "permanent" then draw to a drawing.
e.g. from a Logo/Turtle prog that I'm working on:
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if ( ! initDone ) {
i_drawing = (BufferedImage)createImage(700,500);
g_drawing = i_drawing.createGraphics();
initDone=true;
if (penDown && drawOp) {
g_drawing.drawLine((int)posX, (int)posY, (int)targX, (int)targY);
drawOp = false;
g.drawImage(i_drawing, 0, 0, this);
posX = targX;
posY = targY;
This draws the line on the image (i_drawing) and then displays the image.
Hope this helps.
Similar Messages
-
[SOLVED] terminals & line drawing characters problem
I use quite some escape sequences in my bash prompt, amongst them a few that produce line drawing characters. Works fine in the virtual consoles (tty), but no terminals in X (tried xterm, terminal, urxvt) display them correctly, for some reason. My locale settings seem fine, and I've tried various fonts (including the one I use in the virtual consoles).
What could the issue be?
FYI, my bash prompt variable. Does it display correctly for you?
DRED='\e[0;31m'
DGREEN='\e[0;32m'
DYELLOW='\e[0;33m'
DBLUE='\e[0;34m'
DPURPLE='\e[0;35m'
DCYAN='\e[0;36m'
DWHITE='\e[0;37m'
LRED='\e[1;31m'
LGREEN='\e[1;32m'
LYELLOW='\e[1;33m'
LBLUE='\e[1;34m'
LPURPLE='\e[1;35m'
LCYAN='\e[1;36m'
LWHITE='\e[1;37m'
COLRESET='\e[0m'
PS1="\n\[$DBLUE\]\[\016\]l\[\017\]\[$DRED\](\u@\h)\[$DBLUE\]\[\016\]qqq\[\017\](\[$LBLUE\]H\!\[$DBLUE\])\[\016\]qq\[\017\](\[$LBLUE\]C\#\[$DBLUE\])\[\016\]qq\[\017\](\[$LBLUE\]J\j\[$DBLUE\])\[\016\]qqq\[\017\](\[$LBLUE\]\D{%H:%M %A %d - %B %Y}\[$DBLUE\])\n\[\016\]t\[\017\]\[\016\]q\[\017\](\[\[$LBLUE\]\w\[$DBLUE\])\n\[\016\]mqq\[\017\]> \[$LBLUE\]"
Last edited by Mzg (2010-07-09 10:00:41)After some detective work I have managed to come up with an explanation as well as what seems to be a working solution.
If you have not tried the prompt above, basically I tried to use some line drawing characters in my bash prompt, but these refused to display correctly under any X terminals I tried (though it looked fine on virtual consoles).
The problem was in the
\[\016\] ... \[\017\]
sequences. The \016 escape sequence is supposed to enter the alternate character set mode (common way to draw e.g. lines in text mode) while \017 returns the terminal to the standard character set. These work fine on the virtual consoles, but are apparently a no-no in (some) X terminals. If you tried the prompt you would notice that the color escape sequences worked fine, only the line drawing characters failed.
So that is the explanation part. So for the solution...
For urxvt, which is my preferred terminal emulator, the solution is quite simple. This should also work with other rxvt-derived terminals (including the popular aterm), though I have not tested this.
These terminals offer the same functionality as the virtual consoles, though the escape sequences are different. "\033(0" enters alternate charset mode while "\033(B" returns to standard charset mode. So the solution is simply to replace all previous
\[\016\] ... \[\017\]
sequences with
\[\033(0\] ... \[\033(B\]
But this poses a problem, as the virtual consoles do not recognize these sequences and you'll get the same problem as before, only in text mode instead of X. I solved this by using the PROMPT_COMMAND variable to run fgconsole every time a command is ran in bash, checking if the command is ran in tty7 (i.e. X11) or in one of the (other) virtual consoles. This is my code for the root prompt:
DRED='\e[0;31m'
DGREEN='\e[0;32m'
DYELLOW='\e[0;33m'
DBLUE='\e[0;34m'
DPURPLE='\e[0;35m'
DCYAN='\e[0;36m'
DWHITE='\e[0;37m'
LRED='\e[1;31m'
LGREEN='\e[1;32m'
LYELLOW='\e[1;33m'
LBLUE='\e[1;34m'
LPURPLE='\e[1;35m'
LCYAN='\e[1;36m'
LWHITE='\e[1;37m'
COLRESET='\e[0m'
function prompt_func
# Running in tty7 or larger (X11)
if [ `sudo fgconsole` -gt 6 ]
then
PS1="\n\[$DBLUE\]\[\033(0\]l\[\033(B\]\[$DRED\](\u@\h)\[$DBLUE\]\[\033(0\]qqq\[\033(B\](\[$LBLUE\]H\!\[$DBLUE\])\[\033(0\]qq\[\033(B\](\[$LBLUE\]C\#\[$DBLUE\])\[\033(0\]qq\[\033(B\](\[$LBLUE\]J\j\[$DBLUE\])\[\033(0\]qqq\[\033(B\](\[$LBLUE\]\D{%H:%M %A %d - %B %Y}\[$DBLUE\])\n\[\033(0\]t\[\033(B\]\[\033(0\]q\[\033(B\](\[\[$LBLUE\]\w\[$DBLUE\])\n\[\033(0\]mqq\[\033(B\]> \[$LBLUE\]"
else
PS1="\n\[$DBLUE\]\[\016\]l\[\017\]\[$DRED\](\u@\h)\[$DBLUE\]\[\016\]qqq\[\017\](\[$LBLUE\]H\!\[$DBLUE\])\[\016\]qq\[\017\](\[$LBLUE\]C\#\[$DBLUE\])\[\016\]qq\[\017\](\[$LBLUE\]J\j\[$DBLUE\])\[\016\]qqq\[\017\](\[$LBLUE\]\D{%H:%M %A %d - %B %Y}\[$DBLUE\])\n\[\016\]t\[\017\]\[\016\]q\[\017\](\[\[$LBLUE\]\w\[$DBLUE\])\n\[\016\]mqq\[\017\]> \[$LBLUE\]"
fi
PROMPT_COMMAND=prompt_func
Note that I do not claim to be a good bash programmer, so there might be better ways. This has however worked flawlessly so far, including when su'ing to other users, and switching between tty's and X.
The code is the same for my other users, except from the colors. Note the
`sudo fgconsole`
Sudo proved necessary for non-root users. I added an entry in the sudoers config file to let all users run fgconsole as root without providing a password.
Okay, that's it. It's a bit dirty, but it solved my problem at least.
Last edited by Mzg (2010-07-10 07:06:44) -
Unicode line-drawing characters - possible Java bug?
Hi all, I am trying to draw a box using line drawing characters in UTF-8. I make the UTF-8 box file in Microsoft Word where it looks aligned. However, when I run my Java program to display the box in a JTextArea, it is all out of alignment like below. Is this a bug in Java that prevents it from displaying aligned line-drawing characters? I am tearing my hair out over this so your help is much appreciated.
Regards,
Rianmal.
╔═══════════════════╗
║║║║║║║║║║║║║║║║║║║║║
║ ║
║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
╚═══════════════════╝sabre,
Looks like monospaced isn't found on windows (vista)... So I used "Courier New" instead.
Sabre20090412a.java is saved with encoding=UTF-8 (i.e. CP1252) instead of the default ASCII, which doesn't support the extended characters.
package forums;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class Sabre20090412a
private static final String text;
static {
String t;
t = "╔═══════════════════╗\n"; // LINE 12
t += "║║║║║║║║║║║║║║║║║║║║║\n";
t += "║ ║\n";
t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
t += "╚═══════════════════╝\n"; // LINE 23
text = t;
public static void createAndShowGUI() {
final JFrame frame = new JFrame("Test");
final JTextArea ta = new JTextArea();
ta.setFont(new Font("Courier New", Font.PLAIN, 14)); // <<<<< Note font-name="Courier New"
ta.setText(text);
frame.setContentPane(ta);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
build (NOTE the -encoding utf-8)*
cd /d C:\Java\home\src\forums
"C:\Program Files\Java\jdk1.6.0_12\bin\javac.exe" -encoding utf-8 -Xlint -d C:\Java\home\classes -cp c:\java\home\src;.;C:\Java\home\classes C:\Java\home\src\forums\Sabre20090412a.java
run
cd /d C:\Java\home\src\forums
"C:\Program Files\Java\jdk1.6.0_12\bin\java.exe" -cp C:\Java\home\classes forums.Sabre20090412a
References:
http://www.google.com/search?q=warning%3A+unmappable+character+for+encoding+Cp1252&hl=en
http://en.wikipedia.org/wiki/Windows-1252 #says 1252== IANIA UTF-8 except
http://www.utf8-chartable.de/unicode-utf8-table.pl #page for 2500 onwards
http://forums.sun.com/thread.jspa?threadID=5185338 #-encoding
http://www.java2s.com/Code/Java/2D-Graphics-GUI/Listallavailablefontsproviedinthesystem.htm
Roedy Green rocks!
http://mindprod.com/jgloss/font.html#AVAILABLEJ
http://mindprod.com/applet/fontshower.html
Thanx for the fish!
Cheers. Keith. -
I am looking for a smoothe line drawing effect as in the pencil tool in Flash. I need to implement the same using as3. Any idea how I can achieve that?
Smoothness is a relative concept. Pencil tool in Flash doesn't produce very smooth lines. Nevertheless, runtime drawing smoothness depends on how often you draw lines between points. Here is a quick and dirty drawing board (just paste it on timeline). If you want it even smoother - you will need to write an algorithm that takes into account direction, speed, angles, etc.
var board:Sprite = new Sprite();
addChild(board);
board.x = board.y = 20;
var g:Graphics = board.graphics;
g.beginFill(0xcccccc);
g.drawRect(0, 0, stage.stageWidth - 40, stage.stageHeight - 40);
g.endFill();
board.addEventListener(MouseEvent.MOUSE_DOWN, startDraw);
function draw(e:MouseEvent):void {
g.lineTo(board.mouseX, board.mouseY);
function startDraw(e:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_UP, stopDraw);
addEventListener(MouseEvent.MOUSE_MOVE, draw);
g.lineStyle(1, Math.random() * 0xffffff);
g.moveTo(board.mouseX, board.mouseY);
function stopDraw(e:MouseEvent):void {
removeEventListener(MouseEvent.MOUSE_MOVE, draw);
stage.removeEventListener(MouseEvent.MOUSE_UP, stopDraw); -
Simple line drawing project in swing
hi folks,
i want to write a simple line drawing project. it has a JPanel, a JFrame and JButton.
JPanel and JButton are on JFrame. When Button is clicked,
a line will be added to JPanel but previous lines which have been added are not removed on JPanel.
Could you please help me?i wrote below codes but it adds first line but when click button �n order to add line, it is not adding line. Please help and thanxs...
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Line2D;
import java.util.Enumeration;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;
public class NewJFrame extends javax.swing.JFrame implements ActionListener {
private JButton addButton;
MainPanel mainPane ;
public Vector lines ;
* Auto-generated main method to display this JFrame
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
NewJFrame inst = new NewJFrame();
inst.getContentPane().add(new MainPanel(inst.lines));
inst.setLocationRelativeTo(null);
inst.setVisible(true);
public NewJFrame() {
super();
initGUI();
lines = new Vector();
lines.add(0, 30);
addButton.addActionListener(this);
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
addButton = new JButton();
getContentPane().add(addButton, BorderLayout.SOUTH);
addButton.setText("ADD");
addButton.setPreferredSize(new java.awt.Dimension(71, 21));
pack();
setSize(400, 300);
} catch (Exception e) {
e.printStackTrace();
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == addButton){
lines.addElement(Integer.parseInt(lines.get(0).toString())+30);
mainPane.repaint();
class MainPanel extends JComponent {
Vector tempLines ;
MainPanel(Vector lines){
tempLines = lines;
setBackground(Color.white);
public void paintComponent(Graphics g) {
Enumeration enumeration = tempLines.elements();
while(enumeration.hasMoreElements()) {
Integer point = Integer.parseInt(enumeration.nextElement().toString());
Line2D line = new Line2D.Double(30, point, 200, point);
Graphics2D g2d = (Graphics2D)g;
g2d.setStroke(new BasicStroke(5));
g2d.draw(line);
} -
Curious font name..., 'Reveal Line Draw'?
Hello there.
I just wrote a GUI program which displays fonts and some rendered images for styles.
And I got a font named 'Reveal Line Draw'.
What is it? Is it just an instance of valid font?
Maybe my question can be 'Revealed' as one as some stupid... :)
Here comes my source code.
Please try to compile it and run it.
And, maybe, you can find that thing.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JRootPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
public class FontViewer {
public static void main(String[] args) {
final String[] fontFamilyNames = GraphicsEnvironment.
getLocalGraphicsEnvironment().
getAvailableFontFamilyNames();
final String[] columnNames =
{"NAME", "PLAIN", "BOLD", "ITALIC", "BOLD ITALIC"};
new JFrame("Font Viewer") {
@Override
protected JRootPane createRootPane() {
return new JRootPane() {
@Override
protected Container createContentPane() {
return new JScrollPane(new JTable() {
protected TableModel createDefaultDataModel() {
return new AbstractTableModel() {
@Override
public Class getColumnClass(
int columnIndex) {
return Font.class;
@Override
public String getColumnName(int column) {
return columnNames[column];
public int getColumnCount() {
return columnNames.length;
public int getRowCount() {
return fontFamilyNames.length;
public Object getValueAt(int rowIndex,
int columnIndex) {
return null;
@Override
protected void createDefaultRenderers() {
super.createDefaultRenderers();
defaultRenderersByColumnClass.put(
Font.class, new DefaultTableCellRenderer() {
@Override
public Component
getTableCellRendererComponent(
JTable table, Object value,
boolean isSelected,
boolean hasFocus, int row,
int column) {
Font font =
Font.decode(fontFamilyNames[row]);
Component renderer =
super.getTableCellRendererComponent(
table, font.getName(),
isSelected, hasFocus, row,
column);
if (column == 1) {
renderer.setFont(font.deriveFont(
Font.PLAIN));
} else if (column == 2) {
renderer.setFont(font.deriveFont(
Font.BOLD));
} else if (column == 3) {
renderer.setFont(font.deriveFont(
Font.ITALIC));
} else if (column == 4) {
renderer.setFont(font.deriveFont(
Font.BOLD|Font.ITALIC));
return renderer;
@Override
protected void processWindowEvent(WindowEvent we) {
super.processWindowEvent(we);
if (we.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
@Override
public void frameInit() {
super.frameInit();
setSize(600, 400);
}.setVisible(true);
}Here are my printed font names. And I just wanna know what the bolded font works for?
Acutally it doesn't show any renderred image on my source.
WindowsXP SP2 JRE 1.5.0U5
Agency FB
Arial
Arial Black
Arial Narrow
Arial Rounded MT
Batang
BatangChe
Blackadder ITC
Bodoni MT
Bodoni MT Black
Bodoni MT Condensed
Book Antiqua
Bookman Old Style
Bookshelf Symbol
Bradley Hand ITC
Calisto MT
Castellar
Century Gothic
Century Schoolbook
Comic Sans MS
Copperplate Gothic
Copperplate Gothic Light
Courier New
Curlz MT
Dialog
DialogInput
Dotum
DotumChe
Edwardian Script ITC
Elephant
Engravers MT
Eras Bold ITC
Eras Demi ITC
Eras Light ITC
Eras Medium ITC
Estrangelo Edessa
Felix Titling
Forte
Franklin Gothic Book
Franklin Gothic Demi
Franklin Gothic Demi Cond
Franklin Gothic Heavy
Franklin Gothic Medium
Franklin Gothic Medium Cond
French Script MT
Garamond
Gautami
Georgia
Gigi
Gill Sans MT
Gill Sans MT Condensed
Gill Sans MT Ext Condensed
Gill Sans Ultra
Gill Sans Ultra Bold Condensed
Gloucester MT Extra Condensed
Goudy Old Style
Goudy Stout
Gulim
GulimChe
Gungsuh
GungsuhChe
Haettenschweiler
Impact
Imprint MT Shadow
Kartika
Latha
Lucida Bright
Lucida Console
Lucida Sans
Lucida Sans Typewriter
Lucida Sans Unicode
Maiandra GD
Mangal
Marlett
Microsoft Sans Serif
MingLiU
Monospaced
Monotype Corsiva
MS Gothic
MS Mincho
MS Outlook
MS PGothic
MS PMincho
MS Reference Sans Serif
MS Reference Specialty
MS UI Gothic
MV Boli
NSimSun
OCR A Extended
Palace Script MT
Palatino Linotype
Papyrus
Perpetua
Perpetua Titling MT
PMingLiU
Pristina
Quest Font
Raavi
Rage
Reveal Line Draw <<<<<<<<<<<<<<<< @@?
Rockwell
Rockwell Condensed
Rockwell Extra
SansSerif
Script MT
Serif
Shruti
SimHei
SimSun
Sylfaen
Symbol
Tahoma
Times New Roman
Trebuchet MS
Tunga
Tw Cen MT
Tw Cen MT Condensed
Tw Cen MT Condensed Extra
Verdana
Vrinda
Webdings
Wingdings
Wingdings
Wingdings
ZWAdobeF -
i have a line drawing (black on white paper) i have scanned and need to make the white paper transparent, maintaining the line drawing, can i and then HOW can i do this in PS? this is for my business logo. ive used it for years but with a solid background. id like to have it just be the drawing over my photos with a transparent background.
First let me apologize for posting a reply that was only suitable for advanced users. Photoshop is broad and powerful therefore has a huge learning curve. In fact I would state no one knows and uses all of Photoshop. When we first get Photoshop it intimidate us and we're very uncomfortable using it. Many thing are not intuitive there in much learning involved. After some time we begin to know something and we are able to do some thing. Learning become rapid and we start playing in Photoshop. It is very important to play with Photoshop. Playing with Photoshop and asking for help with in forums like this IMO is the best way to learn.
Photoshop Power lies in layers, selection and automation. However it takes knowledge to use photoshop well so most powerful tool you have ins Photoshop is the gray matter between your ears. Most at one time or another want to watermark or put a logo on their image. So its best to automate this process. All run into a problem in the process. "Size" We find our assets vary in size and aspect ratios. Landscape, Portraits, Panoramas and others. This complicates automation. Vector graphics works best when size vary greatly. If you can not work out how to create a vector solution like a custom shape. Create your Logo and watermark large thing scale down better the up. Text scale well for text uses vectors graphics however if you rasterize text it will not scale well.
I do not type or do English well so let me do some screen captures. I can not stress enough how important Black, White, Grays and Blending is when it come to image processing. Become friends with Multiply, Screen, Overlay and Luminosity blending.....
However when there is a white or black background though you can blend them you can not add a style like a drop shadow, emboss or make it invisible setting fill to 0 so only the style is visible. When there is contrast between the logo and background it is easy to separate the two. To select the background and delet it to have the logo with a transparent background. Many tools can be used to create the selection hee I use my action kill white.
Vector Shape would work better for scaling However it would be best to create the logo from scratch in a vector program like illustrator but I never had the resources to justify the Creative suite. I only had Photoshop. Recently Adobe gave me and other a year subscription to the creative suite for our participation here. I still have not installed anything but Photoshop, A while back I found a program that can create vector patf for black and white art work. It will not be as good as using something like illustrator. However vector paths can be edited in Photoshop and cleaned up some. Here is the PSD it 13MB because od the gradient http://www.mouseprints.net/old/dpr/AmPm24-7.psd -
Is it possible to have more than one Tax code per line item in Billing docu
Is it possible to have more than one Tax code per line item in Billing document ?
Hi,
I have a different perspective there.
If an item is applicable for two different taxes which are represented by two different tax condition types and these tax conditions are configured in the tax procedure, FTXP and so on....then these two condition records can have two different tax codes.
We actually have this scenario in EU now, where EU talks about service tax in 2010 apart from the normal VAT. So now we have MWST and ZWST(Say)
Now there are some materials which come with a service associated with it. So a service charge is also levied when the material is sold. So the material price will become applicable for VAT and the service charge becomes applicable for service tax. In this case, the tax classification of the customer will have two entries in sales orders updated in the fields VBAK-TAXK1 and VBAK-TAXK2 based on the sequence number of these condition types.
Now based on different tax classification of the customer, we have 2 different tax codes representing different %of tax.
Hope it helps -
I tried to import a PDF of a line drawing into Photoshop Elements. The thumbnail looks fine, but when imported the file is empty. This used to work in the past. What is wrong and how do I solve this?
Hi
The value of the Channel Strip volume etc is not stored within the C Strip setting, as you have discovered.
If you really wanted, you could add a Gain plug to the strip, with it set to give the correct output level with the Fader set to 0
(Or just set the fader manually in MS)
CCT -
Hi, odd error in my code with a draw circle method
Hey, I am a first year computer science student who uses java in class.
We have recently been playing with guis
I have created code that when it runs it draws random circles with random gradiants.
However, the code will sometimes draw a random square, any ideas.
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
* Class for animations, if I dont finish this lab I will have egg on my face
public class AnimationStation {
private JFrame frame; //the jframe
private IView viewer; //the viewer
* Constructor
public AnimationStation() {
frame = new JFrame(); //makes jframe
viewer = new IView(); //makes iview
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //window closes
frame.setSize(300, 500); //biggie or smallie
frame.getContentPane().add(BorderLayout.CENTER,viewer); //place it
frame.setVisible(true);
* Main Method
public static void main(String[] args) {
AnimationStation cutie = new AnimationStation();
* The IView inner class
class IView extends JPanel {
int x = 0; //x pos
int y = 0; //w pos
int d = 0; //diameter
Color randomColor1; //random color
Color randomColor2; // random color
private boolean imageOn = true; //do we care about the background, or are we looking for that square?
* Default constructor
public IView() {
//wonders... is this neccessary.... ::thinks:: well it works so lets not mess with it
* Builds our pretty pictures
public void paintComponent(Graphics g) {
g.setColor(Color.white); //make background
g.fillRect(0,0,this.getWidth(),this.getHeight()); //background
for(int x = 0; x < 10; x++) { //no? draw ovals
drawOval(g);
* Method to make ovals
*(and apparently a random square, although I think its good luck if you do! So its a feature, not a bug)
public void drawOval(Graphics g) {
d = (int)((Math.random() * 10) + (this.getWidth() / 5)); //set diameter
x = (int)(Math.random() * (this.getWidth() - d)); //set x dont let it off the screen
y = (int)(Math.random() * (this.getHeight() - d)); //set y dont let it off the screen
randomColor1 = randomColor(); //set random color one
randomColor2 = randomColor(); //set random color two
Graphics2D g2d = (Graphics2D) g; //make a graphics 2d object, helps with gradiants
GradientPaint gradient; //make gradiant
gradient = new GradientPaint(x, y, randomColor1, x+d, y+d, randomColor2); //set gradiant
g2d.setPaint(gradient); //set paint
g2d.fillOval(x,y,d,d); //make that oval
* Method which makes a random color
public Color randomColor() {
Color a = new Color((int)(Math.random() * 255), (int)(Math.random() * 255), (int)(Math.random() * 255));
return a;
* Checks to see if a file is an image file (I REALLY hope this is not how other programs do it,
* becuase technically I can make this a graphic "mv ImageViewer.java fake.gif")
public boolean isImageFile(String filename) {
String ending = "" + filename.charAt(filename.length() - 4) + filename.charAt(filename.length() - 3) + filename.charAt(filename.length() - 2) +
filename.charAt(filename.length() - 1); //make a string with the last four letters
if(ending.equalsIgnoreCase(".jpg") || ending.equalsIgnoreCase(".gif") || ending.equalsIgnoreCase(".bmp")) { //is it an image?
return true; //yes
} else {
return false; //no
}thanks,
Bachmannwell, let me explain some more. Its more of an irritation, then a crippling error....
The squares are quite clear. I mean, its not like a small circle that looks squareish, I have seen a square appear and it could be larger than the circles that I see.
It is also very rare, so yeah, it could have something to do with the random aspects.
It just kinda bothers me since nither me, my classmates, or my professor can figure out why this happens and no one else has mentioned this problem. -
Convert a photo to a single line drawing
It seems I've seen this in one of the photoshop tips & tricks books but did not buy the book. Any suggestions will be appreciated.
http://www.myjanee.com/tuts/linedraw/linedraw.htm
Also, Google for "photoshop elements line drawing" or similar. -
Want to do pencil line drawing based on photograph
PS Elements has a really neat quick line drawing effect. I'd like to do something similar in PS CS3. Does anyone know how? I've been trying the sketch filter, but it doesn't seem quite as nicely done. Can I use that action out of my elements folder in CS3? Elements regularly freezes my computer which is why I'm not using it any longer and intend to uninstall soon.
THanks!It all depends on the original.
You might have success with Image > Mode > Grayscale
Then increase Contrast via Image > Adjustments
followed by Filter > Stylize > Find Edges and a Threshold adjustment if necessary.
You have to experiment! -
Enter the Section code for line number '000'
Dear Consultants,
While posting the Travel Expenses, The system generates posting documents but gives error as "Enter the Section code for line number '000'". Please advise me about the activity to which this error is related to. I am giving Document type as AB.
This error is seen only if the Expense Type is related to some Vendor account like Expenses by company (Service provider's vendor a/c) or Advances paid to the employee & Expenses incurred by employee (Employee Vendor account)
Regards,
Bindumadhav
Edited by: BINDUMADHAV AMBIKE on Mar 26, 2011 7:18 PMI found that some validation criteria were maintained in Tcode OB28. We can edit those validation criteria to exclude Travel Management. OR it was suggested by FICO to use posting key as 34 instead of 31.
This solved my problem. -
Line Drawing best file format for import in InDesign
i was wondering what is the accepted and recommended file format for files to be imported in InDesign. I was under the impression that AI files should be saved as EPS but I just read an article that says that Adobe's Dov Isaacs said that eps will be shortly obsolete.What should I do. I work on curriculum that contains both photographs and line drawing and we use tiff for the former and eps for the latter. Most of our line drawing is done in AI. Howeverwe have a cartoonist that sends us files in jpg format. What would be the best file format for him and for us as we draw in AI?
Article link: http://www.prepressure.com/library/file-formats/eps
The future of the EPS file format
EPS is rapidly becoming an outdated file format which is being replaced by PDF just like PostScript itself is also being phased out and replaced by PDF. Don’t just take my word on this. Here is what Dov Isaacs from Adobe said in a discussion on a PrintPlanet forum about the future of PostScript: “ …Adobe will continue to support EPS as a legacy graphics format for import of non-color managed, opaque graphical data into Adobe applications (such as InDesign and Illustrator). Although we certain do not recommend that new graphical content be stored in EPS format (except to satisfy the need to import data into page layout programs that aren’t quite PDF-centric — no need to mention names here!), our user base should feel comfortable that there is no need to worry about a need to convert their very sizable libraries of EPS-based graphic assets.”Yes, I drag the AI file in.
If after it's in place I need to change I can just right click and chose edit original make the changes and save and the illustration in inDesign will reflect the changes.
On the other hand I can make changes to the original and all iterations of the file will automatically update, say if I used the illustration in several documents.
As an example I had completed a set of documents for a new company, i.e., biz cards, brochures, product labeling, stationery, etc. and in their wisdom they decided to make changes in their logo, which, of course, is on everything. I opened the AI file with the logo made the changes saved and all the documents then reflected the changes. The only caveat to do this seamlessly is to make sure that your file logo size is the same as the original or you might have to tweak placement in the other documents
It is this interoperability that to me makes the Creative Suite so much more than the sum of their parts.
Craig -
How do I change the white background color in a b/w line drawing jpg?
How do I change the white background color in a b/w line drawing jpg?
Just put a Solid Color Layer atop it and set it to Blend Mode Multiply or
• load the Channel with the best contrast (cmd-click it in the Channels Panel)
• invert Selection (cmd-I)
• create a black Solid Color Layer
• put whatever below that Layer
Maybe you are looking for
-
Hi All, I am using Oracle BI Office which Integrates with MS Office 2007. Whenever I open a MS Excel Sheet 2007. It gives tab as : Add Ins > Oracle BI > Login When I login I am not able to see the presentation catalog. Though the testing of the conne
-
How to get the value of a parameter/field in a ADF Read-Only Form
Hi, My requirement is as follows. Could anyone shed some light on this issue. I am showing the records from db table using ADF Read-Only Form ( which uses ViewObject created for the table). Now I want to capture(get) the value of a field in this form
-
i need help with what i posted in the title
-
I NEED HELP!!!! I cant find my apple tv on my Itunes anymore???? I know this is a problem....but I have a lot of music I need to upload on my apple tv? Is there another way??? HHHEEELLPP!!!
-
My icons are big and display too big for screen. help..
my icons are all big on desktop but not on dock. safari screen doesn't fit on my display, too big. what have i done?