I am implement a screenshot app with javafx, like lightshot. I am done with almost all the functionalities, but I am now stuck at the undo operation. I am adding the free draw, line arrows, rectangles etc on a rectangle like this :
selection.setCursor(Cursor.CROSSHAIR);
Arrow arrow = new Arrow();
selection.setOnMousePressed((evt) -> {
rootPane.getChildren().remove(arrow);
arrow.setStartX(evt.getX());
arrow.setStartY(evt.getY());
arrow.setEndX(evt.getX());
arrow.setEndY(evt.getY());
arrow.setStyle("-fx-background-color:red");
rootPane.getChildren().add(arrow);
});
selection.setOnMouseDragged((evt) -> {
arrow.setEndX(evt.getX());
arrow.setEndY(evt.getY());
});
selection.setOnMouseReleased((evt) -> {
arrow.setEndX(evt.getX());
arrow.setEndY(evt.getY());
});
drawtype = "arrow";
});
Selection is the rectangle that I have drawn, this is an example of how I am adding the arrow. I have tried researching online but I cant seem to get something to point me in the right direction, anyone who can help out here please? Remember, I am not using Canvas or GraphicsContext.
If you want to be able to undo the actions, you need to store the state of your 'drawing'.
In your case undoing the creation of your Arrow element, would be simple rootPane.getChildren().remove(arrow);
You just need to create a Data Structure where you store all actions done by the user (or at least a few). And each action can get reversed.
Example:
ActionType.Add -> action: getChildren().add(xyz) -> reverse: getChildren().remove(xyz)
ActionType.Move -> arrow.setEndX(evt.getX()) -> arrow.setEndX(oldX)
Each action should contain all information needed to reverse it. (The node involved, what was done and how it was before)
Related
I'm using Graphviz (and the dot language) to document the operations for a web app . Since there are often many operations available on a page, I've been grouping the mappings for neatness and to prevent repeating myself.
However, I'm unable to get edges to point to the correct field in a record, when the edges are defined in a group. Individually they work fine.
Before anyone asks, I realise record-based nodes are largely superseded by HTML-like labels. However, those are too verbose for what I'm trying to achieve and I don't need the extra features, so I'm sticking with the original.
Here's a working example (you can try running it here):
digraph site_map {
// Pages
{
node[shape=component]
page1[label="Page 1"]
page2[label="Page 2"]
}
// Operations
{
node[shape=record style=filled fillcolor=green]
entity1[label="Entity 1 | {<save> Save |<get> Get |<del> Del}"]
entity2[label="Entity 2 | {<save> Save |<get> Get |<del> Del}"]
}
// Mappings: Page -> Operation
{
// Page 1 - short form (doesn't work)
page1 -> {
entity1:save
entity1:get
entity1:del
entity2:get
}
// Page 2 - Long form
page2 -> entity1:save
page2 -> entity1:get
page2 -> entity1:del
page2 -> entity2:get
}
}
In this example, the edges from Page 1 end up pointing at the entities, rather than the specific operations within them. Is there a tweak to my syntax which can make this work, or an I stuck using the long form?
I need an algorithm to tell a sprite to end as soon as the text finishes appearing, basically I need to make a cutscene which describes the beginning of a story within the game, but since I'm using gamemaker, I don't know how to do it, can someone help me?
For cutscenes and automated image sequences you usually have some sort of variables, that handle the states and counters for displaying sprite's sub-images.
But firstly I like to use mainly two main time-related variables in my controller object usually named sys (counter and counterTime):
c = 0; // and for stepEvent: c += 1; // so it goes +1 per step
ct = 0; // and for stepEvent: ct+= 1 / room_speed; // so it goes +1 per second
During the cutscene you might want to stop everything else that moves:
is_cutscene = false; // objects might not be able to move when this is true
// you still have to implement that by yourself
// player can't move if is_cutscene, nothing happens!!
(except cutscene buttons etc...)
So now when the player gets to a 'cutscene'y object and triggers some cutscene_1 = true eg. you can have the image/text/sound/animation object come to life/create/active... That object might have in the create event:
duration = 6; // 6 seconds the scene lasts
start_time = sys.ct // and in Step: if sys.ct > (start_time + duration)
// then -> cutscene advance/destroy
Ofcourse - this is super simple and now you could only say implement:
walk close to a pop-up object
show an image for 6 seconds
it dissappears
And it might not be big trouble to implement it... BUT THIS may also be the foundation for more advanced multi-step sequence and cuts.
I can find no explanation on what these are actually supposed to do.
There are examples on:
https://jxbrowser.support.teamdev.com/support/solutions/articles/9000102480-forwarding-mouse-events
but 629 and 373 ? I can't figure out what those values are for. I can get the same behaviour with any value for those.
What if you one also sets windowX and windowY ?
What would they do to the result click?
I am looking to be able to click and move on a google map. Is that possible?
The x and y values define the mouse event coordinate inside the browser content area.
The globalX and globalY values define the screen coordinate of the mouse event.
The windowX and windowY are deprecated. If you set them, this doesn't affect anything.
For more detailed information about working with Google Maps, please take a look at the article.
Your browserView must be active/focused first!
Then, let's do this way:
public static void simulateMouseClickOnElement(Browser browser, BrowserView browserView, DOMElement element){
Rectangle rect = element.getBoundingClientRect();
Point ptOnScreen = new Point(rect.x , rect.y );
SwingUtilities.convertPointToScreen(ptOnScreen, browserView);
forwardMouseClickEvent(browser,MouseButtonType.PRIMARY,rect.x,rect.y, ptOnScreen.x, ptOnScreen.y);
}
JxBrowser is the BEST automation or crawling/hacking tool! Selenium is a best alternative choice due to the TCO.
I'm working on a CMS, and want to let users embed Soundcloud tunes and playlists.
I'd like to avoid fiddling with the API - since it doesn't appear to be necessary: )
Instead I just piece together an iframe-src-url with the appropriate parameters.
I was unable to find an official list anywhere, so I've collected my own, from various posts here and elsewhere:
&color=FF4444 // play-button and equalizer graphic (if not &visual=true)
&auto_play=false // shouls be obvious
&show_artwork=true // show the artist-graphic on the left
&show_comments=true // show fans commenst under equalizer
&show_playcount=true // number of times played # bottom right
&hide_related=true // don't force user over to Soundcloud after play
&show_user=false // don't show uploaders name # top left
&show_reposts=false // ?
&liking=false // dont show [Like] button
&visual=true // use artist-graphic for background (way cooler)
&buying=false // no Buy (iTunes) button
&sharing=false // no [Share] button
&download=false // no download button
&start_track=4 // start at specific track (for lists)
And guesed : )
&following=false (removes [Follow] when mouseover artwork)
What parameters am I missing?
What I really want is Next and Previous buttons for lists. Do they even exist?
You're missing:
download=true // Show/hide download buttons
sharing=true // Show/hide share buttons/dialogues
start_track=0 // Preselects a track in the playlist, given a number between 0 and the length of the playlist.
Found in the docs.
It looks like next() and prev() and skip(index) are all methods on the widget rather than parameters. You can get around this by keeping an index of the current track and pass in a value to the start_track parameter as a way to get to the next and previous tracks.
I want to change my origin and destination (Lat and Lng) on click, this is my atual code
ser.route({ 'origin': new google.maps.LatLng(-23.563594, -46.654129), 'destination': new google.maps.LatLng(
-23.563672, -46.640396), 'travelMode': google.maps.DirectionsTravelMode.DRIVING},function(res,sts) {
if(sts=='OK')ren.setDirections(res);
})
I want to change this values to draw a path, for example, I click on one point, them click in another point, so it get this values and draw a path.
I have a path but only with point A and B, I want to create this points clicking on map.
Here is my test with the full code, if needed.
Add a MapsEventListenter listening for the click on the map.
The Map click event has a latLng property. Capture the first one for your start location, the second for your end address (you will probably want to add some logic to either let your user drag them or delete them if they get them wrong).