|
See my last answer above.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
What is this to do with Java?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Sorry posted in the wrong Forum
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
|
no complete sentence - no complete answer
|
|
|
|
|
Hello,
Can anyone please help me.
I am new to itext and dont know much...
I have a jpanel having approx 380 components.I have to create the respective components on itext pdf document.i am trying to take a graphics 2d of each component and placing it in pdf but how should i reduce the size and give respective cordinates..
its too confusing as jpanel creates its component from top left corner and pdf from bottom left.
i also need to calculate proprtionate width and height.
public void convertPageToIText(Form form, Page page,
PagePanel pagePanel,
PageController pageController,ZipOutputStream zos, String pageModel,int i) throws DocumentException, IOException
{
pageController.resetFieldsChecked();
pageController.prepareBeforeSynchronizeFrom(form, page);
pagePanel.synchronizeFrom(page);
pageController.prepareAfterSynchronizeFrom(form, page);
UI.setEnabled(pagePanel, true);
Document doc = new Document(PageSize.A4);
File file=null;
FileInputStream fis=null;
file = File.createTempFile("IR Mobility1-", ".pdf");
ByteArrayOutputStream baos=new ByteArrayOutputStream();
PdfWriter writer =PdfWriter.getInstance(doc, baos);
writer.setPdfVersion(PdfWriter.VERSION_1_5);
doc.open();
PdfContentByte cb=writer.getDirectContent();
Graphics2D g2 =null;
int pagenumber=1;
for (Field field :pagePanel.getClass().getSuperclass().getDeclaredFields())
{
Object o = pagePanel.get(field);
if (o instanceof JLabel)
{
JLabel jLabel = (JLabel)o;
float llx=jLabel.getX()*(594/750);
float lly=((jLabel.getY()*(842/pagePanel.getHeight()))+(jLabel.getHeight()*(842/pagePanel.getHeight())));
PdfTemplate template = cb.createTemplate(jLabel.getWidth()*0.5f, jLabel.getHeight()*0.5f);
g2 = template.createGraphics(jLabel.getWidth()*0.5f, jLabel.getHeight()*0.5f);
jLabel.print(g2);
g2.dispose();
cb.addTemplate(template, jLabel.getX(),842-jLabel.getY());
// cb.stroke();
// cb.restoreState();
continue;
}
// if (o instanceof JTextField)
// {
// JTextField jLabel = (JTextField)o;
//
// PdfTemplate template = cb.createTemplate(jLabel.getWidth(), jLabel.getHeight());
// template.stroke();
// g2 = template.createGraphics(jLabel.getWidth(), jLabel.getHeight());
// g2.scale(1,1);
//
// jLabel.print(g2);
//
// g2.dispose();
// cb.addTemplate(template, jLabel.getX(), 842-jLabel.getY());
//
// continue;
// }
if (o instanceof JTextArea) {}
if (o instanceof JTextPane) {}
if (o instanceof JCheckBox) {}
if (o instanceof JRadioButton) {}
if (o instanceof JDateField) {}
if (o instanceof SignaturePanel) {
}
if (o instanceof DrawingPanel) {}
if (o instanceof HelperObjectComboBox) {}
}
doc.close();
PdfReader reader = new PdfReader(baos.toByteArray());
PdfStamper stamper =new PdfStamper(reader, new FileOutputStream(file));
stamper.setRotateContents(false);
stamper.setFormFlattening(true);
stamper.close();
fis = new FileInputStream(file);
byte[] b = new byte[1 * 1024];
while (true) {
int k = fis.read(b);
if (k == -1) {
break;
}
zos.write(b, 0, k);
}
fis.close();
fis = null;
file.delete();
file = null;
}
}
|
|
|
|
|
Please enclose your code in <pre> tags to make it readable.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
bijalvadher wrote: its too confusing as jpanel creates its component from top left corner and pdf from bottom left.
converted_value = (value * -1) + max_value
that is how you can easily convert the positions.
the resize: I don't know much about IText, but can't you make a full size document and then resize it to the paper format? That would be much simpler.
|
|
|
|
|
<pre> Hello
i want to implement a central weather station( is the class KentrikosMeteorologikosStathmos) where you can add or remove regional weather stations. In the regional station(is the classPeriferiakosMeterologikosStathmos) you can add or remove sensors . There are 3 kinds of sensors SensorAnemou, SensorVroxis and SensorFoteinotitas
When i compile the programm it shows
java.lang.NoClassDefFoundError:
Caused by: java.lang.ClassNotFoundException:
thanks
</pre>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author ΝΙΚΟΣ
*/
import java.util.ArrayList;
public class KentrikosMeteorologikosStathmos {
String poli;
private ArrayList<PeriferiakosMeterologikosStathmos> p;
public void addPeriferiakos()
{
p=new ArrayList<PeriferiakosMeterologikosStathmos>();
}
public void removePeriferiakos()
{
int i=p.indexOf(p);
if(i>=0){
p.remove(i);
}
}
public void collectPerif()
{
ArrayList<PeriferiakosMeterologikosStathmos> per=new ArrayList<PeriferiakosMeterologikosStathmos>();
for(PeriferiakosMeterologikosStathmos var)
per.add(var);
System.out.println("Periferiakoi");
for(int count=0;count<per.size();count++)
System.out.println(per.get(count));
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author ΝΙΚΟΣ
*/
import java.util.ArrayList;
public class PeriferiakosMeterologikosStathmos {
private ArrayList<Sensor> o;
public PeriferiakosMeterologikosStathmos()
{
o=new ArrayList<Sensor>();
}
public void addSensor(Sensor s)
{
//ArrayList<Sensor> o=new ArrayList();
o.add(s);
}
public void removeSensor(ArrayList<Sensor> s)
{
int i=o.indexOf(o);
if(i>=0){
o.remove(i);
}
}
public void collectSensors()
{
ArrayList<Sensor> sens=new ArrayList<Sensor>();
for(Sensor var)
sens.add(var);
System.out.println("Sensores");
for(int count=0;count<sens.size();count++)
System.out.println(sens.get(count));
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author ΝΙΚΟΣ
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
KentrikosMeteorologikosStathmos s=new KentrikosMeteorologikosStathmos();
s.collectPerif();
}
}
import java.util.Random;
public class SensorVroxis extends Sensor {
@Override
public double getValue()
{
Random r=new Random();
int d;
d=r.nextInt(10);
return d;
}
}
import java.util.Random;
public class SensorAnemou extends Sensor {
public double getValue()
{
double d;
Random r=new Random();
int meters=r.nextInt();
int seconds=r.nextInt();
d=r.nextInt(meters/seconds);
return d;
}
}
import java.util.Random;
public class SensorFoteinotitas {
Random r=new Random();
public double getValue()
{
double d;
double cov=r.nextInt();
d=cov/100;
return d;
}
}
import java.util.Random;
public abstract class Sensor {
public abstract double getValue();
}
|
|
|
|
|
What command did you use and what was the full text of the error message?
Note: please edit the above question and place <pre> tags round your code for readability.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi All,
I have added a jPanel Form in my applet project. Now i want to place this jPanel over other forms(Applet window) at run time. For that i created its object in Main applet window and try to place it. But its not visible there. Is there anyone who can catch something and help me . I am adding code as well
//SaveContact is jPanel Form class i want to add
SaveContact objFormSaveContact = new SaveContact();
this.getContentPane().add(objFormSaveContact);
this.getContentPane().validate();
objFormSaveContact.setLocation(200, 50);
objFormSaveContact.setVisible(true);
Thanks.
|
|
|
|
|
Seems like you need to repaint() .
|
|
|
|
|
Hi everyone,
Can someone guide me to a code in java that implements a multithreaded proxy server.
Thanks
|
|
|
|
|
Maybe these guys can.
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
prateek.rajan89 wrote: Can someone guide me to a code in java that implements a multithreaded proxy server.
Java doesn't implement that.
Perhaps you were looking for a server written in java that implements a proxy server. Since "proxy server" can mean different things that can influence the outcome but in general full function proxy servers are not written in java because java doesn't (easily) support functionality that other languages, such as C++, do.
|
|
|
|
|
import java.io.*;
class print
{
public static void main(String[] args)
{
int[] a = new int[20];
int i=0;
while(i<20)
{
a[i] = i;
System.out.println(a[i]);
i++;
}
}
}
output of above code is :<pre lang="vb">0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
while output of:
import java.io.*;
class print
{
public static void main(String[] args)
{
int[] a = new int[20];
int i=0;
while(i<20)
{
a[i] = i;
i++;
System.out.println(a[i]);
}
}
}
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 20
at print.main(print.java:12)
Plz expalin why "i++" make large difference..
Thnx in advance..
modified 19-Jan-12 17:16pm.
|
|
|
|
|
class Code1{
public static void main(String[] args) {
int[] a = new int[20];
int i=0;
while(i<20) {
a[i] = i;
System.out.println(a[i]);
i++;
}
}
}
class Code2{
public static void main(String[] args) {
int[] a = new int[20];
int i=0;
while(i<20) {
a[i] = i;
i++;
System.out.println(a[i]);
}
}
}
That fit's better to my display, which is more wide than high Also check the renaming of the classes
Code1 increments the value i after the value of a[i] is print out.
Therefor each value of a[] is set and print out different.
in Code2 the Array a[] is initialized. That set's all values of a[] to "0".
After that you set a value of a[] and increment i before print out.
So you get in the print out the next value - which is still "0" and you exceed the limit of the array in the endposition (you try to print a[20] , but the array goes from 0-19 ).
That's why.
|
|
|
|
|
thnx Torsten...thnx very much dear.....
|
|
|
|
|
Nice description
Thanks and Regards,
RK_PRABAKAR
|
|
|
|
|
What is the problem here?
you just incrementing the integer 'i' for checking condition but the value you intend to print is integer array a[] of size 20.For that you must modify your code into
import java.io.*;
class print
{
public static void main(String[] args)
{
int[] a = new int[20];
int i=0;
while(i<=20)
{
i++;
a[i] = i;
System.out.println(a[i]);
}
}
}
output of above code is :
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<div class="signature">Thanks and Regards,
RK_PRABAKAR</div>
|
|
|
|
|
i need the source code for image encryption in java based on hill cipher.somebody plz help............
|
|
|
|
|
bhanu.pratap.99 wrote: i need the source code
Then you need to go and search for it; this site is not here to provide source code to order.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Go write it then!
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
don't listen to them - I'll give you a jump start: JCA[^]
Have fun.
|
|
|
|