Search Results

Search found 2521 results on 101 pages for 'alex yan'.

Page 10/101 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Combination of JFreeChart with JXLayer with JHotDraw

    - by Yan Cheng CHEOK
    Recently, I had use JXLayer, to overlay two moving yellow message boxes, on the top of JFreeChart http://yccheok.blogspot.com/2010/02/investment-flow-chart.html I was wondering, had anyone experience using JXLayer + JHotdraw, to overlay all sorts of figures (Re-sizable text box, straight line, circle...), on the top of JFreeChart. I just would like to add drawing capability, without changing the JFreeChart source code. So that, JStock's user may draw trending lines, annotation text on their favorite stock charting. The code skeleton is as follow : // this.chartPanel is JFreeChartPanel final org.jdesktop.jxlayer.JXLayer<ChartPanel> layer = new org.jdesktop.jxlayer.JXLayer<ChartPanel>(this.chartPanel); this.myUI = new MyUI<ChartPanel>(this); layer.setUI(this.myUI); public class MyUI<V extends javax.swing.JComponent> extends AbstractLayerUI<V> { @Override protected void paintLayer(Graphics2D g2, JXLayer<? extends V> layer) { // Previous, I am using my own hand-coded, to draw the yellow box // // Now, How can I make use of JHotDraw at here, to draw various type of // figures? } @Override protected void processMouseEvent(MouseEvent e, JXLayer<? extends V> layer) { // How can I make use of JHotDraw at here? } @Override protected void processMouseMotionEvent(MouseEvent e, JXLayer<? extends V> layer) { // How can I make use of JHotDraw at here? } } As you see, I already got Graphics2D g2 from paintLayer method. How is it possible that I can pass the Graphics2D object to JHotDraw, and let JHotDraw handles all the drawing. My experience in using JHotDraw are with org.jhotdraw.draw.DefaultDrawingView org.jhotdraw.draw.DefaultDrawingEditor I am able to use them to draw various figures, by clicking on the toolbar and click on drawing area. How is it possible I can use DefaultDrawingView and DefaultDrawingEditor within MyUI's paintLayer? Also, shall I let MyUI handles the mouse event, or JHotDraw? Sorry, I start getting confused.

    Read the article

  • Convert CString to string (VC6)

    - by Yan Cheng CHEOK
    I want to convert CString to string. (Yup. I know what am I doing. I know the returned string will be incorrect, if CString value range is outside ANSI, but That's Is OK!) The following code will work under VC2008. std::string Utils::CString2String(const CString& cString) { // Convert a TCHAR string to a LPCSTR CT2CA pszConvertedAnsiString (cString); // construct a std::string using the LPCSTR input std::string strStd (pszConvertedAnsiString); return strStd; } But VC6 doesn't have CT2CA macro. How I can make the code to work as well in both VC6 and VC2008?

    Read the article

  • Is it possible to prevent out-of-order execution by using single volatile

    - by Yan Cheng CHEOK
    By referring article, it is using a pair of volatile to prevent out-of-order execution. I was wondering, is it possible to prevent it using single volatile? void fun_by_thread_1() { this.isNuclearFactory = true; this.factory = new NuclearFactory(); } void fun_by_thread_2() { Factory _factory = this.factory; if (this.isNuclearFactory) { // Do not operate nuclear factory!!! return; } // If out-of-order execution happens, _factory might // be NuclearFactory instance. _factory.operate(); } Factory factory = new FoodFactory(); volatile boolean isNuclearFactory = false; The reason I ask, is because I have a single guard flag (similar to isNuclearFactory flag), to guard against multiple variables (similar to many Factory). I do not wish to mark all the Factory as volatile. Or, shall I fall into the following solution? void fun_by_thread_1() { try { writer.lock(); this.isNuclearFactory = true; this.factory = new NuclearFactory(); } finally { writer.unlock(); } } void fun_by_thread_2() { try { reader.lock(); Factory _factory = this.factory; if (this.isNuclearFactory) { // Do not operate nuclear factory!!! return; } } finally { reader.unlock(); } _factory.operate(); } Factory factory = new FoodFactory(); boolean isNuclearFactory = false; P/S: I know instanceof. Factory is just an example to demonstrate of out-of-order problem.

    Read the article

  • Sort CMap Key by String Length

    - by Yan Cheng CHEOK
    Previously, I am using STL map to perform the mentioned task. struct ltstr { bool operator()(std::string s1, std::string s2) const { const int l1 = s1.length(); const int l2 = s2.length(); if (l1 == l2) { // In alphabetical order. return s1.compare(s2) < 0; } // From longest length to shortest length. return l1 > l2; } }; std::map<std::string, int, ltstr> m; How can I perform the same task using CMap? // How to make key sorted by string length? CMap<CString, LPCTSTR, int, int> m;

    Read the article

  • Deploy GWT Application to Google App Engine using NetBeans

    - by Yan Cheng CHEOK
    Hello, I try to deploy a GWT application, to Google App Engine using NetBeans. I had successful run GWT sample http://code.google.com/webtoolkit/doc/latest/tutorial/create.html using Personal GlassFish v3 Prelude Domain, by 1) Copy generated source code from StockWatcher to C:\Projects\StockWatcherNetbeans\src\java\com\google\ 2) Modify C:\Projects\StockWatcherNetbeans\nbproject\gwt.properties gwt.module=com.google.gwt.stockwatcher.StockWatcher 3) Select Personal GlassFish v3 Prelude Domain, and run. All works fine! Now, I try to select Google App Engine server, and run. However, I get the error "There is no appengine web project opened!" I check... There is file called C:\Projects\StockWatcherNetbeans\war\WEB-INF\appengine-web.xml with content <?xml version="1.0" encoding="UTF-8"?> <appengine-web-app xmlns="http://appengine.google.com/ns/1.0" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://kenai.com/projects/nbappengine/downloads/download/schema/appengine-web.xsd appengine-web.xsd'> <application>StockWatcherNetbeans</application> <version>1</version> </appengine-web-app> I am using NetBeans 6.7.1 GWT4NB (GWT Plugin for NetBeans) 2.6.12 Google App Engine plugin for NetBeans from http://kenai.com/downloads/nbappengine/1.0_NetBeans671/updates.xml Anything I had missed out? Even when I right click to the project, the Deploy to Google App Engine options is disabled. And yes, please do not ask me why not use Eclipse.

    Read the article

  • What is the best way to create a wizard for web?

    - by Yan
    I want to create a wizard that includes a few steps, that in the final steps we need to include all the steps and save to the data base. What is the best design to do this ? Is there an implementation for jquery ? Do I need to save the steps in session till the final save ?

    Read the article

  • problem with QDataStream & QDataStream::operator>> ( char *& s )

    - by yan bellavance
    QFile msnLogFile(item->data(Qt::UserRole).toString()); QDataStream logDataStream; if(msnLogFile.exists()){ msnLogFile.open(QIODevice::ReadOnly); logDataStream.setDevice(&msnLogFile); QByteArray logBlock; logDataStream >> logBlock; } This code doesnt work. The QByte that results is empty. Same thing if I use a char* . Oddely enough the same code works in another program. Im tying to find the difference between both. This works if i use int,uint, quint8, etc

    Read the article

  • Should I make OR operator to return const reference or just reference

    - by Yan Cheng CHEOK
    class error_code { public: error_code() : hi(0), lo(0) {} error_code(__int64 lo) : hi(0), lo(lo) {} error_code(__int64 hi, __int64 lo) : hi(hi), lo(lo) {} error_code& operator|=(const error_code &e) { this->hi |= e.hi; this->lo |= e.lo; return *this; } __int64 hi; __int64 lo; }; error_code operator|(const error_code& e0, const error_code& e1) { return error_code(e0.hi | e1.hi, e0.lo | e1.lo); } int main() { error_code e0(1); error_code e1(2); e0 |= e1; } I was wondering, whether I should make operator|= to return a const error_code& or error_code& ?

    Read the article

  • Using the word "you" in an user manual

    - by yan bellavance
    I am writing a user manual and I have come to a discussion with a colleague. He says I cannot use the word "you" anywhere in the manual. Now I remember something about this at school but that was not for writing procedures. Also, doing some googling I observed that most tutorials where using it a lot. I would prefer using it but only if this is considered good practice. what do you think?

    Read the article

  • Place JComponent On The Top Of JXLayer

    - by Yan Cheng CHEOK
    Hello, currently, I had successful applying JXLayer on my charting component, to draw a yellow information box on the top of it. final org.jdesktop.jxlayer.JXLayer<ChartPanel> layer = new org.jdesktop.jxlayer.JXLayer<ChartPanel>(this.chartPanel); this.chartLayerUI = new ChartLayerUI<ChartPanel>(this); layer.setUI(this.chartLayerUI); At the same time, I wish to add the following JComponent (DefaultDrawingView) on the top of JXLayer. This JComponent has the ability 1) To receive mouse event to draw figures on itself. Within ChartLayerUI, I add the following code @Override @SuppressWarnings("unchecked") public void installUI(JComponent c) { super.installUI(c); JXLayer<JComponent> l = (JXLayer<JComponent>) c; l.getGlassPane().setLayout(new java.awt.BorderLayout()); // this.view is DefaultDrawingView drawing object. l.getGlassPane().add(this.view, java.awt.BorderLayout.CENTER); } However, after having the above code, I get the following outcome 1) My charting component ChartPanel are being blocked by DefaultDrawingView 2) My charting component no longer able to receive mouse event. What I wish is that A) ChartPanel and DefaultDrawingView able to show up B) ChartPanel and DefaultDrawingView able to receive mouse event Is there other steps I had missed out, or did wrong? Thanks.

    Read the article

  • Can I Always debug multiple instances of a same object that is of type thread with GDB?

    - by yan bellavance
    program runs fine. When I put a breakpoint a segmentation fault is generated. Is it me or GDB? At run time this never happens and if I instantiate only one object then no problems. Im using QtCreator on ubuntu x86_64 karmic koala. UPDATE1: I have made a small program containing a simplified version of that class. You can download it at: example program simply put a breakpoint on the first line of the function called drawChart() and step into to see the segfault happen UPDATE2: This is another small program but it is practically the same as the mandlebrot example and it is still happening. You can diff it with mandlebrot to see the small difference. almost the same as mandlebrot example program

    Read the article

  • breakpoint inside QComboBox subclass not working

    - by yan bellavance
    I have subclassed QComboBox to customize it for special needs. The subclass is used to promote QComboBoxes in a ui file from QtDesigner. Everything works except that when I put a break point in a slot, the program does not stop at the breakpoint. I do however know that it is being called from the result it generates. I checked other slots in my program and they work fine with breakpoints. Doing a clean and rebuild all did not fix it. What could be causing this and is there anything I can do about it? The slot in question is the only one in the subclass and is called "do_indexChanged()". You can find the slot on line 37 of the class header below and the signal-slot connection on line 10 of the class source file. CLASS HEADER: #ifndef WVQCOMBOBOX_H #define WVQCOMBOBOX_H #include <QWidget> #include <QObject> #include <QComboBox> #include <QVariant> class wvQComboBox : public QComboBox { Q_OBJECT //Q_PROPERTY(bool writeEnable READ writeEnable WRITE setWriteEnable) public: explicit wvQComboBox(QWidget *parent = 0); bool writeEnable() { return this->property("writeEnable").toBool(); } void setWriteEnable(const bool & writeEnable){ this->setProperty("writeEnable",writeEnable); } bool newValReady() { return this->property("newValReady").toBool(); } void setNewValReady(const bool & newValReady){ this->setProperty("newValReady",newValReady); } QString getNewVal(); int getNewValIndex(); int oldVal; //comboBox Index before user edit began private slots: void do_indexChanged(){ this->setWriteEnable(true); if(oldVal!=currentIndex()){ this->setNewValReady(true); oldVal=currentIndex(); } } protected: void focusInEvent ( QFocusEvent * event ); //void focusOutEvent ( QFocusEvent * event );//dont need because of currentIndexChanged(int) }; #endif // WVQCOMBOBOX_H #include "wvqcombobox.h" wvQComboBox::wvQComboBox(QWidget *parent) : QComboBox(parent) { this->setWriteEnable(true); this->setNewValReady(false); oldVal=this->currentIndex(); connect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(do_indexChanged())); } void wvQComboBox::focusInEvent ( QFocusEvent * event ) { this->setWriteEnable(false); oldVal=this->currentIndex(); } QString wvQComboBox::getNewVal(){ setNewValReady(false); return this->currentText(); } int wvQComboBox::getNewValIndex(){ setNewValReady(false); return this->currentIndex(); }

    Read the article

  • pass other form elements to ajax suggestion box script

    - by Alex Calder
    I paid somebody to build me a jQuery AJAX suggestion box script a while back. It works great. Now I'm trying to learn about it enough to modify it to do something different. Right now, the script that generates the suggestions just takes the query text and does the same check every time. Now, I want to be able to pass along additional info so different things are looked for with each instance of a search box. The HTML... simple, obvious. input class="suggest" name="q" type="text" autocomplete="off" / The jQuery looks like this: jQuery(document).ready(function() { $('.suggest').autocomplete( { source:'output.php', minLength:3, focus: function (event, ui) { $(event.target).val(ui.item.label); return false; } } ); [snip] } Instead of: source:'output.php', minLength:3, I'd like: source:'output.php?arg1=blah1&arg2=blah2', minLength:3, where arg1 and arg2 are passed along in the form... input class="suggest" name="q" type="text" autocomplete="off" / input type="hidden" name="arg1" value="blah1" input type="hidden" name="arg2" value="blah2" Does this make sense? Thanks guys. I know just about "this much" about OOL's and javascript, so I'm learning... Alex

    Read the article

  • How can I catch runtime error in C++

    - by Yan Cheng CHEOK
    By referring to http://stackoverflow.com/questions/315948/c-catching-all-exceptions try { int i = 0; int j = 0/i; /* Division by 0 */ int *k = 0; std::cout << *k << std::endl; /* De-reference invalid memory location. */ } catch (...) { std::cout << "Opps!" << std::endl; } The above run-time error are unable to be detected. Or, am I having wrong expectation on C++ exception handling feature?

    Read the article

  • Convert wchar_t to char

    - by Yan Cheng CHEOK
    I was wondering is it safe to do so? wchar_t wide = /* something */; assert(wide >= 0 && wide < 256 &&); char myChar = static_cast<char>(wide); If I am pretty sure the wide char will fall within ASCII range.

    Read the article

  • ActionLink sending a model of a complex type

    - by Xenph Yan
    I'm trying to paginate the results of a "advanced search", I have a complex model that represents the search options; int ZipCode int MinAge int MaxAge Availability bool Monday bool Tuesday ... bool Friday Requirements bool FirstAid bool DriversLicense I'm using; <%: Html.ActionLink("Next »", "Save", "Notification", Model.options)%> Which correctly sends all the data at the first level, but anything that is a sub-object (Availability or requirements) isn't expanded in the URL, all I get is the class name and so I lose most of the search options when I click the link to change to a different page. Any thoughts?

    Read the article

  • Sql combine 2 rows to one

    - by Yan
    Hi , i have this table Testers employee name ------------ Sam Korch dan mano i want to combine tow rows to one, it will be "Sam Korch,Dan Mano" i have this query select @theString = COALESCE(@theString + ',', '') + EmployeeName from Testers join vw_EKDIR on Testers.TesterGlobalId = vw_EKDIR.GlobalID where TestId = 31 it working but i dont want to do select i want the result will be in @thestring so i try to do this query set @theString = ( select @theString = COALESCE(@theString + ',', '') + EmployeeName from Testers join vw_EKDIR on Testers.TesterGlobalId = vw_EKDIR.GlobalID where TestId = 31 ) it is not working ... i want @thestring will be the result. any idaes ? thanks

    Read the article

  • Problem in printing array of char pointer passing from Python

    - by Yan Cheng CHEOK
    My following C code works quite well, till my Python code trying to pass an array of char pointer to it. The output I obtain is The file_name is python-file Another 3 string is not being printed out. Anything I had missed out? C Code #include <iostream> #include "c_interface.h" int foo(const char* file_name, const char** names) { std::cout << "The file_name is " << file_name << std::endl; while (*names) { std::cout << "The name is " << *names << std::endl; names++; } return 0; } /* int main() { const char *c[] = {"123gh", "456443432", "789", 0}; foo("hello", c); getchar(); } */ Python Code #!c:/Python27/python.exe -u from ctypes import * name0 = "NAME0" name1 = "NAME1" name2 = "NAME2" names = ((c_char_p * 1024) * 4)() names[0].value = name0 names[1].value = name1 names[2].value = name2 names[3].value = 0 libc = CDLL("foo.dll") libc.foo("python-file", names)

    Read the article

  • AtomicInteger lazySet and set

    - by Yan Cheng CHEOK
    May I know what is the difference among lazySet and set method for AtomicInteger. javadoc doesn't talk much about lazySet : Eventually sets to the given value. It seems that AtomicInteger will not immediately be set to the desired value, but it will be scheduled to be set in some time. But, what is the practical use of this method? Any example?

    Read the article

  • Access Violation When Accessing an STL Object Through A Pointer or Reference In A Different DLL or E

    - by Yan Cheng CHEOK
    I experience the following problem while using legacy VC6. I just cann't switch to modern compiler, as I am working on a legacy code base. http://support.microsoft.com/kb/172396 Since there are no way to export map, my planned workaround is using static linking instead of dynamic linking. I was wondering whether you all had encountered the similar situation? What is your workaround for this? Another workaround is to create wrapper class around the stl map, to ensure creation and accessing stl map, are within the same DLL space. Note that, fun0, which uses wrapper class will just work fine. fun1 will crash. Here is the code example : // main.cpp. Compiled it as exe. #pragma warning (disable : 4786) #include <map> #include <string> template <class K, class V> class __declspec(dllimport) map_wrapper { public: map_wrapper(); ~map_wrapper(); map_wrapper(const map_wrapper&); map_wrapper& operator=(const map_wrapper&); V& operator[](const K&); const V& operator[](const K&) const; const V& get(const K&) const; void put(const K&, const V&); int size() const; private: std::map<K, V> *m; }; __declspec(dllimport) void fun0(map_wrapper<std::string, int>& m); __declspec(dllimport) void fun1(std::map<std::string, int>& m); int main () { map_wrapper<std::string, int> m0; std::map<std::string, int> m1; m0["hello"] = 888; m1["hello"] = 888; // Safe. The we create std::map and access map both in dll space. fun0(m0); // Crash! The we create std::map in exe space, and access map in dll space. fun1(m1); return 0; } // dll.cpp. Compiled it as dynamic dll. #pragma warning (disable : 4786) #include <map> #include <string> #include <iostream> /* In map_wrapper.h */ template <class K, class V> class __declspec(dllexport) map_wrapper { public: map_wrapper(); ~map_wrapper(); map_wrapper(const map_wrapper&); map_wrapper& operator=(const map_wrapper&); V& operator[](const K&); const V& operator[](const K&) const; const V& get(const K&) const; void put(const K&, const V&); int size() const; private: std::map<K, V> *m; }; /* End */ /* In map_wrapper.cpp */ template <class K, class V> map_wrapper<K, V>::map_wrapper() : m(new std::map<K, V>()) { } template <class K, class V> map_wrapper<K, V>::~map_wrapper() { delete m; } template <class K, class V> map_wrapper<K, V>::map_wrapper(const map_wrapper<K, V>& map) : m(new std::map<K, V>(*(map.m))) { } template <class K, class V> map_wrapper<K, V>& map_wrapper<K, V>::operator=(const map_wrapper<K, V>& map) { std::map<K, V>* tmp = this->m; this->m = new std::map<K, V>(*(map.m)); delete tmp; return *this; } template <class K, class V> V& map_wrapper<K, V>::operator[](const K& key) { return (*this->m)[key]; } template <class K, class V> const V& map_wrapper<K, V>::operator[](const K& key) const { return (*this->m)[key]; } template <class K, class V> const V& map_wrapper<K, V>::get(const K& key) const { return (*this->m)[key]; } template <class K, class V> void map_wrapper<K, V>::put(const K& key, const V& value) { (*this->m)[key] = value; } template <class K, class V> int map_wrapper<K, V>::size() const { return this->m->size(); } // See : http://www.parashift.com/c++-faq-lite/templates.html#faq-35.15 // [35.15] How can I avoid linker errors with my template classes? template class __declspec(dllexport) map_wrapper<std::string, int>; /* End */ __declspec(dllexport) void fun0(map_wrapper<std::string, int>& m) { std::cout << m["hello"] << std::endl; } __declspec(dllexport) void fun1(std::map<std::string, int>& m) { std::cout << m["hello"] << std::endl; }

    Read the article

  • Rails 3 : Can't get form_for to work as a 'delete' following the RESTful achitecture => always giving a ROUTING ERROR

    - by Alex
    I have a very simple render that goes as follow: <%= form_for(:relationships, :url => relationships_path, :html => {:method => 'delete'}) do |f| %> <div><%= f.hidden_field :user_id_to_unfollow, :value => @user.id %></div> <div class="actions"><%= f.submit "Unfollow" %></div> <% end %> When I submit this form it will always give me a Routing Error No route matches "/relationships" on my page. In my relationships controller, I have created all the propers methods: def create ... end def destroy ... end def update ... end def show ... end And in my routes config I have made sure to allow all routes for the relationships controller resources :relationships But I can't seem to get into the destroy method of the controller :( However if I remove the :html => {:method => 'delete'} method parameter in the form_for then I get to the create method of the controller no pb. I don't get it.... Alex

    Read the article

  • What is the best way to create a wizard in C# for web?

    - by Yan
    Hi , i want to create a wizard the include a few steps ,that in the final steps we need to include all the steps and save on the data base. what is the best design to do this ? there is implemante for a jquery ? i need to save the steps in sessions till the final save ? thanks !!!!

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >