I am using GWT 2.5 and the JAVA Google Visualization wrapper 1.1.2.
I try to create a line Chart with 2 y-axis (it works fine with one). I know it is possible in pure javascript but I don't find any answer for java.
I read GWT Linechart options and try this :
AxisOptions axes[] = new AxisOptions[2];
axes[0] = firstAxis;
axes[1] = secondAxis;
options.set("vAxes", axes); //not working
AxisOptions are correctly created and using code like the one below works fine :
options.set("vAxis", firstAxis);
Someone knows how to do a 2 Y-axis line chart ?
Thanks!
Why don't you use the second version of the SO thread you referenced?
If you must pass an array to the AxisOption you have to use a JsArray instead.
Something like this:
JsArray<AxisOptions> axes= AxisOptions.createArray().cast();
axes.push(firstAxis);
axes.push(secondAxis);
options.set("vAxes",axes);
Related
I want to create a plugin that adds a video on the current slide in an open instance of Open Office Impress by specifying the location of the video automatically. I have successfully added shapes to the slide. But I cannot find a way to embed a video.
Using the .uno:InsertAVMedia I can take user input to choose a file and it works. How do I want to specify the location of the file programmatically?
CONCLUSION:
This is not supported by the API. Images and audio can be inserted without user intervention but videos cannot be done this way. Hope this feature is released in subsequent versions.
You requested information about an extension, even though the code you are using is quite different, using a file stream reader and POI.
If you really do want to develop an extension, then start with one of the Java samples. An example that uses Impress is https://wiki.openoffice.org/wiki/File:SDraw.zip.
Inserting videos into an Impress presentation can be difficult. First be sure you can get it to work manually. The most obvious way to do that seems to be Insert -> Media -> Audio or Video. However many people use links to files instead of actually embedding the file. See also https://ask.libreoffice.org/en/question/1898/how-to-embed-video-into-impress-presentation/.
If embedding is working for your needs and you want to automate the embedding by using an extension (which seems to be what your question is asking), then there is a dispatcher method called InsertAVMedia that does this.
I do not know offhand what the parameters are for the call. See https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=61127 for how to look up parameters for dispatcher calls.
EDIT
Here is some Basic code that inserts a video.
sub insert_video
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:InsertAVMedia", "", 0, Array())
end sub
From looking at InsertAVMedia in sfx.sdi, it seems that this call does not take any parameters.
EDIT 2
Sorry but InsertVideo and InsertImage do not take parameters either. From svx.sdi it looks like the following calls take parameters of some sort: InsertGalleryPic, InsertGraphic, InsertObject, InsertPlugin, AVMediaToolBox.
However according to https://wiki.openoffice.org/wiki/Documentation/OOoAuthors_User_Manual/Getting_Started/Sometimes_the_macro_recorder_fails, it is not possible to specify a file for InsertObject. That documentation also mentions that you never know what will work until you try it.
InsertGraphic takes a FileName parameter, so I would think that should work.
It is possible to add an XPlayer on the current slide. It looks like this will allow you to play a video, and you can specify the file's URL automatically.
Here is an example using createPlayer: https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=57699.
EDIT:
This Basic code works on my system. To play the video, simply call the routine.
sub play_video
If Video_flag = 0 Then
video =converttoURL( _
"C:\Users\JimStandard\Downloads\H264_test1_Talkinghead_avi_480x360.avi")
Video_flag = 1
'for windows:
oManager = CreateUnoService("com.sun.star.media.Manager_DirectX")
' for Linux
' oManager = CreateUnoService("com.sun.star.media.Manager_GStreamer")
oPlayer = oManager.createPlayer( video )
' oPlayer.CreatePlayerwindow(array()) ' crashes?
'oPlayer.setRate(1.1)
oPlayer.setPlaybackLoop(False)
oPlayer.setMediaTime(0.0)
oPlayer.setVolumeDB(GetSoundVolume())
oPlayer.start() ' Lecture
Player_flag = 1
Else
oPlayer.start() ' Lecture
Player_flag = 1
End If
End Sub
Help! I'm looking to create a Java application that generates a graph in any one of these formats:
.graphml
.ygf
.gml
.tgf
I need to be able to open the file in the graph editor "yEd".
So far, I have found these solutions:
yFiles For Java
Pro: Export to graphml, able to open in yEd, Java based, perfect.
Why I can't use it: Would cost me more than $2000 to use :( it is exactly what I need however
Gephi
Pro: FREE, Export to graphml, Java based!
Why I can't use it: When I try to open the generated graphml file in yEd, the graphml is broken: it's linear - one line, like this screenshot:
If I get it to work, then this is perfect
The graph I tried was generated using their example project
JGraphX
Pro: Able to generate a graph, Java based, FREE
Why I can't use it: How to export the generated graph to graphml? I couldn't figure it out...
Prefuse
Pro: Free, graph generation, Java based
What I can't use it: Seems like I can only read graphml, and not write graphml. Also, I built the demos fine with build.sh all, but then when I tried to run demos.jar, I got "Failed to load Main-Class"...
Blueprints with GraphML Reader and Writer Library (Tinkerpop?)
Pro: Java, Free, seems like you can export graphml with it
Why I can't use it: I'm confused, do I need to use this in conjunction with one of the "Implementations" listed? How do I use this?
JGraphT with GraphMLExporter
Pro: Able to generate graph, Java based, free, can export to graphml I think
Why I can't use it: I can't figure out how to export it! When I tried to open the generated graphml in yed, I got "yEd has encountered the following error: Could not import file test.graphml." I used thier example project, and did this:
JGraphT Code I Used:
UndirectedGraph<String, DefaultEdge> g = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class);
String v1 = "v1";
String v2 = "v2";
String v3 = "v3";
String v4 = "v4";
// add the vertices
g.addVertex(v1);
g.addVertex(v2);
g.addVertex(v3);
g.addVertex(v4);
// add edges to create a circuit
g.addEdge(v1, v2);
g.addEdge(v2, v3);
g.addEdge(v3, v4);
g.addEdge(v4, v1);
FileWriter w;
try {
GmlExporter<String, DefaultEdge> exporter =
new GmlExporter<String, DefaultEdge>();
w = new FileWriter("test.graphml");
exporter.export(w, g);
} catch (IOException e) {
e.printStackTrace();
}
Any ideas? Thanks!
It might be late to answer, but for solution number two:
Right after you import the graph into yEd, just click "Layout" and select one. yed will not choose one for you as default, that's why it seemed to be linear.
I also wanted to export JgraphT graphs for yED but was not happy with the results. Therefore, I created an extended GMLWriter supporting yED's specific GML format (groups, colours, different edges,...).
GML-Writer-for-yED
I don't know if this fits your use case, but I use neo4j for creating a graph and then use the neo4j-shell-tools to export the graph as graphml. Perhaps this will work for you.
Just replace every occurrence of GmlExporter with GraphMLExporter in your code. That should work.
I´m using de Prefuse library and you can generate a GraphML file from a Graph object with de class GraphMLWriter.
I created a little Tutorial/Github Repo and sample code on how to work with the classes of JgraphT to export to GraphML and GML and how the results could look like in yED.
As already mentioned in another answer, if you don't want to do much configuration yourself, GML-Writer-for-yED might be handy.
I am programmatically drawing a flowchart(using Java UNO Runtime Reference) in which I am showing If-Else condition.But I am facing problems while showing the "ELSE" condition because in such a case the connector moves over the intermediate shape(as shwon in attached fig)
The code I have used to draw connectors is:-
XShapes xShapes = (XShapes)
UnoRuntime.queryInterface(XShapes.class, xDrawPage);
XMultiServiceFactory xMsf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xDrawDoc);
Object connector = xMsf.createInstance("com.sun.star.drawing.ConnectorShape");
xShapes.add(UnoRuntime.queryInterface(XShape.class, connector));
XPropertySet xConnector2PropSet = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, connector);
xConnector2PropSet.setPropertyValue("EdgeKind", ConnectorType.STANDARD);
xConnector2PropSet.setPropertyValue("StartShape", xShape1);
xConnector2PropSet.setPropertyValue("StartGluePointIndex", new Integer(startPt));
xConnector2PropSet.setPropertyValue("LineEndName", "Arrow");
xConnector2PropSet.setPropertyValue("EndShape", xShape2 );
xConnector2PropSet.setPropertyValue("EndGluePointIndex", new Integer(endPt));
Please suggest how to layout and route connectors properly using UNO Runtime Reference in Java.
I had the same problem in OpenOffice Draw and could not find any possibility to add further handles to one connector. But one connector can end in another one. So I ended up using two connectors, a first one without ending in an arrow (in blue), a second one starting where the first ended (in red).
Hie everybody, i am trying to make a PictureSymbolMarker in my arcgis map..
However i am facing some problems in it. i went to esri website [ http://blogs.esri.com/esri/arcgis/2012/02/03/esri-picture-marker-symbol-generator-for-javascript-developers/ ] to get a pin url .
When i tried to implement it in my codes,
i received error .
This is how i put it together
From
`//Marker
SimpleMarkerSymbol resultSymbol = new SimpleMarkerSymbol(Color.RED,
20, SimpleMarkerSymbol.STYLE.CIRCLE);`
To
`SimpleMarkerSymbol resultSymbol = new SimpleMarkerSymbol
({"angle":0,"xoffset":0,"yoffset":12,"type":"esriPMS",
"url":"http://static.arcgis.com/images/Symbols/Basic/RedStickpin.png",
"contentType":"image/png","width":24,"height":24});`
But after implementing that codes, i received errors. .. Anybody have face the same problem and are enable to troubleshoot it?
Thanks in Advance
your issue is that you are using JSON for a PictureMarkerSymbol and initializing a SimpleMarkerSymbol which will never work. Try to do like this.
var resultSymbol = new esri.symbol.PictureMarkerSymbol
({"angle":0,"xoffset":0,"yoffset":12,"type":"esriPMS",
"url":"http://static.arcgis.com/images/Symbols/Basic/RedStickpin.png",
"contentType":"image/png","width":24,"height":24});
You're using JavaScript object notation (JSON) syntax in your Java code for Android. It won't work.
#azmuhak is on the right track though. You need to create a PictureMarkerSymbol instead of a SimpleMarkerSymbol. But you need to do it the Android way, not the JavaScript way.
Here's some sample code for creating a PictureMarkerSymbol, creating a GraphicsLayer, adding the GraphicsLayer to the map, and adding a new Graphic to the GraphicsLayer (run this code after the map is loaded, maybe using MapView.setOnStatusChangedListener):
PictureMarkerSymbol pms = new PictureMarkerSymbol(
"http://static.arcgis.com/images/Symbols/Basic/RedStickpin.png");
pms.setAngle(0f);
pms.setOffsetX(0f);
pms.setOffsetY(12f);
GraphicsLayer graphicsLayer = new GraphicsLayer();
mMapView.addLayer(graphicsLayer);
graphicsLayer.addGraphic(new Graphic(new Point(12, 34), pms));
Side note: it is possible in Android to parse a JSON string to make a PictureMarkerSymbol. But in this case, my sample code is easier and less error-prone.
I'm using gwt-visualization to display some Google Charts.
Everything works fine except that I can't set up a continuous X-axis for my column chart. From my understanding, I only need to define the first column of the chart to NOT be STRING - but I always end up with a discrete X-axis.
Here's what I do:
DataTable dataTable = DataTable.create();
dataTable.addRows(rawData.getNumberOfRows());
dataTable.addColumn(DATE, "time interval");
for (Category category : rawData.getCategories()) {
dataTable.addColumn(NUMBER, category.getName());
}
int row = 0;
for (Date month : rawData.getMonths()) {
dataTable.setValue(row++, 0, month);
}
// set other data for categories
Is there something wrong with what I'm doing? Or does the Java library not support this?
This issue has been solved on Google Groups by asgallant (a true hero of Google Visualization support):
asgallant's comment:
That sounds like the wrong chart package is getting loaded. Can you post the javascript produced by your code (open in a browser, view source, and copy it here)?
skirsch's response:
Ah well, that was a great hint.
It does actually load the "areachart" instead of the "corechart". Seems like the latest version available via Maven dates back to 2009, being obviously outdated.
Answer
Make sure that you are loading the appropriate chart package, otherwise you cannot use continuous axes.