i want to delete edge (connector) from vertices which are seleted. i am using mxgraph - jgraphx

i want to delete edge which is actually connector between veritce of two shapes. i want to delete connector between the vertices which are selected by click a button.
i have used this code but it does not give me help.
graph.getModel().beginUpdate();
try {
graph.getModel().remove( edge);
} finally {
graph.getModel().endUpdate();
}
i have much study the answer of
http://forum.jgraph.com/questions/4744/delete-edge
this question but it does not give us any help.
thanks

JButton b1 = new JButton ("Clear");
b1.addActionListener(new ActionListener(){
// cell = component.getCellAt(e.getX(), e.getY());
#Override
public void actionPerformed(ActionEvent arg0){
graph.selectChildCell();
graph.removeCells();
}
});

Related

Javafx Hyperlink parameters on action

Thank you for reading my question and apologies for the noobness
I am writing my first JavaFX application in which I have an array of hyperlinks which have latitude longitude (e.g. "42N 7E") in the text value of the hyperlink which is being updated every second from another Thread and updates the hyperlink text in the Main Thread. (This works fine)
public static void setPosLatLong(String posLatLong, int SID) {
Main.posLatLong[SID].setText(posLatLongValue);
}
I am trying to use the value in the hyperlink text when clicking on the hyperlink to dynamically change the destination URL with the latest latlong values... but I get the error 'local variables referenced from a lambda expression must be final or effectively final'
int SID = 'id of the hyperlink corresponding to a machine'
posLatLong[SID] = new Hyperlink();
posLatLong[SID].setOnAction((ActionEvent event) -> {
getHostServices().showDocument("http://maps.google.com/maps?z=17&q=" + posLatLong[SID].getText());
});
I have tried all kinds of ways to get around this but I am shamefully stuck. If anyone could point me in the right direction so that the last updated value in the hyperlink array is passed as a parameter when opening the browser it would be greatly appreciated.
I think I managed to find a solution myself so I'll post it in case it could be useful to someone
posLatLong[i].setOnAction(new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent event) {
String eventLatLong = "";
Object source = event.getSource();
if (source instanceof Hyperlink) {
Hyperlink link = (Hyperlink) source;
eventLatLong = link.getText();
}
getHostServices().showDocument("http://maps.google.com/maps?z=17&q=" + eventLatLong );
}
});
Tada !

adding dynamic data to MPAndroidChart

Can anyone explain with a simple example on how to add the data dynamically to the chart which is already drawn. I tried with the details in the github link to add the data, but couldn't do so. A very short example or link is also fine. Thanks
You can download the project here https://github.com/PhilJay/MPAndroidChart/archive/master.zip
Open the project, and in MPChartExample, you have the file DynamicalAddingActivity.java.
You need to create the chart:
Add dataSet (your line(s)) with the values (please view the example in
addDataSet() method in MPChartExample project).
After you can do a CountTimerDown that add a new Entry, for the
dataset.
/** each 5 seconds **/
new CountDownTimer(5000, 1000) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
double randomValue = 19.0 + (Math.random() * (21.0 - 19.0));
int indexOfMyLine = 0;
Entry newEntry = new Entry((float) randomValue, indexOfMyLine);
}
}.start();

Apache Wicket - Implementing AbstractToolbar with DefaultDataTable

I am trying to add an AbstractToolBar to a DefaultDataTable.
The toolbar has a button on click of which the selected rows should get deleted.
My table has a checkbox column, to select the rows.
AbstractToolBar implementation looks like this -
public class GridToolBar extends AbstractToolbar {
/**
*
*/
private static final long serialVersionUID = -2126515338632353253L;
Button btnDelete;
List<Contact> selected;
public GridToolBar(final DataTable<?> table) {
super(table);
// TODO Auto-generated constructor stub
btnDelete = new Button("delete",new Model("Delete"));
btnDelete.setOutputMarkupId(true);
btnDelete.add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = 6720512493017210281L;
#Override
protected void onEvent(AjaxRequestTarget target) {
System.out.println(selected);
((UserProvider)table.getDataProvider()).remove(selected);
target.add(table);
}
});
add(btnDelete);
}
public void setSelected(List inList){
selected = inList;
}
}
The toolbar has been added to table as follows -
GridToolBar tb = new GridToolBar(table);
tb.setOutputMarkupId(true);
table.addTopToolbar(tb);
The code works fine, except on click of delete button it adds an additional delete button below the table. On inspecting it with firebug, the ids of both the buttons match exactly. On sorting the table though, the extra button is removed from the view.
Could someone help me how can I avoid creation of extra button on every click?
Why is it being created in the first place?
Any help is appreciated.
Thanks,
Sonam
You add the button directly to the table. This is incorrect, as you cannot have a button in a table. You need a <td> element. You can create one using a WebMarkupContainer. See also the source of for example NoRecordsToolbar

MDI Parent and Children

I have four children in a parent container. Each child form is a test for the user to type correct answers into text boxes. Option to open each form is on a menu strip in the parent. In form load, I have disabled all but the first form option. I only want the second form to become available if the first form answers are correct. I would like to figure this out on my own as much as possible. I have searched on line but since I am not sure what to ask, I have not found and answer. Can someone get me started in the right direction? Perhaps some reading that would explain how to go about this, or what I should be typing into google to get what I'm looking for.
Thanks.
private bool CheckFormExistence(stringformName)
{
bool formFound = false;
foreach (Form formTest in MdiChildren)
if (formTest.Name== formName)
{
Activate();
formFound = true;
}
return formFound;
}
private void toolStripMenuItemStationOne_Click(object sender, EventArgs e)
{
bool formExists = false;
FormBlue1 blueOne;
formExists = CheckFormExistence("FormBlue1");
if (!formExists)
{
blueOne = new FormBlue1();
blueOne.MdiParent = this;
blueOne.Show();
}
}

Inserting an Action button from an AbstractPropertySection

I have a tabbed propertiesContributor (and a few propertySections to go with it) using the org.eclipse.ui.views.properties.tabbed.propertySections extension point
I should like to place a tab-specific 'refresh' action-button into the action-bar, and cannot see how it should be done. There is a very tantalising method ..
TabbedPropertySheetPage.setActionBars( ... )
... available in 'createControls()' but I cannot see how I make use of that.
Can anyone point me at some working example code on how to achieve this?
Your clues & boos are most welcome.
M.
The solution was to use an instance of org.eclipse.ui.SubActionBars and add the tab-specific Actions to it, like this ...
#Override
public void createControls(Composite parent, final TabbedPropertySheetPage aTabbedPropertySheetPage)
{
...
makeActions();
subActionBars = new SubActionBars( tabbedPropertySheetPage.getSite().getActionBars() );
subActionBars.getToolBarManager().add( refreshAction );
subActionBars.getMenuManager().add( refreshAction );
}
.. then override aboutToBeShown() and aboutToBeHidden() like this ...
#Override
public void aboutToBeShown()
{
super.aboutToBeShown();
subActionBars.activate();
subActionBars.updateActionBars();
}
#Override
public void aboutToBeHidden()
{
super.aboutToBeHidden();
subActionBars.deactivate();
subActionBars.updateActionBars();
}
I don't think there is a way to add a Tab specific action to the view's action bar. You may have to add the action in a section of that tab only.