xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mariano Kamp <mk...@codamax.com>
Subject Re: painting from components with SVGGenerator Class (fwd)
Date Sat, 10 Feb 2001 22:58:08 GMT
Vincent,
 
  pack() did the job. It's now working, even without calling
setVisible(true). The only downside is, that my program doesn't return
anymore. Aparently when calling pack() it seems to register the component
somewhere? I'll go and get the Java sources in order to have a look what's
happening.

Mariano 


> Mariano,
> 
> Thanks for sending your emails on batik-dev, as other developers may
> be running into the same problem.
> 
> Here is some sample code that does pretty printing of a Swing 
> component. 'g' is an SVGGraphics2D instance:
> 
> 		g.translate(0, 15);
> 		JFrame frame = new JFrame("Hello Swing & SVG");
> 
> 		JButton button = new JButton("JButton");
> 		JLabel label = new JLabel("JLabel");
> 		JList list = new JList(new String[]{ "Item #1", "Item #2", "Item #3",
> "Item #4", "Item #5", "Item #6"});
> 		list.setVisibleRowCount(2);
> 		list.setSelectedIndex(4);
> 		JProgressBar progressBar = new JProgressBar(0, 100);
> 		JScrollBar scrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
> 		JSlider slider = new JSlider(0, 100);
> 		JComboBox combo = new JComboBox(new String[]{"Choice #1", "Choice #2",
> "Choice #3"});
> 
> 		JPanel panelWithTitle = new JPanel();
> 		panelWithTitle.add(new JButton("Button in titled panel"));
> 		panelWithTitle.setBorder(new TitledBorder("Titled Panel"));
> 
> 		Container contentPanel = frame.getContentPane();
> 		GridBagPanel topPanel = new GridBagPanel();
> 		contentPanel.add(topPanel);
> 
> 		topPanel.add(button, 0, 0, 1, 1, topPanel.CENTER, topPanel.BOTH, 1,
> 0);
> 		topPanel.add(label, 1, 0, 1, 1, topPanel.CENTER, topPanel.BOTH, 1, 0);
> 		topPanel.add(progressBar, 0, 1, 1, 1, topPanel.CENTER,
> topPanel.HORIZONTAL, 1, 0);
> 		topPanel.add(scrollBar, 1, 1, 1, 1, topPanel.CENTER,
> topPanel.HORIZONTAL, 1, 0);
> 		topPanel.add(slider, 0, 2, 1, 1, topPanel.CENTER, topPanel.HORIZONTAL,
> 1, 0);
> 		topPanel.add(list, 1, 2, 1, 2, topPanel.CENTER, topPanel.BOTH, 1, 1); 
> 		topPanel.add(panelWithTitle, 0, 4, 2, 1, topPanel.CENTER,
> topPanel.BOTH, 1, 0);
> 		topPanel.add(combo, 0, 5, 2, 1, topPanel.CENTER, topPanel.BOTH, 1, 0);	
> 
> 		frame.pack();
> 		frame.doLayout();
> 
> 		frame.list();
>                 SwingSVGPrettyPrint.print(topPanel, (SVGGraphics2D)g);
> 
> Mariano Kamp wrote:
> > 
> > Vincent,
> > 
> >   I tried to use SwingSVGPrettyPrint ... I am encountering the same
> > problem - as long as the component is not visible nothing is painted.
> > 
> >   I attached a sample file. In the middle is the "setVisible(true)". By
> > Enabling/Disabling it the output below "g" is filled/empty.
> > 
> >   Are there any sample java files? I only found the .svg samples.
> > 
> > Mariano
> > 
> > On Wed, 7 Feb 2001, Vincent Hardy wrote:
> > 
> > > Mariano,
> > >
> > > Actually, yes, the SwingSVGPrettyPrint should solve your problem (even
> > > though there are some caveats). I should have mentioned that class
> > > earlier.
> > >
> > > V
> > >
> > > Mariano Kamp wrote:
> > > >
> > > > Hello Vincent,
> > > >
> > > >   I still don't have a solution for my problem with painting a subclass
> > > > of (J)Component on a SVGGraphics2D object. I tried the approach with
> > > > print(g). Unfortunately print(g) is eventually delegating to paint().
And
> > > > paint() asks if the component is visible. So I am still unlucky.
> > > >
> > > >   I saw your below mentioned mail the SwingSVGPrettyPrint. Do you know
if
> > > > this class works around my problem?!  A short yes or no would be enough
> > > > ;-)
> > > >
> > > > Mariano
> > > >
> > > > On Wed, 7 Feb 2001, Vincent Hardy wrote:
> > > >
> > > > > Actually, there is a SwingSVGPrettyPrint class that will do "all
the
> > > > > right things" (or about, there are some caveats) for you. It is in
> > > > > the org.apache.batik.svggen package in the rc2 build.
> > > > >
> > > > > Vincent.
> > > > >
> > > > > Thierry Kormann wrote:
> > > > > >
> > > > > > > I've been able to produce hebrew font onto a TextArea component
after
> > > > > > > setting the font.properties file
> > > > > > > and importing the correct True-Type with the following
code:
> > > > > >
> > > > > > I don't know wich version of batik you are using but it seems
that your version
> > > > > > of the SVGGraphics2D does not produce image (using the base
64 encoder) by
> > > > > > default. As swing components are double-buffered, the only thing
that will be
> > > > > > produced is an image (and in your case nothing :).
> > > > > >
> > > > > > So, you should:
> > > > > >
> > > > > > 1. download the beta2rc3 from the batik's site.
> > > > > > 2. disable the double buffering on swing component before asking
the
> > > > > > SVGGraphics2D to transform your component.
> > > > > >
> > > > > > Hope it helps.
> > > > > > Thierry.
> > > > > >
> > > > > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
> > > > > > For additional commands, e-mail: batik-dev-help@xml.apache.org
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
> > > > > For additional commands, e-mail: batik-dev-help@xml.apache.org
> > > > >
> > > >
> > > > --
> > > > mariano kamp
> > > > codamax ag
> > > > hessenring 89
> > > >
> > > > 61348 bad homburg v.d.h.
> > > > germany
> > > >
> > > > phone  +49 6172 182 473
> > > > fax    +49 6172 182 475
> > > > mobile +49 177 727 9468
> > >
> > 
> > --
> > mariano kamp
> > codamax ag
> > hessenring 89
> > 
> > 61348 bad homburg v.d.h.
> > germany
> > 
> > phone  +49 6172 182 473
> > fax    +49 6172 182 475
> > mobile +49 173 300 8564 (changed!)
> > 
> >   ------------------------------------------------------------------------
> >                            Name: TestPrettyPrint.java
> >    TestPrettyPrint.java    Type: Plain Text (TEXT/PLAIN)
> >                        Encoding: BASE64
> 

-- 
mariano kamp
codamax ag
hessenring 89

61348 bad homburg v.d.h.
germany

phone  +49 6172 182 473
fax    +49 6172 182 475
mobile +49 173 300 8564 (changed!)

Mime
View raw message