clear the graphics when mouse is rolledout from a canvas - flex4

I have created a tilelist and each tile of tile list is a canvas where graphics is drawn on rollover. When mouse is rolled out from that particular canvas the graphics drawn has to be removed. So I am doing graphics.clear but not able to remove the graphics.
Code
protected function canvas1_updateCompleteHandler(event:FlexEvent):void
{
var allowHighLight:Boolean = QzGridImpl(this.owner).m_bEnableHighLight;
if(!allowHighLight)
return;
var highLighted:Boolean = TileList(this.owner).isItemHighlighted(this.data);
if(highLighted)
{
high = true;
DrawBackgroundImage(QzGridImpl(this.owner).m_strBackgroundImage as String);
}
//when highlighted becomes false the below part is called
else
{
if(high)
{
this.graphics.endFill();//and cleanly im observing that endfill and clear is getting called and they are able to clear graphics when mouse is rolled out slowly but not able to clear when mouse is rolled out fast.
trace("endfill");
this.graphics.clear();
trace("clear");
}
}
private function DrawBackgroundImage(n_strBackImg:String):void
{
//code for drawing the background image
}
and cleanly I am observing that endfill and clear is getting called and they are able to clear graphics when mouse is rolled out slowly but not able to clear when mouse is rolled out fast.
What need to be done to make it working?

You could create a custom ItemRenderer for the TileList, and apply the image effect when the rollover is triggered in the itemRenderer (by adding a rollOver listener to the renderer). That might work - and is probably a neater way of doing it too.

Related

Refresh button in glTF

Is there an easy way to add a refresh button in glTF?
Or rather reload textures etc?
The way not to do it, would be:
if (gui.reset > 0)
{
console.log("RESET!");
gui.reset = 0;
init();
}
The idea being, not a reset button as such, but a button that changes the texture set,lighting environment,shaders etc. on the same model.
Or is it more practical to load both sets of data and switch between the two?

JavaFX Auto Resizing Group

I have a quite complex scene graph which has led me to some resizing problems. I'd be glad if you could help me solve it.
My root node is a BorderPane that its center is filled with a ListView. Each cell of the ListView is filled with a customized zoomable ScrollPane as below:
public class ZoomableScrollPane extends ScrollPane {
Group zoomGroup;
Scale scaleTransform;
LineChart<Number , Number> content;
double scaleValue = 1.0;
double delta = 0.1;
public ZoomableScrollPane(LineChart<Number , Number> content, double height) {
this.content = content;
this.setPrefHeight(height);
Group contentGroup = new Group();
zoomGroup = new Group();
contentGroup.getChildren().add(zoomGroup);
zoomGroup.getChildren().add(content);
setContent(contentGroup);
scaleTransform = new Scale(scaleValue, scaleValue, 0, 0);
zoomGroup.getTransforms().add(scaleTransform);
}
}
As you can see there is a LineChart inside of each ZoomableScrollPane. I want to do two things with this chart. Firstly, to somehow bind its width with the root layout to get the desired result in case of resizing the window (not zooming, zooming is OK), and secondly to change the chart's width at run time whenever a button is pressed:
public void handleButton(ActionEvent actionEvent) {
MainController.lineChart1.setPrefWidth(MainController.lineChart1.getPrefWidth() + CONSTANT);
}
The problem is that here I face a conflict. Cause the LineChart is the child of a Group (not a pane), I just know one way of resizability and that is to bind its width manually with the root BorderPane's like this:
MainController.lineChart1.prefWidthProperty().bind(fourChannels.widthProperty().subtract(40));
And in that case, I cannot change the LineChart's width at run time and will get A bound value cannot be set Exception.
I guess one solution could be revising the ZoomableScrollPane class to somehow avoid the need of manual binding, but really have no idea how to do it.
Any help on this would be greatly appreciated.
You can detect if a property is bound and then unbind it before manipulating it:
if (content.prefWidthProperty().isBound()) {
content.prefWidthProperty().unbind();
}
...
Presumably when you are zoomed in on a chart and the window is resized the content will already be larger than the viewport, so a forced change in width shouldn't kick in until the window is resized beyond the zoomed in size of the chart?
Given the different conditions you have you might be better off monitoring the size of the BorderPane/ListView and when that changes adjust the size of the charts that need it.

Delay shared element transition to complete statelist animation

I've been trying out shared element transition on Lollipop. i have a recyclerview which loads some cards and one click the card expands to its details in the next activity.
I have set a ripple effect and a StateListAnimator on the card. But those are not visible cause the transition starts before these effects are completed.
Is there any way to delay the transition so that it can wait for the statelist animator and ripple to complete?
Here is the code I use
ActivityOptions options = null;
if (Utilities.isLollipop()) {
options = ActivityOptions.makeSceneTransitionAnimation(this, Pair.create(view, "hero_view"), Pair.create((View) fab, "fab"));
startActivity(detailIntent, options.toBundle());
}
Thanks in advance
I ended up using a work around, but I still would want to know what is the right way of doing this and therefore leaving the question open.
The work around I did was
1. remove the state list animator and add that as an animator in the onclick method.
2. Used a Handler to post a delayed call to the activity
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent i=new Intent(SearxhJobs.this,JobsTypes.class);
startActivity(i);
}
}, 200);
P.S- I did end up removing the effect as it was not very intuitive.
The way that may help some that already have the Transitions setup in Second Activity:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().getSharedElementEnterTransition().setDuration(500);
getWindow().getSharedElementReturnTransition().setDuration(500)
.setInterpolator(new DecelerateInterpolator());
}

AlloyUI Diagram Builder Read-only

I am using the Alloy Diagram Builder to create and display network topology.
I would like to remove default click and drag events attached to each nodes, so viewers would not have the ability "build" diagrams but only view diagrams that I have generated.
http://alloyui.com/examples/diagram-builder/real-world/
I have tried these but it does not work.
// detach click event to all nodes with class aui-diagram-node.
Y.all('.aui-diagram-node').detach("click");
// unbind
$(".aui-diagram-node").each(function(){
$(this).unbind();
});
I believe the event is attached to the container .aui-diagram-builder-drop-container via delegate() and the event would be mousedown.
Merely by accident I found a hack that might work for this. I was adding tooltips to my page on which I had a diagram builder, well apparently the tooltips layer a div over the page and simply set the opacity on it to be clear and the object still resides. After a tooltip had come up i was unable to interact with the piece of the diagram builder the tooltip had popped up over.
So based of this concept, why not try overlaying a div over the entire canvas of the diagram and give it a high z-index so that it sits on top. It should effectively not allow interaction with the canvas.
Yes it's a kludge but it just may work.
To make a DiagramBuilder read-only, you can detach() events from all of its children recursively:
/*
* Readonly the diagram
*/
function ReadonlyDiagram(diagram) {
function detachRecursively(node) {
node.get('children').each(detachRecursively);
// You may also want to set the cursor to the default since it will
// change based on which elements the mouse is over.
// node.setStyle('cursor', 'auto');
// You may want to detach specific events such as 'click' or
// 'mousedown' if you do not want to disable all events.
node.detach();
};
diagram.on('render', function (event) {
detachRecursively(diagram.get('boundingBox'));
});
}
Now, you must be post diagramBuilder object to ReadonlyDiagram function like below codes:
YUI().use('aui-diagram-builder', function (y) {
var diagram = new y.DiagramBuilder(
{
availableFields: data,
boundingBox: '#' + containerId,
fields: nodes,
srcNode: '#' + builderId
}).render();
diagram.connectAll(connections);
if (callBackDiagram !== undefined) callBackDiagram(diagram);
if(isReadonly === true) ReadonlyDiagram(diagram);
});
});
Reference

Filtering events in timeline stops drawing a new event in DHTMLX

dhtmlxscheduler timeline when I use filtering
scheduler.filter_timeline = scheduler.filter_month = scheduler.filter_day = scheduler.filter_week = function(id, event) {
// display event only if its type is set to true in filters obj
if (rules[event.user_id]) {
return true;
}
// default, do not display event
return false;
};
drag animation (drawing a Node/session) doesn't work.
if you look at the DHTMLX_scheduler samples you will see create a new event doesn't work properly.
/samples/09_api/09_filtering_events.html
I am using Trace Skin . Every thing is working well. even light box is loading . the main problem is when I use this statement filter_timeline then Timeline drawing stop draw event.(It can also create it but the it is like transparent)
It is not a bug in scheduler itself, but badly written sample
In code of sample, update next line
CODE: SELECT ALL
if (filters[event.type]) {
as
CODE: SELECT ALL
if (filters[event.type] || event.type==scheduler.undefined) {
When event just created it doesn't have the type defined yet, so it was filtered out with previous logic

Resources