You can find objects by key. See if the following example helps:
package charts.test;
import com.dukascopy.api.*;
import com.dukascopy.api.drawings.IHorizontalLineChartObject;
public class HLineKey implements IStrategy {
private IChart chart;
private IHistory history;
@Override
public void onStart(IContext context) throws JFException {
this.chart = context.getChart(Instrument.EURUSD);
this.history = context.getHistory();
ITick tick = history.getLastTick(Instrument.EURUSD);
double price1 = (tick.getAsk() + tick.getBid()) / 2;
IHorizontalLineChartObject hLine = chart.getChartObjectFactory().createHorizontalLine();
hLine.setPrice(0, price1);
hLine.setTime(0, tick.getTime());
chart.addToMainChartUnlocked(hLine);
String hLineKey = hLine.getKey();
IChartObject obj = chart.get(hLineKey);
//note that if object does not have 0th price attribute, an exception will get thrown
context.getConsole().getOut().println("hLineKey="+hLineKey+" object price="+obj.getPrice(0));
}
public void onTick(Instrument instrument, ITick tick) throws JFException { }
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
public void onMessage(IMessage message) throws JFException {}
public void onAccount(IAccount account) throws JFException {}
public void onStop() throws JFException {}
}