How to generate editable drawing of connected shapes in Java - java

Can anybody tell me how I could do the following:
I want my Java code to generate a drawing that has multiple connected shapes. Perhaps hundreds of shapes--not huge. I'd like to generate this and save it as a standard file format that somebody could open in a viewer or an editor. I do not want to implement viewing or editing logic--generation only.
I'd like the user to be able to take my generated file, open it in a WYSIWYG editor, and move the shapes around with the lines that connect the shapes staying connected to the shapes as they move. That way, my generation code does not have to be super smart about making sure that connectors don't overlap.
Can anybody suggest a combination of file format, Java library, editor (or some subset of those three) that would work well for this task?
Thoughts so far:
yEd allows this editing behavior and uses graphml as the format. However, I'm not sure how widely used graphml is, and I'm concerned about availability of glyphs.
Inkscape and SVG are widely used, but I'm a complete novice, and so far I haven't been able to get lines to stay connected to other shapes using Inkscape when I move them around.
I'm open to other options...

Related

Linking Website form progress data to GIS

We are trying to develop a website for tracking the progress of pipeline and assets. I want to link progress data entered from forms developed in Java to GIS. We will be capturing all the lat and longs of pipeline stretch and lat and log of progress of work.
I need help in developing shapefile dynamically based on the progress and also to view that shape file in my webpage
The javascript API does have functionality for uploading shapefiles form your desktop into the browser, but you will need another tool to create those shapefiles based on the progress.
For uploading the shapefiles, see the example here: https://developers.arcgis.com/javascript/3/jssamples/portal_addshapefile.html
There may be more examples available at https://developers.arcgis.com/javascript/3/.
For creating the shapefiles dynamically, you could use ArcMap or ArcPro if you have those, or one of many python libraries to help write shapefiles. There may even be some Java libraries to help with this as well but I only work on the front end so I cannot help you there.
For something simple in context, the complexity of what kind of workflow to best suite your needs can range depending on these questions (and probably others I'm not thinking of):
Do you absolutely need to create a shapefile for this? Why can't you just push the form to a spatial database (e.g. PostGIS) and then return the XYs of the points or the string of XYs for line features, etc.?
Where is the source of the data & what is the format? Is it a PDF, text on an HTML page, a .csv file downloadable from a page, etc.? You may need to implement scraping (from a site) or download and update, or your data could be live streaming - these are all different workflows and you need to establish these boundaries before setting up your workflow.
If your end game are points, all you need is XYs in a table format to display in GIS software. If they are lines or polygons, it'd be a little different. Again - what output type are they and what are you trying to do with it (e.g. import into QGIS)?
Without these answers, it doesn't make sense for anyone to suggest something to you that could be totally impossible for you to execute. Please answer these and think through your workflow from beginning to end and/or visa versa.
Cheers,
Shawn

JBPM and JPanel

I want to represent a business process that I will have from an XML file and represent it in a JPanel, and I need also to visualize its evolution in time by changing colors (for example).
Do you know from where I should start, or if jBPMN can be connected to java and represented in my interface.
Any help will be appreciated.
The jBPM web designer can generate a PNG or SVG from an XML file (either by exporting as PNG or you can automatically save the SVG next to the process in the workbench repository when you save the process in designer. Your JPanel could retrieve this process PNG or SVG, and annotate it by first querying the current state of your process (from the engine or the audit tables directly) and using that to highlight certain nodes for example.
For the next version of jBPM we're working on a REST call that would automate all of that for you.
I think I am going to use JGraphix to draw my bpm, because as I saw, it give the possibility to draw shapes like bpmn ones.
I didn't see if it allows to change the color of the task case after x minut, but I guess it's going to be possible, and it's going to be the way to represent the evolution of the process at run time.
Do you think it's an Ok idea ?

What's the best way to save PowerPoint slides as images

I'm trying to find a way to copy the whole slide, and paste it with the formatting of 'as an image' to a blank slide, using POI's APIs.
The reason why I'm trying to do this is because I want to save each slide as an image.
The POI's Slide.draw() API by itself does not do a very good job of saving the slides' contents to images.
For example it cannot draw the following two types of objects:
Tables created on PowerPoint
Charts pasted from Excel
Is there any way to 'copy' and 'paste with formatting (as an image)' via POI, just like you do these two operations on MS PowerPoint running on a Windows, in order to save the slides as they are?
Since Slide.draw() works just fine with images, once I paste all the objects as a single flat image onto a slide (using POI), I'll be good to go.
Or if there is a better way to save the slides contents as intact as possible, could you please let me know?
The license which comes along with the method needs to be Apache license or otherwise something more permissive.
Also, I read the following post:
Programmatically extracting slides as images from a PowerPoint presentation (.PPT)
unoconv is GPL-licensed, so it is not an option for us.
JODConverter is LGPL-licensed; I'm not sure if it's acceptable so I will talk to my boss and check.
Then I ran the POI as a command line tool, as suggested by Michael,
but I ended up getting the same problem (tables and pasted Excel charts
do not show up in the saved images.)
Thanks.

Using SVG + Java for flexible information display, is this viable?

I have a requirement to create a "mimic" display of a complex electrical system. I have access to real-time status information and system block diagrams in Visio.
Is this a viable approach:
Create an SVG drawing from the system block diagram
Tag the SVG elements of interest with SVG attributes
load the SVG DOM into java
locate the tagged elements and modify them according to system status info (make the element RED if its "in alarm", for example)
render the SVG to PNG for display using BATIK (use a the swing component: JSVGCanvas)
A key requirement is flex ability to modify the SVG after the app is deployed. The app capable of flexibly pulling in different "datapoints" based on the tags in the SVG.
Anyone have success using a similar strategy?
What pitfalls should I expect?
What is out there in the way of SVG editing tools?
I've done something similar for a state of health display. I actually annotated the data objects and had them push their state into a dumb SVG file but the machinery should be roughly the same just reversed.
Benefits:
Makes complex, dynamic diagrams insanely easy to render.
Diagram maintenance is a breeze compared to everything else I've ever used.
Ability to target a web app either directly via SVG or an indirectly via server-rendered images delivered to the client.
Pitfalls:
Data binding can be painful depending on how complex you want your visualization to be. If you want to annotate the SVG to pull data into itself, this will probably end up being the hard part.
You'll need a good grasp of XPath to do anything even slightly tricky. It's never hard but is often tedious to debug XPath expressions.
Editors:
Inkscape. There's a few other vector graphics editors out there that can do SVG, either directly or as an export target, but none of the ones I've seen come close to Inkscape. It doesn't support every feature in the current SVG spec but it sounds like it'll be enough for most if not all of what you want. It's also pretty good about not blasting hand-edits to SVG files for when you need to something it doesn't support.
You should have also a look at SVG Salamander, I have not used it myself but some of the features are:
"An index of all named shapes in the SVG graph is easily accessible. "
"Direct access to the scene graph tree. You can use Java commands to manipulate it directly."

How do I create a GUI to customize content using Java?

This is for my Java programming assignment, and I've only been working with Java for about 3 months.
We need something simple, so I thought of going with a program that allows the user to customise and design a greeting card cover. Not too complex, it's an introductory course. I would really like some guidelines on how to go about this, and if there is some existing code available. We are allowed to refer to existing codes to create our program as long as we include it as a reference.
So far I can only think of something that can allow custom borders, or a bunch of existing borders as options, fonts, colours and background choices, either colours or textures.
I would appreciate all the help I can get. Thanks.
You could use Jasper reports and create different templates with thumbnails for greeting cards. User would fill the required fields and select thumb of report template. You would then load and preview the selected report.
If you would like more complex solution, you could create "plugin engine" which would allow user to load custom Jasper report templates. You could then save the plugin reports data in xml file. That should be more than enough for any school project.
You could use your knowlege in any future project since you would learn how to create reports, how to create xml files and a lot more ... Most application today use reports and xml files so it would be more than useful knowledge.

Categories