Raphael how to access element in Another drawing area or canvas - raphael

I have two drawing areas like paper = raphael(...) and paper1= raphael(...). How to access elements of canvas in another...I have a path in paper1 and i want to access its attributes from paper. Any suggestions?

Create an element that contains both papers and access them from there...there will be no magic between the 2 different papers... or add each paper in the other, so you can do this:
var myCurrentPaper = myElementInPaperOne.paper;
var myOtherPaper = myCurrentPaper.paperTwoReference;

Related

Getting a string from QGraphicsSimpleTextItem from QGraphicsItem foreach loop?

I am making an image annotation system Using qrect and Simple text items.
I am trying to store the string values from the QGraphicssimpletext items into a JSON file to save and load the annotation boxes. The rectangles work fine but I cannot understand how to get a string value. This is the foreach I am trying to loop through for each item, and as the text items are children of the rectangles the position does not matter.
foreach(QGraphicsItem* item, items())
{
arrayPosX.push_back(item->x());
arrayHeight.push_back(item->boundingRect().height());
arrayWidth.push_back(item->boundingRect().width());
arrayPosY.push_back(item->y());
arrayAnnotation.push_back(item->?);
}
Both the simple text and rect items are added to the scene using
itemToDraw = new QGraphicsRectItem;
this->addItem(itemToDraw);
simpleTextToDraw = new QGraphicsSimpleTextItem;
this->addItem(simpleTextToDraw);
I would simply like to know how I could get the string values from the simple text item as to allow saving and loading of both strings and boxes, not just boxes which the current system can do.
You have to cast and verify that the pointer is not null:
// ...
arrayPosY.push_back(item->y());
if(QGraphicsSimpleTextItem* text_item = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(item)){
arrayAnnotation.push_back(text_item->text());
}

How can I set the color of a specific line in a libgdx list?

I am developing a list and I want to highlight certain lines by showing the font color in red. Is this possible?
EDIT:
Ok, here a simplified version of my code:
Skin defListSkin = new Skin(Gdx.files.internal("data/uiskin.json"));
List listHistory = new List<String>(defSkin);
// Here I set the general font color for the list
List.ListStyle listStyle = listHistory.getStyle();
listStyle.font = fontList;
listStyle.fontColorUnselected = Color.LIGHT_GRAY;
listHistory.setStyle(listStyle);
String[] items = new String[20];
// Example of item[]
// item[0]: "John 12"
// item[1]: "Amy -3" <-- I want certain lines to appear in red (e.g. those with negative numbers)
// Populate the list
listHistory.setItems(items);
// Drawing the list (actual draw happens in render() of course)
Table myTable = new Table();
myTable.add(listHistory);
stage.addActor(myTable);
Use the Color Markup Language that Libgdx supports.
The markup syntax is really simple but still versatile:
[name] Sets the color by name. There are a few predefined colors, see the Colors.reset() method for an exhaustive list. Users can define their own colors through the methods of the Colors class.
[#xxxxxxxx] Sets the color specified by the hex value xxxxxxxx in the form RRGGBBAA where AA is optional and defaults to 0xFF.
[] Sets the color to the previous color (kind of optional end tag)
[[ Escapes the left bracket.
Markup is disabled by default. Use the public member font.getData().markupEnabled to turn it on/off.
Reference: https://github.com/libgdx/libgdx/wiki/Color-Markup-Language
If you want a more complex html like markup you can use those templates: https://github.com/czyzby/gdx-lml, live tests: http://czyzby.github.io/gdx-lml-tests/
I know what you mean, and I don't think it is possible. The list items are all linked to the same listStyle, and the only way to change the color of the list items is to make a new style for listHistory and change the font color of this style, however if you do this, it changes every item in the list to that new font color. My suggestion would be to create two separate lists and two separate ListStyles and the lines you want red be in one list and have one style and the lines you don't want to be red be in another list and have a different style. Hope this helps

google areachart cannot access datatable rows

I'm using google chart API to draw an area chart.
The chart represents an altimetric profile and when I pass the mouse over it, it shows the position (lat and long) from the underlying data table.
So I created my chart:
data = new google.visualization.DataTable(json);
chart = new google.visualization.AreaChart(document.getElementById("chart-output"));
and draw it:
chart.draw(data, options);
and add an handler for the mouseover event
When the event triggers, I want to get the row from the underlying data source
if (event.row != null && event.column != null){
//data is the chart datasource
var o = data.D[event.row];
var sel_x = o.c[0]["coords"]["x"];
var sel_y = o.c[0]["coords"]["y"];
... //show x, y
}
The point is that when the project was first released, last year, everything worked fine and the property data.D actually contained the desired value.
But now, I've found that the same property is undefined and the rows array is found in property data.tf.
I would expect to gain access to the datasource rows through a getter method, but I cannot find the right one. The datatable method ǵetRowProperties(rowIndex) does not provide any content.
What am I doing wrong?
Thanks and regards
**EDIT 12/09 **
#Juvian
Thanks for yr reply, but it's a bit more complicated than that.
My datasource is like this:
{"cols":
[
{"id":"distance","label":"Distance","type":"number"},
{"id":"asfaltocemento","label":"Asphalt/Beton","type":"number"},
{"id":"rocciaghiaia","label":"Fels/Schotter","type":"number"},
{"id":"ghiaccio","label":"Eis","type":"number"},
{"id":"terraprato","label":"Erde/Wiese","type":"number"},
{"id":"sassolastricato","label":"Stein/Pflaster","type":"number"},
{"id":"sconosciuto","label":"Unbekannt","type":"number"}],
"rows":
[
{"c":[{"v":0,"coords": {"x":1296400.1245177952,"y":5885847.104437432,"z":1345.275458520788,"segment_no":0}},{},{"v":1345.275458520788},{},{},{},{}]},
{"c":[{"v":2.8740587294156668,"coords":{"x":1296395.9416741736,"y":5885847.412533606,"z":1345.4754191288682,"segment_no":0}},{},{"v":1345.4754191288682},{},{},{},{}]},
{"c":[{"v":17.583008965075226,"coords":{"x":1296374.532888888,"y":5885848.966197753,"z":1346.3169989102385,"segment_no":0}},{},{"v":1346.3169989102385},{},{},{},{}]},
{"c":[{"v":23.830815143830804,"coords":{"x":1296365.4205057025,"y":5885849.273363226,"z":1346.724445260275,"segment_no":0}}, {},{"v":1346.724445260275},{},{},{},{}]},
....
]}
When I get the event from the graphic, I retrieve the needed values this way:
var o = data.tf[event.row];
var sel_x = o.c[0]["coords"]["x"];
var sel_y = o.c[0]["coords"]["y"];
I know it's not a good practise to use property (tf) and I should use accessor like getValue(), but using the getValue method I can't access 'coords' object and its subobject.
Any help will be appreciated
Well, data.d is not a public method, so google can make changes to that, you should use public methods instead for consistency.
Try this:
var sel_x = data.getValue(event.row, 0); // supposing your x value is in fisrt column
var sel_y = data.getValue(event.row, 1); // supposing your y value is in second column
More info here: Google DataTable

Colour report rows that contain the same product name

I have a list of products and I am trying to alternate the colour between each product (grey, white, grey, white, and so on). I understand how to use colour formatting based on a condition such as the following link: example followed. However I dont know how to get it to look at the previous line on the report and check whether it holds the same product name. If it does, then colour the row the same colour, else the alternate colour.
I've setup an example report in the application: Application 67666 - Colour Row by Product example. I have two products in the report so I'm trying to get 3 grey lines and then 3 white lines, if I had more products it would then go back to grey and so on.
Link:apex.oracle.com
workspace: apps2
user: user
password: DynamicAction2
Please could I be directed in the right direction, JavaScript and Dynamic Actions shout out to me as in the example link however its looking at the previous row which is getting me all stuck.
I can't think of another solution than javascript really. There is possibly using lag in the sql, but only to use it to determine where the row color should change. You could use the value of the column in a html expression of a column and put it in a class, but you still need to iterate over it with javascript anyway. So it seems less fiddly to just use javascript.
Inline CSS:
table.report-standard tr.normalRow td{
background-color: green;
}
table.report-standard tr.altRow td{
background-color: red;
}
This will override the default style, but you will need to tune this to your demands. For example, the color change on :hover of the row. I prefer steering the style through assigning classes and then define the rules in css than to directly assign css through javascript (which would place it in style tags, ugh).
Dynamic action: change row colour
After Refresh, Region, Product Report
True action: execute javascript code, fire on page load checked
$('td[headers="PRODUCT"]', this.triggeringElement).each(function(){
var lCurrRow = $(this).closest('tr'),
lPrevRow = lCurrRow.prev(),
lPrevVal = lPrevRow.find('td[headers="PRODUCT"]').text();
console.log(lPrevVal + ' - ' + $(this).text());
//if value on previous row differs from the that on the current row
//then change the class
//if the value didnt change, then use the same class as the previous row
if ( lPrevVal != $(this).text() ){
if ( lPrevRow.hasClass('normalRow') ){
lCurrRow.addClass('altRow');
} else {
lCurrRow.addClass('normalRow');
};
} else {
if ( lPrevRow.hasClass('normalRow') ){
lCurrRow.addClass('normalRow');
} else {
lCurrRow.addClass('altRow');
};
};
})
Check your solution on apex.oracle.com, I implemented it there.

Sencha Touch 2 list background change

I have a list within my application, but was wondering if it is possible to have each list displayed show a different background colour, rather than the same one through out each item?
I have created a template but would be nice to have the background of each change colour.
Thanks
EDIT: I have also created the same list via a 'Ext.dataview.component.DataItem' / 'DataView' so if this is easier to control separately then great, as I am looking at interfering in te process of creating each and setting its background, if that is at all possible.
You could try to do that with simply XTemplate:
var tpl = new Ext.XTemplate(
'<p>Name: {name}</p>',
'<p>Company: {[values.company.toUpperCase() + ", " + values.title]}</p>',
'<p>Kids: ',
'<tpl for="kids">',
'<div class="{[xindex % 2 === 0 ? "even" : "odd"]}">',
'{name}',
'</div>',
'</tpl></p>'
);
take a look at their explanations, might find something interesting:
http://docs.sencha.com/touch/2-0/#!/api/Ext.XTemplate
I have seen many variants on the Ext.query('class').up().addCls('backgroundClass'); hack, which makes perfect sense to me, but my question is WHEN are people calling this? I can't put it in 'painted', since DOM doesn't seem to exist yet.. where/when are you guys executing the Ext.get(..) call?
I have been looking for this also, and I had a hard time finding out how to access the individual items of a xlist...
This is the way I finally did it:
in your itemTpl, add a class to your < div >, using the property 'id' of your model:
itemTpl:'< div class="my_list_item_{id}"> ... content ... < /div>'
the tricky part is that if you want to set the background color of the whole item area, you have to access to < div > with class 'x-item-label' that is wrapping your itemTpl < div >.
Here is how I did it (for the first item as an example):
Ext.select('.my_list_item_1').first().up('div.x-list-item-label').addCls('background_item');
where 'background_item' is a CSS style, defining your background color.
(Since there is no way (at least that I know of) to get the index count of your items in the 'itemTpl' config, I had to use to automatic 'id' property of my model/store.
Note that if you apply filtering/sorting/... on your store, this property will not be sorted anymore. So if you want to link the order displayed in your list to the 'id' property, you have to do something like 'Ext.StoreManager.get('MyStore').getAt(indexInList).get('id') )
Hope this helps...
Since Sencha Touch 2.2.1 it's also possible to use striped parameter (more info here). It will add x-list-item-odd class to odd items of your list.