各位大虾好. 我这里有个用户界面要用JAVA实现, 用JAVA也没有做过什么大东东, 书倒是看过几本. 但是没有思路该怎么做. 所以希望大家可以给我思路和建议. 界面如下
http://service.gmx.net/mc/L6kVrJ4RbY2jlleNAVBdM04dKgQDHd最好大家可以详细说说, 应该由什么部件组成等等. 有原代码做范例那就是太好了. 谢谢..
http://service.gmx.net/mc/L6kVrJ4RbY2jlleNAVBdM04dKgQDHd最好大家可以详细说说, 应该由什么部件组成等等. 有原代码做范例那就是太好了. 谢谢..
楼主要做一个数字信号处理方面的软件吧
整体上可以用一个可滚动的panel做,界面上使用liquid或者substance的皮肤达到图中的效果。
其中需要输入公式和文字的部分可以用jTextField或者jTextArea实现,对输入进行一定处理并且把图片画到panel上,然后把重构panel的paint(Graphics g)方法,在上面画图。
这里可能有个问题,就是信息处理方面的图形一般比较复杂,单靠java的函数可能比较困难,楼主可以考虑集成一些函数处理能力强的软件。
这个界面提供对于语音信号进行回放,
用户按照自己的要求在界面下方可以对语音信号进行时间段的分割 和注释我所不清楚的地方
1。 如何将 .wav文件如同图片里显示的那样展示出来,(我的想法是用JFreeChart, 但是怎么把.wav文件转换成JFreeChart识别的格式, 大家是否知道。)
3。 用户需要选定一个时间段, 如何在java中实现(如果使用JFreeChart,如何实现选取的操作)。2。 用户需要8种分割方式, 在图片的中下方可见。 比如 vowels等等。 在java中如何实现(我的想法是用table, 添加8行。 不过如何和用户在JFreeChart上选取时间段的操作, 进行关联。 大家是否有好的建)
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Sub Command1_Click()
Dim LastX, LastY, CurX, CurY As Byte
CommonDialog1.ShowOpen
Form1.Caption = CommonDialog1.FileName & " - Graphical Wave"
If CommonDialog1.CancelError = True Or CommonDialog1.FileName = "" Then Exit Sub
'If the user pressed cancel or didn't se
' lect anything then exit this sub
On Error Resume Next
Picture1.Width = FileLen(CommonDialog1.FileName)
'Makes the invisible picturebox the widt
' h of the size of the .wav file
Open CommonDialog1.FileName For Binary As #1
Get #1, 44, LastY
'Gets the 44th byte of the .wav file (th
' at is where the sound information that w
' e are
'interested in starts)
LastX = 0
For i = 45 To FileLen(CommonDialog1.FileName)
'Loops through each byte (after 44) of t
' he file
Get #1, i, CurY
Picture1.Line (LastX, LastY + 22)-(i, CurY + 22), 0
'Draws a line in the invisible picturebo
' x using the data we read from the file
LastX = i
LastY = CurY
Next i
Close #1
StretchBlt Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbSrcCopy
Picture2.Refresh
'This just copies the area of picture1 i
' nto picture2, so that you can see the wh
' ole Wave
End Sub
Private Sub Form_Load()
Form1.ScaleMode = vbPixels
Picture1.AutoRedraw = True
Picture1.ScaleMode = vbPixels
Picture1.Visible = False
Picture1.Height = 300
Picture1.BackColor = vbWhite
Picture2.AutoRedraw = True
Picture2.ScaleMode = vbPixels
Command1.Caption = "Load .wav"
CommonDialog1.Filter = "Wave Files (.wav) | *.wav"
End Sub
Private Sub Form_Resize()
Picture2.Move 0, Command1.Height, Form1.ScaleWidth, Form1.ScaleHeight
Command1.Move 0, 0, Form1.ScaleWidth, Command1.Height
'Stretches the visible picturebox and th
' e commandbutton to fit the form
End Sub
画WAV的图形函数:
//***********************************************************************//
// //
// 画全部音频数据的波形 //
// 参数: //
// Dw_Type : 波形显示数据记录 //
// WaveMin : 波形数据的最小值 //
// WaveMax : 波形数据的最大值 //
// DrawLineColor : 画波形的颜色 //
// DrawBackColor : 画波形的背景颜色 //
// Draw : 是否画波形 //
// 返回值: 无 //
// //
//***********************************************************************//
procedure DrawAllWave(Dw_Type: TDrawWave_Type; var WaveMin, WaveMax: LongInt;
DrawLineColor, DrawBackColor: TColor; Draw: Boolean = True);
var
Buf: PChar;
i, Loop, j, k, lmax, lmin: LongInt;
Max, Min: LongInt;
X, Y: SmallInt;
DrawLoop: LongInt;
MODDrawSize: LongInt;
LoadSize: LongInt;
hFile: Integer;
begin
Application.ProcessMessages;hFile := 0;DrawLoop := Dw_Type.Length DIV LoadMemSize;
MODDrawSize := 0;
if (Dw_Type.Length MOD LoadMemSize) <> 0 then
begin
DrawLoop := DrawLoop + 1;
MODDrawSize := Dw_Type.Length MOD LoadMemSize;
end;SendMessage(Application.MainForm.Handle, CM_BEGINDRAW, DrawLoop * 3, 0);with Dw_Type.DesBitMap do
begin
Width := Dw_Type.DW;
Height := Dw_Type.DH;
Canvas.Brush.Color := DrawBackColor;
Canvas.Brush.Style := bsSolid;
Canvas.Pen.Color := DrawLineColor;
Canvas.Pen.Mode := pmCopy;
Canvas.FillRect(Rect(0, 0, Dw_Type.DW, Dw_Type.DH));
end;if Dw_Type.Length = 0 then
begin
BitBlt(Dw_Type.DesCanvas.Handle, 0, 0, Dw_Type.DW, Dw_Type.DH,
Dw_Type.DesBitMap.Canvas.Handle, 0, 0, SRCCOPY);
Exit;
end;case Dw_Type.FileType of //不同的方式,打开不同的文件
//移到文件音频数据开始处
CS_SAVE_PLAY: mmioseek(Dw_Type.hio, Dw_Type.Length, SEEK_END); //播方方式
CS_SAVE_RECORD: hFile := FileOpen(Dw_Type.FileName, fmOpenRead); //录音方式
end;Max := -32768;
Min := 32767;Try
for Loop := 1 to DrawLoop do
begin
if (MODDrawSize <> 0) AND (Loop = DrawLoop) then
LoadSize := MODDrawSize //要播放的音频数据的长度
else
LoadSize := LoadMemSize;
//开辟内存
Buf := PChar(GlobalAllocPtr(GMEM_MOVEABLE or GMEM_SHARE, LoadMemSize));if Buf = NIL then
raise EMMIO.Create('不能分配内存!');Try
case Dw_Type.FileType of //读音频数
CS_SAVE_PLAY: mmioRead(Dw_Type.hio, Buf, LoadSize);
CS_SAVE_RECORD: FileRead(hFile, Buf^, LoadSize);
end;if Dw_Type.Length <= LoadMemSize then //假如小于区域长度的最大长度
begin //画区域波形
DrawPartWave(Dw_Type.Flag, Buf, Dw_Type.Length, Dw_Type.DesCanvas,
Dw_Type.DH, Dw_Type.DW, Dw_Type.DesBitMap, DrawLineColor,
DrawBackColor, Draw);
WaveMin := DrawMin;
WaveMax := DrawMax;
SendMessage(Application.MainForm.Handle, CM_DRAWPosI, DrawLoop * 3, 0);
SendMessage(Application.MainForm.Handle, CM_ENDDRAW, 0, 0);
FileClose(hFile);
Exit;
end;for i := 0 to (LoadSize div 2 - 1) do
begin //取最大最小值
j := PCMInt(PChar(Buf)+ i * 2)^;
if j > Max then Max := j;
if j < Min then Min := j;
end;
Finally
GloBalFreePtr(Buf);
end;
SendMessage(Application.MainForm.Handle, CM_DRAWPosI, DrawLoop, 0);
end;
Finally
FileClose(hFile);
end;WaveMin := Min;
WaveMax := Max;if Not Draw then
begin
if Dw_Type.FileType = CS_SAVE_RECORD then FileClose(hFile);
SendMessage(Application.MainForm.Handle, CM_ENDDRAW, 0, 0);
Exit;
end;Max := Max - Min;
Dw_Type.DesBitMap.Canvas.MoveTo(0, Dw_Type.DH div 2);
j := 0;
X := 0;
lmax := 0;
lmin := 32767;hFile := 0;case Dw_Type.FileType of //移到文件开始处
CS_SAVE_PLAY: mmioseek(Dw_Type.hio, Dw_Type.Length, SEEK_END);
CS_SAVE_RECORD: hFile := FileOpen(Dw_Type.FileName, fmOpenRead);
else
hFile := 0;
end;Try
for Loop := 1 to DrawLoop do
begin
if (MODDrawSize <> 0) AND (Loop = DrawLoop) then
begin
//开辟内存
Buf := PChar(GlobalAllocPtr(GMEM_MOVEABLE or GMEM_SHARE, MODDrawSize));
LoadSize := MODDrawSize; //要播放的音频数据的长度
end
else begin
Buf := PChar(GlobalAllocPtr(GMEM_MOVEABLE or GMEM_SHARE, LoadMemSize));
LoadSize := LoadMemSize;
end;if Buf = NIL then
raise EMMIO.Create('不能分配内存!');Try
case Dw_Type.FileType of
CS_SAVE_PLAY: mmioRead(Dw_Type.hio, Buf, LoadSize);
CS_SAVE_RECORD: FileRead(hFile, Buf^, LoadSize);
end;
for i := 0 to (LoadSize div 2 - 1 ) do
begin
if j < (Dw_Type.Flag - 1) then //在同一周期内
begin
INC(j);
end
else begin
j := 0;
X := X + 1;
lmax := 0;
lmin := 32767;
end;
if Max <> 0 then
Y := Abs(PCMInt(PChar(Buf) + i * 2)^ - Min) * Dw_Type.DH div Max
else
Y := Dw_Type.DH div 2;k := 0;
if Y > lmax then
begin
lmax := Y;
k := 1;
end;
if Y < lmin then
begin
lmin := Y;
k := 1;
end;
if k = 1 then
Dw_Type.DesBitMap.Canvas.LineTo(X, Y);
if X > Dw_Type.DW then break;
end;
Finally
GloBalFreePtr(Buf);
end;
SendMessage(Application.MainForm.Handle, CM_DRAWPosI, DrawLoop + Loop * 2 , 0);
end;
Finally
FileClose(hFile);
end;//复制图像
BitBlt(Dw_Type.DesCanvas.Handle, 0, 0, Dw_Type.DW, Dw_Type.DH,
Dw_Type.DesBitMap.Canvas.Handle, 0, 0, SRCCOPY);
SendMessage(Application.MainForm.Handle, CM_ENDDRAW, 0, 0);
end;
4Long文件长度(比实际长度小6)
4Char[4]WAVE标志“WAVE”
4Char[4]Fmt标志“FMT”
4Long以下描述占用空间
2ShortWAVE格式类别
2Short声道数
4Long采样率
4Long数据传送率
2Short块调整值
2Short采样位数
2Short暂时未用,值为0
4Char[4]暂时未用,值为“fact”
4LongWAVE标志,值为4
4Char[4]暂时未用
4Char[4]DATA标志,“data”
4Long数据区长度