How to create user notification message similar to JGrowl - javafx-2

I started to work to user notification message similar to JGrowl for JavaFX.
public void newMessage()
{
final Stage newConnDialog = new Stage();
newConnDialog.initStyle(StageStyle.UNDECORATED);
newConnDialog.initModality(Modality.WINDOW_MODAL);
// Set pisition
newConnDialog.setX(1050); //secondStage.setX(primaryStage.getX() + 250);
newConnDialog.setY(150);
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(5);
grid.setVgap(5);
grid.setPadding(new Insets(20, 20, 20, 20));
// text
Text productName = new Text("Test");
productName.setFont(Font.font("Verdana", 12));
grid.add(productName, 0, 2);
// Configure dialog size and background color
Scene aboutDialogScene = new Scene(grid, 200, 100, Color.WHITESMOKE);
newConnDialog.setScene(aboutDialogScene);
newConnDialog.show();
}
I have a basic knowledge about JavaFX. Can you give me some basic advice what will be the best way to implement this component. For example do I need to create new Stage or I can use other component as stage. How I can hide the component after 10 seconds activity and etc. Any advice will be highly appreciated.
P.S.
I found this example for JavaFX 1.3 Maybe it can be rewritten for JavaFX 2.2?

This is one possible solution by using the Enzo library:
// Create a custom Notification without icon
Notification info = new Notification("Title", "Info-Message");
// Show the custom notification
Notifier.INSTANCE.notify(info);
// Show a predefined Warning notification
Notifier.INSTANCE.notifyWarning("This is a warning");
Source

You can use the ControlsFx library to create notifications
http://docs.controlsfx.org/org/controlsfx/control/NotificationPane.html

you can try JFXToast see github
that can help you doing this work
this is an class for empelement toast in javafx

Related

JAVAFX imageview allow user to add tag

I am making an image gallery using javafx, i wish to have the feature which allow the user to add some tag(for human faces) to the imageview when the user is onclick at the imageview, it should grab the position of the mouse pointed and prompt a dialog for user to enter the name for the face and save it to database.
Is this achievable by using javafx?
If yes, how should i do that?
Your help is appreciated.
Sample output of my application below:
Sure it's possible. I created this simple example for a single Image that adds a button to the scene which adds a circle where the image was clicked. This should demonstrate the approach.
#Override
public void start(Stage primaryStage) {
ImageView imageView = new ImageView(...);
imageView.setPreserveRatio(true);
imageView.setFitHeight(200);
StackPane pane = new StackPane();
StackPane.setAlignment(imageView, Pos.TOP_LEFT);
pane.getChildren().add(imageView);
VBox box = new VBox(pane);
pane.setOnMouseClicked(evt -> {
if (evt.getButton() == MouseButton.PRIMARY) {
// create node(s) that uses the click data
Button button = new Button("Show point");
button.setOnAction(e -> {
// do something with the data on user interaction
box.getChildren().remove(button);
Circle circle = new Circle(evt.getX(), evt.getY(), 5, Color.RED);
Pane circlePane = new Pane(circle);
StackPane.setAlignment(circlePane, Pos.TOP_LEFT);
pane.getChildren().add(circlePane);
});
box.getChildren().add(button);
}
});
Scene scene = new Scene(box, 200, 300);
primaryStage.setScene(scene);
primaryStage.show();
}
For your application you would:
Create a different event handler that creates and/or initializes the UI according to your needs or shows a dialog. You also would register the listener to the ImageView directly (unless you need to add some elements on top of it, like I do)
Calculate the real click position in image coordinates using evt.getX() * imageView.getImage().getWidth() / imageView.getLayoutBounds().getWidth() (absolute position) or evt.getX() / imageView.getLayoutBounds().getWidth() (relative position); procede accordingly for y position. Do this calculation directly in the click handler, not when the user submits the entered information, since you may want the user to be able to resize the image. Also if you use the viewport property, you need to modify the calculations accordingly.
Create a different thread that sends the information to the database, when the user submits his/her edits. Of course you also need to store some information about the image currently shown in the ImageView somewhere.

How to listen to android googlemaps geofence transitions

How can i make something happen when my location on a map enters and exits one of my application google map's fence. I cant seem to understand the tutorial of google regarding geofencing. And i cant find any other tutorial of this thing.
this are my code..
#Override
protected void onCreate(Bundle savedInstanceState) {
...
buildGeofence(14.728801, 120.961209, "Id_test", 500);
}
private void buildGeofence(double latitude ,double longitude, String requestId, int radius){
int GEOFENCE_TRANSITION_ENTER = 1;
LatLng geofencePoint = new LatLng(latitude, longitude);
//int radius = 500;
Geofence.Builder geofence = new Geofence.Builder();
geofence.setCircularRegion(geofencePoint.latitude,geofencePoint.longitude, radius);
geofence.setRequestId(requestId);
geofence.setExpirationDuration(Geofence.NEVER_EXPIRE);
geofence.setTransitionTypes(GEOFENCE_TRANSITION_ENTER);
geofence.setNotificationResponsiveness(0);
geofence.build();
CircleOptions circleOptions = new CircleOptions();
circleOptions.center(geofencePoint);
circleOptions.radius(radius);
circleOptions.strokeColor(Color.BLACK);
circleOptions.strokeWidth(2);
circleOptions.fillColor(0x30ff0000);
mMap.addCircle(circleOptions);
}
Dens,
To make something happen when you transition the Geofence you need to
Create an intent for Geofence transitions.
Create a GeofencingRequest.
Add the intent, GeofenceingRequest, and GoogleApiClient to the LocationServices.GeofencingApi API.
Handle the intent.
The code you have written so far will create a geofence and a circle on the map, but it will not yet do anything when the fence is transitioned.
In the tutorial you linked, you successfully created a geofence, but now you need to follow some of the other steps. Make sure you follow the steps in "Specify geofences and initial triggers", "Define an Intent for geofence transitions", and "Add geofences". This should complete steps 1, 2, and 3 that I listed above. One you have those steps working, try the section "Handle Geofence Transitions", which will complete step 4 that I listed above.
I hope this helps you!
P.S.: Since I see you are adding circles to the map, you may quickly discover you need a way to keep track of these circles in order to correctly add and remove them for each geofence. There is a short blog post here that discusses how to do this.

Integrating SmartGWT Layout in Vaadin 7

I want to use a SmartGWT Layout in Vaadin 7. I searched it everywhere; But, couldn't get the correct tutorial or any source code. Can anyone help me in this?
And, I tried in SmartGWT.
I created a Layout in SmartGWT.
public class SmartGWTLayout extends Widget {
public SmartGWTLayout() {
TabSet tabSet = new TabSet();
tabSet.setTabBarPosition(Side.TOP);
tabSet.setWidth(400);
tabSet.setHeight(200);
Tab tTab1 = new Tab("Blue", "pieces/16/pawn_blue.png");
Img tImg1 = new Img("pieces/48/pawn_blue.png", 48, 48);
tTab1.setPane(tImg1);
Tab tTab2 = new Tab("Green", "pieces/16/pawn_green.png");
Img tImg2 = new Img("pieces/48/pawn_green.png", 48, 48);
tTab2.setPane(tImg2);
tabSet.addTab(tTab1);
tabSet.addTab(tTab2);
VLayout vLayout = new VLayout();
vLayout.setMembersMargin(15);
vLayout.addMember(tabSet);
vLayout.setAutoHeight();
vLayout.draw();
}
}
I called the Layout in Vaadin like this.
SmartGWTLayout aSmartGWTLayout = new SmartGWTLayout();
vaadinLayout.addComponent((Component)SmartGWTLayout);
And, I'm getting this error
HTTP Status 500 - java.lang.NoClassDefFoundError: com/google/gwt/core/shared/GWTBridge
type: Exception report
message: java.lang.NoClassDefFoundError: com/google/gwt/core/shared/GWTBridge
description: The server encountered an internal error that prevented it from fulfilling this request.
This is not the right way to use GWT Widget in Vaadin.
Try to follow this tutorial:
http://java.dzone.com/articles/using-gwt-widgets-vaadin-7
http://java.dzone.com/articles/using-gwt-widgets-vaadin-7-0
http://java.dzone.com/articles/using-gwt-widgets-vaadin-7-1
If you use the Vaadin Plugin for Eclipse: https://vaadin.com/eclipse
You can create a new Widget with all the features (necessary classes, xml files and widgetset) at:
Project/New/Other/Vaadin/Widget

EXT.Net - Dynamic UserControlLoader with Property

I need a solution to the below scenario. I'm developing an application in ASP.Net with the help of EXT.Net Controls.
In my scenario, I'm creating dynamic tabs (EXT.Net) and loading an User Control dynamically with UserControlLoader component.
How can I pass a parameter to the UserControl dynamically? Below is my sample code.
[DirectMethod]
public void AddNewTab()
{
getTitle gt = new getTitle();
Ext.Net.Panel panel = new Ext.Net.Panel
{
Title = gt.Title(),
Closable = false,
Layout = "Fit",
Items = {
new UserControlLoader{
Path="ElementChooser.ascx"
}
}
};
TabPanel1.Add(panel);
panel.Render();
TabPanel1.SetLastTabAsActive();
}
Your help is highly appreciated.
It is a bit unclear what "pass a parameter to a User Control" means, but I think you need to handle the UserControlLoader's OnUserControlAdded and OnComponentAdded events.
The first one fires when a user control is added to a UserControlLoader.
The second one fires for each top level Ext.NET component from a user control.
These events helps to configure a user control and its components as needed.
Here is an example with the OnComponentAdded example.

Android programmatically created MapView v2 is not displayed

I updated RawMapViewDemoActivity.java in the Android Google Maps v2 sample app to programmatically create a MapView but map is not displayed. I just get a blank screen.
I replaced
mMapView = (MapView) findViewById(R.id.map);
with
GoogleMapOptions options = new GoogleMapOptions();
options.camera(new CameraPosition(new LatLng(0, 0), 15, 0, 0));
mMapView = new MapView(this, options);
mMapView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
What am I doing wrong?
Have you forwarded all the livecycle methods to the new MapView?
mMapView.onCreate(savedInstanceState);
Take a look at the API Reference
Sorry - I fixed this a while ago, but forgot to post the answer.
It seems that a MapView must be placed in a layout container before it will be correctly displayed. The following snippet shows what I did to make the sample work.
LinearLayout linearLayout = new LinearLayout(this);
GoogleMapOptions options = new GoogleMapOptions();
options.camera(new CameraPosition(new LatLng(0, 0), 1, 0, 0));
mMapView = new MapView(this, options);
linearLayout.addView(mMapView);
setContentView(linearLayout);

Resources