Difference between revisions of "Dragtop"
Line 59: | Line 59: | ||
Then drag & drop your powerpoint files. | Then drag & drop your powerpoint files. | ||
[[File:DragTopStep2_2019-03-21.png|400px]] | [[File:DragTopStep2_2019-03-21.png|400px]] | ||
+ | |||
+ | Then drag & drop a "tool" which can be a jar that follows the dragtop plugin guidelines or simply a fitting rythm template. Dowload https://raw.githubusercontent.com/BITPlan/com.bitplan.dragtop/master/src/test/rythm/pptExtractor.rythm and drag&drop it. | ||
+ | |||
+ | [[File:DragTopStep3_2019-03-21.png|400px]] | ||
+ | As a result your browser should open and show you an "exported" version of your Powerpoint presentation with all images and text "extracted". You'll find the images in your /tmp directory. | ||
+ | |||
+ | === pptExtractor.rythm === | ||
<source lang='java'> | <source lang='java'> | ||
@// Rythm template | @// Rythm template |
Revision as of 09:45, 21 March 2019
OsProject | |
---|---|
id | com.bitplan.dragtop |
state | |
owner | BITPlan |
title | Drag and Drop target desktop application with plugable functionality |
url | https://github.com/BITPlan/com.bitplan.dragtop |
version | 0.0.1 |
description | |
date | 2018/12/03 |
since | |
until |
Installation
git clone https://github.com/BITPlan/com.bitplan.dragtop
mvn clean install -D createAssembly=true
or use the rebuild script which skips Tests and gpg signature
dragtop script
This is a convenience script to start your dragtop. You might want to adapt the base directory setting to your environment
#!/bin/bash
# WF 2019-02-17
#
# start dragtop
#
# uncomment to debug
# set -x
base=$HOME/source/java
case $(uname -a) in
Darwin*)
base=$HOME/Documents/workspace
;;
esac
pdir=$base/com.bitplan.dragtop
if [ ! -d $pdir ]
then
echo "dragtop project missing - will get it"
cd $base
git clone https://github.com/BITPlan/com.bitplan.dragtop
fi
cd $pdir
git pull
jar=$pdir/release/com.bitplan.dragtop.jar
if [ ! -f $jar ]
then
echo "dragtop jar missing - will create"
mvn install
fi
java -jar $jar $*
Using the dragtop
Powerpoint extraction example
You you need one ore more Powerpoint files in pptx format e.g. http://people.apache.org/~sctemme/ApconEU2008/Performance_Out.pptx
Then drag & drop your powerpoint files.
Then drag & drop a "tool" which can be a jar that follows the dragtop plugin guidelines or simply a fitting rythm template. Dowload https://raw.githubusercontent.com/BITPlan/com.bitplan.dragtop/master/src/test/rythm/pptExtractor.rythm and drag&drop it.
As a result your browser should open and show you an "exported" version of your Powerpoint presentation with all images and text "extracted". You'll find the images in your /tmp directory.
pptExtractor.rythm
@// Rythm template
@// you can try Rythm out at http://fiddle.rythmengine.com
@// Created by Wolfgang Fahl, BITPlan GmbH, 2018-12-06
@import com.bitplan.dragtop.DropTarget
@import com.bitplan.dragtop.DragItem
@import org.apache.tinkerpop.gremlin.structure.Graph
@import com.bitplan.simplegraph.powerpoint.PowerPointSystem
@import com.bitplan.simplegraph.powerpoint.SlideNode
@import com.bitplan.simplegraph.core.SimpleStepNode
@import java.util.stream.Collectors
@args() {
DropTarget dropTarget,
Graph graph;
}
@{
PowerPointSystem pps=null;
Throwable error=null;
try {
pps=new PowerPointSystem();
pps.connect();
} catch (Throwable th) {
error=th;
}
}
@// error handling - get a stack trace
@def String getStackTrace (Throwable t) {
StringWriter sw = new StringWriter();
t.printStackTrace(new PrintWriter(sw));
return sw.toString();
}
@def showError(Throwable error) {
<h3 style="color:red">Error @(error.getClass().getName()): @(error.getMessage())</h3>
<pre>
@getStackTrace(error)
</pre>
}
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8"/>
</head>
<body>
@if (error) {
@showError(error)
} else {
@for(DragItem dragItem:dropTarget.getDragItems()) {
@{
Object item=dragItem.getItem();
int index=0;
File file=null;
SimpleStepNode slideShowNode=null;
List<SimpleStepNode> slides=null;
if (item instanceof File) {
file=(File) item;
if (file.getName().contains(".ppt")) {
slideShowNode = (SimpleStepNode) pps.moveTo(file.getPath());
slides = slideShowNode.out("slides")
.collect(Collectors.toCollection(ArrayList::new));
} else {
file=null;
}
}
}
@if (file) {
<h3>@(file.getName())</h3>
<ol>
@for (SimpleStepNode slideNode:slides) {
@{
Object titleProperty=slideNode.property("title");
String title="?";
SlideNode slide=null;
File slideFile=null;
if (titleProperty!=null)
title=titleProperty.toString();
if (slideNode instanceof SlideNode) {
try {
slide=(SlideNode) slideNode;
slideFile=new File("/tmp/"+file.getName()+""+index++);
slide.outputSlideAsImage(slideFile,1.0,false);
} catch (Throwable th) {
error=th;
}
}
}
<li>@(title)
@if (error) {
@showError(error)
} else {
@if (slideFile) {
<img src='file://@(slideFile.getAbsolutePath())'/>
}
}
<pre>@(slideNode.property("text"))</pre>
</li>
}
</ol>
}
}
}
</body>
</html>