J/CarnacPro Technical FAQs
The following FAQs
provide some general information for J/CarnacPro. If you would like
more technical input, go to Really,
Really Technical FAQs.
What
do I need to use J/CarnacPro?
JDK 1.4 and above
What
is the current release of J/CarnacPro?
The current release is 2.6.
What
is the genesis of J/CarnacPro?
INT customers requested
toolkits to display and visualize scientific data over networks and through web
browsers. The company first responded with J/Carnac, a pure Java implementation
of its core graphics technology which was offered as a free download. After incorporating
many significant enhancements based upon the user feedback from thousands of downloads,
the company released J/CarnacPro.
Does
J/CarnacPro provide any tutorial documentation?
Yes, look in the doc folder you have downloaded. You will find a reference
manual and a tutorial describing our demos.
Why
should I use J/CarnacPro over Java 2D?
Java 2D is just a rendering
engine with routines to fill and draw based on shape. Java 2D users are required
to use different rendering routines for text, images and geometrical shapes.
J/CarnacPro
has simplified and optimized these processes. The J/CarnacPro architecture is
built so that an individual shape can be redrawn without repainting the whole
graphic. Using J/CarnacPro will save you time because a lot of classes have been
created to make your programming process easier. Take a look at our demos to see
the full advantages of J/CarnacPro.
A
practical example:
You
could create an application that provides geographical data of a certain area.
First, start with the map initially in a layer. On top of this map you will see
the different sets of data that describe the geography -- terrain with elevations,
forest area, amount of rainfall received by different areas on the map, and mark
urbanized areas.
You
can add the geographical data into different layers. When you want to view the
terrain, simply overlay the layer (with the map) with the layer containing terrain
information. If you want forest area data, you then can create another layer and
overlay. Using J/CarnacPro makes this process much faster because you can hide
or unhide the layer (or remove it) with little repainting.
What
shapes are available in J/CarnacPro?
Primitive
Shapes
Arc,
Ellipse, Polygon, Polyline, Rectangle, Line, Dynamic polygon, Dynamic polyline.
Anchored
shapes
Image,
Text (fixed size and scalable), Symbol
Composite
Shape – shapes that can group other shapes
Animated
Shape – an abstract class that represents a dynamic shape with the understanding
of frames and loops.
How
is text in J/CarnacPro different from Java 2D?
In Java 2D, text is
not a shape object, so it requires a different handling mechanism. Text handling
has been simplified in J/CarnacPro because it is considered a shape object. The
text object can be scaled or restricted, and rotated around an anchor point. J/CarnacPro
also provides tools to display multiline text.
What
are the differences between J/CarnacPro and Java 2D shapes?
J/CarnacPro provides
optimized rendering and picking algorithms for shapes. Unlike Java 2D you can
use the real coordinates of your plot when you want to add a shape.
Can
you add Java 2D shapes to J/CarnacPro?
No. Users will have
to write their own shape classes to extend the capabilities in order to include
other Java 2D shapes.
What
image operations can be performed with J/CarnacPro?
Rendering, rotating,
translation and scaling.
Does
the Bounding Box feature ensure that the shape is completely enclosed,
with no leftovers or extras?
The method getBoundingBox()
always returns a box that completely encloses the object.
Can
you remove a model?
No. Models are attached
to a PlotView object and cannot be removed. However, you can remove layers. One
of the advantages of having shapes in layers is that it is quicker to remove a
whole set of objects from view.
Does
adding a shape to a layer call render automatically?
No. A standard layer
will invoke an invalidation process when shapes are added.
When
is a quad tree layer used, and for what purposes?
A quad tree is an optimal
method of storing information by creating subdivisions that contain small local
quads. A quad tree offers the benefit of speed in rendering time. Also, search
algorithms perform better.
Does
J/CarnacPro provide printing support?
Yes, J/CarnacPro has
full support for printing. We have also included a built-in editorsfor selecting
paper size, orientation, fit mode and so on. There is also an option for print
preview.
Could
we use Java Swing components with J/CarnacPro?
Yes.
Really,
Really Technical FAQs

Installation
of J/CarnacPro
What
if I cannot compile samples or tutorials? My compiler exits with an
error diagnostics?
Check your CLASSPATH variable, it should contain the file jcarnac.jar and full
path to this file (i.e. c:\workspace\jcarnac\jcarnac.jar). Also, be sure that
your JDK is the one that satisfies J/CarnacPro’s system requirements. For "advanced"
tutorials, that use XML parsers, you will also need xml4j.jar (XML parser from
IBM – alphaworks.ibm.com) in your CLASSPATH
What
if my JVM exits with an error "java.lang.NoClassDefFoundError:
com/interactive/jcarnac2d/.."?
Check your CLASSPATH
variable, it should contain file jcarnac.jar and full path to this file (i.e.
c:\workspace\jcarnac\jcarnac.jar)
Why
can't I run anything in "simple" tutorials?
Be sure that you pointed
CLASSPATH to the ..tutorial\simple directory.
Why
can't I run anything in "advanced" tutorials?
Be sure that
you pointed CLASSPATH to the ..tutorial\advanced directory. Also be
sure that you have xml4j.jar in your CLASSPATH , if you run XML-related
tutorials.
Use
of J/CarnacPro
Hey!
I’m running XWindows and I have really weird problems with cgText object
– it doesn’t draw properly!
Sad, but true – JDK,
so far, has bugs in its implementation – text objects aren't transformed properly
under Xwindows. We can only look forward to when Sun will fix it. So far
– just don’t use any rotations or font changes under XWindows.
Hey!
I want to have annotated axes and nice looking scrollbars!
Do
this:
..
myplot = new cgPlot(myCentralView);
…
..
cgAxisView myaxis = new cgAxisView(…)
cgLabelView mylabel = new cgLabelView(…)
cgPlot myaxisplot = new cgPlot(myaxis);
myaxis.addAnnotation(mylabel, "North"); // for north-placed label
…
…
myplot.addAnnotation(myaxisplot, "North", true); // for
north axis
…
and here it comes!
I
want to have the ability to disable-enable sets of information on the
screen by using the menu!
Just put different kinds of information into different layers, and then
use setVisible(boolean) method for cgLayer to play around.
I
want to create an axis that will have minor ticks and major ticks!
Just extend
the existing or write your own TickGenerator to return different sizes
on getTickSize(), and if you want to change label size – TickLabelGenerator
(getLabelSize()).
Why
doesn't my text look perfect?
By default, Antialiasing is turned off in J/CarnacPro.
This makes rendering a bit (in some cases about 20-30% actually) faster.
You can turn it on as:
com.interactive.jcarnac2d.model.Java2DRenderer
.setAntiAliased(true);
Why
are there three kinds of polygons and polylines? Which one I should
use?
There are three kinds of these poly- shapes:
Compressed
– these shapes try to keep geometry in forms of short instead of double
. This approach allows you to give up about 80% of memory that will be used
with regular kinds of shapes. But it will require some more time to render such
shapes. So – if you are limited with memory, but have a fast CPU – try these shapes.
Another point – these shapes don’t allow the user to change geometry.
Dynamic
– these shapes do not copy initial arrays inside them. Instead they
just keep references to initial arrays. So you can share the same arrays
between many shapes. That allows you to save some memory, and will provide
you with direct access to geometry. But in this case, it's your responsibility
to recalculate the bounding box for the shape, if you changed geometry.
Whenever you have polylines that enclose the same areas as polygons,
you can consider these shapes a good option.
Regular
– these shapes copy initial arrays inside objects, provide methods to access geometry,
and perform all automatic updates for you.
What
do I need to make my Adaptive TickGenerator work properly?
A common mistake is to not provide the Adaptive TickGenerator with a
label generator. The reason why it needs this is simple – adaptive tick
generators try to measure label size for the best fit possible. If you
do not supply a label generator, then you will have distance between
ticks based on the regular gaps between labels, which is 10 pixels by
default.
What
if I need multiple axes for my cgPlot?
The easiest way to do
it:
myBigAnnotation
= new cgPlotBoxContainer();
cgPlot
axisplot;
axisplot
= new cgPlot(new cgAxisView(…….));
axisplot.setSize(…);
myBigAnnotation.add(axisplot);
…..
axisplot
= new cgPlot(new cgAxisView(…….));
axisplot.setSize(…)
myBigAnnotation.add(axisplot);
//
and so on.. for each axis that you want to add
How
I can convert mouse coordinates into modeling space?
First of all – be sure that mouse coordinates belong to cgPlotView
(i.e. mouse listener was attached to cgPlotView, not to
cgPlot & etc.). Then all you need to do is:
Point
p = _plot.getViewPosition();
int
x = mouseEvent.getX() + p.x;
int
y = mouseEvent.getY() + p.y;
AffineTransform
tr = myPlotView.getTransformation();
Point2D.Double
src = new Point2D.Double(x,y);
Point2D.Double
dst = new Point2D.Double(0,0);
//
create inverse transformation (see javadoc for AffineTransform)
//
and just transform src to dst.
//
and dst.x dst.y – will be what are you looking for
Second
way is easier, and more compact
Point
p = _plot.getViewPosition();
int
x = me.getX() + p.x;
int
y = me.getY() + p.y;
cgRect
box = new cgRect(x, y, x, y);
box
= _plot.getTransformation().inverseTransform(box);
//
box.x and box.y – what are you looking for
Does
J/CarnacPro provide a mechanism for file paging, so I will be able to
reduce memory consumption for my mapping applications?
Right now we don’t have support for it, but it's on the list for
features that we want to implement later.
Do
I really need to provide cgContainerModel each time I create cgGraphicAttribute?
No, you don’t have to. There is a default constructor for cgGraphics
attribute. But then you should remember that the model will not invoke repaint,
if you change any part of this attribute (like line color, line style & etc.),
unless you attach AttributeListener later (after creation).
Why
is scrolling really fast on some computers, and on others (with the
same kind of CPU or even faster) its runs so slowly?
The reason might be the driver for your
video card. Also, you can try to play with setCacheMode to
be CACHE_VIEW_SIZE or NO_CACHE. Sometimes switching offscreen
cache ON can really help. (By default, it's OFF, since Beta3.)
I
want to have TIFF support in my application , can J/CarnacPro do it?
No. So far
J/CarnacPro doesn’t provide support for any particular image format.
We support BufferedImage, which is the base for our cgImage
shape. However, you can find a couple of free Java-based decoders
for TIFF on the web. Then, when you have an image – just pass it to
JCarnacPro.
What
if I need more assistance, or I didn't find the answer I need?
If you need
additional assistance or consulting, please contact us at intinfo@int.com