I am using java and iText to create a pdf. Is it possible to add a map with a pointer on it so the user will know where the starting point is?
Clarification (from a meanwhile deleted answer by the OP which should have been an edit of the question)
my problem is can i add at iText google map from web and not as an image
Since you didn't answer my counter-question added in comment, I'm providing you two examples. If these are not what you're looking for, you really should clarify your question.
Example 1: add a custom shape as extra content on top of a map
This is demonstrated in the AddPointer example:
PdfContentByte canvas = writer.getDirectContent();
canvas.setColorStroke(BaseColor.RED);
canvas.setLineWidth(3);
canvas.moveTo(220, 330);
canvas.lineTo(240, 370);
canvas.arc(200, 350, 240, 390, 0, (float) 180);
canvas.lineTo(220, 330);
canvas.closePathStroke();
canvas.setColorFill(BaseColor.RED);
canvas.circle(220, 370, 10);
canvas.fill();
If we know the coordinates of the pointer, we can draw lines and curves that result in a the red pointer shown here (see the red pin near the Cambridge Innovation Center):
Example 2: add a line annotation on top of a map
This is demonstrated in the AddPointerAnnotation example:
Rectangle rect = new Rectangle(220, 350, 475, 595);
PdfAnnotation annotation = PdfAnnotation.createLine(writer, rect, "Cambridge Innovation Center", 225, 355, 470, 590);
PdfArray le = new PdfArray();
le.add(new PdfName("OpenArrow"));
le.add(new PdfName("None"));
annotation.setTitle("You are here:");
annotation.setColor(BaseColor.RED);
annotation.setFlags(PdfAnnotation.FLAGS_PRINT);
annotation.setBorderStyle(
new PdfBorderDictionary(5, PdfBorderDictionary.STYLE_SOLID));
annotation.put(new PdfName("LE"), le);
annotation.put(new PdfName("IT"), new PdfName("LineArrow"));
writer.addAnnotation(annotation);
The result is an annotation (which isn't part of the real content, but part of an interactive layer on top of the real content):
It is interactive in the sense that extra info is shown when the user clicks the annotation:
Many other options are possible, but once again: your question wasn't entirely clear.
Related
I am using aspose-slides-17.3-jdk16.jar for java. I have created the Area Chart using IChartDataWorkbook and I'm able to get the series values in the tool tip for all the charts except Area chart.
Following is the code I have done so far.
public class AreaChartSlide {
public static void main(String[] args) {
Presentation pres = new Presentation();
ISlide slide = pres.getSlides().get_Item(0);
// Creating the default chart
IChart chart = slide.getShapes().addChart(ChartType.Area, 0, 0, 500, 400);
// Getting the default chart data worksheet index
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// Delete demo series
chart.getChartData().getSeries().clear();
// Add new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.getType());
// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, "Cat 1"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, "Cat 2"));
// Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
// Now populating series data
series.getDataPoints().addDataPointForAreaSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 20));
series.getDataPoints().addDataPointForAreaSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 50));
// Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.RED);
// Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
// Now populating series data
series.getDataPoints().addDataPointForAreaSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 30));
series.getDataPoints().addDataPointForAreaSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 10));
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.GREEN);
pres.save("E:/PPT/Aspose.pptx", SaveFormat.Pptx);
System.out.println("done");
}
Below is the chart output i got
Any help would be greatly appreciated.
I have worked with shared sample code using Aspose.Slides for Java 17.5 on my end and have generated a presentation with Area chart having two series and two categories. I have opened the generated presentation in PowerPoint and able to observe the tool-tip text for both chart series. Please observe Series 1 and Series 2 tool-tip text display for your kind reference. I hope the shared information will be helpful. Please share, if I may help you further in this regard.
I am working as Support developer/ Evangelist at Aspose.
We are sorry for your inconvenience.
I have observed your comments and comparison image of tool-tip text display for Bar chart and Area chart. I like to add here that this is not some issue in Aspose.Slides charting engine but its a PowerPoint implementation. If you add an Area chart using PowerPoint, that too will display the point and series name in tool-tip text. Please observe the tool-tip text for slides 2 and 3 in this presentation. You can observe in this snapshot as well that tool-tip text for PowerPoint generated chart is also displaying series and point as it is being shown for similar chart type generated using Aspose.Slides. I hope the shared information will be helpful.
I am working as Support developer/ Evangelist at Aspose.
Many Thanks.
I'm currently trying to modify a java project TRMSim_WSN (Simulator) using Eclipse.
I changed some parts of the source code but the layout seems like it has changed even though I didn't touch it!
The original one:
After modifying:
Can you help me please?
There are two parts for this component:
The 1st one:
this.legendPanelContainer.add(this.legendPanel, null);
this.legendPanel.setBackground(Color.white);
this.legendPanelContainer.setPreferredSize(new Dimension(100, 98));
GroupLayout legendPanelContainerLayout = new GroupLayout(this.legendPanelContainer);
this.legendPanelContainer.setLayout(legendPanelContainerLayout);
legendPanelContainerLayout.setHorizontalGroup(legendPanelContainerLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 100, 32767));
legendPanelContainerLayout.setVerticalGroup(legendPanelContainerLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 81, 32767));
this.legendLabel.setText("Legend");
this.legendLabel.setPreferredSize(new Dimension(100, 15));
The 2nd one:
this.legendPanelContainer.add(this.legendPanel, null);
this.legendPanel.setBackground(Color.white);
this.legendPanel.setSize(this.legendPanelContainer.getSize());
this.legendPanel.plotLegend();
The problem is that I don't see any difference between the source code and the one I modified for this part!
I'm getting mixed results trying to render a basic alien that was done in Blender:
I export in to Ogre 3D and load it in Eclipse:
Then when I load it in my code and try to render it the material won't render:
Could you tell me what I must do to achieve the full alien in my scene? The code I use in Jmonkeyengine is
Spatial model3 = assetManager
.loadModel("objects/creatures/alien/alien.mesh.xml");
model3.scale(0.3f, 0.3f, 0.3f);
model3.setLocalTranslation(-40.0f, 3.5f, -20.0f);
rootNode.attachChild(model3);
Update
I've got material files like these from the export:
dev#dev-OptiPlex-745:~$ ls workspace/DungeonWorld2/assets/objects/creatures/alien/
alien.mesh Material.002.material Material.005.material
alien.mesh.xml Material.003.material
alien.skeleton.xml Material.004.material
dev#dev-OptiPlex-745:~$
This material code actually produces a material in the scene but it's not the one from blender:
model3.setMaterial( new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md") );
Result:
However, loading a 3D model of an alephant without defining the material does work:
Spatial elephant = (Spatial) assetManager.loadModel("Models/Elephant/Elephant.mesh.xml");
float scale = 0.05f;
elephant.scale(scale,scale,scale);
elephant.setLocalTranslation(-50.0f, 3.5f, -20.0f);
control = elephant.getControl(AnimControl.class);
control.addListener(this);
channel = control.createChannel();
for (String anim : control.getAnimationNames())
System.out.println("elephant can:"+anim);
The above code correctly renders the elephant so why can't I export a mesh like that for the alien? I tried to explcitly load the material but it's not working for me:
Spatial model3 = assetManager
.loadModel("objects/creatures/alien/alien.mesh.xml");
model3.scale(0.3f, 0.3f, 0.3f);
model3.setLocalTranslation(-40.0f, 3.5f, -20.0f);
model3.setMaterial( new Material(assetManager,
"objects/creatures/alien/alien.material") );
rootNode.attachChild(model3);
The above generates an exception and I don't really know what material file it is that I'm loading and what do to with the two or three other material files that the export generated:
java.lang.ClassCastException: com.jme3.material.MaterialList cannot be cast to com.jme3.material.MaterialDef
at com.jme3.material.Material.<init>(Material.java:116)
at adventure.Main.simpleInitApp(Main.java:309)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
at java.lang.Thread.run(Thread.java:679)
Update
Loading other models this way is working:
BlenderKey blenderKey = new BlenderKey(
"objects/creatures/troll/troll.mesh.xml");
Spatial troll = (Spatial) assetManager.loadModel(blenderKey);
troll.setLocalTranslation(new Vector3f(-145, 15, -10));
rootNode.attachChild(troll);
BlenderKey blenderKey2 = new BlenderKey(
"objects/creatures/spaceman/man.mesh.xml");
Spatial man = (Spatial) assetManager.loadModel(blenderKey2);
man.setLocalTranslation(new Vector3f(-140, 15, -10));
rootNode.attachChild(man);
I get the models inside my game and they look alreight, both the troll and the spaceman that both originally were .blend files.
Now it's much better when I did it over and it is loading the material. The only problem with the alien left now is the holes in the head that was also answered here.
BlenderKey blenderKey = new BlenderKey(
"objects/creatures/alien/alien.mesh.xml");
Spatial alien = (Spatial) assetManager.loadModel(blenderKey);
alien.setLocalTranslation(new Vector3f(-145, 15, -10));
rootNode.attachChild(alien);
You didn't write anything about your material - did you write one and used it correctly? The problem you get seems to be the lack of material to me.
In general you'll need some *.material file and probably some textures (if you used them in Blender). For the beginning you can use one of the materials that come with Ogre, you'll just need to add:
model3.setMaterialName( "Examples/Rockwall" );
Then look if it changes anything. If you still get the problem you can look into 'Ogre.log' file - it's always worth checking because all the errors goes there.
I also see the second problem here - you render the object as 'one sided' while blender probably render is as two-sided mesh, so you get the holes on the head. You can select in the material to be two sided, but it's better (and faster during rendering) to just create your models without the holes :).
So I am trying to draw a font using Slick2D's UnicodeFont. The code that loads the font:
Font font = new Font("Arial", Font.BOLD, 20);
UnicodeFont uFont = new UnicodeFont(font);
uFont.addAsciiGlyphs();
uFont.getEffects().add(new ColorEffect(java.awt.Color.BLACK));
uFont.loadGlyphs();
It's more or less copied and pasted from the wiki. Next, during a frame I use gluOrtho2d() and reset the projection and modelview matrices. Then I call
this.font.drawString(100, 50, "some text goes here");
to actually draw the text. But all I get is an empty screen, an no errors of any kind.
Considering that UnicodeFonts are depreciated in the current version of slick 2d, I recomend you folow my steps for using AngelCodeFonts on this related question: Slick2D Fonts don't work
I am trying to create a gradient fill for a series in an area chart that I am building through the BIRT chart API, but the book "Integrating and Extending BIRT" and the Interwebs seem curiously silent about how to get it to work. It seems no matter what I do, I always get a flat color from the default palette. I've tried using SeriesDefinition.getSeriesPalette().update(Gradient) and even creating my own Palette with the gradient fill in it and setting that on the SeriesDefinition, but to no avail. I've also noticed that if I do not perform a shift() on the Palette, even if it's shift(0), which the Javadocs claim will do nothing, I get NullPointerException when I try to generate the chart:
Caused by: java.lang.NullPointerException
at org.eclipse.birt.chart.render.Area.renderDataPoints(Area.java:521)
at org.eclipse.birt.chart.render.Line.renderSeries(Line.java:570)
at org.eclipse.birt.chart.render.AxesRenderer.renderPlot(AxesRenderer.java:2181)
at org.eclipse.birt.chart.render.AxesRenderer.render(AxesRenderer.java:314)
at org.eclipse.birt.chart.factory.Generator.render(Generator.java:1368)
... 108 more
Here's the latest (non-working) code that I've tried:
Gradient gradient = FillUtil.createDefaultGradient(BirtReportBuilder.COLOR_WHITE);
gradient.setStartColor(ColorDefinitionImpl.WHITE());
gradient.setEndColor(ColorDefinitionImpl.create(76, 116, 131));
gradient.setDirection(90);
SeriesDefinition sdY = SeriesDefinitionImpl.create();
sdY.getQuery().setDefinition("\"Quantity\"");
Palette pal = PaletteImpl.create(gradient);
pal.shift(0);
sdY.setSeriesPalette(pal);
sdY.getSeries().add(as1);
yAxisPrimary.getSeriesDefinitions().add(sdY);
So what's the magic incantation to get the BIRT charting API to use my Gradient as the area fill?
This code works for me, I get a ugly coloured serie...
sdY.getSeriesPalette().update(GradientImpl.create(ColorDefinitionImpl.create(255,255,255), ColorDefinitionImpl.create(200,0,0,150), 90, false));
Hope it will help you ;p